A fork of The Ur-Quan Masters + HD-mod that remasters the HD graphics with a veritable smorgasbord of extra features, options, QoL improvements, and much more...
MegaMod supports reading five different variants of saved game states corresponding to Vanilla UQM 0.7, MegaMod/HD 0.7 (added autopilot and QS portal flags), UQM 0.8 (moving all the GRPOFFS to the end), MM 0.8.0.85 (autopilot/portals), and MM 0.8.1 (visited systems, homeworlds). Combined with the original #defines in globdata.h this makes for six complete copies of the entire list of game state flags, and following this scheme, adding additional flags (such as for an in-game Journal...) would have required a seventh copy, and even messier logic for detecting the variant during game load.
This patch consolidates the game states to three copies: the globdata.h symbols, the current GameStateBitMap array in save.c, and the legacy array in load_legacy.c (with the old GRPOFFS positions). Within the two GameStateBitMap arrays, I have simply added delimiters to mark the cut-off points for the various previous releases. All functions that handle GameStateBitMap arrays now recognize a revision number corresponding to one of these cut-off points, and when working with an older revision, simply behave as if the array ends sooner.
This change incidentally also fixes a bug in MegaMod 0.8.1 which illustrates one of the pitfalls of the previous scheme: 32 new 'RESERVED' bits were added to the primary array in 0.8.1, but in LoadGameState(), the difference in bit count between core and MM game states was hard-coded and not updated from 556 to 588. Consequently, MegaMod 0.8.1 fails to load core saved games because it expects too many bytes. The updated logic computes the expected bit count by counting forward to the appropritae delimiter, rather than deducting a hard-coded difference from the latest total, so adding new flags to the end (as long as they're preceeded by a new delimiter) won't cause this issue in the future.
MegaMod supports reading five different variants of saved game states corresponding to Vanilla UQM 0.7, MegaMod/HD 0.7 (added autopilot and QS portal flags), UQM 0.8 (moving all the GRPOFFS to the end), MM 0.8.0.85 (autopilot/portals), and MM 0.8.1 (visited systems, homeworlds). Combined with the original
#define
s inglobdata.h
this makes for six complete copies of the entire list of game state flags, and following this scheme, adding additional flags (such as for an in-game Journal...) would have required a seventh copy, and even messier logic for detecting the variant during game load.This patch consolidates the game states to three copies: the
globdata.h
symbols, the currentGameStateBitMap
array insave.c
, and the legacy array inload_legacy.c
(with the old GRPOFFS positions). Within the twoGameStateBitMap
arrays, I have simply added delimiters to mark the cut-off points for the various previous releases. All functions that handleGameStateBitMap
arrays now recognize arev
ision number corresponding to one of these cut-off points, and when working with an older revision, simply behave as if the array ends sooner.This change incidentally also fixes a bug in MegaMod 0.8.1 which illustrates one of the pitfalls of the previous scheme: 32 new 'RESERVED' bits were added to the primary array in 0.8.1, but in
LoadGameState()
, the difference in bit count between core and MM game states was hard-coded and not updated from 556 to 588. Consequently, MegaMod 0.8.1 fails to load core saved games because it expects too many bytes. The updated logic computes the expected bit count by counting forward to the appropritae delimiter, rather than deducting a hard-coded difference from the latest total, so adding new flags to the end (as long as they're preceeded by a new delimiter) won't cause this issue in the future.