PDA

View Full Version : Cvar Limit


Kyle098
09-12-2002, 04:46 PM
hey i added like 23 new cvars,so the server can control the damage and velocity of each weapon,but when i compiled it and ran it,when i did create server,right before it loaded my monitor blinked a couple of times then it quit tyjhe program,then i removed like 18 of those cvars and it worked,is there a cvar limit that i reached,because i only added 23 cvars so far to jedimod1.2,if,someone is a good coder i can give them my source so they check it out,but only if i trus you(people like ask,dest...and so on i knoiw wont steal my source because they have been through someone stealing source.)

Azymn
09-12-2002, 06:21 PM
How are you flagging them?

ASk
09-13-2002, 04:34 AM
There's a limit for one thing: server-to-client config string:


// the game guarantees that no string from the network will ever
// exceed MAX_STRING_CHARS
#define MAX_STRING_CHARS 1024 // max length of a string passed to Cmd_TokenizeString
#define MAX_STRING_TOKENS 1024 // max tokens resulting from Cmd_TokenizeString
#define MAX_TOKEN_CHARS 1024 // max length of an individual token

#define MAX_INFO_STRING 1024
#define MAX_INFO_KEY 1024
#define MAX_INFO_VALUE 1024

#define BIG_INFO_STRING 8192 // used for system info key only
#define BIG_INFO_KEY 8192
#define BIG_INFO_VALUE 8192



This effectively limits the cvar number, but I do not think that this was the problem

Azymn
09-13-2002, 01:11 PM
This effectively limits the cvar number, but I do not think that this was the problem
I agree - this only limits the length of the cvar string being passed from game to cgame.

Kyle098
09-13-2002, 10:56 PM
hey,what do u mean how am i flagging them,i add it to g_local.h,then in g_main.c i add them there and add them to the table.for example if i want my cvar to be rage_blasterdam in g__local.h i type:
extern vmCvar_t rage_blasterdam;
in g_main.c
vmCvar_t rage_blasterdam

then in g_main.c in the table:
{ &rage_blasterdam, "rage_blasterdam", "20", CVAR_SERVERINFO | CVAR_LATCH, 0, qfalse },
ive also tried:
{&rage_blasterdam, "rage_blasterdam", "20", CVAR_ARCHIVE |CVAR_SERVERINFO , 0, qfalse },
with all of them but that too doesnt work,hey darth syrup if your willing to help i am willing to give you my source code and you then can see right away what the problem is.

Azymn
09-13-2002, 11:50 PM
Change this:
{&rage_blasterdam, "rage_blasterdam", "20", CVAR_ARCHIVE |CVAR_SERVERINFO , 0, qfalse },

...to this:
{&rage_blasterdam, "rage_blasterdam", "20", CVAR_ARCHIVE, 0, qfalse },

