diff options
author | Paul Gilbert | 2009-06-01 03:27:54 +0000 |
---|---|---|
committer | Paul Gilbert | 2009-06-01 03:27:54 +0000 |
commit | 4269c3a4ea04909edec47669b42b10a9449fe250 (patch) | |
tree | db15591d4afb2ec72a3860d2f18cde0a5bb1c4a6 | |
parent | 83dbcf8531c7703e3024a45e76c3794fa2327b79 (diff) | |
download | scummvm-rg350-4269c3a4ea04909edec47669b42b10a9449fe250.tar.gz scummvm-rg350-4269c3a4ea04909edec47669b42b10a9449fe250.tar.bz2 scummvm-rg350-4269c3a4ea04909edec47669b42b10a9449fe250.zip |
Converted the saving of perso structure data to proper endian-safe serialisation
svn-id: r41093
-rw-r--r-- | engines/cruise/saveload.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/engines/cruise/saveload.cpp b/engines/cruise/saveload.cpp index ed7b2a90c3..4230829bcf 100644 --- a/engines/cruise/saveload.cpp +++ b/engines/cruise/saveload.cpp @@ -555,6 +555,27 @@ static void syncSongs(Common::Serializer &s) { } } +static void syncPerso(Common::Serializer &s, persoStruct &p) { + s.syncAsSint16LE(p.inc_droite); + s.syncAsSint16LE(p.inc_droite0); + s.syncAsSint16LE(p.inc_chemin); + + for (int i = 0; i < 400; ++i) { + s.syncAsSint16LE(p.coordinates[i].x); + s.syncAsSint16LE(p.coordinates[i].y); + } + + for (int i = 0; i < NUM_NODES + 3; ++i) { + s.syncAsSint16LE(p.solution[i][0]); + s.syncAsSint16LE(p.solution[i][1]); + } + + s.syncAsSint16LE(p.inc_jo1); + s.syncAsSint16LE(p.inc_jo2); + s.syncAsSint16LE(p.dir_perso); + s.syncAsSint16LE(p.inc_jo0); +} + static void syncCT(Common::Serializer &s) { int v = (polyStruct) ? 1 : 0; s.syncAsSint32LE(v); @@ -583,12 +604,8 @@ static void syncCT(Common::Serializer &s) { // Set up the pointer for the next structure persoTable[i] = (v == 0) ? NULL : (persoStruct *)mallocAndZero(sizeof(persoStruct)); - if (v != 0) { - // FIXME: This code is not endian safe, and breaks if struct - // packing changes. Read/write the members one by one instead. - assert(sizeof(persoStruct) == 0x6AA); - s.syncBytes((byte *)persoTable[i], 0x6AA); - } + if (v != 0) + syncPerso(s, *persoTable[i]); } } |