PDA

View Full Version : Patches for 64bit linux


gaeorn
06-10-2009, 08:17 PM
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.

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.

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.

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.

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.

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:
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.

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.

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
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.

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.

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;

gaeorn
06-18-2009, 01:45 AM
There is no va_copy() on windows.


This should work for windows:

va_list apcopy = ap;

From what I was reading, va_copy is just the following define in most cases:

#define va_copy(d,s) ((d) = (s))

gaeorn
06-18-2009, 02:41 AM
In fact, it probably would be more efficient to simply create copies of va_lists everywhere instead of reusing va_start and va_end like I did in my patch. I could submit another patch doing that and accounting for va_copy missing under windows if you would like.

Angelox
06-18-2009, 03:44 PM
I can get it to compile without bots, but when I activate -DEQBOTS, I get a lot of this;
/usr/bin/ld: Dwarf Error: Offset (217430) greater than or equal to .debug_str size (1812).
And it eventually crashes.
Hoping you might can help me.

thanks

gaeorn
06-18-2009, 10:51 PM
I can get it to compile without bots, but when I activate -DEQBOTS, I get a lot of this;
/usr/bin/ld: Dwarf Error: Offset (217430) greater than or equal to .debug_str size (1812).
And it eventually crashes.
Hoping you might can help me.

thanks

I'll need more info. What emu rev are you using. I'll assume this is for 64bit linux or you probably wouldn't have posted to this thread. If that is incorrect, please let me know. What patches have you applied, if any, to the emu code? What gcc version are you using? What is crashing, the compile? One of the programs?

Sorry for all the questions, but the more information you get me, the more likely I'll be able to find the problem. Thanks.

Angelox
06-19-2009, 06:55 AM
GCC ver is 4.3.2, and is 64 bit - what you have posted here;
https://www.tsahosting.net/svn/eqemu64/trunk/
I just downloaded it and compiled - it appeared to have all the patches posted in this thread.
here's the piece where it crashes;

