EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Server Code Submissions (https://www.eqemulator.org/forums/forumdisplay.php?f=669)
-   -   Patches for 64bit linux (https://www.eqemulator.org/forums/showthread.php?t=28539)

gaeorn 06-10-2009 08:17 PM

Patches for 64bit linux
 
I'll be posting patches to improve compatibility with 64bit linux compiles in this thread.

First up, makefile changes to allow it to begin compiling.

Code:

Index: eqlaunch/makefile
===================================================================
--- eqlaunch/makefile  (revision 1)
+++ eqlaunch/makefile  (revision 2)
@@ -10,11 +10,11 @@
 LINKOUT=-o
 NOLINK=-c
 LINKER=gcc
-MYSQL_FLAGS=-I/usr/include/mysql
-MYSQL_LIB=-L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lc -lnss_files -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv
+MYSQL_FLAGS=$(shell mysql_config --cflags)
+MYSQL_LIB=$(shell mysql_config --libs)
 DFLAGS=-DEQDEBUG=5
 WFLAGS=-Wall -Wuninitialized -Wwrite-strings -Wcast-qual -Wno-deprecated  -Wcomment -Wcast-align
-COPTS=$(WFLAGS) -O -g -march=i686 -pthread -pipe -DEQLAUNCH $(DFLAGS) $(MYSQL_FLAGS)
+COPTS=$(WFLAGS) -O -g -pthread -pipe -DEQLAUNCH $(DFLAGS) $(MYSQL_FLAGS)
 LINKOPTS=$(COPTS) -rdynamic -L. -lstdc++ -ldl $(MYSQL_LIB)

 all: eqlaunch
Index: chatserver/makefile
===================================================================
--- chatserver/makefile (revision 1)
+++ chatserver/makefile (revision 2)
@@ -21,7 +21,7 @@
 MYSQL_FLAGS=$(shell mysql_config --cflags)
 MYSQL_LIB=$(shell mysql_config --libs)

-COPTS=$(WFLAGS) -g -march=i686 -pthread -pipe -I../common/SocketLib \
+COPTS=$(WFLAGS) -g -pthread -pipe -I../common/SocketLib \
  -DFX -D_GNU_SOURCE -DINVERSEXY $(DFLAGS) $(MYSQL_FLAGS) $(PERL_FLAGS)
 LINKOPTS=$(COPTS) -rdynamic -L. -lstdc++ -lm -lz -ldl \
  $(MYSQL_LIB) $(PERL_LIB)
Index: world/makefile
===================================================================
--- world/makefile      (revision 1)
+++ world/makefile      (revision 2)
@@ -21,7 +21,7 @@
 MYSQL_FLAGS=$(shell mysql_config --cflags)
 MYSQL_LIB=$(shell mysql_config --libs)

-COPTS=$(WFLAGS) -g -march=i686 -O -pthread -pipe -I../common/SocketLib \
+COPTS=$(WFLAGS) -g -O -pthread -pipe -I../common/SocketLib \
  -DFX -D_GNU_SOURCE -DINVERSEXY -DWORLD $(DFLAGS) $(MYSQL_FLAGS) $(PERL_FLAGS)
 LINKOPTS=$(COPTS) -rdynamic -L. -lstdc++ -lm -lz -ldl \
  $(MYSQL_LIB) $(PERL_LIB)
Index: mailserver/makefile
===================================================================
--- mailserver/makefile (revision 1)
+++ mailserver/makefile (revision 2)
@@ -21,7 +21,7 @@
 MYSQL_FLAGS=$(shell mysql_config --cflags)
 MYSQL_LIB=$(shell mysql_config --libs)

-COPTS=$(WFLAGS) -g -march=i686 -pthread -pipe -I../common/SocketLib \
+COPTS=$(WFLAGS) -g -pthread -pipe -I../common/SocketLib \
  -DFX -D_GNU_SOURCE -DINVERSEXY $(DFLAGS) $(MYSQL_FLAGS) $(PERL_FLAGS)
 LINKOPTS=$(COPTS) -rdynamic -L. -lstdc++ -lm -lz -ldl \
  $(MYSQL_LIB) $(PERL_LIB)
Index: zone/makefile
===================================================================
--- zone/makefile      (revision 1)
+++ zone/makefile      (revision 2)
@@ -10,15 +10,15 @@
 LINKOUT=-o
 NOLINK=-c
 LINKER=gcc
-MYSQL_FLAGS=-I/usr/include/mysql
-MYSQL_LIB=-L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lc -lnss_files -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv
+MYSQL_FLAGS=$(shell mysql_config --cflags)
+MYSQL_LIB=$(shell mysql_config --libs)
 DFLAGS=-DEQDEBUG=5 -DCATCH_CRASH -DNO_PIDLOG -DSHAREMEM -DFIELD_ITEMS -DCOMBINED -DAPP_OPCODE_SIZE=2 -Di386
 #try commenting out the following three lines to disable embedded perl
 PERL_FLAGS=perl -MExtUtils::Embed -e ccopts
 PERL_LIB=perl -MExtUtils::Embed -e ldopts
 DFLAGS+=-DEMBPERL -DEMBPERL_PLUGIN -DHAS_UNION_SEMUN
 WFLAGS=-fpermissive -Wall -Wuninitialized -Wwrite-strings -Wcast-qual -Wno-deprecated  -Wcomment -Wcast-align
-COPTS=$(WFLAGS) -O -g -march=i686 -pthread -pipe -D_GNU_SOURCE -DINVERSEXY -DFX -DZONE $(DFLAGS) $(MYSQL_FLAGS) `$(PERL_FLAGS)`
+COPTS=$(WFLAGS) -O -g -pthread -pipe -D_GNU_SOURCE -DINVERSEXY -DFX -DZONE $(DFLAGS) $(MYSQL_FLAGS) `$(PERL_FLAGS)`
 LINKOPTS=$(COPTS) -rdynamic -L. -lstdc++ -ldl $(MYSQL_LIB) `$(PERL_LIB)`

 all: zone
Index: ucs/makefile
===================================================================
--- ucs/makefile        (revision 30)
+++ ucs/makefile        (revision 31)
@@ -21,7 +21,7 @@
 MYSQL_FLAGS=$(shell mysql_config --cflags)
 MYSQL_LIB=$(shell mysql_config --libs)

-COPTS=$(WFLAGS) -g -march=i686 -pthread -pipe -I../common/SocketLib \
+COPTS=$(WFLAGS) -g -pthread -pipe -I../common/SocketLib \
  -DFX -D_GNU_SOURCE -DINVERSEXY $(DFLAGS) $(MYSQL_FLAGS) $(PERL_FLAGS)
 LINKOPTS=$(COPTS) -rdynamic -L. -lstdc++ -lm -lz -ldl \
  $(MYSQL_LIB) $(PERL_LIB)

This patch merely removes the -march=i686 to allow the compiler to dynamically set arch and in two makefiles it changes the mysql flags from hardcoded to dynamically generated.

If desired, I could create patches so the makefile will selectively add the -march=i686 for 32 bit machines.

gaeorn 06-10-2009 08:20 PM

Type cast in common/TCPConnection.cpp to fix compile error under 64bit.

Code:

Index: common/TCPConnection.cpp
===================================================================
--- common/TCPConnection.cpp    (revision 2)
+++ common/TCPConnection.cpp    (revision 3)
@@ -145,7 +145,7 @@
 #endif
 #endif
        addrlen=sizeof(struct sockaddr_in);
-      if (!getsockname(connection_socket,(struct sockaddr *)&local,&addrlen)) {
+      if (!getsockname(connection_socket,(struct sockaddr *)&local,(socklen_t *)&addrlen)) {
                unsigned long ip=local.sin_addr.s_addr;
                sprintf(host,"%d.%d.%d.%d",
                        *(unsigned char *)&ip,


gaeorn 06-10-2009 08:23 PM

Apparently va_lists are not preserved in (most) 64bit linux libraries after vprintf (and variations) calls. This causes segfaults under 64bit when a va_list is reused. This patch avoids reusing va_lists.

Code:

Index: common/MiscFunctions.cpp
===================================================================
--- common/MiscFunctions.cpp    (revision 3)
+++ common/MiscFunctions.cpp    (revision 4)
@@ -148,7 +148,6 @@
        int buf_len = 128;
    int chars = -1;
        va_list argptr;
-      va_start(argptr, format);
        while (chars == -1 || chars >= buf_len) {
                safe_delete_array(*ret);
                if (chars == -1)
@@ -156,9 +155,10 @@
                else
                        buf_len = chars + 1;
                *ret = new char[buf_len];
+              va_start(argptr, format);
                chars = vsnprintf(*ret, buf_len, format, argptr);
+              va_end(argptr);
        }
-      va_end(argptr);
        return chars;
 }

@@ -170,7 +170,6 @@
    int chars = -1;
        char* oldret = 0;
        va_list argptr;
-      va_start(argptr, format);
        while (chars == -1 || chars >= (sint32)(*bufsize-*strlen)) {
                if (chars == -1)
                        *bufsize += 256;
@@ -183,7 +182,9 @@
                                memcpy(*ret, oldret, *strlen);
                        safe_delete_array(oldret);
                }
+              va_start(argptr, format);
                chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, argptr);
+              va_end(argptr);
        }
        va_end(argptr);
        *strlen += chars;
Index: common/debug.cpp
===================================================================
--- common/debug.cpp    (revision 3)
+++ common/debug.cpp    (revision 4)
@@ -144,11 +144,16 @@

        va_list argptr;
        va_start(argptr, fmt);
-    if (dofile)
+    if (dofile) {
                vfprintf( fp[id], fmt, argptr );
+              va_end(argptr);
+              va_start(argptr, fmt);
+      }
        if(logCallbackFmt[id]) {
                msgCallbackFmt p = logCallbackFmt[id];
                p(id, fmt, argptr );
+              va_end(argptr);
+              va_start(argptr, fmt);
        }
    if (pLogStatus[id] & 2) {
                if (pLogStatus[id] & 8) {
@@ -202,17 +207,21 @@
    time( &aclock );                /* Get time in seconds */
    newtime = localtime( &aclock );  /* Convert time to struct */

+    va_list tmpargptr;
+
    if (dofile) {
 #ifndef NO_PIDLOG
                fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] %s", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, prefix);
 #else
                fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] %s", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, prefix);
 #endif
-              vfprintf( fp[id], fmt, argptr );
+              va_copy(tmpargptr, argptr);
+              vfprintf( fp[id], fmt, tmpargptr );
    }
        if(logCallbackPva[id]) {
                msgCallbackPva p = logCallbackPva[id];
-              p(id, prefix, fmt, argptr );
+              va_copy(tmpargptr, argptr);
+              p(id, prefix, fmt, tmpargptr );
        }
    if (pLogStatus[id] & 2) {
                if (pLogStatus[id] & 8) {
@@ -295,8 +304,11 @@
 bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
        va_list argptr;
        va_start(argptr, fmt);
-      if (dofile)
+      if (dofile) {
                vfprintf( fp[id], fmt, argptr );
+              va_end(argptr);
+              va_start(argptr, fmt);
+      }
    if (pLogStatus[id] & 2) {
                if (pLogStatus[id] & 8)
                        vfprintf( stderr, fmt, argptr );


gaeorn 06-10-2009 08:28 PM

This patch fixes disappearing augments and no drop flags seemingly randomly toggling on items in inventory with 64bit linux compiles.

Code:

Index: common/shareddb.cpp
===================================================================
--- common/shareddb.cpp (revision 6)
+++ common/shareddb.cpp (revision 7)
@@ -254,8 +254,8 @@
                                "      augslot1,augslot2,augslot3,augslot4,augslot5)"
                                " VALUES(%lu,%lu,%lu,%lu,"
                                "      %lu,%lu,%lu,%lu,%lu)",
-                              account_id, slot_id, inst->GetItem()->ID, charges ,
-                              augslot[0],augslot[1],augslot[2],augslot[3],augslot[4]);
+                              (unsigned long)account_id, (unsigned long)slot_id, (unsigned long)inst->GetItem()->ID, (unsigned long)charges ,
+                              (unsigned long)augslot[0],(unsigned long)augslot[1],(unsigned long)augslot[2],(unsigned long)augslot[3],(unsigned long)augslot[4]);


                        ret = RunQuery(query, len_query, errbuf);
@@ -290,8 +290,8 @@
                                "      augslot1,augslot2,augslot3,augslot4,augslot5)"
                                " VALUES(%lu,%lu,%lu,%lu,%lu,%lu,"
                                "      %lu,%lu,%lu,%lu,%lu)",
-                              char_id, slot_id, inst->GetItem()->ID, charges, inst->IsInstNoDrop() ? 1:0,inst->GetColor(),
-                              augslot[0],augslot[1],augslot[2],augslot[3],augslot[4] );
+                              (unsigned long)char_id, (unsigned long)slot_id, (unsigned long)inst->GetItem()->ID, (unsigned long)charges, (unsigned long)(inst->IsInstNoDrop() ? 1:0),(unsigned long)inst->GetColor(),
+                              (unsigned long)augslot[0],(unsigned long)augslot[1],(unsigned long)augslot[2],(unsigned long)augslot[3],(unsigned long)augslot[4] );

                        ret = RunQuery(query, len_query, errbuf);
                }


