[Scummvm-cvs-logs] scummvm master -> 2ec3adfad531b7e1f698c338545fb9817f99e5b1

RichieSams adastley at gmail.com
Fri Sep 12 23:07:43 CEST 2014


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
2ec3adfad5 SWORD25: Make save files x32/x64 agnostic


Commit: 2ec3adfad531b7e1f698c338545fb9817f99e5b1
    https://github.com/scummvm/scummvm/commit/2ec3adfad531b7e1f698c338545fb9817f99e5b1
Author: Adrian Astley (adastley at gmail.com)
Date: 2014-09-12T16:07:06-05:00

Commit Message:
SWORD25: Make save files x32/x64 agnostic

Changed paths:
    engines/sword25/util/pluto/pluto.cpp



diff --git a/engines/sword25/util/pluto/pluto.cpp b/engines/sword25/util/pluto/pluto.cpp
index fb477c1..78b0a81 100644
--- a/engines/sword25/util/pluto/pluto.cpp
+++ b/engines/sword25/util/pluto/pluto.cpp
@@ -835,7 +835,15 @@ static void persistthread(PersistInfo *pi)
 #endif
 		write_size(pi, &stackbase);
 		write_size(pi, &stacktop);
+
+		// ptrdiff_t changes sizes based on 32/64 bit
+		// Hard cast to 64 bit size if SIZE64 is defined
+#ifdef SIZES64
+		uint64 ptrIndex = static_cast<uint64>(L2->errfunc);
+		pi_write(pi, &ptrIndex, sizeof(uint64), pi->ud);
+#else
 		pi_write(pi, &L2->errfunc, sizeof(ptrdiff_t), pi->ud);
+#endif
 		//write_size(pi, (size_t *)&L2->errfunc);
 	}
 
@@ -944,12 +952,6 @@ static void persist(PersistInfo *pi)
 	if(!lua_isnil(pi->L, -1)) {
 					/* perms reftbl ... obj ref */
 		int zero = 0;
-		// FIXME: Casting a pointer to an integer data type is a bad idea we
-		// should really get rid of this by fixing the design of this code.
-		// For now casting to size_t should silence most (all?) compilers,
-		// since size_t is supposedly the same size as a pointer on most
-		// (modern) architectures.
-		int ref = (int)(size_t)lua_touserdata(pi->L, -1);
 		pi_write(pi, &zero, sizeof(int), pi->ud);
 		if (humanReadable) {
 			snprintf(hrBuf, hrBufSize, "persist_seenobject\n");
@@ -958,7 +960,8 @@ static void persist(PersistInfo *pi)
 #ifdef TOTEXT
 		printf("persist_seenobject\n");
 #endif
-		pi_write(pi, &ref, sizeof(int), pi->ud);
+		int *ref = (int *)lua_touserdata(pi->L, -1);
+		pi_write(pi, ref, sizeof(int), pi->ud);
 		if (humanReadable) {
 			snprintf(hrBuf, hrBufSize, "persist_touserdata_ref %d\n", ref);
 			hrOut(pi);
@@ -1011,7 +1014,8 @@ static void persist(PersistInfo *pi)
 	}
 	lua_pushvalue(pi->L, -1);
 					/* perms reftbl ... obj obj */
-	lua_pushlightuserdata(pi->L, (void *)(++(pi->counter)));
+	int *ref = (int *)lua_newuserdata(pi->L, sizeof(int));
+	*ref = ++(pi->counter);
 					/* perms reftbl ... obj obj ref */
 	lua_rawset(pi->L, 2);
 					/* perms reftbl ... obj */
@@ -1737,7 +1741,16 @@ static void unpersistthread(int ref, UnpersistInfo *upi)
 		verify(LIF(Z,read)(&upi->zio, &L2->status, sizeof(lu_byte)) == 0);
 		read_size(&upi->zio, &stackbase);
 		read_size(&upi->zio, &stacktop);
+
+#ifdef SIZES64
+		uint64 value;
+		verify(LIF(Z,read)(&upi->zio, &value, sizeof(uint64)) == 0);
+
+		L2->errfunc = static_cast<ptrdiff_t>(value);
+#else
 		verify(LIF(Z,read)(&upi->zio, &L2->errfunc, sizeof(ptrdiff_t)) == 0);
+#endif
+		
 		//read_size(&upi->zio, (size_t *)&L2->errfunc);
 		L2->base = L2->stack + stackbase;
 		L2->top = L2->stack + stacktop;






More information about the Scummvm-git-logs mailing list