dewiniaid / BlueprintExtensions

Useful blueprinting tools for Factorio
Other
4 stars 8 forks source link

[0.4.3] Crash when loading vanilla save with BP Extentions. #12

Closed PiggyWhiskey closed 5 years ago

PiggyWhiskey commented 5 years ago

I'm trying to load a test world, that has SignleColorTerrain and Creative Mod.

The loaded modpack has BP Extensions 0.4.3.

Crash as shown: image

Console Log as show:

 244.360 Script @__BlueprintExtensions__/modules/landfill.lua:43: Computing collision box overrides...
 244.733 Error AppManagerStates.cpp:1397: The mod Blueprint Extensions caused a non-recoverable error.
Please report this error to the mod author.

Error while running event BlueprintExtensions::on_configuration_changed
Invalid surface name: Surface names must not be blank and must be unique.
stack traceback:
    __BlueprintExtensions__/modules/landfill.lua:46: in function '?'
    __BlueprintExtensions__/control.lua:60: in function 'call_module_methods'
    __BlueprintExtensions__/control.lua:96: in function <__BlueprintExtensions__/control.lua:93>
stack traceback:
    [C]: in function 'create_surface'
    __BlueprintExtensions__/modules/landfill.lua:46: in function '?'
    __BlueprintExtensions__/control.lua:60: in function 'call_module_methods'
    __BlueprintExtensions__/control.lua:96: in function <__BlueprintExtensions__/control.lua:93>
AlienXAXS commented 5 years ago

I am also getting the same issue, my guess is that during Migrations the surface can possibly still exist.

Changing line 46 inside landfill.lua to the following should fix the issue: local surface = game.get_surface("_BPEX_Temp_Surface") or game.create_surface("_BPEX_Temp_Surface")

That is, assuming you dont want to re-create the surface from scratch.

dewiniaid commented 5 years ago

Duplicate of #10, which I am currently working on.

dewiniaid commented 5 years ago

This code is not called during migrations.

The issue is that Landfill.compute_prototype_overrides() can be called twice in one tick -- once from on_init and once from on_configuration_changed, and a deleted surface isn't actually deleted until the next tick. The function is supposed to have a guard against being called more than once, but for whatever reason the guard is not working -- so it fails the second time it is called.

@AlienXAXS, your workaround may actually work, but it's not the best fix (the code doesn't need to run twice!) so I'm working on a better one.

Also, this entire mess is only present because of the Factorio API giving bad information when I ask it for collision boxes on entities that aren't actually placed so I have to workaround it myself.

PiggyWhiskey commented 5 years ago

Issue has re-emerged in 0.4.4

Established Save. Added mod (Alone in the Dark) Loaded Save

image