Question: Problem with CVARS in bothgame-files


(nUllSkillZ) #1

Hi,

I’m working around the cvars and menus.
And try to correct an inconsistency that has appeared in the tutorial I have written.
The value of a cvars can be set via menu.
In the menu file there is one variable name per cvar.
The cvar should be declared in the “_main.c"- and "local.h"-file where it fits best.
Now I have the problem to use this variable in a "bg
.c"-file (both game).
In the menu I have only one variable.
Whereas I have two corresponding cvars in the "bg
.c”-file (comming from the game- and cgame-files).


(digibob) #2

Cvars used in bgame should be kept to a bare minimum, and i’d avoid it completely if at all possible. If the cvar can be set independantly on the client and the server, then you are likely to run into inconsistancies between what the client sees, and what the server thinks is going on, which is a very bad thing.


(jamez) #3

well nullskillz, is it a cvar that the server should have set or the client? (by server i mean what the dedicated server would set)


(nUllSkillZ) #4

Normally it should be set by the server.
But as the file belongs to both games (to the server and to the client) I don’t know how this is handled during compilation.
In the concerned function there are some other “bothgame” variable used (gametype and movespeed):


#ifdef CGAMEDLL
	int gametype = cg_gameType.integer;
	int movespeed = cg_movespeed.integer;
#elif GAMEDLL
	int gametype = g_gametype.integer;
	int movespeed = g_movespeed.integer;
#endif

But I think they aren’t set by menu or command line.


(jamez) #5

Movespeed? yeh it should be set on server side, why dont u make it a cvar that only gets set on server side, u have rcon if u want it set from client side
and i think the only problem would be client prediction right? i think it is already set to be based on the movespeed anyway


(bacon) #6
{ &cg_movespeed, "g_movespeed", "76", 0 }, // actual movespeed of player

So the cg_movespeed is set to the value of g_movespeed, which is totally pointless. It does not get called at all in the client code. Why is it there?


(nUllSkillZ) #7

These two variables were already in the code in the function I try to change.
This is original code.


(guerilla) #8

I’m not sure I even understand the question yet. what was the question exactly?


(=>ETK<=Elite) #9
{ &cg_movespeed, "g_movespeed", "76", 0 }, // actual movespeed of player

So the cg_movespeed is set to the value of g_movespeed, which is totally pointless. It does not get called at all in the client code. Why is it there?

I know this is pretty old…but just in case there are others that want to know why that quoted line was in there I will explain.

This is located in the cvar tables. The cg_movespeed is what it was declared as in the source, and g_movespeed is what it is referred to and accessed by through the console. The default value is 76 in this case, and the next number in that statement says this cvar has not been modified yet, which should always be the case (atleast as far as I am aware) in the cvar table. It is not actually 2 different cvars, rather it is more of an alias I guess in a way.