gaeorn 06-10-2009 08:35 PM

This patch fixes assembler errors on some 64bit systems.

Code:

Index: common/crc32.cpp
===================================================================
--- common/crc32.cpp    (revision 1)
+++ common/crc32.cpp    (working copy)
@@ -112,6 +112,14 @@
 #undef i386    //darwin seems to think we are generating PIC, and we clobber ebx
 #endif

+/* Some 64bit systems do not like the i386 assembly code below. However, some 64bit
+  systems do work with the assembly code below. We #undef i386 to be on the safe
+  side if we are compiling 64bit. */
+
+#ifdef __x86_64__
+#undef i386
+#endif
+
 uint32 CRC32::Update(const int8* buf, uint32 bufsize, uint32 crc32) {
 #if defined(WIN32)
        // Register use:


gaeorn 06-10-2009 08:42 PM

I did a whole pile of type casts where MakeAnyLenString was being used with %lu in the format string. This patch is over 400 lines long so rather than post it here, it can be retrieved at:
Code:

svn diff -c 8 https://www.tsahosting.net/svn/eqemu64/trunk/

gaeorn 06-10-2009 08:50 PM

The following patch removes the optimize flag (-O) when building common/patches/SoF.o. There is a bug in gcc that causes stringstreams not to work if optimized under 64bit.

Without this patch to the makefile, zone will segfault when a SoF client tries to enter the game (post char select). I also patch the makefile for world since the same object file is linked into world.

Code:

Index: world/makefile
===================================================================
--- world/makefile      (revision 27)
+++ world/makefile      (working copy)
@@ -21,6 +21,8 @@
 MYSQL_FLAGS=$(shell mysql_config --cflags)
 MYSQL_LIB=$(shell mysql_config --libs)

+SOFCOPTS=$(WFLAGS) -g -pthread -pipe -I../common/SocketLib \
+  -DFX -D_GNU_SOURCE -DINVERSEXY -DWORLD $(DFLAGS) $(MYSQL_FLAGS) $(PERL_FLAGS)
 COPTS=$(WFLAGS) -g -O -pthread -pipe -I../common/SocketLib \
  -DFX -D_GNU_SOURCE -DINVERSEXY -DWORLD $(DFLAGS) $(MYSQL_FLAGS) $(PERL_FLAGS)
 LINKOPTS=$(COPTS) -rdynamic -L. -lstdc++ -lm -lz -ldl \
@@ -33,6 +35,9 @@

 include makefile.common

+../common/patches/SoF.o: ../common/patches/SoF.cpp
+        $(CC) $(NOLINK) $(SOFCOPTS) $< $(OUT)$@
+
 .depend depend:
        for f in $(SF); \
        do \
Index: zone/makefile
===================================================================
--- zone/makefile      (revision 27)
+++ zone/makefile      (working copy)
@@ -18,6 +18,7 @@
 PERL_LIB=$(shell perl -MExtUtils::Embed -e ldopts)
 DFLAGS+=-DEMBPERL -DEMBPERL_PLUGIN -DHAS_UNION_SEMUN
 WFLAGS=-fpermissive -Wall -Wuninitialized -Wwrite-strings -Wcast-qual -Wno-deprecated  -Wcomment -Wcast-align
+SOFCOPTS=$(WFLAGS) -g -pthread -pipe -D_GNU_SOURCE -DINVERSEXY -DFX -DZONE $(DFLAGS) $(MYSQL_FLAGS) $(PERL_FLAGS)
 COPTS=$(WFLAGS) -O -g -pthread -pipe -D_GNU_SOURCE -DINVERSEXY -DFX -DZONE $(DFLAGS) $(MYSQL_FLAGS) $(PERL_FLAGS)
 LINKOPTS=$(COPTS) -rdynamic -L. -lstdc++ -ldl $(MYSQL_LIB) $(PERL_LIB)

@@ -27,6 +28,9 @@

 include makefile.common

+../common/patches/SoF.o: ../common/patches/SoF.cpp
+        $(CC) $(NOLINK) $(SOFCOPTS) $< $(OUT)$@
+
 .depend depend:
        for f in $(SF); \
        do \


gaeorn 06-10-2009 08:52 PM

I needed to add this header include to ucs/clientlist.cpp to compile on my system. I do not know if this is a 64bit problem or just my version of gcc.

Code:

Index: ucs/clientlist.cpp
===================================================================
--- ucs/clientlist.cpp  (revision 37)
+++ ucs/clientlist.cpp  (revision 38)
@@ -31,6 +31,7 @@
 #include "../common/EmuTCPServer.h"
 #include <list>
 #include <vector>
+#include <algorithm>
 #include <string>
 #include <cstdlib>


gaeorn 06-10-2009 09:51 PM

Just realized I hadn't given credit to ndnet for his work on the patch that fixed the missing augments. He is the one who found that fix.

KLS 06-15-2009 02:00 AM

I'll try to get to this stuff in the next few days, sorry I almost forgot about it.

gaeorn 06-15-2009 02:35 AM

No worries. I just figured they could be done one at a time as time permits. Thanks.

gaeorn 06-17-2009 08:22 PM

Quote:

Originally Posted by gaeorn (Post 171881)
I needed to add this header include to ucs/clientlist.cpp to compile on my system. I do not know if this is a 64bit problem or just my version of gcc.

Code:

Index: ucs/clientlist.cpp
===================================================================
--- ucs/clientlist.cpp  (revision 37)
+++ ucs/clientlist.cpp  (revision 38)
@@ -31,6 +31,7 @@
 #include "../common/EmuTCPServer.h"
 #include <list>
 #include <vector>
+#include <algorithm>
 #include <string>
 #include <cstdlib>


You can ignore this patch as Derision already updated the SVN with a fix.

KLS 06-18-2009 12:58 AM

I was gonna commit some of this tonight but I ran into some issues; not entirely your fault.

Some comments:

There is no va_copy() on windows.
I also don't believe socklen_t is defined type on windows, though I didn't look into it further.

gaeorn 06-18-2009 01:23 AM

The va_copy() probably could be replaced with a memcpy. The socklen_t could be inside an #ifdef.

Feel free to do whatever you think is best. And fyi, I know C much better than I know C++, so if there are better ways of doing things, change it :)

