linking files across projects

Locked
zonide
Posts: 11
Joined: Fri Aug 25, 2006 10:41 pm

linking files across projects

Post by zonide »

short version:

i just need to know how to access CG_CenterPrint which is located in cgame - cg_draw.c from ClientBegin which is located in game - g_client.c

issue:

cant find cg_centerprint and dont know how to properly link the 2 files

guess:

because the files containing cg_centerprint are located in a different project
_______________________

ive been looking for how to print messages in large text in the center of the screen since ive started

ex: You Fragged X

i found it today :

project - file - function

cgame - cg_event.c - CG_Obituary -

s = va(S_COLOR_GREEN "You obliterated %s\n%s place with %i", targetName,

CG_PlaceString( cg.snap->ps.persistant[PERS_RANK] + 1 ),

CG_CenterPrint( s, SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );

changed some of the messages just to test it

ex: You Obliterated X

it worked...

i tried to put the code in to another project

game - g_client.c - client_begin

CG_CenterPrint( S_COLOR_GREEN "ZoNiDe", SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );

it doesnt link properly...

game error LNK2019: unresolved external symbol _CG_CenterPrint referenced in function _ClientBegin

game fatal error LNK1120: 1 unresolved externals

i tried to include cg_draw.c in g_client.c

#include "../cgame/cg_draw.c"

\code\game\bg_public.h(98): error C2365: 'GT_FFA' : redefinition; previous definition was a 'enumerator'

didnt work... it gave me a sh*t load of errors

then i noticed that some of the other projects used files that were in other projects...

1 file being used by 2 projects? no errors?

so then i tried it... wouldnt let me add the cg_draw.c to the game source files... it would only let me put it in the header folder.. seemed like i was making progress...

i hit play...

game error LNK2019: unresolved external symbol _trap_R_RenderScene referenced in function _CG_Draw3DModel

im guessing i should find the file that contains _trap_R_RenderScene and add it to the headers folder

i did... it was in cg_main.c

i added it and hit play

game error LNK2005: _vmMain already defined in g_main.obj

ok... now what...

please help
zonide
Posts: 11
Joined: Fri Aug 25, 2006 10:41 pm

Post by zonide »

im new if you cant already tell

_____________

i just noticed that q_shared is used by both game and cgame

....

im going to try to write a function that calls CG_CenterPrint from ClentBegin using q_shared.h as a link
zonide
Posts: 11
Joined: Fri Aug 25, 2006 10:41 pm

Post by zonide »

void zLinkCG_CenterPrint( const char *str, int y, int charWidth ) {

CG_CenterPrint (str, y, charWidth);
}

didnt work

:icon32: :icon32: :icon32:

\code\game\q_shared.h(1436): warning C4013: 'CG_CenterPrint' undefined; assuming extern returning int
corncobman
Posts: 304
Joined: Fri Aug 08, 2003 7:00 am

Post by corncobman »

You can't call a function within cgame from game. You can, however, create an event and then call it when the event happens.

As for making cgame use center print just put the line

trap_SendServerCommand( ent-g_entities, "cp \"blah blah blah\n\"");

You can substitute the blah blah blah for whatever.
zonide
Posts: 11
Joined: Fri Aug 25, 2006 10:41 pm

Post by zonide »

as far as creating an event goes... im not sure what exactly you mean

the trap server thing worked though
Locked