2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 cvar_t sv_cheats = {0, "sv_cheats", "0", "enables cheat commands in any game, and cheat impulses in dpmod"};
25 cvar_t rcon_password = {CVAR_PRIVATE, "rcon_password", "", "password to authenticate rcon commands"};
26 cvar_t rcon_address = {0, "rcon_address", "", "server address to send rcon commands to (when not connected to a server)"};
27 cvar_t team = {CVAR_USERINFO | CVAR_SAVE, "team", "none", "QW team (4 character limit, example: blue)"};
28 cvar_t skin = {CVAR_USERINFO | CVAR_SAVE, "skin", "", "QW player skin name (example: base)"};
29 cvar_t noaim = {CVAR_USERINFO | CVAR_SAVE, "noaim", "1", "QW option to disable vertical autoaim"};
30 qboolean allowcheats = false;
38 void Host_Quit_f (void)
49 void Host_Status_f (void)
52 int seconds, minutes, hours = 0, j, players;
53 void (*print) (const char *fmt, ...);
55 if (cmd_source == src_command)
57 // if running a client, try to send over network so the client's status report parser will see the report
58 if (cls.state == ca_connected)
60 Cmd_ForwardToServer ();
66 print = SV_ClientPrintf;
71 for (players = 0, j = 0;j < svs.maxclients;j++)
72 if (svs.clients[j].active)
74 print ("host: %s\n", Cvar_VariableString ("hostname"));
75 print ("version: %s build %s\n", gamename, buildstring);
76 print ("protocol: %i (%s)\n", Protocol_NumberForEnum(sv.protocol), Protocol_NameForEnum(sv.protocol));
77 print ("map: %s\n", sv.name);
78 print ("players: %i active (%i max)\n\n", players, svs.maxclients);
79 for (j = 0, client = svs.clients;j < svs.maxclients;j++, client++)
83 seconds = (int)(realtime - client->connecttime);
84 minutes = seconds / 60;
87 seconds -= (minutes * 60);
90 minutes -= (hours * 60);
94 print ("#%-3u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->fields.server->frags, hours, minutes, seconds);
95 print (" %s\n", client->netconnection ? client->netconnection->address : "botclient");
104 Sets client to godmode
107 void Host_God_f (void)
111 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
115 host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags ^ FL_GODMODE;
116 if (!((int)host_client->edict->fields.server->flags & FL_GODMODE) )
117 SV_ClientPrint("godmode OFF\n");
119 SV_ClientPrint("godmode ON\n");
122 void Host_Notarget_f (void)
126 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
130 host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags ^ FL_NOTARGET;
131 if (!((int)host_client->edict->fields.server->flags & FL_NOTARGET) )
132 SV_ClientPrint("notarget OFF\n");
134 SV_ClientPrint("notarget ON\n");
137 qboolean noclip_anglehack;
139 void Host_Noclip_f (void)
143 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
147 if (host_client->edict->fields.server->movetype != MOVETYPE_NOCLIP)
149 noclip_anglehack = true;
150 host_client->edict->fields.server->movetype = MOVETYPE_NOCLIP;
151 SV_ClientPrint("noclip ON\n");
155 noclip_anglehack = false;
156 host_client->edict->fields.server->movetype = MOVETYPE_WALK;
157 SV_ClientPrint("noclip OFF\n");
165 Sets client to flymode
168 void Host_Fly_f (void)
172 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
176 if (host_client->edict->fields.server->movetype != MOVETYPE_FLY)
178 host_client->edict->fields.server->movetype = MOVETYPE_FLY;
179 SV_ClientPrint("flymode ON\n");
183 host_client->edict->fields.server->movetype = MOVETYPE_WALK;
184 SV_ClientPrint("flymode OFF\n");
195 void Host_Pings_f (void); // called by Host_Ping_f
196 void Host_Ping_f (void)
200 void (*print) (const char *fmt, ...);
202 if (cmd_source == src_command)
204 // if running a client, try to send over network so the client's ping report parser will see the report
205 if (cls.state == ca_connected)
207 Cmd_ForwardToServer ();
213 print = SV_ClientPrintf;
218 print("Client ping times:\n");
219 for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
223 print("%4i %s\n", bound(0, (int)floor(client->ping*1000+0.5), 9999), client->name);
226 // now call the Pings command also, which will send a report that contains packet loss for the scoreboard (as well as a simpler ping report)
231 ===============================================================================
235 ===============================================================================
239 ======================
244 command from the console. Active clients are kicked off.
245 ======================
247 void Host_Map_f (void)
249 char level[MAX_QPATH];
253 Con_Print("map <levelname> : start a new game (kicks off all players)\n");
257 cls.demonum = -1; // stop demo loop in case this fails
260 Host_ShutdownServer();
265 svs.serverflags = 0; // haven't completed an episode yet
266 allowcheats = sv_cheats.integer != 0;
267 strlcpy(level, Cmd_Argv(1), sizeof(level));
268 SV_SpawnServer(level);
269 if (sv.active && cls.state == ca_disconnected)
270 CL_EstablishConnection("local:1");
272 #ifdef AUTODEMO_BROKEN
273 // if cl_autodemo is set, automatically start recording a demo if one isn't being recorded already
274 if (cl_autodemo.integer && !cls.demorecording)
276 char demofile[MAX_OSPATH];
278 dpsnprintf (demofile, sizeof(demofile), "%s_%s.dem", Sys_TimeString (cl_autodemo_nameformat.string), level);
280 Con_Printf ("Recording to %s.\n", demofile);
282 cls.demofile = FS_Open (demofile, "wb", false, false);
286 FS_Printf (cls.demofile, "%i\n", cls.forcetrack);
289 Con_Print ("ERROR: couldn't open.\n");
291 cls.demorecording = true;
300 Goes to a new map, taking all clients along
303 void Host_Changelevel_f (void)
305 char level[MAX_QPATH];
309 Con_Print("changelevel <levelname> : continue game on a new level\n");
322 SV_SaveSpawnparms ();
324 allowcheats = sv_cheats.integer != 0;
325 strlcpy(level, Cmd_Argv(1), sizeof(level));
326 SV_SpawnServer(level);
327 if (sv.active && cls.state == ca_disconnected)
328 CL_EstablishConnection("local:1");
335 Restarts the current server for a dead player
338 void Host_Restart_f (void)
340 char mapname[MAX_QPATH];
344 Con_Print("restart : restart current level\n");
349 Con_Print("Only the server may restart\n");
356 allowcheats = sv_cheats.integer != 0;
357 strlcpy(mapname, sv.name, sizeof(mapname));
358 SV_SpawnServer(mapname);
359 if (sv.active && cls.state == ca_disconnected)
360 CL_EstablishConnection("local:1");
367 This command causes the client to wait for the signon messages again.
368 This is sent just before a server changes levels
371 void Host_Reconnect_f (void)
373 if (cls.protocol == PROTOCOL_QUAKEWORLD)
375 if (cls.qw_downloadmemory) // don't change when downloading
382 if (cls.state == ca_connected && cls.signon < SIGNONS)
384 Con_Printf("reconnecting...\n");
385 MSG_WriteChar(&cls.netcon->message, qw_clc_stringcmd);
386 MSG_WriteString(&cls.netcon->message, "new");
391 // if we have connected to a server recently, the userinfo
392 // will still contain its IP address, so get the address...
393 InfoString_GetValue(cls.userinfo, "*ip", temp, sizeof(temp));
395 CL_EstablishConnection(temp);
397 Con_Printf("Reconnect to what server? (you have not connected to a server yet)\n");
405 Con_Print("reconnect : wait for signon messages again\n");
410 Con_Print("reconnect: no signon, ignoring reconnect\n");
413 cls.signon = 0; // need new connection messages
418 =====================
421 User command to connect to server
422 =====================
424 void Host_Connect_f (void)
428 Con_Print("connect <serveraddress> : connect to a multiplayer game\n");
431 CL_EstablishConnection(Cmd_Argv(1));
436 ===============================================================================
440 ===============================================================================
443 #define SAVEGAME_VERSION 5
449 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
452 void Host_SavegameComment (char *text)
457 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
459 // LordHavoc: added min() to prevent overflow
460 memcpy (text, cl.levelname, min(strlen(cl.levelname), SAVEGAME_COMMENT_LENGTH));
461 sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
462 memcpy (text+22, kills, strlen(kills));
463 // convert space to _ to make stdio happy
464 // LordHavoc: convert control characters to _ as well
465 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
468 text[SAVEGAME_COMMENT_LENGTH] = '\0';
477 void Host_Savegame_f (void)
479 char name[MAX_QPATH];
482 char comment[SAVEGAME_COMMENT_LENGTH+1];
484 if (cls.state != ca_connected || !sv.active)
486 Con_Print("Not playing a local game.\n");
492 Con_Print("Can't save in intermission.\n");
496 for (i = 0;i < svs.maxclients;i++)
498 if (svs.clients[i].active)
502 Con_Print("Can't save multiplayer games.\n");
505 if (svs.clients[i].edict->fields.server->deadflag)
507 Con_Print("Can't savegame with a dead player\n");
515 Con_Print("save <savename> : save a game\n");
519 if (strstr(Cmd_Argv(1), ".."))
521 Con_Print("Relative pathnames are not allowed.\n");
525 strlcpy (name, Cmd_Argv(1), sizeof (name));
526 FS_DefaultExtension (name, ".sav", sizeof (name));
528 Con_Printf("Saving game to %s...\n", name);
529 f = FS_Open (name, "wb", false, false);
532 Con_Print("ERROR: couldn't open.\n");
536 FS_Printf(f, "%i\n", SAVEGAME_VERSION);
537 Host_SavegameComment (comment);
538 FS_Printf(f, "%s\n", comment);
539 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
540 FS_Printf(f, "%f\n", svs.clients[0].spawn_parms[i]);
541 FS_Printf(f, "%d\n", current_skill);
542 FS_Printf(f, "%s\n", sv.name);
543 FS_Printf(f, "%f\n",sv.time);
545 // write the light styles
546 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
548 if (sv.lightstyles[i][0])
549 FS_Printf(f, "%s\n", sv.lightstyles[i]);
556 PRVM_ED_WriteGlobals (f);
557 for (i=0 ; i<prog->num_edicts ; i++)
558 PRVM_ED_Write (f, PRVM_EDICT_NUM(i));
563 Con_Print("done.\n");
572 void Host_Loadgame_f (void)
574 char filename[MAX_QPATH];
575 char mapname[MAX_QPATH];
585 float spawn_parms[NUM_SPAWN_PARMS];
589 Con_Print("load <savename> : load a game\n");
593 strlcpy (filename, Cmd_Argv(1), sizeof(filename));
594 FS_DefaultExtension (filename, ".sav", sizeof (filename));
596 Con_Printf("Loading game from %s...\n", filename);
598 cls.demonum = -1; // stop demo loop in case this fails
600 t = text = (char *)FS_LoadFile (filename, tempmempool, false, NULL);
603 Con_Print("ERROR: couldn't open.\n");
608 COM_ParseTokenConsole(&t);
609 version = atoi(com_token);
610 if (version != SAVEGAME_VERSION)
613 Con_Printf("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
618 // this is a little hard to parse, as : is a separator in COM_ParseToken,
619 // so use the console parser instead
620 COM_ParseTokenConsole(&t);
622 for (i = 0;i < NUM_SPAWN_PARMS;i++)
624 COM_ParseTokenConsole(&t);
625 spawn_parms[i] = atof(com_token);
628 COM_ParseTokenConsole(&t);
629 // this silliness is so we can load 1.06 save files, which have float skill values
630 current_skill = (int)(atof(com_token) + 0.5);
631 Cvar_SetValue ("skill", (float)current_skill);
634 COM_ParseTokenConsole(&t);
635 strlcpy (mapname, com_token, sizeof(mapname));
638 COM_ParseTokenConsole(&t);
639 time = atof(com_token);
641 allowcheats = sv_cheats.integer != 0;
643 SV_SpawnServer (mapname);
647 Con_Print("Couldn't load map\n");
650 sv.paused = true; // pause until all clients connect
653 // load the light styles
655 for (i = 0;i < MAX_LIGHTSTYLES;i++)
659 COM_ParseTokenConsole(&t);
660 // if this is a 64 lightstyle savegame produced by Quake, stop now
661 // we have to check this because darkplaces saves 256 lightstyle savegames
662 if (com_token[0] == '{')
667 strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i]));
670 // now skip everything before the first opening brace
671 // (this is for forward compatibility, so that older versions (at
672 // least ones with this fix) can load savegames with extra data before the
673 // first brace, as might be produced by a later engine version)
677 COM_ParseTokenConsole(&t);
678 if (com_token[0] == '{')
685 // load the edicts out of the savegame file
692 while (COM_ParseTokenConsole(&t))
693 if (!strcmp(com_token, "}"))
695 if (!COM_ParseTokenConsole(&start))
700 if (strcmp(com_token,"{"))
703 Host_Error ("First token isn't a brace");
708 // parse the global vars
709 PRVM_ED_ParseGlobals (start);
714 if (entnum >= MAX_EDICTS)
717 Host_Error("Host_PerformLoadGame: too many edicts in save file (reached MAX_EDICTS %i)", MAX_EDICTS);
719 while (entnum >= prog->max_edicts)
720 //SV_IncreaseEdicts();
721 PRVM_MEM_IncreaseEdicts();
722 ent = PRVM_EDICT_NUM(entnum);
723 memset (ent->fields.server, 0, prog->progs->entityfields * 4);
724 ent->priv.server->free = false;
725 PRVM_ED_ParseEdict (start, ent);
727 // link it into the bsp tree
728 if (!ent->priv.server->free)
729 SV_LinkEdict (ent, false);
736 prog->num_edicts = entnum;
739 for (i = 0;i < NUM_SPAWN_PARMS;i++)
740 svs.clients[0].spawn_parms[i] = spawn_parms[i];
744 // make sure we're connected to loopback
745 if (cls.state == ca_disconnected || !(cls.state == ca_connected && cls.netcon != NULL && LHNETADDRESS_GetAddressType(&cls.netcon->peeraddress) == LHNETADDRESSTYPE_LOOP))
746 CL_EstablishConnection("local:1");
749 //============================================================================
752 ======================
754 ======================
756 cvar_t cl_name = {CVAR_SAVE, "_cl_name", "player", "internal storage cvar for current player name (changed by name command)"};
757 void Host_Name_f (void)
760 char newName[sizeof(host_client->name)];
762 if (Cmd_Argc () == 1)
764 Con_Printf("\"name\" is \"%s\"\n", cl_name.string);
768 if (Cmd_Argc () == 2)
769 strlcpy (newName, Cmd_Argv(1), sizeof (newName));
771 strlcpy (newName, Cmd_Args(), sizeof (newName));
773 for (i = 0, j = 0;newName[i];i++)
774 if (newName[i] != '\r' && newName[i] != '\n')
775 newName[j++] = newName[i];
778 if (cmd_source == src_command)
780 Cvar_Set ("_cl_name", newName);
781 CL_SetInfo("name", newName, true, false, false, false);
785 if (sv.time < host_client->nametime)
787 SV_ClientPrintf("You can't change name more than once every 5 seconds!\n");
791 host_client->nametime = sv.time + 5;
793 // point the string back at updateclient->name to keep it safe
794 strlcpy (host_client->name, newName, sizeof (host_client->name));
795 host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name);
796 if (strcmp(host_client->old_name, host_client->name))
798 if (host_client->spawned)
799 SV_BroadcastPrintf("%s changed name to %s\n", host_client->old_name, host_client->name);
800 strlcpy(host_client->old_name, host_client->name, sizeof(host_client->old_name));
801 // send notification to all clients
802 MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
803 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
804 MSG_WriteString (&sv.reliable_datagram, host_client->name);
809 ======================
811 ======================
813 cvar_t cl_playermodel = {CVAR_SAVE, "_cl_playermodel", "", "internal storage cvar for current player model in Nexuiz (changed by playermodel command)"};
814 // the old cl_playermodel in cl_main has been renamed to __cl_playermodel
815 void Host_Playermodel_f (void)
818 char newPath[sizeof(host_client->playermodel)];
820 if (Cmd_Argc () == 1)
822 Con_Printf("\"playermodel\" is \"%s\"\n", cl_playermodel.string);
826 if (Cmd_Argc () == 2)
827 strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
829 strlcpy (newPath, Cmd_Args(), sizeof (newPath));
831 for (i = 0, j = 0;newPath[i];i++)
832 if (newPath[i] != '\r' && newPath[i] != '\n')
833 newPath[j++] = newPath[i];
836 if (cmd_source == src_command)
838 Cvar_Set ("_cl_playermodel", newPath);
839 CL_SetInfo("playermodel", newPath, true, false, false, false);
844 if (sv.time < host_client->nametime)
846 SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
850 host_client->nametime = sv.time + 5;
853 // point the string back at updateclient->name to keep it safe
854 strlcpy (host_client->playermodel, newPath, sizeof (host_client->playermodel));
855 if( eval_playermodel )
856 PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PRVM_SetEngineString(host_client->playermodel);
857 if (strcmp(host_client->old_model, host_client->playermodel))
859 strlcpy(host_client->old_model, host_client->playermodel, sizeof(host_client->old_model));
860 /*// send notification to all clients
861 MSG_WriteByte (&sv.reliable_datagram, svc_updatepmodel);
862 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
863 MSG_WriteString (&sv.reliable_datagram, host_client->playermodel);*/
868 ======================
870 ======================
872 cvar_t cl_playerskin = {CVAR_SAVE, "_cl_playerskin", "", "internal storage cvar for current player skin in Nexuiz (changed by playerskin command)"};
873 void Host_Playerskin_f (void)
876 char newPath[sizeof(host_client->playerskin)];
878 if (Cmd_Argc () == 1)
880 Con_Printf("\"playerskin\" is \"%s\"\n", cl_playerskin.string);
884 if (Cmd_Argc () == 2)
885 strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
887 strlcpy (newPath, Cmd_Args(), sizeof (newPath));
889 for (i = 0, j = 0;newPath[i];i++)
890 if (newPath[i] != '\r' && newPath[i] != '\n')
891 newPath[j++] = newPath[i];
894 if (cmd_source == src_command)
896 Cvar_Set ("_cl_playerskin", newPath);
897 CL_SetInfo("playerskin", newPath, true, false, false, false);
902 if (sv.time < host_client->nametime)
904 SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
908 host_client->nametime = sv.time + 5;
911 // point the string back at updateclient->name to keep it safe
912 strlcpy (host_client->playerskin, newPath, sizeof (host_client->playerskin));
913 if( eval_playerskin )
914 PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string = PRVM_SetEngineString(host_client->playerskin);
915 if (strcmp(host_client->old_skin, host_client->playerskin))
917 //if (host_client->spawned)
918 // SV_BroadcastPrintf("%s changed skin to %s\n", host_client->name, host_client->playerskin);
919 strlcpy(host_client->old_skin, host_client->playerskin, sizeof(host_client->old_skin));
920 /*// send notification to all clients
921 MSG_WriteByte (&sv.reliable_datagram, svc_updatepskin);
922 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
923 MSG_WriteString (&sv.reliable_datagram, host_client->playerskin);*/
927 void Host_Version_f (void)
929 Con_Printf("Version: %s build %s\n", gamename, buildstring);
932 void Host_Say(qboolean teamonly)
938 // LordHavoc: long say messages
940 qboolean fromServer = false;
942 if (cmd_source == src_command)
944 if (cls.state == ca_dedicated)
951 Cmd_ForwardToServer ();
959 if (!teamplay.integer)
969 // note this uses the chat prefix \001
971 dpsnprintf (text, sizeof(text), "\001%s" STRING_COLOR_DEFAULT_STR ": %s", host_client->name, p1);
973 dpsnprintf (text, sizeof(text), "\001<%s" STRING_COLOR_DEFAULT_STR "> %s", hostname.string, p1);
974 p2 = text + strlen(text);
975 while ((const char *)p2 > (const char *)text && (p2[-1] == '\r' || p2[-1] == '\n' || (p2[-1] == '\"' && quoted)))
977 if (p2[-1] == '\"' && quoted)
982 strlcat(text, "\n", sizeof(text));
984 // note: save is not a valid edict if fromServer is true
986 for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
987 if (host_client->spawned && (!teamonly || host_client->edict->fields.server->team == save->edict->fields.server->team))
988 SV_ClientPrint(text);
991 if (cls.state == ca_dedicated)
996 void Host_Say_f(void)
1002 void Host_Say_Team_f(void)
1008 void Host_Tell_f(void)
1012 const char *p1, *p2;
1013 char text[MAX_INPUTLINE]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
1014 qboolean fromServer = false;
1016 if (cmd_source == src_command)
1018 if (cls.state == ca_dedicated)
1022 Cmd_ForwardToServer ();
1027 if (Cmd_Argc () < 3)
1030 // note this uses the chat prefix \001
1032 sprintf (text, "\001%s tells you: ", host_client->name);
1034 sprintf (text, "\001<%s tells you> ", hostname.string);
1037 p2 = p1 + strlen(p1);
1038 // remove the target name
1039 while (p1 < p2 && *p1 != ' ')
1041 while (p1 < p2 && *p1 == ' ')
1043 // remove trailing newlines
1044 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
1046 // remove quotes if present
1052 else if (fromServer)
1053 Con_Print("Host_Tell: missing end quote\n");
1055 SV_ClientPrint("Host_Tell: missing end quote\n");
1057 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
1059 for (j = (int)strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;)
1065 for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
1066 if (host_client->spawned && !strcasecmp(host_client->name, Cmd_Argv(1)))
1067 SV_ClientPrint(text);
1077 cvar_t cl_color = {CVAR_SAVE, "_cl_color", "0", "internal storage cvar for current player colors (changed by color command)"};
1078 void Host_Color(int changetop, int changebottom)
1080 int top, bottom, playercolor;
1082 func_t SV_ChangeTeam;
1084 // get top and bottom either from the provided values or the current values
1085 // (allows changing only top or bottom, or both at once)
1086 top = changetop >= 0 ? changetop : (cl_color.integer >> 4);
1087 bottom = changebottom >= 0 ? changebottom : cl_color.integer;
1091 // LordHavoc: allowing skin colormaps 14 and 15 by commenting this out
1097 playercolor = top*16 + bottom;
1099 if (cmd_source == src_command)
1101 Cvar_SetValueQuick(&cl_color, playercolor);
1103 CL_SetInfo("topcolor", va("%i", top), true, false, false, false);
1104 if (changebottom >= 0)
1105 CL_SetInfo("bottomcolor", va("%i", bottom), true, false, false, false);
1106 if (cls.protocol != PROTOCOL_QUAKEWORLD && cls.netcon)
1108 MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
1109 MSG_WriteString(&cls.netcon->message, va("color %i %i", top, bottom));
1114 if (cls.protocol == PROTOCOL_QUAKEWORLD)
1117 if (host_client->edict && (f = PRVM_ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - prog->functions)))
1119 Con_DPrint("Calling SV_ChangeTeam\n");
1120 prog->globals.server->time = sv.time;
1121 prog->globals.generic[OFS_PARM0] = playercolor;
1122 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1123 PRVM_ExecuteProgram (SV_ChangeTeam, "QC function SV_ChangeTeam is missing");
1128 if (host_client->edict)
1130 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_clientcolors)))
1131 val->_float = playercolor;
1132 host_client->edict->fields.server->team = bottom + 1;
1134 host_client->colors = playercolor;
1135 if (host_client->old_colors != host_client->colors)
1137 host_client->old_colors = host_client->colors;
1138 // send notification to all clients
1139 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
1140 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
1141 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
1146 void Host_Color_f(void)
1150 if (Cmd_Argc() == 1)
1152 Con_Printf("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15);
1153 Con_Print("color <0-15> [0-15]\n");
1157 if (Cmd_Argc() == 2)
1158 top = bottom = atoi(Cmd_Argv(1));
1161 top = atoi(Cmd_Argv(1));
1162 bottom = atoi(Cmd_Argv(2));
1164 Host_Color(top, bottom);
1167 void Host_TopColor_f(void)
1169 if (Cmd_Argc() == 1)
1171 Con_Printf("\"topcolor\" is \"%i\"\n", (cl_color.integer >> 4) & 15);
1172 Con_Print("topcolor <0-15>\n");
1176 Host_Color(atoi(Cmd_Argv(1)), -1);
1179 void Host_BottomColor_f(void)
1181 if (Cmd_Argc() == 1)
1183 Con_Printf("\"bottomcolor\" is \"%i\"\n", cl_color.integer & 15);
1184 Con_Print("bottomcolor <0-15>\n");
1188 Host_Color(-1, atoi(Cmd_Argv(1)));
1191 cvar_t cl_rate = {CVAR_SAVE, "_cl_rate", "10000", "internal storage cvar for current rate (changed by rate command)"};
1192 void Host_Rate_f(void)
1196 if (Cmd_Argc() != 2)
1198 Con_Printf("\"rate\" is \"%i\"\n", cl_rate.integer);
1199 Con_Print("rate <bytespersecond>\n");
1203 rate = atoi(Cmd_Argv(1));
1205 if (cmd_source == src_command)
1207 Cvar_SetValue ("_cl_rate", max(NET_MINRATE, rate));
1208 CL_SetInfo("rate", va("%i", rate), true, false, false, false);
1212 host_client->rate = rate;
1220 void Host_Kill_f (void)
1222 if (host_client->edict->fields.server->health <= 0)
1224 SV_ClientPrint("Can't suicide -- already dead!\n");
1228 prog->globals.server->time = sv.time;
1229 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1230 PRVM_ExecuteProgram (prog->globals.server->ClientKill, "QC function ClientKill is missing");
1239 void Host_Pause_f (void)
1241 if (!pausable.integer)
1242 SV_ClientPrint("Pause not allowed.\n");
1246 SV_BroadcastPrintf("%s %spaused the game\n", host_client->name, sv.paused ? "" : "un");
1247 // send notification to all clients
1248 MSG_WriteByte(&sv.reliable_datagram, svc_setpause);
1249 MSG_WriteByte(&sv.reliable_datagram, sv.paused);
1254 ======================
1256 LordHavoc: only supported for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
1257 LordHavoc: correction, Mindcrime will be removing pmodel in the future, but it's still stuck here for compatibility.
1258 ======================
1260 cvar_t cl_pmodel = {CVAR_SAVE, "_cl_pmodel", "0", "internal storage cvar for current player model number in nehahra (changed by pmodel command)"};
1261 static void Host_PModel_f (void)
1266 if (Cmd_Argc () == 1)
1268 Con_Printf("\"pmodel\" is \"%s\"\n", cl_pmodel.string);
1271 i = atoi(Cmd_Argv(1));
1273 if (cmd_source == src_command)
1275 if (cl_pmodel.integer == i)
1277 Cvar_SetValue ("_cl_pmodel", i);
1278 if (cls.state == ca_connected)
1279 Cmd_ForwardToServer ();
1283 if (host_client->edict && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1287 //===========================================================================
1295 void Host_PreSpawn_f (void)
1297 if (host_client->spawned)
1299 Con_Print("prespawn not valid -- already spawned\n");
1303 if (host_client->netconnection)
1305 SZ_Write (&host_client->netconnection->message, sv.signon.data, sv.signon.cursize);
1306 MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
1307 MSG_WriteByte (&host_client->netconnection->message, 2);
1310 // reset the name change timer because the client will send name soon
1311 host_client->nametime = 0;
1319 void Host_Spawn_f (void)
1325 int stats[MAX_CL_STATS];
1327 if (host_client->spawned)
1329 Con_Print("Spawn not valid -- already spawned\n");
1333 // reset name change timer again because they might want to change name
1334 // again in the first 5 seconds after connecting
1335 host_client->nametime = 0;
1337 // LordHavoc: moved this above the QC calls at FrikaC's request
1338 // LordHavoc: commented this out
1339 //if (host_client->netconnection)
1340 // SZ_Clear (&host_client->netconnection->message);
1342 // run the entrance script
1345 // loaded games are fully initialized already
1346 // if this is the last client to be connected, unpause
1349 if ((f = PRVM_ED_FindFunction ("RestoreGame")))
1350 if ((RestoreGame = (func_t)(f - prog->functions)))
1352 Con_DPrint("Calling RestoreGame\n");
1353 prog->globals.server->time = sv.time;
1354 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1355 PRVM_ExecuteProgram (RestoreGame, "QC function RestoreGame is missing");
1360 //Con_Printf("Host_Spawn_f: host_client->edict->netname = %s, host_client->edict->netname = %s, host_client->name = %s\n", PRVM_GetString(host_client->edict->fields.server->netname), PRVM_GetString(host_client->edict->fields.server->netname), host_client->name);
1362 // copy spawn parms out of the client_t
1363 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1364 (&prog->globals.server->parm1)[i] = host_client->spawn_parms[i];
1366 // call the spawn function
1367 host_client->clientconnectcalled = true;
1368 prog->globals.server->time = sv.time;
1369 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1370 PRVM_ExecuteProgram (prog->globals.server->ClientConnect, "QC function ClientConnect is missing");
1372 if ((Sys_DoubleTime() - host_client->connecttime) <= sv.time)
1373 Con_Printf("%s entered the game\n", host_client->name);
1375 PRVM_ExecuteProgram (prog->globals.server->PutClientInServer, "QC function PutClientInServer is missing");
1378 if (!host_client->netconnection)
1381 // send time of update
1382 MSG_WriteByte (&host_client->netconnection->message, svc_time);
1383 MSG_WriteFloat (&host_client->netconnection->message, sv.time);
1385 // send all current names, colors, and frag counts
1386 for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
1388 if (!client->active)
1390 MSG_WriteByte (&host_client->netconnection->message, svc_updatename);
1391 MSG_WriteByte (&host_client->netconnection->message, i);
1392 MSG_WriteString (&host_client->netconnection->message, client->name);
1393 MSG_WriteByte (&host_client->netconnection->message, svc_updatefrags);
1394 MSG_WriteByte (&host_client->netconnection->message, i);
1395 MSG_WriteShort (&host_client->netconnection->message, client->frags);
1396 MSG_WriteByte (&host_client->netconnection->message, svc_updatecolors);
1397 MSG_WriteByte (&host_client->netconnection->message, i);
1398 MSG_WriteByte (&host_client->netconnection->message, client->colors);
1401 // send all current light styles
1402 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1404 if (sv.lightstyles[i][0])
1406 MSG_WriteByte (&host_client->netconnection->message, svc_lightstyle);
1407 MSG_WriteByte (&host_client->netconnection->message, (char)i);
1408 MSG_WriteString (&host_client->netconnection->message, sv.lightstyles[i]);
1413 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1414 MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALSECRETS);
1415 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->total_secrets);
1417 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1418 MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALMONSTERS);
1419 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->total_monsters);
1421 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1422 MSG_WriteByte (&host_client->netconnection->message, STAT_SECRETS);
1423 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->found_secrets);
1425 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1426 MSG_WriteByte (&host_client->netconnection->message, STAT_MONSTERS);
1427 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->killed_monsters);
1430 // Never send a roll angle, because savegames can catch the server
1431 // in a state where it is expecting the client to correct the angle
1432 // and it won't happen if the game was just loaded, so you wind up
1433 // with a permanent head tilt
1436 MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
1437 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[0], sv.protocol);
1438 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[1], sv.protocol);
1439 MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
1440 sv.loadgame = false; // we're basically done with loading now
1444 MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
1445 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[0], sv.protocol);
1446 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[1], sv.protocol);
1447 MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
1450 SV_WriteClientdataToMessage (host_client, host_client->edict, &host_client->netconnection->message, stats);
1452 MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
1453 MSG_WriteByte (&host_client->netconnection->message, 3);
1461 void Host_Begin_f (void)
1463 host_client->spawned = true;
1466 //===========================================================================
1473 Kicks a user off of the server
1476 void Host_Kick_f (void)
1479 const char *message = NULL;
1482 qboolean byNumber = false;
1490 if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1492 i = (int)(atof(Cmd_Argv(2)) - 1);
1493 if (i < 0 || i >= svs.maxclients || !(host_client = svs.clients + i)->active)
1499 for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
1501 if (!host_client->active)
1503 if (strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1508 if (i < svs.maxclients)
1510 if (cmd_source == src_command)
1512 if (cls.state == ca_dedicated)
1515 who = cl_name.string;
1520 // can't kick yourself!
1521 if (host_client == save)
1526 message = Cmd_Args();
1527 COM_ParseTokenConsole(&message);
1530 message++; // skip the #
1531 while (*message == ' ') // skip white space
1533 message += strlen(Cmd_Argv(2)); // skip the number
1535 while (*message && *message == ' ')
1539 SV_ClientPrintf("Kicked by %s: %s\n", who, message);
1541 SV_ClientPrintf("Kicked by %s\n", who);
1542 SV_DropClient (false); // kicked
1550 ===============================================================================
1554 ===============================================================================
1562 void Host_Give_f (void)
1570 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
1575 v = atoi (Cmd_Argv(2));
1589 // MED 01/04/97 added hipnotic give stuff
1590 if (gamemode == GAME_HIPNOTIC)
1595 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_PROXIMITY_GUN;
1597 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | IT_GRENADE_LAUNCHER;
1599 else if (t[0] == '9')
1600 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_LASER_CANNON;
1601 else if (t[0] == '0')
1602 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_MJOLNIR;
1603 else if (t[0] >= '2')
1604 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
1609 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
1614 if (gamemode == GAME_ROGUE && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_shells1)))
1617 host_client->edict->fields.server->ammo_shells = v;
1620 if (gamemode == GAME_ROGUE)
1622 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_nails1)))
1625 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1626 host_client->edict->fields.server->ammo_nails = v;
1631 host_client->edict->fields.server->ammo_nails = v;
1635 if (gamemode == GAME_ROGUE)
1637 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_lava_nails);
1641 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1642 host_client->edict->fields.server->ammo_nails = v;
1647 if (gamemode == GAME_ROGUE)
1649 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_rockets1);
1653 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1654 host_client->edict->fields.server->ammo_rockets = v;
1659 host_client->edict->fields.server->ammo_rockets = v;
1663 if (gamemode == GAME_ROGUE)
1665 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_multi_rockets);
1669 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1670 host_client->edict->fields.server->ammo_rockets = v;
1675 host_client->edict->fields.server->health = v;
1678 if (gamemode == GAME_ROGUE)
1680 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_cells1);
1684 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1685 host_client->edict->fields.server->ammo_cells = v;
1690 host_client->edict->fields.server->ammo_cells = v;
1694 if (gamemode == GAME_ROGUE)
1696 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_plasma);
1700 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1701 host_client->edict->fields.server->ammo_cells = v;
1708 prvm_edict_t *FindViewthing (void)
1713 for (i=0 ; i<prog->num_edicts ; i++)
1715 e = PRVM_EDICT_NUM(i);
1716 if (!strcmp (PRVM_GetString(e->fields.server->classname), "viewthing"))
1719 Con_Print("No viewthing on map\n");
1728 void Host_Viewmodel_f (void)
1737 e = FindViewthing ();
1742 m = Mod_ForName (Cmd_Argv(1), false, true, false);
1743 if (!m || !m->loaded || !m->Draw)
1745 Con_Printf("viewmodel: can't load %s\n", Cmd_Argv(1));
1749 e->fields.server->frame = 0;
1750 cl.model_precache[(int)e->fields.server->modelindex] = m;
1758 void Host_Viewframe_f (void)
1768 e = FindViewthing ();
1772 m = cl.model_precache[(int)e->fields.server->modelindex];
1774 f = atoi(Cmd_Argv(1));
1775 if (f >= m->numframes)
1778 e->fields.server->frame = f;
1782 void PrintFrameName (model_t *m, int frame)
1785 Con_Printf("frame %i: %s\n", frame, m->animscenes[frame].name);
1787 Con_Printf("frame %i\n", frame);
1795 void Host_Viewnext_f (void)
1804 e = FindViewthing ();
1808 m = cl.model_precache[(int)e->fields.server->modelindex];
1810 e->fields.server->frame = e->fields.server->frame + 1;
1811 if (e->fields.server->frame >= m->numframes)
1812 e->fields.server->frame = m->numframes - 1;
1814 PrintFrameName (m, (int)e->fields.server->frame);
1822 void Host_Viewprev_f (void)
1831 e = FindViewthing ();
1836 m = cl.model_precache[(int)e->fields.server->modelindex];
1838 e->fields.server->frame = e->fields.server->frame - 1;
1839 if (e->fields.server->frame < 0)
1840 e->fields.server->frame = 0;
1842 PrintFrameName (m, (int)e->fields.server->frame);
1846 ===============================================================================
1850 ===============================================================================
1859 void Host_Startdemos_f (void)
1863 if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-demolooponly"))
1869 Con_Printf("Max %i demos in demoloop\n", MAX_DEMOS);
1872 Con_Printf("%i demo(s) in loop\n", c);
1874 for (i=1 ; i<c+1 ; i++)
1875 strlcpy (cls.demos[i-1], Cmd_Argv(i), sizeof (cls.demos[i-1]));
1877 // LordHavoc: clear the remaining slots
1878 for (;i <= MAX_DEMOS;i++)
1879 cls.demos[i-1][0] = 0;
1881 if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1895 Return to looping demos
1898 void Host_Demos_f (void)
1900 if (cls.state == ca_dedicated)
1902 if (cls.demonum == -1)
1912 Return to looping demos
1915 void Host_Stopdemo_f (void)
1917 if (!cls.demoplayback)
1920 Host_ShutdownServer ();
1923 void Host_SendCvar_f (void)
1931 if(!(c = Cvar_FindVar(Cmd_Argv(1))) || (c->flags & CVAR_PRIVATE))
1933 if (cls.state != ca_dedicated)
1934 Cmd_ForwardStringToServer(va("sentcvar %s %s\n", c->name, c->string));
1935 if(!sv.active)// || !SV_ParseClientCommandQC)
1939 if (cls.state != ca_dedicated)
1943 for(;i<svs.maxclients;i++)
1944 if(svs.clients[i].active && svs.clients[i].netconnection)
1946 host_client = &svs.clients[i];
1947 Host_ClientCommands(va("sendcvar %s\n", c->name));
1952 static void MaxPlayers_f(void)
1956 if (Cmd_Argc() != 2)
1958 Con_Printf("\"maxplayers\" is \"%u\"\n", svs.maxclients);
1964 Con_Print("maxplayers can not be changed while a server is running.\n");
1968 n = atoi(Cmd_Argv(1));
1969 n = bound(1, n, MAX_SCOREBOARD);
1970 Con_Printf("\"maxplayers\" set to \"%u\"\n", n);
1973 Mem_Free(svs.clients);
1975 svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
1977 Cvar_Set ("deathmatch", "0");
1979 Cvar_Set ("deathmatch", "1");
1982 //=============================================================================
1984 // QuakeWorld commands
1987 =====================
1990 Send the rest of the command line over as
1991 an unconnected command.
1992 =====================
1994 void Host_Rcon_f (void) // credit: taken from QuakeWorld
1998 lhnetsocket_t *mysocket;
2000 if (!rcon_password.string || !rcon_password.string[0])
2002 Con_Printf ("You must set rcon_password before issuing an rcon command.\n");
2006 for (i = 0;rcon_password.string[i];i++)
2008 if (rcon_password.string[i] <= ' ')
2010 Con_Printf("rcon_password is not allowed to have any whitespace.\n");
2016 to = cls.netcon->peeraddress;
2019 if (!rcon_address.string[0])
2021 Con_Printf ("You must either be connected, or set the rcon_address cvar to issue rcon commands\n");
2024 LHNETADDRESS_FromString(&to, rcon_address.string, sv_netport.integer);
2026 mysocket = NetConn_ChooseClientSocketForAddress(&to);
2029 // simply put together the rcon packet and send it
2030 NetConn_WriteString(mysocket, va("\377\377\377\377rcon %s %s", rcon_password.string, Cmd_Args()), &to);
2035 ====================
2038 user <name or userid>
2040 Dump userdata / masterdata for a user
2041 ====================
2043 void Host_User_f (void) // credit: taken from QuakeWorld
2048 if (Cmd_Argc() != 2)
2050 Con_Printf ("Usage: user <username / userid>\n");
2054 uid = atoi(Cmd_Argv(1));
2056 for (i = 0;i < cl.maxclients;i++)
2058 if (!cl.scores[i].name[0])
2060 if (cl.scores[i].qw_userid == uid || !strcasecmp(cl.scores[i].name, Cmd_Argv(1)))
2062 InfoString_Print(cl.scores[i].qw_userinfo);
2066 Con_Printf ("User not in server.\n");
2070 ====================
2073 Dump userids for all current players
2074 ====================
2076 void Host_Users_f (void) // credit: taken from QuakeWorld
2082 Con_Printf ("userid frags name\n");
2083 Con_Printf ("------ ----- ----\n");
2084 for (i = 0;i < cl.maxclients;i++)
2086 if (cl.scores[i].name[0])
2088 Con_Printf ("%6i %4i %s\n", cl.scores[i].qw_userid, cl.scores[i].frags, cl.scores[i].name);
2093 Con_Printf ("%i total users\n", c);
2098 Host_FullServerinfo_f
2100 Sent by server when serverinfo changes
2103 // TODO: shouldn't this be a cvar instead?
2104 void Host_FullServerinfo_f (void) // credit: taken from QuakeWorld
2107 if (Cmd_Argc() != 2)
2109 Con_Printf ("usage: fullserverinfo <complete info string>\n");
2113 strlcpy (cl.qw_serverinfo, Cmd_Argv(1), sizeof(cl.qw_serverinfo));
2114 InfoString_GetValue(cl.qw_serverinfo, "teamplay", temp, sizeof(temp));
2115 cl.qw_teamplay = atoi(temp);
2122 Allow clients to change userinfo
2126 void Host_FullInfo_f (void) // credit: taken from QuakeWorld
2133 if (Cmd_Argc() != 2)
2135 Con_Printf ("fullinfo <complete info string>\n");
2145 while (*s && *s != '\\')
2151 Con_Printf ("MISSING VALUE\n");
2157 while (*s && *s != '\\')
2164 CL_SetInfo(key, value, false, false, false, false);
2172 Allow clients to change userinfo
2175 void Host_SetInfo_f (void) // credit: taken from QuakeWorld
2177 if (Cmd_Argc() == 1)
2179 InfoString_Print(cls.userinfo);
2182 if (Cmd_Argc() != 3)
2184 Con_Printf ("usage: setinfo [ <key> <value> ]\n");
2187 CL_SetInfo(Cmd_Argv(1), Cmd_Argv(2), true, false, false, false);
2191 ====================
2194 packet <destination> <contents>
2196 Contents allows \n escape character
2197 ====================
2199 void Host_Packet_f (void) // credit: taken from QuakeWorld
2205 lhnetaddress_t address;
2206 lhnetsocket_t *mysocket;
2208 if (Cmd_Argc() != 3)
2210 Con_Printf ("packet <destination> <contents>\n");
2214 if (!LHNETADDRESS_FromString (&address, Cmd_Argv(1), sv_netport.integer))
2216 Con_Printf ("Bad address\n");
2222 send[0] = send[1] = send[2] = send[3] = 0xff;
2224 l = (int)strlen (in);
2225 for (i=0 ; i<l ; i++)
2227 if (out >= send + sizeof(send) - 1)
2229 if (in[i] == '\\' && in[i+1] == 'n')
2234 else if (in[i] == '\\' && in[i+1] == '0')
2239 else if (in[i] == '\\' && in[i+1] == 't')
2244 else if (in[i] == '\\' && in[i+1] == 'r')
2249 else if (in[i] == '\\' && in[i+1] == '"')
2258 mysocket = NetConn_ChooseClientSocketForAddress(&address);
2260 NetConn_Write(mysocket, send, out - send, &address);
2264 ====================
2267 Send back ping and packet loss update for all current players to this player
2268 ====================
2270 void Host_Pings_f (void)
2272 int i, j, ping, packetloss;
2275 if (!host_client->netconnection)
2278 if (sv.protocol != PROTOCOL_QUAKEWORLD)
2280 MSG_WriteByte(&host_client->netconnection->message, svc_stufftext);
2281 MSG_WriteUnterminatedString(&host_client->netconnection->message, "pingplreport");
2283 for (i = 0;i < svs.maxclients;i++)
2286 if (svs.clients[i].netconnection)
2287 for (j = 0;j < 100;j++)
2288 packetloss += svs.clients[i].netconnection->packetlost[j];
2289 ping = (int)floor(svs.clients[i].ping*1000+0.5);
2290 ping = bound(0, ping, 9999);
2291 if (sv.protocol == PROTOCOL_QUAKEWORLD)
2293 // send qw_svc_updateping and qw_svc_updatepl messages
2294 MSG_WriteByte(&host_client->netconnection->message, qw_svc_updateping);
2295 MSG_WriteShort(&host_client->netconnection->message, ping);
2296 MSG_WriteByte(&host_client->netconnection->message, qw_svc_updatepl);
2297 MSG_WriteByte(&host_client->netconnection->message, packetloss);
2301 // write the string into the packet as multiple unterminated strings to avoid needing a local buffer
2302 dpsnprintf(temp, sizeof(temp), " %d %d", ping, packetloss);
2303 MSG_WriteUnterminatedString(&host_client->netconnection->message, temp);
2306 if (sv.protocol != PROTOCOL_QUAKEWORLD)
2307 MSG_WriteString(&host_client->netconnection->message, "\n");
2310 void Host_PingPLReport_f(void)
2314 if (l > cl.maxclients)
2316 for (i = 0;i < l;i++)
2318 cl.scores[i].qw_ping = atoi(Cmd_Argv(1+i*2));
2319 cl.scores[i].qw_packetloss = atoi(Cmd_Argv(1+i*2+1));
2323 //=============================================================================
2330 void Host_InitCommands (void)
2332 dpsnprintf(cls.userinfo, sizeof(cls.userinfo), "\\name\\player\\team\\none\\topcolor\\0\\bottomcolor\\0\\rate\\10000\\msg\\1\\noaim\\1\\*ver\\%s", engineversion);
2334 Cmd_AddCommand_WithClientCommand ("status", Host_Status_f, Host_Status_f, "print server status information");
2335 Cmd_AddCommand ("quit", Host_Quit_f, "quit the game");
2336 if (gamemode == GAME_NEHAHRA)
2338 Cmd_AddCommand_WithClientCommand ("max", NULL, Host_God_f, "god mode (invulnerability)");
2339 Cmd_AddCommand_WithClientCommand ("monster", NULL, Host_Notarget_f, "notarget mode (monsters do not see you)");
2340 Cmd_AddCommand_WithClientCommand ("scrag", NULL, Host_Fly_f, "fly mode (flight)");
2341 Cmd_AddCommand_WithClientCommand ("wraith", NULL, Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
2342 Cmd_AddCommand_WithClientCommand ("gimme", NULL, Host_Give_f, "alter inventory");
2346 Cmd_AddCommand_WithClientCommand ("god", NULL, Host_God_f, "god mode (invulnerability)");
2347 Cmd_AddCommand_WithClientCommand ("notarget", NULL, Host_Notarget_f, "notarget mode (monsters do not see you)");
2348 Cmd_AddCommand_WithClientCommand ("fly", NULL, Host_Fly_f, "fly mode (flight)");
2349 Cmd_AddCommand_WithClientCommand ("noclip", NULL, Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
2350 Cmd_AddCommand_WithClientCommand ("give", NULL, Host_Give_f, "alter inventory");
2352 Cmd_AddCommand ("map", Host_Map_f, "kick everyone off the server and start a new level");
2353 Cmd_AddCommand ("restart", Host_Restart_f, "restart current level");
2354 Cmd_AddCommand ("changelevel", Host_Changelevel_f, "change to another level, bringing along all connected clients");
2355 Cmd_AddCommand ("connect", Host_Connect_f, "connect to a server by IP address or hostname");
2356 Cmd_AddCommand ("reconnect", Host_Reconnect_f, "reset signon level in preparation for a new level (do not use)");
2357 Cmd_AddCommand ("version", Host_Version_f, "print engine version");
2358 Cmd_AddCommand_WithClientCommand ("say", Host_Say_f, Host_Say_f, "send a chat message to everyone on the server");
2359 Cmd_AddCommand_WithClientCommand ("say_team", Host_Say_Team_f, Host_Say_Team_f, "send a chat message to your team on the server");
2360 Cmd_AddCommand_WithClientCommand ("tell", Host_Tell_f, Host_Tell_f, "send a chat message to only one person on the server");
2361 Cmd_AddCommand_WithClientCommand ("kill", NULL, Host_Kill_f, "die instantly");
2362 Cmd_AddCommand_WithClientCommand ("pause", NULL, Host_Pause_f, "pause the game (if the server allows pausing)");
2363 Cmd_AddCommand ("kick", Host_Kick_f, "kick a player off the server by number or name");
2364 Cmd_AddCommand_WithClientCommand ("ping", Host_Ping_f, Host_Ping_f, "print ping times of all players on the server");
2365 Cmd_AddCommand ("load", Host_Loadgame_f, "load a saved game file");
2366 Cmd_AddCommand ("save", Host_Savegame_f, "save the game to a file");
2368 Cmd_AddCommand ("startdemos", Host_Startdemos_f, "start playing back the selected demos sequentially (used at end of startup script)");
2369 Cmd_AddCommand ("demos", Host_Demos_f, "restart looping demos defined by the last startdemos command");
2370 Cmd_AddCommand ("stopdemo", Host_Stopdemo_f, "stop playing or recording demo (like stop command) and return to looping demos");
2372 Cmd_AddCommand ("viewmodel", Host_Viewmodel_f, "change model of viewthing entity in current level");
2373 Cmd_AddCommand ("viewframe", Host_Viewframe_f, "change animation frame of viewthing entity in current level");
2374 Cmd_AddCommand ("viewnext", Host_Viewnext_f, "change to next animation frame of viewthing entity in current level");
2375 Cmd_AddCommand ("viewprev", Host_Viewprev_f, "change to previous animation frame of viewthing entity in current level");
2377 Cvar_RegisterVariable (&cl_name);
2378 Cmd_AddCommand_WithClientCommand ("name", Host_Name_f, Host_Name_f, "change your player name");
2379 Cvar_RegisterVariable (&cl_color);
2380 Cmd_AddCommand_WithClientCommand ("color", Host_Color_f, Host_Color_f, "change your player shirt and pants colors");
2381 Cvar_RegisterVariable (&cl_rate);
2382 Cmd_AddCommand_WithClientCommand ("rate", Host_Rate_f, Host_Rate_f, "change your network connection speed");
2383 if (gamemode == GAME_NEHAHRA)
2385 Cvar_RegisterVariable (&cl_pmodel);
2386 Cmd_AddCommand_WithClientCommand ("pmodel", Host_PModel_f, Host_PModel_f, "change your player model choice (Nehahra specific)");
2389 // BLACK: This isnt game specific anymore (it was GAME_NEXUIZ at first)
2390 Cvar_RegisterVariable (&cl_playermodel);
2391 Cmd_AddCommand_WithClientCommand ("playermodel", Host_Playermodel_f, Host_Playermodel_f, "change your player model");
2392 Cvar_RegisterVariable (&cl_playerskin);
2393 Cmd_AddCommand_WithClientCommand ("playerskin", Host_Playerskin_f, Host_Playerskin_f, "change your player skin number");
2395 Cmd_AddCommand_WithClientCommand ("prespawn", NULL, Host_PreSpawn_f, "signon 1 (client acknowledges that server information has been received)");
2396 Cmd_AddCommand_WithClientCommand ("spawn", NULL, Host_Spawn_f, "signon 2 (client has sent player information, and is asking server to send scoreboard rankings)");
2397 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)");
2398 Cmd_AddCommand ("maxplayers", MaxPlayers_f, "sets limit on how many players (or bots) may be connected to the server at once");
2400 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]
2402 Cvar_RegisterVariable (&rcon_password);
2403 Cvar_RegisterVariable (&rcon_address);
2404 Cmd_AddCommand ("rcon", Host_Rcon_f, "sends a command to the server console (if your rcon_password matches the server's rcon_password), or to the address specified by rcon_address when not connected (again rcon_password must match the server's)");
2405 Cmd_AddCommand ("user", Host_User_f, "prints additional information about a player number or name on the scoreboard");
2406 Cmd_AddCommand ("users", Host_Users_f, "prints additional information about all players on the scoreboard");
2407 Cmd_AddCommand ("fullserverinfo", Host_FullServerinfo_f, "internal use only, sent by server to client to update client's local copy of serverinfo string");
2408 Cmd_AddCommand ("fullinfo", Host_FullInfo_f, "allows client to modify their userinfo");
2409 Cmd_AddCommand ("setinfo", Host_SetInfo_f, "modifies your userinfo");
2410 Cmd_AddCommand ("packet", Host_Packet_f, "send a packet to the specified address:port containing a text string");
2411 Cmd_AddCommand ("topcolor", Host_TopColor_f, "QW command to set top color without changing bottom color");
2412 Cmd_AddCommand ("bottomcolor", Host_BottomColor_f, "QW command to set bottom color without changing top color");
2414 Cmd_AddCommand_WithClientCommand ("pings", NULL, Host_Pings_f, "command sent by clients to request updated ping and packetloss of players on scoreboard (originally from QW, but also used on NQ servers)");
2415 Cmd_AddCommand ("pingplreport", Host_PingPLReport_f, "command sent by server containing client ping and packet loss values for scoreboard, triggered by pings command from client (not used by QW servers)");
2417 Cvar_RegisterVariable (&team);
2418 Cvar_RegisterVariable (&skin);
2419 Cvar_RegisterVariable (&noaim);
2421 Cvar_RegisterVariable(&sv_cheats);