Closed Spikeone closed 6 months ago
Replay is also crashing: 2022-04-10_23-33-01.zip
Just checked by running from visual studio, this doesn't seem to be related to LUA scripting but a more general problem which I do not fully understand :-/
I think what happens here, is that there is a flag at 88,7.
When loading the savegame, MissionEvent(e=1)
is triggered, which adds a static object of size 2.
rttr:GetWorld():AddStaticObject(89, 8, 560, 0xFFFF, 2)
This causes the removal of the flag. Unfortunately, at that moment there is already a worker carrying something to that flag. When he reaches it and wants to place his goods, we have a nullptr dereference.
The lua doc says e=1
is an initial event.
I guess this should only be called when the game starts and not on every loading of a savegame.
Good find @wichern I guess - never understood the stack trace correctly.
I'm still confused since when having a look at the script, from the very beginning MissionEvent(1)
has been called. That means rttr:GetWorld():AddStaticObject(89, 8, 560, 0xFFFF, 2)
should work just fine - since an object should block all the space it requires. Although the MissionEvent(99)
calls rttr:GetWorld():AddStaticObject(89, 8, 561, 0xFFFF, 2)
as well, this shouldn't be a problem.
So maybe for this bug here, the root cause then is #1516 - maybe roads are removed when placing the object, but spots are not blocked correctly, thus leading to the crash.
The build locations for portals are strange. And they get even stranger, when building/removing stuff around them. Seems they bend time and space :)
I tried with this change, and it seems to solve the issue of adding building quality by just removing/adding things. I did not really understand what happens though.
I tried with this change, and it seems to solve the issue of adding building quality by just removing/adding things. I did not really understand what happens though.
This might actually be 2 different issues, depending on what we want as the end result. If your third image is the correct BQ then this part of the code must not change. I think the issue is that not enough BQ points are updated when the object is placed. So we need to update more at https://github.com/Return-To-The-Roots/s25client/blob/12f0c5fbb5ab130dc43172519ebcfbb511222509/libs/s25main/lua/LuaWorld.cpp#L87 possibly depending on the size (0=no call, 1= current call, 2=RecalcBQAroundPointBig
, maybe just no or RecalcBQAroundPointBig
)
The castle-like blocking behavior is achieved by "noExtension
" instances: https://github.com/Return-To-The-Roots/s25client/blob/12f0c5fbb5ab130dc43172519ebcfbb511222509/libs/s25main/nodeObjs/noStaticObject.cpp#L35
probably fixed by #1647 - thanks to @wichern
This is a savegame of a scripted map - it always crashes after some GF. Not sure what the cause is, the console does not indicate a LUA error.
4.zip WORLDS.zip