diff options
author | dreammaster | 2019-06-22 03:41:11 +0100 |
---|---|---|
committer | Paul Gilbert | 2019-06-22 14:40:50 -0700 |
commit | a3fa9d12a94494f86134f56df6c064d7e48e8580 (patch) | |
tree | 7de5f43a53a281039bfa574ccd7bcc91efa84cf6 | |
parent | dd4108e7c79770ec8235bd4440e0cdc06becd9d9 (diff) | |
download | scummvm-rg350-a3fa9d12a94494f86134f56df6c064d7e48e8580.tar.gz scummvm-rg350-a3fa9d12a94494f86134f56df6c064d7e48e8580.tar.bz2 scummvm-rg350-a3fa9d12a94494f86134f56df6c064d7e48e8580.zip |
GLK: ALAN2: Fix gcc errors for references to packed struct fields
-rw-r--r-- | engines/glk/alan2/alan2.cpp | 26 | ||||
-rw-r--r-- | engines/glk/alan2/types.cpp | 28 |
2 files changed, 33 insertions, 21 deletions
diff --git a/engines/glk/alan2/alan2.cpp b/engines/glk/alan2/alan2.cpp index 73b8a5e1a3..05e52335b5 100644 --- a/engines/glk/alan2/alan2.cpp +++ b/engines/glk/alan2/alan2.cpp @@ -91,6 +91,12 @@ Common::Error Alan2::writeGameData(Common::WriteStream *ws) { return Common::kNoError; } +// This works around gcc errors for passing packed structure fields +void syncVal(Common::Serializer &s, uint32 *fld) { + uint32 &v = *fld; + s.syncAsUint32LE(v); +} + void Alan2::synchronizeSave(Common::Serializer &s) { AtrElem *atr; int i; @@ -100,31 +106,31 @@ void Alan2::synchronizeSave(Common::Serializer &s) { // Save actors for (i = ACTMIN; i <= ACTMAX; ++i) { - s.syncAsSint32LE(acts[i-ACTMIN].loc); - s.syncAsSint32LE(acts[i-ACTMIN].script); - s.syncAsSint32LE(acts[i-ACTMIN].step); - s.syncAsSint32LE(acts[i-ACTMIN].count); + 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) - s.syncAsSint32LE(atr->val); + syncVal(s, &atr->val); } } // Sync locations for (i = LOCMIN; i <= LOCMAX; ++i) { - s.syncAsSint32LE(locs[i-LOCMIN].describe); + syncVal(s, &locs[i-LOCMIN].describe); if (locs[i-LOCMIN].atrs) for (atr = (AtrElem *)addrTo(locs[i-LOCMIN].atrs); !endOfTable(atr); atr++) - s.syncAsSint32LE(atr->val); + syncVal(s, &atr->val); } // Sync objects for (i = OBJMIN; i <= OBJMAX; ++i) { - s.syncAsSint32LE(objs[i-OBJMIN].loc); + syncVal(s, &objs[i-OBJMIN].loc); if (objs[i-OBJMIN].atrs) for (atr = (AtrElem *)addrTo(objs[i-OBJMIN].atrs); !endOfTable(atr); atr++) - s.syncAsSint32LE(atr->val); + syncVal(s, &atr->val); } // Sync the event queue @@ -140,7 +146,7 @@ void Alan2::synchronizeSave(Common::Serializer &s) { // Sync scores for (i = 0; scores[i] != EOF; i++) - s.syncAsSint32LE(scores[i]); + syncVal(s, &scores[i]); } bool Alan2::is_gamefile_valid() { diff --git a/engines/glk/alan2/types.cpp b/engines/glk/alan2/types.cpp index 8419e33ff4..9ce4a657b0 100644 --- a/engines/glk/alan2/types.cpp +++ b/engines/glk/alan2/types.cpp @@ -25,21 +25,27 @@ namespace Glk { namespace Alan2 { +// This works around gcc errors for passing packed structure fields +static void syncVal(Common::Serializer &s, int *fld) { + int &v = *fld; + s.syncAsSint32LE(v); +} + void CurVars::synchronize(Common::Serializer &s) { - s.syncAsSint32LE(vrb); - s.syncAsSint32LE(obj); - s.syncAsSint32LE(loc); - s.syncAsSint32LE(act); - s.syncAsSint32LE(tick); - s.syncAsSint32LE(score); - s.syncAsSint32LE(visits); + syncVal(s, &vrb); + syncVal(s, &obj); + syncVal(s, &loc); + syncVal(s, &act); + syncVal(s, &tick); + syncVal(s, &score); + syncVal(s, &visits); } void EvtqElem::synchronize(Common::Serializer &s) { - s.syncAsSint32LE(time); - s.syncAsSint32LE(event); - s.syncAsSint32LE(where); -}; + syncVal(s, &time); + syncVal(s, &event); + syncVal(s, &where); +} } // End of namespace Alan2 } // End of namespace Glk |