[root@marysol zone]# make
gcc -o zone .obj/EQPacket.o .obj/EQStream.o .obj/EQStreamFactory.o .obj/CRC16.o ../common/timer.o ../common/packet_dump.o ../common/packet_functions.o ../common/unix.o ../common/packet_dump_file.o ../common/Mutex.o ../common/MiscFunctions.o zone.o entity.o mob.o client.o client_process.o npc.o net.o spawn2.o attack.o hate_list.o ../common/serverinfo.o ../common/moremath.o worldserver.o spells.o spawngroup.o loottables.o faction.o Map.o watermap.o PlayerCorpse.o petitions.o MobAI.o Object.o ../common/eqtime.o groups.o ../common/classes.o ../common/races.o ../common/TCPConnection.o forage.o ../common/crc32.o ../common/guilds.o ../common/md5.o ../common/dbcore.o ../common/dbasync.o zonedbasync.o parser.o embperl.o embparser.o ../common/EMuShareMem.o ../common/EQEMuError.o ../common/ptimer.o .obj/debug.o .obj/database.o .obj/Item.o .obj/misc.o tribute.o doors.o command.o beacon.o embxs.o AA.o trap.o client_packet.o bonuses.o trading.o spdat.o spell_effects.o aggro.o guild.o inventory.o client_mods.o tradeskills.o waypoints.o pets.o zone_profile.o effects.o perl_client.o perl_entity.o perl_mob.o perl_questitem.o perl_npc.o perl_PlayerCorpse.o perl_groups.o perl_raids.o questmgr.o client_logs.o perlparser.o ../common/rdtsc.o ../common/extprofile.o horse.o exp.o pathing.o fearpath.o special_attacks.o ../common/timeoutmgr.o ../common/Condition.o .obj/opcodemgr.o .obj/emu_opcodes.o ../common/SharedLibrary.o zoning.o titles.o perlpacket.o perl_perlpacket.o zonedb.o ../common/shareddb.o ../common/logsys.o .obj/rulesys.o ../common/logsys_eqemu.o ../common/EQEmuConfig.o ZoneConfig.o ../common/XMLParser.o ../common/tinyxml/tinystr.o ../common/tinyxml/tinyxml.o ../common/tinyxml/tinyxmlerror.o ../common/tinyxml/tinyxmlparser.o ../common/EQStreamProxy.o ../common/patches/patches.o ../common/patches/Client62.o ../common/patches/Titanium.o ../common/patches/Anniversary.o ../common/patches/SoF.o ../common/StructStrategy.o ../common/EQStreamIdent.o ../common/patches/Live.o zone_logsys.o ../common/BasePacket.o ../common/worldconn.o ../common/EmuTCPConnection.o ../common/EmuTCPServer.o ../common/TCPServer.o ../common/guild_base.o guild_mgr.o tasks.o raids.o -fpermissive -Wall -O -Wuninitialized -Wwrite-strings -Wcast-qual -Wno-deprecated -Wcomment -Wcast-align -O -g -pthread -pipe -D_GNU_SOURCE -DINVERSEXY -DFX -DZONE -DEQDEBUG=5 -DCATCH_CRASH -DNO_PIDLOG -DSHAREMEM -DFIELD_ITEMS -DCOMBINED -DAPP_OPCODE_SIZE=2 -Di386 -DEQBOTS -DEMBPERL -DEMBPERL_PLUGIN -DHAS_UNION_SEMUN -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -fstack-protector-all -fPIC -fstack-protector -fstack-protector-all -DUNIV_LINUX -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -I/usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/CORE -rdynamic -L. -lstdc++ -ldl -rdynamic -L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib64/ -lssl -lcrypto -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/CORE -L/usr/local/lib64 -L/usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
client.o: In function `memset':
/usr/include/bits/string3.h:82: warning: memset used with constant zero length parameter; this could be due to transposed parameters
/usr/bin/ld: Dwarf Error: Offset (225072) greater than or equal to .debug_str size (22084).
entity.o: In function `EntityList::GetBotRaidByMob(Mob*)':
/root/eqemu/source/zone/entity.cpp:1612: undefined reference to `BotRaids::IsBotRaidMember(Mob*)'
/usr/bin/ld: Dwarf Error: Offset (220496) greater than or equal to .debug_str size (18580).
npc.o: In function `NPC::Process()':
/root/eqemu/source/zone/npc.cpp:734: undefined reference to `Mob::BOT_Process()'
/root/eqemu/source/zone/npc.cpp:736: undefined reference to `Mob::PET_Process()'
npc.o:(.data.rel.ro._ZTV3NPC[vtable for NPC]+0x318): undefined reference to `NPC::Bot_AI_IdleCastCheck()'
npc.o:(.data.rel.ro._ZTV3NPC[vtable for NPC]+0x320): undefined reference to `NPC::Bot_AI_EngagedCastCheck()'
npc.o:(.data.rel.ro._ZTV3NPC[vtable for NPC]+0x328): undefined reference to `NPC::Bot_AI_PursueCastCheck()'
npc.o:(.data.rel.ro._ZTV3NPC[vtable for NPC]+0x330): undefined reference to `NPC::Bot_Command_MezzTarget(Mob*)'
npc.o:(.data.rel.ro._ZTV3NPC[vtable for NPC]+0x338): undefined reference to `NPC::Bot_Command_RezzTarget(Mob*)'
npc.o:(.data.rel.ro._ZTV3NPC[vtable for NPC]+0x340): undefined reference to `NPC::Bot_Command_Cure(int, int)'
npc.o:(.data.rel.ro._ZTV3NPC[vtable for NPC]+0x348): undefined reference to `NPC::BotRaidSpell(unsigned short)'
npc.o:(.data.rel.ro._ZTV3NPC[vtable for NPC]+0x350): undefined reference to `NPC::Bot_Command_CalmTarget(Mob*)'
npc.o:(.data.rel.ro._ZTV3NPC[vtable for NPC]+0x358): undefined reference to `NPC::Bot_Command_CharmTarget(int, Mob*)'
npc.o:(.data.rel.ro._ZTV3NPC[vtable for NPC]+0x360): undefined reference to `NPC::Bot_Command_DireTarget(int, Mob*)'
npc.o:(.data.rel.ro._ZTV3NPC[vtable for NPC]+0x368): undefined reference to `NPC::Bot_Command_Resist(int, int)'
/usr/bin/ld: Dwarf Error: Offset (217430) greater than or equal to .debug_str size (1812).
attack.o: In function `Mob::CheckHitChance(Mob*, SkillType, int)':
/root/eqemu/source/zone/attack.cpp:458: undefined reference to `BotRaids::GetBotMainTank()'
/root/eqemu/source/zone/attack.cpp:458: undefined reference to `BotRaids::GetBotMainTank()'
/root/eqemu/source/zone/attack.cpp:458: undefined reference to `BotRaids::GetBotSecondTank()'
/root/eqemu/source/zone/attack.cpp:458: undefined reference to `BotRaids::GetBotSecondTank()'
attack.o: In function `NPC::Attack(Mob*, int, bool)':
/root/eqemu/source/zone/attack.cpp:2398: undefined reference to `BotRaids::AddBotRaidAggro(Mob*)'
/root/eqemu/source/zone/attack.cpp:2422: undefined reference to `BotRaids::AddBotRaidAggro(Mob*)'
attack.o: In function `Client::Death(Mob*, int, unsigned short, SkillType)':
/root/eqemu/source/zone/attack.cpp:1945: undefined reference to `BotRaids::RemoveRaidBots()'
attack.o: In function `NPC::Death(Mob*, int, unsigned short, SkillType)':
/root/eqemu/source/zone/attack.cpp:2740: undefined reference to `BotRaids::SplitExp(unsigned int, Mob*)'
/root/eqemu/source/zone/attack.cpp:2742: undefined reference to `BotRaids::GetBotMainTarget()'
/root/eqemu/source/zone/attack.cpp:2743: undefined reference to `BotRaids::SetBotMainTarget(Mob*)'
/root/eqemu/source/zone/attack.cpp:2973: undefined reference to `BotRaids::RemoveEmptyBotGroup()'
/root/eqemu/source/zone/attack.cpp:2977: undefined reference to `BotRaids::RaidBotGroupsCount()'
/root/eqemu/source/zone/attack.cpp:2978: undefined reference to `BotRaids::GetRaidBotLeader()'
/root/eqemu/source/zone/attack.cpp:2978: undefined reference to `BotRaids::RemoveClientGroup(Mob*)'
/root/eqemu/source/zone/attack.cpp:2980: undefined reference to `BotRaids::RaidBotGroupsCount()'
/root/eqemu/source/zone/attack.cpp:2981: undefined reference to `BotRaids::DisbandBotRaid()'
/usr/bin/ld: Dwarf Error: Offset (207917) greater than or equal to .debug_str size (1002).
groups.o: In function `Group::DelMember(Mob*, bool)':
/root/eqemu/source/zone/groups.cpp:524: undefined reference to `BotRaids::RemoveRaidBots()'
groups.o: In function `Client::LeaveGroup()':
/root/eqemu/source/zone/groups.cpp:1053: undefined reference to `BotRaids::RemoveRaidBots()'
/usr/bin/ld: Dwarf Error: Offset (271637) greater than or equal to .debug_str size (55798).
command.o: In function `command_bot(Client*, Seperator const*)':
/root/eqemu/source/zone/command.cpp:9195: undefined reference to `BotRaids::GetBotRaidAggro()'
/root/eqemu/source/zone/command.cpp:9474: undefined reference to `BotRaids::BotRaids(Mob*)'
/root/eqemu/source/zone/command.cpp:9482: undefined reference to `BotRaids::AddBotGroup(Group*)'
/root/eqemu/source/zone/command.cpp:9494: undefined reference to `BotRaids::AddBotGroup(Group*)'
/root/eqemu/source/zone/command.cpp:9576: undefined reference to `BotRaids::GetBotRaidAggro()'
/root/eqemu/source/zone/command.cpp:9600: undefined reference to `BotRaids::SaveGroups(Client*)'
/root/eqemu/source/zone/command.cpp:9634: undefined reference to `BotRaids::GetBotRaidAggro()'
/root/eqemu/source/zone/command.cpp:9814: undefined reference to `BotRaids::FollowGuardCmd(Client*, bool)'
/root/eqemu/source/zone/command.cpp:9844: undefined reference to `BotRaids::FollowGuardCmd(Client*, bool)'
/root/eqemu/source/zone/command.cpp:9869: undefined reference to `BotRaids::AddBotRaidAggro(Mob*)'
/root/eqemu/source/zone/command.cpp:10069: undefined reference to `BotRaids::GetBotRaidAggro()'
/root/eqemu/source/zone/command.cpp:10114: undefined reference to `BotRaids::SummonRaidBots(Mob*, bool)'
/root/eqemu/source/zone/command.cpp:10260: undefined reference to `EntityList::ShowSpawnWindow(Client*, int, bool)'
/root/eqemu/source/zone/command.cpp:10264: undefined reference to `EntityList::ShowSpawnWindow(Client*, int, bool)'
/root/eqemu/source/zone/command.cpp:10268: undefined reference to `EntityList::ShowSpawnWindow(Client*, int, bool)'
/root/eqemu/source/zone/command.cpp:10279: undefined reference to `EntityList::ShowSpawnWindow(Client*, int, bool)'
/root/eqemu/source/zone/command.cpp:10286: undefined reference to `EntityList::ShowSpawnWindow(Client*, int, bool)'
/root/eqemu/source/zone/command.cpp:11988: undefined reference to `BotRaids::BotRaidInfo(Client*)'
/root/eqemu/source/zone/command.cpp:12024: undefined reference to `BotRaids::AddBotGroup(Group*)'
/root/eqemu/source/zone/command.cpp:12039: undefined reference to `BotRaids::GetBotRaidAggro()'
/root/eqemu/source/zone/command.cpp:12078: undefined reference to `BotRaids::RaidBotGroupsCount()'
/root/eqemu/source/zone/command.cpp:12096: undefined reference to `BotRaids::AddBotGroup(Group*)'
/root/eqemu/source/zone/command.cpp:12198: undefined reference to `BotRaids::RemoveRaidBots()'
/root/eqemu/source/zone/command.cpp:12238: undefined reference to `BotRaids::SetBotMainTank(Mob*)'
/root/eqemu/source/zone/command.cpp:12253: undefined reference to `BotRaids::SetBotSecondTank(Mob*)'
/root/eqemu/source/zone/command.cpp:12267: undefined reference to `BotRaids::SetBotMainTarget(Mob*)'
/root/eqemu/source/zone/command.cpp:12302: undefined reference to `BotRaids::SetBotGroupTarget(Mob*, Group*)'
/root/eqemu/source/zone/command.cpp:12315: undefined reference to `BotRaids::GroupAssignTask(Group*, int, Mob*)'
/root/eqemu/source/zone/command.cpp:12325: undefined reference to `BotRaids::GroupAssignTask(Group*, int, Mob*)'
/root/eqemu/source/zone/command.cpp:12329: undefined reference to `BotRaids::GroupAssignTask(Group*, int, Group*)'
/root/eqemu/source/zone/command.cpp:12333: undefined reference to `BotRaids::GroupAssignTask(Group*, int, Group*)'
/root/eqemu/source/zone/command.cpp:12336: undefined reference to `BotRaids::RaidDefendEnraged()'
/root/eqemu/source/zone/command.cpp:12010: undefined reference to `BotRaids::BotRaids(Mob*)'
/root/eqemu/source/zone/command.cpp:12272: undefined reference to `BotRaids::SetBotMainTarget(Mob*)'
/root/eqemu/source/zone/command.cpp:12286: undefined reference to `BotRaids::SetBotSecondTarget(Mob*)'
/usr/bin/ld: Dwarf Error: Offset (293649) greater than or equal to .debug_str size (24492).
client_packet.o: In function `Client::Handle_OP_Logout(EQApplicationPacket const*)':
/root/eqemu/source/zone/client_packet.cpp:2514: undefined reference to `BotRaids::RemoveRaidBots()'
/usr/bin/ld: Dwarf Error: Offset (207944) greater than or equal to .debug_str size (166).
pets.o:(.data.rel.ro._ZTV3Pet[vtable for Pet]+0x318): undefined reference to `NPC::Bot_AI_IdleCastCheck()'
pets.o:(.data.rel.ro._ZTV3Pet[vtable for Pet]+0x320): undefined reference to `NPC::Bot_AI_EngagedCastCheck()'
pets.o:(.data.rel.ro._ZTV3Pet[vtable for Pet]+0x328): undefined reference to `NPC::Bot_AI_PursueCastCheck()'
pets.o:(.data.rel.ro._ZTV3Pet[vtable for Pet]+0x330): undefined reference to `NPC::Bot_Command_MezzTarget(Mob*)'
pets.o:(.data.rel.ro._ZTV3Pet[vtable for Pet]+0x338): undefined reference to `NPC::Bot_Command_RezzTarget(Mob*)'
pets.o:(.data.rel.ro._ZTV3Pet[vtable for Pet]+0x340): undefined reference to `NPC::Bot_Command_Cure(int, int)'
pets.o:(.data.rel.ro._ZTV3Pet[vtable for Pet]+0x348): undefined reference to `NPC::BotRaidSpell(unsigned short)'
pets.o:(.data.rel.ro._ZTV3Pet[vtable for Pet]+0x350): undefined reference to `NPC::Bot_Command_CalmTarget(Mob*)'
pets.o:(.data.rel.ro._ZTV3Pet[vtable for Pet]+0x358): undefined reference to `NPC::Bot_Command_CharmTarget(int, Mob*)'
pets.o:(.data.rel.ro._ZTV3Pet[vtable for Pet]+0x360): undefined reference to `NPC::Bot_Command_DireTarget(int, Mob*)'
pets.o:(.data.rel.ro._ZTV3Pet[vtable for Pet]+0x368): undefined reference to `NPC::Bot_Command_Resist(int, int)'
/usr/bin/ld: Dwarf Error: Offset (210230) greater than or equal to .debug_str size (14401).
horse.o:(.data.rel.ro._ZTV5Horse[vtable for Horse]+0x318): undefined reference to `NPC::Bot_AI_IdleCastCheck()'
horse.o:(.data.rel.ro._ZTV5Horse[vtable for Horse]+0x320): undefined reference to `NPC::Bot_AI_EngagedCastCheck()'
horse.o:(.data.rel.ro._ZTV5Horse[vtable for Horse]+0x328): undefined reference to `NPC::Bot_AI_PursueCastCheck()'
horse.o:(.data.rel.ro._ZTV5Horse[vtable for Horse]+0x330): undefined reference to `NPC::Bot_Command_MezzTarget(Mob*)'
horse.o:(.data.rel.ro._ZTV5Horse[vtable for Horse]+0x338): undefined reference to `NPC::Bot_Command_RezzTarget(Mob*)'
horse.o:(.data.rel.ro._ZTV5Horse[vtable for Horse]+0x340): undefined reference to `NPC::Bot_Command_Cure(int, int)'
horse.o:(.data.rel.ro._ZTV5Horse[vtable for Horse]+0x348): undefined reference to `NPC::BotRaidSpell(unsigned short)'
horse.o:(.data.rel.ro._ZTV5Horse[vtable for Horse]+0x350): undefined reference to `NPC::Bot_Command_CalmTarget(Mob*)'
horse.o:(.data.rel.ro._ZTV5Horse[vtable for Horse]+0x358): undefined reference to `NPC::Bot_Command_CharmTarget(int, Mob*)'
horse.o:(.data.rel.ro._ZTV5Horse[vtable for Horse]+0x360): undefined reference to `NPC::Bot_Command_DireTarget(int, Mob*)'
horse.o:(.data.rel.ro._ZTV5Horse[vtable for Horse]+0x368): undefined reference to `NPC::Bot_Command_Resist(int, int)'
/usr/bin/ld: Dwarf Error: Offset (210114) greater than or equal to .debug_str size (629).
special_attacks.o: In function `Mob::Taunt(NPC*, bool)':
/root/eqemu/source/zone/special_attacks.cpp:1553: undefined reference to `BotRaids::GetBotMainTank()'
/root/eqemu/source/zone/special_attacks.cpp:1553: undefined reference to `BotRaids::GetBotMainTank()'
/root/eqemu/source/zone/special_attacks.cpp:1553: undefined reference to `BotRaids::GetBotSecondTank()'
/root/eqemu/source/zone/special_attacks.cpp:1553: undefined reference to `BotRaids::GetBotSecondTank()'
/usr/bin/ld: Dwarf Error: Offset (207620) greater than or equal to .debug_str size (142).
zoning.o: In function `Client::Handle_OP_ZoneChange(EQApplicationPacket const*)':
/root/eqemu/source/zone/zoning.cpp:44: undefined reference to `BotRaids::RemoveRaidBots()'
collect2: ld returned 1 exit status
make: *** [zone] Error 1
[root@marysol zone]#