And make sure you only have it in there once (it's shown twice above). Don't change anything else.

Kyle098
09-13-2002, 11:57 PM
hey,thanks i will try that,you are very helpfull,unlike deadlybofh,=here is my conversation with him today,and jevery other time i ask him a question:
sk8ingaelement: hey,can u answer a quick question?
Guitarist 225: depends who are u
sk8ingaelement: from the message boards,kyle098,BUT i already got the questions i asked you before all answered.i now just have a quick one.
sk8ingaelement: I wanted the time between fires to get changed,so now i made that in bg_weapons.c but when i compile it says that:
../bg_weapons.c:87: initializer must be constant
../bg_weapons.c:104: initializer must be constant
sk8ingaelement: how can i make the number be a cvar then?
Guitarist 225: ok
Guitarist 225: that doesnt help me
sk8ingaelement: what other info do u need?
sk8ingaelement: ?
sk8ingaelement: are u there?
Guitarist 225: IM BUSY
Guitarist 225: not now
sk8ingaelement: ok,i will ask like 20 minutes later.
Guitarist 225: no
Guitarist 225: ur not
sk8ingaelement: ?when?
Guitarist 225: how bout never
sk8ingaelement: why do u have to be so mean?
Guitarist 225: cuz im ****ing busy
Guitarist 225: now go away

Kyle098
09-14-2002, 12:23 AM
yay it worked,so once again thanks darth syrup.i have another question now(there is always another one,lol.,i am still sorta a biggener in this mod making.) I wanted the time between fires to get changed,so now i madecvar instead of the numbers in bg_weapons.c but when i compile it says that:
../bg_weapons.c:87: initializer must be constant
../bg_weapons.c:104: initializer must be constant .
i know it is possibe because jediplus i think has variables for it because he said ou can now change all the weapon speeds.

Azymn
09-14-2002, 12:28 AM
If you want to change the weapon speeds, don't put the cvar in the array:
somewhere before the array is read to determine weapon speed, set the value in the array equal to the cvar. Then the array will have the value in it, and your speed will change.

Kyle098
09-14-2002, 11:56 AM
array, i am sorry but i dont know what you mean,the code is like this:
{ // WP_BRYAR_PISTOL,
// "Bryar Pistol", // char classname[32]; // Spawning name
AMMO_BLASTER, // int ammoIndex; // Index to proper ammo slot
15, // int ammoLow; // Count when ammo is low
2, // int energyPerShot; // Amount of energy used per shot
400, // int fireTime; // Amount of time between firings
8192, // int range; // Range of weapon
2, // int altEnergyPerShot; // Amount of energy used for alt-fire
400, // int altFireTime; // Amount of time between alt-firings
8192, // int altRange; // Range of alt-fire
0, // int chargeSubTime; // ms interval for subtracting ammo during charge
200, // int altChargeSubTime; // above for secondary
0, // int chargeSub; // amount to subtract during charge on each interval
1, //int altChargeSub; // above for secondary
0, // int maxCharge; // stop subtracting once charged for this many ms
1500 // int altMaxCharge; // above for secondary

now i change the 400 to rage_blastervel for example but it gives me that problem.
do u mean i should do the following before the setting:
#define firetime rage_blastervel;
?

ASk
09-14-2002, 01:39 PM
He means that before that variable is referenced, you need to make it equal to the cvar.

Array elements must be constant on their definitions.

You can always do this: a switch statement on each reference of the variable, on the condition of the currently active weapon, where you make it to use the specific cvar.

Kyle098
09-14-2002, 02:06 PM
where is this variable referenced?do u mean in g_weapons.c under the bryan pistol coding for example where it says like:
int damage = BRYAR_PISTOL_DAMAGE;
and stiff like that i should add:
int firetime = Rage_pistolvel
or in like bg_weapons.h there is a
int fireTime;
But i cant set that to a variable because it is for all the firetime weapons and i cant have one cvar for all of them.

Sorry for the dumb questions as i said before i am a biggener in game coding.

also i am trying so people can find my game like in jedimod and i replaced in ui_main.c:
static const serverFilter_t serverFilters[] = {
{"All", "" },
{"Jedi Knight 2", "" },
{"JediMod", "JediMod" },
with
static const serverFilter_t serverFilters[] = {
{"All", "" },
{"Jedi Knight 2", "" },
{"JediRage", "JediRage" },

but it still doesnt work.

Azymn
09-14-2002, 03:28 PM
But i cant set that to a variable because it is for all the firetime weapons and i cant have one cvar for all of them.
Try what ASk said, make a switch statement - if it's the gun you want to change the speed for, use the cvar, else on the default case, use the array.


static const serverFilter_t serverFilters[] = {
{"All", "" },
{"Jedi Knight 2", "" },
{"JediRage", "JediRage" },

Is your mod loading from a "JediRage" folder in the Gamedata directory?

Kyle098
09-14-2002, 04:26 PM
Originally posted by Darth_Syrup

Is your mod loading from a "JediRage" folder in the Gamedata directory?
OHH,OK,THEN IWILL DO THAT.

so in bg_pmove it says:
if ( pm->cmd.buttons & BUTTON_ALT_ATTACK ) {
if (pm->ps->weapon == WP_DISRUPTOR && pm->ps->zoomMode != 1)
{
PM_AddEvent( EV_FIRE_WEAPON );
addTime = weaponData[pm->ps->weapon].fireTime;
}
else
{
PM_AddEvent( EV_ALT_FIRE );
addTime = weaponData[pm->ps->weapon].altFireTime;
}
}
else {
PM_AddEvent( EV_FIRE_WEAPON );
addTime = weaponData[pm->ps->weapon].fireTime;
by switch statement do u mean a if then else statement?
something like:
if (wp_BryanPistol)
{
int firetime= rage_pistolvel.integer
}

Azymn
09-14-2002, 05:15 PM
by switch statement do u mean a if then else statement?
something like:
if (wp_BryanPistol)
{
int firetime= rage_pistolvel.integer
}

Yeah, something like that. :)
Why not just:

if (wp_BryanPistol)
{
addTime = rage_pistolvel.integer
}

Then you won't have to change the array, assuming it's not used anywhere else (i'm pretty sure the firetime is only checked right here).

Kyle098
09-14-2002, 06:22 PM
oh ok now i get it so should i put
if (wp_BryanPistol)
{
addTime = rage_pistolvel.integer
}
instead of what it says or should i put all the weapons first and write else then waht it said before i changed the code.

Kyle098
09-14-2002, 07:36 PM
i did what you told me and when i compiled it said that my cvars where undeclared identifiers so i declared each cvar in the begginign of g_pmove.c by typing the following for each cvar:
extern vmCvar_t rage_pistolspeed;

then it compiled but in the game now my guns shoot but they dont shoot anything?did i declare my cvars in the wrong place or did i edit the wrong thing?

Kyle098
09-14-2002, 07:41 PM
never mind i got the gun to shoot,but now the only problem is that they all shoot at one fast rate and changeing the cvar value doesnt make the speed change.

Kyle098
09-14-2002, 08:39 PM
now i got the speed to go down somehow by making the if statemet to this:
if (pm->ps->weapon == WP_BRYAR_PISTOL)
{
PM_AddEvent( EV_FIRE_WEAPON );
addTime = rage_pistolspeed.integer;
}
but i stillcant chnage the speed in the game and now the alt attack on some weapons is the same as the regular attack and on some it is combined.

Kyle098
09-15-2002, 02:26 AM
anyone?

Azymn
09-15-2002, 02:31 AM
Look through the code, look at what it does for each weapon's primary and secondary fire, and look at what you're doing.

Kyle098
09-15-2002, 10:52 AM
no, i am pretty sure the problem is not that but the problem is the cvar i declared i the wrong place and\or bg_pmove doesnt reach g_main.c where the value of the cvars are declared and stuff.

The Eternal
09-16-2002, 08:13 AM
The pmove stuff should be seen seperately from game and cgame..

it might have access to g_main, sure but it ****s up on movement prediction clientside when accessing that. you should use a seperate array in pmove_t for example. i haven't ever tested cvars in pmove i think, (never needed them) but i 'think' it ****s up.

(btw, there is no cvar limit, only memory limit because q3 uses a linked list if it's using a cvar system anthing like q2's)

also the cvars do need to be communicated with the clients for them to do correct weapon predictions.. which give problems when using alot (i did it in a q3 mod once.. lotta problems ;) but making the variable names really small and removing alot of them fixxed it)

Kyle098
09-16-2002, 02:14 PM
ohh, yesterday i was looking through the coding of only pmove for like half an hour and i figured it out, now it all works and i made the alt fire sweet(especially the bowcaster).i want someone good to test it out,i can send you the pk3.

ASk
09-16-2002, 04:03 PM
The Eternal: there's a limit on a config string length that the server can pass to clients. That effectively limits the g_ cvars number.

Azymn
09-16-2002, 06:17 PM
The Eternal: there's a limit on a config string length that the server can pass to clients. That effectively limits the g_ cvars number.

True, but you can set a variable inside the cgs struct in cgame equal to a cvar in game, without having to pass it thru the config string. As long as the cvar is flagged as SERVERINFO in game, it will update the respective struct in cgame (with the proper code in place) whenever the game cvar is modified.
Then you don't have to worry about config string lengths (the max is 1024, right?)

Kyle098
09-16-2002, 11:59 PM
lol i can just imagine a 1024 letter long cvar:D
ok i sent my mod to jk2files and i said it is Jedi Rage beta.for now i still dont want it to say that it is the full version because i am still working on alot of things,i just want to see how people like it.also does anyone know how long it usually takes for them to put it up on there site,i didnt have a screenshot made?

The Eternal
09-20-2002, 04:45 PM
ask. i know but i wasn't talking about that :)
i tought they where talking about the maximum amount of cvars, not about the maximum amount of shared cvars