[Scummvm-cvs-logs] SF.net SVN: scummvm:[41093] scummvm/trunk/engines/cruise/saveload.cpp

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Mon Jun 1 05:27:55 CEST 2009


Revision: 41093
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41093&view=rev
Author:   dreammaster
Date:     2009-06-01 03:27:54 +0000 (Mon, 01 Jun 2009)

Log Message:
-----------
Converted the saving of perso structure data to proper endian-safe serialisation

Modified Paths:
--------------
    scummvm/trunk/engines/cruise/saveload.cpp

Modified: scummvm/trunk/engines/cruise/saveload.cpp
===================================================================
--- scummvm/trunk/engines/cruise/saveload.cpp	2009-06-01 01:24:17 UTC (rev 41092)
+++ scummvm/trunk/engines/cruise/saveload.cpp	2009-06-01 03:27:54 UTC (rev 41093)
@@ -555,6 +555,27 @@
 	}
 }
 
+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 @@
 			// 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]);
 	}
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list