gaeorn
06-19-2009, 11:33 PM
Looks to me like you didn't add the bot object files into zone/makefile.common that are needed for -EQBOTS to work. This patch will do it for you.

diff -up EQEmuServer/zone/makefile.common.dan EQEmuServer/zone/makefile.common
--- EQEmuServer/zone/makefile.common.dan 2009-06-11 17:43:20.000000000 -0700
+++ EQEmuServer/zone/makefile.common 2009-06-11 17:44:08.000000000 -0700
@@ -31,7 +31,7 @@ SF= .obj/EQPacket.o .obj/EQStream.o .obj
../common/EQStreamIdent.o ../common/patches/Live.o \
zone_logsys.o ../common/BasePacket.o ../common/worldconn.o \
../common/EmuTCPConnection.o ../common/EmuTCPServer.o ../common/TCPServer.o \
- ../common/guild_base.o guild_mgr.o tasks.o raids.o
+ ../common/guild_base.o guild_mgr.o tasks.o raids.o botAI.o botRaids.o petAI.o


all: $(APP)

Let me know if this resolves the problem or if you have other problems after this change.

gaeorn
06-22-2009, 03:01 PM
KLS, try this patch for va_lists under windows. It defines va_copy if it is not already defined.

Index: common/MiscFunctions.cpp
================================================== =================
--- common/MiscFunctions.cpp (revision 702)
+++ common/MiscFunctions.cpp (working copy)
@@ -59,6 +59,10 @@
#include <errno.h>
#endif

