Replacing a quake3 function

AnthonyJ
Posts: 130
Joined: Wed Nov 15, 2006 7:51 pm

Post by AnthonyJ »

Install ioq3 and you'll be fine.

Or, if you really want to compile it yourself, dl the engine source, make the change in the diff I linked, and then recompile it.

Note that neither of these solutions will allow you to use punkbuster on the server though.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

Ah, it starts to make sense now. You're better off using ioq3 altogether because the q3msgboom bug wasn't exactly the only thing that needed patching. And you can indeed use q3as with ioq3.
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

Ok but the problem remains that I must keep my server as a 1.32c point release. In looking at ioq3 it says the point release is 1.34. Doesn't this mean then that people wouldn't be able to connect to my server with the 1.32c point release?
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

This server that I play on is running punkbuster, pt release 1.32c, and their server fully patched for the q3msgboom bug. I have e-mailed the administrator of the server and asked him how he did it but he doesn't respond to my e-mails. Can any of you think of a way this admin has accomplished this?
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

Does anyone have or know where I could obtain the source for Q3as 1.99q mod?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

No, but to answer the question of ioq3 1.34 being compatible with 1.32c: yes, it is.
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

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:

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
q_math.c: 817

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.)
q_math.c:1060

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);
}
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

What compiler are you using and could you post the entire compile log?
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

I am using gcc make that is part of cygwin... could that be a problem?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

Yep. __declspec(naked) only works with MSVC (and then only when compiling for x86, not x64). q_math.c also sports an implementation of BoxOnPlaneSide written entirely in C; replace the offending function with that one. Or edit the Makefile and add -DC_ONLY to the CFLAGS.
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

So I need to compile this under linux if I want to create a .so file in the end?
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

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
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

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
The compiler can't find the standard include files. How to fix it? An easy albeit hackish solution would be to add -I/usr/include to the CFLAGS.
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

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
Sevensins
Posts: 444
Joined: Tue Jul 17, 2001 7:00 am

Post by Sevensins »

do you have the standard libraries installed?

Are they in /usr/include?
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

That was it! I just needed to download the standard library files and it compiled without a hitch! Thanks for all your help.
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

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.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

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.

EDIT: and yeah, you'll need to compile with -static if you're going to use the .so across distros.
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

I am a bit unfamiliar with some of this terminology. What does gdb stand for? Also, you said to compile with -static so does that mean I would issue this command 'make -static' ?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

Ah, sorry, no. Add it to your CFLAGS. It'll produce a .so that doesn't depend on external libraries.
Sevensins
Posts: 444
Joined: Tue Jul 17, 2001 7:00 am

Post by Sevensins »

nexus024 wrote:What does gdb stand for?
just Google gdb, you'll want to read on how to use it anyway

it stands for gnu debugger, btw
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

CFLAGS= -I /usr/include -static

The quake3 process still crashes with the .so file compiled with -static.
Sevensins
Posts: 444
Joined: Tue Jul 17, 2001 7:00 am

Post by Sevensins »

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.
nexus024
Posts: 148
Joined: Fri Oct 06, 2006 7:26 pm

Post by nexus024 »

Where might I obtain a debug build of the engine?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

- Download icculus: `svn checkout svn://svn.icculus.org/quake3/trunk quake3`
- Create a Makefile.local in the same directory where the Makefile resides
- Add this line to it: CFLAGS="-static"
- Run: `make debug`

And there's your debug build. :)
Locked