andrei-drexler / ironwail

High-performance QuakeSpasm fork
GNU General Public License v2.0
530 stars 49 forks source link

Save/Load does not preserve Coop flag, causing model index issues. #170

Open Lain-tf opened 1 year ago

Lain-tf commented 1 year ago

Before restart and load: ironwail0000 Skill 3; Coop 1

After restart and load: ironwail0001 Skill 3; Coop 0

Anything with a model is effected, and it only seems to shift the models, items like the Grenade Launcher in the above image are still nail pickups.

4LT commented 1 year ago

This could conceivably be caused by the Quake C code. If you are pre-caching models in co-op mode and not without co-op mode, or vice-versa, or you load the models in a different order with co-op mode on, then the model indices will be different for the models.

Also, I notice that while a game saved in co-op mode will load with the coop cvar set to 0, co-op mode is still apparently still active (respawn is enabled). That part sounds like an engine bug.

4LT commented 1 year ago

@andrei-drexler This is a really stupid fix, but it does fix the issue. I'd post a pull request, but I'm sure you could do better.

https://github.com/andrei-drexler/ironwail/compare/master...4LT:ironwail:restore-coop-cvar

Apparently entities are spawned before globals are read, and the entity spawn behavior depends on the value of the "coop" global. I noticed that loading the savegame works if the coop cvar is 1, so my fix (hack) is to check if the savegame coop field matches the cvar, and if not, call the Host_Loadgame_f function again.

Oh yeah, this assumes that the expected/desired behavior is to load the coop flag from saves. I assume it should, as that would bring it in parity with the skill field.

[EDIT]

Arguments AGAINST this "fix":

If you load a game with the co-op flag set, starting a subsequent new game will start in co-op mode.