+#ifndef va_copy
+ #define va_copy(d,s) ((d) = (s))
+#endif
+
void CoutTimestamp(bool ms) {
time_t rawtime;
struct tm* gmt_t;
@@ -147,7 +151,7 @@
int MakeAnyLenString(char** ret, const char* format, ...) {
int buf_len = 128;
int chars = -1;
- va_list argptr;
+ va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= buf_len) {
safe_delete_array(*ret);
@@ -156,7 +160,8 @@
else
buf_len = chars + 1;
*ret = new char[buf_len];
- chars = vsnprintf(*ret, buf_len, format, argptr);
+ va_copy(tmpargptr, argptr);
+ chars = vsnprintf(*ret, buf_len, format, tmpargptr);
}
va_end(argptr);
return chars;
@@ -169,7 +174,7 @@
*strlen = 0;
int chars = -1;
char* oldret = 0;
- va_list argptr;
+ va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= (sint32)(*bufsize-*strlen)) {
if (chars == -1)
@@ -183,7 +188,8 @@
memcpy(*ret, oldret, *strlen);
safe_delete_array(oldret);
}
- chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, argptr);
+ va_copy(tmpargptr, argptr);
+ chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, tmpargptr);
}
va_end(argptr);
*strlen += chars;
Index: common/debug.cpp
================================================== =================
--- common/debug.cpp (revision 702)
+++ common/debug.cpp (working copy)
@@ -20,6 +20,10 @@
#endif
#include "../common/MiscFunctions.h"

