Quake3World.com Forums
     Programming Discussion
        Quake 3 : Add a trap function ?


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Quake 3 : Add a trap function ?

Recruit
Recruit
Joined: 29 Jun 2007
Posts: 3
PostPosted: 06-29-2007 06:45 AM           Profile Send private message  E-mail  Edit post Reply with quote


Do you know how to add your own trap function ?
I put my function in qcommon directory and I want to call it from the game directory (like for example the trap_FS_Write function).
I do the same (definition/declaration) like the other trap functions but I suppose the problem is to find the correct id for the g_syscalls.asm.

For example :

In qcommon/common.c :

void example_trap_function( void )
{
int i = 12345; // only for for debug
}


In qcommon/q_shared.h :

void example_trap_function( void );


In game/g_local.h :

void example_trap_function( void );


In game/gpublic.h :

in the gameImport_t enum adding the line :

EXAMPLE_TRAP_FUNCTION


In game/g_syscalls.c :

void example_trap_function( void )
{
syscall( EXAMPLE_TRAP_FUNCTION );
}

You have to modify the game.q3asm for compiling g_syscalls.c (replace line ../g_syscalls with g_syscalls) with ioquake3.


In game/g_syscalls.asm :

adding this line at the end of the file :

equ trap_example_trap_function -600

Is it my problem ?
How to know the number ?


In game/g_main.c :

Use the example function in G_InitGame :

trap_example_trap_function( );


Compiling is ok
After installing everything (bin and qvm) and starting the game it's ok.
When the map is launching (G_InitGame function) I have this message :

bad game system trap -582

582 is the number for the trap_BotLibSourceFileAndLine in the g_syscalls.asm file.
I add my line after it...




Top
                 

Mentor
Mentor
Joined: 12 Mar 2005
Posts: 3958
PostPosted: 06-29-2007 07:11 AM           Profile Send private message  E-mail  Edit post Reply with quote


Alf2010 wrote:
in the gameImport_t enum adding the line :

EXAMPLE_TRAP_FUNCTION

I think you'll want to make that:
Code:
EXAMPLE_TRAP_FUNCTION = -600




Top
                 

Recruit
Recruit
Joined: 29 Jun 2007
Posts: 3
PostPosted: 06-29-2007 07:38 AM           Profile Send private message  E-mail  Edit post Reply with quote


I think you're right but there is an other mistake because now the error message is : bad game system trap -600




Top
                 

Mentor
Mentor
Joined: 12 Mar 2005
Posts: 3958
PostPosted: 06-29-2007 07:42 AM           Profile Send private message  E-mail  Edit post Reply with quote


You'll also need to add it to SV_GameSystemCalls() in server/sv_game.c




Top
                 

Recruit
Recruit
Joined: 29 Jun 2007
Posts: 3
PostPosted: 06-29-2007 08:12 AM           Profile Send private message  E-mail  Edit post Reply with quote


Thank's a lot :)

The modifications to have it working :

In game/gpublic.h :

in the gameImport_t enum adding the line :

EXAMPLE_TRAP_FUNCTION = 600


In server/sv_game.c :

in the SV_GameSystemCalls function adding the lines :

case EXAMPLE_TRAP_FUNCTION:
example_trap_function();
return 0;




Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.