gaeorn 06-18-2009 01:36 AM

Here is another patch. This one fixes loading the regular and water map files.

Code:

Index: zone/map.h
===================================================================
--- zone/map.h  (revision 687)
+++ zone/map.h  (working copy)
@@ -56,11 +56,11 @@
 }FACE, *PFACE;

 typedef struct _mapHeader {
-      unsigned long version;
+      uint32 version;
 //    unsigned long vertex_count;
-      unsigned long face_count;
-      unsigned short node_count;
-      unsigned long facelist_count;
+      uint32 face_count;
+      uint16 node_count;
+      uint32 facelist_count;
 } mapHeader;

 /*
@@ -95,12 +95,12 @@
        float maxx;
        float maxy;

-      unsigned char flags;
+      uint8 flags;
        union {
-              unsigned short nodes[4];        //index 0 means NULL, not root
+              uint16 nodes[4];        //index 0 means NULL, not root
                struct {
-                      unsigned long count;
-                      unsigned long offset;
+                      uint32 count;
+                      uint32 offset;
                } faces;
        };
 } nodeHeader, NODE, *PNODE;
@@ -111,7 +111,7 @@
 #define NODE_NONE 65534
 #define MAP_ROOT_NODE 0

-typedef unsigned short NodeRef;
+typedef uint16 NodeRef;

 /*typedef struct _node {
        nodeHeader head;
@@ -145,7 +145,7 @@
        bool LineIntersectsZone(VERTEX start, VERTEX end, float step, VERTEX *result, FACE **on = NULL) const;

 //    inline unsigned int            GetVertexNumber( ) {return m_Vertex; }
-      inline unsigned int            GetFacesNumber( ) const { return m_Faces; }
+      inline uint32                  GetFacesNumber( ) const { return m_Faces; }
 //    inline PVERTEX  GetVertex( int _idx ) {return mFinalVertex + _idx;      }
        inline PFACE            GetFace( int _idx) {return mFinalFaces + _idx;          }
        inline PFACE            GetFaceFromlist( int _idx) {return &mFinalFaces[ mFaceLists[_idx] ];    }
@@ -161,13 +161,13 @@
        bool LineIntersectsZoneNoZLeaps(VERTEX start, VERTEX end, float step_mag, VERTEX *result, FACE **on);
 private:
 //    unsigned long m_Vertex;
-      unsigned long m_Faces;
-      unsigned long m_Nodes;
-      unsigned long m_FaceLists;
+      uint32 m_Faces;
+      uint32 m_Nodes;
+      uint32 m_FaceLists;
 //    PVERTEX mFinalVertex;
        PFACE mFinalFaces;
        PNODE mNodes;
-      unsigned long *mFaceLists;
+      uint32 *mFaceLists;


        int mCandFaces[100];
Index: zone/Map.cpp
===================================================================
--- zone/Map.cpp        (revision 687)
+++ zone/Map.cpp        (working copy)
@@ -119,11 +119,11 @@
        if(head.version != MAP_VERSION) {
                //invalid version... if there really are multiple versions,
                //a conversion routine could be possible.
-              printf("Invalid map version 0x%lx\n", head.version);
+              printf("Invalid map version 0x%lx\n", (unsigned long)head.version);
                return(false);
        }

-      printf("Map header: %lu faces, %u nodes, %lu facelists\n", head.face_count, head.node_count, head.facelist_count);
+      printf("Map header: %lu faces, %u nodes, %lu facelists\n", (unsigned long)head.face_count, (unsigned int)head.node_count, (unsigned long)head.facelist_count);

        m_Faces = head.face_count;
        m_Nodes = head.node_count;
@@ -134,24 +134,24 @@
 //    mFinalVertex = new VERTEX[m_Vertex];
        mFinalFaces = new FACE  [m_Faces];
        mNodes = new NODE[m_Nodes];
-      mFaceLists = new unsigned long[m_FaceLists];
+      mFaceLists = new uint32[m_FaceLists];

 //    fread(mFinalVertex, m_Vertex, sizeof(VERTEX), fp);

        //this was changed to this loop from the single read because valgrind was
        //hanging on this read otherwise... I dont pretend to understand it.
 #ifdef SLOW_AND_CRAPPY_MAKES_VALGRIND_HAPPY
-      unsigned long r;
+      uint32 r;
        for(r = 0; r < m_Faces; r++) {
                if(fread(mFinalFaces+r, sizeof(FACE), 1, fp) != 1) {
-                      printf("Unable to read %lu faces from map file, got %lu.\n", m_Faces, r);
+                      printf("Unable to read %lu faces from map file, got %lu.\n", (unsigned long)m_Faces, (unsigned long)r);
                        return(false);
                }
        }
 #else
-      unsigned long count;
+      uint32 count;
        if((count=fread(mFinalFaces, sizeof(FACE), m_Faces , fp)) != m_Faces) {
-              printf("Unable to read %lu face bytes from map file, got %lu.\n", m_Faces, count);
+              printf("Unable to read %lu face bytes from map file, got %lu.\n", (unsigned long)m_Faces, (unsigned long)count);
                return(false);
        }
 #endif
@@ -159,27 +159,27 @@
 #ifdef SLOW_AND_CRAPPY_MAKES_VALGRIND_HAPPY
        for(r = 0; r < m_Nodes; r++) {
                if(fread(mNodes+r, sizeof(NODE), 1, fp) != 1) {
-                      printf("Unable to read %lu nodes from map file, got %lu.\n", m_Nodes, r);
+                      printf("Unable to read %lu nodes from map file, got %lu.\n", (unsigned long)m_Nodes, (unsigned long)r);
                        return(false);
                }
        }
 #else
        if(fread(mNodes, sizeof(NODE), m_Nodes, fp) != m_Nodes) {
-              printf("Unable to read %lu nodes from map file.\n", m_Nodes);
+              printf("Unable to read %lu nodes from map file.\n", (unsigned long)m_Nodes);
                return(false);
        }
 #endif

 #ifdef SLOW_AND_CRAPPY_MAKES_VALGRIND_HAPPY
        for(r = 0; r < m_FaceLists; r++) {
-              if(fread(mFaceLists+r, sizeof(unsigned long), 1, fp) != 1) {
-                      printf("Unable to read %lu face lists from map file, got %lu.\n", m_FaceLists, r);
+              if(fread(mFaceLists+r, sizeof(uint32), 1, fp) != 1) {
+                      printf("Unable to read %lu face lists from map file, got %lu.\n", (unsigned long)m_FaceLists, (unsigned long)r);
                        return(false);
                }
        }
 #else
-      if(fread(mFaceLists, sizeof(unsigned long), m_FaceLists, fp) != m_FaceLists) {
-              printf("Unable to read %lu face lists from map file.\n", m_FaceLists);
+      if(fread(mFaceLists, sizeof(uint32), m_FaceLists, fp) != m_FaceLists) {
+              printf("Unable to read %lu face lists from map file.\n", (unsigned long)m_FaceLists);
                return(false);
        }
 #endif
@@ -188,7 +188,7 @@
 /*    mRoot = new NODE();
        RecLoadNode(mRoot, fp );*/

