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.
25 cvar_t sv_cheats = {0, "sv_cheats", "0", "enables cheat commands in any game, and cheat impulses in dpmod"};
26 cvar_t rcon_password = {0, "rcon_password", "", "password to authenticate rcon commands"};
27 cvar_t rcon_address = {0, "rcon_address", "", "server address to send rcon commands to (when not connected to a server)"};
28 cvar_t team = {CVAR_USERINFO | CVAR_SAVE, "team", "none", "QW team (4 character limit, example: blue)"};
29 cvar_t skin = {CVAR_USERINFO | CVAR_SAVE, "skin", "", "QW player skin name (example: base)"};
30 cvar_t noaim = {CVAR_USERINFO | CVAR_SAVE, "noaim", "1", "QW option to disable vertical autoaim"};
31 qboolean allowcheats = false;
39 void Host_Quit_f (void)
50 void Host_Status_f (void)
53 int seconds, minutes, hours = 0, j, players;
54 void (*print) (const char *fmt, ...);
56 if (cmd_source == src_command)
60 Cmd_ForwardToServer ();
66 print = SV_ClientPrintf;
68 for (players = 0, j = 0;j < svs.maxclients;j++)
69 if (svs.clients[j].active)
71 print ("host: %s\n", Cvar_VariableString ("hostname"));
72 print ("version: %s build %s\n", gamename, buildstring);
73 print ("protocol: %i (%s)\n", Protocol_NumberForEnum(sv.protocol), Protocol_NameForEnum(sv.protocol));
74 print ("map: %s\n", sv.name);
75 print ("players: %i active (%i max)\n\n", players, svs.maxclients);
76 for (j = 0, client = svs.clients;j < svs.maxclients;j++, client++)
80 seconds = (int)(realtime - client->connecttime);
81 minutes = seconds / 60;
84 seconds -= (minutes * 60);
87 minutes -= (hours * 60);
91 print ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->fields.server->frags, hours, minutes, seconds);
92 print (" %s\n", client->netconnection ? client->netconnection->address : "botclient");
101 Sets client to godmode
104 void Host_God_f (void)
106 if (cmd_source == src_command)
108 Cmd_ForwardToServer ();
114 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
118 host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags ^ FL_GODMODE;
119 if (!((int)host_client->edict->fields.server->flags & FL_GODMODE) )
120 SV_ClientPrint("godmode OFF\n");
122 SV_ClientPrint("godmode ON\n");
125 void Host_Notarget_f (void)
127 if (cmd_source == src_command)
129 Cmd_ForwardToServer ();
135 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
139 host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags ^ FL_NOTARGET;
140 if (!((int)host_client->edict->fields.server->flags & FL_NOTARGET) )
141 SV_ClientPrint("notarget OFF\n");
143 SV_ClientPrint("notarget ON\n");
146 qboolean noclip_anglehack;
148 void Host_Noclip_f (void)
150 if (cmd_source == src_command)
152 Cmd_ForwardToServer ();
158 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
162 if (host_client->edict->fields.server->movetype != MOVETYPE_NOCLIP)
164 noclip_anglehack = true;
165 host_client->edict->fields.server->movetype = MOVETYPE_NOCLIP;
166 SV_ClientPrint("noclip ON\n");
170 noclip_anglehack = false;
171 host_client->edict->fields.server->movetype = MOVETYPE_WALK;
172 SV_ClientPrint("noclip OFF\n");
180 Sets client to flymode
183 void Host_Fly_f (void)
185 if (cmd_source == src_command)
187 Cmd_ForwardToServer ();
193 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
197 if (host_client->edict->fields.server->movetype != MOVETYPE_FLY)
199 host_client->edict->fields.server->movetype = MOVETYPE_FLY;
200 SV_ClientPrint("flymode ON\n");
204 host_client->edict->fields.server->movetype = MOVETYPE_WALK;
205 SV_ClientPrint("flymode OFF\n");
216 void Host_Ping_f (void)
220 void (*print) (const char *fmt, ...);
222 if (cmd_source == src_command)
226 Cmd_ForwardToServer ();
232 print = SV_ClientPrintf;
234 print("Client ping times:\n");
235 for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
239 print("%4i %s\n", (int)floor(client->ping*1000+0.5), client->name);
244 ===============================================================================
248 ===============================================================================
252 ======================
257 command from the console. Active clients are kicked off.
258 ======================
260 void Host_Map_f (void)
262 char level[MAX_QPATH];
266 Con_Print("map <levelname> : start a new game (kicks off all players)\n");
270 if (cmd_source != src_command)
273 cls.demonum = -1; // stop demo loop in case this fails
276 Host_ShutdownServer();
281 svs.serverflags = 0; // haven't completed an episode yet
282 allowcheats = sv_cheats.integer != 0;
283 strcpy(level, Cmd_Argv(1));
284 SV_SpawnServer(level);
285 if (sv.active && cls.state == ca_disconnected)
286 CL_EstablishConnection("local:1");
288 // if cl_autodemo is set, automatically start recording a demo if one isn't being recorded already
289 if (cl_autodemo.integer && !cls.demorecording)
291 char demofile[MAX_OSPATH];
293 dpsnprintf (demofile, sizeof(demofile), "%s_%s.dem", Sys_TimeString (cl_autodemo_nameformat.string), level);
295 Con_Printf ("Recording to %s.\n", demofile);
297 cls.demofile = FS_Open (demofile, "wb", false, false);
301 FS_Printf (cls.demofile, "%i\n", cls.forcetrack);
304 Con_Print ("ERROR: couldn't open.\n");
306 cls.demorecording = true;
314 Goes to a new map, taking all clients along
317 void Host_Changelevel_f (void)
319 char level[MAX_QPATH];
323 Con_Print("changelevel <levelname> : continue game on a new level\n");
331 if (cmd_source != src_command)
338 SV_SaveSpawnparms ();
340 allowcheats = sv_cheats.integer != 0;
341 strcpy(level, Cmd_Argv(1));
342 SV_SpawnServer(level);
343 if (sv.active && cls.state == ca_disconnected)
344 CL_EstablishConnection("local:1");
351 Restarts the current server for a dead player
354 void Host_Restart_f (void)
356 char mapname[MAX_QPATH];
360 Con_Print("restart : restart current level\n");
365 Con_Print("Only the server may restart\n");
368 if (cmd_source != src_command)
374 allowcheats = sv_cheats.integer != 0;
375 strcpy(mapname, sv.name);
376 SV_SpawnServer(mapname);
377 if (sv.active && cls.state == ca_disconnected)
378 CL_EstablishConnection("local:1");
385 This command causes the client to wait for the signon messages again.
386 This is sent just before a server changes levels
389 void Host_Reconnect_f (void)
391 if (cls.protocol == PROTOCOL_QUAKEWORLD)
393 if (cls.qw_downloadmemory) // don't change when downloading
400 if (cls.state == ca_connected && cls.signon < SIGNONS)
402 Con_Printf("reconnecting...\n");
403 MSG_WriteChar(&cls.netcon->message, qw_clc_stringcmd);
404 MSG_WriteString(&cls.netcon->message, "new");
409 // if we have connected to a server recently, the userinfo
410 // will still contain its IP address, so get the address...
411 InfoString_GetValue(cls.userinfo, "*ip", temp, sizeof(temp));
413 CL_EstablishConnection(temp);
415 Con_Printf("Reconnect to what server? (you have not connected to a server yet)\n");
423 Con_Print("reconnect : wait for signon messages again\n");
428 Con_Print("reconnect: no signon, ignoring reconnect\n");
431 cls.signon = 0; // need new connection messages
436 =====================
439 User command to connect to server
440 =====================
442 void Host_Connect_f (void)
446 Con_Print("connect <serveraddress> : connect to a multiplayer game\n");
449 CL_EstablishConnection(Cmd_Argv(1));
454 ===============================================================================
458 ===============================================================================
461 #define SAVEGAME_VERSION 5
467 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
470 void Host_SavegameComment (char *text)
475 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
477 // LordHavoc: added min() to prevent overflow
478 memcpy (text, cl.levelname, min(strlen(cl.levelname), SAVEGAME_COMMENT_LENGTH));
479 sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
480 memcpy (text+22, kills, strlen(kills));
481 // convert space to _ to make stdio happy
482 // LordHavoc: convert control characters to _ as well
483 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
486 text[SAVEGAME_COMMENT_LENGTH] = '\0';
495 void Host_Savegame_f (void)
497 char name[MAX_QPATH];
500 char comment[SAVEGAME_COMMENT_LENGTH+1];
502 if (cmd_source != src_command)
505 if (cls.state != ca_connected || !sv.active)
507 Con_Print("Not playing a local game.\n");
513 Con_Print("Can't save in intermission.\n");
517 for (i = 0;i < svs.maxclients;i++)
519 if (svs.clients[i].active)
523 Con_Print("Can't save multiplayer games.\n");
526 if (svs.clients[i].edict->fields.server->deadflag)
528 Con_Print("Can't savegame with a dead player\n");
536 Con_Print("save <savename> : save a game\n");
540 if (strstr(Cmd_Argv(1), ".."))
542 Con_Print("Relative pathnames are not allowed.\n");
546 strlcpy (name, Cmd_Argv(1), sizeof (name));
547 FS_DefaultExtension (name, ".sav", sizeof (name));
549 Con_Printf("Saving game to %s...\n", name);
550 f = FS_Open (name, "wb", false, false);
553 Con_Print("ERROR: couldn't open.\n");
557 FS_Printf(f, "%i\n", SAVEGAME_VERSION);
558 Host_SavegameComment (comment);
559 FS_Printf(f, "%s\n", comment);
560 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
561 FS_Printf(f, "%f\n", svs.clients[0].spawn_parms[i]);
562 FS_Printf(f, "%d\n", current_skill);
563 FS_Printf(f, "%s\n", sv.name);
564 FS_Printf(f, "%f\n",sv.time);
566 // write the light styles
567 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
569 if (sv.lightstyles[i][0])
570 FS_Printf(f, "%s\n", sv.lightstyles[i]);
577 PRVM_ED_WriteGlobals (f);
578 for (i=0 ; i<prog->num_edicts ; i++)
579 PRVM_ED_Write (f, PRVM_EDICT_NUM(i));
584 Con_Print("done.\n");
593 void Host_Loadgame_f (void)
595 char filename[MAX_QPATH];
596 char mapname[MAX_QPATH];
606 float spawn_parms[NUM_SPAWN_PARMS];
608 if (cmd_source != src_command)
613 Con_Print("load <savename> : load a game\n");
617 strcpy (filename, Cmd_Argv(1));
618 FS_DefaultExtension (filename, ".sav", sizeof (filename));
620 Con_Printf("Loading game from %s...\n", filename);
622 cls.demonum = -1; // stop demo loop in case this fails
624 t = text = (char *)FS_LoadFile (filename, tempmempool, false, NULL);
627 Con_Print("ERROR: couldn't open.\n");
632 COM_ParseToken(&t, false);
633 version = atoi(com_token);
634 if (version != SAVEGAME_VERSION)
637 Con_Printf("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
642 // this is a little hard to parse, as : is a separator in COM_ParseToken,
643 // so use the console parser instead
644 COM_ParseTokenConsole(&t);
646 for (i = 0;i < NUM_SPAWN_PARMS;i++)
648 COM_ParseToken(&t, false);
649 spawn_parms[i] = atof(com_token);
652 COM_ParseToken(&t, false);
653 // this silliness is so we can load 1.06 save files, which have float skill values
654 current_skill = (int)(atof(com_token) + 0.5);
655 Cvar_SetValue ("skill", (float)current_skill);
658 COM_ParseToken(&t, false);
659 strcpy (mapname, com_token);
662 COM_ParseToken(&t, false);
663 time = atof(com_token);
665 allowcheats = sv_cheats.integer != 0;
667 SV_SpawnServer (mapname);
671 Con_Print("Couldn't load map\n");
674 sv.paused = true; // pause until all clients connect
677 // load the light styles
679 for (i = 0;i < MAX_LIGHTSTYLES;i++)
683 COM_ParseToken(&t, false);
684 // if this is a 64 lightstyle savegame produced by Quake, stop now
685 // we have to check this because darkplaces saves 256 lightstyle savegames
686 if (com_token[0] == '{')
691 strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i]));
694 // now skip everything before the first opening brace
695 // (this is for forward compatibility, so that older versions (at
696 // least ones with this fix) can load savegames with extra data before the
697 // first brace, as might be produced by a later engine version)
701 COM_ParseToken(&t, false);
702 if (com_token[0] == '{')
709 // load the edicts out of the savegame file
716 while (COM_ParseToken(&t, false))
717 if (!strcmp(com_token, "}"))
719 if (!COM_ParseToken(&start, false))
724 if (strcmp(com_token,"{"))
727 Host_Error ("First token isn't a brace");
732 // parse the global vars
733 PRVM_ED_ParseGlobals (start);
738 if (entnum >= MAX_EDICTS)
741 Host_Error("Host_PerformLoadGame: too many edicts in save file (reached MAX_EDICTS %i)", MAX_EDICTS);
743 while (entnum >= prog->max_edicts)
744 //SV_IncreaseEdicts();
745 PRVM_MEM_IncreaseEdicts();
746 ent = PRVM_EDICT_NUM(entnum);
747 memset (ent->fields.server, 0, prog->progs->entityfields * 4);
748 ent->priv.server->free = false;
749 PRVM_ED_ParseEdict (start, ent);
751 // link it into the bsp tree
752 if (!ent->priv.server->free)
753 SV_LinkEdict (ent, false);
760 prog->num_edicts = entnum;
763 for (i = 0;i < NUM_SPAWN_PARMS;i++)
764 svs.clients[0].spawn_parms[i] = spawn_parms[i];
768 // make sure we're connected to loopback
769 if (cls.state == ca_disconnected || !(cls.state == ca_connected && cls.netcon != NULL && LHNETADDRESS_GetAddressType(&cls.netcon->peeraddress) == LHNETADDRESSTYPE_LOOP))
770 CL_EstablishConnection("local:1");
773 //============================================================================
776 ======================
778 ======================
780 cvar_t cl_name = {CVAR_SAVE, "_cl_name", "player", "internal storage cvar for current player name (changed by name command)"};
781 void Host_Name_f (void)
784 char newName[sizeof(host_client->name)];
786 if (Cmd_Argc () == 1)
788 Con_Printf("\"name\" is \"%s\"\n", cl_name.string);
792 if (Cmd_Argc () == 2)
793 strlcpy (newName, Cmd_Argv(1), sizeof (newName));
795 strlcpy (newName, Cmd_Args(), sizeof (newName));
797 for (i = 0, j = 0;newName[i];i++)
798 if (newName[i] != '\r' && newName[i] != '\n')
799 newName[j++] = newName[i];
802 if (cmd_source == src_command)
804 Cvar_Set ("_cl_name", newName);
805 CL_SetInfo("name", newName, true, false, false, false);
809 if (sv.time < host_client->nametime)
811 SV_ClientPrintf("You can't change name more than once every 5 seconds!\n");
815 host_client->nametime = sv.time + 5;
817 // point the string back at updateclient->name to keep it safe
818 strlcpy (host_client->name, newName, sizeof (host_client->name));
819 host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name);
820 if (strcmp(host_client->old_name, host_client->name))
822 if (host_client->spawned)
823 SV_BroadcastPrintf("%s changed name to %s\n", host_client->old_name, host_client->name);
824 strcpy(host_client->old_name, host_client->name);
825 // send notification to all clients
826 MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
827 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
828 MSG_WriteString (&sv.reliable_datagram, host_client->name);
833 ======================
835 ======================
837 cvar_t cl_playermodel = {CVAR_SAVE, "_cl_playermodel", "", "internal storage cvar for current player model in Nexuiz (changed by playermodel command)"};
838 // the old cl_playermodel in cl_main has been renamed to __cl_playermodel
839 void Host_Playermodel_f (void)
842 char newPath[sizeof(host_client->playermodel)];
844 if (Cmd_Argc () == 1)
846 Con_Printf("\"playermodel\" is \"%s\"\n", cl_playermodel.string);
850 if (Cmd_Argc () == 2)
851 strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
853 strlcpy (newPath, Cmd_Args(), sizeof (newPath));
855 for (i = 0, j = 0;newPath[i];i++)
856 if (newPath[i] != '\r' && newPath[i] != '\n')
857 newPath[j++] = newPath[i];
860 if (cmd_source == src_command)
862 Cvar_Set ("_cl_playermodel", newPath);
863 CL_SetInfo("playermodel", newPath, true, false, false, false);
868 if (sv.time < host_client->nametime)
870 SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
874 host_client->nametime = sv.time + 5;
877 // point the string back at updateclient->name to keep it safe
878 strlcpy (host_client->playermodel, newPath, sizeof (host_client->playermodel));
879 if( eval_playermodel )
880 PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PRVM_SetEngineString(host_client->playermodel);
881 if (strcmp(host_client->old_model, host_client->playermodel))
883 strcpy(host_client->old_model, host_client->playermodel);
884 /*// send notification to all clients
885 MSG_WriteByte (&sv.reliable_datagram, svc_updatepmodel);
886 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
887 MSG_WriteString (&sv.reliable_datagram, host_client->playermodel);*/
892 ======================
894 ======================
896 cvar_t cl_playerskin = {CVAR_SAVE, "_cl_playerskin", "", "internal storage cvar for current player skin in Nexuiz (changed by playerskin command)"};
897 void Host_Playerskin_f (void)
900 char newPath[sizeof(host_client->playerskin)];
902 if (Cmd_Argc () == 1)
904 Con_Printf("\"playerskin\" is \"%s\"\n", cl_playerskin.string);
908 if (Cmd_Argc () == 2)
909 strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
911 strlcpy (newPath, Cmd_Args(), sizeof (newPath));
913 for (i = 0, j = 0;newPath[i];i++)
914 if (newPath[i] != '\r' && newPath[i] != '\n')
915 newPath[j++] = newPath[i];
918 if (cmd_source == src_command)
920 Cvar_Set ("_cl_playerskin", newPath);
921 CL_SetInfo("playermodel", newPath, true, false, false, false);
926 if (sv.time < host_client->nametime)
928 SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
932 host_client->nametime = sv.time + 5;
935 // point the string back at updateclient->name to keep it safe
936 strlcpy (host_client->playerskin, newPath, sizeof (host_client->playerskin));
937 if( eval_playerskin )
938 PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string = PRVM_SetEngineString(host_client->playerskin);
939 if (strcmp(host_client->old_skin, host_client->playerskin))
941 if (host_client->spawned)
942 SV_BroadcastPrintf("%s changed skin to %s\n", host_client->name, host_client->playerskin);
943 strcpy(host_client->old_skin, host_client->playerskin);
944 /*// send notification to all clients
945 MSG_WriteByte (&sv.reliable_datagram, svc_updatepskin);
946 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
947 MSG_WriteString (&sv.reliable_datagram, host_client->playerskin);*/
951 void Host_Version_f (void)
953 Con_Printf("Version: %s build %s\n", gamename, buildstring);
956 void Host_Say(qboolean teamonly)
962 // LordHavoc: long say messages
964 qboolean fromServer = false;
966 if (cmd_source == src_command)
968 if (cls.state == ca_dedicated)
975 Cmd_ForwardToServer ();
983 if (!teamplay.integer)
993 // note this uses the chat prefix \001
995 dpsnprintf (text, sizeof(text), "\001%s" STRING_COLOR_DEFAULT_STR ": %s", host_client->name, p1);
997 dpsnprintf (text, sizeof(text), "\001<%s" STRING_COLOR_DEFAULT_STR "> %s", hostname.string, p1);
998 p2 = text + strlen(text);
999 while ((const char *)p2 > (const char *)text && (p2[-1] == '\r' || p2[-1] == '\n' || (p2[-1] == '\"' && quoted)))
1001 if (p2[-1] == '\"' && quoted)
1006 strlcat(text, "\n", sizeof(text));
1008 // note: save is not a valid edict if fromServer is true
1010 for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
1011 if (host_client->spawned && (!teamonly || host_client->edict->fields.server->team == save->edict->fields.server->team))
1012 SV_ClientPrint(text);
1015 if (cls.state == ca_dedicated)
1016 Con_Print(&text[1]);
1020 void Host_Say_f(void)
1026 void Host_Say_Team_f(void)
1032 void Host_Tell_f(void)
1036 const char *p1, *p2;
1037 char text[MAX_INPUTLINE]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
1038 qboolean fromServer = false;
1040 if (cmd_source == src_command)
1042 if (cls.state == ca_dedicated)
1046 Cmd_ForwardToServer ();
1051 if (Cmd_Argc () < 3)
1054 // note this uses the chat prefix \001
1056 sprintf (text, "\001%s tells you: ", host_client->name);
1058 sprintf (text, "\001<%s tells you> ", hostname.string);
1061 p2 = p1 + strlen(p1);
1062 // remove the target name
1063 while (p1 < p2 && *p1 != ' ')
1065 while (p1 < p2 && *p1 == ' ')
1067 // remove trailing newlines
1068 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
1070 // remove quotes if present
1076 else if (fromServer)
1077 Con_Print("Host_Tell: missing end quote\n");
1079 SV_ClientPrint("Host_Tell: missing end quote\n");
1081 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
1083 for (j = (int)strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;)
1089 for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
1090 if (host_client->spawned && !strcasecmp(host_client->name, Cmd_Argv(1)))
1091 SV_ClientPrint(text);
1101 cvar_t cl_color = {CVAR_SAVE, "_cl_color", "0", "internal storage cvar for current player colors (changed by color command)"};
1102 void Host_Color(int changetop, int changebottom)
1104 int top, bottom, playercolor;
1106 func_t SV_ChangeTeam;
1108 // get top and bottom either from the provided values or the current values
1109 // (allows changing only top or bottom, or both at once)
1110 top = changetop >= 0 ? changetop : (cl_color.integer >> 4);
1111 bottom = changebottom >= 0 ? changebottom : cl_color.integer;
1115 // LordHavoc: allowing skin colormaps 14 and 15 by commenting this out
1121 playercolor = top*16 + bottom;
1123 if (cmd_source == src_command)
1125 Cvar_SetValueQuick(&cl_color, playercolor);
1127 CL_SetInfo("topcolor", va("%i", top), true, false, false, false);
1128 if (changebottom >= 0)
1129 CL_SetInfo("bottomcolor", va("%i", bottom), true, false, false, false);
1130 if (cls.protocol != PROTOCOL_QUAKEWORLD && cls.netcon)
1132 MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
1133 MSG_WriteString(&cls.netcon->message, va("color %i %i", top, bottom));
1138 if (cls.protocol == PROTOCOL_QUAKEWORLD)
1141 if (host_client->edict && (f = PRVM_ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - prog->functions)))
1143 Con_DPrint("Calling SV_ChangeTeam\n");
1144 prog->globals.server->time = sv.time;
1145 prog->globals.generic[OFS_PARM0] = playercolor;
1146 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1147 PRVM_ExecuteProgram (SV_ChangeTeam, "QC function SV_ChangeTeam is missing");
1152 if (host_client->edict)
1154 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_clientcolors)))
1155 val->_float = playercolor;
1156 host_client->edict->fields.server->team = bottom + 1;
1158 host_client->colors = playercolor;
1159 if (host_client->old_colors != host_client->colors)
1161 host_client->old_colors = host_client->colors;
1162 // send notification to all clients
1163 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
1164 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
1165 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
1170 void Host_Color_f(void)
1174 if (Cmd_Argc() == 1)
1176 Con_Printf("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15);
1177 Con_Print("color <0-15> [0-15]\n");
1181 if (Cmd_Argc() == 2)
1182 top = bottom = atoi(Cmd_Argv(1));
1185 top = atoi(Cmd_Argv(1));
1186 bottom = atoi(Cmd_Argv(2));
1188 Host_Color(top, bottom);
1191 void Host_TopColor_f(void)
1193 if (Cmd_Argc() == 1)
1195 Con_Printf("\"topcolor\" is \"%i\"\n", (cl_color.integer >> 4) & 15);
1196 Con_Print("topcolor <0-15>\n");
1200 Host_Color(atoi(Cmd_Argv(1)), -1);
1203 void Host_BottomColor_f(void)
1205 if (Cmd_Argc() == 1)
1207 Con_Printf("\"bottomcolor\" is \"%i\"\n", cl_color.integer & 15);
1208 Con_Print("bottomcolor <0-15>\n");
1212 Host_Color(-1, atoi(Cmd_Argv(1)));
1215 cvar_t cl_rate = {CVAR_SAVE, "_cl_rate", "10000", "internal storage cvar for current rate (changed by rate command)"};
1216 void Host_Rate_f(void)
1220 if (Cmd_Argc() != 2)
1222 Con_Printf("\"rate\" is \"%i\"\n", cl_rate.integer);
1223 Con_Print("rate <500-25000>\n");
1227 rate = atoi(Cmd_Argv(1));
1229 if (cmd_source == src_command)
1231 Cvar_SetValue ("_cl_rate", bound(NET_MINRATE, rate, NET_MAXRATE));
1232 CL_SetInfo("rate", va("%i", rate), true, false, false, false);
1236 host_client->rate = rate;
1244 void Host_Kill_f (void)
1246 if (cmd_source == src_command)
1248 Cmd_ForwardToServer ();
1252 if (host_client->edict->fields.server->health <= 0)
1254 SV_ClientPrint("Can't suicide -- already dead!\n");
1258 prog->globals.server->time = sv.time;
1259 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1260 PRVM_ExecuteProgram (prog->globals.server->ClientKill, "QC function ClientKill is missing");
1269 void Host_Pause_f (void)
1272 if (cmd_source == src_command)
1274 Cmd_ForwardToServer ();
1277 if (!pausable.integer)
1278 SV_ClientPrint("Pause not allowed.\n");
1282 SV_BroadcastPrintf("%s %spaused the game\n", host_client->name, sv.paused ? "" : "un");
1283 // send notification to all clients
1284 MSG_WriteByte(&sv.reliable_datagram, svc_setpause);
1285 MSG_WriteByte(&sv.reliable_datagram, sv.paused);
1290 ======================
1292 LordHavoc: only supported for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
1293 LordHavoc: correction, Mindcrime will be removing pmodel in the future, but it's still stuck here for compatibility.
1294 ======================
1296 cvar_t cl_pmodel = {CVAR_SAVE, "_cl_pmodel", "0", "internal storage cvar for current player model number in nehahra (changed by pmodel command)"};
1297 static void Host_PModel_f (void)
1302 if (Cmd_Argc () == 1)
1304 Con_Printf("\"pmodel\" is \"%s\"\n", cl_pmodel.string);
1307 i = atoi(Cmd_Argv(1));
1309 if (cmd_source == src_command)
1311 if (cl_pmodel.integer == i)
1313 Cvar_SetValue ("_cl_pmodel", i);
1314 if (cls.state == ca_connected)
1315 Cmd_ForwardToServer ();
1319 if (host_client->edict && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1323 //===========================================================================
1331 void Host_PreSpawn_f (void)
1333 if (cmd_source == src_command)
1335 Con_Print("prespawn is not valid from the console\n");
1339 if (host_client->spawned)
1341 Con_Print("prespawn not valid -- already spawned\n");
1345 if (host_client->netconnection)
1347 SZ_Write (&host_client->netconnection->message, sv.signon.data, sv.signon.cursize);
1348 MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
1349 MSG_WriteByte (&host_client->netconnection->message, 2);
1352 // reset the name change timer because the client will send name soon
1353 host_client->nametime = 0;
1361 void Host_Spawn_f (void)
1367 int stats[MAX_CL_STATS];
1369 if (cmd_source == src_command)
1371 Con_Print("spawn is not valid from the console\n");
1375 if (host_client->spawned)
1377 Con_Print("Spawn not valid -- already spawned\n");
1381 // reset name change timer again because they might want to change name
1382 // again in the first 5 seconds after connecting
1383 host_client->nametime = 0;
1385 // LordHavoc: moved this above the QC calls at FrikaC's request
1386 // LordHavoc: commented this out
1387 //if (host_client->netconnection)
1388 // SZ_Clear (&host_client->netconnection->message);
1390 // run the entrance script
1393 // loaded games are fully initialized already
1394 // if this is the last client to be connected, unpause
1397 if ((f = PRVM_ED_FindFunction ("RestoreGame")))
1398 if ((RestoreGame = (func_t)(f - prog->functions)))
1400 Con_DPrint("Calling RestoreGame\n");
1401 prog->globals.server->time = sv.time;
1402 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1403 PRVM_ExecuteProgram (RestoreGame, "QC function RestoreGame is missing");
1408 //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);
1410 // copy spawn parms out of the client_t
1411 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1412 (&prog->globals.server->parm1)[i] = host_client->spawn_parms[i];
1414 // call the spawn function
1415 host_client->clientconnectcalled = true;
1416 prog->globals.server->time = sv.time;
1417 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1418 PRVM_ExecuteProgram (prog->globals.server->ClientConnect, "QC function ClientConnect is missing");
1420 if ((Sys_DoubleTime() - host_client->connecttime) <= sv.time)
1421 Con_Printf("%s entered the game\n", host_client->name);
1423 PRVM_ExecuteProgram (prog->globals.server->PutClientInServer, "QC function PutClientInServer is missing");
1426 if (!host_client->netconnection)
1429 // send time of update
1430 MSG_WriteByte (&host_client->netconnection->message, svc_time);
1431 MSG_WriteFloat (&host_client->netconnection->message, sv.time);
1433 // send all current names, colors, and frag counts
1434 for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
1436 if (!client->active)
1438 MSG_WriteByte (&host_client->netconnection->message, svc_updatename);
1439 MSG_WriteByte (&host_client->netconnection->message, i);
1440 MSG_WriteString (&host_client->netconnection->message, client->name);
1441 MSG_WriteByte (&host_client->netconnection->message, svc_updatefrags);
1442 MSG_WriteByte (&host_client->netconnection->message, i);
1443 MSG_WriteShort (&host_client->netconnection->message, client->frags);
1444 MSG_WriteByte (&host_client->netconnection->message, svc_updatecolors);
1445 MSG_WriteByte (&host_client->netconnection->message, i);
1446 MSG_WriteByte (&host_client->netconnection->message, client->colors);
1449 // send all current light styles
1450 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1452 if (sv.lightstyles[i][0])
1454 MSG_WriteByte (&host_client->netconnection->message, svc_lightstyle);
1455 MSG_WriteByte (&host_client->netconnection->message, (char)i);
1456 MSG_WriteString (&host_client->netconnection->message, sv.lightstyles[i]);
1461 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1462 MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALSECRETS);
1463 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->total_secrets);
1465 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1466 MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALMONSTERS);
1467 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->total_monsters);
1469 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1470 MSG_WriteByte (&host_client->netconnection->message, STAT_SECRETS);
1471 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->found_secrets);
1473 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1474 MSG_WriteByte (&host_client->netconnection->message, STAT_MONSTERS);
1475 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->killed_monsters);
1478 // Never send a roll angle, because savegames can catch the server
1479 // in a state where it is expecting the client to correct the angle
1480 // and it won't happen if the game was just loaded, so you wind up
1481 // with a permanent head tilt
1484 MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
1485 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[0], sv.protocol);
1486 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[1], sv.protocol);
1487 MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
1488 sv.loadgame = false; // we're basically done with loading now
1492 MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
1493 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[0], sv.protocol);
1494 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[1], sv.protocol);
1495 MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
1498 SV_WriteClientdataToMessage (host_client, host_client->edict, &host_client->netconnection->message, stats);
1500 MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
1501 MSG_WriteByte (&host_client->netconnection->message, 3);
1509 void Host_Begin_f (void)
1511 if (cmd_source == src_command)
1513 Con_Print("begin is not valid from the console\n");
1517 Curl_SendRequirements();
1519 host_client->spawned = true;
1522 //===========================================================================
1529 Kicks a user off of the server
1532 void Host_Kick_f (void)
1535 const char *message = NULL;
1538 qboolean byNumber = false;
1540 if (cmd_source != src_command || !sv.active)
1546 if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1548 i = (int)(atof(Cmd_Argv(2)) - 1);
1549 if (i < 0 || i >= svs.maxclients || !(host_client = svs.clients + i)->active)
1555 for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
1557 if (!host_client->active)
1559 if (strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1564 if (i < svs.maxclients)
1566 if (cmd_source == src_command)
1568 if (cls.state == ca_dedicated)
1571 who = cl_name.string;
1576 // can't kick yourself!
1577 if (host_client == save)
1582 message = Cmd_Args();
1583 COM_ParseToken(&message, false);
1586 message++; // skip the #
1587 while (*message == ' ') // skip white space
1589 message += strlen(Cmd_Argv(2)); // skip the number
1591 while (*message && *message == ' ')
1595 SV_ClientPrintf("Kicked by %s: %s\n", who, message);
1597 SV_ClientPrintf("Kicked by %s\n", who);
1598 SV_DropClient (false); // kicked
1606 ===============================================================================
1610 ===============================================================================
1618 void Host_Give_f (void)
1624 if (cmd_source == src_command)
1626 Cmd_ForwardToServer ();
1632 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
1637 v = atoi (Cmd_Argv(2));
1651 // MED 01/04/97 added hipnotic give stuff
1652 if (gamemode == GAME_HIPNOTIC)
1657 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_PROXIMITY_GUN;
1659 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | IT_GRENADE_LAUNCHER;
1661 else if (t[0] == '9')
1662 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_LASER_CANNON;
1663 else if (t[0] == '0')
1664 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_MJOLNIR;
1665 else if (t[0] >= '2')
1666 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
1671 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
1676 if (gamemode == GAME_ROGUE && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_shells1)))
1679 host_client->edict->fields.server->ammo_shells = v;
1682 if (gamemode == GAME_ROGUE)
1684 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_nails1)))
1687 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1688 host_client->edict->fields.server->ammo_nails = v;
1693 host_client->edict->fields.server->ammo_nails = v;
1697 if (gamemode == GAME_ROGUE)
1699 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_lava_nails);
1703 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1704 host_client->edict->fields.server->ammo_nails = v;
1709 if (gamemode == GAME_ROGUE)
1711 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_rockets1);
1715 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1716 host_client->edict->fields.server->ammo_rockets = v;
1721 host_client->edict->fields.server->ammo_rockets = v;
1725 if (gamemode == GAME_ROGUE)
1727 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_multi_rockets);
1731 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1732 host_client->edict->fields.server->ammo_rockets = v;
1737 host_client->edict->fields.server->health = v;
1740 if (gamemode == GAME_ROGUE)
1742 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_cells1);
1746 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1747 host_client->edict->fields.server->ammo_cells = v;
1752 host_client->edict->fields.server->ammo_cells = v;
1756 if (gamemode == GAME_ROGUE)
1758 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_plasma);
1762 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1763 host_client->edict->fields.server->ammo_cells = v;
1770 prvm_edict_t *FindViewthing (void)
1775 for (i=0 ; i<prog->num_edicts ; i++)
1777 e = PRVM_EDICT_NUM(i);
1778 if (!strcmp (PRVM_GetString(e->fields.server->classname), "viewthing"))
1781 Con_Print("No viewthing on map\n");
1790 void Host_Viewmodel_f (void)
1799 e = FindViewthing ();
1804 m = Mod_ForName (Cmd_Argv(1), false, true, false);
1805 if (!m || !m->loaded || !m->Draw)
1807 Con_Printf("viewmodel: can't load %s\n", Cmd_Argv(1));
1811 e->fields.server->frame = 0;
1812 cl.model_precache[(int)e->fields.server->modelindex] = m;
1820 void Host_Viewframe_f (void)
1830 e = FindViewthing ();
1834 m = cl.model_precache[(int)e->fields.server->modelindex];
1836 f = atoi(Cmd_Argv(1));
1837 if (f >= m->numframes)
1840 e->fields.server->frame = f;
1844 void PrintFrameName (model_t *m, int frame)
1847 Con_Printf("frame %i: %s\n", frame, m->animscenes[frame].name);
1849 Con_Printf("frame %i\n", frame);
1857 void Host_Viewnext_f (void)
1866 e = FindViewthing ();
1870 m = cl.model_precache[(int)e->fields.server->modelindex];
1872 e->fields.server->frame = e->fields.server->frame + 1;
1873 if (e->fields.server->frame >= m->numframes)
1874 e->fields.server->frame = m->numframes - 1;
1876 PrintFrameName (m, (int)e->fields.server->frame);
1884 void Host_Viewprev_f (void)
1893 e = FindViewthing ();
1898 m = cl.model_precache[(int)e->fields.server->modelindex];
1900 e->fields.server->frame = e->fields.server->frame - 1;
1901 if (e->fields.server->frame < 0)
1902 e->fields.server->frame = 0;
1904 PrintFrameName (m, (int)e->fields.server->frame);
1908 ===============================================================================
1912 ===============================================================================
1921 void Host_Startdemos_f (void)
1925 if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-demolooponly"))
1931 Con_Printf("Max %i demos in demoloop\n", MAX_DEMOS);
1934 Con_Printf("%i demo(s) in loop\n", c);
1936 for (i=1 ; i<c+1 ; i++)
1937 strlcpy (cls.demos[i-1], Cmd_Argv(i), sizeof (cls.demos[i-1]));
1939 // LordHavoc: clear the remaining slots
1940 for (;i <= MAX_DEMOS;i++)
1941 cls.demos[i-1][0] = 0;
1943 if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1957 Return to looping demos
1960 void Host_Demos_f (void)
1962 if (cls.state == ca_dedicated)
1964 if (cls.demonum == -1)
1974 Return to looping demos
1977 void Host_Stopdemo_f (void)
1979 if (!cls.demoplayback)
1982 Host_ShutdownServer ();
1985 void Host_SendCvar_f (void)
1993 if(!(c = Cvar_FindVar(Cmd_Argv(1))))
1995 if (cls.state != ca_dedicated)
1996 Cmd_ForwardStringToServer(va("sentcvar %s %s\n", c->name, c->string));
1997 if(!sv.active)// || !SV_ParseClientCommandQC)
2001 if (cls.state != ca_dedicated)
2005 for(;i<svs.maxclients;i++)
2006 if(svs.clients[i].active && svs.clients[i].netconnection)
2008 host_client = &svs.clients[i];
2009 Host_ClientCommands(va("sendcvar %s\n", c->name));
2014 static void MaxPlayers_f(void)
2018 if (Cmd_Argc() != 2)
2020 Con_Printf("\"maxplayers\" is \"%u\"\n", svs.maxclients);
2026 Con_Print("maxplayers can not be changed while a server is running.\n");
2030 n = atoi(Cmd_Argv(1));
2031 n = bound(1, n, MAX_SCOREBOARD);
2032 Con_Printf("\"maxplayers\" set to \"%u\"\n", n);
2035 Mem_Free(svs.clients);
2037 svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
2039 Cvar_Set ("deathmatch", "0");
2041 Cvar_Set ("deathmatch", "1");
2044 //=============================================================================
2046 // QuakeWorld commands
2049 =====================
2052 Send the rest of the command line over as
2053 an unconnected command.
2054 =====================
2056 void Host_Rcon_f (void) // credit: taken from QuakeWorld
2060 lhnetsocket_t *mysocket;
2062 if (!rcon_password.string || !rcon_password.string[0])
2064 Con_Printf ("You must set rcon_password before issuing an rcon command.\n");
2068 for (i = 0;rcon_password.string[i];i++)
2070 if (rcon_password.string[i] <= ' ')
2072 Con_Printf("rcon_password is not allowed to have any whitespace.\n");
2078 to = cls.netcon->peeraddress;
2081 if (!rcon_address.string[0])
2083 Con_Printf ("You must either be connected, or set the rcon_address cvar to issue rcon commands\n");
2086 LHNETADDRESS_FromString(&to, rcon_address.string, sv_netport.integer);
2088 mysocket = NetConn_ChooseClientSocketForAddress(&to);
2091 // simply put together the rcon packet and send it
2092 NetConn_WriteString(mysocket, va("\377\377\377\377rcon %s %s", rcon_password.string, Cmd_Args()), &to);
2097 ====================
2100 user <name or userid>
2102 Dump userdata / masterdata for a user
2103 ====================
2105 void Host_User_f (void) // credit: taken from QuakeWorld
2110 if (Cmd_Argc() != 2)
2112 Con_Printf ("Usage: user <username / userid>\n");
2116 uid = atoi(Cmd_Argv(1));
2118 for (i = 0;i < cl.maxclients;i++)
2120 if (!cl.scores[i].name[0])
2122 if (cl.scores[i].qw_userid == uid || !strcasecmp(cl.scores[i].name, Cmd_Argv(1)))
2124 InfoString_Print(cl.scores[i].qw_userinfo);
2128 Con_Printf ("User not in server.\n");
2132 ====================
2135 Dump userids for all current players
2136 ====================
2138 void Host_Users_f (void) // credit: taken from QuakeWorld
2144 Con_Printf ("userid frags name\n");
2145 Con_Printf ("------ ----- ----\n");
2146 for (i = 0;i < cl.maxclients;i++)
2148 if (cl.scores[i].name[0])
2150 Con_Printf ("%6i %4i %s\n", cl.scores[i].qw_userid, cl.scores[i].frags, cl.scores[i].name);
2155 Con_Printf ("%i total users\n", c);
2160 Host_FullServerinfo_f
2162 Sent by server when serverinfo changes
2165 // TODO: shouldn't this be a cvar instead?
2166 void Host_FullServerinfo_f (void) // credit: taken from QuakeWorld
2169 if (Cmd_Argc() != 2)
2171 Con_Printf ("usage: fullserverinfo <complete info string>\n");
2175 strlcpy (cl.qw_serverinfo, Cmd_Argv(1), sizeof(cl.qw_serverinfo));
2176 InfoString_GetValue(cl.qw_serverinfo, "teamplay", temp, sizeof(temp));
2177 cl.qw_teamplay = atoi(temp);
2184 Allow clients to change userinfo
2188 void Host_FullInfo_f (void) // credit: taken from QuakeWorld
2195 if (Cmd_Argc() != 2)
2197 Con_Printf ("fullinfo <complete info string>\n");
2207 while (*s && *s != '\\')
2213 Con_Printf ("MISSING VALUE\n");
2219 while (*s && *s != '\\')
2226 CL_SetInfo(key, value, false, false, false, false);
2234 Allow clients to change userinfo
2237 void Host_SetInfo_f (void) // credit: taken from QuakeWorld
2239 if (Cmd_Argc() == 1)
2241 InfoString_Print(cls.userinfo);
2244 if (Cmd_Argc() != 3)
2246 Con_Printf ("usage: setinfo [ <key> <value> ]\n");
2249 CL_SetInfo(Cmd_Argv(1), Cmd_Argv(2), true, false, false, false);
2253 ====================
2256 packet <destination> <contents>
2258 Contents allows \n escape character
2259 ====================
2261 void Host_Packet_f (void) // credit: taken from QuakeWorld
2267 lhnetaddress_t address;
2268 lhnetsocket_t *mysocket;
2270 if (Cmd_Argc() != 3)
2272 Con_Printf ("packet <destination> <contents>\n");
2276 if (!LHNETADDRESS_FromString (&address, Cmd_Argv(1), sv_netport.integer))
2278 Con_Printf ("Bad address\n");
2284 send[0] = send[1] = send[2] = send[3] = 0xff;
2286 l = (int)strlen (in);
2287 for (i=0 ; i<l ; i++)
2289 if (out >= send + sizeof(send) - 1)
2291 if (in[i] == '\\' && in[i+1] == 'n')
2296 else if (in[i] == '\\' && in[i+1] == '0')
2301 else if (in[i] == '\\' && in[i+1] == 't')
2306 else if (in[i] == '\\' && in[i+1] == 'r')
2311 else if (in[i] == '\\' && in[i+1] == '"')
2320 mysocket = NetConn_ChooseClientSocketForAddress(&address);
2322 NetConn_Write(mysocket, send, out - send, &address);
2325 //=============================================================================
2332 void Host_InitCommands (void)
2334 dpsnprintf(cls.userinfo, sizeof(cls.userinfo), "\\name\\player\\team\\none\\topcolor\\0\\bottomcolor\\0\\rate\\10000\\msg\\1\\noaim\\1\\*ver\\%s", engineversion);
2336 Cmd_AddCommand ("status", Host_Status_f, "print server status information");
2337 Cmd_AddCommand ("quit", Host_Quit_f, "quit the game");
2338 if (gamemode == GAME_NEHAHRA)
2340 Cmd_AddCommand ("max", Host_God_f, "god mode (invulnerability)");
2341 Cmd_AddCommand ("monster", Host_Notarget_f, "notarget mode (monsters do not see you)");
2342 Cmd_AddCommand ("scrag", Host_Fly_f, "fly mode (flight)");
2343 Cmd_AddCommand ("wraith", Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
2344 Cmd_AddCommand ("gimme", Host_Give_f, "alter inventory");
2348 Cmd_AddCommand ("god", Host_God_f, "god mode (invulnerability)");
2349 Cmd_AddCommand ("notarget", Host_Notarget_f, "notarget mode (monsters do not see you)");
2350 Cmd_AddCommand ("fly", Host_Fly_f, "fly mode (flight)");
2351 Cmd_AddCommand ("noclip", Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
2352 Cmd_AddCommand ("give", Host_Give_f, "alter inventory");
2354 Cmd_AddCommand ("map", Host_Map_f, "kick everyone off the server and start a new level");
2355 Cmd_AddCommand ("restart", Host_Restart_f, "restart current level");
2356 Cmd_AddCommand ("changelevel", Host_Changelevel_f, "change to another level, bringing along all connected clients");
2357 Cmd_AddCommand ("connect", Host_Connect_f, "connect to a server by IP address or hostname");
2358 Cmd_AddCommand ("reconnect", Host_Reconnect_f, "reset signon level in preparation for a new level (do not use)");
2359 Cmd_AddCommand ("version", Host_Version_f, "print engine version");
2360 Cmd_AddCommand ("say", Host_Say_f, "send a chat message to everyone on the server");
2361 Cmd_AddCommand ("say_team", Host_Say_Team_f, "send a chat message to your team on the server");
2362 Cmd_AddCommand ("tell", Host_Tell_f, "send a chat message to only one person on the server");
2363 Cmd_AddCommand ("kill", Host_Kill_f, "die instantly");
2364 Cmd_AddCommand ("pause", Host_Pause_f, "pause the game (if the server allows pausing)");
2365 Cmd_AddCommand ("kick", Host_Kick_f, "kick a player off the server by number or name");
2366 Cmd_AddCommand ("ping", Host_Ping_f, "print ping times of all players on the server");
2367 Cmd_AddCommand ("load", Host_Loadgame_f, "load a saved game file");
2368 Cmd_AddCommand ("save", Host_Savegame_f, "save the game to a file");
2370 Cmd_AddCommand ("startdemos", Host_Startdemos_f, "start playing back the selected demos sequentially (used at end of startup script)");
2371 Cmd_AddCommand ("demos", Host_Demos_f, "restart looping demos defined by the last startdemos command");
2372 Cmd_AddCommand ("stopdemo", Host_Stopdemo_f, "stop playing or recording demo (like stop command) and return to looping demos");
2374 Cmd_AddCommand ("viewmodel", Host_Viewmodel_f, "change model of viewthing entity in current level");
2375 Cmd_AddCommand ("viewframe", Host_Viewframe_f, "change animation frame of viewthing entity in current level");
2376 Cmd_AddCommand ("viewnext", Host_Viewnext_f, "change to next animation frame of viewthing entity in current level");
2377 Cmd_AddCommand ("viewprev", Host_Viewprev_f, "change to previous animation frame of viewthing entity in current level");
2379 Cvar_RegisterVariable (&cl_name);
2380 Cmd_AddCommand ("name", Host_Name_f, "change your player name");
2381 Cvar_RegisterVariable (&cl_color);
2382 Cmd_AddCommand ("color", Host_Color_f, "change your player shirt and pants colors");
2383 Cvar_RegisterVariable (&cl_rate);
2384 Cmd_AddCommand ("rate", Host_Rate_f, "change your network connection speed");
2385 if (gamemode == GAME_NEHAHRA)
2387 Cvar_RegisterVariable (&cl_pmodel);
2388 Cmd_AddCommand ("pmodel", Host_PModel_f, "change your player model choice (Nehahra specific)");
2391 // BLACK: This isnt game specific anymore (it was GAME_NEXUIZ at first)
2392 Cvar_RegisterVariable (&cl_playermodel);
2393 Cmd_AddCommand ("playermodel", Host_Playermodel_f, "change your player model");
2394 Cvar_RegisterVariable (&cl_playerskin);
2395 Cmd_AddCommand ("playerskin", Host_Playerskin_f, "change your player skin number");
2397 Cmd_AddCommand ("prespawn", Host_PreSpawn_f, "signon 1 (client acknowledges that server information has been received)");
2398 Cmd_AddCommand ("spawn", Host_Spawn_f, "signon 2 (client has sent player information, and is asking server to send scoreboard rankings)");
2399 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)");
2400 Cmd_AddCommand ("maxplayers", MaxPlayers_f, "sets limit on how many players (or bots) may be connected to the server at once");
2402 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]
2404 Cvar_RegisterVariable (&rcon_password);
2405 Cvar_RegisterVariable (&rcon_address);
2406 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)");
2407 Cmd_AddCommand ("user", Host_User_f, "prints additional information about a player number or name on the scoreboard");
2408 Cmd_AddCommand ("users", Host_Users_f, "prints additional information about all players on the scoreboard");
2409 Cmd_AddCommand ("fullserverinfo", Host_FullServerinfo_f, "internal use only, sent by server to client to update client's local copy of serverinfo string");
2410 Cmd_AddCommand ("fullinfo", Host_FullInfo_f, "allows client to modify their userinfo");
2411 Cmd_AddCommand ("setinfo", Host_SetInfo_f, "modifies your userinfo");
2412 Cmd_AddCommand ("packet", Host_Packet_f, "send a packet to the specified address:port containing a text string");
2413 Cmd_AddCommand ("topcolor", Host_TopColor_f, "QW command to set top color without changing bottom color");
2414 Cmd_AddCommand ("bottomcolor", Host_BottomColor_f, "QW command to set bottom color without changing top color");
2416 Cvar_RegisterVariable (&team);
2417 Cvar_RegisterVariable (&skin);
2418 Cvar_RegisterVariable (&noaim);
2420 Cvar_RegisterVariable(&sv_cheats);