2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 cvar_t sv_cheats = {0, "sv_cheats", "0", "enables cheat commands in any game, and cheat impulses in dpmod"};
26 cvar_t rcon_password = {CVAR_PRIVATE, "rcon_password", "", "password to authenticate rcon commands"};
27 cvar_t rcon_address = {0, "rcon_address", "", "server address to send rcon commands to (when not connected to a server)"};
28 cvar_t team = {CVAR_USERINFO | CVAR_SAVE, "team", "none", "QW team (4 character limit, example: blue)"};
29 cvar_t skin = {CVAR_USERINFO | CVAR_SAVE, "skin", "", "QW player skin name (example: base)"};
30 cvar_t noaim = {CVAR_USERINFO | CVAR_SAVE, "noaim", "1", "QW option to disable vertical autoaim"};
31 qboolean allowcheats = false;
39 void Host_Quit_f (void)
50 void Host_Status_f (void)
53 int seconds, minutes, hours = 0, j, players;
54 void (*print) (const char *fmt, ...);
56 if (cmd_source == src_command)
58 // if running a client, try to send over network so the client's status report parser will see the report
59 if (cls.state == ca_connected)
61 Cmd_ForwardToServer ();
67 print = SV_ClientPrintf;
72 for (players = 0, j = 0;j < svs.maxclients;j++)
73 if (svs.clients[j].active)
75 print ("host: %s\n", Cvar_VariableString ("hostname"));
76 print ("version: %s build %s\n", gamename, buildstring);
77 print ("protocol: %i (%s)\n", Protocol_NumberForEnum(sv.protocol), Protocol_NameForEnum(sv.protocol));
78 print ("map: %s\n", sv.name);
79 print ("players: %i active (%i max)\n\n", players, svs.maxclients);
80 for (j = 0, client = svs.clients;j < svs.maxclients;j++, client++)
84 seconds = (int)(realtime - client->connecttime);
85 minutes = seconds / 60;
88 seconds -= (minutes * 60);
91 minutes -= (hours * 60);
95 print ("#%-3u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->fields.server->frags, hours, minutes, seconds);
96 print (" %s\n", client->netconnection ? client->netconnection->address : "botclient");
105 Sets client to godmode
108 void Host_God_f (void)
110 if (cmd_source == src_command)
112 Cmd_ForwardToServer ();
118 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
122 host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags ^ FL_GODMODE;
123 if (!((int)host_client->edict->fields.server->flags & FL_GODMODE) )
124 SV_ClientPrint("godmode OFF\n");
126 SV_ClientPrint("godmode ON\n");
129 void Host_Notarget_f (void)
131 if (cmd_source == src_command)
133 Cmd_ForwardToServer ();
139 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
143 host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags ^ FL_NOTARGET;
144 if (!((int)host_client->edict->fields.server->flags & FL_NOTARGET) )
145 SV_ClientPrint("notarget OFF\n");
147 SV_ClientPrint("notarget ON\n");
150 qboolean noclip_anglehack;
152 void Host_Noclip_f (void)
154 if (cmd_source == src_command)
156 Cmd_ForwardToServer ();
162 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
166 if (host_client->edict->fields.server->movetype != MOVETYPE_NOCLIP)
168 noclip_anglehack = true;
169 host_client->edict->fields.server->movetype = MOVETYPE_NOCLIP;
170 SV_ClientPrint("noclip ON\n");
174 noclip_anglehack = false;
175 host_client->edict->fields.server->movetype = MOVETYPE_WALK;
176 SV_ClientPrint("noclip OFF\n");
184 Sets client to flymode
187 void Host_Fly_f (void)
189 if (cmd_source == src_command)
191 Cmd_ForwardToServer ();
197 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
201 if (host_client->edict->fields.server->movetype != MOVETYPE_FLY)
203 host_client->edict->fields.server->movetype = MOVETYPE_FLY;
204 SV_ClientPrint("flymode ON\n");
208 host_client->edict->fields.server->movetype = MOVETYPE_WALK;
209 SV_ClientPrint("flymode OFF\n");
220 void Host_Pings_f (void); // called by Host_Ping_f
221 void Host_Ping_f (void)
225 void (*print) (const char *fmt, ...);
227 if (cmd_source == src_command)
229 // if running a client, try to send over network so the client's ping report parser will see the report
230 if (cls.state == ca_connected)
232 Cmd_ForwardToServer ();
238 print = SV_ClientPrintf;
243 print("Client ping times:\n");
244 for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
248 print("%4i %s\n", (int)floor(client->ping*1000+0.5), client->name);
251 // now call the Pings command also, which will send a report that contains packet loss for the scoreboard (as well as a simpler ping report)
256 ===============================================================================
260 ===============================================================================
264 ======================
269 command from the console. Active clients are kicked off.
270 ======================
272 void Host_Map_f (void)
274 char level[MAX_QPATH];
278 Con_Print("map <levelname> : start a new game (kicks off all players)\n");
282 if (cmd_source != src_command)
285 cls.demonum = -1; // stop demo loop in case this fails
288 Host_ShutdownServer();
293 svs.serverflags = 0; // haven't completed an episode yet
294 allowcheats = sv_cheats.integer != 0;
295 strcpy(level, Cmd_Argv(1));
296 SV_SpawnServer(level);
297 if (sv.active && cls.state == ca_disconnected)
298 CL_EstablishConnection("local:1");
300 #ifdef AUTODEMO_BROKEN
301 // if cl_autodemo is set, automatically start recording a demo if one isn't being recorded already
302 if (cl_autodemo.integer && !cls.demorecording)
304 char demofile[MAX_OSPATH];
306 dpsnprintf (demofile, sizeof(demofile), "%s_%s.dem", Sys_TimeString (cl_autodemo_nameformat.string), level);
308 Con_Printf ("Recording to %s.\n", demofile);
310 cls.demofile = FS_Open (demofile, "wb", false, false);
314 FS_Printf (cls.demofile, "%i\n", cls.forcetrack);
317 Con_Print ("ERROR: couldn't open.\n");
319 cls.demorecording = true;
328 Goes to a new map, taking all clients along
331 void Host_Changelevel_f (void)
333 char level[MAX_QPATH];
337 Con_Print("changelevel <levelname> : continue game on a new level\n");
345 if (cmd_source != src_command)
352 SV_SaveSpawnparms ();
354 allowcheats = sv_cheats.integer != 0;
355 strcpy(level, Cmd_Argv(1));
356 SV_SpawnServer(level);
357 if (sv.active && cls.state == ca_disconnected)
358 CL_EstablishConnection("local:1");
365 Restarts the current server for a dead player
368 void Host_Restart_f (void)
370 char mapname[MAX_QPATH];
374 Con_Print("restart : restart current level\n");
379 Con_Print("Only the server may restart\n");
382 if (cmd_source != src_command)
388 allowcheats = sv_cheats.integer != 0;
389 strcpy(mapname, sv.name);
390 SV_SpawnServer(mapname);
391 if (sv.active && cls.state == ca_disconnected)
392 CL_EstablishConnection("local:1");
399 This command causes the client to wait for the signon messages again.
400 This is sent just before a server changes levels
403 void Host_Reconnect_f (void)
405 if (cls.protocol == PROTOCOL_QUAKEWORLD)
407 if (cls.qw_downloadmemory) // don't change when downloading
414 if (cls.state == ca_connected && cls.signon < SIGNONS)
416 Con_Printf("reconnecting...\n");
417 MSG_WriteChar(&cls.netcon->message, qw_clc_stringcmd);
418 MSG_WriteString(&cls.netcon->message, "new");
423 // if we have connected to a server recently, the userinfo
424 // will still contain its IP address, so get the address...
425 InfoString_GetValue(cls.userinfo, "*ip", temp, sizeof(temp));
427 CL_EstablishConnection(temp);
429 Con_Printf("Reconnect to what server? (you have not connected to a server yet)\n");
437 Con_Print("reconnect : wait for signon messages again\n");
442 Con_Print("reconnect: no signon, ignoring reconnect\n");
445 cls.signon = 0; // need new connection messages
450 =====================
453 User command to connect to server
454 =====================
456 void Host_Connect_f (void)
460 Con_Print("connect <serveraddress> : connect to a multiplayer game\n");
463 CL_EstablishConnection(Cmd_Argv(1));
468 ===============================================================================
472 ===============================================================================
475 #define SAVEGAME_VERSION 5
481 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
484 void Host_SavegameComment (char *text)
489 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
491 // LordHavoc: added min() to prevent overflow
492 memcpy (text, cl.levelname, min(strlen(cl.levelname), SAVEGAME_COMMENT_LENGTH));
493 sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
494 memcpy (text+22, kills, strlen(kills));
495 // convert space to _ to make stdio happy
496 // LordHavoc: convert control characters to _ as well
497 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
500 text[SAVEGAME_COMMENT_LENGTH] = '\0';
509 void Host_Savegame_f (void)
511 char name[MAX_QPATH];
514 char comment[SAVEGAME_COMMENT_LENGTH+1];
516 if (cmd_source != src_command)
519 if (cls.state != ca_connected || !sv.active)
521 Con_Print("Not playing a local game.\n");
527 Con_Print("Can't save in intermission.\n");
531 for (i = 0;i < svs.maxclients;i++)
533 if (svs.clients[i].active)
537 Con_Print("Can't save multiplayer games.\n");
540 if (svs.clients[i].edict->fields.server->deadflag)
542 Con_Print("Can't savegame with a dead player\n");
550 Con_Print("save <savename> : save a game\n");
554 if (strstr(Cmd_Argv(1), ".."))
556 Con_Print("Relative pathnames are not allowed.\n");
560 strlcpy (name, Cmd_Argv(1), sizeof (name));
561 FS_DefaultExtension (name, ".sav", sizeof (name));
563 Con_Printf("Saving game to %s...\n", name);
564 f = FS_Open (name, "wb", false, false);
567 Con_Print("ERROR: couldn't open.\n");
571 FS_Printf(f, "%i\n", SAVEGAME_VERSION);
572 Host_SavegameComment (comment);
573 FS_Printf(f, "%s\n", comment);
574 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
575 FS_Printf(f, "%f\n", svs.clients[0].spawn_parms[i]);
576 FS_Printf(f, "%d\n", current_skill);
577 FS_Printf(f, "%s\n", sv.name);
578 FS_Printf(f, "%f\n",sv.time);
580 // write the light styles
581 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
583 if (sv.lightstyles[i][0])
584 FS_Printf(f, "%s\n", sv.lightstyles[i]);
591 PRVM_ED_WriteGlobals (f);
592 for (i=0 ; i<prog->num_edicts ; i++)
593 PRVM_ED_Write (f, PRVM_EDICT_NUM(i));
598 Con_Print("done.\n");
607 void Host_Loadgame_f (void)
609 char filename[MAX_QPATH];
610 char mapname[MAX_QPATH];
620 float spawn_parms[NUM_SPAWN_PARMS];
622 if (cmd_source != src_command)
627 Con_Print("load <savename> : load a game\n");
631 strcpy (filename, Cmd_Argv(1));
632 FS_DefaultExtension (filename, ".sav", sizeof (filename));
634 Con_Printf("Loading game from %s...\n", filename);
636 cls.demonum = -1; // stop demo loop in case this fails
638 t = text = (char *)FS_LoadFile (filename, tempmempool, false, NULL);
641 Con_Print("ERROR: couldn't open.\n");
646 COM_ParseTokenConsole(&t);
647 version = atoi(com_token);
648 if (version != SAVEGAME_VERSION)
651 Con_Printf("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
656 // this is a little hard to parse, as : is a separator in COM_ParseToken,
657 // so use the console parser instead
658 COM_ParseTokenConsole(&t);
660 for (i = 0;i < NUM_SPAWN_PARMS;i++)
662 COM_ParseTokenConsole(&t);
663 spawn_parms[i] = atof(com_token);
666 COM_ParseTokenConsole(&t);
667 // this silliness is so we can load 1.06 save files, which have float skill values
668 current_skill = (int)(atof(com_token) + 0.5);
669 Cvar_SetValue ("skill", (float)current_skill);
672 COM_ParseTokenConsole(&t);
673 strcpy (mapname, com_token);
676 COM_ParseTokenConsole(&t);
677 time = atof(com_token);
679 allowcheats = sv_cheats.integer != 0;
681 SV_SpawnServer (mapname);
685 Con_Print("Couldn't load map\n");
688 sv.paused = true; // pause until all clients connect
691 // load the light styles
693 for (i = 0;i < MAX_LIGHTSTYLES;i++)
697 COM_ParseTokenConsole(&t);
698 // if this is a 64 lightstyle savegame produced by Quake, stop now
699 // we have to check this because darkplaces saves 256 lightstyle savegames
700 if (com_token[0] == '{')
705 strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i]));
708 // now skip everything before the first opening brace
709 // (this is for forward compatibility, so that older versions (at
710 // least ones with this fix) can load savegames with extra data before the
711 // first brace, as might be produced by a later engine version)
715 COM_ParseTokenConsole(&t);
716 if (com_token[0] == '{')
723 // load the edicts out of the savegame file
730 while (COM_ParseTokenConsole(&t))
731 if (!strcmp(com_token, "}"))
733 if (!COM_ParseTokenConsole(&start))
738 if (strcmp(com_token,"{"))
741 Host_Error ("First token isn't a brace");
746 // parse the global vars
747 PRVM_ED_ParseGlobals (start);
752 if (entnum >= MAX_EDICTS)
755 Host_Error("Host_PerformLoadGame: too many edicts in save file (reached MAX_EDICTS %i)", MAX_EDICTS);
757 while (entnum >= prog->max_edicts)
758 //SV_IncreaseEdicts();
759 PRVM_MEM_IncreaseEdicts();
760 ent = PRVM_EDICT_NUM(entnum);
761 memset (ent->fields.server, 0, prog->progs->entityfields * 4);
762 ent->priv.server->free = false;
763 PRVM_ED_ParseEdict (start, ent);
765 // link it into the bsp tree
766 if (!ent->priv.server->free)
767 SV_LinkEdict (ent, false);
774 prog->num_edicts = entnum;
777 for (i = 0;i < NUM_SPAWN_PARMS;i++)
778 svs.clients[0].spawn_parms[i] = spawn_parms[i];
782 // make sure we're connected to loopback
783 if (cls.state == ca_disconnected || !(cls.state == ca_connected && cls.netcon != NULL && LHNETADDRESS_GetAddressType(&cls.netcon->peeraddress) == LHNETADDRESSTYPE_LOOP))
784 CL_EstablishConnection("local:1");
787 //============================================================================
790 ======================
792 ======================
794 cvar_t cl_name = {CVAR_SAVE, "_cl_name", "player", "internal storage cvar for current player name (changed by name command)"};
795 void Host_Name_f (void)
798 char newName[sizeof(host_client->name)];
800 if (Cmd_Argc () == 1)
802 Con_Printf("\"name\" is \"%s\"\n", cl_name.string);
806 if (Cmd_Argc () == 2)
807 strlcpy (newName, Cmd_Argv(1), sizeof (newName));
809 strlcpy (newName, Cmd_Args(), sizeof (newName));
811 for (i = 0, j = 0;newName[i];i++)
812 if (newName[i] != '\r' && newName[i] != '\n')
813 newName[j++] = newName[i];
816 if (cmd_source == src_command)
818 Cvar_Set ("_cl_name", newName);
819 CL_SetInfo("name", newName, true, false, false, false);
823 if (sv.time < host_client->nametime)
825 SV_ClientPrintf("You can't change name more than once every 5 seconds!\n");
829 host_client->nametime = sv.time + 5;
831 // point the string back at updateclient->name to keep it safe
832 strlcpy (host_client->name, newName, sizeof (host_client->name));
833 host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name);
834 if (strcmp(host_client->old_name, host_client->name))
836 if (host_client->spawned)
837 SV_BroadcastPrintf("%s changed name to %s\n", host_client->old_name, host_client->name);
838 strcpy(host_client->old_name, host_client->name);
839 // send notification to all clients
840 MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
841 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
842 MSG_WriteString (&sv.reliable_datagram, host_client->name);
847 ======================
849 ======================
851 cvar_t cl_playermodel = {CVAR_SAVE, "_cl_playermodel", "", "internal storage cvar for current player model in Nexuiz (changed by playermodel command)"};
852 // the old cl_playermodel in cl_main has been renamed to __cl_playermodel
853 void Host_Playermodel_f (void)
856 char newPath[sizeof(host_client->playermodel)];
858 if (Cmd_Argc () == 1)
860 Con_Printf("\"playermodel\" is \"%s\"\n", cl_playermodel.string);
864 if (Cmd_Argc () == 2)
865 strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
867 strlcpy (newPath, Cmd_Args(), sizeof (newPath));
869 for (i = 0, j = 0;newPath[i];i++)
870 if (newPath[i] != '\r' && newPath[i] != '\n')
871 newPath[j++] = newPath[i];
874 if (cmd_source == src_command)
876 Cvar_Set ("_cl_playermodel", newPath);
877 CL_SetInfo("playermodel", newPath, true, false, false, false);
882 if (sv.time < host_client->nametime)
884 SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
888 host_client->nametime = sv.time + 5;
891 // point the string back at updateclient->name to keep it safe
892 strlcpy (host_client->playermodel, newPath, sizeof (host_client->playermodel));
893 if( eval_playermodel )
894 PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PRVM_SetEngineString(host_client->playermodel);
895 if (strcmp(host_client->old_model, host_client->playermodel))
897 strcpy(host_client->old_model, host_client->playermodel);
898 /*// send notification to all clients
899 MSG_WriteByte (&sv.reliable_datagram, svc_updatepmodel);
900 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
901 MSG_WriteString (&sv.reliable_datagram, host_client->playermodel);*/
906 ======================
908 ======================
910 cvar_t cl_playerskin = {CVAR_SAVE, "_cl_playerskin", "", "internal storage cvar for current player skin in Nexuiz (changed by playerskin command)"};
911 void Host_Playerskin_f (void)
914 char newPath[sizeof(host_client->playerskin)];
916 if (Cmd_Argc () == 1)
918 Con_Printf("\"playerskin\" is \"%s\"\n", cl_playerskin.string);
922 if (Cmd_Argc () == 2)
923 strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
925 strlcpy (newPath, Cmd_Args(), sizeof (newPath));
927 for (i = 0, j = 0;newPath[i];i++)
928 if (newPath[i] != '\r' && newPath[i] != '\n')
929 newPath[j++] = newPath[i];
932 if (cmd_source == src_command)
934 Cvar_Set ("_cl_playerskin", newPath);
935 CL_SetInfo("playerskin", newPath, true, false, false, false);
940 if (sv.time < host_client->nametime)
942 SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
946 host_client->nametime = sv.time + 5;
949 // point the string back at updateclient->name to keep it safe
950 strlcpy (host_client->playerskin, newPath, sizeof (host_client->playerskin));
951 if( eval_playerskin )
952 PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string = PRVM_SetEngineString(host_client->playerskin);
953 if (strcmp(host_client->old_skin, host_client->playerskin))
955 //if (host_client->spawned)
956 // SV_BroadcastPrintf("%s changed skin to %s\n", host_client->name, host_client->playerskin);
957 strcpy(host_client->old_skin, host_client->playerskin);
958 /*// send notification to all clients
959 MSG_WriteByte (&sv.reliable_datagram, svc_updatepskin);
960 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
961 MSG_WriteString (&sv.reliable_datagram, host_client->playerskin);*/
965 void Host_Version_f (void)
967 Con_Printf("Version: %s build %s\n", gamename, buildstring);
970 void Host_Say(qboolean teamonly)
976 // LordHavoc: long say messages
978 qboolean fromServer = false;
980 if (cmd_source == src_command)
982 if (cls.state == ca_dedicated)
989 Cmd_ForwardToServer ();
997 if (!teamplay.integer)
1007 // note this uses the chat prefix \001
1009 dpsnprintf (text, sizeof(text), "\001%s" STRING_COLOR_DEFAULT_STR ": %s", host_client->name, p1);
1011 dpsnprintf (text, sizeof(text), "\001<%s" STRING_COLOR_DEFAULT_STR "> %s", hostname.string, p1);
1012 p2 = text + strlen(text);
1013 while ((const char *)p2 > (const char *)text && (p2[-1] == '\r' || p2[-1] == '\n' || (p2[-1] == '\"' && quoted)))
1015 if (p2[-1] == '\"' && quoted)
1020 strlcat(text, "\n", sizeof(text));
1022 // note: save is not a valid edict if fromServer is true
1024 for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
1025 if (host_client->spawned && (!teamonly || host_client->edict->fields.server->team == save->edict->fields.server->team))
1026 SV_ClientPrint(text);
1029 if (cls.state == ca_dedicated)
1030 Con_Print(&text[1]);
1034 void Host_Say_f(void)
1040 void Host_Say_Team_f(void)
1046 void Host_Tell_f(void)
1050 const char *p1, *p2;
1051 char text[MAX_INPUTLINE]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
1052 qboolean fromServer = false;
1054 if (cmd_source == src_command)
1056 if (cls.state == ca_dedicated)
1060 Cmd_ForwardToServer ();
1065 if (Cmd_Argc () < 3)
1068 // note this uses the chat prefix \001
1070 sprintf (text, "\001%s tells you: ", host_client->name);
1072 sprintf (text, "\001<%s tells you> ", hostname.string);
1075 p2 = p1 + strlen(p1);
1076 // remove the target name
1077 while (p1 < p2 && *p1 != ' ')
1079 while (p1 < p2 && *p1 == ' ')
1081 // remove trailing newlines
1082 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
1084 // remove quotes if present
1090 else if (fromServer)
1091 Con_Print("Host_Tell: missing end quote\n");
1093 SV_ClientPrint("Host_Tell: missing end quote\n");
1095 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
1097 for (j = (int)strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;)
1103 for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
1104 if (host_client->spawned && !strcasecmp(host_client->name, Cmd_Argv(1)))
1105 SV_ClientPrint(text);
1115 cvar_t cl_color = {CVAR_SAVE, "_cl_color", "0", "internal storage cvar for current player colors (changed by color command)"};
1116 void Host_Color(int changetop, int changebottom)
1118 int top, bottom, playercolor;
1120 func_t SV_ChangeTeam;
1122 // get top and bottom either from the provided values or the current values
1123 // (allows changing only top or bottom, or both at once)
1124 top = changetop >= 0 ? changetop : (cl_color.integer >> 4);
1125 bottom = changebottom >= 0 ? changebottom : cl_color.integer;
1129 // LordHavoc: allowing skin colormaps 14 and 15 by commenting this out
1135 playercolor = top*16 + bottom;
1137 if (cmd_source == src_command)
1139 Cvar_SetValueQuick(&cl_color, playercolor);
1141 CL_SetInfo("topcolor", va("%i", top), true, false, false, false);
1142 if (changebottom >= 0)
1143 CL_SetInfo("bottomcolor", va("%i", bottom), true, false, false, false);
1144 if (cls.protocol != PROTOCOL_QUAKEWORLD && cls.netcon)
1146 MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
1147 MSG_WriteString(&cls.netcon->message, va("color %i %i", top, bottom));
1152 if (cls.protocol == PROTOCOL_QUAKEWORLD)
1155 if (host_client->edict && (f = PRVM_ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - prog->functions)))
1157 Con_DPrint("Calling SV_ChangeTeam\n");
1158 prog->globals.server->time = sv.time;
1159 prog->globals.generic[OFS_PARM0] = playercolor;
1160 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1161 PRVM_ExecuteProgram (SV_ChangeTeam, "QC function SV_ChangeTeam is missing");
1166 if (host_client->edict)
1168 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_clientcolors)))
1169 val->_float = playercolor;
1170 host_client->edict->fields.server->team = bottom + 1;
1172 host_client->colors = playercolor;
1173 if (host_client->old_colors != host_client->colors)
1175 host_client->old_colors = host_client->colors;
1176 // send notification to all clients
1177 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
1178 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
1179 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
1184 void Host_Color_f(void)
1188 if (Cmd_Argc() == 1)
1190 Con_Printf("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15);
1191 Con_Print("color <0-15> [0-15]\n");
1195 if (Cmd_Argc() == 2)
1196 top = bottom = atoi(Cmd_Argv(1));
1199 top = atoi(Cmd_Argv(1));
1200 bottom = atoi(Cmd_Argv(2));
1202 Host_Color(top, bottom);
1205 void Host_TopColor_f(void)
1207 if (Cmd_Argc() == 1)
1209 Con_Printf("\"topcolor\" is \"%i\"\n", (cl_color.integer >> 4) & 15);
1210 Con_Print("topcolor <0-15>\n");
1214 Host_Color(atoi(Cmd_Argv(1)), -1);
1217 void Host_BottomColor_f(void)
1219 if (Cmd_Argc() == 1)
1221 Con_Printf("\"bottomcolor\" is \"%i\"\n", cl_color.integer & 15);
1222 Con_Print("bottomcolor <0-15>\n");
1226 Host_Color(-1, atoi(Cmd_Argv(1)));
1229 cvar_t cl_rate = {CVAR_SAVE, "_cl_rate", "10000", "internal storage cvar for current rate (changed by rate command)"};
1230 void Host_Rate_f(void)
1234 if (Cmd_Argc() != 2)
1236 Con_Printf("\"rate\" is \"%i\"\n", cl_rate.integer);
1237 Con_Print("rate <500-25000>\n");
1241 rate = atoi(Cmd_Argv(1));
1243 if (cmd_source == src_command)
1245 Cvar_SetValue ("_cl_rate", bound(NET_MINRATE, rate, NET_MAXRATE));
1246 CL_SetInfo("rate", va("%i", rate), true, false, false, false);
1250 host_client->rate = rate;
1258 void Host_Kill_f (void)
1260 if (cmd_source == src_command)
1262 Cmd_ForwardToServer ();
1266 if (host_client->edict->fields.server->health <= 0)
1268 SV_ClientPrint("Can't suicide -- already dead!\n");
1272 prog->globals.server->time = sv.time;
1273 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1274 PRVM_ExecuteProgram (prog->globals.server->ClientKill, "QC function ClientKill is missing");
1283 void Host_Pause_f (void)
1286 if (cmd_source == src_command)
1288 Cmd_ForwardToServer ();
1291 if (!pausable.integer)
1292 SV_ClientPrint("Pause not allowed.\n");
1296 SV_BroadcastPrintf("%s %spaused the game\n", host_client->name, sv.paused ? "" : "un");
1297 // send notification to all clients
1298 MSG_WriteByte(&sv.reliable_datagram, svc_setpause);
1299 MSG_WriteByte(&sv.reliable_datagram, sv.paused);
1304 ======================
1306 LordHavoc: only supported for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
1307 LordHavoc: correction, Mindcrime will be removing pmodel in the future, but it's still stuck here for compatibility.
1308 ======================
1310 cvar_t cl_pmodel = {CVAR_SAVE, "_cl_pmodel", "0", "internal storage cvar for current player model number in nehahra (changed by pmodel command)"};
1311 static void Host_PModel_f (void)
1316 if (Cmd_Argc () == 1)
1318 Con_Printf("\"pmodel\" is \"%s\"\n", cl_pmodel.string);
1321 i = atoi(Cmd_Argv(1));
1323 if (cmd_source == src_command)
1325 if (cl_pmodel.integer == i)
1327 Cvar_SetValue ("_cl_pmodel", i);
1328 if (cls.state == ca_connected)
1329 Cmd_ForwardToServer ();
1333 if (host_client->edict && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1337 //===========================================================================
1345 void Host_PreSpawn_f (void)
1347 if (cmd_source == src_command)
1349 Con_Print("prespawn is not valid from the console\n");
1353 if (host_client->spawned)
1355 Con_Print("prespawn not valid -- already spawned\n");
1359 if (host_client->netconnection)
1361 SZ_Write (&host_client->netconnection->message, sv.signon.data, sv.signon.cursize);
1362 MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
1363 MSG_WriteByte (&host_client->netconnection->message, 2);
1366 // reset the name change timer because the client will send name soon
1367 host_client->nametime = 0;
1375 void Host_Spawn_f (void)
1381 int stats[MAX_CL_STATS];
1383 if (cmd_source == src_command)
1385 Con_Print("spawn is not valid from the console\n");
1389 if (host_client->spawned)
1391 Con_Print("Spawn not valid -- already spawned\n");
1395 // reset name change timer again because they might want to change name
1396 // again in the first 5 seconds after connecting
1397 host_client->nametime = 0;
1399 // LordHavoc: moved this above the QC calls at FrikaC's request
1400 // LordHavoc: commented this out
1401 //if (host_client->netconnection)
1402 // SZ_Clear (&host_client->netconnection->message);
1404 // run the entrance script
1407 // loaded games are fully initialized already
1408 // if this is the last client to be connected, unpause
1411 if ((f = PRVM_ED_FindFunction ("RestoreGame")))
1412 if ((RestoreGame = (func_t)(f - prog->functions)))
1414 Con_DPrint("Calling RestoreGame\n");
1415 prog->globals.server->time = sv.time;
1416 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1417 PRVM_ExecuteProgram (RestoreGame, "QC function RestoreGame is missing");
1422 //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);
1424 // copy spawn parms out of the client_t
1425 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1426 (&prog->globals.server->parm1)[i] = host_client->spawn_parms[i];
1428 // call the spawn function
1429 host_client->clientconnectcalled = true;
1430 prog->globals.server->time = sv.time;
1431 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1432 PRVM_ExecuteProgram (prog->globals.server->ClientConnect, "QC function ClientConnect is missing");
1434 if ((Sys_DoubleTime() - host_client->connecttime) <= sv.time)
1435 Con_Printf("%s entered the game\n", host_client->name);
1437 PRVM_ExecuteProgram (prog->globals.server->PutClientInServer, "QC function PutClientInServer is missing");
1440 if (!host_client->netconnection)
1443 // send time of update
1444 MSG_WriteByte (&host_client->netconnection->message, svc_time);
1445 MSG_WriteFloat (&host_client->netconnection->message, sv.time);
1447 // send all current names, colors, and frag counts
1448 for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
1450 if (!client->active)
1452 MSG_WriteByte (&host_client->netconnection->message, svc_updatename);
1453 MSG_WriteByte (&host_client->netconnection->message, i);
1454 MSG_WriteString (&host_client->netconnection->message, client->name);
1455 MSG_WriteByte (&host_client->netconnection->message, svc_updatefrags);
1456 MSG_WriteByte (&host_client->netconnection->message, i);
1457 MSG_WriteShort (&host_client->netconnection->message, client->frags);
1458 MSG_WriteByte (&host_client->netconnection->message, svc_updatecolors);
1459 MSG_WriteByte (&host_client->netconnection->message, i);
1460 MSG_WriteByte (&host_client->netconnection->message, client->colors);
1463 // send all current light styles
1464 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1466 if (sv.lightstyles[i][0])
1468 MSG_WriteByte (&host_client->netconnection->message, svc_lightstyle);
1469 MSG_WriteByte (&host_client->netconnection->message, (char)i);
1470 MSG_WriteString (&host_client->netconnection->message, sv.lightstyles[i]);
1475 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1476 MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALSECRETS);
1477 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->total_secrets);
1479 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1480 MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALMONSTERS);
1481 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->total_monsters);
1483 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1484 MSG_WriteByte (&host_client->netconnection->message, STAT_SECRETS);
1485 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->found_secrets);
1487 MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1488 MSG_WriteByte (&host_client->netconnection->message, STAT_MONSTERS);
1489 MSG_WriteLong (&host_client->netconnection->message, (int)prog->globals.server->killed_monsters);
1492 // Never send a roll angle, because savegames can catch the server
1493 // in a state where it is expecting the client to correct the angle
1494 // and it won't happen if the game was just loaded, so you wind up
1495 // with a permanent head tilt
1498 MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
1499 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[0], sv.protocol);
1500 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[1], sv.protocol);
1501 MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
1502 sv.loadgame = false; // we're basically done with loading now
1506 MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
1507 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[0], sv.protocol);
1508 MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[1], sv.protocol);
1509 MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
1512 SV_WriteClientdataToMessage (host_client, host_client->edict, &host_client->netconnection->message, stats);
1514 MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
1515 MSG_WriteByte (&host_client->netconnection->message, 3);
1523 void Host_Begin_f (void)
1525 if (cmd_source == src_command)
1527 Con_Print("begin is not valid from the console\n");
1531 Curl_SendRequirements();
1533 host_client->spawned = true;
1536 //===========================================================================
1543 Kicks a user off of the server
1546 void Host_Kick_f (void)
1549 const char *message = NULL;
1552 qboolean byNumber = false;
1554 if (cmd_source != src_command || !sv.active)
1560 if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1562 i = (int)(atof(Cmd_Argv(2)) - 1);
1563 if (i < 0 || i >= svs.maxclients || !(host_client = svs.clients + i)->active)
1569 for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
1571 if (!host_client->active)
1573 if (strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1578 if (i < svs.maxclients)
1580 if (cmd_source == src_command)
1582 if (cls.state == ca_dedicated)
1585 who = cl_name.string;
1590 // can't kick yourself!
1591 if (host_client == save)
1596 message = Cmd_Args();
1597 COM_ParseTokenConsole(&message);
1600 message++; // skip the #
1601 while (*message == ' ') // skip white space
1603 message += strlen(Cmd_Argv(2)); // skip the number
1605 while (*message && *message == ' ')
1609 SV_ClientPrintf("Kicked by %s: %s\n", who, message);
1611 SV_ClientPrintf("Kicked by %s\n", who);
1612 SV_DropClient (false); // kicked
1620 ===============================================================================
1624 ===============================================================================
1632 void Host_Give_f (void)
1638 if (cmd_source == src_command)
1640 Cmd_ForwardToServer ();
1646 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
1651 v = atoi (Cmd_Argv(2));
1665 // MED 01/04/97 added hipnotic give stuff
1666 if (gamemode == GAME_HIPNOTIC)
1671 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_PROXIMITY_GUN;
1673 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | IT_GRENADE_LAUNCHER;
1675 else if (t[0] == '9')
1676 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_LASER_CANNON;
1677 else if (t[0] == '0')
1678 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_MJOLNIR;
1679 else if (t[0] >= '2')
1680 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
1685 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
1690 if (gamemode == GAME_ROGUE && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_shells1)))
1693 host_client->edict->fields.server->ammo_shells = v;
1696 if (gamemode == GAME_ROGUE)
1698 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_nails1)))
1701 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1702 host_client->edict->fields.server->ammo_nails = v;
1707 host_client->edict->fields.server->ammo_nails = v;
1711 if (gamemode == GAME_ROGUE)
1713 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_lava_nails);
1717 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1718 host_client->edict->fields.server->ammo_nails = v;
1723 if (gamemode == GAME_ROGUE)
1725 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_rockets1);
1729 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1730 host_client->edict->fields.server->ammo_rockets = v;
1735 host_client->edict->fields.server->ammo_rockets = v;
1739 if (gamemode == GAME_ROGUE)
1741 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_multi_rockets);
1745 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1746 host_client->edict->fields.server->ammo_rockets = v;
1751 host_client->edict->fields.server->health = v;
1754 if (gamemode == GAME_ROGUE)
1756 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_cells1);
1760 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1761 host_client->edict->fields.server->ammo_cells = v;
1766 host_client->edict->fields.server->ammo_cells = v;
1770 if (gamemode == GAME_ROGUE)
1772 val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_plasma);
1776 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1777 host_client->edict->fields.server->ammo_cells = v;
1784 prvm_edict_t *FindViewthing (void)
1789 for (i=0 ; i<prog->num_edicts ; i++)
1791 e = PRVM_EDICT_NUM(i);
1792 if (!strcmp (PRVM_GetString(e->fields.server->classname), "viewthing"))
1795 Con_Print("No viewthing on map\n");
1804 void Host_Viewmodel_f (void)
1813 e = FindViewthing ();
1818 m = Mod_ForName (Cmd_Argv(1), false, true, false);
1819 if (!m || !m->loaded || !m->Draw)
1821 Con_Printf("viewmodel: can't load %s\n", Cmd_Argv(1));
1825 e->fields.server->frame = 0;
1826 cl.model_precache[(int)e->fields.server->modelindex] = m;
1834 void Host_Viewframe_f (void)
1844 e = FindViewthing ();
1848 m = cl.model_precache[(int)e->fields.server->modelindex];
1850 f = atoi(Cmd_Argv(1));
1851 if (f >= m->numframes)
1854 e->fields.server->frame = f;
1858 void PrintFrameName (model_t *m, int frame)
1861 Con_Printf("frame %i: %s\n", frame, m->animscenes[frame].name);
1863 Con_Printf("frame %i\n", frame);
1871 void Host_Viewnext_f (void)
1880 e = FindViewthing ();
1884 m = cl.model_precache[(int)e->fields.server->modelindex];
1886 e->fields.server->frame = e->fields.server->frame + 1;
1887 if (e->fields.server->frame >= m->numframes)
1888 e->fields.server->frame = m->numframes - 1;
1890 PrintFrameName (m, (int)e->fields.server->frame);
1898 void Host_Viewprev_f (void)
1907 e = FindViewthing ();
1912 m = cl.model_precache[(int)e->fields.server->modelindex];
1914 e->fields.server->frame = e->fields.server->frame - 1;
1915 if (e->fields.server->frame < 0)
1916 e->fields.server->frame = 0;
1918 PrintFrameName (m, (int)e->fields.server->frame);
1922 ===============================================================================
1926 ===============================================================================
1935 void Host_Startdemos_f (void)
1939 if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-demolooponly"))
1945 Con_Printf("Max %i demos in demoloop\n", MAX_DEMOS);
1948 Con_Printf("%i demo(s) in loop\n", c);
1950 for (i=1 ; i<c+1 ; i++)
1951 strlcpy (cls.demos[i-1], Cmd_Argv(i), sizeof (cls.demos[i-1]));
1953 // LordHavoc: clear the remaining slots
1954 for (;i <= MAX_DEMOS;i++)
1955 cls.demos[i-1][0] = 0;
1957 if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1971 Return to looping demos
1974 void Host_Demos_f (void)
1976 if (cls.state == ca_dedicated)
1978 if (cls.demonum == -1)
1988 Return to looping demos
1991 void Host_Stopdemo_f (void)
1993 if (!cls.demoplayback)
1996 Host_ShutdownServer ();
1999 void Host_SendCvar_f (void)
2007 if(!(c = Cvar_FindVar(Cmd_Argv(1))) || (c->flags & CVAR_PRIVATE))
2009 if (cls.state != ca_dedicated)
2010 Cmd_ForwardStringToServer(va("sentcvar %s %s\n", c->name, c->string));
2011 if(!sv.active)// || !SV_ParseClientCommandQC)
2015 if (cls.state != ca_dedicated)
2019 for(;i<svs.maxclients;i++)
2020 if(svs.clients[i].active && svs.clients[i].netconnection)
2022 host_client = &svs.clients[i];
2023 Host_ClientCommands(va("sendcvar %s\n", c->name));
2028 static void MaxPlayers_f(void)
2032 if (Cmd_Argc() != 2)
2034 Con_Printf("\"maxplayers\" is \"%u\"\n", svs.maxclients);
2040 Con_Print("maxplayers can not be changed while a server is running.\n");
2044 n = atoi(Cmd_Argv(1));
2045 n = bound(1, n, MAX_SCOREBOARD);
2046 Con_Printf("\"maxplayers\" set to \"%u\"\n", n);
2049 Mem_Free(svs.clients);
2051 svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
2053 Cvar_Set ("deathmatch", "0");
2055 Cvar_Set ("deathmatch", "1");
2058 //=============================================================================
2060 // QuakeWorld commands
2063 =====================
2066 Send the rest of the command line over as
2067 an unconnected command.
2068 =====================
2070 void Host_Rcon_f (void) // credit: taken from QuakeWorld
2074 lhnetsocket_t *mysocket;
2076 if (!rcon_password.string || !rcon_password.string[0])
2078 Con_Printf ("You must set rcon_password before issuing an rcon command.\n");
2082 for (i = 0;rcon_password.string[i];i++)
2084 if (rcon_password.string[i] <= ' ')
2086 Con_Printf("rcon_password is not allowed to have any whitespace.\n");
2092 to = cls.netcon->peeraddress;
2095 if (!rcon_address.string[0])
2097 Con_Printf ("You must either be connected, or set the rcon_address cvar to issue rcon commands\n");
2100 LHNETADDRESS_FromString(&to, rcon_address.string, sv_netport.integer);
2102 mysocket = NetConn_ChooseClientSocketForAddress(&to);
2105 // simply put together the rcon packet and send it
2106 NetConn_WriteString(mysocket, va("\377\377\377\377rcon %s %s", rcon_password.string, Cmd_Args()), &to);
2111 ====================
2114 user <name or userid>
2116 Dump userdata / masterdata for a user
2117 ====================
2119 void Host_User_f (void) // credit: taken from QuakeWorld
2124 if (Cmd_Argc() != 2)
2126 Con_Printf ("Usage: user <username / userid>\n");
2130 uid = atoi(Cmd_Argv(1));
2132 for (i = 0;i < cl.maxclients;i++)
2134 if (!cl.scores[i].name[0])
2136 if (cl.scores[i].qw_userid == uid || !strcasecmp(cl.scores[i].name, Cmd_Argv(1)))
2138 InfoString_Print(cl.scores[i].qw_userinfo);
2142 Con_Printf ("User not in server.\n");
2146 ====================
2149 Dump userids for all current players
2150 ====================
2152 void Host_Users_f (void) // credit: taken from QuakeWorld
2158 Con_Printf ("userid frags name\n");
2159 Con_Printf ("------ ----- ----\n");
2160 for (i = 0;i < cl.maxclients;i++)
2162 if (cl.scores[i].name[0])
2164 Con_Printf ("%6i %4i %s\n", cl.scores[i].qw_userid, cl.scores[i].frags, cl.scores[i].name);
2169 Con_Printf ("%i total users\n", c);
2174 Host_FullServerinfo_f
2176 Sent by server when serverinfo changes
2179 // TODO: shouldn't this be a cvar instead?
2180 void Host_FullServerinfo_f (void) // credit: taken from QuakeWorld
2183 if (Cmd_Argc() != 2)
2185 Con_Printf ("usage: fullserverinfo <complete info string>\n");
2189 strlcpy (cl.qw_serverinfo, Cmd_Argv(1), sizeof(cl.qw_serverinfo));
2190 InfoString_GetValue(cl.qw_serverinfo, "teamplay", temp, sizeof(temp));
2191 cl.qw_teamplay = atoi(temp);
2198 Allow clients to change userinfo
2202 void Host_FullInfo_f (void) // credit: taken from QuakeWorld
2209 if (Cmd_Argc() != 2)
2211 Con_Printf ("fullinfo <complete info string>\n");
2221 while (*s && *s != '\\')
2227 Con_Printf ("MISSING VALUE\n");
2233 while (*s && *s != '\\')
2240 CL_SetInfo(key, value, false, false, false, false);
2248 Allow clients to change userinfo
2251 void Host_SetInfo_f (void) // credit: taken from QuakeWorld
2253 if (Cmd_Argc() == 1)
2255 InfoString_Print(cls.userinfo);
2258 if (Cmd_Argc() != 3)
2260 Con_Printf ("usage: setinfo [ <key> <value> ]\n");
2263 CL_SetInfo(Cmd_Argv(1), Cmd_Argv(2), true, false, false, false);
2267 ====================
2270 packet <destination> <contents>
2272 Contents allows \n escape character
2273 ====================
2275 void Host_Packet_f (void) // credit: taken from QuakeWorld
2281 lhnetaddress_t address;
2282 lhnetsocket_t *mysocket;
2284 if (Cmd_Argc() != 3)
2286 Con_Printf ("packet <destination> <contents>\n");
2290 if (!LHNETADDRESS_FromString (&address, Cmd_Argv(1), sv_netport.integer))
2292 Con_Printf ("Bad address\n");
2298 send[0] = send[1] = send[2] = send[3] = 0xff;
2300 l = (int)strlen (in);
2301 for (i=0 ; i<l ; i++)
2303 if (out >= send + sizeof(send) - 1)
2305 if (in[i] == '\\' && in[i+1] == 'n')
2310 else if (in[i] == '\\' && in[i+1] == '0')
2315 else if (in[i] == '\\' && in[i+1] == 't')
2320 else if (in[i] == '\\' && in[i+1] == 'r')
2325 else if (in[i] == '\\' && in[i+1] == '"')
2334 mysocket = NetConn_ChooseClientSocketForAddress(&address);
2336 NetConn_Write(mysocket, send, out - send, &address);
2340 ====================
2343 Send back ping and packet loss update for all current players to this player
2344 ====================
2346 void Host_Pings_f (void)
2348 int i, j, ping, packetloss;
2351 if (cmd_source == src_command)
2353 Cmd_ForwardToServer ();
2356 if (!host_client->netconnection)
2359 if (sv.protocol != PROTOCOL_QUAKEWORLD)
2361 MSG_WriteByte(&host_client->netconnection->message, svc_stufftext);
2362 MSG_WriteUnterminatedString(&host_client->netconnection->message, "pingplreport");
2364 for (i = 0;i < svs.maxclients;i++)
2367 if (svs.clients[i].netconnection)
2368 for (j = 0;j < 100;j++)
2369 packetloss += svs.clients[i].netconnection->packetlost[j];
2370 ping = (int)floor(svs.clients[i].ping*1000+0.5);
2371 ping = bound(0, ping, 9999);
2372 if (sv.protocol == PROTOCOL_QUAKEWORLD)
2374 // send qw_svc_updateping and qw_svc_updatepl messages
2375 MSG_WriteByte(&host_client->netconnection->message, qw_svc_updateping);
2376 MSG_WriteShort(&host_client->netconnection->message, ping);
2377 MSG_WriteByte(&host_client->netconnection->message, qw_svc_updatepl);
2378 MSG_WriteByte(&host_client->netconnection->message, packetloss);
2382 // write the string into the packet as multiple unterminated strings to avoid needing a local buffer
2383 dpsnprintf(temp, sizeof(temp), " %d %d", ping, packetloss);
2384 MSG_WriteUnterminatedString(&host_client->netconnection->message, temp);
2387 if (sv.protocol != PROTOCOL_QUAKEWORLD)
2388 MSG_WriteString(&host_client->netconnection->message, "\n");
2391 void Host_PingPLReport_f(void)
2395 if (l > cl.maxclients)
2397 for (i = 0;i < l;i++)
2399 cl.scores[i].qw_ping = atoi(Cmd_Argv(1+i*2));
2400 cl.scores[i].qw_packetloss = atoi(Cmd_Argv(1+i*2+1));
2404 //=============================================================================
2411 void Host_InitCommands (void)
2413 dpsnprintf(cls.userinfo, sizeof(cls.userinfo), "\\name\\player\\team\\none\\topcolor\\0\\bottomcolor\\0\\rate\\10000\\msg\\1\\noaim\\1\\*ver\\%s", engineversion);
2415 Cmd_AddCommand ("status", Host_Status_f, "print server status information");
2416 Cmd_AddCommand ("quit", Host_Quit_f, "quit the game");
2417 if (gamemode == GAME_NEHAHRA)
2419 Cmd_AddCommand ("max", Host_God_f, "god mode (invulnerability)");
2420 Cmd_AddCommand ("monster", Host_Notarget_f, "notarget mode (monsters do not see you)");
2421 Cmd_AddCommand ("scrag", Host_Fly_f, "fly mode (flight)");
2422 Cmd_AddCommand ("wraith", Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
2423 Cmd_AddCommand ("gimme", Host_Give_f, "alter inventory");
2427 Cmd_AddCommand ("god", Host_God_f, "god mode (invulnerability)");
2428 Cmd_AddCommand ("notarget", Host_Notarget_f, "notarget mode (monsters do not see you)");
2429 Cmd_AddCommand ("fly", Host_Fly_f, "fly mode (flight)");
2430 Cmd_AddCommand ("noclip", Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
2431 Cmd_AddCommand ("give", Host_Give_f, "alter inventory");
2433 Cmd_AddCommand ("map", Host_Map_f, "kick everyone off the server and start a new level");
2434 Cmd_AddCommand ("restart", Host_Restart_f, "restart current level");
2435 Cmd_AddCommand ("changelevel", Host_Changelevel_f, "change to another level, bringing along all connected clients");
2436 Cmd_AddCommand ("connect", Host_Connect_f, "connect to a server by IP address or hostname");
2437 Cmd_AddCommand ("reconnect", Host_Reconnect_f, "reset signon level in preparation for a new level (do not use)");
2438 Cmd_AddCommand ("version", Host_Version_f, "print engine version");
2439 Cmd_AddCommand ("say", Host_Say_f, "send a chat message to everyone on the server");
2440 Cmd_AddCommand ("say_team", Host_Say_Team_f, "send a chat message to your team on the server");
2441 Cmd_AddCommand ("tell", Host_Tell_f, "send a chat message to only one person on the server");
2442 Cmd_AddCommand ("kill", Host_Kill_f, "die instantly");
2443 Cmd_AddCommand ("pause", Host_Pause_f, "pause the game (if the server allows pausing)");
2444 Cmd_AddCommand ("kick", Host_Kick_f, "kick a player off the server by number or name");
2445 Cmd_AddCommand ("ping", Host_Ping_f, "print ping times of all players on the server");
2446 Cmd_AddCommand ("load", Host_Loadgame_f, "load a saved game file");
2447 Cmd_AddCommand ("save", Host_Savegame_f, "save the game to a file");
2449 Cmd_AddCommand ("startdemos", Host_Startdemos_f, "start playing back the selected demos sequentially (used at end of startup script)");
2450 Cmd_AddCommand ("demos", Host_Demos_f, "restart looping demos defined by the last startdemos command");
2451 Cmd_AddCommand ("stopdemo", Host_Stopdemo_f, "stop playing or recording demo (like stop command) and return to looping demos");
2453 Cmd_AddCommand ("viewmodel", Host_Viewmodel_f, "change model of viewthing entity in current level");
2454 Cmd_AddCommand ("viewframe", Host_Viewframe_f, "change animation frame of viewthing entity in current level");
2455 Cmd_AddCommand ("viewnext", Host_Viewnext_f, "change to next animation frame of viewthing entity in current level");
2456 Cmd_AddCommand ("viewprev", Host_Viewprev_f, "change to previous animation frame of viewthing entity in current level");
2458 Cvar_RegisterVariable (&cl_name);
2459 Cmd_AddCommand ("name", Host_Name_f, "change your player name");
2460 Cvar_RegisterVariable (&cl_color);
2461 Cmd_AddCommand ("color", Host_Color_f, "change your player shirt and pants colors");
2462 Cvar_RegisterVariable (&cl_rate);
2463 Cmd_AddCommand ("rate", Host_Rate_f, "change your network connection speed");
2464 if (gamemode == GAME_NEHAHRA)
2466 Cvar_RegisterVariable (&cl_pmodel);
2467 Cmd_AddCommand ("pmodel", Host_PModel_f, "change your player model choice (Nehahra specific)");
2470 // BLACK: This isnt game specific anymore (it was GAME_NEXUIZ at first)
2471 Cvar_RegisterVariable (&cl_playermodel);
2472 Cmd_AddCommand ("playermodel", Host_Playermodel_f, "change your player model");
2473 Cvar_RegisterVariable (&cl_playerskin);
2474 Cmd_AddCommand ("playerskin", Host_Playerskin_f, "change your player skin number");
2476 Cmd_AddCommand ("prespawn", Host_PreSpawn_f, "signon 1 (client acknowledges that server information has been received)");
2477 Cmd_AddCommand ("spawn", Host_Spawn_f, "signon 2 (client has sent player information, and is asking server to send scoreboard rankings)");
2478 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)");
2479 Cmd_AddCommand ("maxplayers", MaxPlayers_f, "sets limit on how many players (or bots) may be connected to the server at once");
2481 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]
2483 Cvar_RegisterVariable (&rcon_password);
2484 Cvar_RegisterVariable (&rcon_address);
2485 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)");
2486 Cmd_AddCommand ("user", Host_User_f, "prints additional information about a player number or name on the scoreboard");
2487 Cmd_AddCommand ("users", Host_Users_f, "prints additional information about all players on the scoreboard");
2488 Cmd_AddCommand ("fullserverinfo", Host_FullServerinfo_f, "internal use only, sent by server to client to update client's local copy of serverinfo string");
2489 Cmd_AddCommand ("fullinfo", Host_FullInfo_f, "allows client to modify their userinfo");
2490 Cmd_AddCommand ("setinfo", Host_SetInfo_f, "modifies your userinfo");
2491 Cmd_AddCommand ("packet", Host_Packet_f, "send a packet to the specified address:port containing a text string");
2492 Cmd_AddCommand ("topcolor", Host_TopColor_f, "QW command to set top color without changing bottom color");
2493 Cmd_AddCommand ("bottomcolor", Host_BottomColor_f, "QW command to set bottom color without changing top color");
2495 Cmd_AddCommand ("pings", Host_Pings_f, "command sent by clients to request updated ping and packetloss of players on scoreboard (originally from QW, but also used on NQ servers)");
2496 Cmd_AddCommand ("pingplreport", Host_PingPLReport_f, "command sent by server containing client ping and packet loss values for scoreboard, triggered by pings command from client (not used by QW servers)");
2498 Cvar_RegisterVariable (&team);
2499 Cvar_RegisterVariable (&skin);
2500 Cvar_RegisterVariable (&noaim);
2502 Cvar_RegisterVariable(&sv_cheats);