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");
290 Goes to a new map, taking all clients along
293 void Host_Changelevel_f (void)
295 char level[MAX_QPATH];
299 Con_Print("changelevel <levelname> : continue game on a new level\n");
302 if (cls.demoplayback)
304 Con_Print("Only the server may changelevel\n");
312 if (cmd_source != src_command)
315 // remove console or menu
317 key_consoleactive = 0;
320 SV_SaveSpawnparms ();
322 allowcheats = sv_cheats.integer != 0;
323 strcpy(level, Cmd_Argv(1));
324 SV_SpawnServer(level);
325 if (sv.active && cls.state == ca_disconnected)
326 CL_EstablishConnection("local:1");
333 Restarts the current server for a dead player
336 void Host_Restart_f (void)
338 char mapname[MAX_QPATH];
342 Con_Print("restart : restart current level\n");
347 Con_Print("Only the server may restart\n");
350 if (cmd_source != src_command)
353 // remove console or menu
355 key_consoleactive = 0;
357 allowcheats = sv_cheats.integer != 0;
358 strcpy(mapname, sv.name);
359 SV_SpawnServer(mapname);
360 if (sv.active && cls.state == ca_disconnected)
361 CL_EstablishConnection("local:1");
368 This command causes the client to wait for the signon messages again.
369 This is sent just before a server changes levels
372 void Host_Reconnect_f (void)
374 if (cls.protocol == PROTOCOL_QUAKEWORLD)
376 if (cls.qw_downloadmemory) // don't change when downloading
383 if (cls.state == ca_connected && cls.signon < SIGNONS)
385 Con_Printf("reconnecting...\n");
386 MSG_WriteChar(&cls.netcon->message, qw_clc_stringcmd);
387 MSG_WriteString(&cls.netcon->message, "new");
390 Con_Printf("Please use connect instead (reconnect not implemented)\n");
397 Con_Print("reconnect : wait for signon messages again\n");
402 Con_Print("reconnect: no signon, ignoring reconnect\n");
405 cls.signon = 0; // need new connection messages
410 =====================
413 User command to connect to server
414 =====================
416 void Host_Connect_f (void)
420 Con_Print("connect <serveraddress> : connect to a multiplayer game\n");
423 CL_EstablishConnection(Cmd_Argv(1));
428 ===============================================================================
432 ===============================================================================
435 #define SAVEGAME_VERSION 5
441 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
444 void Host_SavegameComment (char *text)
449 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
451 // LordHavoc: added min() to prevent overflow
452 memcpy (text, cl.levelname, min(strlen(cl.levelname), SAVEGAME_COMMENT_LENGTH));
453 sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
454 memcpy (text+22, kills, strlen(kills));
455 // convert space to _ to make stdio happy
456 // LordHavoc: convert control characters to _ as well
457 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
460 text[SAVEGAME_COMMENT_LENGTH] = '\0';
469 void Host_Savegame_f (void)
471 char name[MAX_QPATH];
474 char comment[SAVEGAME_COMMENT_LENGTH+1];
476 if (cmd_source != src_command)
479 if (cls.state != ca_connected || !sv.active)
481 Con_Print("Not playing a local game.\n");
487 Con_Print("Can't save in intermission.\n");
491 for (i = 0;i < svs.maxclients;i++)
493 if (svs.clients[i].active)
497 Con_Print("Can't save multiplayer games.\n");
500 if (svs.clients[i].edict->fields.server->deadflag)
502 Con_Print("Can't savegame with a dead player\n");
510 Con_Print("save <savename> : save a game\n");
514 if (strstr(Cmd_Argv(1), ".."))
516 Con_Print("Relative pathnames are not allowed.\n");
520 strlcpy (name, Cmd_Argv(1), sizeof (name));
521 FS_DefaultExtension (name, ".sav", sizeof (name));
523 Con_Printf("Saving game to %s...\n", name);
524 f = FS_Open (name, "wb", false, false);
527 Con_Print("ERROR: couldn't open.\n");
531 FS_Printf(f, "%i\n", SAVEGAME_VERSION);
532 Host_SavegameComment (comment);
533 FS_Printf(f, "%s\n", comment);
534 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
535 FS_Printf(f, "%f\n", svs.clients[0].spawn_parms[i]);
536 FS_Printf(f, "%d\n", current_skill);
537 FS_Printf(f, "%s\n", sv.name);
538 FS_Printf(f, "%f\n",sv.time);
540 // write the light styles
541 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
543 if (sv.lightstyles[i][0])
544 FS_Printf(f, "%s\n", sv.lightstyles[i]);
551 PRVM_ED_WriteGlobals (f);
552 for (i=0 ; i<prog->num_edicts ; i++)
553 PRVM_ED_Write (f, PRVM_EDICT_NUM(i));
558 Con_Print("done.\n");
567 void Host_Loadgame_f (void)
569 char filename[MAX_QPATH];
570 char mapname[MAX_QPATH];
580 float spawn_parms[NUM_SPAWN_PARMS];
582 if (cmd_source != src_command)
587 Con_Print("load <savename> : load a game\n");
591 strcpy (filename, Cmd_Argv(1));
592 FS_DefaultExtension (filename, ".sav", sizeof (filename));
594 Con_Printf("Loading game from %s...\n", filename);
596 cls.demonum = -1; // stop demo loop in case this fails
598 t = text = (char *)FS_LoadFile (filename, tempmempool, false, NULL);
601 Con_Print("ERROR: couldn't open.\n");
606 COM_ParseToken(&t, false);
607 version = atoi(com_token);
608 if (version != SAVEGAME_VERSION)
611 Con_Printf("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
616 // this is a little hard to parse, as : is a separator in COM_ParseToken,
617 // so use the console parser instead
618 COM_ParseTokenConsole(&t);
620 for (i = 0;i < NUM_SPAWN_PARMS;i++)
622 COM_ParseToken(&t, false);
623 spawn_parms[i] = atof(com_token);
626 COM_ParseToken(&t, false);
627 // this silliness is so we can load 1.06 save files, which have float skill values
628 current_skill = (int)(atof(com_token) + 0.5);
629 Cvar_SetValue ("skill", (float)current_skill);
632 COM_ParseToken(&t, false);
633 strcpy (mapname, com_token);
636 COM_ParseToken(&t, false);
637 time = atof(com_token);
639 allowcheats = sv_cheats.integer != 0;
641 SV_SpawnServer (mapname);
645 Con_Print("Couldn't load map\n");
648 sv.paused = true; // pause until all clients connect
651 // load the light styles
653 for (i = 0;i < MAX_LIGHTSTYLES;i++)
657 COM_ParseToken(&t, false);
658 // if this is a 64 lightstyle savegame produced by Quake, stop now
659 // we have to check this because darkplaces saves 256 lightstyle savegames
660 if (com_token[0] == '{')
665 strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i]));
668 // now skip everything before the first opening brace
669 // (this is for forward compatibility, so that older versions (at
670 // least ones with this fix) can load savegames with extra data before the
671 // first brace, as might be produced by a later engine version)
675 COM_ParseToken(&t, false);
676 if (com_token[0] == '{')
683 // load the edicts out of the savegame file
690 while (COM_ParseToken(&t, false))
691 if (!strcmp(com_token, "}"))
693 if (!COM_ParseToken(&start, false))
698 if (strcmp(com_token,"{"))
701 Host_Error ("First token isn't a brace");
706 // parse the global vars
707 PRVM_ED_ParseGlobals (start);
712 if (entnum >= MAX_EDICTS)
715 Host_Error("Host_PerformLoadGame: too many edicts in save file (reached MAX_EDICTS %i)", MAX_EDICTS);
717 while (entnum >= prog->max_edicts)
718 //SV_IncreaseEdicts();
719 PRVM_MEM_IncreaseEdicts();
720 ent = PRVM_EDICT_NUM(entnum);
721 memset (ent->fields.server, 0, prog->progs->entityfields * 4);
722 ent->priv.server->free = false;
723 PRVM_ED_ParseEdict (start, ent);
725 // link it into the bsp tree
726 if (!ent->priv.server->free)
727 SV_LinkEdict (ent, false);
733 prog->num_edicts = entnum;
736 for (i = 0;i < NUM_SPAWN_PARMS;i++)
737 svs.clients[0].spawn_parms[i] = spawn_parms[i];
741 // make sure we're connected to loopback
742 if (cls.state == ca_disconnected || !(cls.state == ca_connected && cls.netcon != NULL && LHNETADDRESS_GetAddressType(&cls.netcon->peeraddress) == LHNETADDRESSTYPE_LOOP))
743 CL_EstablishConnection("local:1");
746 //============================================================================
749 ======================
751 ======================
753 cvar_t cl_name = {CVAR_SAVE, "_cl_name", "player", "internal storage cvar for current player name (changed by name command)"};
754 void Host_Name_f (void)
757 char newName[sizeof(host_client->name)];
759 if (Cmd_Argc () == 1)
761 Con_Printf("\"name\" is \"%s\"\n", cl_name.string);
765 if (Cmd_Argc () == 2)
766 strlcpy (newName, Cmd_Argv(1), sizeof (newName));
768 strlcpy (newName, Cmd_Args(), sizeof (newName));
770 for (i = 0, j = 0;newName[i];i++)
771 if (newName[i] != '\r' && newName[i] != '\n')
772 newName[j++] = newName[i];
775 if (cmd_source == src_command)
777 Cvar_Set ("_cl_name", newName);
778 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "name", newName);
779 if (cls.state == ca_connected)
780 Cmd_ForwardToServer ();
784 if (sv.time < host_client->nametime)
786 SV_ClientPrintf("You can't change name more than once every 5 seconds!\n");
790 host_client->nametime = sv.time + 5;
792 // point the string back at updateclient->name to keep it safe
793 strlcpy (host_client->name, newName, sizeof (host_client->name));
794 host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name);
795 if (strcmp(host_client->old_name, host_client->name))
797 if (host_client->spawned)
798 SV_BroadcastPrintf("%s changed name to %s\n", host_client->old_name, host_client->name);
799 strcpy(host_client->old_name, host_client->name);
800 // send notification to all clients
801 MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
802 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
803 MSG_WriteString (&sv.reliable_datagram, host_client->name);
808 ======================
810 ======================
812 cvar_t cl_playermodel = {CVAR_SAVE, "_cl_playermodel", "", "internal storage cvar for current player model in Nexuiz (changed by playermodel command)"};
813 // the old cl_playermodel in cl_main has been renamed to __cl_playermodel
814 void Host_Playermodel_f (void)
817 char newPath[sizeof(host_client->playermodel)];
819 if (Cmd_Argc () == 1)
821 Con_Printf("\"playermodel\" is \"%s\"\n", cl_playermodel.string);
825 if (Cmd_Argc () == 2)
826 strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
828 strlcpy (newPath, Cmd_Args(), sizeof (newPath));
830 for (i = 0, j = 0;newPath[i];i++)
831 if (newPath[i] != '\r' && newPath[i] != '\n')
832 newPath[j++] = newPath[i];
835 if (cmd_source == src_command)
837 Cvar_Set ("_cl_playermodel", newPath);
838 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "playermodel", newPath);
839 if (cls.state == ca_connected)
840 Cmd_ForwardToServer ();
845 if (sv.time < host_client->nametime)
847 SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
851 host_client->nametime = sv.time + 5;
854 // point the string back at updateclient->name to keep it safe
855 strlcpy (host_client->playermodel, newPath, sizeof (host_client->playermodel));
856 if( eval_playermodel )
857 PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PRVM_SetEngineString(host_client->playermodel);
858 if (strcmp(host_client->old_model, host_client->playermodel))
860 strcpy(host_client->old_model, host_client->playermodel);
861 /*// send notification to all clients
862 MSG_WriteByte (&sv.reliable_datagram, svc_updatepmodel);
863 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
864 MSG_WriteString (&sv.reliable_datagram, host_client->playermodel);*/
869 ======================
871 ======================
873 cvar_t cl_playerskin = {CVAR_SAVE, "_cl_playerskin", "", "internal storage cvar for current player skin in Nexuiz (changed by playerskin command)"};
874 void Host_Playerskin_f (void)
877 char newPath[sizeof(host_client->playerskin)];
879 if (Cmd_Argc () == 1)
881 Con_Printf("\"playerskin\" is \"%s\"\n", cl_playerskin.string);
885 if (Cmd_Argc () == 2)
886 strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
888 strlcpy (newPath, Cmd_Args(), sizeof (newPath));
890 for (i = 0, j = 0;newPath[i];i++)
891 if (newPath[i] != '\r' && newPath[i] != '\n')
892 newPath[j++] = newPath[i];
895 if (cmd_source == src_command)
897 Cvar_Set ("_cl_playerskin", newPath);
898 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "playerskin", newPath);
899 if (cls.state == ca_connected)
900 Cmd_ForwardToServer ();
905 if (sv.time < host_client->nametime)
907 SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
911 host_client->nametime = sv.time + 5;
914 // point the string back at updateclient->name to keep it safe
915 strlcpy (host_client->playerskin, newPath, sizeof (host_client->playerskin));
916 if( eval_playerskin )
917 PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string = PRVM_SetEngineString(host_client->playerskin);
918 if (strcmp(host_client->old_skin, host_client->playerskin))
920 if (host_client->spawned)
921 SV_BroadcastPrintf("%s changed skin to %s\n", host_client->name, host_client->playerskin);
922 strcpy(host_client->old_skin, host_client->playerskin);
923 /*// send notification to all clients
924 MSG_WriteByte (&sv.reliable_datagram, svc_updatepskin);
925 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
926 MSG_WriteString (&sv.reliable_datagram, host_client->playerskin);*/
930 void Host_Version_f (void)
932 Con_Printf("Version: %s build %s\n", gamename, buildstring);
935 void Host_Say(qboolean teamonly)
941 // LordHavoc: long say messages
943 qboolean fromServer = false;
945 if (cmd_source == src_command)
947 if (cls.state == ca_dedicated)
954 Cmd_ForwardToServer ();
962 if (!teamplay.integer)
965 // turn on color set 1
974 dpsnprintf (text, sizeof(text), "%c%s" STRING_COLOR_DEFAULT_STR ": %s", 1, host_client->name, p1);
976 dpsnprintf (text, sizeof(text), "%c<%s" STRING_COLOR_DEFAULT_STR "> %s", 1, hostname.string, p1);
977 p2 = text + strlen(text);
978 while ((const char *)p2 > (const char *)text && (p2[-1] == '\r' || p2[-1] == '\n' || (p2[-1] == '\"' && quoted)))
980 if (p2[-1] == '\"' && quoted)
985 strlcat(text, "\n", sizeof(text));
987 // note: save is not a valid edict if fromServer is true
989 for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
990 if (host_client->spawned && (!teamonly || host_client->edict->fields.server->team == save->edict->fields.server->team))
991 SV_ClientPrint(text);
994 if (cls.state == ca_dedicated)
999 void Host_Say_f(void)
1005 void Host_Say_Team_f(void)
1011 void Host_Tell_f(void)
1015 const char *p1, *p2;
1016 char text[MAX_INPUTLINE]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
1017 qboolean fromServer = false;
1019 if (cmd_source == src_command)
1021 if (cls.state == ca_dedicated)
1025 Cmd_ForwardToServer ();
1030 if (Cmd_Argc () < 3)
1034 sprintf (text, "%s: ", host_client->name);
1036 sprintf (text, "<%s> ", hostname.string);
1039 p2 = p1 + strlen(p1);
1040 // remove the target name
1041 while (p1 < p2 && *p1 != ' ')
1043 while (p1 < p2 && *p1 == ' ')
1045 // remove trailing newlines
1046 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
1048 // remove quotes if present
1054 else if (fromServer)
1055 Con_Print("Host_Tell: missing end quote\n");
1057 SV_ClientPrint("Host_Tell: missing end quote\n");
1059 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
1061 for (j = (int)strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;)
1067 for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
1068 if (host_client->spawned && !strcasecmp(host_client->name, Cmd_Argv(1)))
1069 SV_ClientPrint(text);
1079 cvar_t cl_color = {CVAR_SAVE, "_cl_color", "0", "internal storage cvar for current player colors (changed by color command)"};
1080 void Host_Color_f(void)
1085 func_t SV_ChangeTeam;
1087 if (Cmd_Argc() == 1)
1089 Con_Printf("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15);
1090 Con_Print("color <0-15> [0-15]\n");
1094 if (Cmd_Argc() == 2)
1095 top = bottom = atoi(Cmd_Argv(1));
1098 top = atoi(Cmd_Argv(1));
1099 bottom = atoi(Cmd_Argv(2));
1103 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
1107 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
1111 playercolor = top*16 + bottom;
1113 if (cmd_source == src_command)
1115 Cvar_SetValue ("_cl_color", playercolor);
1116 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "topcolor", va("%i", top));
1117 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "bottomcolor", va("%i", bottom));
1118 if (cls.state == ca_connected && cls.protocol != PROTOCOL_QUAKEWORLD)
1119 Cmd_ForwardToServer ();
1123 if (cls.protocol == PROTOCOL_QUAKEWORLD)
1126 if (host_client->edict && (f = PRVM_ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - prog->functions)))
1128 Con_DPrint("Calling SV_ChangeTeam\n");
1129 prog->globals.server->time = sv.time;
1130 prog->globals.generic[OFS_PARM0] = playercolor;
1131 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1132 PRVM_ExecuteProgram (SV_ChangeTeam, "QC function SV_ChangeTeam is missing");
1137 if (host_client->edict)
1139 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_clientcolors)))
1140 val->_float = playercolor;
1141 host_client->edict->fields.server->team = bottom + 1;
1143 host_client->colors = playercolor;
1144 if (host_client->old_colors != host_client->colors)
1146 host_client->old_colors = host_client->colors;
1147 // send notification to all clients
1148 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
1149 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
1150 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
1155 cvar_t cl_rate = {CVAR_SAVE, "_cl_rate", "10000", "internal storage cvar for current rate (changed by rate command)"};
1156 void Host_Rate_f(void)
1160 if (Cmd_Argc() != 2)
1162 Con_Printf("\"rate\" is \"%i\"\n", cl_rate.integer);
1163 Con_Print("rate <500-25000>\n");
1167 rate = atoi(Cmd_Argv(1));
1169 if (cmd_source == src_command)
1171 Cvar_SetValue ("_cl_rate", bound(NET_MINRATE, rate, NET_MAXRATE));
1172 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "rate", va("%i", rate));
1173 if (cls.state == ca_connected)
1174 Cmd_ForwardToServer ();
1178 host_client->rate = rate;
1186 void Host_Kill_f (void)
1188 if (cmd_source == src_command)
1190 Cmd_ForwardToServer ();
1194 if (host_client->edict->fields.server->health <= 0)
1196 SV_ClientPrint("Can't suicide -- already dead!\n");
1200 prog->globals.server->time = sv.time;
1201 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1202 PRVM_ExecuteProgram (prog->globals.server->ClientKill, "QC function ClientKill is missing");
1211 void Host_Pause_f (void)
1214 if (cmd_source == src_command)
1216 Cmd_ForwardToServer ();
1219 if (!pausable.integer)
1220 SV_ClientPrint("Pause not allowed.\n");
1224 SV_BroadcastPrintf("%s %spaused the game\n", host_client->name, sv.paused ? "" : "un");
1225 // send notification to all clients
1226 MSG_WriteByte(&sv.reliable_datagram, svc_setpause);
1227 MSG_WriteByte(&sv.reliable_datagram, sv.paused);
1232 ======================
1234 LordHavoc: only supported for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
1235 LordHavoc: correction, Mindcrime will be removing pmodel in the future, but it's still stuck here for compatibility.
1236 ======================
1238 cvar_t cl_pmodel = {CVAR_SAVE, "_cl_pmodel", "0", "internal storage cvar for current player model number in nehahra (changed by pmodel command)"};
1239 static void Host_PModel_f (void)
1244 if (Cmd_Argc () == 1)
1246 Con_Printf("\"pmodel\" is \"%s\"\n", cl_pmodel.string);
1249 i = atoi(Cmd_Argv(1));
1251 if (cmd_source == src_command)
1253 if (cl_pmodel.integer == i)
1255 Cvar_SetValue ("_cl_pmodel", i);
1256 if (cls.state == ca_connected)
1257 Cmd_ForwardToServer ();
1261 if (host_client->edict && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1265 //===========================================================================
1273 void Host_PreSpawn_f (void)
1275 if (cmd_source == src_command)
1277 Con_Print("prespawn is not valid from the console\n");
1281 if (host_client->spawned)
1283 Con_Print("prespawn not valid -- already spawned\n");
1287 if (host_client->netconnection)
1289 SZ_Write (&host_client->netconnection->message, sv.signon.data, sv.signon.cursize);
1290 MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
1291 MSG_WriteByte (&host_client->netconnection->message, 2);
1294 // reset the name change timer because the client will send name soon
1295 host_client->nametime = 0;
1303 void Host_Spawn_f (void)
1309 int stats[MAX_CL_STATS];
1311 if (cmd_source == src_command)
1313 Con_Print("spawn is not valid from the console\n");
1317 if (host_client->spawned)
1319 Con_Print("Spawn not valid -- already spawned\n");
1323 // reset name change timer again because they might want to change name
1324 // again in the first 5 seconds after connecting
1325 host_client->nametime = 0;
1327 // LordHavoc: moved this above the QC calls at FrikaC's request
1328 // LordHavoc: commented this out
1329 //if (host_client->netconnection)
1330 // SZ_Clear (&host_client->netconnection->message);
1332 // run the entrance script
1335 // loaded games are fully initialized already
1336 // if this is the last client to be connected, unpause
1339 if ((f = PRVM_ED_FindFunction ("RestoreGame")))
1340 if ((RestoreGame = (func_t)(f - prog->functions)))
1342 Con_DPrint("Calling RestoreGame\n");
1343 prog->globals.server->time = sv.time;
1344 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1345 PRVM_ExecuteProgram (RestoreGame, "QC function RestoreGame is missing");
1350 //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);
1352 // copy spawn parms out of the client_t
1353 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1354 (&prog->globals.server->parm1)[i] = host_client->spawn_parms[i];
1356 // call the spawn function
1357 host_client->clientconnectcalled = true;
1358 prog->globals.server->time = sv.time;
1359 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1360 PRVM_ExecuteProgram (prog->globals.server->ClientConnect, "QC function ClientConnect is missing");
1362 if ((Sys_DoubleTime() - host_client->connecttime) <= sv.time)
1363 Con_Printf("%s entered the game\n", host_client->name);
1365 PRVM_ExecuteProgram (prog->globals.server->PutClientInServer, "QC function PutClientInServer is missing");
1368 if (!host_client->netconnection)
1371 // send time of update
1372 MSG_WriteByte (&host_client->netconnection->message, svc_time);
1373 MSG_WriteFloat (&host_client->netconnection->message, sv.time);
1375 // send all current names, colors, and frag counts
1376 for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
1378 if (!client->active)
1380 MSG_WriteByte (&host_client->netconnection->message, svc_updatename);
1381 MSG_WriteByte (&host_client->netconnection->message, i);
1382 MSG_WriteString (&host_client->netconnection->message, client->name);
1383 MSG_WriteByte (&host_client->netconnection->message, svc_updatefrags);
1384 MSG_WriteByte (&host_client->netconnection->message, i);
1385 MSG_WriteShort (&host_client->netconnection->message, client->frags);
1386 MSG_WriteByte (&host_client->netconnection->message, svc_updatecolors);
1387 MSG_WriteByte (&host_client->netconnection->message, i);
1388 MSG_WriteByte (&host_client->netconnection->message, client->colors);
1391 // send all current light styles
1392 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1394 if (sv.lightstyles[i][0])
1396 MSG_WriteByte (&host_client->netconnection->message, svc_lightstyle);
1397 MSG_WriteByte (&host_client->netconnection->message, (char)i);
1398 MSG_WriteString (&host_client->netconnection->message, sv.lightstyles[i]);
1403 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1404 MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALSECRETS);
1405 MSG_WriteLong (&host_client->netconnection->message, prog->globals.server->total_secrets);
1407 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1408 MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALMONSTERS);
1409 MSG_WriteLong (&host_client->netconnection->message, prog->globals.server->total_monsters);
1411 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1412 MSG_WriteByte (&host_client->netconnection->message, STAT_SECRETS);
1413 MSG_WriteLong (&host_client->netconnection->message, prog->globals.server->found_secrets);
1415 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1416 MSG_WriteByte (&host_client->netconnection->message, STAT_MONSTERS);
1417 MSG_WriteLong (&host_client->netconnection->message, prog->globals.server->killed_monsters);
1420 // Never send a roll angle, because savegames can catch the server
1421 // in a state where it is expecting the client to correct the angle
1422 // and it won't happen if the game was just loaded, so you wind up
1423 // with a permanent head tilt
1424 MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
1425 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[0], sv.protocol);
1426 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[1], sv.protocol);
1427 MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
1429 SV_WriteClientdataToMessage (host_client, host_client->edict, &host_client->netconnection->message, stats);
1431 MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
1432 MSG_WriteByte (&host_client->netconnection->message, 3);
1440 void Host_Begin_f (void)
1442 if (cmd_source == src_command)
1444 Con_Print("begin is not valid from the console\n");
1448 host_client->spawned = true;
1451 //===========================================================================
1458 Kicks a user off of the server
1461 void Host_Kick_f (void)
1464 const char *message = NULL;
1467 qboolean byNumber = false;
1469 if (cmd_source != src_command || !sv.active)
1475 if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1477 i = atof(Cmd_Argv(2)) - 1;
1478 if (i < 0 || i >= svs.maxclients || !(host_client = svs.clients + i)->active)
1484 for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
1486 if (!host_client->active)
1488 if (strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1493 if (i < svs.maxclients)
1495 if (cmd_source == src_command)
1497 if (cls.state == ca_dedicated)
1500 who = cl_name.string;
1505 // can't kick yourself!
1506 if (host_client == save)
1511 message = Cmd_Args();
1512 COM_ParseToken(&message, false);
1515 message++; // skip the #
1516 while (*message == ' ') // skip white space
1518 message += strlen(Cmd_Argv(2)); // skip the number
1520 while (*message && *message == ' ')
1524 SV_ClientPrintf("Kicked by %s: %s\n", who, message);
1526 SV_ClientPrintf("Kicked by %s\n", who);
1527 SV_DropClient (false); // kicked
1535 ===============================================================================
1539 ===============================================================================
1547 void Host_Give_f (void)
1553 if (cmd_source == src_command)
1555 Cmd_ForwardToServer ();
1561 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
1566 v = atoi (Cmd_Argv(2));
1580 // MED 01/04/97 added hipnotic give stuff
1581 if (gamemode == GAME_HIPNOTIC)
1586 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_PROXIMITY_GUN;
1588 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | IT_GRENADE_LAUNCHER;
1590 else if (t[0] == '9')
1591 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_LASER_CANNON;
1592 else if (t[0] == '0')
1593 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_MJOLNIR;
1594 else if (t[0] >= '2')
1595 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
1600 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
1605 if (gamemode == GAME_ROGUE && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_shells1)))
1608 host_client->edict->fields.server->ammo_shells = v;
1611 if (gamemode == GAME_ROGUE)
1613 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_nails1)))
1616 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1617 host_client->edict->fields.server->ammo_nails = v;
1622 host_client->edict->fields.server->ammo_nails = v;
1626 if (gamemode == GAME_ROGUE)
1628 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_lava_nails);
1632 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1633 host_client->edict->fields.server->ammo_nails = v;
1638 if (gamemode == GAME_ROGUE)
1640 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_rockets1);
1644 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1645 host_client->edict->fields.server->ammo_rockets = v;
1650 host_client->edict->fields.server->ammo_rockets = v;
1654 if (gamemode == GAME_ROGUE)
1656 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_multi_rockets);
1660 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1661 host_client->edict->fields.server->ammo_rockets = v;
1666 host_client->edict->fields.server->health = v;
1669 if (gamemode == GAME_ROGUE)
1671 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_cells1);
1675 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1676 host_client->edict->fields.server->ammo_cells = v;
1681 host_client->edict->fields.server->ammo_cells = v;
1685 if (gamemode == GAME_ROGUE)
1687 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_plasma);
1691 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1692 host_client->edict->fields.server->ammo_cells = v;
1699 prvm_edict_t *FindViewthing (void)
1704 for (i=0 ; i<prog->num_edicts ; i++)
1706 e = PRVM_EDICT_NUM(i);
1707 if (!strcmp (PRVM_GetString(e->fields.server->classname), "viewthing"))
1710 Con_Print("No viewthing on map\n");
1719 void Host_Viewmodel_f (void)
1728 e = FindViewthing ();
1733 m = Mod_ForName (Cmd_Argv(1), false, true, false);
1734 if (!m || !m->loaded || !m->Draw)
1736 Con_Printf("viewmodel: can't load %s\n", Cmd_Argv(1));
1740 e->fields.server->frame = 0;
1741 cl.model_precache[(int)e->fields.server->modelindex] = m;
1749 void Host_Viewframe_f (void)
1759 e = FindViewthing ();
1763 m = cl.model_precache[(int)e->fields.server->modelindex];
1765 f = atoi(Cmd_Argv(1));
1766 if (f >= m->numframes)
1769 e->fields.server->frame = f;
1773 void PrintFrameName (model_t *m, int frame)
1776 Con_Printf("frame %i: %s\n", frame, m->animscenes[frame].name);
1778 Con_Printf("frame %i\n", frame);
1786 void Host_Viewnext_f (void)
1795 e = FindViewthing ();
1799 m = cl.model_precache[(int)e->fields.server->modelindex];
1801 e->fields.server->frame = e->fields.server->frame + 1;
1802 if (e->fields.server->frame >= m->numframes)
1803 e->fields.server->frame = m->numframes - 1;
1805 PrintFrameName (m, e->fields.server->frame);
1813 void Host_Viewprev_f (void)
1822 e = FindViewthing ();
1827 m = cl.model_precache[(int)e->fields.server->modelindex];
1829 e->fields.server->frame = e->fields.server->frame - 1;
1830 if (e->fields.server->frame < 0)
1831 e->fields.server->frame = 0;
1833 PrintFrameName (m, e->fields.server->frame);
1837 ===============================================================================
1841 ===============================================================================
1850 void Host_Startdemos_f (void)
1854 if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-demolooponly"))
1860 Con_Printf("Max %i demos in demoloop\n", MAX_DEMOS);
1863 Con_Printf("%i demo(s) in loop\n", c);
1865 for (i=1 ; i<c+1 ; i++)
1866 strlcpy (cls.demos[i-1], Cmd_Argv(i), sizeof (cls.demos[i-1]));
1868 // LordHavoc: clear the remaining slots
1869 for (;i <= MAX_DEMOS;i++)
1870 cls.demos[i-1][0] = 0;
1872 if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1886 Return to looping demos
1889 void Host_Demos_f (void)
1891 if (cls.state == ca_dedicated)
1893 if (cls.demonum == -1)
1903 Return to looping demos
1906 void Host_Stopdemo_f (void)
1908 if (!cls.demoplayback)
1911 Host_ShutdownServer ();
1914 void Host_SendCvar_f (void)
1922 if(!(c = Cvar_FindVar(Cmd_Argv(1))))
1924 if (cls.state != ca_dedicated)
1925 Cmd_ForwardStringToServer(va("sentcvar %s %s\n", c->name, c->string));
1926 if(!sv.active)// || !SV_ParseClientCommandQC)
1930 if (cls.state != ca_dedicated)
1934 for(;i<svs.maxclients;i++)
1935 if(svs.clients[i].active && svs.clients[i].netconnection)
1937 host_client = &svs.clients[i];
1938 Host_ClientCommands(va("sendcvar %s\n", c->name));
1943 static void MaxPlayers_f(void)
1947 if (Cmd_Argc() != 2)
1949 Con_Printf("\"maxplayers\" is \"%u\"\n", svs.maxclients);
1955 Con_Print("maxplayers can not be changed while a server is running.\n");
1959 n = atoi(Cmd_Argv(1));
1960 n = bound(1, n, MAX_SCOREBOARD);
1961 Con_Printf("\"maxplayers\" set to \"%u\"\n", n);
1964 Mem_Free(svs.clients);
1966 svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
1968 Cvar_Set ("deathmatch", "0");
1970 Cvar_Set ("deathmatch", "1");
1973 //=============================================================================
1975 // QuakeWorld commands
1978 =====================
1981 Send the rest of the command line over as
1982 an unconnected command.
1983 =====================
1985 void Host_Rcon_f (void) // credit: taken from QuakeWorld
1989 lhnetsocket_t *mysocket;
1991 if (!rcon_password.string || !rcon_password.string[0])
1993 Con_Printf ("You must set rcon_password before issuing an rcon command.\n");
1997 for (i = 0;rcon_password.string[i];i++)
1999 if (rcon_password.string[i] <= ' ')
2001 Con_Printf("rcon_password is not allowed to have any whitespace.\n");
2007 to = cls.netcon->peeraddress;
2010 if (!rcon_address.integer || !rcon_address.string[0])
2012 Con_Printf ("You must either be connected, or set the rcon_address cvar to issue rcon commands\n");
2015 LHNETADDRESS_FromString(&to, rcon_address.string, sv_netport.integer);
2017 mysocket = NetConn_ChooseClientSocketForAddress(&to);
2020 // simply put together the rcon packet and send it
2021 NetConn_WriteString(mysocket, va("\377\377\377\377rcon %s %s", rcon_password.string, Cmd_Args()), &to);
2026 ====================
2029 user <name or userid>
2031 Dump userdata / masterdata for a user
2032 ====================
2034 void Host_User_f (void) // credit: taken from QuakeWorld
2039 if (Cmd_Argc() != 2)
2041 Con_Printf ("Usage: user <username / userid>\n");
2045 uid = atoi(Cmd_Argv(1));
2047 for (i = 0;i < cl.maxclients;i++)
2049 if (!cl.scores[i].name[0])
2051 if (cl.scores[i].qw_userid == uid || !strcasecmp(cl.scores[i].name, Cmd_Argv(1)))
2053 InfoString_Print(cl.scores[i].qw_userinfo);
2057 Con_Printf ("User not in server.\n");
2061 ====================
2064 Dump userids for all current players
2065 ====================
2067 void Host_Users_f (void) // credit: taken from QuakeWorld
2073 Con_Printf ("userid frags name\n");
2074 Con_Printf ("------ ----- ----\n");
2075 for (i = 0;i < cl.maxclients;i++)
2077 if (cl.scores[i].name[0])
2079 Con_Printf ("%6i %4i %s\n", cl.scores[i].qw_userid, cl.scores[i].frags, cl.scores[i].name);
2084 Con_Printf ("%i total users\n", c);
2089 Host_FullServerinfo_f
2091 Sent by server when serverinfo changes
2094 // TODO: shouldn't this be a cvar instead?
2095 void Host_FullServerinfo_f (void) // credit: taken from QuakeWorld
2098 if (Cmd_Argc() != 2)
2100 Con_Printf ("usage: fullserverinfo <complete info string>\n");
2104 strlcpy (cl.qw_serverinfo, Cmd_Argv(1), sizeof(cl.qw_serverinfo));
2105 InfoString_GetValue(cl.qw_serverinfo, "teamplay", temp, sizeof(temp));
2106 cl.qw_teamplay = atoi(temp);
2113 Allow clients to change userinfo
2117 void Host_FullInfo_f (void) // credit: taken from QuakeWorld
2124 if (Cmd_Argc() != 2)
2126 Con_Printf ("fullinfo <complete info string>\n");
2136 while (*s && *s != '\\')
2142 Con_Printf ("MISSING VALUE\n");
2148 while (*s && *s != '\\')
2155 if (!strcasecmp(key, "pmodel") || !strcasecmp(key, "emodel"))
2160 Con_Printf("Can't set star-key \"%s\" to \"%s\"\n", key, value);
2164 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), key, value);
2172 Allow clients to change userinfo
2175 void Host_SetInfo_f (void) // credit: taken from QuakeWorld
2177 if (Cmd_Argc() == 1)
2179 InfoString_Print(cls.userinfo);
2182 if (Cmd_Argc() != 3)
2184 Con_Printf ("usage: setinfo [ <key> <value> ]\n");
2187 if (!strcasecmp(Cmd_Argv(1), "pmodel") || !strcasecmp(Cmd_Argv(1), "emodel"))
2189 if (Cmd_Argv(1)[0] == '*')
2191 Con_Printf("Can't set star-key \"%s\" to \"%s\"\n", Cmd_Argv(1), Cmd_Argv(2));
2194 InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), Cmd_Argv(1), Cmd_Argv(2));
2195 if (cls.state == ca_connected)
2196 Cmd_ForwardToServer ();
2200 ====================
2203 packet <destination> <contents>
2205 Contents allows \n escape character
2206 ====================
2208 void Host_Packet_f (void) // credit: taken from QuakeWorld
2214 lhnetaddress_t address;
2215 lhnetsocket_t *mysocket;
2217 if (Cmd_Argc() != 3)
2219 Con_Printf ("packet <destination> <contents>\n");
2223 if (!LHNETADDRESS_FromString (&address, Cmd_Argv(1), sv_netport.integer))
2225 Con_Printf ("Bad address\n");
2231 send[0] = send[1] = send[2] = send[3] = 0xff;
2233 l = (int)strlen (in);
2234 for (i=0 ; i<l ; i++)
2236 if (out >= send + sizeof(send) - 1)
2238 if (in[i] == '\\' && in[i+1] == 'n')
2243 else if (in[i] == '\\' && in[i+1] == '0')
2248 else if (in[i] == '\\' && in[i+1] == 't')
2253 else if (in[i] == '\\' && in[i+1] == 'r')
2258 else if (in[i] == '\\' && in[i+1] == '"')
2267 mysocket = NetConn_ChooseClientSocketForAddress(&address);
2269 NetConn_Write(mysocket, send, out - send, &address);
2272 //=============================================================================
2279 void Host_InitCommands (void)
2281 strcpy(cls.userinfo, "\\name\\player\\team\\none\\topcolor\\0\\bottomcolor\\0\\rate\\10000\\msg\\1\\*ver\\dp");
2283 Cmd_AddCommand ("status", Host_Status_f, "print server status information");
2284 Cmd_AddCommand ("quit", Host_Quit_f, "quit the game");
2285 if (gamemode == GAME_NEHAHRA)
2287 Cmd_AddCommand ("max", Host_God_f, "god mode (invulnerability)");
2288 Cmd_AddCommand ("monster", Host_Notarget_f, "notarget mode (monsters do not see you)");
2289 Cmd_AddCommand ("scrag", Host_Fly_f, "fly mode (flight)");
2290 Cmd_AddCommand ("wraith", Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
2291 Cmd_AddCommand ("gimme", Host_Give_f, "alter inventory");
2295 Cmd_AddCommand ("god", Host_God_f, "god mode (invulnerability)");
2296 Cmd_AddCommand ("notarget", Host_Notarget_f, "notarget mode (monsters do not see you)");
2297 Cmd_AddCommand ("fly", Host_Fly_f, "fly mode (flight)");
2298 Cmd_AddCommand ("noclip", Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
2299 Cmd_AddCommand ("give", Host_Give_f, "alter inventory");
2301 Cmd_AddCommand ("map", Host_Map_f, "kick everyone off the server and start a new level");
2302 Cmd_AddCommand ("restart", Host_Restart_f, "restart current level");
2303 Cmd_AddCommand ("changelevel", Host_Changelevel_f, "change to another level, bringing along all connected clients");
2304 Cmd_AddCommand ("connect", Host_Connect_f, "connect to a server by IP address or hostname");
2305 Cmd_AddCommand ("reconnect", Host_Reconnect_f, "reset signon level in preparation for a new level (do not use)");
2306 Cmd_AddCommand ("version", Host_Version_f, "print engine version");
2307 Cmd_AddCommand ("say", Host_Say_f, "send a chat message to everyone on the server");
2308 Cmd_AddCommand ("say_team", Host_Say_Team_f, "send a chat message to your team on the server");
2309 Cmd_AddCommand ("tell", Host_Tell_f, "send a chat message to only one person on the server");
2310 Cmd_AddCommand ("kill", Host_Kill_f, "die instantly");
2311 Cmd_AddCommand ("pause", Host_Pause_f, "pause the game (if the server allows pausing)");
2312 Cmd_AddCommand ("kick", Host_Kick_f, "kick a player off the server by number or name");
2313 Cmd_AddCommand ("ping", Host_Ping_f, "print ping times of all players on the server");
2314 Cmd_AddCommand ("load", Host_Loadgame_f, "load a saved game file");
2315 Cmd_AddCommand ("save", Host_Savegame_f, "save the game to a file");
2317 Cmd_AddCommand ("startdemos", Host_Startdemos_f, "start playing back the selected demos sequentially (used at end of startup script)");
2318 Cmd_AddCommand ("demos", Host_Demos_f, "restart looping demos defined by the last startdemos command");
2319 Cmd_AddCommand ("stopdemo", Host_Stopdemo_f, "stop playing or recording demo (like stop command) and return to looping demos");
2321 Cmd_AddCommand ("viewmodel", Host_Viewmodel_f, "change model of viewthing entity in current level");
2322 Cmd_AddCommand ("viewframe", Host_Viewframe_f, "change animation frame of viewthing entity in current level");
2323 Cmd_AddCommand ("viewnext", Host_Viewnext_f, "change to next animation frame of viewthing entity in current level");
2324 Cmd_AddCommand ("viewprev", Host_Viewprev_f, "change to previous animation frame of viewthing entity in current level");
2326 Cvar_RegisterVariable (&cl_name);
2327 Cmd_AddCommand ("name", Host_Name_f, "change your player name");
2328 Cvar_RegisterVariable (&cl_color);
2329 Cmd_AddCommand ("color", Host_Color_f, "change your player shirt and pants colors");
2330 Cvar_RegisterVariable (&cl_rate);
2331 Cmd_AddCommand ("rate", Host_Rate_f, "change your network connection speed");
2332 if (gamemode == GAME_NEHAHRA)
2334 Cvar_RegisterVariable (&cl_pmodel);
2335 Cmd_AddCommand ("pmodel", Host_PModel_f, "change your player model choice (Nehahra specific)");
2338 // BLACK: This isnt game specific anymore (it was GAME_NEXUIZ at first)
2339 Cvar_RegisterVariable (&cl_playermodel);
2340 Cmd_AddCommand ("playermodel", Host_Playermodel_f, "change your player model");
2341 Cvar_RegisterVariable (&cl_playerskin);
2342 Cmd_AddCommand ("playerskin", Host_Playerskin_f, "change your player skin number");
2344 Cmd_AddCommand ("prespawn", Host_PreSpawn_f, "signon 1 (client acknowledges that server information has been received)");
2345 Cmd_AddCommand ("spawn", Host_Spawn_f, "signon 2 (client has sent player information, and is asking server to send scoreboard rankings)");
2346 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)");
2347 Cmd_AddCommand ("maxplayers", MaxPlayers_f, "sets limit on how many players (or bots) may be connected to the server at once");
2349 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]
2351 Cvar_RegisterVariable (&rcon_password);
2352 Cvar_RegisterVariable (&rcon_address);
2353 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)");
2354 Cmd_AddCommand ("user", Host_User_f, "prints additional information about a player number or name on the scoreboard");
2355 Cmd_AddCommand ("users", Host_Users_f, "prints additional information about all players on the scoreboard");
2356 Cmd_AddCommand ("fullserverinfo", Host_FullServerinfo_f, "internal use only, sent by server to client to update client's local copy of serverinfo string");
2357 Cmd_AddCommand ("fullinfo", Host_FullInfo_f, "allows client to modify their userinfo");
2358 Cmd_AddCommand ("setinfo", Host_SetInfo_f, "modifies your userinfo");
2359 Cmd_AddCommand ("packet", Host_Packet_f, "send a packet to the specified address:port containing a text string");
2361 Cvar_RegisterVariable(&sv_cheats);