[Scummvm-cvs-logs] CVS: residual/lua/src lundump.c,1.1.1.1,1.2
Joost Peters
joostp at users.sourceforge.net
Mon Apr 12 08:39:02 CEST 2004
Update of /cvsroot/scummvm/residual/lua/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10800/lua/src
Modified Files:
lundump.c
Log Message:
Big Endian fix
Inventory, walking backwards, picking up items, etc. work now
Index: lundump.c
===================================================================
RCS file: /cvsroot/scummvm/residual/lua/src/lundump.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- lundump.c 15 Aug 2003 18:00:40 -0000 1.1.1.1
+++ lundump.c 12 Apr 2004 15:24:25 -0000 1.2
@@ -12,15 +12,28 @@
#include "lstring.h"
#include "lundump.h"
+#include <SDL_byteorder.h>
+
#define LoadBlock(b,size,Z) ezread(Z,b,size)
#define LoadNative(t,Z) LoadBlock(&t,sizeof(t),Z)
-#if ID_NUMBER=='F'
+#if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
#define doLoadNumber(f,Z) LoadNative(f,Z)
#else
#define doLoadNumber(f,Z) f=LoadNumber(Z)
#endif
+
+static float conv_float(const char *data) {
+ const unsigned char *udata = (const unsigned char *)(data);
+ unsigned char fdata[4];
+ fdata[0] = udata[3];
+ fdata[1] = udata[2];
+ fdata[2] = udata[1];
+ fdata[3] = udata[0];
+ return *(const float *)(fdata);
+}
+
static void unexpectedEOZ(ZIO* Z)
{
luaL_verror("unexpected end of file in %s",zname(Z));
@@ -59,9 +72,7 @@
static float LoadFloat(ZIO* Z)
{
unsigned long l=LoadLong(Z);
- float f;
- memcpy(&f,&l,sizeof(f));
- return f;
+ return conv_float((const char *)&l);
}
#endif
More information about the Scummvm-git-logs
mailing list