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