-      unsigned long i;
+      uint32 i;
        float v;
        for(i = 0; i < m_Faces; i++) {
                v = Vmax3(x, mFinalFaces[i].a, mFinalFaces[i].b, mFinalFaces[i].c);
@@ -210,7 +210,7 @@
                if(v < _minz)
                        _minz = v;
        }
-      printf("Loaded map: %lu vertices, %lu faces\n", m_Faces*3, m_Faces);
+      printf("Loaded map: %lu vertices, %lu faces\n", (unsigned long)m_Faces*3, (unsigned long)m_Faces);
        printf("Map BB: (%.2f -> %.2f, %.2f -> %.2f, %.2f -> %.2f)\n", _minx, _maxx, _miny, _maxy, _minz, _maxz);
        return(true);
 }
@@ -454,7 +454,7 @@
        unsigned long i;

        PFACE cur;
-      const unsigned long *cfl = mFaceLists + _node->faces.offset;
+      const uint32 *cfl = mFaceLists + _node->faces.offset;

        for(i = 0; i < _node->faces.count; i++) {
                if(*cfl > m_Faces)
@@ -508,7 +508,7 @@
        //
        for(zAttempt=1; zAttempt<=2; zAttempt++) {

-              const unsigned long *cfl = mFaceLists + _node->faces.offset;
+              const uint32 *cfl = mFaceLists + _node->faces.offset;

 #ifdef DEBUG_BEST_Z
 printf("Start finding best Z...\n");
Index: zone/watermap.h
===================================================================
--- zone/watermap.h    (revision 687)
+++ zone/watermap.h    (working copy)
@@ -22,11 +22,11 @@

 #pragma pack(1)
 typedef struct ZBSP_Node {
-        long node_number;
+        sint32 node_number;
        float normal[3], splitdistance;
-        long region;
-        int special;
-        long left, right;
+        sint32 region;
+        sint32 special;
+        sint32 left, right;
 } ZBSP_Node;
 #pragma pack()

@@ -43,7 +43,7 @@

 public:
        static WaterMap*  LoadWaterMapfile(const char* in_zonename, const char *directory = NULL);
-        WaterRegionType BSPReturnRegionType(long node_number, float y, float x, float z) const;
+        WaterRegionType BSPReturnRegionType(sint32 node_number, float y, float x, float z) const;
        bool InWater(float y, float x, float z) const;
        bool InLava(float y, float x, float z) const;

Index: zone/watermap.cpp
===================================================================
--- zone/watermap.cpp  (revision 687)
+++ zone/watermap.cpp  (working copy)
@@ -41,7 +41,7 @@
 }


-WaterRegionType WaterMap::BSPReturnRegionType(long node_number, float y, float x, float z) const
+WaterRegionType WaterMap::BSPReturnRegionType(sint32 node_number, float y, float x, float z) const
 {
        float distance;



All times are GMT -4. The time now is 01:41 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.