void Host_Quit_f (void)
{
- Sys_Quit ();
+ Sys_Quit (0);
}
}
else
hours = 0;
- print ("#%-3u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, client->frags, hours, minutes, seconds);
+ print ("#%-3u %-16.16s^%i %3i %2i:%02i:%02i\n", j+1, client->name, STRING_COLOR_DEFAULT, client->frags, hours, minutes, seconds);
print (" %s\n", client->netconnection ? client->netconnection->address : "botclient");
}
}
SV_SpawnServer(level);
if (sv.active && cls.state == ca_disconnected)
CL_EstablishConnection("local:1");
-
-#ifdef AUTODEMO_BROKEN
-// if cl_autodemo is set, automatically start recording a demo if one isn't being recorded already
- if (cl_autodemo.integer && !cls.demorecording)
- {
- char demofile[MAX_OSPATH];
-
- dpsnprintf (demofile, sizeof(demofile), "%s_%s.dem", Sys_TimeString (cl_autodemo_nameformat.string), level);
-
- Con_Printf ("Recording to %s.\n", demofile);
-
- cls.demofile = FS_Open (demofile, "wb", false, false);
- if (cls.demofile)
- {
- cls.forcetrack = -1;
- FS_Printf (cls.demofile, "%i\n", cls.forcetrack);
- }
- else
- Con_Print ("ERROR: couldn't open.\n");
-
- cls.demorecording = true;
- }
-#endif
}
/*
void Host_Name_f (void)
{
int i, j;
+ qboolean valid_colors;
char newName[sizeof(host_client->name)];
if (Cmd_Argc () == 1)
if (cmd_source == src_command)
{
Cvar_Set ("_cl_name", newName);
- CL_SetInfo("name", newName, true, false, false, false);
return;
}
- if (sv.time < host_client->nametime)
+ if (realtime < host_client->nametime)
{
SV_ClientPrintf("You can't change name more than once every 5 seconds!\n");
return;
}
- host_client->nametime = sv.time + 5;
+ host_client->nametime = realtime + 5;
// point the string back at updateclient->name to keep it safe
strlcpy (host_client->name, newName, sizeof (host_client->name));
+
+ COM_StringLengthNoColors(host_client->name, 0, &valid_colors);
+ if(!valid_colors) // NOTE: this also proves the string is not empty, as "" is a valid colored string
+ {
+ size_t l;
+ l = strlen(host_client->name);
+ if(l < sizeof(host_client->name) - 1)
+ {
+ // duplicate the color tag to escape it
+ host_client->name[i] = STRING_COLOR_TAG;
+ host_client->name[i+1] = 0;
+ //Con_DPrintf("abuse detected, adding another trailing color tag\n");
+ }
+ else
+ {
+ // remove the last character to fix the color code
+ host_client->name[l-1] = 0;
+ //Con_DPrintf("abuse detected, removing a trailing color tag\n");
+ }
+ }
+
host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name);
if (strcmp(host_client->old_name, host_client->name))
{
if (host_client->spawned)
- SV_BroadcastPrintf("%s changed name to %s\n", host_client->old_name, host_client->name);
+ SV_BroadcastPrintf("%s^%i changed name to %s\n", host_client->old_name, STRING_COLOR_DEFAULT, host_client->name);
strlcpy(host_client->old_name, host_client->name, sizeof(host_client->old_name));
// send notification to all clients
MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
if (cmd_source == src_command)
{
Cvar_Set ("_cl_playermodel", newPath);
- CL_SetInfo("playermodel", newPath, true, false, false, false);
return;
}
/*
- if (sv.time < host_client->nametime)
+ if (realtime < host_client->nametime)
{
SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
return;
}
- host_client->nametime = sv.time + 5;
+ host_client->nametime = realtime + 5;
*/
// point the string back at updateclient->name to keep it safe
if (cmd_source == src_command)
{
Cvar_Set ("_cl_playerskin", newPath);
- CL_SetInfo("playerskin", newPath, true, false, false, false);
return;
}
/*
- if (sv.time < host_client->nametime)
+ if (realtime < host_client->nametime)
{
SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
return;
}
- host_client->nametime = sv.time + 5;
+ host_client->nametime = realtime + 5;
*/
// point the string back at updateclient->name to keep it safe
p1++;
}
// note this uses the chat prefix \001
- if (!fromServer)
+ if (!fromServer && !teamonly)
dpsnprintf (text, sizeof(text), "\001%s" STRING_COLOR_DEFAULT_STR ": %s", host_client->name, p1);
+ else if (!fromServer && teamonly)
+ dpsnprintf (text, sizeof(text), "\001(%s" STRING_COLOR_DEFAULT_STR "): %s", host_client->name, p1);
else if(*(sv_adminnick.string))
dpsnprintf (text, sizeof(text), "\001<%s" STRING_COLOR_DEFAULT_STR "> %s", sv_adminnick.string, p1);
else
if (cmd_source == src_command)
{
Cvar_SetValueQuick(&cl_color, playercolor);
- if (changetop >= 0)
- CL_SetInfo("topcolor", va("%i", top), true, false, false, false);
- if (changebottom >= 0)
- CL_SetInfo("bottomcolor", va("%i", bottom), true, false, false, false);
- if (cls.protocol != PROTOCOL_QUAKEWORLD && cls.netcon)
- {
- MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
- MSG_WriteString(&cls.netcon->message, va("color %i %i", top, bottom));
- }
return;
}
if (cmd_source == src_command)
{
Cvar_SetValue ("_cl_rate", max(NET_MINRATE, rate));
- CL_SetInfo("rate", va("%i", rate), true, false, false, false);
return;
}
prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
PRVM_ExecuteProgram (prog->globals.server->ClientConnect, "QC function ClientConnect is missing");
- if ((Sys_DoubleTime() - host_client->connecttime) <= sv.time)
- Con_Printf("%s entered the game\n", host_client->name);
+ if (svs.maxclients > 1 || cls.state == ca_dedicated)
+ Con_Printf("%s^%i entered the game\n", host_client->name, STRING_COLOR_DEFAULT);
PRVM_ExecuteProgram (prog->globals.server->PutClientInServer, "QC function PutClientInServer is missing");
}
{
int i, c;
- if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-demolooponly"))
+ if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo"))
return;
c = Cmd_Argc() - 1;
{
int i;
cvar_t *c;
+ const char *cvarname;
client_t *old;
if(Cmd_Argc() != 2)
return;
- if(!(c = Cvar_FindVar(Cmd_Argv(1))) || (c->flags & CVAR_PRIVATE))
+ cvarname = Cmd_Argv(1);
+ if (cls.state == ca_connected)
+ {
+ c = Cvar_FindVar(cvarname);
+ // LordHavoc: if there is no such cvar or if it is private, send a
+ // reply indicating that it has no value
+ if(!c || (c->flags & CVAR_PRIVATE))
+ Cmd_ForwardStringToServer(va("sentcvar %s\n", cvarname));
+ else
+ Cmd_ForwardStringToServer(va("sentcvar %s \"%s\"\n", c->name, c->string));
return;
- if (cls.state != ca_dedicated)
- Cmd_ForwardStringToServer(va("sentcvar %s \"%s\"\n", c->name, c->string));
+ }
if(!sv.active)// || !prog->funcoffsets.SV_ParseClientCommand)
return;
if(svs.clients[i].active && svs.clients[i].netconnection)
{
host_client = &svs.clients[i];
- Host_ClientCommands(va("sendcvar %s\n", c->name));
+ Host_ClientCommands(va("sendcvar %s\n", cvarname));
}
host_client = old;
}
{
packetloss = 0;
if (svs.clients[i].netconnection)
- for (j = 0;j < 100;j++)
- packetloss += svs.clients[i].netconnection->packetlost[j];
+ for (j = 0;j < NETGRAPH_PACKETS;j++)
+ if (svs.clients[i].netconnection->incoming_unreliablesize[j] == NETGRAPH_LOSTPACKET)
+ packetloss++;
+ packetloss = packetloss * 100 / NETGRAPH_PACKETS;
ping = (int)floor(svs.clients[i].ping*1000+0.5);
ping = bound(0, ping, 9999);
if (sv.protocol == PROTOCOL_QUAKEWORLD)
*/
void Host_InitCommands (void)
{
- dpsnprintf(cls.userinfo, sizeof(cls.userinfo), "\\name\\player\\team\\none\\topcolor\\0\\bottomcolor\\0\\rate\\10000\\msg\\1\\noaim\\1\\*ver\\%s", engineversion);
+ dpsnprintf(cls.userinfo, sizeof(cls.userinfo), "\\name\\player\\team\\none\\topcolor\\0\\bottomcolor\\0\\rate\\10000\\msg\\1\\noaim\\1\\*ver\\dp");
Cmd_AddCommand_WithClientCommand ("status", Host_Status_f, Host_Status_f, "print server status information");
Cmd_AddCommand ("quit", Host_Quit_f, "quit the game");
Cmd_AddCommand_WithClientCommand ("begin", NULL, Host_Begin_f, "signon 3 (client asks server to start sending entities, and will go to signon 4 (playing) when the first entity update is received)");
Cmd_AddCommand ("maxplayers", MaxPlayers_f, "sets limit on how many players (or bots) may be connected to the server at once");
- Cmd_AddCommand ("sendcvar", Host_SendCvar_f, "sends the value of a cvar to the server as a sentcvar command, for use by QuakeC"); // By [515]
+ Cmd_AddCommand ("sendcvar", Host_SendCvar_f, "sends the value of a cvar to the server as a sentcvar command, for use by QuakeC");
Cvar_RegisterVariable (&rcon_password);
Cvar_RegisterVariable (&rcon_address);