]> git.xonotic.org Git - xonotic/darkplaces.git/blob - host_cmd.c
70572dab2d1783567803d7ec5fbe48cc91aa5527
[xonotic/darkplaces.git] / host_cmd.c
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
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.
8
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.
12
13 See the GNU General Public License for more details.
14
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.
18
19 */
20
21 #include "quakedef.h"
22
23 int current_skill;
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;
28
29 /*
30 ==================
31 Host_Quit_f
32 ==================
33 */
34
35 void Host_Quit_f (void)
36 {
37         Sys_Quit ();
38 }
39
40
41 /*
42 ==================
43 Host_Status_f
44 ==================
45 */
46 void Host_Status_f (void)
47 {
48         client_t *client;
49         int seconds, minutes, hours = 0, j, players;
50         void (*print) (const char *fmt, ...);
51
52         if (cmd_source == src_command)
53         {
54                 if (!sv.active)
55                 {
56                         Cmd_ForwardToServer ();
57                         return;
58                 }
59                 print = Con_Printf;
60         }
61         else
62                 print = SV_ClientPrintf;
63
64         for (players = 0, j = 0;j < svs.maxclients;j++)
65                 if (svs.clients[j].active)
66                         players++;
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++)
73         {
74                 if (!client->active)
75                         continue;
76                 seconds = (int)(realtime - client->connecttime);
77                 minutes = seconds / 60;
78                 if (minutes)
79                 {
80                         seconds -= (minutes * 60);
81                         hours = minutes / 60;
82                         if (hours)
83                                 minutes -= (hours * 60);
84                 }
85                 else
86                         hours = 0;
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");
89         }
90 }
91
92
93 /*
94 ==================
95 Host_God_f
96
97 Sets client to godmode
98 ==================
99 */
100 void Host_God_f (void)
101 {
102         if (cmd_source == src_command)
103         {
104                 Cmd_ForwardToServer ();
105                 return;
106         }
107
108         if (!allowcheats)
109         {
110                 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
111                 return;
112         }
113
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");
117         else
118                 SV_ClientPrint("godmode ON\n");
119 }
120
121 void Host_Notarget_f (void)
122 {
123         if (cmd_source == src_command)
124         {
125                 Cmd_ForwardToServer ();
126                 return;
127         }
128
129         if (!allowcheats)
130         {
131                 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
132                 return;
133         }
134
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");
138         else
139                 SV_ClientPrint("notarget ON\n");
140 }
141
142 qboolean noclip_anglehack;
143
144 void Host_Noclip_f (void)
145 {
146         if (cmd_source == src_command)
147         {
148                 Cmd_ForwardToServer ();
149                 return;
150         }
151
152         if (!allowcheats)
153         {
154                 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
155                 return;
156         }
157
158         if (host_client->edict->fields.server->movetype != MOVETYPE_NOCLIP)
159         {
160                 noclip_anglehack = true;
161                 host_client->edict->fields.server->movetype = MOVETYPE_NOCLIP;
162                 SV_ClientPrint("noclip ON\n");
163         }
164         else
165         {
166                 noclip_anglehack = false;
167                 host_client->edict->fields.server->movetype = MOVETYPE_WALK;
168                 SV_ClientPrint("noclip OFF\n");
169         }
170 }
171
172 /*
173 ==================
174 Host_Fly_f
175
176 Sets client to flymode
177 ==================
178 */
179 void Host_Fly_f (void)
180 {
181         if (cmd_source == src_command)
182         {
183                 Cmd_ForwardToServer ();
184                 return;
185         }
186
187         if (!allowcheats)
188         {
189                 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
190                 return;
191         }
192
193         if (host_client->edict->fields.server->movetype != MOVETYPE_FLY)
194         {
195                 host_client->edict->fields.server->movetype = MOVETYPE_FLY;
196                 SV_ClientPrint("flymode ON\n");
197         }
198         else
199         {
200                 host_client->edict->fields.server->movetype = MOVETYPE_WALK;
201                 SV_ClientPrint("flymode OFF\n");
202         }
203 }
204
205
206 /*
207 ==================
208 Host_Ping_f
209
210 ==================
211 */
212 void Host_Ping_f (void)
213 {
214         int i;
215         client_t *client;
216         void (*print) (const char *fmt, ...);
217
218         if (cmd_source == src_command)
219         {
220                 if (!sv.active)
221                 {
222                         Cmd_ForwardToServer ();
223                         return;
224                 }
225                 print = Con_Printf;
226         }
227         else
228                 print = SV_ClientPrintf;
229
230         print("Client ping times:\n");
231         for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
232         {
233                 if (!client->active)
234                         continue;
235                 print("%4i %s\n", (int)floor(client->ping*1000+0.5), client->name);
236         }
237 }
238
239 /*
240 ===============================================================================
241
242 SERVER TRANSITIONS
243
244 ===============================================================================
245 */
246
247 /*
248 ======================
249 Host_Map_f
250
251 handle a
252 map <servername>
253 command from the console.  Active clients are kicked off.
254 ======================
255 */
256 void Host_Map_f (void)
257 {
258         char level[MAX_QPATH];
259
260         if (Cmd_Argc() != 2)
261         {
262                 Con_Print("map <levelname> : start a new game (kicks off all players)\n");
263                 return;
264         }
265
266         if (cmd_source != src_command)
267                 return;
268
269         cls.demonum = -1;               // stop demo loop in case this fails
270
271         CL_Disconnect ();
272         Host_ShutdownServer();
273
274         // remove console or menu
275         key_dest = key_game;
276         key_consoleactive = 0;
277
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         {
284                 SV_VM_Begin();
285                 CL_EstablishConnection("local:1");
286                 SV_VM_End();
287         }
288 }
289
290 /*
291 ==================
292 Host_Changelevel_f
293
294 Goes to a new map, taking all clients along
295 ==================
296 */
297 void Host_Changelevel_f (void)
298 {
299         char level[MAX_QPATH];
300
301         if (Cmd_Argc() != 2)
302         {
303                 Con_Print("changelevel <levelname> : continue game on a new level\n");
304                 return;
305         }
306         if (cls.demoplayback)
307         {
308                 Con_Print("Only the server may changelevel\n");
309                 return;
310         }
311         // HACKHACKHACK
312         if (!sv.active) {
313                 Host_Map_f();
314                 return;
315         }
316         if (cmd_source != src_command)
317                 return;
318
319         // remove console or menu
320         key_dest = key_game;
321         key_consoleactive = 0;
322
323         SV_VM_Begin();
324         SV_SaveSpawnparms ();
325         SV_VM_End();
326         allowcheats = sv_cheats.integer != 0;
327         strcpy(level, Cmd_Argv(1));
328         SV_SpawnServer(level);
329         if (sv.active && cls.state == ca_disconnected)
330         {
331                 SV_VM_Begin();
332                 CL_EstablishConnection("local:1");
333                 SV_VM_End();
334         }
335 }
336
337 /*
338 ==================
339 Host_Restart_f
340
341 Restarts the current server for a dead player
342 ==================
343 */
344 void Host_Restart_f (void)
345 {
346         char mapname[MAX_QPATH];
347
348         if (Cmd_Argc() != 1)
349         {
350                 Con_Print("restart : restart current level\n");
351                 return;
352         }
353         if (!sv.active)
354         {
355                 Con_Print("Only the server may restart\n");
356                 return;
357         }
358         if (cmd_source != src_command)
359                 return;
360
361         // remove console or menu
362         key_dest = key_game;
363         key_consoleactive = 0;
364
365         allowcheats = sv_cheats.integer != 0;
366         strcpy(mapname, sv.name);
367         SV_SpawnServer(mapname);
368         if (sv.active && cls.state == ca_disconnected)
369         {
370                 SV_VM_Begin();
371                 CL_EstablishConnection("local:1");
372                 SV_VM_End();
373         }
374 }
375
376 /*
377 ==================
378 Host_Reconnect_f
379
380 This command causes the client to wait for the signon messages again.
381 This is sent just before a server changes levels
382 ==================
383 */
384 void Host_Reconnect_f (void)
385 {
386         if (cmd_source == src_command)
387         {
388                 Con_Print("reconnect is not valid from the console\n");
389                 return;
390         }
391         if (Cmd_Argc() != 1)
392         {
393                 Con_Print("reconnect : wait for signon messages again\n");
394                 return;
395         }
396         if (!cls.signon)
397         {
398                 //Con_Print("reconnect: no signon, ignoring reconnect\n");
399                 return;
400         }
401         cls.signon = 0;         // need new connection messages
402 }
403
404 /*
405 =====================
406 Host_Connect_f
407
408 User command to connect to server
409 =====================
410 */
411 void Host_Connect_f (void)
412 {
413         if (Cmd_Argc() != 2)
414         {
415                 Con_Print("connect <serveraddress> : connect to a multiplayer game\n");
416                 return;
417         }
418         if( sv.active ) {
419                 SV_VM_Begin();
420                 CL_EstablishConnection(Cmd_Argv(1));
421                 SV_VM_End();
422         } else {
423                 CL_EstablishConnection(Cmd_Argv(1));
424         }
425 }
426
427
428 /*
429 ===============================================================================
430
431 LOAD / SAVE GAME
432
433 ===============================================================================
434 */
435
436 #define SAVEGAME_VERSION        5
437
438 /*
439 ===============
440 Host_SavegameComment
441
442 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
443 ===============
444 */
445 void Host_SavegameComment (char *text)
446 {
447         int             i;
448         char    kills[20];
449
450         for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
451                 text[i] = ' ';
452         // LordHavoc: added min() to prevent overflow
453         memcpy (text, cl.levelname, min(strlen(cl.levelname), SAVEGAME_COMMENT_LENGTH));
454         sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
455         memcpy (text+22, kills, strlen(kills));
456         // convert space to _ to make stdio happy
457         // LordHavoc: convert control characters to _ as well
458         for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
459                 if (text[i] <= ' ')
460                         text[i] = '_';
461         text[SAVEGAME_COMMENT_LENGTH] = '\0';
462 }
463
464
465 /*
466 ===============
467 Host_Savegame_f
468 ===============
469 */
470 void Host_Savegame_f (void)
471 {
472         char    name[MAX_QPATH];
473         qfile_t *f;
474         int             i;
475         char    comment[SAVEGAME_COMMENT_LENGTH+1];
476
477         if (cmd_source != src_command)
478                 return;
479
480         if (cls.state != ca_connected || !sv.active)
481         {
482                 Con_Print("Not playing a local game.\n");
483                 return;
484         }
485
486         if (cl.intermission)
487         {
488                 Con_Print("Can't save in intermission.\n");
489                 return;
490         }
491
492         for (i = 0;i < svs.maxclients;i++)
493         {
494                 if (svs.clients[i].active)
495                 {
496                         if (i > 0)
497                         {
498                                 Con_Print("Can't save multiplayer games.\n");
499                                 return;
500                         }
501                         if (svs.clients[i].edict->fields.server->deadflag)
502                         {
503                                 Con_Print("Can't savegame with a dead player\n");
504                                 return;
505                         }
506                 }
507         }
508
509         if (Cmd_Argc() != 2)
510         {
511                 Con_Print("save <savename> : save a game\n");
512                 return;
513         }
514
515         if (strstr(Cmd_Argv(1), ".."))
516         {
517                 Con_Print("Relative pathnames are not allowed.\n");
518                 return;
519         }
520
521         strlcpy (name, Cmd_Argv(1), sizeof (name));
522         FS_DefaultExtension (name, ".sav", sizeof (name));
523
524         Con_Printf("Saving game to %s...\n", name);
525         f = FS_Open (name, "wb", false, false);
526         if (!f)
527         {
528                 Con_Print("ERROR: couldn't open.\n");
529                 return;
530         }
531
532         FS_Printf(f, "%i\n", SAVEGAME_VERSION);
533         Host_SavegameComment (comment);
534         FS_Printf(f, "%s\n", comment);
535         for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
536                 FS_Printf(f, "%f\n", svs.clients[0].spawn_parms[i]);
537         FS_Printf(f, "%d\n", current_skill);
538         FS_Printf(f, "%s\n", sv.name);
539         FS_Printf(f, "%f\n",sv.time);
540
541         // write the light styles
542         for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
543         {
544                 if (sv.lightstyles[i][0])
545                         FS_Printf(f, "%s\n", sv.lightstyles[i]);
546                 else
547                         FS_Print(f,"m\n");
548         }
549
550         SV_VM_Begin();
551
552         PRVM_ED_WriteGlobals (f);
553         for (i=0 ; i<prog->num_edicts ; i++)
554                 PRVM_ED_Write (f, PRVM_EDICT_NUM(i));
555
556         SV_VM_End();
557
558         FS_Close (f);
559         Con_Print("done.\n");
560 }
561
562
563 /*
564 ===============
565 Host_Loadgame_f
566 ===============
567 */
568 void Host_Loadgame_f (void)
569 {
570         char filename[MAX_QPATH];
571         char mapname[MAX_QPATH];
572         float time;
573         const char *start;
574         const char *t;
575         const char *oldt;
576         char *text;
577         prvm_edict_t *ent;
578         int i;
579         int entnum;
580         int version;
581         float spawn_parms[NUM_SPAWN_PARMS];
582
583         if (cmd_source != src_command)
584                 return;
585
586         if (Cmd_Argc() != 2)
587         {
588                 Con_Print("load <savename> : load a game\n");
589                 return;
590         }
591
592         strcpy (filename, Cmd_Argv(1));
593         FS_DefaultExtension (filename, ".sav", sizeof (filename));
594
595         Con_Printf("Loading game from %s...\n", filename);
596
597         cls.demonum = -1;               // stop demo loop in case this fails
598
599         t = text = (char *)FS_LoadFile (filename, tempmempool, false, NULL);
600         if (!text)
601         {
602                 Con_Print("ERROR: couldn't open.\n");
603                 return;
604         }
605
606         // version
607         COM_ParseToken(&t, false);
608         version = atoi(com_token);
609         if (version != SAVEGAME_VERSION)
610         {
611                 Mem_Free(text);
612                 Con_Printf("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
613                 return;
614         }
615
616         // description
617         // this is a little hard to parse, as : is a separator in COM_ParseToken,
618         // so use the console parser instead
619         COM_ParseTokenConsole(&t);
620
621         for (i = 0;i < NUM_SPAWN_PARMS;i++)
622         {
623                 COM_ParseToken(&t, false);
624                 spawn_parms[i] = atof(com_token);
625         }
626         // skill
627         COM_ParseToken(&t, false);
628 // this silliness is so we can load 1.06 save files, which have float skill values
629         current_skill = (int)(atof(com_token) + 0.5);
630         Cvar_SetValue ("skill", (float)current_skill);
631
632         // mapname
633         COM_ParseToken(&t, false);
634         strcpy (mapname, com_token);
635
636         // time
637         COM_ParseToken(&t, false);
638         time = atof(com_token);
639
640         allowcheats = sv_cheats.integer != 0;
641
642         SV_SpawnServer (mapname);
643         if (!sv.active)
644         {
645                 Mem_Free(text);
646                 Con_Print("Couldn't load map\n");
647                 return;
648         }
649         sv.paused = true;               // pause until all clients connect
650         sv.loadgame = true;
651
652 // load the light styles
653
654         for (i = 0;i < MAX_LIGHTSTYLES;i++)
655         {
656                 // light style
657                 oldt = t;
658                 COM_ParseToken(&t, false);
659                 // if this is a 64 lightstyle savegame produced by Quake, stop now
660                 // we have to check this because darkplaces saves 256 lightstyle savegames
661                 if (com_token[0] == '{')
662                 {
663                         t = oldt;
664                         break;
665                 }
666                 strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i]));
667         }
668
669         // now skip everything before the first opening brace
670         // (this is for forward compatibility, so that older versions (at
671         // least ones with this fix) can load savegames with extra data before the
672         // first brace, as might be produced by a later engine version)
673         for(;;)
674         {
675                 oldt = t;
676                 COM_ParseToken(&t, false);
677                 if (com_token[0] == '{')
678                 {
679                         t = oldt;
680                         break;
681                 }
682         }
683
684 // load the edicts out of the savegame file
685         SV_VM_Begin();
686         // -1 is the globals
687         entnum = -1;
688         for (;;)
689         {
690                 start = t;
691                 while (COM_ParseToken(&t, false))
692                         if (!strcmp(com_token, "}"))
693                                 break;
694                 if (!COM_ParseToken(&start, false))
695                 {
696                         // end of file
697                         break;
698                 }
699                 if (strcmp(com_token,"{"))
700                 {
701                         Mem_Free(text);
702                         Host_Error ("First token isn't a brace");
703                 }
704
705                 if (entnum == -1)
706                 {
707                         // parse the global vars
708                         PRVM_ED_ParseGlobals (start);
709                 }
710                 else
711                 {
712                         // parse an edict
713                         if (entnum >= MAX_EDICTS)
714                         {
715                                 Mem_Free(text);
716                                 Host_Error("Host_PerformLoadGame: too many edicts in save file (reached MAX_EDICTS %i)", MAX_EDICTS);
717                         }
718                         while (entnum >= prog->max_edicts)
719                                 //SV_IncreaseEdicts();
720                                 PRVM_MEM_IncreaseEdicts();
721                         ent = PRVM_EDICT_NUM(entnum);
722                         memset (ent->fields.server, 0, prog->progs->entityfields * 4);
723                         ent->priv.server->free = false;
724                         PRVM_ED_ParseEdict (start, ent);
725
726                         // link it into the bsp tree
727                         if (!ent->priv.server->free)
728                                 SV_LinkEdict (ent, false);
729                 }
730
731                 entnum++;
732         }
733
734         prog->num_edicts = entnum;
735         sv.time = time;
736
737         for (i = 0;i < NUM_SPAWN_PARMS;i++)
738                 svs.clients[0].spawn_parms[i] = spawn_parms[i];
739
740         // make sure we're connected to loopback
741         if (cls.state == ca_disconnected || !(cls.state == ca_connected && cls.netcon != NULL && LHNETADDRESS_GetAddressType(&cls.netcon->peeraddress) == LHNETADDRESSTYPE_LOOP))
742                 CL_EstablishConnection("local:1");
743
744         SV_VM_End();
745 }
746
747 //============================================================================
748
749 /*
750 ======================
751 Host_Name_f
752 ======================
753 */
754 cvar_t cl_name = {CVAR_SAVE, "_cl_name", "player", "internal storage cvar for current player name (changed by name command)"};
755 void Host_Name_f (void)
756 {
757         int i, j;
758         char newName[sizeof(host_client->name)];
759
760         if (Cmd_Argc () == 1)
761         {
762                 Con_Printf("\"name\" is \"%s\"\n", cl_name.string);
763                 return;
764         }
765
766         if (Cmd_Argc () == 2)
767                 strlcpy (newName, Cmd_Argv(1), sizeof (newName));
768         else
769                 strlcpy (newName, Cmd_Args(), sizeof (newName));
770
771         for (i = 0, j = 0;newName[i];i++)
772                 if (newName[i] != '\r' && newName[i] != '\n')
773                         newName[j++] = newName[i];
774         newName[j] = 0;
775
776         if (cmd_source == src_command)
777         {
778                 Cvar_Set ("_cl_name", newName);
779                 if (cls.state == ca_connected)
780                         Cmd_ForwardToServer ();
781                 return;
782         }
783
784         if (sv.time < host_client->nametime)
785         {
786                 SV_ClientPrintf("You can't change name more than once every 5 seconds!\n");
787                 return;
788         }
789
790         host_client->nametime = sv.time + 5;
791
792         // point the string back at updateclient->name to keep it safe
793         SV_VM_Begin();
794         strlcpy (host_client->name, newName, sizeof (host_client->name));
795         host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name);
796         if (strcmp(host_client->old_name, host_client->name))
797         {
798                 if (host_client->spawned)
799                         SV_BroadcastPrintf("%s changed name to %s\n", host_client->old_name, host_client->name);
800                 strcpy(host_client->old_name, host_client->name);
801                 // send notification to all clients
802                 MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
803                 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
804                 MSG_WriteString (&sv.reliable_datagram, host_client->name);
805         }
806         SV_VM_End();
807 }
808
809 /*
810 ======================
811 Host_Playermodel_f
812 ======================
813 */
814 cvar_t cl_playermodel = {CVAR_SAVE, "_cl_playermodel", "", "internal storage cvar for current player model in Nexuiz (changed by playermodel command)"};
815 // the old cl_playermodel in cl_main has been renamed to __cl_playermodel
816 void Host_Playermodel_f (void)
817 {
818         int i, j;
819         char newPath[sizeof(host_client->playermodel)];
820
821         if (Cmd_Argc () == 1)
822         {
823                 Con_Printf("\"playermodel\" is \"%s\"\n", cl_playermodel.string);
824                 return;
825         }
826
827         if (Cmd_Argc () == 2)
828                 strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
829         else
830                 strlcpy (newPath, Cmd_Args(), sizeof (newPath));
831
832         for (i = 0, j = 0;newPath[i];i++)
833                 if (newPath[i] != '\r' && newPath[i] != '\n')
834                         newPath[j++] = newPath[i];
835         newPath[j] = 0;
836
837         if (cmd_source == src_command)
838         {
839                 Cvar_Set ("_cl_playermodel", newPath);
840                 if (cls.state == ca_connected)
841                         Cmd_ForwardToServer ();
842                 return;
843         }
844
845         /*
846         if (sv.time < host_client->nametime)
847         {
848                 SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
849                 return;
850         }
851
852         host_client->nametime = sv.time + 5;
853         */
854
855         SV_VM_Begin();
856         // point the string back at updateclient->name to keep it safe
857         strlcpy (host_client->playermodel, newPath, sizeof (host_client->playermodel));
858         if( eval_playermodel )
859                 PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PRVM_SetEngineString(host_client->playermodel);
860         if (strcmp(host_client->old_model, host_client->playermodel))
861         {
862                 strcpy(host_client->old_model, host_client->playermodel);
863                 /*// send notification to all clients
864                 MSG_WriteByte (&sv.reliable_datagram, svc_updatepmodel);
865                 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
866                 MSG_WriteString (&sv.reliable_datagram, host_client->playermodel);*/
867         }
868         SV_VM_End();
869 }
870
871 /*
872 ======================
873 Host_Playerskin_f
874 ======================
875 */
876 cvar_t cl_playerskin = {CVAR_SAVE, "_cl_playerskin", "", "internal storage cvar for current player skin in Nexuiz (changed by playerskin command)"};
877 void Host_Playerskin_f (void)
878 {
879         int i, j;
880         char newPath[sizeof(host_client->playerskin)];
881
882         if (Cmd_Argc () == 1)
883         {
884                 Con_Printf("\"playerskin\" is \"%s\"\n", cl_playerskin.string);
885                 return;
886         }
887
888         if (Cmd_Argc () == 2)
889                 strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
890         else
891                 strlcpy (newPath, Cmd_Args(), sizeof (newPath));
892
893         for (i = 0, j = 0;newPath[i];i++)
894                 if (newPath[i] != '\r' && newPath[i] != '\n')
895                         newPath[j++] = newPath[i];
896         newPath[j] = 0;
897
898         if (cmd_source == src_command)
899         {
900                 Cvar_Set ("_cl_playerskin", newPath);
901                 if (cls.state == ca_connected)
902                         Cmd_ForwardToServer ();
903                 return;
904         }
905
906         /*
907         if (sv.time < host_client->nametime)
908         {
909                 SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
910                 return;
911         }
912
913         host_client->nametime = sv.time + 5;
914         */
915
916         SV_VM_Begin();
917         // point the string back at updateclient->name to keep it safe
918         strlcpy (host_client->playerskin, newPath, sizeof (host_client->playerskin));
919         if( eval_playerskin )
920                 PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string = PRVM_SetEngineString(host_client->playerskin);
921         if (strcmp(host_client->old_skin, host_client->playerskin))
922         {
923                 if (host_client->spawned)
924                         SV_BroadcastPrintf("%s changed skin to %s\n", host_client->name, host_client->playerskin);
925                 strcpy(host_client->old_skin, host_client->playerskin);
926                 /*// send notification to all clients
927                 MSG_WriteByte (&sv.reliable_datagram, svc_updatepskin);
928                 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
929                 MSG_WriteString (&sv.reliable_datagram, host_client->playerskin);*/
930         }
931         SV_VM_End();
932 }
933
934 void Host_Version_f (void)
935 {
936         Con_Printf("Version: %s build %s\n", gamename, buildstring);
937 }
938
939 void Host_Say(qboolean teamonly)
940 {
941         client_t *save;
942         int j, quoted;
943         const char *p1;
944         char *p2;
945         // LordHavoc: long say messages
946         char text[1024];
947         qboolean fromServer = false;
948
949         if (cmd_source == src_command)
950         {
951                 if (cls.state == ca_dedicated)
952                 {
953                         fromServer = true;
954                         teamonly = false;
955                 }
956                 else
957                 {
958                         Cmd_ForwardToServer ();
959                         return;
960                 }
961         }
962
963         if (Cmd_Argc () < 2)
964                 return;
965
966         if (!teamplay.integer)
967                 teamonly = false;
968
969 // turn on color set 1
970         p1 = Cmd_Args();
971         quoted = false;
972         if (*p1 == '\"')
973         {
974                 quoted = true;
975                 p1++;
976         }
977         if (!fromServer)
978                 dpsnprintf (text, sizeof(text), "%c%s" STRING_COLOR_DEFAULT_STR ": %s", 1, host_client->name, p1);
979         else
980                 dpsnprintf (text, sizeof(text), "%c<%s" STRING_COLOR_DEFAULT_STR "> %s", 1, hostname.string, p1);
981         p2 = text + strlen(text);
982         while ((const char *)p2 > (const char *)text && (p2[-1] == '\r' || p2[-1] == '\n' || (p2[-1] == '\"' && quoted)))
983         {
984                 if (p2[-1] == '\"' && quoted)
985                         quoted = false;
986                 p2[-1] = 0;
987                 p2--;
988         }
989         strlcat(text, "\n", sizeof(text));
990
991         // note: save is not a valid edict if fromServer is true
992         save = host_client;
993         for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
994                 if (host_client->spawned && (!teamonly || host_client->edict->fields.server->team == save->edict->fields.server->team))
995                         SV_ClientPrint(text);
996         host_client = save;
997
998         if (cls.state == ca_dedicated)
999                 Con_Print(&text[1]);
1000 }
1001
1002
1003 void Host_Say_f(void)
1004 {
1005         Host_Say(false);
1006 }
1007
1008
1009 void Host_Say_Team_f(void)
1010 {
1011         Host_Say(true);
1012 }
1013
1014
1015 void Host_Tell_f(void)
1016 {
1017         client_t *save;
1018         int j;
1019         const char *p1, *p2;
1020         char text[MAX_INPUTLINE]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
1021         qboolean fromServer = false;
1022
1023         if (cmd_source == src_command)
1024         {
1025                 if (cls.state == ca_dedicated)
1026                         fromServer = true;
1027                 else
1028                 {
1029                         Cmd_ForwardToServer ();
1030                         return;
1031                 }
1032         }
1033
1034         if (Cmd_Argc () < 3)
1035                 return;
1036
1037         if (!fromServer)
1038                 sprintf (text, "%s: ", host_client->name);
1039         else
1040                 sprintf (text, "<%s> ", hostname.string);
1041
1042         p1 = Cmd_Args();
1043         p2 = p1 + strlen(p1);
1044         // remove the target name
1045         while (p1 < p2 && *p1 != ' ')
1046                 p1++;
1047         while (p1 < p2 && *p1 == ' ')
1048                 p1++;
1049         // remove trailing newlines
1050         while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
1051                 p2--;
1052         // remove quotes if present
1053         if (*p1 == '"')
1054         {
1055                 p1++;
1056                 if (p2[-1] == '"')
1057                         p2--;
1058                 else if (fromServer)
1059                         Con_Print("Host_Tell: missing end quote\n");
1060                 else
1061                         SV_ClientPrint("Host_Tell: missing end quote\n");
1062         }
1063         while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
1064                 p2--;
1065         for (j = (int)strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;)
1066                 text[j++] = *p1++;
1067         text[j++] = '\n';
1068         text[j++] = 0;
1069
1070         save = host_client;
1071         for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
1072                 if (host_client->spawned && !strcasecmp(host_client->name, Cmd_Argv(1)))
1073                         SV_ClientPrint(text);
1074         host_client = save;
1075 }
1076
1077
1078 /*
1079 ==================
1080 Host_Color_f
1081 ==================
1082 */
1083 cvar_t cl_color = {CVAR_SAVE, "_cl_color", "0", "internal storage cvar for current player colors (changed by color command)"};
1084 void Host_Color_f(void)
1085 {
1086         int             top, bottom;
1087         int             playercolor;
1088         mfunction_t *f;
1089         func_t  SV_ChangeTeam;
1090
1091         if (Cmd_Argc() == 1)
1092         {
1093                 Con_Printf("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15);
1094                 Con_Print("color <0-15> [0-15]\n");
1095                 return;
1096         }
1097
1098         if (Cmd_Argc() == 2)
1099                 top = bottom = atoi(Cmd_Argv(1));
1100         else
1101         {
1102                 top = atoi(Cmd_Argv(1));
1103                 bottom = atoi(Cmd_Argv(2));
1104         }
1105
1106         top &= 15;
1107         // LordHavoc: allow skin colormaps 14 and 15 (was 13)
1108         if (top > 15)
1109                 top = 15;
1110         bottom &= 15;
1111         // LordHavoc: allow skin colormaps 14 and 15 (was 13)
1112         if (bottom > 15)
1113                 bottom = 15;
1114
1115         playercolor = top*16 + bottom;
1116
1117         if (cmd_source == src_command)
1118         {
1119                 Cvar_SetValue ("_cl_color", playercolor);
1120                 if (cls.state == ca_connected)
1121                         Cmd_ForwardToServer ();
1122                 return;
1123         }
1124
1125         SV_VM_Begin();
1126         if (host_client->edict && (f = PRVM_ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - prog->functions)))
1127         {
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");
1133         }
1134         else
1135         {
1136                 prvm_eval_t *val;
1137                 if (host_client->edict)
1138                 {
1139                         if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_clientcolors)))
1140                                 val->_float = playercolor;
1141                         host_client->edict->fields.server->team = bottom + 1;
1142                 }
1143                 host_client->colors = playercolor;
1144                 if (host_client->old_colors != host_client->colors)
1145                 {
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);
1151                 }
1152         }
1153         SV_VM_End();
1154 }
1155
1156 cvar_t cl_rate = {CVAR_SAVE, "_cl_rate", "10000", "internal storage cvar for current rate (changed by rate command)"};
1157 void Host_Rate_f(void)
1158 {
1159         int rate;
1160
1161         if (Cmd_Argc() != 2)
1162         {
1163                 Con_Printf("\"rate\" is \"%i\"\n", cl_rate.integer);
1164                 Con_Print("rate <500-25000>\n");
1165                 return;
1166         }
1167
1168         rate = atoi(Cmd_Argv(1));
1169
1170         if (cmd_source == src_command)
1171         {
1172                 Cvar_SetValue ("_cl_rate", bound(NET_MINRATE, rate, NET_MAXRATE));
1173                 if (cls.state == ca_connected)
1174                         Cmd_ForwardToServer ();
1175                 return;
1176         }
1177
1178         host_client->rate = rate;
1179 }
1180
1181 /*
1182 ==================
1183 Host_Kill_f
1184 ==================
1185 */
1186 void Host_Kill_f (void)
1187 {
1188         if (cmd_source == src_command)
1189         {
1190                 Cmd_ForwardToServer ();
1191                 return;
1192         }
1193
1194         if (host_client->edict->fields.server->health <= 0)
1195         {
1196                 SV_ClientPrint("Can't suicide -- already dead!\n");
1197                 return;
1198         }
1199
1200         SV_VM_Begin();
1201         prog->globals.server->time = sv.time;
1202         prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1203         PRVM_ExecuteProgram (prog->globals.server->ClientKill, "QC function ClientKill is missing");
1204         SV_VM_End();
1205 }
1206
1207
1208 /*
1209 ==================
1210 Host_Pause_f
1211 ==================
1212 */
1213 void Host_Pause_f (void)
1214 {
1215
1216         if (cmd_source == src_command)
1217         {
1218                 Cmd_ForwardToServer ();
1219                 return;
1220         }
1221         if (!pausable.integer)
1222                 SV_ClientPrint("Pause not allowed.\n");
1223         else
1224         {
1225                 sv.paused ^= 1;
1226                 SV_BroadcastPrintf("%s %spaused the game\n", host_client->name, sv.paused ? "" : "un");
1227                 // send notification to all clients
1228                 MSG_WriteByte(&sv.reliable_datagram, svc_setpause);
1229                 MSG_WriteByte(&sv.reliable_datagram, sv.paused);
1230         }
1231 }
1232
1233 /*
1234 ======================
1235 Host_PModel_f
1236 LordHavoc: only supported for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
1237 LordHavoc: correction, Mindcrime will be removing pmodel in the future, but it's still stuck here for compatibility.
1238 ======================
1239 */
1240 cvar_t cl_pmodel = {CVAR_SAVE, "_cl_pmodel", "0", "internal storage cvar for current player model number in nehahra (changed by pmodel command)"};
1241 static void Host_PModel_f (void)
1242 {
1243         int i;
1244         prvm_eval_t *val;
1245
1246         if (Cmd_Argc () == 1)
1247         {
1248                 Con_Printf("\"pmodel\" is \"%s\"\n", cl_pmodel.string);
1249                 return;
1250         }
1251         i = atoi(Cmd_Argv(1));
1252
1253         if (cmd_source == src_command)
1254         {
1255                 if (cl_pmodel.integer == i)
1256                         return;
1257                 Cvar_SetValue ("_cl_pmodel", i);
1258                 if (cls.state == ca_connected)
1259                         Cmd_ForwardToServer ();
1260                 return;
1261         }
1262
1263         SV_VM_Begin();
1264         if (host_client->edict && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1265                 val->_float = i;
1266         SV_VM_End();
1267 }
1268
1269 //===========================================================================
1270
1271
1272 /*
1273 ==================
1274 Host_PreSpawn_f
1275 ==================
1276 */
1277 void Host_PreSpawn_f (void)
1278 {
1279         if (cmd_source == src_command)
1280         {
1281                 Con_Print("prespawn is not valid from the console\n");
1282                 return;
1283         }
1284
1285         if (host_client->spawned)
1286         {
1287                 Con_Print("prespawn not valid -- already spawned\n");
1288                 return;
1289         }
1290
1291         if (host_client->netconnection)
1292         {
1293                 SZ_Write (&host_client->netconnection->message, sv.signon.data, sv.signon.cursize);
1294                 MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
1295                 MSG_WriteByte (&host_client->netconnection->message, 2);
1296         }
1297
1298         // reset the name change timer because the client will send name soon
1299         host_client->nametime = 0;
1300 }
1301
1302 /*
1303 ==================
1304 Host_Spawn_f
1305 ==================
1306 */
1307 void Host_Spawn_f (void)
1308 {
1309         int i;
1310         client_t *client;
1311         func_t RestoreGame;
1312         mfunction_t *f;
1313         int stats[MAX_CL_STATS];
1314
1315         if (cmd_source == src_command)
1316         {
1317                 Con_Print("spawn is not valid from the console\n");
1318                 return;
1319         }
1320
1321         if (host_client->spawned)
1322         {
1323                 Con_Print("Spawn not valid -- already spawned\n");
1324                 return;
1325         }
1326
1327         // reset name change timer again because they might want to change name
1328         // again in the first 5 seconds after connecting
1329         host_client->nametime = 0;
1330
1331         // LordHavoc: moved this above the QC calls at FrikaC's request
1332         // LordHavoc: commented this out
1333         //if (host_client->netconnection)
1334         //      SZ_Clear (&host_client->netconnection->message);
1335
1336         // run the entrance script
1337         SV_VM_Begin();
1338         if (sv.loadgame)
1339         {
1340                 // loaded games are fully initialized already
1341                 // if this is the last client to be connected, unpause
1342                 sv.paused = false;
1343
1344                 if ((f = PRVM_ED_FindFunction ("RestoreGame")))
1345                 if ((RestoreGame = (func_t)(f - prog->functions)))
1346                 {
1347                         Con_DPrint("Calling RestoreGame\n");
1348                         prog->globals.server->time = sv.time;
1349                         prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1350                         PRVM_ExecuteProgram (RestoreGame, "QC function RestoreGame is missing");
1351                 }
1352         }
1353         else
1354         {
1355                 //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);
1356
1357                 // copy spawn parms out of the client_t
1358                 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1359                         (&prog->globals.server->parm1)[i] = host_client->spawn_parms[i];
1360
1361                 // call the spawn function
1362                 host_client->clientconnectcalled = true;
1363                 prog->globals.server->time = sv.time;
1364                 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
1365                 PRVM_ExecuteProgram (prog->globals.server->ClientConnect, "QC function ClientConnect is missing");
1366
1367                 if ((Sys_DoubleTime() - host_client->connecttime) <= sv.time)
1368                         Con_Printf("%s entered the game\n", host_client->name);
1369
1370                 PRVM_ExecuteProgram (prog->globals.server->PutClientInServer, "QC function PutClientInServer is missing");
1371         }
1372         SV_VM_End();
1373
1374         if (!host_client->netconnection)
1375                 return;
1376
1377         SV_VM_Begin();
1378         // send time of update
1379         MSG_WriteByte (&host_client->netconnection->message, svc_time);
1380         MSG_WriteFloat (&host_client->netconnection->message, sv.time);
1381
1382         // send all current names, colors, and frag counts
1383         for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
1384         {
1385                 if (!client->active)
1386                         continue;
1387                 MSG_WriteByte (&host_client->netconnection->message, svc_updatename);
1388                 MSG_WriteByte (&host_client->netconnection->message, i);
1389                 MSG_WriteString (&host_client->netconnection->message, client->name);
1390                 MSG_WriteByte (&host_client->netconnection->message, svc_updatefrags);
1391                 MSG_WriteByte (&host_client->netconnection->message, i);
1392                 MSG_WriteShort (&host_client->netconnection->message, client->frags);
1393                 MSG_WriteByte (&host_client->netconnection->message, svc_updatecolors);
1394                 MSG_WriteByte (&host_client->netconnection->message, i);
1395                 MSG_WriteByte (&host_client->netconnection->message, client->colors);
1396         }
1397
1398         // send all current light styles
1399         for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1400         {
1401                 if (sv.lightstyles[i][0])
1402                 {
1403                         MSG_WriteByte (&host_client->netconnection->message, svc_lightstyle);
1404                         MSG_WriteByte (&host_client->netconnection->message, (char)i);
1405                         MSG_WriteString (&host_client->netconnection->message, sv.lightstyles[i]);
1406                 }
1407         }
1408
1409         // send some stats
1410         MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1411         MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALSECRETS);
1412         MSG_WriteLong (&host_client->netconnection->message, prog->globals.server->total_secrets);
1413
1414         MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1415         MSG_WriteByte (&host_client->netconnection->message, STAT_TOTALMONSTERS);
1416         MSG_WriteLong (&host_client->netconnection->message, prog->globals.server->total_monsters);
1417
1418         MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1419         MSG_WriteByte (&host_client->netconnection->message, STAT_SECRETS);
1420         MSG_WriteLong (&host_client->netconnection->message, prog->globals.server->found_secrets);
1421
1422         MSG_WriteByte (&host_client->netconnection->message, svc_updatestat);
1423         MSG_WriteByte (&host_client->netconnection->message, STAT_MONSTERS);
1424         MSG_WriteLong (&host_client->netconnection->message, prog->globals.server->killed_monsters);
1425
1426         // send a fixangle
1427         // Never send a roll angle, because savegames can catch the server
1428         // in a state where it is expecting the client to correct the angle
1429         // and it won't happen if the game was just loaded, so you wind up
1430         // with a permanent head tilt
1431         MSG_WriteByte (&host_client->netconnection->message, svc_setangle);
1432         MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[0], sv.protocol);
1433         MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->angles[1], sv.protocol);
1434         MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
1435
1436         SV_WriteClientdataToMessage (host_client, host_client->edict, &host_client->netconnection->message, stats);
1437
1438         MSG_WriteByte (&host_client->netconnection->message, svc_signonnum);
1439         MSG_WriteByte (&host_client->netconnection->message, 3);
1440         SV_VM_End();
1441 }
1442
1443 /*
1444 ==================
1445 Host_Begin_f
1446 ==================
1447 */
1448 void Host_Begin_f (void)
1449 {
1450         if (cmd_source == src_command)
1451         {
1452                 Con_Print("begin is not valid from the console\n");
1453                 return;
1454         }
1455
1456         host_client->spawned = true;
1457 }
1458
1459 //===========================================================================
1460
1461
1462 /*
1463 ==================
1464 Host_Kick_f
1465
1466 Kicks a user off of the server
1467 ==================
1468 */
1469 void Host_Kick_f (void)
1470 {
1471         char *who;
1472         const char *message = NULL;
1473         client_t *save;
1474         int i;
1475         qboolean byNumber = false;
1476
1477         if (cmd_source != src_command || !sv.active)
1478                 return;
1479
1480         SV_VM_Begin();
1481         save = host_client;
1482
1483         if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1484         {
1485                 i = atof(Cmd_Argv(2)) - 1;
1486                 if (i < 0 || i >= svs.maxclients || !(host_client = svs.clients + i)->active)
1487                         return;
1488                 byNumber = true;
1489         }
1490         else
1491         {
1492                 for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
1493                 {
1494                         if (!host_client->active)
1495                                 continue;
1496                         if (strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1497                                 break;
1498                 }
1499         }
1500
1501         if (i < svs.maxclients)
1502         {
1503                 if (cmd_source == src_command)
1504                 {
1505                         if (cls.state == ca_dedicated)
1506                                 who = "Console";
1507                         else
1508                                 who = cl_name.string;
1509                 }
1510                 else
1511                         who = save->name;
1512
1513                 // can't kick yourself!
1514                 if (host_client == save)
1515                         return;
1516
1517                 if (Cmd_Argc() > 2)
1518                 {
1519                         message = Cmd_Args();
1520                         COM_ParseToken(&message, false);
1521                         if (byNumber)
1522                         {
1523                                 message++;                                                      // skip the #
1524                                 while (*message == ' ')                         // skip white space
1525                                         message++;
1526                                 message += strlen(Cmd_Argv(2)); // skip the number
1527                         }
1528                         while (*message && *message == ' ')
1529                                 message++;
1530                 }
1531                 if (message)
1532                         SV_ClientPrintf("Kicked by %s: %s\n", who, message);
1533                 else
1534                         SV_ClientPrintf("Kicked by %s\n", who);
1535                 SV_DropClient (false); // kicked
1536         }
1537
1538         host_client = save;
1539         SV_VM_End();
1540 }
1541
1542 /*
1543 ===============================================================================
1544
1545 DEBUGGING TOOLS
1546
1547 ===============================================================================
1548 */
1549
1550 /*
1551 ==================
1552 Host_Give_f
1553 ==================
1554 */
1555 void Host_Give_f (void)
1556 {
1557         const char *t;
1558         int v;
1559         prvm_eval_t *val;
1560
1561         if (cmd_source == src_command)
1562         {
1563                 Cmd_ForwardToServer ();
1564                 return;
1565         }
1566
1567         if (!allowcheats)
1568         {
1569                 SV_ClientPrint("No cheats allowed, use sv_cheats 1 and restart level to enable.\n");
1570                 return;
1571         }
1572
1573         t = Cmd_Argv(1);
1574         v = atoi (Cmd_Argv(2));
1575
1576         SV_VM_Begin();
1577         switch (t[0])
1578         {
1579         case '0':
1580         case '1':
1581         case '2':
1582         case '3':
1583         case '4':
1584         case '5':
1585         case '6':
1586         case '7':
1587         case '8':
1588         case '9':
1589                 // MED 01/04/97 added hipnotic give stuff
1590                 if (gamemode == GAME_HIPNOTIC)
1591                 {
1592                         if (t[0] == '6')
1593                         {
1594                                 if (t[1] == 'a')
1595                                         host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_PROXIMITY_GUN;
1596                                 else
1597                                         host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | IT_GRENADE_LAUNCHER;
1598                         }
1599                         else if (t[0] == '9')
1600                                 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_LASER_CANNON;
1601                         else if (t[0] == '0')
1602                                 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | HIT_MJOLNIR;
1603                         else if (t[0] >= '2')
1604                                 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
1605                 }
1606                 else
1607                 {
1608                         if (t[0] >= '2')
1609                                 host_client->edict->fields.server->items = (int)host_client->edict->fields.server->items | (IT_SHOTGUN << (t[0] - '2'));
1610                 }
1611                 break;
1612
1613         case 's':
1614                 if (gamemode == GAME_ROGUE && (val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_shells1)))
1615                         val->_float = v;
1616
1617                 host_client->edict->fields.server->ammo_shells = v;
1618                 break;
1619         case 'n':
1620                 if (gamemode == GAME_ROGUE)
1621                 {
1622                         if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_nails1)))
1623                         {
1624                                 val->_float = v;
1625                                 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1626                                         host_client->edict->fields.server->ammo_nails = v;
1627                         }
1628                 }
1629                 else
1630                 {
1631                         host_client->edict->fields.server->ammo_nails = v;
1632                 }
1633                 break;
1634         case 'l':
1635                 if (gamemode == GAME_ROGUE)
1636                 {
1637                         val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_lava_nails);
1638                         if (val)
1639                         {
1640                                 val->_float = v;
1641                                 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1642                                         host_client->edict->fields.server->ammo_nails = v;
1643                         }
1644                 }
1645                 break;
1646         case 'r':
1647                 if (gamemode == GAME_ROGUE)
1648                 {
1649                         val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_rockets1);
1650                         if (val)
1651                         {
1652                                 val->_float = v;
1653                                 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1654                                         host_client->edict->fields.server->ammo_rockets = v;
1655                         }
1656                 }
1657                 else
1658                 {
1659                         host_client->edict->fields.server->ammo_rockets = v;
1660                 }
1661                 break;
1662         case 'm':
1663                 if (gamemode == GAME_ROGUE)
1664                 {
1665                         val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_multi_rockets);
1666                         if (val)
1667                         {
1668                                 val->_float = v;
1669                                 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1670                                         host_client->edict->fields.server->ammo_rockets = v;
1671                         }
1672                 }
1673                 break;
1674         case 'h':
1675                 host_client->edict->fields.server->health = v;
1676                 break;
1677         case 'c':
1678                 if (gamemode == GAME_ROGUE)
1679                 {
1680                         val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_cells1);
1681                         if (val)
1682                         {
1683                                 val->_float = v;
1684                                 if (host_client->edict->fields.server->weapon <= IT_LIGHTNING)
1685                                         host_client->edict->fields.server->ammo_cells = v;
1686                         }
1687                 }
1688                 else
1689                 {
1690                         host_client->edict->fields.server->ammo_cells = v;
1691                 }
1692                 break;
1693         case 'p':
1694                 if (gamemode == GAME_ROGUE)
1695                 {
1696                         val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ammo_plasma);
1697                         if (val)
1698                         {
1699                                 val->_float = v;
1700                                 if (host_client->edict->fields.server->weapon > IT_LIGHTNING)
1701                                         host_client->edict->fields.server->ammo_cells = v;
1702                         }
1703                 }
1704                 break;
1705         }
1706         SV_VM_End();
1707 }
1708
1709 prvm_edict_t    *FindViewthing (void)
1710 {
1711         int             i;
1712         prvm_edict_t    *e;
1713
1714         for (i=0 ; i<prog->num_edicts ; i++)
1715         {
1716                 e = PRVM_EDICT_NUM(i);
1717                 if (!strcmp (PRVM_GetString(e->fields.server->classname), "viewthing"))
1718                         return e;
1719         }
1720         Con_Print("No viewthing on map\n");
1721         return NULL;
1722 }
1723
1724 /*
1725 ==================
1726 Host_Viewmodel_f
1727 ==================
1728 */
1729 void Host_Viewmodel_f (void)
1730 {
1731         prvm_edict_t    *e;
1732         model_t *m;
1733
1734         if (!sv.active)
1735                 return;
1736
1737         SV_VM_Begin();
1738         e = FindViewthing ();
1739         SV_VM_End();
1740         if (!e)
1741                 return;
1742
1743         m = Mod_ForName (Cmd_Argv(1), false, true, false);
1744         if (!m || !m->loaded || !m->Draw)
1745         {
1746                 Con_Printf("viewmodel: can't load %s\n", Cmd_Argv(1));
1747                 return;
1748         }
1749
1750         e->fields.server->frame = 0;
1751         cl.model_precache[(int)e->fields.server->modelindex] = m;
1752 }
1753
1754 /*
1755 ==================
1756 Host_Viewframe_f
1757 ==================
1758 */
1759 void Host_Viewframe_f (void)
1760 {
1761         prvm_edict_t    *e;
1762         int             f;
1763         model_t *m;
1764
1765         if (!sv.active)
1766                 return;
1767
1768         SV_VM_Begin();
1769         e = FindViewthing ();
1770         SV_VM_End();
1771         if (!e)
1772                 return;
1773         m = cl.model_precache[(int)e->fields.server->modelindex];
1774
1775         f = atoi(Cmd_Argv(1));
1776         if (f >= m->numframes)
1777                 f = m->numframes-1;
1778
1779         e->fields.server->frame = f;
1780 }
1781
1782
1783 void PrintFrameName (model_t *m, int frame)
1784 {
1785         if (m->animscenes)
1786                 Con_Printf("frame %i: %s\n", frame, m->animscenes[frame].name);
1787         else
1788                 Con_Printf("frame %i\n", frame);
1789 }
1790
1791 /*
1792 ==================
1793 Host_Viewnext_f
1794 ==================
1795 */
1796 void Host_Viewnext_f (void)
1797 {
1798         prvm_edict_t    *e;
1799         model_t *m;
1800
1801         if (!sv.active)
1802                 return;
1803
1804         SV_VM_Begin();
1805         e = FindViewthing ();
1806         SV_VM_End();
1807         if (!e)
1808                 return;
1809         m = cl.model_precache[(int)e->fields.server->modelindex];
1810
1811         e->fields.server->frame = e->fields.server->frame + 1;
1812         if (e->fields.server->frame >= m->numframes)
1813                 e->fields.server->frame = m->numframes - 1;
1814
1815         PrintFrameName (m, e->fields.server->frame);
1816 }
1817
1818 /*
1819 ==================
1820 Host_Viewprev_f
1821 ==================
1822 */
1823 void Host_Viewprev_f (void)
1824 {
1825         prvm_edict_t    *e;
1826         model_t *m;
1827
1828         if (!sv.active)
1829                 return;
1830
1831         SV_VM_Begin();
1832         e = FindViewthing ();
1833         SV_VM_End();
1834         if (!e)
1835                 return;
1836
1837         m = cl.model_precache[(int)e->fields.server->modelindex];
1838
1839         e->fields.server->frame = e->fields.server->frame - 1;
1840         if (e->fields.server->frame < 0)
1841                 e->fields.server->frame = 0;
1842
1843         PrintFrameName (m, e->fields.server->frame);
1844 }
1845
1846 /*
1847 ===============================================================================
1848
1849 DEMO LOOP CONTROL
1850
1851 ===============================================================================
1852 */
1853
1854
1855 /*
1856 ==================
1857 Host_Startdemos_f
1858 ==================
1859 */
1860 void Host_Startdemos_f (void)
1861 {
1862         int             i, c;
1863
1864         if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-demolooponly"))
1865                 return;
1866
1867         c = Cmd_Argc() - 1;
1868         if (c > MAX_DEMOS)
1869         {
1870                 Con_Printf("Max %i demos in demoloop\n", MAX_DEMOS);
1871                 c = MAX_DEMOS;
1872         }
1873         Con_Printf("%i demo(s) in loop\n", c);
1874
1875         for (i=1 ; i<c+1 ; i++)
1876                 strlcpy (cls.demos[i-1], Cmd_Argv(i), sizeof (cls.demos[i-1]));
1877
1878         // LordHavoc: clear the remaining slots
1879         for (;i <= MAX_DEMOS;i++)
1880                 cls.demos[i-1][0] = 0;
1881
1882         if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1883         {
1884                 cls.demonum = 0;
1885                 CL_NextDemo ();
1886         }
1887         else
1888                 cls.demonum = -1;
1889 }
1890
1891
1892 /*
1893 ==================
1894 Host_Demos_f
1895
1896 Return to looping demos
1897 ==================
1898 */
1899 void Host_Demos_f (void)
1900 {
1901         if (cls.state == ca_dedicated)
1902                 return;
1903         if (cls.demonum == -1)
1904                 cls.demonum = 1;
1905         CL_Disconnect_f ();
1906         CL_NextDemo ();
1907 }
1908
1909 /*
1910 ==================
1911 Host_Stopdemo_f
1912
1913 Return to looping demos
1914 ==================
1915 */
1916 void Host_Stopdemo_f (void)
1917 {
1918         if (!cls.demoplayback)
1919                 return;
1920         CL_Disconnect ();
1921         Host_ShutdownServer ();
1922 }
1923
1924 void Host_SendCvar_f (void)
1925 {
1926         int             i;
1927         cvar_t  *c;
1928         client_t *old;
1929
1930         if(Cmd_Argc() != 2)
1931                 return;
1932         if(!(c = Cvar_FindVar(Cmd_Argv(1))))
1933                 return;
1934         if (cls.state != ca_dedicated)
1935                 Cmd_ForwardStringToServer(va("sentcvar %s %s\n", c->name, c->string));
1936         if(!sv.active)// || !SV_ParseClientCommandQC)
1937                 return;
1938
1939         old = host_client;
1940         if (cls.state != ca_dedicated)
1941                 i = 1;
1942         else
1943                 i = 0;
1944         for(;i<svs.maxclients;i++)
1945                 if(svs.clients[i].active && svs.clients[i].netconnection)
1946                 {
1947                         host_client = &svs.clients[i];
1948                         Host_ClientCommands(va("sendcvar %s\n", c->name));
1949                 }
1950         host_client = old;
1951 }
1952
1953 static void MaxPlayers_f(void)
1954 {
1955         int n;
1956
1957         if (Cmd_Argc() != 2)
1958         {
1959                 Con_Printf("\"maxplayers\" is \"%u\"\n", svs.maxclients);
1960                 return;
1961         }
1962
1963         if (sv.active)
1964         {
1965                 Con_Print("maxplayers can not be changed while a server is running.\n");
1966                 return;
1967         }
1968
1969         n = atoi(Cmd_Argv(1));
1970         n = bound(1, n, MAX_SCOREBOARD);
1971         Con_Printf("\"maxplayers\" set to \"%u\"\n", n);
1972
1973         if (svs.clients)
1974                 Mem_Free(svs.clients);
1975         svs.maxclients = n;
1976         svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
1977         if (n == 1)
1978                 Cvar_Set ("deathmatch", "0");
1979         else
1980                 Cvar_Set ("deathmatch", "1");
1981 }
1982
1983 //=============================================================================
1984
1985 // QuakeWorld commands
1986
1987 char emodel_name[] =
1988         { 'e' ^ 0xff, 'm' ^ 0xff, 'o' ^ 0xff, 'd' ^ 0xff, 'e' ^ 0xff, 'l' ^ 0xff, 0 };
1989 char pmodel_name[] =
1990         { 'p' ^ 0xff, 'm' ^ 0xff, 'o' ^ 0xff, 'd' ^ 0xff, 'e' ^ 0xff, 'l' ^ 0xff, 0 };
1991 char prespawn_name[] =
1992         { 'p'^0xff, 'r'^0xff, 'e'^0xff, 's'^0xff, 'p'^0xff, 'a'^0xff, 'w'^0xff, 'n'^0xff,
1993                 ' '^0xff, '%'^0xff, 'i'^0xff, ' '^0xff, '0'^0xff, ' '^0xff, '%'^0xff, 'i'^0xff, 0 };
1994 char modellist_name[] =
1995         { 'm'^0xff, 'o'^0xff, 'd'^0xff, 'e'^0xff, 'l'^0xff, 'l'^0xff, 'i'^0xff, 's'^0xff, 't'^0xff,
1996                 ' '^0xff, '%'^0xff, 'i'^0xff, ' '^0xff, '%'^0xff, 'i'^0xff, 0 };
1997 char soundlist_name[] =
1998         { 's'^0xff, 'o'^0xff, 'u'^0xff, 'n'^0xff, 'd'^0xff, 'l'^0xff, 'i'^0xff, 's'^0xff, 't'^0xff,
1999                 ' '^0xff, '%'^0xff, 'i'^0xff, ' '^0xff, '%'^0xff, 'i'^0xff, 0 };
2000
2001 /*
2002 =====================
2003 Host_Rcon_f
2004
2005   Send the rest of the command line over as
2006   an unconnected command.
2007 =====================
2008 */
2009 void Host_Rcon_f (void) // credit: taken from QuakeWorld
2010 {
2011         lhnetaddress_t to;
2012         lhnetsocket_t *mysocket;
2013
2014         if (!rcon_password.string)
2015         {
2016                 Con_Printf ("You must set rcon_password before issuing an rcon command.\n");
2017                 return;
2018         }
2019
2020         if (cls.netcon)
2021                 to = cls.netcon->peeraddress;
2022         else
2023         {
2024                 if (!rcon_address.integer || !rcon_address.string[0])
2025                 {
2026                         Con_Printf ("You must either be connected, or set the rcon_address cvar to issue rcon commands\n");
2027                         return;
2028                 }
2029                 LHNETADDRESS_FromString(&to, rcon_address.string, sv_netport.integer);
2030         }
2031         mysocket = NetConn_ChooseClientSocketForAddress(&to);
2032         if (mysocket)
2033         {
2034                 // simply put together the rcon packet and send it
2035                 NetConn_WriteString(mysocket, va("\377\377\377\377rcon %s %s", rcon_password.string, Cmd_Args()), &to);
2036         }
2037 }
2038
2039 /*
2040 ====================
2041 Host_Packet_f
2042
2043 packet <destination> <contents>
2044
2045 Contents allows \n escape character
2046 ====================
2047 */
2048 void Host_Packet_f (void) // credit: taken from QuakeWorld
2049 {
2050         char send[2048];
2051         int i, l;
2052         const char *in;
2053         char *out;
2054         lhnetaddress_t address;
2055         lhnetsocket_t *mysocket;
2056
2057         if (Cmd_Argc() != 3)
2058         {
2059                 Con_Printf ("packet <destination> <contents>\n");
2060                 return;
2061         }
2062
2063         if (!LHNETADDRESS_FromString (&address, Cmd_Argv(1), sv_netport.integer))
2064         {
2065                 Con_Printf ("Bad address\n");
2066                 return;
2067         }
2068
2069         in = Cmd_Argv(2);
2070         out = send+4;
2071         send[0] = send[1] = send[2] = send[3] = 0xff;
2072
2073         l = strlen (in);
2074         for (i=0 ; i<l ; i++)
2075         {
2076                 if (out >= send + sizeof(send) - 1)
2077                         break;
2078                 if (in[i] == '\\' && in[i+1] == 'n')
2079                 {
2080                         *out++ = '\n';
2081                         i++;
2082                 }
2083                 else
2084                         *out++ = in[i];
2085         }
2086         *out = 0;
2087
2088         mysocket = NetConn_ChooseClientSocketForAddress(&address);
2089         if (mysocket)
2090                 NetConn_WriteString(mysocket, send, &address);
2091 }
2092
2093 //=============================================================================
2094
2095 /*
2096 ==================
2097 Host_InitCommands
2098 ==================
2099 */
2100 void Host_InitCommands (void)
2101 {
2102         Cmd_AddCommand ("status", Host_Status_f, "print server status information");
2103         Cmd_AddCommand ("quit", Host_Quit_f, "quit the game");
2104         if (gamemode == GAME_NEHAHRA)
2105         {
2106                 Cmd_AddCommand ("max", Host_God_f, "god mode (invulnerability)");
2107                 Cmd_AddCommand ("monster", Host_Notarget_f, "notarget mode (monsters do not see you)");
2108                 Cmd_AddCommand ("scrag", Host_Fly_f, "fly mode (flight)");
2109                 Cmd_AddCommand ("wraith", Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
2110                 Cmd_AddCommand ("gimme", Host_Give_f, "alter inventory");
2111         }
2112         else
2113         {
2114                 Cmd_AddCommand ("god", Host_God_f, "god mode (invulnerability)");
2115                 Cmd_AddCommand ("notarget", Host_Notarget_f, "notarget mode (monsters do not see you)");
2116                 Cmd_AddCommand ("fly", Host_Fly_f, "fly mode (flight)");
2117                 Cmd_AddCommand ("noclip", Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
2118                 Cmd_AddCommand ("give", Host_Give_f, "alter inventory");
2119         }
2120         Cmd_AddCommand ("map", Host_Map_f, "kick everyone off the server and start a new level");
2121         Cmd_AddCommand ("restart", Host_Restart_f, "restart current level");
2122         Cmd_AddCommand ("changelevel", Host_Changelevel_f, "change to another level, bringing along all connected clients");
2123         Cmd_AddCommand ("connect", Host_Connect_f, "connect to a server by IP address or hostname");
2124         Cmd_AddCommand ("reconnect", Host_Reconnect_f, "reset signon level in preparation for a new level (do not use)");
2125         Cmd_AddCommand ("version", Host_Version_f, "print engine version");
2126         Cmd_AddCommand ("say", Host_Say_f, "send a chat message to everyone on the server");
2127         Cmd_AddCommand ("say_team", Host_Say_Team_f, "send a chat message to your team on the server");
2128         Cmd_AddCommand ("tell", Host_Tell_f, "send a chat message to only one person on the server");
2129         Cmd_AddCommand ("kill", Host_Kill_f, "die instantly");
2130         Cmd_AddCommand ("pause", Host_Pause_f, "pause the game (if the server allows pausing)");
2131         Cmd_AddCommand ("kick", Host_Kick_f, "kick a player off the server by number or name");
2132         Cmd_AddCommand ("ping", Host_Ping_f, "print ping times of all players on the server");
2133         Cmd_AddCommand ("load", Host_Loadgame_f, "load a saved game file");
2134         Cmd_AddCommand ("save", Host_Savegame_f, "save the game to a file");
2135
2136         Cmd_AddCommand ("startdemos", Host_Startdemos_f, "start playing back the selected demos sequentially (used at end of startup script)");
2137         Cmd_AddCommand ("demos", Host_Demos_f, "restart looping demos defined by the last startdemos command");
2138         Cmd_AddCommand ("stopdemo", Host_Stopdemo_f, "stop playing or recording demo (like stop command) and return to looping demos");
2139
2140         Cmd_AddCommand ("viewmodel", Host_Viewmodel_f, "change model of viewthing entity in current level");
2141         Cmd_AddCommand ("viewframe", Host_Viewframe_f, "change animation frame of viewthing entity in current level");
2142         Cmd_AddCommand ("viewnext", Host_Viewnext_f, "change to next animation frame of viewthing entity in current level");
2143         Cmd_AddCommand ("viewprev", Host_Viewprev_f, "change to previous animation frame of viewthing entity in current level");
2144
2145         Cvar_RegisterVariable (&cl_name);
2146         Cmd_AddCommand ("name", Host_Name_f, "change your player name");
2147         Cvar_RegisterVariable (&cl_color);
2148         Cmd_AddCommand ("color", Host_Color_f, "change your player shirt and pants colors");
2149         Cvar_RegisterVariable (&cl_rate);
2150         Cmd_AddCommand ("rate", Host_Rate_f, "change your network connection speed");
2151         if (gamemode == GAME_NEHAHRA)
2152         {
2153                 Cvar_RegisterVariable (&cl_pmodel);
2154                 Cmd_AddCommand ("pmodel", Host_PModel_f, "change your player model choice (Nehahra specific)");
2155         }
2156
2157         // BLACK: This isnt game specific anymore (it was GAME_NEXUIZ at first)
2158         Cvar_RegisterVariable (&cl_playermodel);
2159         Cmd_AddCommand ("playermodel", Host_Playermodel_f, "change your player model");
2160         Cvar_RegisterVariable (&cl_playerskin);
2161         Cmd_AddCommand ("playerskin", Host_Playerskin_f, "change your player skin number");
2162
2163         Cmd_AddCommand ("prespawn", Host_PreSpawn_f, "signon 1 (client acknowledges that server information has been received)");
2164         Cmd_AddCommand ("spawn", Host_Spawn_f, "signon 2 (client has sent player information, and is asking server to send scoreboard rankings)");
2165         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)");
2166         Cmd_AddCommand ("maxplayers", MaxPlayers_f, "sets limit on how many players (or bots) may be connected to the server at once");
2167
2168         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]
2169
2170         Cvar_RegisterVariable (&rcon_password);
2171         Cvar_RegisterVariable (&rcon_address);
2172         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)");
2173         Cmd_AddCommand ("packet", Host_Packet_f, "send a packet to the specified address:port containing a text string");
2174
2175         Cvar_RegisterVariable(&sv_cheats);
2176 }
2177