Ejemplo n.º 1
0
void SV_Serverinfo_f (void)
{
	cvar_t	*var;

	if (Cmd_Argc() == 1)
	{
		Con_Printf ("Server info settings:\n");
		Info_Print (svs.info);
		return;
	}

	if (Cmd_Argc() != 3)
	{
		Con_Printf ("usage: serverinfo [ <key> <value> ]\n");
		return;
	}

	if (Cmd_Argv(1)[0] == '*')
	{
		Con_Printf ("Star variables cannot be changed.\n");
		return;
	}
	Info_SetValueForKey (svs.info, Cmd_Argv(1), Cmd_Argv(2), MAX_SERVERINFO_STRING);

	// if this is a cvar, change it too	
	var = Cvar_FindVar (Cmd_Argv(1));
	if (var)
	{
		Z_Free (var->string);	// free the old value string	
		var->string = CopyString (Cmd_Argv(2));
		var->value = Q_atof (var->string);
	}

	SV_SendServerInfoChange(Cmd_Argv(1), Cmd_Argv(2));
}
Ejemplo n.º 2
0
void
Cvar_Info (cvar_t *var)
{
	if (var->flags & CVAR_SERVERINFO) {
		Info_SetValueForKey (svs.info, var->name, var->string,
							 (!sv_highchars || !sv_highchars->int_val));

		SV_SendServerInfoChange (var->name, var->string);
	}
}
Ejemplo n.º 3
0
/*
===========
SV_Serverinfo_f

Examine or change the serverinfo string
===========
*/
void SV_Serverinfo_f (void)
{
	cvar_t	*var;
	char	*key, *value;

	if (Cmd_Argc() == 1)
	{
		Com_Printf ("Server info settings:\n");
		Info_Print (svs.info);
		return;
	}

	if (Cmd_Argc() != 3)
	{
		Com_Printf ("usage: serverinfo [ <key> <value> ]\n");
		return;
	}

	key = Cmd_Argv(1);
	value = Cmd_Argv(2);

	if (key[0] == '*')
	{
		Com_Printf ("Star variables cannot be changed.\n");
		return;
	}

	if (!strcmp(key, "maxpitch") || !strcmp(Cmd_Argv(1), "minpitch")) {
		Cvar_Set (Cvar_FindVar(va("sv_%s", key)), value);
		return;		// cvar callbacks will take care of updating serverinfo
	}

#ifdef VWEP_TEST
	if (!strcmp(key, "#vw"))
		return;		// reserved for VWep precaches
#endif

	Info_SetValueForKey (svs.info, key, value, MAX_SERVERINFO_STRING);

	// if the key is also a serverinfo cvar, change it too
	var = Cvar_FindVar (key);
	if (var && (var->flags & CVAR_SERVERINFO))
	{
		// a hack - strip the serverinfo flag so that the Cvar_Set
		// doesn't trigger SV_ServerinfoChanged
		var->flags &= ~CVAR_SERVERINFO;
		Cvar_Set (var, Cmd_Argv(2));
		var->flags |= CVAR_SERVERINFO;		// put it back
	}

	// FIXME, don't send if the key hasn't changed
	SV_SendServerInfoChange (key, value);
}
Ejemplo n.º 4
0
//Cvar system calls this when a CVAR_SERVERINFO cvar changes
void SV_ServerinfoChanged (char *key, char *string) {
	if ( (!strcmp(key, "pm_bunnyspeedcap") || !strcmp(key, "pm_slidefix")
		|| !strcmp(key, "pm_airstep") || !strcmp(key, "pm_pground")
		|| !strcmp(key, "samelevel") || !strcmp(key, "watervis") || !strcmp(key, "coop") )
		&& !strcmp(string, "0") ) {
		// don't add default values to serverinfo to keep it cleaner
		string = "";
	}

	if (strcmp(string, Info_ValueForKey (svs.info, key))) {
		Info_SetValueForKey (svs.info, key, string, MAX_SERVERINFO_STRING);
		SV_SendServerInfoChange (key, string);
	}
}
Ejemplo n.º 5
0
/*
	SV_Serverinfo_f

	Examine or change the serverinfo string
*/
static void
SV_Serverinfo_f (void)
{
	cvar_t     *var;
	const char *key;
	const char *value;

	switch (Cmd_Argc ()) {
		case 1:
			SV_Printf ("Server info settings:\n");
			Info_Print (svs.info);
			return;
		case 2:
			key = Cmd_Argv (1);
			value = Info_ValueForKey (svs.info, key);
			if (Info_Key (svs.info, key))
				SV_Printf ("Server info %s: \"%s\"\n", key, value);
			else
				SV_Printf ("No such key %s\n", Cmd_Argv(1));
			return;
		case 3:
			key = Cmd_Argv (1);
			value = Cmd_Argv (2);
			break;
		default:
			SV_Printf ("usage: serverinfo [ <key> <value> ]\n");
			return;
	}

	if (Cmd_Argv (1)[0] == '*') {
		SV_Printf ("Star variables cannot be changed.\n");
		return;
	}

	// if this is a cvar, change it too
	var = Cvar_FindVar (key);
	if (var && (var->flags & CVAR_SERVERINFO)) {
		Cvar_Set (var, value);
	} else {
		Info_SetValueForKey (svs.info, key, value, !sv_highchars->int_val);
		SV_SendServerInfoChange (key, value);
	}
}
Ejemplo n.º 6
0
void Cvar_Set (char *var_name, char *value)
{
	cvar_t	*var;
	
	var = Cvar_FindVar (var_name);
	if (!var)
	{	// there is an error in C code if this happens
		Con_Printf ("Cvar_Set: variable %s not found\n", var_name);
		return;
	}

#ifdef SERVERONLY
	if (var->info)
	{
		Info_SetValueForKey (svs.info, var_name, value, MAX_SERVERINFO_STRING);
		SV_SendServerInfoChange(var_name, value);
//		SV_BroadcastCommand ("fullserverinfo \"%s\"\n", svs.info);
	}
#else
	if (var->info)
	{
		Info_SetValueForKey (cls.userinfo, var_name, value, MAX_INFO_STRING);
		if (cls.state >= ca_connected)
		{
			MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
			SZ_Print (&cls.netchan.message, va("setinfo \"%s\" \"%s\"\n", var_name, value));
		}
	}
#endif
	
	Z_Free (var->string);	// free the old value string
	
	var->string = Z_Malloc (Q_strlen(value)+1);
	Q_strcpy (var->string, value);
	var->value = Q_atof (var->string);
}