Reading Client Only CVAR


(Schaffer) #1

Hi, I feel rather stupid asking this but I’m not really sure how to read a client side CVAR I have setup.

This is the code I have added:
glocal.h


extern vmCvar_t g_tracemap_size;			// size of the tracemap to generate

Then ing_main.c


vmCvar_t		g_tracemap_size;  // User Size of tracemap for generation only


{ &g_tracemap_size, "g_tracemap_size", "1024", CVAR_ARCHIVE },

Now when i try to use this in bg_tracemap.c I the following code:


#ifdef CGAMEDLL 
   info = CG_ConfigString(CS_SERVERINFO); 
   s = Info_ValueForKey(info, "g_tracemap_size"); 
if (s) 
   c_tracemap_size = atoi(s); 
#elif GAMEDLL 
   c_tracemap_size = g_tracemap_size.integer;
#endif 

CG_Printf("Tracemap size is %i
",c_tracemap_size);

Now this always returns the value of 0 regaurdless of what I have set g_tracemap_size to. When type in \g_tracemap_size in the console it says it is for example 1024 (default 1024) which is all cool it’s just when I try to use it, then nothing.

Sorry if you think I’m a pain, I’m just trying to get my head around this and it hurts. (Probably those 10 or so pints of Killkenny and the hald a dozen Sambucas from yesterday)

Thanks for any help I get. I sort of think that maybe this code should be setup in cgmain.c (hmmmmm)


(bacon) #2

Make a client-side CVAR then in cg_servercmds.c at the end of CG_ParseServerinfo() add:

trap_Cvar_Set( "cg_tracemap_size", va("%i", atoi( Info_ValueForKey( info, "g_tracemap_size" ) )));

Then somewhere in bg_tracemap.c add:


#ifdef CGAMEDLL
//extern vmCvar_t cg_tracemap_size;          // uncomment if this gives you an error
#define c_tracemap_size cg_tracemap_size.integer
#elif GAMEDLL
//extern vmCvar_t g_tracemap_size;            // uncomment if this gives you an error
#define c_tracemap_size g_tracemap_size.integer
#endif


(Schaffer) #3

Thanks for the reply Bacon but I had sort of worked it out in the end.

This is the code I used in bg_tracemap.c


  trap_Cvar_VariableStringBuffer( "cg_tracemap_size", buffInfo, sizeof(buffInfo));
  c_tracemap_size = atoi(buffInfo);

This is for a sort of developer mod that I am playing around with. It was originally inspired by Duke’ku with his high resolution tracemap mod but mine expands on this allowing (and it now works) for selection of a variety of different size tracemaps as well as starting a map in dev mode through the UI and providing in-game menus for creating the tracemaps as well as screenshots, including enabling and disabling on scree display as well as noclip