#define CF_PRIVATE (1<<11) // cvar should not be $ expanded or sent to the server under any circumstances (rcon_password, etc)
#define CF_MAXFLAGSVAL ((1<<12) - 1) // used to determine if flags is valid
// for internal use only!
+#define CF_REGISTERED (1<<29) // created by Cvar_RegisterVariable()
#define CF_DEFAULTSET (1<<30)
-#define CF_ALLOCATED (1<<31)
+#define CF_ALLOCATED (1<<31) // created by Cvar_Get() (console or QC)
#define CF_SHARED 3
return;
}
+ if (!(var->flags & CF_REGISTERED) && !(var->flags & CF_ALLOCATED))
+ {
+ Con_Printf(CON_WARN "Warning: Cvar_SetQuick() cannot set unregistered cvar \"%s\"\n", var->name);
+ return; // setting an unregistered engine cvar crashes
+ }
+
if (developer_extra.integer)
Con_DPrintf("Cvar_SetQuick({\"%s\", \"%s\", %i, \"%s\"}, \"%s\");\n", var->name, var->string, var->flags, var->defstring, value);
cvar_hash_t *hash;
int hashindex;
+ if (cls.state == ca_dedicated && !(variable->flags & CF_SERVER))
+ return;
+
if(!*name)
{
- Con_Printf("Cvar_RegisterVirtual: invalid virtual cvar name\n");
+ Con_Printf(CON_WARN "Cvar_RegisterVirtual: invalid virtual cvar name\n");
return;
}
// check for overlap with a command
if (Cmd_Exists(cmd_local, name))
{
- Con_Printf("Cvar_RegisterVirtual: %s is a command\n", name);
+ Con_Printf(CON_WARN "Cvar_RegisterVirtual: %s is a command\n", name);
return;
}
if(Cvar_FindVar(&cvars_all, name, 0))
{
- Con_Printf("Cvar_RegisterVirtual: %s is a cvar\n", name);
+ Con_Printf(CON_WARN "Cvar_RegisterVirtual: %s is a cvar\n", name);
return;
}
switch (variable->flags & (CF_CLIENT | CF_SERVER))
{
- case CF_CLIENT:
+ case CF_CLIENT: // client-only cvar
+ if (cls.state == ca_dedicated)
+ return;
case CF_SERVER:
case CF_CLIENT | CF_SERVER:
cvars = &cvars_all;
// (because the engine directly accesses fixed variables)
// NOTE: this isn't actually used currently
// (all cvars are registered before config parsing)
- variable->flags |= (cvar->flags & ~CF_ALLOCATED);
+ variable->flags &= ~CF_ALLOCATED;
// cvar->string is now owned by variable instead
variable->string = cvar->string;
variable->defstring = cvar->defstring;
for (i = 0;i < PRVM_PROG_MAX;i++)
variable->globaldefindex[i] = -1;
+ // Safe for Cvar_SetQuick()
+ variable->flags |= CF_REGISTERED;
+
Cvar_Link(variable, cvars);
}
// add back the selfpack as new first item
FS_AddSelfPack();
- // set the default screenshot name to either the mod name or the
- // gamemode screenshot name
- if (strcmp(com_modname, gamedirname1))
- Cvar_SetQuick (&scr_screenshot_name, com_modname);
- else
- Cvar_SetQuick (&scr_screenshot_name, gamescreenshotname);
-
+ if (cls.state != ca_dedicated)
+ {
+ // set the default screenshot name to either the mod name or the
+ // gamemode screenshot name
+ if (strcmp(com_modname, gamedirname1))
+ Cvar_SetQuick (&scr_screenshot_name, com_modname);
+ else
+ Cvar_SetQuick (&scr_screenshot_name, gamescreenshotname);
+ }
+
if((i = Sys_CheckParm("-modname")) && i < sys.argc - 1)
strlcpy(com_modname, sys.argv[i+1], sizeof(com_modname));
if (Sys_CheckParm("-nostdout"))
sys_nostdout = 1;
+ // -dedicated is checked in SV_ServerOptions() but that's too late for Cvar_RegisterVariable() to skip all the client-only cvars
+ if (Sys_CheckParm ("-dedicated") || !cl_available)
+ cls.state = ca_dedicated;
+
// initialize console command/cvar/alias/command execution systems
Cmd_Init();
i = Sys_CheckParm ("-dedicated");
if (i || !cl_available)
{
- cls.state = ca_dedicated;
// check for -dedicated specifying how many players
if (i && i + 1 < sys.argc && atoi (sys.argv[i+1]) >= 1)
svs.maxclients = atoi (sys.argv[i+1]);
{
advancetime = sys_ticrate.value;
// listen servers can run multiple server frames per client frame
- framelimit = cl_maxphysicsframesperserverframe.integer;
+ if (cl_maxphysicsframesperserverframe.integer > 0)
+ framelimit = cl_maxphysicsframesperserverframe.integer;
aborttime = Sys_DirtyTime() + 0.1;
}