Replacing a quake3 function
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
I was able to grab a copy of the q3as 1.99q mod source code, but it appears to be buggy. It won't compile nicely as is and gives me several error messages that I need some help debugging. Here are the problems I am having:
q_math.c: 817
q_math.c:1060
Code: Select all
q_math.c:817: warning: `naked' attribute directive ignored
q_math.c: In function `BoxOnPlaneSide':
q_math.c:821: error: parse error before '{' token
Code: Select all
__declspec( naked ) int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p)
{
static int bops_initialized;
static int Ljmptab[8];
__asm { // Line 821
push ebx
cmp bops_initialized, 1
je initialized
mov bops_initialized, 1
mov Ljmptab[0*4], offset Lcase0
mov Ljmptab[1*4], offset Lcase1
mov Ljmptab[2*4], offset Lcase2
mov Ljmptab[3*4], offset Lcase3
mov Ljmptab[4*4], offset Lcase4
mov Ljmptab[5*4], offset Lcase5
mov Ljmptab[6*4], offset Lcase6
mov Ljmptab[7*4], offset Lcase7
initialized:
mov edx,dword ptr[4+12+esp]
mov ecx,dword ptr[4+4+esp]
xor eax,eax
mov ebx,dword ptr[4+8+esp]
mov al,byte ptr[17+edx]
cmp al,8
jge Lerror
fld dword ptr[0+edx]
fld st(0)
jmp dword ptr[Ljmptab+eax*4]
Lcase0:
fmul dword ptr[ebx]
fld dword ptr[0+4+edx]
fxch st(2)
fmul dword ptr[ecx]
fxch st(2)
fld st(0)
fmul dword ptr[4+ebx]
fld dword ptr[0+8+edx]
fxch st(2)
fmul dword ptr[4+ecx]
fxch st(2)
fld st(0)
fmul dword ptr[8+ebx]
fxch st(5)
faddp st(3),st(0)
fmul dword ptr[8+ecx]
fxch st(1)
faddp st(3),st(0)
fxch st(3)
faddp st(2),st(0)
jmp LSetSides
Lcase1:
fmul dword ptr[ecx]
fld dword ptr[0+4+edx]
fxch st(2)
fmul dword ptr[ebx]
fxch st(2)
fld st(0)
fmul dword ptr[4+ebx]
fld dword ptr[0+8+edx]
fxch st(2)
fmul dword ptr[4+ecx]
fxch st(2)
fld st(0)
fmul dword ptr[8+ebx]
fxch st(5)
faddp st(3),st(0)
fmul dword ptr[8+ecx]
fxch st(1)
faddp st(3),st(0)
fxch st(3)
faddp st(2),st(0)
jmp LSetSides
Lcase2:
fmul dword ptr[ebx]
fld dword ptr[0+4+edx]
fxch st(2)
fmul dword ptr[ecx]
fxch st(2)
fld st(0)
fmul dword ptr[4+ecx]
fld dword ptr[0+8+edx]
fxch st(2)
fmul dword ptr[4+ebx]
fxch st(2)
fld st(0)
fmul dword ptr[8+ebx]
fxch st(5)
faddp st(3),st(0)
fmul dword ptr[8+ecx]
fxch st(1)
faddp st(3),st(0)
fxch st(3)
faddp st(2),st(0)
jmp LSetSides
Lcase3:
fmul dword ptr[ecx]
fld dword ptr[0+4+edx]
fxch st(2)
fmul dword ptr[ebx]
fxch st(2)
fld st(0)
fmul dword ptr[4+ecx]
fld dword ptr[0+8+edx]
fxch st(2)
fmul dword ptr[4+ebx]
fxch st(2)
fld st(0)
fmul dword ptr[8+ebx]
fxch st(5)
faddp st(3),st(0)
fmul dword ptr[8+ecx]
fxch st(1)
faddp st(3),st(0)
fxch st(3)
faddp st(2),st(0)
jmp LSetSides
Lcase4:
fmul dword ptr[ebx]
fld dword ptr[0+4+edx]
fxch st(2)
fmul dword ptr[ecx]
fxch st(2)
fld st(0)
fmul dword ptr[4+ebx]
fld dword ptr[0+8+edx]
fxch st(2)
fmul dword ptr[4+ecx]
fxch st(2)
fld st(0)
fmul dword ptr[8+ecx]
fxch st(5)
faddp st(3),st(0)
fmul dword ptr[8+ebx]
fxch st(1)
faddp st(3),st(0)
fxch st(3)
faddp st(2),st(0)
jmp LSetSides
Lcase5:
fmul dword ptr[ecx]
fld dword ptr[0+4+edx]
fxch st(2)
fmul dword ptr[ebx]
fxch st(2)
fld st(0)
fmul dword ptr[4+ebx]
fld dword ptr[0+8+edx]
fxch st(2)
fmul dword ptr[4+ecx]
fxch st(2)
fld st(0)
fmul dword ptr[8+ecx]
fxch st(5)
faddp st(3),st(0)
fmul dword ptr[8+ebx]
fxch st(1)
faddp st(3),st(0)
fxch st(3)
faddp st(2),st(0)
jmp LSetSides
Lcase6:
fmul dword ptr[ebx]
fld dword ptr[0+4+edx]
fxch st(2)
fmul dword ptr[ecx]
fxch st(2)
fld st(0)
fmul dword ptr[4+ecx]
fld dword ptr[0+8+edx]
fxch st(2)
fmul dword ptr[4+ebx]
fxch st(2)
fld st(0)
fmul dword ptr[8+ecx]
fxch st(5)
faddp st(3),st(0)
fmul dword ptr[8+ebx]
fxch st(1)
faddp st(3),st(0)
fxch st(3)
faddp st(2),st(0)
jmp LSetSides
Lcase7:
fmul dword ptr[ecx]
fld dword ptr[0+4+edx]
fxch st(2)
fmul dword ptr[ebx]
fxch st(2)
fld st(0)
fmul dword ptr[4+ecx]
fld dword ptr[0+8+edx]
fxch st(2)
fmul dword ptr[4+ebx]
fxch st(2)
fld st(0)
fmul dword ptr[8+ecx]
fxch st(5)
faddp st(3),st(0)
fmul dword ptr[8+ebx]
fxch st(1)
faddp st(3),st(0)
fxch st(3)
faddp st(2),st(0)
LSetSides:
faddp st(2),st(0)
fcomp dword ptr[12+edx]
xor ecx,ecx
fnstsw ax
fcomp dword ptr[12+edx]
and ah,1
xor ah,1
add cl,ah
fnstsw ax
and ah,1
add ah,ah
add cl,ah
pop ebx
mov eax,ecx
ret
Lerror:
int 3
}
}
#pragma warning( default: 4035 )
#endif
#endif
Code: Select all
q_math.c:1060: error: `i' undeclared (first use in this function)
q_math.c:1060: error: (Each undeclared identifier is reported only once
q_math.c:1060: error: for each function it appears in.)
Code: Select all
float RadiusFromBounds( const vec3_t emins, const vec3_t emaxs ) {
int i;
vec3_t corner;
float a, b;
for (i=0 ; i<3 ; i++) {
a = fabs( emins[i] );
b = fabs( emaxs[i] );
corner[i] = a > b ? a : b;
}
return VectorLength (corner);
}
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
I am now trying to compile under linux by just running the make command. I am not getting the same errors but differen't ones. What must I do in order to compile this mod?
Code: Select all
In file included from g_local.h:18,
from ai_chat.c:17:
q_shared.h:74:20: warning: assert.h: No such file or directory
q_shared.h:75:18: warning: math.h: No such file or directory
q_shared.h:76:19: warning: stdio.h: No such file or directory
q_shared.h:78:20: warning: string.h: No such file or directory
q_shared.h:79:20: warning: stdlib.h: No such file or directory
q_shared.h:80:18: warning: time.h: No such file or directory
q_shared.h:81:19: warning: ctype.h: No such file or directory
In file included from g_local.h:18,
from ai_chat.c:17:
q_shared.h:444: error: syntax error before ‘count’
q_shared.h:445: error: syntax error before ‘count’
q_shared.h: In function ‘VectorLength’:
q_shared.h:655: warning: incompatible implicit declaration of built-in function ‘sqrt’
ai_chat.c: In function ‘BotNumActivePlayers’:
ai_chat.c:64: warning: incompatible implicit declaration of built-in function ‘strlen’
ai_chat.c: In function ‘BotIsFirstInRankings’:
ai_chat.c:91: warning: incompatible implicit declaration of built-in function ‘strlen’
ai_chat.c: In function ‘BotIsLastInRankings’:
ai_chat.c:119: warning: incompatible implicit declaration of built-in function ‘strlen’
ai_chat.c: In function ‘BotFirstClientInRankings’:
ai_chat.c:149: warning: incompatible implicit declaration of built-in function ‘strlen’
ai_chat.c: In function ‘BotLastClientInRankings’:
ai_chat.c:183: warning: incompatible implicit declaration of built-in function ‘strlen’
ai_chat.c: In function ‘BotRandomOpponentName’:
ai_chat.c:219: warning: incompatible implicit declaration of built-in function ‘strlen’
ai_chat.c: In function ‘BotMapTitle’:
ai_chat.c:252: warning: incompatible implicit declaration of built-in function ‘strncpy’
ai_chat.c: In function ‘BotChat_Death’:
ai_chat.c:575: warning: incompatible implicit declaration of built-in function ‘strcpy’
ai_chat.c: In function ‘BotChat_EnemySuicide’:
ai_chat.c:744: warning: incompatible implicit declaration of built-in function ‘strcpy’
ai_chat.c: In function ‘BotChat_Random’:
ai_chat.c:905: warning: incompatible implicit declaration of built-in function ‘strcpy’
ai_chat.c: In function ‘BotChatTest’:
ai_chat.c:1177: warning: incompatible implicit declaration of built-in function ‘strcpy’
make: *** [ai_chat.o] Error 1
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Code: Select all
In file included from g_local.h:18,
from ai_chat.c:17:
q_shared.h:74:20: warning: assert.h: No such file or directory
q_shared.h:75:18: warning: math.h: No such file or directory
q_shared.h:76:19: warning: stdio.h: No such file or directory
q_shared.h:78:20: warning: string.h: No such file or directory
q_shared.h:79:20: warning: stdlib.h: No such file or directory
q_shared.h:80:18: warning: time.h: No such file or directory
q_shared.h:81:19: warning: ctype.h: No such file or directory
Ok I edited the Makefile, Makefile.q3, and Makefile.ta and added in the -I/usr/include option to the CFLAGS. I still get the same errors.
Code: Select all
make
cc -c -MMD -pipe -DNDEBUG -O6 -ffast-math -fstrength-reduce -DQAGAME -fPIC -I/usr/include ai_chat.c -o OBJS/Q3/ai_chat.o
In file included from g_local.h:18,
from ai_chat.c:17:
q_shared.h:74:20: warning: assert.h: No such file or directory
q_shared.h:75:18: warning: math.h: No such file or directory
q_shared.h:76:19: warning: stdio.h: No such file or directory
q_shared.h:78:20: warning: string.h: No such file or directory
q_shared.h:79:20: warning: stdlib.h: No such file or directory
q_shared.h:80:18: warning: time.h: No such file or directory
q_shared.h:81:19: warning: ctype.h: No such file or directory
In file included from g_local.h:18,
from ai_chat.c:17:
q_shared.h:444: error: syntax error before ‘count’
q_shared.h:445: error: syntax error before ‘count’
q_shared.h: In function ‘VectorLength’:
q_shared.h:655: warning: incompatible implicit declaration of built-in function ‘sqrt’
ai_chat.c: In function ‘BotNumActivePlayers’:
ai_chat.c:64: warning: incompatible implicit declaration of built-in function ‘strlen’
ai_chat.c: In function ‘BotIsFirstInRankings’:
ai_chat.c:91: warning: incompatible implicit declaration of built-in function ‘strlen’
ai_chat.c: In function ‘BotIsLastInRankings’:
ai_chat.c:119: warning: incompatible implicit declaration of built-in function ‘strlen’
ai_chat.c: In function ‘BotFirstClientInRankings’:
ai_chat.c:149: warning: incompatible implicit declaration of built-in function ‘strlen’
ai_chat.c: In function ‘BotLastClientInRankings’:
ai_chat.c:183: warning: incompatible implicit declaration of built-in function ‘strlen’
ai_chat.c: In function ‘BotRandomOpponentName’:
ai_chat.c:219: warning: incompatible implicit declaration of built-in function ‘strlen’
ai_chat.c: In function ‘BotMapTitle’:
ai_chat.c:252: warning: incompatible implicit declaration of built-in function ‘strncpy’
ai_chat.c: In function ‘BotChat_Death’:
ai_chat.c:575: warning: incompatible implicit declaration of built-in function ‘strcpy’
ai_chat.c: In function ‘BotChat_EnemySuicide’:
ai_chat.c:744: warning: incompatible implicit declaration of built-in function ‘strcpy’
ai_chat.c: In function ‘BotChat_Random’:
ai_chat.c:905: warning: incompatible implicit declaration of built-in function ‘strcpy’
ai_chat.c: In function ‘BotChatTest’:
ai_chat.c:1177: warning: incompatible implicit declaration of built-in function ‘strcpy’
make: *** [ai_chat.o] Error 1
Well I have run into another error after trying to use the mod. The game server rejects it. The server will load it for a few seconds then the entire q3 process crashes. I also noticed that my patched version of the mod is about 25KB smaller than the original. This seems like a big difference and I was also expecting it to be larger in size since I was adding the wrapper function. I compiled the qagamei386.so under ubuntu linux but it is running on a CentOS4 final game server. I am unsure if that matters or not...
Any ideas would be much appreciated.
Any ideas would be much appreciated.
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
nexus024 wrote:CFLAGS= -I /usr/include -static
The quake3 process still crashes with the .so file compiled with -static.
^misantropia^ wrote:Compile a debug version (add -g to your CFLAGS) and run it in gdb. Do a backtrace (`bt`) when it crashes. You might need a debug build of the engine as well to get meaningful results.
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm