diff options
author | Paul Gilbert | 2019-07-06 17:59:39 -0700 |
---|---|---|
committer | Paul Gilbert | 2019-07-06 17:59:39 -0700 |
commit | 2fd5d82078605b17d59343dd2f6b55d75e86601b (patch) | |
tree | 098f8dec5d32ca7da34cdfdea848bbdc013af801 /engines/glk/alan2 | |
parent | 0a6f015a862747df716d310dd98df9a572a9dfbe (diff) | |
download | scummvm-rg350-2fd5d82078605b17d59343dd2f6b55d75e86601b.tar.gz scummvm-rg350-2fd5d82078605b17d59343dd2f6b55d75e86601b.tar.bz2 scummvm-rg350-2fd5d82078605b17d59343dd2f6b55d75e86601b.zip |
GLK: ALAN3: Refactoring save code to see if it fixes openpandora gcc
Diffstat (limited to 'engines/glk/alan2')
-rw-r--r-- | engines/glk/alan2/alan2.cpp | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/engines/glk/alan2/alan2.cpp b/engines/glk/alan2/alan2.cpp index 7e942b15e5..9b2478fd4f 100644 --- a/engines/glk/alan2/alan2.cpp +++ b/engines/glk/alan2/alan2.cpp @@ -124,57 +124,64 @@ void syncVal(Common::Serializer &s, uint32 *fld) { s.syncAsUint32LE(v); } -void Alan2::synchronizeSave(Common::Serializer &s) { - AtrElem *atr; - Aword i; - - // Sync current values - cur.synchronize(s); - - // Save actors - for (i = ACTMIN; i <= ACTMAX; ++i) { +static void syncActors(Common::Serializer &s) { + for (uint i = ACTMIN; i <= ACTMAX; ++i) { syncVal(s, &acts[i - ACTMIN].loc); syncVal(s, &acts[i - ACTMIN].script); syncVal(s, &acts[i - ACTMIN].step); syncVal(s, &acts[i - ACTMIN].count); if (acts[i - ACTMIN].atrs) { - for (atr = (AtrElem *)addrTo(acts[i - ACTMIN].atrs); !endOfTable(atr); ++atr) + for (AtrElem *atr = (AtrElem *)addrTo(acts[i - ACTMIN].atrs); !endOfTable(atr); ++atr) syncVal(s, &atr->val); } } +} - // Sync locations - for (i = LOCMIN; i <= LOCMAX; ++i) { +static void syncLocations(Common::Serializer &s) { + for (uint i = LOCMIN; i <= LOCMAX; ++i) { syncVal(s, &locs[i - LOCMIN].describe); if (locs[i - LOCMIN].atrs) - for (atr = (AtrElem *)addrTo(locs[i - LOCMIN].atrs); !endOfTable(atr); atr++) + for (AtrElem *atr = (AtrElem *)addrTo(locs[i - LOCMIN].atrs); !endOfTable(atr); atr++) syncVal(s, &atr->val); } +} - // Sync objects - for (i = OBJMIN; i <= OBJMAX; ++i) { +static void syncObjects(Common::Serializer &s) { + for (uint i = OBJMIN; i <= OBJMAX; ++i) { syncVal(s, &objs[i - OBJMIN].loc); if (objs[i - OBJMIN].atrs) - for (atr = (AtrElem *)addrTo(objs[i - OBJMIN].atrs); !endOfTable(atr); atr++) + for (AtrElem *atr = (AtrElem *)addrTo(objs[i - OBJMIN].atrs); !endOfTable(atr); atr++) syncVal(s, &atr->val); } +} - // Sync the event queue +static void syncEventQueue(Common::Serializer &s) { if (s.isSaving()) { eventq[etop].time = 0; // Mark the top - for (i = 0; i <= (Aword)etop; ++i) + for (int i = 0; i <= etop; ++i) eventq[i].synchronize(s); } else { for (etop = 0; eventq[etop - 1].time; ++etop) eventq[etop].synchronize(s); --etop; } +} - // Sync scores - for (i = 0; scores[i] != EOD; i++) +static void syncScores(Common::Serializer &s) { + for (int i = 0; scores[i] != EOD; i++) syncVal(s, &scores[i]); } +void Alan2::synchronizeSave(Common::Serializer &s) { + // Sync various savegame data + cur.synchronize(s); + syncActors(s); + syncLocations(s); + syncObjects(s); + syncEventQueue(s); + syncScores(s); +} + } // End of namespace Alan2 } // End of namespace Glk |