+#ifndef va_copy
+ #define va_copy(d,s) ((d) = (s))
+#endif
+
static volatile bool logFileValid = false;
static EQEMuLog realLogFile;
EQEMuLog *LogFile = &realLogFile;
@@ -144,13 +148,16 @@
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] ", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
#endif

- va_list argptr;
+ va_list argptr, tmpargptr;
va_start(argptr, fmt);
- if (dofile)
- vfprintf( fp[id], fmt, argptr );
+ if (dofile) {
+ va_copy(tmpargptr, argptr);
+ vfprintf( fp[id], fmt, tmpargptr );
+ }
if(logCallbackFmt[id]) {
msgCallbackFmt p = logCallbackFmt[id];
- p(id, fmt, argptr );
+ va_copy(tmpargptr, argptr);
+ p(id, fmt, tmpargptr );
}
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8) {
@@ -204,17 +211,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,10 +306,12 @@
}

bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
- va_list argptr;
+ va_list argptr, tmpargptr;
va_start(argptr, fmt);
- if (dofile)
- vfprintf( fp[id], fmt, argptr );
+ if (dofile) {
+ va_copy(tmpargptr, argptr);
+ vfprintf( fp[id], fmt, tmpargptr );
+ }
if (pLogStatus[id] & 2) {
if (pLogStatus[id] & 8)
vfprintf( stderr, fmt, argptr );

gaeorn
06-23-2009, 03:59 AM
Somehow a uint16 in the patch was changed to a uint32 in the SVN. The following patch fixes this:

Index: zone/map.h
================================================== =================
--- zone/map.h (revision 706)
+++ zone/map.h (working copy)
@@ -96,7 +96,7 @@

uint8 flags;
union {
- uint32 nodes[4]; //index 0 means NULL, not root
+ uint16 nodes[4]; //index 0 means NULL, not root
struct {
uint32 count;
uint32 offset;

gaeorn
06-23-2009, 12:11 PM
If the va_list patch is what is causing the zone.exe crashes under windows, this patch should avoid the problem by using #ifndef WIN32 blocks. This patch should be applied against rev706 or later.

Index: common/MiscFunctions.cpp
================================================== =================
--- common/MiscFunctions.cpp (revision 707)
+++ common/MiscFunctions.cpp (working copy)
@@ -59,10 +59,6 @@
#include <errno.h>
#endif

-#ifndef va_copy
- #define va_copy(d,s) ((d) = (s))
-#endif
-
void CoutTimestamp(bool ms) {
time_t rawtime;
struct tm* gmt_t;
@@ -151,8 +147,12 @@
int MakeAnyLenString(char** ret, const char* format, ...) {
int buf_len = 128;
int chars = -1;
- va_list argptr, tmpargptr;
+ va_list argptr;
va_start(argptr, format);
+#ifndef WIN32
+ va_list tmpargptr;
+ va_copy(tmpargptr, argptr);
+#endif
while (chars == -1 || chars >= buf_len) {
safe_delete_array(*ret);
if (chars == -1)
@@ -160,8 +160,10 @@
else
buf_len = chars + 1;
*ret = new char[buf_len];
- va_copy(tmpargptr, argptr);
- chars = vsnprintf(*ret, buf_len, format, tmpargptr);
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
+ chars = vsnprintf(*ret, buf_len, format, argptr);
}
va_end(argptr);
return chars;
@@ -174,8 +176,12 @@
*strlen = 0;
int chars = -1;
char* oldret = 0;
- va_list argptr, tmpargptr;
+ va_list argptr;
va_start(argptr, format);
+#ifndef WIN32
+ va_list tmpargptr;
+ va_copy(tmpargptr, argptr);
+#endif
while (chars == -1 || chars >= (sint32)(*bufsize-*strlen)) {
if (chars == -1)
*bufsize += 256;
@@ -188,8 +194,10 @@
memcpy(*ret, oldret, *strlen);
safe_delete_array(oldret);
}
- va_copy(tmpargptr, argptr);
- chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, tmpargptr);
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
+ chars = vsnprintf(&(*ret)[*strlen], (*bufsize-*strlen), format, argptr);
}
va_end(argptr);
*strlen += chars;
Index: common/debug.cpp
================================================== =================
--- common/debug.cpp (revision 707)
+++ common/debug.cpp (working copy)
@@ -20,10 +20,6 @@
#endif
#include "../common/MiscFunctions.h"

-#ifndef va_copy
- #define va_copy(d,s) ((d) = (s))
-#endif
-
static volatile bool logFileValid = false;
static EQEMuLog realLogFile;
EQEMuLog *LogFile = &realLogFile;
@@ -148,18 +144,29 @@
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] ", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
#endif

- va_list argptr, tmpargptr;
+ va_list argptr;
va_start(argptr, fmt);
+#ifndef WIN32
+ va_list tmpargptr;
+ va_copy(tmpargptr, argptr);
+#endif
if (dofile) {
- va_copy(tmpargptr, argptr);
- vfprintf( fp[id], fmt, tmpargptr );
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
+ vfprintf( fp[id], fmt, argptr );
}
if(logCallbackFmt[id]) {
msgCallbackFmt p = logCallbackFmt[id];
- va_copy(tmpargptr, argptr);
- p(id, fmt, tmpargptr );
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
+ p(id, fmt, argptr );
}
if (pLogStatus[id] & 2) {
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
if (pLogStatus[id] & 8) {
fprintf(stderr, "[%s] ", LogNames[id]);
vfprintf( stderr, fmt, argptr );
@@ -211,7 +218,10 @@
time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */

+#ifndef WIN32
va_list tmpargptr;
+ va_copy(tmpargptr, argptr);
+#endif

if (dofile) {
#ifndef NO_PIDLOG
@@ -219,15 +229,22 @@
#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
- va_copy(tmpargptr, argptr);
- vfprintf( fp[id], fmt, tmpargptr );
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
+ vfprintf( fp[id], fmt, argptr );
}
if(logCallbackPva[id]) {
msgCallbackPva p = logCallbackPva[id];
- va_copy(tmpargptr, argptr);
- p(id, prefix, fmt, tmpargptr );
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
+ p(id, prefix, fmt, argptr );
}
if (pLogStatus[id] & 2) {
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
if (pLogStatus[id] & 8) {
fprintf(stderr, "[%s] %s", LogNames[id], prefix);
vfprintf( stderr, fmt, argptr );
@@ -306,13 +323,22 @@
}

bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
- va_list argptr, tmpargptr;
+ va_list argptr;
va_start(argptr, fmt);
+#ifndef WIN32
+ va_list tmpargptr;
+ va_copy(tmpargptr, argptr);
+#endif
if (dofile) {
- va_copy(tmpargptr, argptr);
- vfprintf( fp[id], fmt, tmpargptr );
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
+ vfprintf( fp[id], fmt, argptr );
}
if (pLogStatus[id] & 2) {
+#ifndef WIN32
+ va_copy(argptr, tmpargptr);
+#endif
if (pLogStatus[id] & 8)
vfprintf( stderr, fmt, argptr );
else

KLS
06-23-2009, 02:26 PM
No crashes for va_lists from windows that I can find.

gaeorn
06-23-2009, 04:25 PM
Excellent.