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 = {0, "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)
59 Cmd_ForwardToServer ();
65 print = SV_ClientPrintf;
67 for (players = 0, j = 0;j < svs.maxclients;j++)
68 if (svs.clients[j].active)
70 print ("host: %s\n", Cvar_VariableString ("hostname"));
71 print ("version: %s build %s\n", gamename, buildstring);
72 print ("protocol: %i (%s)\n", Protocol_NumberForEnum(sv.protocol), Protocol_NameForEnum(sv.protocol));
73 print ("map: %s\n", sv.name);
74 print ("players: %i active (%i max)\n\n", players, svs.maxclients);
75 for (j = 0, client = svs.clients;j < svs.maxclients;j++, client++)
79 seconds = (int)(realtime - client->connecttime);
80 minutes = seconds / 60;
83 seconds -= (minutes * 60);
86 minutes -= (hours * 60);
90 print ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->fields.server->frags, hours, minutes, seconds);
91 print (" %s\n", client->netconnection ? client->netconnection->address : "botclient");
100 Sets client to godmode
103 void Host_God_f (void)
105 if (cmd_source == src_command)
107 Cmd_ForwardToServer ();
113 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
117 host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags ^ FL_GODMODE;
118 if (!((int)host_client->edict->fields.server->flags & FL_GODMODE) )
119 SV_ClientPrint("godmode OFF\n");
121 SV_ClientPrint("godmode ON\n");
124 void Host_Notarget_f (void)
126 if (cmd_source == src_command)
128 Cmd_ForwardToServer ();
134 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
138 host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags ^ FL_NOTARGET;
139 if (!((int)host_client->edict->fields.server->flags & FL_NOTARGET) )
140 SV_ClientPrint("notarget OFF\n");
142 SV_ClientPrint("notarget ON\n");
145 qboolean noclip_anglehack;
147 void Host_Noclip_f (void)
149 if (cmd_source == src_command)
151 Cmd_ForwardToServer ();
157 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
161 if (host_client->edict->fields.server->movetype != MOVETYPE_NOCLIP)
163 noclip_anglehack = true;
164 host_client->edict->fields.server->movetype = MOVETYPE_NOCLIP;
165 SV_ClientPrint("noclip ON\n");
169 noclip_anglehack = false;
170 host_client->edict->fields.server->movetype = MOVETYPE_WALK;
171 SV_ClientPrint("noclip OFF\n");
179 Sets client to flymode
182 void Host_Fly_f (void)
184 if (cmd_source == src_command)
186 Cmd_ForwardToServer ();
192 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
196 if (host_client->edict->fields.server->movetype != MOVETYPE_FLY)
198 host_client->edict->fields.server->movetype = MOVETYPE_FLY;
199 SV_ClientPrint("flymode ON\n");
203 host_client->edict->fields.server->movetype = MOVETYPE_WALK;
204 SV_ClientPrint("flymode OFF\n");
215 void Host_Ping_f (void)
219 void (*print) (const char *fmt, ...);
221 if (cmd_source == src_command)
225 Cmd_ForwardToServer ();
231 print = SV_ClientPrintf;
233 print("Client ping times:\n");
234 for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
238 print("%4i %s\n", (int)floor(client->ping*1000+0.5), client->name);
243 ===============================================================================
247 ===============================================================================
251 ======================
256 command from the console. Active clients are kicked off.
257 ======================
259 void Host_Map_f (void)
261 char level[MAX_QPATH];
265 Con_Print("map <levelname> : start a new game (kicks off all players)\n");
269 if (cmd_source != src_command)
272 cls.demonum = -1; // stop demo loop in case this fails
275 Host_ShutdownServer();
280 svs.serverflags = 0; // haven't completed an episode yet
281 allowcheats = sv_cheats.integer != 0;
282 strcpy(level, Cmd_Argv(1));
283 SV_SpawnServer(level);
284 if (sv.active && cls.state == ca_disconnected)
285 CL_EstablishConnection("local:1");
287 // if cl_autodemo is set, automatically start recording a demo if one isn't being recorded already
288 if (cl_autodemo.integer && !cls.demorecording)
290 char demofile[MAX_OSPATH];
292 dpsnprintf (demofile, sizeof(demofile), "%s_%s.dem", Sys_TimeString (cl_autodemo_nameformat.string), level);
294 Con_Printf ("Recording to %s.\n", demofile);
296 cls.demofile = FS_Open (demofile, "wb", false, false);
300 FS_Printf (cls.demofile, "%i\n", cls.forcetrack);
303 Con_Print ("ERROR: couldn't open.\n");
305 cls.demorecording = true;
313 Goes to a new map, taking all clients along
316 void Host_Changelevel_f (void)
318 char level[MAX_QPATH];
322 Con_Print("changelevel <levelname> : continue game on a new level\n");
330 if (cmd_source != src_command)
337 SV_SaveSpawnparms ();
339 allowcheats = sv_cheats.integer != 0;
340 strcpy(level, Cmd_Argv(1));
341 SV_SpawnServer(level);
342 if (sv.active && cls.state == ca_disconnected)
343 CL_EstablishConnection("local:1");
350 Restarts the current server for a dead player
353 void Host_Restart_f (void)
355 char mapname[MAX_QPATH];
359 Con_Print("restart : restart current level\n");
364 Con_Print("Only the server may restart\n");
367 if (cmd_source != src_command)
373 allowcheats = sv_cheats.integer != 0;
374 strcpy(mapname, sv.name);
375 SV_SpawnServer(mapname);
376 if (sv.active && cls.state == ca_disconnected)
377 CL_EstablishConnection("local:1");
384 This command causes the client to wait for the signon messages again.
385 This is sent just before a server changes levels
388 void Host_Reconnect_f (void)
390 if (cls.protocol == PROTOCOL_QUAKEWORLD)
392 if (cls.qw_downloadmemory) // don't change when downloading
399 if (cls.state == ca_connected && cls.signon < SIGNONS)
401 Con_Printf("reconnecting...\n");
402 MSG_WriteChar(&cls.netcon->message, qw_clc_stringcmd);
403 MSG_WriteString(&cls.netcon->message, "new");
408 // if we have connected to a server recently, the userinfo
409 // will still contain its IP address, so get the address...
410 InfoString_GetValue(cls.userinfo, "*ip", temp, sizeof(temp));
412 CL_EstablishConnection(temp);
414 Con_Printf("Reconnect to what server? (you have not connected to a server yet)\n");
422 Con_Print("reconnect : wait for signon messages again\n");
427 Con_Print("reconnect: no signon, ignoring reconnect\n");
430 cls.signon = 0; // need new connection messages
435 =====================
438 User command to connect to server
439 =====================
441 void Host_Connect_f (void)
445 Con_Print("connect <serveraddress> : connect to a multiplayer game\n");
448 CL_EstablishConnection(Cmd_Argv(1));
453 ===============================================================================
457 ===============================================================================
460 #define SAVEGAME_VERSION 5
466 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
469 void Host_SavegameComment (char *text)
474 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
476 // LordHavoc: added min() to prevent overflow
477 memcpy (text, cl.levelname, min(strlen(cl.levelname), SAVEGAME_COMMENT_LENGTH));
478 sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
479 memcpy (text+22, kills, strlen(kills));
480 // convert space to _ to make stdio happy
481 // LordHavoc: convert control characters to _ as well
482 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
485 text[SAVEGAME_COMMENT_LENGTH] = '\0';
494 void Host_Savegame_f (void)
496 char name[MAX_QPATH];
499 char comment[SAVEGAME_COMMENT_LENGTH+1];
501 if (cmd_source != src_command)
504 if (cls.state != ca_connected || !sv.active)
506 Con_Print("Not playing a local game.\n");
512 Con_Print("Can't save in intermission.\n");
516 for (i = 0;i < svs.maxclients;i++)
518 if (svs.clients[i].active)
522 Con_Print("Can't save multiplayer games.\n");
525 if (svs.clients[i].edict->fields.server->deadflag)
527 Con_Print("Can't savegame with a dead player\n");
535 Con_Print("save <savename> : save a game\n");
539 if (strstr(Cmd_Argv(1), ".."))
541 Con_Print("Relative pathnames are not allowed.\n");
545 strlcpy (name, Cmd_Argv(1), sizeof (name));
546 FS_DefaultExtension (name, ".sav", sizeof (name));
548 Con_Printf("Saving game to %s...\n", name);
549 f = FS_Open (name, "wb", false, false);
552 Con_Print("ERROR: couldn't open.\n");
556 FS_Printf(f, "%i\n", SAVEGAME_VERSION);
557 Host_SavegameComment (comment);
558 FS_Printf(f, "%s\n", comment);
559 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
560 FS_Printf(f, "%f\n", svs.clients[0].spawn_parms[i]);
561 FS_Printf(f, "%d\n", current_skill);
562 FS_Printf(f, "%s\n", sv.name);
563 FS_Printf(f, "%f\n",sv.time);
565 // write the light styles
566 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
568 if (sv.lightstyles[i][0])
569 FS_Printf(f, "%s\n", sv.lightstyles[i]);
576 PRVM_ED_WriteGlobals (f);
577 for (i=0 ; i<prog->num_edicts ; i++)
578 PRVM_ED_Write (f, PRVM_EDICT_NUM(i));
583 Con_Print("done.\n");
592 void Host_Loadgame_f (void)
594 char filename[MAX_QPATH];
595 char mapname[MAX_QPATH];
605 float spawn_parms[NUM_SPAWN_PARMS];
607 if (cmd_source != src_command)
612 Con_Print("load <savename> : load a game\n");
616 strcpy (filename, Cmd_Argv(1));
617 FS_DefaultExtension (filename, ".sav", sizeof (filename));
619 Con_Printf("Loading game from %s...\n", filename);
621 cls.demonum = -1; // stop demo loop in case this fails
623 t = text = (char *)FS_LoadFile (filename, tempmempool, false, NULL);
626 Con_Print("ERROR: couldn't open.\n");
631 COM_ParseToken(&t, false);
632 version = atoi(com_token);
633 if (version != SAVEGAME_VERSION)
636 Con_Printf("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
641 // this is a little hard to parse, as : is a separator in COM_ParseToken,
642 // so use the console parser instead
643 COM_ParseTokenConsole(&t);
645 for (i = 0;i < NUM_SPAWN_PARMS;i++)
647 COM_ParseToken(&t, false);
648 spawn_parms[i] = atof(com_token);
651 COM_ParseToken(&t, false);
652 // this silliness is so we can load 1.06 save files, which have float skill values
653 current_skill = (int)(atof(com_token) + 0.5);
654 Cvar_SetValue ("skill", (float)current_skill);
657 COM_ParseToken(&t, false);
658 strcpy (mapname, com_token);
661 COM_ParseToken(&t, false);
662 time = atof(com_token);
664 allowcheats = sv_cheats.integer != 0;
666 SV_SpawnServer (mapname);
670 Con_Print("Couldn't load map\n");
673 sv.paused = true; // pause until all clients connect
676 // load the light styles
678 for (i = 0;i < MAX_LIGHTSTYLES;i++)
682 COM_ParseToken(&t, false);
683 // if this is a 64 lightstyle savegame produced by Quake, stop now
684 // we have to check this because darkplaces saves 256 lightstyle savegames
685 if (com_token[0] == '{')
690 strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i]));
693 // now skip everything before the first opening brace
694 // (this is for forward compatibility, so that older versions (at
695 // least ones with this fix) can load savegames with extra data before the
696 // first brace, as might be produced by a later engine version)
700 COM_ParseToken(&t, false);
701 if (com_token[0] == '{')
708 // load the edicts out of the savegame file
715 while (COM_ParseToken(&t, false))
716 if (!strcmp(com_token, "}"))
718 if (!COM_ParseToken(&start, false))
723 if (strcmp(com_token,"{"))
726 Host_Error ("First token isn't a brace");
731 // parse the global vars
732 PRVM_ED_ParseGlobals (start);
737 if (entnum >= MAX_EDICTS)
740 Host_Error("Host_PerformLoadGame: too many edicts in save file (reached MAX_EDICTS %i)", MAX_EDICTS);
742 while (entnum >= prog->max_edicts)
743 //SV_IncreaseEdicts();
744 PRVM_MEM_IncreaseEdicts();
745 ent = PRVM_EDICT_NUM(entnum);
746 memset (ent->fields.server, 0, prog->progs->entityfields * 4);
747 ent->priv.server->free = false;
748 PRVM_ED_ParseEdict (start, ent);
750 // link it into the bsp tree
751 if (!ent->priv.server->free)
752 SV_LinkEdict (ent, false);
759 prog->num_edicts = entnum;
762 for (i = 0;i < NUM_SPAWN_PARMS;i++)
763 svs.clients[0].spawn_parms[i] = spawn_parms[i];
767 // make sure we're connected to loopback
768 if (cls.state == ca_disconnected || !(cls.state == ca_connected && cls.netcon != NULL && LHNETADDRESS_GetAddressType(&cls.netcon->peeraddress) == LHNETADDRESSTYPE_LOOP))
769 CL_EstablishConnection("local:1");
772 //============================================================================
775 ======================
777 ======================
779 cvar_t cl_name = {CVAR_SAVE, "_cl_name", "player", "internal storage cvar for current player name (changed by name command)"};
780 void Host_Name_f (void)
783 char newName[sizeof(host_client->name)];
785 if (Cmd_Argc () == 1)
787 Con_Printf("\"name\" is \"%s\"\n", cl_name.string);
791 if (Cmd_Argc () == 2)
792 strlcpy (newName, Cmd_Argv(1), sizeof (newName));
794 strlcpy (newName, Cmd_Args(), sizeof (newName));
796 for (i = 0, j = 0;newName[i];i++)
797 if (newName[i] != '\r' && newName[i] != '\n')
798 newName[j++] = newName[i];
801 if (cmd_source == src_command)
803 Cvar_Set ("_cl_name", newName);
804 CL_SetInfo("name", newName, true, false, false, false);
808 if (sv.time < host_client->nametime)
810 SV_ClientPrintf("You can't change name more than once every 5 seconds!\n");
814 host_client->nametime = sv.time + 5;
816 // point the string back at updateclient->name to keep it safe
817 strlcpy (host_client->name, newName, sizeof (host_client->name));
818 host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name);
819 if (strcmp(host_client->old_name, host_client->name))
821 if (host_client->spawned)
822 SV_BroadcastPrintf("%s changed name to %s\n", host_client->old_name, host_client->name);
823 strcpy(host_client->old_name, host_client->name);
824 // send notification to all clients
825 MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
826 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
827 MSG_WriteString (&sv.reliable_datagram, host_client->name);
832 ======================
834 ======================
836 cvar_t cl_playermodel = {CVAR_SAVE, "_cl_playermodel", "", "internal storage cvar for current player model in Nexuiz (changed by playermodel command)"};
837 // the old cl_playermodel in cl_main has been renamed to __cl_playermodel
838 void Host_Playermodel_f (void)
841 char newPath[sizeof(host_client->playermodel)];
843 if (Cmd_Argc () == 1)
845 Con_Printf("\"playermodel\" is \"%s\"\n", cl_playermodel.string);
849 if (Cmd_Argc () == 2)
850 strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
852 strlcpy (newPath, Cmd_Args(), sizeof (newPath));
854 for (i = 0, j = 0;newPath[i];i++)
855 if (newPath[i] != '\r' && newPath[i] != '\n')
856 newPath[j++] = newPath[i];
859 if (cmd_source == src_command)
861 Cvar_Set ("_cl_playermodel", newPath);
862 CL_SetInfo("playermodel", newPath, true, false, false, false);
867 if (sv.time < host_client->nametime)
869 SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
873 host_client->nametime = sv.time + 5;
876 // point the string back at updateclient->name to keep it safe
877 strlcpy (host_client->playermodel, newPath, sizeof (host_client->playermodel));
878 if( eval_playermodel )
879 PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PRVM_SetEngineString(host_client->playermodel);
880 if (strcmp(host_client->old_model, host_client->playermodel))
882 strcpy(host_client->old_model, host_client->playermodel);
883 /*// send notification to all clients
884 MSG_WriteByte (&sv.reliable_datagram, svc_updatepmodel);
885 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
886 MSG_WriteString (&sv.reliable_datagram, host_client->playermodel);*/
891 ======================
893 ======================
895 cvar_t cl_playerskin = {CVAR_SAVE, "_cl_playerskin", "", "internal storage cvar for current player skin in Nexuiz (changed by playerskin command)"};
896 void Host_Playerskin_f (void)
899 char newPath[sizeof(host_client->playerskin)];
901 if (Cmd_Argc () == 1)
903 Con_Printf("\"playerskin\" is \"%s\"\n", cl_playerskin.string);
907 if (Cmd_Argc () == 2)
908 strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
910 strlcpy (newPath, Cmd_Args(), sizeof (newPath));
912 for (i = 0, j = 0;newPath[i];i++)
913 if (newPath[i] != '\r' && newPath[i] != '\n')
914 newPath[j++] = newPath[i];
917 if (cmd_source == src_command)
919 Cvar_Set ("_cl_playerskin", newPath);
920 CL_SetInfo("playermodel", newPath, true, false, false, false);
925 if (sv.time < host_client->nametime)
927 SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
931 host_client->nametime = sv.time + 5;
934 // point the string back at updateclient->name to keep it safe
935 strlcpy (host_client->playerskin, newPath, sizeof (host_client->playerskin));
936 if( eval_playerskin )
937 PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string = PRVM_SetEngineString(host_client->playerskin);
938 if (strcmp(host_client->old_skin, host_client->playerskin))
940 if (host_client->spawned)
941 SV_BroadcastPrintf("%s changed skin to %s\n", host_client->name, host_client->playerskin);
942 strcpy(host_client->old_skin, host_client->playerskin);
943 /*// send notification to all clients
944 MSG_WriteByte (&sv.reliable_datagram, svc_updatepskin);
945 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
946 MSG_WriteString (&sv.reliable_datagram, host_client->playerskin);*/
950 void Host_Version_f (void)
952 Con_Printf("Version: %s build %s\n", gamename, buildstring);
955 void Host_Say(qboolean teamonly)
961 // LordHavoc: long say messages
963 qboolean fromServer = false;
965 if (cmd_source == src_command)
967 if (cls.state == ca_dedicated)
974 Cmd_ForwardToServer ();
982 if (!teamplay.integer)
992 // note this uses the chat prefix \001
994 dpsnprintf (text, sizeof(text), "\001%s" STRING_COLOR_DEFAULT_STR ": %s", host_client->name, p1);
996 dpsnprintf (text, sizeof(text), "\001<%s" STRING_COLOR_DEFAULT_STR "> %s", hostname.string, p1);
997 p2 = text + strlen(text);
998 while ((const char *)p2 > (const char *)text && (p2[-1] == '\r' || p2[-1] == '\n' || (p2[-1] == '\"' && quoted)))
1000 if (p2[-1] == '\"' && quoted)
1005 strlcat(text, "\n", sizeof(text));
1007 // note: save is not a valid edict if fromServer is true
1009 for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
1010 if (host_client->spawned && (!teamonly || host_client->edict->fields.server->team == save->edict->fields.server->team))
1011 SV_ClientPrint(text);
1014 if (cls.state == ca_dedicated)
1015 Con_Print(&text[1]);
1019 void Host_Say_f(void)
1025 void Host_Say_Team_f(void)
1031 void Host_Tell_f(void)
1035 const char *p1, *p2;
1036 char text[MAX_INPUTLINE]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
1037 qboolean fromServer = false;
1039 if (cmd_source == src_command)
1041 if (cls.state == ca_dedicated)
1045 Cmd_ForwardToServer ();
1050 if (Cmd_Argc () < 3)
1053 // note this uses the chat prefix \001
1055 sprintf (text, "\001%s tells you: ", host_client->name);
1057 sprintf (text, "\001<%s tells you> ", hostname.string);
1060 p2 = p1 + strlen(p1);
1061 // remove the target name
1062 while (p1 < p2 && *p1 != ' ')
1064 while (p1 < p2 && *p1 == ' ')
1066 // remove trailing newlines
1067 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
1069 // remove quotes if present
1075 else if (fromServer)
1076 Con_Print("Host_Tell: missing end quote\n");
1078 SV_ClientPrint("Host_Tell: missing end quote\n");
1080 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
1082 for (j = (int)strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;)
1088 for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
1089 if (host_client->spawned && !strcasecmp(host_client->name, Cmd_Argv(1)))
1090 SV_ClientPrint(text);
1100 cvar_t cl_color = {CVAR_SAVE, "_cl_color", "0", "internal storage cvar for current player colors (changed by color command)"};
1101 void Host_Color(int changetop, int changebottom)
1103 int top, bottom, playercolor;
1105 func_t SV_ChangeTeam;
1107 // get top and bottom either from the provided values or the current values
1108 // (allows changing only top or bottom, or both at once)
1109 top = changetop >= 0 ? changetop : (cl_color.integer >> 4);
1110 bottom = changebottom >= 0 ? changebottom : cl_color.integer;
1114 // LordHavoc: allowing skin colormaps 14 and 15 by commenting this out
1120 playercolor = top*16 + bottom;
1122 if (cmd_source == src_command)
1124 Cvar_SetValueQuick(&cl_color, playercolor);
1126 CL_SetInfo("topcolor", va("%i", top), true, false, false, false);
1127 if (changebottom >= 0)
1128 CL_SetInfo("bottomcolor", va("%i", bottom), true, false, false, false);
1129 if (cls.protocol != PROTOCOL_QUAKEWORLD)
1131 MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
1132 MSG_WriteString(&cls.netcon->message, va("color %i %i", top, bottom));
1137 if (cls.protocol == PROTOCOL_QUAKEWORLD)
1140 if (host_client->edict && (f = PRVM_ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - prog->functions)))
1142 Con_DPrint("Calling SV_ChangeTeam\n");
1143 prog->globals.server->time = sv.time;
1144 prog->globals.generic[OFS_PARM0] = playercolor;
1145 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1146 PRVM_ExecuteProgram (SV_ChangeTeam, "QC function SV_ChangeTeam is missing");
1151 if (host_client->edict)
1153 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_clientcolors)))
1154 val->_float = playercolor;
1155 host_client->edict->fields.server->team = bottom + 1;
1157 host_client->colors = playercolor;
1158 if (host_client->old_colors != host_client->colors)
1160 host_client->old_colors = host_client->colors;
1161 // send notification to all clients
1162 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
1163 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
1164 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
1169 void Host_Color_f(void)
1173 if (Cmd_Argc() == 1)
1175 Con_Printf("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15);
1176 Con_Print("color <0-15> [0-15]\n");
1180 if (Cmd_Argc() == 2)
1181 top = bottom = atoi(Cmd_Argv(1));
1184 top = atoi(Cmd_Argv(1));
1185 bottom = atoi(Cmd_Argv(2));
1187 Host_Color(top, bottom);
1190 void Host_TopColor_f(void)
1192 if (Cmd_Argc() == 1)
1194 Con_Printf("\"topcolor\" is \"%i\"\n", cl_color.integer >> 4);
1195 Con_Print("topcolor <0-15>\n");
1199 Host_Color(atoi(Cmd_Argv(1)), -1);
1202 void Host_BottomColor_f(void)
1204 if (Cmd_Argc() == 1)
1206 Con_Printf("\"bottomcolor\" is \"%i\"\n", cl_color.integer);
1207 Con_Print("bottomcolor <0-15>\n");
1211 Host_Color(-1, atoi(Cmd_Argv(1)));
1214 cvar_t cl_rate = {CVAR_SAVE, "_cl_rate", "10000", "internal storage cvar for current rate (changed by rate command)"};
1215 void Host_Rate_f(void)
1219 if (Cmd_Argc() != 2)
1221 Con_Printf("\"rate\" is \"%i\"\n", cl_rate.integer);
1222 Con_Print("rate <500-25000>\n");
1226 rate = atoi(Cmd_Argv(1));
1228 if (cmd_source == src_command)
1230 Cvar_SetValue ("_cl_rate", bound(NET_MINRATE, rate, NET_MAXRATE));
1231 CL_SetInfo("rate", va("%i", rate), true, false, false, false);
1235 host_client->rate = rate;
1243 void Host_Kill_f (void)
1245 if (cmd_source == src_command)
1247 Cmd_ForwardToServer ();
1251 if (host_client->edict->fields.server->health <= 0)
1253 SV_ClientPrint("Can't suicide -- already dead!\n");
1257 prog->globals.server->time = sv.time;
1258 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1259 PRVM_ExecuteProgram (prog->globals.server->ClientKill, "QC function ClientKill is missing");
1268 void Host_Pause_f (void)
1271 if (cmd_source == src_command)
1273 Cmd_ForwardToServer ();
1276 if (!pausable.integer)
1277 SV_ClientPrint("Pause not allowed.\n");
1281 SV_BroadcastPrintf("%s %spaused the game\n", host_client->name, sv.paused ? "" : "un");
1282 // send notification to all clients
1283 MSG_WriteByte(&sv.reliable_datagram, svc_setpause);
1284 MSG_WriteByte(&sv.reliable_datagram, sv.paused);
1289 ======================
1291 LordHavoc: only supported for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
1292 LordHavoc: correction, Mindcrime will be removing pmodel in the future, but it's still stuck here for compatibility.
1293 ======================
1295 cvar_t cl_pmodel = {CVAR_SAVE, "_cl_pmodel", "0", "internal storage cvar for current player model number in nehahra (changed by pmodel command)"};
1296 static void Host_PModel_f (void)
1301 if (Cmd_Argc () == 1)
1303 Con_Printf("\"pmodel\" is \"%s\"\n", cl_pmodel.string);
1306 i = atoi(Cmd_Argv(1));
1308 if (cmd_source == src_command)
1310 if (cl_pmodel.integer == i)
1312 Cvar_SetValue ("_cl_pmodel", i);
1313 if (cls.state == ca_connected)
1314 Cmd_ForwardToServer ();
1318 if (host_client->edict && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1322 //===========================================================================
1330 void Host_PreSpawn_f (void)
1332 if (cmd_source == src_command)
1334 Con_Print("prespawn is not valid from the console\n");
1338 if (host_client->spawned)
1340 Con_Print("prespawn not valid -- already spawned\n");
1344 if (host_client->netconnection)
1346 SZ_Write (&host_client->netconnection->message, sv.signon.data, sv.signon.cursize);
1347 MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
1348 MSG_WriteByte (&host_client->netconnection->message, 2);
1351 // reset the name change timer because the client will send name soon
1352 host_client->nametime = 0;
1360 void Host_Spawn_f (void)
1366 int stats[MAX_CL_STATS];
1368 if (cmd_source == src_command)
1370 Con_Print("spawn is not valid from the console\n");
1374 if (host_client->spawned)
1376 Con_Print("Spawn not valid -- already spawned\n");
1380 // reset name change timer again because they might want to change name
1381 // again in the first 5 seconds after connecting
1382 host_client->nametime = 0;
1384 // LordHavoc: moved this above the QC calls at FrikaC's request
1385 // LordHavoc: commented this out
1386 //if (host_client->netconnection)
1387 // SZ_Clear (&host_client->netconnection->message);
1389 // run the entrance script
1392 // loaded games are fully initialized already
1393 // if this is the last client to be connected, unpause
1396 if ((f = PRVM_ED_FindFunction ("RestoreGame")))
1397 if ((RestoreGame = (func_t)(f - prog->functions)))
1399 Con_DPrint("Calling RestoreGame\n");
1400 prog->globals.server->time = sv.time;
1401 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1402 PRVM_ExecuteProgram (RestoreGame, "QC function RestoreGame is missing");
1407 //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);
1409 // copy spawn parms out of the client_t
1410 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1411 (&prog->globals.server->parm1)[i] = host_client->spawn_parms[i];
1413 // call the spawn function
1414 host_client->clientconnectcalled = true;
1415 prog->globals.server->time = sv.time;
1416 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1417 PRVM_ExecuteProgram (prog->globals.server->ClientConnect, "QC function ClientConnect is missing");
1419 if ((Sys_DoubleTime() - host_client->connecttime) <= sv.time)
1420 Con_Printf("%s entered the game\n", host_client->name);
1422 PRVM_ExecuteProgram (prog->globals.server->PutClientInServer, "QC function PutClientInServer is missing");
1425 if (!host_client->netconnection)
1428 // send time of update
1429 MSG_WriteByte (&host_client->netconnection->message, svc_time);
1430 MSG_WriteFloat (&host_client->netconnection->message, sv.time);
1432 // send all current names, colors, and frag counts
1433 for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
1435 if (!client->active)
1437 MSG_WriteByte (&host_client->netconnection->message, svc_updatename);
1438 MSG_WriteByte (&host_client->netconnection->message, i);
1439 MSG_WriteString (&host_client->netconnection->message, client->name);
1440 MSG_WriteByte (&host_client->netconnection->message, svc_updatefrags);
1441 MSG_WriteByte (&host_client->netconnection->message, i);
1442 MSG_WriteShort (&host_client->netconnection->message, client->frags);
1443 MSG_WriteByte (&host_client->netconnection->message, svc_updatecolors);
1444 MSG_WriteByte (&host_client->netconnection->message, i);
1445 MSG_WriteByte (&host_client->netconnection->message, client->colors);
1448 // send all current light styles
1449 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1451 if (sv.lightstyles[i][0])
1453 MSG_WriteByte (&host_client->netconnection->message, svc_lightstyle);
1454 MSG_WriteByte (&host_client->netconnection->message, (char)i);
1455 MSG_WriteString (&host_client->netconnection->message, sv.lightstyles[i]);
1460 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1461 MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALSECRETS);
1462 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->total_secrets);
1464 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1465 MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALMONSTERS);
1466 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->total_monsters);
1468 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1469 MSG_WriteByte (&host_client->netconnection->message, STAT_SECRETS);
1470 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->found_secrets);
1472 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1473 MSG_WriteByte (&host_client->netconnection->message, STAT_MONSTERS);
1474 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->killed_monsters);
1477 // Never send a roll angle, because savegames can catch the server
1478 // in a state where it is expecting the client to correct the angle
1479 // and it won't happen if the game was just loaded, so you wind up
1480 // with a permanent head tilt
1483 MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
1484 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[0], sv.protocol);
1485 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[1], sv.protocol);
1486 MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
1487 sv.loadgame = false; // we're basically done with loading now
1491 MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
1492 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[0], sv.protocol);
1493 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[1], sv.protocol);
1494 MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
1497 SV_WriteClientdataToMessage (host_client, host_client->edict, &host_client->netconnection->message, stats);
1499 MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
1500 MSG_WriteByte (&host_client->netconnection->message, 3);
1508 void Host_Begin_f (void)
1510 if (cmd_source == src_command)
1512 Con_Print("begin is not valid from the console\n");
1516 host_client->spawned = true;
1519 //===========================================================================
1526 Kicks a user off of the server
1529 void Host_Kick_f (void)
1532 const char *message = NULL;
1535 qboolean byNumber = false;
1537 if (cmd_source != src_command || !sv.active)
1543 if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1545 i = (int)(atof(Cmd_Argv(2)) - 1);
1546 if (i < 0 || i >= svs.maxclients || !(host_client = svs.clients + i)->active)
1552 for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
1554 if (!host_client->active)
1556 if (strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1561 if (i < svs.maxclients)
1563 if (cmd_source == src_command)
1565 if (cls.state == ca_dedicated)
1568 who = cl_name.string;
1573 // can't kick yourself!
1574 if (host_client == save)
1579 message = Cmd_Args();
1580 COM_ParseToken(&message, false);
1583 message++; // skip the #
1584 while (*message == ' ') // skip white space
1586 message += strlen(Cmd_Argv(2)); // skip the number
1588 while (*message && *message == ' ')
1592 SV_ClientPrintf("Kicked by %s: %s\n", who, message);
1594 SV_ClientPrintf("Kicked by %s\n", who);
1595 SV_DropClient (false); // kicked
1603 ===============================================================================
1607 ===============================================================================
1615 void Host_Give_f (void)
1621 if (cmd_source == src_command)
1623 Cmd_ForwardToServer ();
1629 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
1634 v = atoi (Cmd_Argv(2));
1648 // MED 01/04/97 added hipnotic give stuff
1649 if (gamemode == GAME_HIPNOTIC)
1654 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_PROXIMITY_GUN;
1656 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | IT_GRENADE_LAUNCHER;
1658 else if (t[0] == '9')
1659 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_LASER_CANNON;
1660 else if (t[0] == '0')
1661 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_MJOLNIR;
1662 else if (t[0] >= '2')
1663 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
1668 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
1673 if (gamemode == GAME_ROGUE && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_shells1)))
1676 host_client->edict->fields.server->ammo_shells = v;
1679 if (gamemode == GAME_ROGUE)
1681 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_nails1)))
1684 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1685 host_client->edict->fields.server->ammo_nails = v;
1690 host_client->edict->fields.server->ammo_nails = v;
1694 if (gamemode == GAME_ROGUE)
1696 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_lava_nails);
1700 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1701 host_client->edict->fields.server->ammo_nails = v;
1706 if (gamemode == GAME_ROGUE)
1708 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_rockets1);
1712 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1713 host_client->edict->fields.server->ammo_rockets = v;
1718 host_client->edict->fields.server->ammo_rockets = v;
1722 if (gamemode == GAME_ROGUE)
1724 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_multi_rockets);
1728 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1729 host_client->edict->fields.server->ammo_rockets = v;
1734 host_client->edict->fields.server->health = v;
1737 if (gamemode == GAME_ROGUE)
1739 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_cells1);
1743 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1744 host_client->edict->fields.server->ammo_cells = v;
1749 host_client->edict->fields.server->ammo_cells = v;
1753 if (gamemode == GAME_ROGUE)
1755 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_plasma);
1759 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1760 host_client->edict->fields.server->ammo_cells = v;
1767 prvm_edict_t *FindViewthing (void)
1772 for (i=0 ; i<prog->num_edicts ; i++)
1774 e = PRVM_EDICT_NUM(i);
1775 if (!strcmp (PRVM_GetString(e->fields.server->classname), "viewthing"))
1778 Con_Print("No viewthing on map\n");
1787 void Host_Viewmodel_f (void)
1796 e = FindViewthing ();
1801 m = Mod_ForName (Cmd_Argv(1), false, true, false);
1802 if (!m || !m->loaded || !m->Draw)
1804 Con_Printf("viewmodel: can't load %s\n", Cmd_Argv(1));
1808 e->fields.server->frame = 0;
1809 cl.model_precache[(int)e->fields.server->modelindex] = m;
1817 void Host_Viewframe_f (void)
1827 e = FindViewthing ();
1831 m = cl.model_precache[(int)e->fields.server->modelindex];
1833 f = atoi(Cmd_Argv(1));
1834 if (f >= m->numframes)
1837 e->fields.server->frame = f;
1841 void PrintFrameName (model_t *m, int frame)
1844 Con_Printf("frame %i: %s\n", frame, m->animscenes[frame].name);
1846 Con_Printf("frame %i\n", frame);
1854 void Host_Viewnext_f (void)
1863 e = FindViewthing ();
1867 m = cl.model_precache[(int)e->fields.server->modelindex];
1869 e->fields.server->frame = e->fields.server->frame + 1;
1870 if (e->fields.server->frame >= m->numframes)
1871 e->fields.server->frame = m->numframes - 1;
1873 PrintFrameName (m, (int)e->fields.server->frame);
1881 void Host_Viewprev_f (void)
1890 e = FindViewthing ();
1895 m = cl.model_precache[(int)e->fields.server->modelindex];
1897 e->fields.server->frame = e->fields.server->frame - 1;
1898 if (e->fields.server->frame < 0)
1899 e->fields.server->frame = 0;
1901 PrintFrameName (m, (int)e->fields.server->frame);
1905 ===============================================================================
1909 ===============================================================================
1918 void Host_Startdemos_f (void)
1922 if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-demolooponly"))
1928 Con_Printf("Max %i demos in demoloop\n", MAX_DEMOS);
1931 Con_Printf("%i demo(s) in loop\n", c);
1933 for (i=1 ; i<c+1 ; i++)
1934 strlcpy (cls.demos[i-1], Cmd_Argv(i), sizeof (cls.demos[i-1]));
1936 // LordHavoc: clear the remaining slots
1937 for (;i <= MAX_DEMOS;i++)
1938 cls.demos[i-1][0] = 0;
1940 if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1954 Return to looping demos
1957 void Host_Demos_f (void)
1959 if (cls.state == ca_dedicated)
1961 if (cls.demonum == -1)
1971 Return to looping demos
1974 void Host_Stopdemo_f (void)
1976 if (!cls.demoplayback)
1979 Host_ShutdownServer ();
1982 void Host_SendCvar_f (void)
1990 if(!(c = Cvar_FindVar(Cmd_Argv(1))))
1992 if (cls.state != ca_dedicated)
1993 Cmd_ForwardStringToServer(va("sentcvar %s %s\n", c->name, c->string));
1994 if(!sv.active)// || !SV_ParseClientCommandQC)
1998 if (cls.state != ca_dedicated)
2002 for(;i<svs.maxclients;i++)
2003 if(svs.clients[i].active && svs.clients[i].netconnection)
2005 host_client = &svs.clients[i];
2006 Host_ClientCommands(va("sendcvar %s\n", c->name));
2011 static void MaxPlayers_f(void)
2015 if (Cmd_Argc() != 2)
2017 Con_Printf("\"maxplayers\" is \"%u\"\n", svs.maxclients);
2023 Con_Print("maxplayers can not be changed while a server is running.\n");
2027 n = atoi(Cmd_Argv(1));
2028 n = bound(1, n, MAX_SCOREBOARD);
2029 Con_Printf("\"maxplayers\" set to \"%u\"\n", n);
2032 Mem_Free(svs.clients);
2034 svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
2036 Cvar_Set ("deathmatch", "0");
2038 Cvar_Set ("deathmatch", "1");
2041 //=============================================================================
2043 // QuakeWorld commands
2046 =====================
2049 Send the rest of the command line over as
2050 an unconnected command.
2051 =====================
2053 void Host_Rcon_f (void) // credit: taken from QuakeWorld
2057 lhnetsocket_t *mysocket;
2059 if (!rcon_password.string || !rcon_password.string[0])
2061 Con_Printf ("You must set rcon_password before issuing an rcon command.\n");
2065 for (i = 0;rcon_password.string[i];i++)
2067 if (rcon_password.string[i] <= ' ')
2069 Con_Printf("rcon_password is not allowed to have any whitespace.\n");
2075 to = cls.netcon->peeraddress;
2078 if (!rcon_address.integer || !rcon_address.string[0])
2080 Con_Printf ("You must either be connected, or set the rcon_address cvar to issue rcon commands\n");
2083 LHNETADDRESS_FromString(&to, rcon_address.string, sv_netport.integer);
2085 mysocket = NetConn_ChooseClientSocketForAddress(&to);
2088 // simply put together the rcon packet and send it
2089 NetConn_WriteString(mysocket, va("\377\377\377\377rcon %s %s", rcon_password.string, Cmd_Args()), &to);
2094 ====================
2097 user <name or userid>
2099 Dump userdata / masterdata for a user
2100 ====================
2102 void Host_User_f (void) // credit: taken from QuakeWorld
2107 if (Cmd_Argc() != 2)
2109 Con_Printf ("Usage: user <username / userid>\n");
2113 uid = atoi(Cmd_Argv(1));
2115 for (i = 0;i < cl.maxclients;i++)
2117 if (!cl.scores[i].name[0])
2119 if (cl.scores[i].qw_userid == uid || !strcasecmp(cl.scores[i].name, Cmd_Argv(1)))
2121 InfoString_Print(cl.scores[i].qw_userinfo);
2125 Con_Printf ("User not in server.\n");
2129 ====================
2132 Dump userids for all current players
2133 ====================
2135 void Host_Users_f (void) // credit: taken from QuakeWorld
2141 Con_Printf ("userid frags name\n");
2142 Con_Printf ("------ ----- ----\n");
2143 for (i = 0;i < cl.maxclients;i++)
2145 if (cl.scores[i].name[0])
2147 Con_Printf ("%6i %4i %s\n", cl.scores[i].qw_userid, cl.scores[i].frags, cl.scores[i].name);
2152 Con_Printf ("%i total users\n", c);
2157 Host_FullServerinfo_f
2159 Sent by server when serverinfo changes
2162 // TODO: shouldn't this be a cvar instead?
2163 void Host_FullServerinfo_f (void) // credit: taken from QuakeWorld
2166 if (Cmd_Argc() != 2)
2168 Con_Printf ("usage: fullserverinfo <complete info string>\n");
2172 strlcpy (cl.qw_serverinfo, Cmd_Argv(1), sizeof(cl.qw_serverinfo));
2173 InfoString_GetValue(cl.qw_serverinfo, "teamplay", temp, sizeof(temp));
2174 cl.qw_teamplay = atoi(temp);
2181 Allow clients to change userinfo
2185 void Host_FullInfo_f (void) // credit: taken from QuakeWorld
2192 if (Cmd_Argc() != 2)
2194 Con_Printf ("fullinfo <complete info string>\n");
2204 while (*s && *s != '\\')
2210 Con_Printf ("MISSING VALUE\n");
2216 while (*s && *s != '\\')
2223 CL_SetInfo(key, value, false, false, false, false);
2231 Allow clients to change userinfo
2234 void Host_SetInfo_f (void) // credit: taken from QuakeWorld
2236 if (Cmd_Argc() == 1)
2238 InfoString_Print(cls.userinfo);
2241 if (Cmd_Argc() != 3)
2243 Con_Printf ("usage: setinfo [ <key> <value> ]\n");
2246 CL_SetInfo(Cmd_Argv(1), Cmd_Argv(2), true, false, false, false);
2250 ====================
2253 packet <destination> <contents>
2255 Contents allows \n escape character
2256 ====================
2258 void Host_Packet_f (void) // credit: taken from QuakeWorld
2264 lhnetaddress_t address;
2265 lhnetsocket_t *mysocket;
2267 if (Cmd_Argc() != 3)
2269 Con_Printf ("packet <destination> <contents>\n");
2273 if (!LHNETADDRESS_FromString (&address, Cmd_Argv(1), sv_netport.integer))
2275 Con_Printf ("Bad address\n");
2281 send[0] = send[1] = send[2] = send[3] = 0xff;
2283 l = (int)strlen (in);
2284 for (i=0 ; i<l ; i++)
2286 if (out >= send + sizeof(send) - 1)
2288 if (in[i] == '\\' && in[i+1] == 'n')
2293 else if (in[i] == '\\' && in[i+1] == '0')
2298 else if (in[i] == '\\' && in[i+1] == 't')
2303 else if (in[i] == '\\' && in[i+1] == 'r')
2308 else if (in[i] == '\\' && in[i+1] == '"')
2317 mysocket = NetConn_ChooseClientSocketForAddress(&address);
2319 NetConn_Write(mysocket, send, out - send, &address);
2322 //=============================================================================
2329 void Host_InitCommands (void)
2331 dpsnprintf(cls.userinfo, sizeof(cls.userinfo), "\\name\\player\\team\\none\\topcolor\\0\\bottomcolor\\0\\rate\\10000\\msg\\1\\noaim\\1\\*ver\\%s", engineversion);
2333 Cmd_AddCommand ("status", Host_Status_f, "print server status information");
2334 Cmd_AddCommand ("quit", Host_Quit_f, "quit the game");
2335 if (gamemode == GAME_NEHAHRA)
2337 Cmd_AddCommand ("max", Host_God_f, "god mode (invulnerability)");
2338 Cmd_AddCommand ("monster", Host_Notarget_f, "notarget mode (monsters do not see you)");
2339 Cmd_AddCommand ("scrag", Host_Fly_f, "fly mode (flight)");
2340 Cmd_AddCommand ("wraith", Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
2341 Cmd_AddCommand ("gimme", Host_Give_f, "alter inventory");
2345 Cmd_AddCommand ("god", Host_God_f, "god mode (invulnerability)");
2346 Cmd_AddCommand ("notarget", Host_Notarget_f, "notarget mode (monsters do not see you)");
2347 Cmd_AddCommand ("fly", Host_Fly_f, "fly mode (flight)");
2348 Cmd_AddCommand ("noclip", Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
2349 Cmd_AddCommand ("give", Host_Give_f, "alter inventory");
2351 Cmd_AddCommand ("map", Host_Map_f, "kick everyone off the server and start a new level");
2352 Cmd_AddCommand ("restart", Host_Restart_f, "restart current level");
2353 Cmd_AddCommand ("changelevel", Host_Changelevel_f, "change to another level, bringing along all connected clients");
2354 Cmd_AddCommand ("connect", Host_Connect_f, "connect to a server by IP address or hostname");
2355 Cmd_AddCommand ("reconnect", Host_Reconnect_f, "reset signon level in preparation for a new level (do not use)");
2356 Cmd_AddCommand ("version", Host_Version_f, "print engine version");
2357 Cmd_AddCommand ("say", Host_Say_f, "send a chat message to everyone on the server");
2358 Cmd_AddCommand ("say_team", Host_Say_Team_f, "send a chat message to your team on the server");
2359 Cmd_AddCommand ("tell", Host_Tell_f, "send a chat message to only one person on the server");
2360 Cmd_AddCommand ("kill", Host_Kill_f, "die instantly");
2361 Cmd_AddCommand ("pause", Host_Pause_f, "pause the game (if the server allows pausing)");
2362 Cmd_AddCommand ("kick", Host_Kick_f, "kick a player off the server by number or name");
2363 Cmd_AddCommand ("ping", Host_Ping_f, "print ping times of all players on the server");
2364 Cmd_AddCommand ("load", Host_Loadgame_f, "load a saved game file");
2365 Cmd_AddCommand ("save", Host_Savegame_f, "save the game to a file");
2367 Cmd_AddCommand ("startdemos", Host_Startdemos_f, "start playing back the selected demos sequentially (used at end of startup script)");
2368 Cmd_AddCommand ("demos", Host_Demos_f, "restart looping demos defined by the last startdemos command");
2369 Cmd_AddCommand ("stopdemo", Host_Stopdemo_f, "stop playing or recording demo (like stop command) and return to looping demos");
2371 Cmd_AddCommand ("viewmodel", Host_Viewmodel_f, "change model of viewthing entity in current level");
2372 Cmd_AddCommand ("viewframe", Host_Viewframe_f, "change animation frame of viewthing entity in current level");
2373 Cmd_AddCommand ("viewnext", Host_Viewnext_f, "change to next animation frame of viewthing entity in current level");
2374 Cmd_AddCommand ("viewprev", Host_Viewprev_f, "change to previous animation frame of viewthing entity in current level");
2376 Cvar_RegisterVariable (&cl_name);
2377 Cmd_AddCommand ("name", Host_Name_f, "change your player name");
2378 Cvar_RegisterVariable (&cl_color);
2379 Cmd_AddCommand ("color", Host_Color_f, "change your player shirt and pants colors");
2380 Cvar_RegisterVariable (&cl_rate);
2381 Cmd_AddCommand ("rate", Host_Rate_f, "change your network connection speed");
2382 if (gamemode == GAME_NEHAHRA)
2384 Cvar_RegisterVariable (&cl_pmodel);
2385 Cmd_AddCommand ("pmodel", Host_PModel_f, "change your player model choice (Nehahra specific)");
2388 // BLACK: This isnt game specific anymore (it was GAME_NEXUIZ at first)
2389 Cvar_RegisterVariable (&cl_playermodel);
2390 Cmd_AddCommand ("playermodel", Host_Playermodel_f, "change your player model");
2391 Cvar_RegisterVariable (&cl_playerskin);
2392 Cmd_AddCommand ("playerskin", Host_Playerskin_f, "change your player skin number");
2394 Cmd_AddCommand ("prespawn", Host_PreSpawn_f, "signon 1 (client acknowledges that server information has been received)");
2395 Cmd_AddCommand ("spawn", Host_Spawn_f, "signon 2 (client has sent player information, and is asking server to send scoreboard rankings)");
2396 Cmd_AddCommand ("begin", 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)");
2397 Cmd_AddCommand ("maxplayers", MaxPlayers_f, "sets limit on how many players (or bots) may be connected to the server at once");
2399 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]
2401 Cvar_RegisterVariable (&rcon_password);
2402 Cvar_RegisterVariable (&rcon_address);
2403 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)");
2404 Cmd_AddCommand ("user", Host_User_f, "prints additional information about a player number or name on the scoreboard");
2405 Cmd_AddCommand ("users", Host_Users_f, "prints additional information about all players on the scoreboard");
2406 Cmd_AddCommand ("fullserverinfo", Host_FullServerinfo_f, "internal use only, sent by server to client to update client's local copy of serverinfo string");
2407 Cmd_AddCommand ("fullinfo", Host_FullInfo_f, "allows client to modify their userinfo");
2408 Cmd_AddCommand ("setinfo", Host_SetInfo_f, "modifies your userinfo");
2409 Cmd_AddCommand ("packet", Host_Packet_f, "send a packet to the specified address:port containing a text string");
2410 Cmd_AddCommand ("topcolor", Host_TopColor_f, "QW command to set top color without changing bottom color");
2411 Cmd_AddCommand ("bottomcolor", Host_BottomColor_f, "QW command to set bottom color without changing top color");
2413 Cvar_RegisterVariable (&team);
2414 Cvar_RegisterVariable (&skin);
2415 Cvar_RegisterVariable (&noaim);
2417 Cvar_RegisterVariable(&sv_cheats);