rlcevg / CircuitAI

Spring RTS local native AI
GNU General Public License v2.0
18 stars 19 forks source link

Circuit doesn't work when loading an engine savegame. #101

Closed GoogleFrog closed 5 years ago

GoogleFrog commented 5 years ago

See https://springrts.com/mantis/view.php?id=6222

rlcevg commented 5 years ago

Probably in ssf no one informed AI that it has units, while with ZK's handling of slsf for each unit AI receives UnitCreated or UnitFinished event. Should be fixable AI-side by querying all friendly (own) units on Load event. @GoogleFrog, so what's ssf and is slsf going to be deprecated for good?

GoogleFrog commented 5 years ago

ssf is the new save format that makes creating a Spring game with save/load support just as easy as creating a Spring game that can be played multiplayer, or that has replays. As far as I can tell it is supposed to save and load everything that could impact the sync state of the game. Notably, it compresses and saves the whole lua state, so game devs shouldn't need to worry much about how the saves work. It's quite a big feature to have automatically included in an RTS engine.

I have not looked too closely at the details as I am mainly focused on being able to use it. I don't know whether it syncs perfectly, or what sort of unsynced information it saves. It would be nice if it saved things like control groups.

I expect slsf to be deprecated eventually, but I don't want to deprecate it any time soon. Trying to simultaneously update two systems which are mutually incompatible with old versions is a recipe for disaster, so I would like Circuit to support both save formats. I also can't rule of the possibility that ssf will have an unexpected issue after it appears stable, so I will keep the slsf code around for at least a few months.

I think you should talk to hokomoko about what is required, as I don't think any one person has a full idea of what changes are required in AI or the engine to make Circuit work with ssf.

rlcevg commented 5 years ago

savegame from OP crashes for me with

Thread 1 "spring-main" received signal SIGSEGV, Segmentation fault.
0x0000555555b02c66 in creg::CInputStreamSerializer::SerializeObjectInstance (this=0x7fffffffd160, inst=0x5555c57b41e0, cls=0x5555569e1d60 <creg_TValue::creg_class>)
    at .../games/spring/spring/rts/System/creg/Serializer.cpp:485
485             o.obj = inst;
(gdb) bt
#0  0x0000555555b02c66 in creg::CInputStreamSerializer::SerializeObjectInstance (this=0x7fffffffd160, inst=0x5555c57b41e0, cls=0x5555569e1d60 <creg_TValue::creg_class>)
    at .../games/spring/spring/rts/System/creg/Serializer.cpp:485
#1  0x0000555555afe1f1 in SerializeCVector<creg_TValue, int> (count=<optimized out>, vecPtr=0x5555ca5cccf8, s=0x7fffffffd160) at /usr/include/c++/8.3.0/bits/unique_ptr.h:342
#2  creg_Table::Serialize (this=0x5555ca5ccce0, s=0x7fffffffd160) at .../games/spring/spring/rts/System/creg/SerializeLuaState.cpp:758
#3  0x0000555555b03257 in creg::CInputStreamSerializer::LoadPackage (this=this@entry=0x7fffffffd160, s=s@entry=0x555599408718, root=@0x7fffffffd0c8: 0x5555cae07100, 
    rootCls=@0x7fffffffd0d0: 0x0) at .../games/spring/spring/rts/System/creg/Serializer.cpp:574
#4  0x0000555555abd142 in LoadLuaState (handle=0x5555bef73640, is=..., iss=...) at .../games/spring/spring/rts/System/LoadSave/CregLoadSaveHandler.cpp:178
#5  0x0000555555abef1b in CCregLoadSaveHandler::LoadGame (this=0x5555994086b0) at .../games/spring/spring/rts/System/LoadSave/CregLoadSaveHandler.cpp:325
#6  0x00005555556e6172 in CGame::LoadGame (this=0x555599a12480, mapFileName="maps/Battle for PlanetXVII-v01.smf") at .../games/spring/spring/rts/Game/Game.cpp:421
#7  0x00005555557084a6 in CLoadScreen::Init (this=0x555599f550b0) at .../games/spring/spring/rts/Game/LoadScreen.cpp:136
#8  0x00005555557085d9 in CLoadScreen::CreateDeleteInstance (mapFileName=..., modFileName=..., saveFile=<optimized out>)
    at .../games/spring/spring/rts/Game/LoadScreen.cpp:183
#9  0x0000555555711625 in CPreGame::UpdateClientNet (this=<optimized out>) at .../games/spring/spring/rts/Game/PreGame.cpp:388
#10 0x00005555557127e8 in CPreGame::Update (this=0x555599e19970) at .../games/spring/spring/rts/Game/PreGame.cpp:185
#11 0x0000555555add990 in SpringApp::Update (this=this@entry=0x7fffffffe4d0) at .../games/spring/spring/rts/System/SpringApp.cpp:763
#12 0x0000555555ae12b0 in SpringApp::Run (this=this@entry=0x7fffffffe4d0) at .../games/spring/spring/rts/System/SpringApp.cpp:802
#13 0x0000555555aca6e0 in Run (argc=2, argv=0x7fffffffe6a8) at .../games/spring/spring/rts/System/Main.cpp:43
#14 0x000055555569889a in main (argc=2, argv=0x7fffffffe6a8) at .../games/spring/spring/rts/System/Main.cpp:94

it is modified 104.0.1-1239-g12caea1 compiled with gcc 8.3.0 version: disabled checksum test because otherwise i can't add debug stuff and loading always fails with "Metadata checksum error: Package file was saved with a different version"

ashdnazg commented 5 years ago

better use a new engine with a new save

rlcevg commented 5 years ago

@GoogleFrog, question about DISABLE_CONTROL LuaMessage: is there unit-rules-param for this? Current fix registers all own units returned by the engine, and i'm looking for quick solution to not register units that were given DISABLE_CONTROL message.

GoogleFrog commented 5 years ago

No, but I can make one called "disableAiControl".

rlcevg commented 5 years ago

https://github.com/rlcevg/CircuitAI/commit/30555caa14f4cc1ac28ea1cf2b095d26b6dcd38c