Comment 3 for bug 1311244

Revision history for this message
SirVer (sirver) wrote :

Should be fixed in 6965 (which broke savegame compatibility again). I was unable to reproduce the problem in a test case though, so I theorycrafted the solution.

The problem was that on each Coroutine game command, the whole coroutine was saved into the savegame. This was bad for multiple reasons, one was that the single global Lua state was fractured into many lua states on save and we hoped for the best when loading to reassemble a single state.

In r6965 I changed the code to only save the global lua state once - but inside the luastate (in a global table named __coroutine_registry) we keep a reference to each coroutine. When we now save a 'coroutine' we only save the index of its reference into this table. On load, we must make sure that the global lua state is loaded before any coroutine cmdqueue is loaded, but then restoring these commands is simply looking up the index that we saved to the file and we have the coroutine again.

This is an awesome fix: it is more correct, faster, results in smaller save games and is simpler in the code.

I think this should fix these problems. Playtesting would be very much appreciated because as said, I was unable to construct a test case.