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