using unused cvars for mods?

Discuss programming topics for the various GPL'd game engine sources.
Post Reply
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

using unused cvars for mods?

Post by drm_wayne »

Hey,

I found a few unused cvars in Quake like "saved1", saved2" etc, and im currently wondering if i can use them
for a mod but i have a few questions:

- The cvar gets saved to the config, so is it a client side cvar?
- Can i use it for setting custom start weapons or teams?

If yes it would be really usefull since alot of engines have those saved cvars, so my mod will run in Darkplaces too :)
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: using unused cvars for mods?

Post by Cobalt »

There is also :

nomonsters , monsters

both I believe are traditional cvars that came with original Quake.

The cvars are always 16 bit floats , range is : -16777216 to 16777216

Actually when you look at it, its really a 32 bit float if you make code to account for the negative values.

Now that I think of it, I wonder of the PARMS 1-15 which are 24 bit floats also hold negative values in which case they would be 48 bit in the same sense.

But anyway, the cvar floats are server side, not client side as far as writing or changing them. Client side is read-only written by the QC.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: using unused cvars for mods?

Post by Spike »

frikac did a load of float tricks to pack more info into the parms in prydon gate. most of these tricks will loose precision from string conversions, and will thus be unusable for cvars, but may be usable if your settings are player-specific and thus can use parms for them.
using the negative bit of floats only gives 1 extra bit, not twice as many. due to string conversions you cannot distinguish between positive and negative 0 (also true if you're using dp).
an ieee single-precision float has 23 mantissa bits, 8 exponent bits, and 1 sign bit.
thus 23 integer bits can trivially be stored in a float. 24 bits is possible, but uses a different bit pattern. 25 bits will suffer from precision issues and will start to forget other bits.

nomonsters, gamecfg, scratch1, scratch2, scratch3, scratch4, savedgamecfg, saved1, saved2, saved3, saved4, temp1, noexit
none of those cvars have any special meaning to the engine.
you can probably find others (like modem cvars) which are defined but not used by most players.

many engines support a 'set' console command which can be used to dynamically create new cvars. be sure it use it in your mod's default.cfg
'seta' also exists in many engines, which will attempt to preserve the cvars over engine restarts.
you can then just use the regular cvar builtins for these cvars as if they always existed.

for completeness: if you're making a quakeworld mod, you can use the serverinfo/localinfo/setinfo commands combined with the infokey builtin to create custom(or per-player) settings.
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: using unused cvars for mods?

Post by drm_wayne »

well i want to add a custom menu where the player can choose their starting layout in a multiplayer match..
so i can use the saved1 etc.. or did i need to add a new one?

I dont want everybody have the same layout xD
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: using unused cvars for mods?

Post by Cobalt »

Choose their spawn? If you want to draw a representation of the map I would guess you do that part in csqc....or I dunno if menu.dat is a simpler way for your objective.
If none of those legacy type free cvars appeal to you I gues you can use registercvar.

Code: Select all

registercvar ("player1_layout", "0");
registercvar ("player2_layout", "0");
registercvar ("player3_layout", "0");
registercvar ("player4_layout", "0");


drm_wayne wrote:well i want to add a custom menu where the player can choose their starting layout in a multiplayer match..
so i can use the saved1 etc.. or did i need to add a new one?

I dont want everybody have the same layout xD
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: using unused cvars for mods?

Post by Spike »

ditch register_cvar.
the most portable solution, and the most user friendly, is to provide your own default.cfg and include lots of set console commands in there. This allows you to easily set your various defaults. use seta if you want it to be saved to the user's config so that its restored when they next load up your game.
the advantage of using the console command is that the cvar is valid before any qc code was even execed. which means it can be changed by the user before they start a map - plus ALL default cvar settings are then in the same place.

the most efficient way to deal with cvars is to use autocvars, but this requires an engine that supports them (read: dp+fte).

choosing starting positions requires you to know the valid locations first. I would assume such things would be best implemented inside csqc on a per-spawn basis or so - this would result in removing the need for using cvars for it, or at least cut it down to a single client-side cvar.
remember dedicated servers have no menuqc or csqc, so its either personal spawn spot, or its unusable.
Post Reply