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 qboolean allowcheats = false;
35 void Host_Quit_f (void)
46 void Host_Status_f (void)
49 int seconds, minutes, hours = 0, j, players;
50 void (*print) (const char *fmt, ...);
52 if (cmd_source == src_command)
56 Cmd_ForwardToServer ();
62 print = SV_ClientPrintf;
64 for (players = 0, j = 0;j < svs.maxclients;j++)
65 if (svs.clients[j].active)
67 print ("host: %s\n", Cvar_VariableString ("hostname"));
68 print ("version: %s build %s\n", gamename, buildstring);
69 print ("protocol: %i (%s)\n", Protocol_NumberForEnum(sv.protocol), Protocol_NameForEnum(sv.protocol));
70 print ("map: %s\n", sv.name);
71 print ("players: %i active (%i max)\n\n", players, svs.maxclients);
72 for (j = 0, client = svs.clients;j < svs.maxclients;j++, client++)
76 seconds = (int)(realtime - client->connecttime);
77 minutes = seconds / 60;
80 seconds -= (minutes * 60);
83 minutes -= (hours * 60);
87 print ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->fields.server->frags, hours, minutes, seconds);
88 print (" %s\n", client->netconnection ? client->netconnection->address : "botclient");
97 Sets client to godmode
100 void Host_God_f (void)
102 if (cmd_source == src_command)
104 Cmd_ForwardToServer ();
110 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
114 host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags ^ FL_GODMODE;
115 if (!((int)host_client->edict->fields.server->flags & FL_GODMODE) )
116 SV_ClientPrint("godmode OFF\n");
118 SV_ClientPrint("godmode ON\n");
121 void Host_Notarget_f (void)
123 if (cmd_source == src_command)
125 Cmd_ForwardToServer ();
131 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
135 host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags ^ FL_NOTARGET;
136 if (!((int)host_client->edict->fields.server->flags & FL_NOTARGET) )
137 SV_ClientPrint("notarget OFF\n");
139 SV_ClientPrint("notarget ON\n");
142 qboolean noclip_anglehack;
144 void Host_Noclip_f (void)
146 if (cmd_source == src_command)
148 Cmd_ForwardToServer ();
154 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
158 if (host_client->edict->fields.server->movetype != MOVETYPE_NOCLIP)
160 noclip_anglehack = true;
161 host_client->edict->fields.server->movetype = MOVETYPE_NOCLIP;
162 SV_ClientPrint("noclip ON\n");
166 noclip_anglehack = false;
167 host_client->edict->fields.server->movetype = MOVETYPE_WALK;
168 SV_ClientPrint("noclip OFF\n");
176 Sets client to flymode
179 void Host_Fly_f (void)
181 if (cmd_source == src_command)
183 Cmd_ForwardToServer ();
189 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
193 if (host_client->edict->fields.server->movetype != MOVETYPE_FLY)
195 host_client->edict->fields.server->movetype = MOVETYPE_FLY;
196 SV_ClientPrint("flymode ON\n");
200 host_client->edict->fields.server->movetype = MOVETYPE_WALK;
201 SV_ClientPrint("flymode OFF\n");
212 void Host_Ping_f (void)
216 void (*print) (const char *fmt, ...);
218 if (cmd_source == src_command)
222 Cmd_ForwardToServer ();
228 print = SV_ClientPrintf;
230 print("Client ping times:\n");
231 for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
235 print("%4i %s\n", (int)floor(client->ping*1000+0.5), client->name);
240 ===============================================================================
244 ===============================================================================
248 ======================
253 command from the console. Active clients are kicked off.
254 ======================
256 void Host_Map_f (void)
258 char level[MAX_QPATH];
262 Con_Print("map <levelname> : start a new game (kicks off all players)\n");
266 if (cmd_source != src_command)
269 cls.demonum = -1; // stop demo loop in case this fails
272 Host_ShutdownServer();
274 // remove console or menu
276 key_consoleactive = 0;
278 svs.serverflags = 0; // haven't completed an episode yet
279 allowcheats = sv_cheats.integer != 0;
280 strcpy(level, Cmd_Argv(1));
281 SV_SpawnServer(level);
282 if (sv.active && cls.state == ca_disconnected)
283 CL_EstablishConnection("local:1");
285 // if cl_autodemo is set, automatically start recording a demo if one isn't being recorded already
286 if (cl_autodemo.integer && !cls.demorecording)
288 char demofile[MAX_OSPATH];
290 dpsnprintf (demofile, sizeof(demofile), "%s_%s.dem", Sys_TimeString (cl_autodemo_nameformat.string), level);
292 Con_Printf ("Recording to %s.\n", demofile);
294 cls.demofile = FS_Open (demofile, "wb", false, false);
298 FS_Printf (cls.demofile, "%i\n", cls.forcetrack);
301 Con_Print ("ERROR: couldn't open.\n");
303 cls.demorecording = true;
311 Goes to a new map, taking all clients along
314 void Host_Changelevel_f (void)
316 char level[MAX_QPATH];
320 Con_Print("changelevel <levelname> : continue game on a new level\n");
323 if (cls.demoplayback)
325 Con_Print("Only the server may changelevel\n");
333 if (cmd_source != src_command)
336 // remove console or menu
338 key_consoleactive = 0;
341 SV_SaveSpawnparms ();
343 allowcheats = sv_cheats.integer != 0;
344 strcpy(level, Cmd_Argv(1));
345 SV_SpawnServer(level);
346 if (sv.active && cls.state == ca_disconnected)
347 CL_EstablishConnection("local:1");
354 Restarts the current server for a dead player
357 void Host_Restart_f (void)
359 char mapname[MAX_QPATH];
363 Con_Print("restart : restart current level\n");
368 Con_Print("Only the server may restart\n");
371 if (cmd_source != src_command)
374 // remove console or menu
376 key_consoleactive = 0;
378 allowcheats = sv_cheats.integer != 0;
379 strcpy(mapname, sv.name);
380 SV_SpawnServer(mapname);
381 if (sv.active && cls.state == ca_disconnected)
382 CL_EstablishConnection("local:1");
389 This command causes the client to wait for the signon messages again.
390 This is sent just before a server changes levels
393 void Host_Reconnect_f (void)
395 if (cls.protocol == PROTOCOL_QUAKEWORLD)
397 if (cls.qw_downloadmemory) // don't change when downloading
404 if (cls.state == ca_connected && cls.signon < SIGNONS)
406 Con_Printf("reconnecting...\n");
407 MSG_WriteChar(&cls.netcon->message, qw_clc_stringcmd);
408 MSG_WriteString(&cls.netcon->message, "new");
411 Con_Printf("Please use connect instead (reconnect not implemented)\n");
418 Con_Print("reconnect : wait for signon messages again\n");
423 Con_Print("reconnect: no signon, ignoring reconnect\n");
426 cls.signon = 0; // need new connection messages
431 =====================
434 User command to connect to server
435 =====================
437 void Host_Connect_f (void)
441 Con_Print("connect <serveraddress> : connect to a multiplayer game\n");
444 CL_EstablishConnection(Cmd_Argv(1));
449 ===============================================================================
453 ===============================================================================
456 #define SAVEGAME_VERSION 5
462 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
465 void Host_SavegameComment (char *text)
470 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
472 // LordHavoc: added min() to prevent overflow
473 memcpy (text, cl.levelname, min(strlen(cl.levelname), SAVEGAME_COMMENT_LENGTH));
474 sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
475 memcpy (text+22, kills, strlen(kills));
476 // convert space to _ to make stdio happy
477 // LordHavoc: convert control characters to _ as well
478 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
481 text[SAVEGAME_COMMENT_LENGTH] = '\0';
490 void Host_Savegame_f (void)
492 char name[MAX_QPATH];
495 char comment[SAVEGAME_COMMENT_LENGTH+1];
497 if (cmd_source != src_command)
500 if (cls.state != ca_connected || !sv.active)
502 Con_Print("Not playing a local game.\n");
508 Con_Print("Can't save in intermission.\n");
512 for (i = 0;i < svs.maxclients;i++)
514 if (svs.clients[i].active)
518 Con_Print("Can't save multiplayer games.\n");
521 if (svs.clients[i].edict->fields.server->deadflag)
523 Con_Print("Can't savegame with a dead player\n");
531 Con_Print("save <savename> : save a game\n");
535 if (strstr(Cmd_Argv(1), ".."))
537 Con_Print("Relative pathnames are not allowed.\n");
541 strlcpy (name, Cmd_Argv(1), sizeof (name));
542 FS_DefaultExtension (name, ".sav", sizeof (name));
544 Con_Printf("Saving game to %s...\n", name);
545 f = FS_Open (name, "wb", false, false);
548 Con_Print("ERROR: couldn't open.\n");
552 FS_Printf(f, "%i\n", SAVEGAME_VERSION);
553 Host_SavegameComment (comment);
554 FS_Printf(f, "%s\n", comment);
555 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
556 FS_Printf(f, "%f\n", svs.clients[0].spawn_parms[i]);
557 FS_Printf(f, "%d\n", current_skill);
558 FS_Printf(f, "%s\n", sv.name);
559 FS_Printf(f, "%f\n",sv.time);
561 // write the light styles
562 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
564 if (sv.lightstyles[i][0])
565 FS_Printf(f, "%s\n", sv.lightstyles[i]);
572 PRVM_ED_WriteGlobals (f);
573 for (i=0 ; i<prog->num_edicts ; i++)
574 PRVM_ED_Write (f, PRVM_EDICT_NUM(i));
579 Con_Print("done.\n");
588 void Host_Loadgame_f (void)
590 char filename[MAX_QPATH];
591 char mapname[MAX_QPATH];
601 float spawn_parms[NUM_SPAWN_PARMS];
603 if (cmd_source != src_command)
608 Con_Print("load <savename> : load a game\n");
612 strcpy (filename, Cmd_Argv(1));
613 FS_DefaultExtension (filename, ".sav", sizeof (filename));
615 Con_Printf("Loading game from %s...\n", filename);
617 cls.demonum = -1; // stop demo loop in case this fails
619 t = text = (char *)FS_LoadFile (filename, tempmempool, false, NULL);
622 Con_Print("ERROR: couldn't open.\n");
627 COM_ParseToken(&t, false);
628 version = atoi(com_token);
629 if (version != SAVEGAME_VERSION)
632 Con_Printf("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
637 // this is a little hard to parse, as : is a separator in COM_ParseToken,
638 // so use the console parser instead
639 COM_ParseTokenConsole(&t);
641 for (i = 0;i < NUM_SPAWN_PARMS;i++)
643 COM_ParseToken(&t, false);
644 spawn_parms[i] = atof(com_token);
647 COM_ParseToken(&t, false);
648 // this silliness is so we can load 1.06 save files, which have float skill values
649 current_skill = (int)(atof(com_token) + 0.5);
650 Cvar_SetValue ("skill", (float)current_skill);
653 COM_ParseToken(&t, false);
654 strcpy (mapname, com_token);
657 COM_ParseToken(&t, false);
658 time = atof(com_token);
660 allowcheats = sv_cheats.integer != 0;
662 SV_SpawnServer (mapname);
666 Con_Print("Couldn't load map\n");
669 sv.paused = true; // pause until all clients connect
672 // load the light styles
674 for (i = 0;i < MAX_LIGHTSTYLES;i++)
678 COM_ParseToken(&t, false);
679 // if this is a 64 lightstyle savegame produced by Quake, stop now
680 // we have to check this because darkplaces saves 256 lightstyle savegames
681 if (com_token[0] == '{')
686 strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i]));
689 // now skip everything before the first opening brace
690 // (this is for forward compatibility, so that older versions (at
691 // least ones with this fix) can load savegames with extra data before the
692 // first brace, as might be produced by a later engine version)
696 COM_ParseToken(&t, false);
697 if (com_token[0] == '{')
704 // load the edicts out of the savegame file
711 while (COM_ParseToken(&t, false))
712 if (!strcmp(com_token, "}"))
714 if (!COM_ParseToken(&start, false))
719 if (strcmp(com_token,"{"))
722 Host_Error ("First token isn't a brace");
727 // parse the global vars
728 PRVM_ED_ParseGlobals (start);
733 if (entnum >= MAX_EDICTS)
736 Host_Error("Host_PerformLoadGame: too many edicts in save file (reached MAX_EDICTS %i)", MAX_EDICTS);
738 while (entnum >= prog->max_edicts)
739 //SV_IncreaseEdicts();
740 PRVM_MEM_IncreaseEdicts();
741 ent = PRVM_EDICT_NUM(entnum);
742 memset (ent->fields.server, 0, prog->progs->entityfields * 4);
743 ent->priv.server->free = false;
744 PRVM_ED_ParseEdict (start, ent);
746 // link it into the bsp tree
747 if (!ent->priv.server->free)
748 SV_LinkEdict (ent, false);
755 prog->num_edicts = entnum;
758 for (i = 0;i < NUM_SPAWN_PARMS;i++)
759 svs.clients[0].spawn_parms[i] = spawn_parms[i];
763 // make sure we're connected to loopback
764 if (cls.state == ca_disconnected || !(cls.state == ca_connected && cls.netcon != NULL && LHNETADDRESS_GetAddressType(&cls.netcon->peeraddress) == LHNETADDRESSTYPE_LOOP))
765 CL_EstablishConnection("local:1");
768 //============================================================================
771 ======================
773 ======================
775 cvar_t cl_name = {CVAR_SAVE, "_cl_name", "player", "internal storage cvar for current player name (changed by name command)"};
776 void Host_Name_f (void)
779 char newName[sizeof(host_client->name)];
781 if (Cmd_Argc () == 1)
783 Con_Printf("\"name\" is \"%s\"\n", cl_name.string);
787 if (Cmd_Argc () == 2)
788 strlcpy (newName, Cmd_Argv(1), sizeof (newName));
790 strlcpy (newName, Cmd_Args(), sizeof (newName));
792 for (i = 0, j = 0;newName[i];i++)
793 if (newName[i] != '\r' && newName[i] != '\n')
794 newName[j++] = newName[i];
797 if (cmd_source == src_command)
799 Cvar_Set ("_cl_name", newName);
800 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "name", newName);
801 if (cls.state == ca_connected)
802 Cmd_ForwardToServer ();
806 if (sv.time < host_client->nametime)
808 SV_ClientPrintf("You can't change name more than once every 5 seconds!\n");
812 host_client->nametime = sv.time + 5;
814 // point the string back at updateclient->name to keep it safe
815 strlcpy (host_client->name, newName, sizeof (host_client->name));
816 host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name);
817 if (strcmp(host_client->old_name, host_client->name))
819 if (host_client->spawned)
820 SV_BroadcastPrintf("%s changed name to %s\n", host_client->old_name, host_client->name);
821 strcpy(host_client->old_name, host_client->name);
822 // send notification to all clients
823 MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
824 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
825 MSG_WriteString (&sv.reliable_datagram, host_client->name);
830 ======================
832 ======================
834 cvar_t cl_playermodel = {CVAR_SAVE, "_cl_playermodel", "", "internal storage cvar for current player model in Nexuiz (changed by playermodel command)"};
835 // the old cl_playermodel in cl_main has been renamed to __cl_playermodel
836 void Host_Playermodel_f (void)
839 char newPath[sizeof(host_client->playermodel)];
841 if (Cmd_Argc () == 1)
843 Con_Printf("\"playermodel\" is \"%s\"\n", cl_playermodel.string);
847 if (Cmd_Argc () == 2)
848 strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
850 strlcpy (newPath, Cmd_Args(), sizeof (newPath));
852 for (i = 0, j = 0;newPath[i];i++)
853 if (newPath[i] != '\r' && newPath[i] != '\n')
854 newPath[j++] = newPath[i];
857 if (cmd_source == src_command)
859 Cvar_Set ("_cl_playermodel", newPath);
860 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "playermodel", newPath);
861 if (cls.state == ca_connected)
862 Cmd_ForwardToServer ();
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 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "playerskin", newPath);
921 if (cls.state == ca_connected)
922 Cmd_ForwardToServer ();
927 if (sv.time < host_client->nametime)
929 SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
933 host_client->nametime = sv.time + 5;
936 // point the string back at updateclient->name to keep it safe
937 strlcpy (host_client->playerskin, newPath, sizeof (host_client->playerskin));
938 if( eval_playerskin )
939 PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string = PRVM_SetEngineString(host_client->playerskin);
940 if (strcmp(host_client->old_skin, host_client->playerskin))
942 if (host_client->spawned)
943 SV_BroadcastPrintf("%s changed skin to %s\n", host_client->name, host_client->playerskin);
944 strcpy(host_client->old_skin, host_client->playerskin);
945 /*// send notification to all clients
946 MSG_WriteByte (&sv.reliable_datagram, svc_updatepskin);
947 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
948 MSG_WriteString (&sv.reliable_datagram, host_client->playerskin);*/
952 void Host_Version_f (void)
954 Con_Printf("Version: %s build %s\n", gamename, buildstring);
957 void Host_Say(qboolean teamonly)
963 // LordHavoc: long say messages
965 qboolean fromServer = false;
967 if (cmd_source == src_command)
969 if (cls.state == ca_dedicated)
976 Cmd_ForwardToServer ();
984 if (!teamplay.integer)
987 // turn on color set 1
996 dpsnprintf (text, sizeof(text), "%c%s" STRING_COLOR_DEFAULT_STR ": %s", 1, host_client->name, p1);
998 dpsnprintf (text, sizeof(text), "%c<%s" STRING_COLOR_DEFAULT_STR "> %s", 1, hostname.string, p1);
999 p2 = text + strlen(text);
1000 while ((const char *)p2 > (const char *)text && (p2[-1] == '\r' || p2[-1] == '\n' || (p2[-1] == '\"' && quoted)))
1002 if (p2[-1] == '\"' && quoted)
1007 strlcat(text, "\n", sizeof(text));
1009 // note: save is not a valid edict if fromServer is true
1011 for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
1012 if (host_client->spawned && (!teamonly || host_client->edict->fields.server->team == save->edict->fields.server->team))
1013 SV_ClientPrint(text);
1016 if (cls.state == ca_dedicated)
1017 Con_Print(&text[1]);
1021 void Host_Say_f(void)
1027 void Host_Say_Team_f(void)
1033 void Host_Tell_f(void)
1037 const char *p1, *p2;
1038 char text[MAX_INPUTLINE]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
1039 qboolean fromServer = false;
1041 if (cmd_source == src_command)
1043 if (cls.state == ca_dedicated)
1047 Cmd_ForwardToServer ();
1052 if (Cmd_Argc () < 3)
1056 sprintf (text, "%s: ", host_client->name);
1058 sprintf (text, "<%s> ", 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_f(void)
1107 func_t SV_ChangeTeam;
1109 if (Cmd_Argc() == 1)
1111 Con_Printf("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15);
1112 Con_Print("color <0-15> [0-15]\n");
1116 if (Cmd_Argc() == 2)
1117 top = bottom = atoi(Cmd_Argv(1));
1120 top = atoi(Cmd_Argv(1));
1121 bottom = atoi(Cmd_Argv(2));
1125 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
1129 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
1133 playercolor = top*16 + bottom;
1135 if (cmd_source == src_command)
1137 Cvar_SetValue ("_cl_color", playercolor);
1138 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "topcolor", va("%i", top));
1139 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "bottomcolor", va("%i", bottom));
1140 if (cls.state == ca_connected && cls.protocol != PROTOCOL_QUAKEWORLD)
1141 Cmd_ForwardToServer ();
1145 if (cls.protocol == PROTOCOL_QUAKEWORLD)
1148 if (host_client->edict && (f = PRVM_ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - prog->functions)))
1150 Con_DPrint("Calling SV_ChangeTeam\n");
1151 prog->globals.server->time = sv.time;
1152 prog->globals.generic[OFS_PARM0] = playercolor;
1153 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1154 PRVM_ExecuteProgram (SV_ChangeTeam, "QC function SV_ChangeTeam is missing");
1159 if (host_client->edict)
1161 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_clientcolors)))
1162 val->_float = playercolor;
1163 host_client->edict->fields.server->team = bottom + 1;
1165 host_client->colors = playercolor;
1166 if (host_client->old_colors != host_client->colors)
1168 host_client->old_colors = host_client->colors;
1169 // send notification to all clients
1170 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
1171 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
1172 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
1177 cvar_t cl_rate = {CVAR_SAVE, "_cl_rate", "10000", "internal storage cvar for current rate (changed by rate command)"};
1178 void Host_Rate_f(void)
1182 if (Cmd_Argc() != 2)
1184 Con_Printf("\"rate\" is \"%i\"\n", cl_rate.integer);
1185 Con_Print("rate <500-25000>\n");
1189 rate = atoi(Cmd_Argv(1));
1191 if (cmd_source == src_command)
1193 Cvar_SetValue ("_cl_rate", bound(NET_MINRATE, rate, NET_MAXRATE));
1194 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "rate", va("%i", rate));
1195 if (cls.state == ca_connected)
1196 Cmd_ForwardToServer ();
1200 host_client->rate = rate;
1208 void Host_Kill_f (void)
1210 if (cmd_source == src_command)
1212 Cmd_ForwardToServer ();
1216 if (host_client->edict->fields.server->health <= 0)
1218 SV_ClientPrint("Can't suicide -- already dead!\n");
1222 prog->globals.server->time = sv.time;
1223 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1224 PRVM_ExecuteProgram (prog->globals.server->ClientKill, "QC function ClientKill is missing");
1233 void Host_Pause_f (void)
1236 if (cmd_source == src_command)
1238 Cmd_ForwardToServer ();
1241 if (!pausable.integer)
1242 SV_ClientPrint("Pause not allowed.\n");
1246 SV_BroadcastPrintf("%s %spaused the game\n", host_client->name, sv.paused ? "" : "un");
1247 // send notification to all clients
1248 MSG_WriteByte(&sv.reliable_datagram, svc_setpause);
1249 MSG_WriteByte(&sv.reliable_datagram, sv.paused);
1254 ======================
1256 LordHavoc: only supported for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
1257 LordHavoc: correction, Mindcrime will be removing pmodel in the future, but it's still stuck here for compatibility.
1258 ======================
1260 cvar_t cl_pmodel = {CVAR_SAVE, "_cl_pmodel", "0", "internal storage cvar for current player model number in nehahra (changed by pmodel command)"};
1261 static void Host_PModel_f (void)
1266 if (Cmd_Argc () == 1)
1268 Con_Printf("\"pmodel\" is \"%s\"\n", cl_pmodel.string);
1271 i = atoi(Cmd_Argv(1));
1273 if (cmd_source == src_command)
1275 if (cl_pmodel.integer == i)
1277 Cvar_SetValue ("_cl_pmodel", i);
1278 if (cls.state == ca_connected)
1279 Cmd_ForwardToServer ();
1283 if (host_client->edict && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1287 //===========================================================================
1295 void Host_PreSpawn_f (void)
1297 if (cmd_source == src_command)
1299 Con_Print("prespawn is not valid from the console\n");
1303 if (host_client->spawned)
1305 Con_Print("prespawn not valid -- already spawned\n");
1309 if (host_client->netconnection)
1311 SZ_Write (&host_client->netconnection->message, sv.signon.data, sv.signon.cursize);
1312 MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
1313 MSG_WriteByte (&host_client->netconnection->message, 2);
1316 // reset the name change timer because the client will send name soon
1317 host_client->nametime = 0;
1325 void Host_Spawn_f (void)
1331 int stats[MAX_CL_STATS];
1333 if (cmd_source == src_command)
1335 Con_Print("spawn is not valid from the console\n");
1339 if (host_client->spawned)
1341 Con_Print("Spawn not valid -- already spawned\n");
1345 // reset name change timer again because they might want to change name
1346 // again in the first 5 seconds after connecting
1347 host_client->nametime = 0;
1349 // LordHavoc: moved this above the QC calls at FrikaC's request
1350 // LordHavoc: commented this out
1351 //if (host_client->netconnection)
1352 // SZ_Clear (&host_client->netconnection->message);
1354 // run the entrance script
1357 // loaded games are fully initialized already
1358 // if this is the last client to be connected, unpause
1361 if ((f = PRVM_ED_FindFunction ("RestoreGame")))
1362 if ((RestoreGame = (func_t)(f - prog->functions)))
1364 Con_DPrint("Calling RestoreGame\n");
1365 prog->globals.server->time = sv.time;
1366 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1367 PRVM_ExecuteProgram (RestoreGame, "QC function RestoreGame is missing");
1372 //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);
1374 // copy spawn parms out of the client_t
1375 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1376 (&prog->globals.server->parm1)[i] = host_client->spawn_parms[i];
1378 // call the spawn function
1379 host_client->clientconnectcalled = true;
1380 prog->globals.server->time = sv.time;
1381 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1382 PRVM_ExecuteProgram (prog->globals.server->ClientConnect, "QC function ClientConnect is missing");
1384 if ((Sys_DoubleTime() - host_client->connecttime) <= sv.time)
1385 Con_Printf("%s entered the game\n", host_client->name);
1387 PRVM_ExecuteProgram (prog->globals.server->PutClientInServer, "QC function PutClientInServer is missing");
1390 if (!host_client->netconnection)
1393 // send time of update
1394 MSG_WriteByte (&host_client->netconnection->message, svc_time);
1395 MSG_WriteFloat (&host_client->netconnection->message, sv.time);
1397 // send all current names, colors, and frag counts
1398 for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
1400 if (!client->active)
1402 MSG_WriteByte (&host_client->netconnection->message, svc_updatename);
1403 MSG_WriteByte (&host_client->netconnection->message, i);
1404 MSG_WriteString (&host_client->netconnection->message, client->name);
1405 MSG_WriteByte (&host_client->netconnection->message, svc_updatefrags);
1406 MSG_WriteByte (&host_client->netconnection->message, i);
1407 MSG_WriteShort (&host_client->netconnection->message, client->frags);
1408 MSG_WriteByte (&host_client->netconnection->message, svc_updatecolors);
1409 MSG_WriteByte (&host_client->netconnection->message, i);
1410 MSG_WriteByte (&host_client->netconnection->message, client->colors);
1413 // send all current light styles
1414 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1416 if (sv.lightstyles[i][0])
1418 MSG_WriteByte (&host_client->netconnection->message, svc_lightstyle);
1419 MSG_WriteByte (&host_client->netconnection->message, (char)i);
1420 MSG_WriteString (&host_client->netconnection->message, sv.lightstyles[i]);
1425 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1426 MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALSECRETS);
1427 MSG_WriteLong (&host_client->netconnection->message, prog->globals.server->total_secrets);
1429 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1430 MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALMONSTERS);
1431 MSG_WriteLong (&host_client->netconnection->message, prog->globals.server->total_monsters);
1433 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1434 MSG_WriteByte (&host_client->netconnection->message, STAT_SECRETS);
1435 MSG_WriteLong (&host_client->netconnection->message, prog->globals.server->found_secrets);
1437 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1438 MSG_WriteByte (&host_client->netconnection->message, STAT_MONSTERS);
1439 MSG_WriteLong (&host_client->netconnection->message, prog->globals.server->killed_monsters);
1442 // Never send a roll angle, because savegames can catch the server
1443 // in a state where it is expecting the client to correct the angle
1444 // and it won't happen if the game was just loaded, so you wind up
1445 // with a permanent head tilt
1448 MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
1449 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[0], sv.protocol);
1450 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[1], sv.protocol);
1451 MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
1452 sv.loadgame = false; // we're basically done with loading now
1456 MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
1457 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[0], sv.protocol);
1458 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[1], sv.protocol);
1459 MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
1462 SV_WriteClientdataToMessage (host_client, host_client->edict, &host_client->netconnection->message, stats);
1464 MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
1465 MSG_WriteByte (&host_client->netconnection->message, 3);
1473 void Host_Begin_f (void)
1475 if (cmd_source == src_command)
1477 Con_Print("begin is not valid from the console\n");
1481 host_client->spawned = true;
1484 //===========================================================================
1491 Kicks a user off of the server
1494 void Host_Kick_f (void)
1497 const char *message = NULL;
1500 qboolean byNumber = false;
1502 if (cmd_source != src_command || !sv.active)
1508 if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1510 i = atof(Cmd_Argv(2)) - 1;
1511 if (i < 0 || i >= svs.maxclients || !(host_client = svs.clients + i)->active)
1517 for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
1519 if (!host_client->active)
1521 if (strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1526 if (i < svs.maxclients)
1528 if (cmd_source == src_command)
1530 if (cls.state == ca_dedicated)
1533 who = cl_name.string;
1538 // can't kick yourself!
1539 if (host_client == save)
1544 message = Cmd_Args();
1545 COM_ParseToken(&message, false);
1548 message++; // skip the #
1549 while (*message == ' ') // skip white space
1551 message += strlen(Cmd_Argv(2)); // skip the number
1553 while (*message && *message == ' ')
1557 SV_ClientPrintf("Kicked by %s: %s\n", who, message);
1559 SV_ClientPrintf("Kicked by %s\n", who);
1560 SV_DropClient (false); // kicked
1568 ===============================================================================
1572 ===============================================================================
1580 void Host_Give_f (void)
1586 if (cmd_source == src_command)
1588 Cmd_ForwardToServer ();
1594 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
1599 v = atoi (Cmd_Argv(2));
1613 // MED 01/04/97 added hipnotic give stuff
1614 if (gamemode == GAME_HIPNOTIC)
1619 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_PROXIMITY_GUN;
1621 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | IT_GRENADE_LAUNCHER;
1623 else if (t[0] == '9')
1624 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_LASER_CANNON;
1625 else if (t[0] == '0')
1626 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_MJOLNIR;
1627 else if (t[0] >= '2')
1628 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
1633 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
1638 if (gamemode == GAME_ROGUE && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_shells1)))
1641 host_client->edict->fields.server->ammo_shells = v;
1644 if (gamemode == GAME_ROGUE)
1646 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_nails1)))
1649 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1650 host_client->edict->fields.server->ammo_nails = v;
1655 host_client->edict->fields.server->ammo_nails = v;
1659 if (gamemode == GAME_ROGUE)
1661 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_lava_nails);
1665 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1666 host_client->edict->fields.server->ammo_nails = v;
1671 if (gamemode == GAME_ROGUE)
1673 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_rockets1);
1677 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1678 host_client->edict->fields.server->ammo_rockets = v;
1683 host_client->edict->fields.server->ammo_rockets = v;
1687 if (gamemode == GAME_ROGUE)
1689 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_multi_rockets);
1693 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1694 host_client->edict->fields.server->ammo_rockets = v;
1699 host_client->edict->fields.server->health = v;
1702 if (gamemode == GAME_ROGUE)
1704 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_cells1);
1708 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1709 host_client->edict->fields.server->ammo_cells = v;
1714 host_client->edict->fields.server->ammo_cells = v;
1718 if (gamemode == GAME_ROGUE)
1720 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_plasma);
1724 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1725 host_client->edict->fields.server->ammo_cells = v;
1732 prvm_edict_t *FindViewthing (void)
1737 for (i=0 ; i<prog->num_edicts ; i++)
1739 e = PRVM_EDICT_NUM(i);
1740 if (!strcmp (PRVM_GetString(e->fields.server->classname), "viewthing"))
1743 Con_Print("No viewthing on map\n");
1752 void Host_Viewmodel_f (void)
1761 e = FindViewthing ();
1766 m = Mod_ForName (Cmd_Argv(1), false, true, false);
1767 if (!m || !m->loaded || !m->Draw)
1769 Con_Printf("viewmodel: can't load %s\n", Cmd_Argv(1));
1773 e->fields.server->frame = 0;
1774 cl.model_precache[(int)e->fields.server->modelindex] = m;
1782 void Host_Viewframe_f (void)
1792 e = FindViewthing ();
1796 m = cl.model_precache[(int)e->fields.server->modelindex];
1798 f = atoi(Cmd_Argv(1));
1799 if (f >= m->numframes)
1802 e->fields.server->frame = f;
1806 void PrintFrameName (model_t *m, int frame)
1809 Con_Printf("frame %i: %s\n", frame, m->animscenes[frame].name);
1811 Con_Printf("frame %i\n", frame);
1819 void Host_Viewnext_f (void)
1828 e = FindViewthing ();
1832 m = cl.model_precache[(int)e->fields.server->modelindex];
1834 e->fields.server->frame = e->fields.server->frame + 1;
1835 if (e->fields.server->frame >= m->numframes)
1836 e->fields.server->frame = m->numframes - 1;
1838 PrintFrameName (m, e->fields.server->frame);
1846 void Host_Viewprev_f (void)
1855 e = FindViewthing ();
1860 m = cl.model_precache[(int)e->fields.server->modelindex];
1862 e->fields.server->frame = e->fields.server->frame - 1;
1863 if (e->fields.server->frame < 0)
1864 e->fields.server->frame = 0;
1866 PrintFrameName (m, e->fields.server->frame);
1870 ===============================================================================
1874 ===============================================================================
1883 void Host_Startdemos_f (void)
1887 if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-demolooponly"))
1893 Con_Printf("Max %i demos in demoloop\n", MAX_DEMOS);
1896 Con_Printf("%i demo(s) in loop\n", c);
1898 for (i=1 ; i<c+1 ; i++)
1899 strlcpy (cls.demos[i-1], Cmd_Argv(i), sizeof (cls.demos[i-1]));
1901 // LordHavoc: clear the remaining slots
1902 for (;i <= MAX_DEMOS;i++)
1903 cls.demos[i-1][0] = 0;
1905 if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1919 Return to looping demos
1922 void Host_Demos_f (void)
1924 if (cls.state == ca_dedicated)
1926 if (cls.demonum == -1)
1936 Return to looping demos
1939 void Host_Stopdemo_f (void)
1941 if (!cls.demoplayback)
1944 Host_ShutdownServer ();
1947 void Host_SendCvar_f (void)
1955 if(!(c = Cvar_FindVar(Cmd_Argv(1))))
1957 if (cls.state != ca_dedicated)
1958 Cmd_ForwardStringToServer(va("sentcvar %s %s\n", c->name, c->string));
1959 if(!sv.active)// || !SV_ParseClientCommandQC)
1963 if (cls.state != ca_dedicated)
1967 for(;i<svs.maxclients;i++)
1968 if(svs.clients[i].active && svs.clients[i].netconnection)
1970 host_client = &svs.clients[i];
1971 Host_ClientCommands(va("sendcvar %s\n", c->name));
1976 static void MaxPlayers_f(void)
1980 if (Cmd_Argc() != 2)
1982 Con_Printf("\"maxplayers\" is \"%u\"\n", svs.maxclients);
1988 Con_Print("maxplayers can not be changed while a server is running.\n");
1992 n = atoi(Cmd_Argv(1));
1993 n = bound(1, n, MAX_SCOREBOARD);
1994 Con_Printf("\"maxplayers\" set to \"%u\"\n", n);
1997 Mem_Free(svs.clients);
1999 svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
2001 Cvar_Set ("deathmatch", "0");
2003 Cvar_Set ("deathmatch", "1");
2006 //=============================================================================
2008 // QuakeWorld commands
2011 =====================
2014 Send the rest of the command line over as
2015 an unconnected command.
2016 =====================
2018 void Host_Rcon_f (void) // credit: taken from QuakeWorld
2022 lhnetsocket_t *mysocket;
2024 if (!rcon_password.string || !rcon_password.string[0])
2026 Con_Printf ("You must set rcon_password before issuing an rcon command.\n");
2030 for (i = 0;rcon_password.string[i];i++)
2032 if (rcon_password.string[i] <= ' ')
2034 Con_Printf("rcon_password is not allowed to have any whitespace.\n");
2040 to = cls.netcon->peeraddress;
2043 if (!rcon_address.integer || !rcon_address.string[0])
2045 Con_Printf ("You must either be connected, or set the rcon_address cvar to issue rcon commands\n");
2048 LHNETADDRESS_FromString(&to, rcon_address.string, sv_netport.integer);
2050 mysocket = NetConn_ChooseClientSocketForAddress(&to);
2053 // simply put together the rcon packet and send it
2054 NetConn_WriteString(mysocket, va("\377\377\377\377rcon %s %s", rcon_password.string, Cmd_Args()), &to);
2059 ====================
2062 user <name or userid>
2064 Dump userdata / masterdata for a user
2065 ====================
2067 void Host_User_f (void) // credit: taken from QuakeWorld
2072 if (Cmd_Argc() != 2)
2074 Con_Printf ("Usage: user <username / userid>\n");
2078 uid = atoi(Cmd_Argv(1));
2080 for (i = 0;i < cl.maxclients;i++)
2082 if (!cl.scores[i].name[0])
2084 if (cl.scores[i].qw_userid == uid || !strcasecmp(cl.scores[i].name, Cmd_Argv(1)))
2086 InfoString_Print(cl.scores[i].qw_userinfo);
2090 Con_Printf ("User not in server.\n");
2094 ====================
2097 Dump userids for all current players
2098 ====================
2100 void Host_Users_f (void) // credit: taken from QuakeWorld
2106 Con_Printf ("userid frags name\n");
2107 Con_Printf ("------ ----- ----\n");
2108 for (i = 0;i < cl.maxclients;i++)
2110 if (cl.scores[i].name[0])
2112 Con_Printf ("%6i %4i %s\n", cl.scores[i].qw_userid, cl.scores[i].frags, cl.scores[i].name);
2117 Con_Printf ("%i total users\n", c);
2122 Host_FullServerinfo_f
2124 Sent by server when serverinfo changes
2127 // TODO: shouldn't this be a cvar instead?
2128 void Host_FullServerinfo_f (void) // credit: taken from QuakeWorld
2131 if (Cmd_Argc() != 2)
2133 Con_Printf ("usage: fullserverinfo <complete info string>\n");
2137 strlcpy (cl.qw_serverinfo, Cmd_Argv(1), sizeof(cl.qw_serverinfo));
2138 InfoString_GetValue(cl.qw_serverinfo, "teamplay", temp, sizeof(temp));
2139 cl.qw_teamplay = atoi(temp);
2146 Allow clients to change userinfo
2150 void Host_FullInfo_f (void) // credit: taken from QuakeWorld
2157 if (Cmd_Argc() != 2)
2159 Con_Printf ("fullinfo <complete info string>\n");
2169 while (*s && *s != '\\')
2175 Con_Printf ("MISSING VALUE\n");
2181 while (*s && *s != '\\')
2188 if (!strcasecmp(key, "pmodel") || !strcasecmp(key, "emodel"))
2193 Con_Printf("Can't set star-key \"%s\" to \"%s\"\n", key, value);
2197 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), key, value);
2205 Allow clients to change userinfo
2208 void Host_SetInfo_f (void) // credit: taken from QuakeWorld
2210 if (Cmd_Argc() == 1)
2212 InfoString_Print(cls.userinfo);
2215 if (Cmd_Argc() != 3)
2217 Con_Printf ("usage: setinfo [ <key> <value> ]\n");
2220 if (!strcasecmp(Cmd_Argv(1), "pmodel") || !strcasecmp(Cmd_Argv(1), "emodel"))
2222 if (Cmd_Argv(1)[0] == '*')
2224 Con_Printf("Can't set star-key \"%s\" to \"%s\"\n", Cmd_Argv(1), Cmd_Argv(2));
2227 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), Cmd_Argv(1), Cmd_Argv(2));
2228 if (cls.state == ca_connected)
2229 Cmd_ForwardToServer ();
2233 ====================
2236 packet <destination> <contents>
2238 Contents allows \n escape character
2239 ====================
2241 void Host_Packet_f (void) // credit: taken from QuakeWorld
2247 lhnetaddress_t address;
2248 lhnetsocket_t *mysocket;
2250 if (Cmd_Argc() != 3)
2252 Con_Printf ("packet <destination> <contents>\n");
2256 if (!LHNETADDRESS_FromString (&address, Cmd_Argv(1), sv_netport.integer))
2258 Con_Printf ("Bad address\n");
2264 send[0] = send[1] = send[2] = send[3] = 0xff;
2266 l = (int)strlen (in);
2267 for (i=0 ; i<l ; i++)
2269 if (out >= send + sizeof(send) - 1)
2271 if (in[i] == '\\' && in[i+1] == 'n')
2276 else if (in[i] == '\\' && in[i+1] == '0')
2281 else if (in[i] == '\\' && in[i+1] == 't')
2286 else if (in[i] == '\\' && in[i+1] == 'r')
2291 else if (in[i] == '\\' && in[i+1] == '"')
2300 mysocket = NetConn_ChooseClientSocketForAddress(&address);
2302 NetConn_Write(mysocket, send, out - send, &address);
2305 //=============================================================================
2312 void Host_InitCommands (void)
2314 strcpy(cls.userinfo, "\\name\\player\\team\\none\\topcolor\\0\\bottomcolor\\0\\rate\\10000\\msg\\1\\*ver\\dp");
2316 Cmd_AddCommand ("status", Host_Status_f, "print server status information");
2317 Cmd_AddCommand ("quit", Host_Quit_f, "quit the game");
2318 if (gamemode == GAME_NEHAHRA)
2320 Cmd_AddCommand ("max", Host_God_f, "god mode (invulnerability)");
2321 Cmd_AddCommand ("monster", Host_Notarget_f, "notarget mode (monsters do not see you)");
2322 Cmd_AddCommand ("scrag", Host_Fly_f, "fly mode (flight)");
2323 Cmd_AddCommand ("wraith", Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
2324 Cmd_AddCommand ("gimme", Host_Give_f, "alter inventory");
2328 Cmd_AddCommand ("god", Host_God_f, "god mode (invulnerability)");
2329 Cmd_AddCommand ("notarget", Host_Notarget_f, "notarget mode (monsters do not see you)");
2330 Cmd_AddCommand ("fly", Host_Fly_f, "fly mode (flight)");
2331 Cmd_AddCommand ("noclip", Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
2332 Cmd_AddCommand ("give", Host_Give_f, "alter inventory");
2334 Cmd_AddCommand ("map", Host_Map_f, "kick everyone off the server and start a new level");
2335 Cmd_AddCommand ("restart", Host_Restart_f, "restart current level");
2336 Cmd_AddCommand ("changelevel", Host_Changelevel_f, "change to another level, bringing along all connected clients");
2337 Cmd_AddCommand ("connect", Host_Connect_f, "connect to a server by IP address or hostname");
2338 Cmd_AddCommand ("reconnect", Host_Reconnect_f, "reset signon level in preparation for a new level (do not use)");
2339 Cmd_AddCommand ("version", Host_Version_f, "print engine version");
2340 Cmd_AddCommand ("say", Host_Say_f, "send a chat message to everyone on the server");
2341 Cmd_AddCommand ("say_team", Host_Say_Team_f, "send a chat message to your team on the server");
2342 Cmd_AddCommand ("tell", Host_Tell_f, "send a chat message to only one person on the server");
2343 Cmd_AddCommand ("kill", Host_Kill_f, "die instantly");
2344 Cmd_AddCommand ("pause", Host_Pause_f, "pause the game (if the server allows pausing)");
2345 Cmd_AddCommand ("kick", Host_Kick_f, "kick a player off the server by number or name");
2346 Cmd_AddCommand ("ping", Host_Ping_f, "print ping times of all players on the server");
2347 Cmd_AddCommand ("load", Host_Loadgame_f, "load a saved game file");
2348 Cmd_AddCommand ("save", Host_Savegame_f, "save the game to a file");
2350 Cmd_AddCommand ("startdemos", Host_Startdemos_f, "start playing back the selected demos sequentially (used at end of startup script)");
2351 Cmd_AddCommand ("demos", Host_Demos_f, "restart looping demos defined by the last startdemos command");
2352 Cmd_AddCommand ("stopdemo", Host_Stopdemo_f, "stop playing or recording demo (like stop command) and return to looping demos");
2354 Cmd_AddCommand ("viewmodel", Host_Viewmodel_f, "change model of viewthing entity in current level");
2355 Cmd_AddCommand ("viewframe", Host_Viewframe_f, "change animation frame of viewthing entity in current level");
2356 Cmd_AddCommand ("viewnext", Host_Viewnext_f, "change to next animation frame of viewthing entity in current level");
2357 Cmd_AddCommand ("viewprev", Host_Viewprev_f, "change to previous animation frame of viewthing entity in current level");
2359 Cvar_RegisterVariable (&cl_name);
2360 Cmd_AddCommand ("name", Host_Name_f, "change your player name");
2361 Cvar_RegisterVariable (&cl_color);
2362 Cmd_AddCommand ("color", Host_Color_f, "change your player shirt and pants colors");
2363 Cvar_RegisterVariable (&cl_rate);
2364 Cmd_AddCommand ("rate", Host_Rate_f, "change your network connection speed");
2365 if (gamemode == GAME_NEHAHRA)
2367 Cvar_RegisterVariable (&cl_pmodel);
2368 Cmd_AddCommand ("pmodel", Host_PModel_f, "change your player model choice (Nehahra specific)");
2371 // BLACK: This isnt game specific anymore (it was GAME_NEXUIZ at first)
2372 Cvar_RegisterVariable (&cl_playermodel);
2373 Cmd_AddCommand ("playermodel", Host_Playermodel_f, "change your player model");
2374 Cvar_RegisterVariable (&cl_playerskin);
2375 Cmd_AddCommand ("playerskin", Host_Playerskin_f, "change your player skin number");
2377 Cmd_AddCommand ("prespawn", Host_PreSpawn_f, "signon 1 (client acknowledges that server information has been received)");
2378 Cmd_AddCommand ("spawn", Host_Spawn_f, "signon 2 (client has sent player information, and is asking server to send scoreboard rankings)");
2379 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)");
2380 Cmd_AddCommand ("maxplayers", MaxPlayers_f, "sets limit on how many players (or bots) may be connected to the server at once");
2382 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]
2384 Cvar_RegisterVariable (&rcon_password);
2385 Cvar_RegisterVariable (&rcon_address);
2386 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)");
2387 Cmd_AddCommand ("user", Host_User_f, "prints additional information about a player number or name on the scoreboard");
2388 Cmd_AddCommand ("users", Host_Users_f, "prints additional information about all players on the scoreboard");
2389 Cmd_AddCommand ("fullserverinfo", Host_FullServerinfo_f, "internal use only, sent by server to client to update client's local copy of serverinfo string");
2390 Cmd_AddCommand ("fullinfo", Host_FullInfo_f, "allows client to modify their userinfo");
2391 Cmd_AddCommand ("setinfo", Host_SetInfo_f, "modifies your userinfo");
2392 Cmd_AddCommand ("packet", Host_Packet_f, "send a packet to the specified address:port containing a text string");
2394 Cvar_RegisterVariable(&sv_cheats);