rewrote memory system entirely (hunk, cache, and zone are gone, memory pools replaced...
[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
25 dfunction_t *ED_FindFunction (char *name);
26
27 /*
28 ==================
29 Host_Quit_f
30 ==================
31 */
32
33 // LordHavoc: didn't like it asking me if I wanted to quit
34 //extern void M_Menu_Quit_f (void);
35
36 extern qboolean host_shuttingdown;
37 void Host_Quit_f (void)
38 {
39         /*
40         if (key_dest != key_console && cls.state != ca_dedicated)
41         {
42                 M_Menu_Quit_f ();
43                 return;
44         }
45         */
46         host_shuttingdown = true;
47         CL_Disconnect ();
48         Host_ShutdownServer(false);
49
50         Sys_Quit ();
51 }
52
53
54 /*
55 ==================
56 Host_Status_f
57 ==================
58 */
59 void Host_Status_f (void)
60 {
61         client_t        *client;
62         int                     seconds;
63         int                     minutes;
64         int                     hours = 0;
65         int                     j;
66         void            (*print) (char *fmt, ...);
67
68         if (cmd_source == src_command)
69         {
70                 if (!sv.active)
71                 {
72                         Cmd_ForwardToServer ();
73                         return;
74                 }
75                 print = Con_Printf;
76         }
77         else
78                 print = SV_ClientPrintf;
79
80         print ("host:    %s\n", Cvar_VariableString ("hostname"));
81         print ("version: %s build %i\n", gamename, buildnumber);
82         if (tcpipAvailable)
83                 print ("tcp/ip:  %s\n", my_tcpip_address);
84         if (ipxAvailable)
85                 print ("ipx:     %s\n", my_ipx_address);
86         print ("map:     %s\n", sv.name);
87         print ("players: %i active (%i max)\n\n", net_activeconnections, svs.maxclients);
88         for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
89         {
90                 if (!client->active)
91                         continue;
92                 seconds = (int)(net_time - client->netconnection->connecttime);
93                 minutes = seconds / 60;
94                 if (minutes)
95                 {
96                         seconds -= (minutes * 60);
97                         hours = minutes / 60;
98                         if (hours)
99                                 minutes -= (hours * 60);
100                 }
101                 else
102                         hours = 0;
103                 print ("#%-2u %-16.16s  %3i  %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->v.frags, hours, minutes, seconds);
104                 print ("   %s\n", client->netconnection->address);
105         }
106 }
107
108
109 /*
110 ==================
111 Host_God_f
112
113 Sets client to godmode
114 ==================
115 */
116 void Host_God_f (void)
117 {
118         if (cmd_source == src_command)
119         {
120                 Cmd_ForwardToServer ();
121                 return;
122         }
123
124         if (pr_global_struct->deathmatch)
125                 return;
126
127         sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
128         if (!((int)sv_player->v.flags & FL_GODMODE) )
129                 SV_ClientPrintf ("godmode OFF\n");
130         else
131                 SV_ClientPrintf ("godmode ON\n");
132 }
133
134 void Host_Notarget_f (void)
135 {
136         if (cmd_source == src_command)
137         {
138                 Cmd_ForwardToServer ();
139                 return;
140         }
141
142         if (pr_global_struct->deathmatch)
143                 return;
144
145         sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
146         if (!((int)sv_player->v.flags & FL_NOTARGET) )
147                 SV_ClientPrintf ("notarget OFF\n");
148         else
149                 SV_ClientPrintf ("notarget ON\n");
150 }
151
152 qboolean noclip_anglehack;
153
154 void Host_Noclip_f (void)
155 {
156         if (cmd_source == src_command)
157         {
158                 Cmd_ForwardToServer ();
159                 return;
160         }
161
162         if (pr_global_struct->deathmatch)
163                 return;
164
165         if (sv_player->v.movetype != MOVETYPE_NOCLIP)
166         {
167                 noclip_anglehack = true;
168                 sv_player->v.movetype = MOVETYPE_NOCLIP;
169                 SV_ClientPrintf ("noclip ON\n");
170         }
171         else
172         {
173                 noclip_anglehack = false;
174                 sv_player->v.movetype = MOVETYPE_WALK;
175                 SV_ClientPrintf ("noclip OFF\n");
176         }
177 }
178
179 /*
180 ==================
181 Host_Fly_f
182
183 Sets client to flymode
184 ==================
185 */
186 void Host_Fly_f (void)
187 {
188         if (cmd_source == src_command)
189         {
190                 Cmd_ForwardToServer ();
191                 return;
192         }
193
194         if (pr_global_struct->deathmatch)
195                 return;
196
197         if (sv_player->v.movetype != MOVETYPE_FLY)
198         {
199                 sv_player->v.movetype = MOVETYPE_FLY;
200                 SV_ClientPrintf ("flymode ON\n");
201         }
202         else
203         {
204                 sv_player->v.movetype = MOVETYPE_WALK;
205                 SV_ClientPrintf ("flymode OFF\n");
206         }
207 }
208
209
210 /*
211 ==================
212 Host_Ping_f
213
214 ==================
215 */
216 void Host_Ping_f (void)
217 {
218         int             i, j;
219         float   total;
220         client_t        *client;
221         
222         if (cmd_source == src_command)
223         {
224                 Cmd_ForwardToServer ();
225                 return;
226         }
227
228         SV_ClientPrintf ("Client ping times:\n");
229         for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
230         {
231                 if (!client->active)
232                         continue;
233                 total = 0;
234                 for (j=0 ; j<NUM_PING_TIMES ; j++)
235                         total+=client->ping_times[j];
236                 total /= NUM_PING_TIMES;
237                 SV_ClientPrintf ("%4i %s\n", (int)(total*1000), client->name);
238         }
239 }
240
241 /*
242 ===============================================================================
243
244 SERVER TRANSITIONS
245
246 ===============================================================================
247 */
248
249
250 /*
251 ======================
252 Host_Map_f
253
254 handle a 
255 map <servername>
256 command from the console.  Active clients are kicked off.
257 ======================
258 */
259 void Host_Map_f (void)
260 {
261         int             i;
262         char    name[MAX_QPATH];
263
264         if (cmd_source != src_command)
265                 return;
266
267         cls.demonum = -1;               // stop demo loop in case this fails
268
269 //      SCR_BeginLoadingPlaque ();
270
271         CL_Disconnect ();
272         Host_ShutdownServer(false);             
273
274         key_dest = key_game;                    // remove console or menu
275
276         cls.mapstring[0] = 0;
277         for (i=0 ; i<Cmd_Argc() ; i++)
278         {
279                 strcat (cls.mapstring, Cmd_Argv(i));
280                 strcat (cls.mapstring, " ");
281         }
282         strcat (cls.mapstring, "\n");
283
284         svs.serverflags = 0;                    // haven't completed an episode yet
285         strcpy (name, Cmd_Argv(1));
286         SV_SpawnServer (name);
287         if (!sv.active)
288                 return;
289         
290         if (cls.state != ca_dedicated)
291         {
292                 strcpy (cls.spawnparms, "");
293
294                 for (i=2 ; i<Cmd_Argc() ; i++)
295                 {
296                         strcat (cls.spawnparms, Cmd_Argv(i));
297                         strcat (cls.spawnparms, " ");
298                 }
299                 
300                 Cmd_ExecuteString ("connect local", src_command);
301         }       
302 }
303
304 /*
305 ==================
306 Host_Changelevel_f
307
308 Goes to a new map, taking all clients along
309 ==================
310 */
311 void Host_Changelevel_f (void)
312 {
313         char    level[MAX_QPATH];
314
315         if (Cmd_Argc() != 2)
316         {
317                 Con_Printf ("changelevel <levelname> : continue game on a new level\n");
318                 return;
319         }
320         if (!sv.active || cls.demoplayback)
321         {
322                 Con_Printf ("Only the server may changelevel\n");
323                 return;
324         }
325         SV_SaveSpawnparms ();
326         strcpy (level, Cmd_Argv(1));
327         SV_SpawnServer (level);
328 }
329
330 /*
331 ==================
332 Host_Restart_f
333
334 Restarts the current server for a dead player
335 ==================
336 */
337 void Host_Restart_f (void)
338 {
339         char    mapname[MAX_QPATH];
340
341         if (cls.demoplayback || !sv.active)
342                 return;
343
344         if (cmd_source != src_command)
345                 return;
346         strcpy (mapname, sv.name);      // must copy out, because it gets cleared
347                                                                 // in sv_spawnserver
348         SV_SpawnServer (mapname);
349 }
350
351 /*
352 ==================
353 Host_Reconnect_f
354
355 This command causes the client to wait for the signon messages again.
356 This is sent just before a server changes levels
357 ==================
358 */
359 void Host_Reconnect_f (void)
360 {
361 //      SCR_BeginLoadingPlaque ();
362         cls.signon = 0;         // need new connection messages
363 }
364
365 /*
366 =====================
367 Host_Connect_f
368
369 User command to connect to server
370 =====================
371 */
372 void Host_Connect_f (void)
373 {
374         char    name[MAX_QPATH];
375         
376         cls.demonum = -1;               // stop demo loop in case this fails
377         if (cls.demoplayback)
378                 CL_Disconnect ();
379         strcpy (name, Cmd_Argv(1));
380         CL_EstablishConnection (name);
381         Host_Reconnect_f ();
382 }
383
384
385 /*
386 ===============================================================================
387
388 LOAD / SAVE GAME
389
390 ===============================================================================
391 */
392
393 #define SAVEGAME_VERSION        5
394
395 /*
396 ===============
397 Host_SavegameComment
398
399 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current 
400 ===============
401 */
402 void Host_SavegameComment (char *text)
403 {
404         int             i;
405         char    kills[20];
406
407         for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
408                 text[i] = ' ';
409         memcpy (text, cl.levelname, strlen(cl.levelname));
410         sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
411         memcpy (text+22, kills, strlen(kills));
412 // convert space to _ to make stdio happy
413         for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
414                 if (text[i] == ' ')
415                         text[i] = '_';
416         text[SAVEGAME_COMMENT_LENGTH] = '\0';
417 }
418
419
420 /*
421 ===============
422 Host_Savegame_f
423 ===============
424 */
425 void Host_Savegame_f (void)
426 {
427         char    name[256];
428         QFile   *f;
429         int             i;
430         char    comment[SAVEGAME_COMMENT_LENGTH+1];
431
432         if (cmd_source != src_command)
433                 return;
434
435         if (!sv.active)
436         {
437                 Con_Printf ("Not playing a local game.\n");
438                 return;
439         }
440
441         if (cl.intermission)
442         {
443                 Con_Printf ("Can't save in intermission.\n");
444                 return;
445         }
446
447         if (svs.maxclients != 1)
448         {
449                 Con_Printf ("Can't save multiplayer games.\n");
450                 return;
451         }
452
453         if (Cmd_Argc() != 2)
454         {
455                 Con_Printf ("save <savename> : save a game\n");
456                 return;
457         }
458
459         if (strstr(Cmd_Argv(1), ".."))
460         {
461                 Con_Printf ("Relative pathnames are not allowed.\n");
462                 return;
463         }
464                 
465         for (i=0 ; i<svs.maxclients ; i++)
466         {
467                 if (svs.clients[i].active && (svs.clients[i].edict->v.health <= 0) )
468                 {
469                         Con_Printf ("Can't savegame with a dead player\n");
470                         return;
471                 }
472         }
473
474         sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
475         COM_DefaultExtension (name, ".sav");
476         
477         Con_Printf ("Saving game to %s...\n", name);
478         f = Qopen (name, "w");
479         if (!f)
480         {
481                 Con_Printf ("ERROR: couldn't open.\n");
482                 return;
483         }
484         
485         Qprintf (f, "%i\n", SAVEGAME_VERSION);
486         Host_SavegameComment (comment);
487         Qprintf (f, "%s\n", comment);
488         for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
489                 Qprintf (f, "%f\n", svs.clients->spawn_parms[i]);
490         Qprintf (f, "%d\n", current_skill);
491         Qprintf (f, "%s\n", sv.name);
492         Qprintf (f, "%f\n",sv.time);
493
494 // write the light styles
495
496         for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
497         {
498                 if (sv.lightstyles[i])
499                         Qprintf (f, "%s\n", sv.lightstyles[i]);
500                 else
501                         Qprintf (f,"m\n");
502         }
503
504
505         ED_WriteGlobals (f);
506         for (i=0 ; i<sv.num_edicts ; i++)
507         {
508                 ED_Write (f, EDICT_NUM(i));
509                 Qflush (f);
510         }
511         Qclose (f);
512         Con_Printf ("done.\n");
513 }
514
515
516 extern mempool_t *edictstring_mempool;
517
518 /*
519 ===============
520 Host_Loadgame_f
521 ===============
522 */
523 void Host_Loadgame_f (void)
524 {
525         char    name[MAX_OSPATH];
526         QFile   *f;
527         char    mapname[MAX_QPATH];
528         float   time, tfloat;
529         char    buf[32768], *start;
530         char    *str;
531         int             i, r;
532         edict_t *ent;
533         int             entnum;
534         int             version;
535         float   spawn_parms[NUM_SPAWN_PARMS];
536
537         if (cmd_source != src_command)
538                 return;
539
540         if (Cmd_Argc() != 2)
541         {
542                 Con_Printf ("load <savename> : load a game\n");
543                 return;
544         }
545
546         cls.demonum = -1;               // stop demo loop in case this fails
547
548         sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
549         COM_DefaultExtension (name, ".sav");
550
551         // LordHavoc: made SCR_UpdateScreen use a great deal less stack space, no longer an issue
552         //// we can't call SCR_BeginLoadingPlaque, because too much stack space has
553         //// been used.  The menu calls it before stuffing loadgame command
554 //      SCR_BeginLoadingPlaque ();
555
556         Con_Printf ("Loading game from %s...\n", name);
557         f = Qopen (name, "rz");
558         if (!f)
559         {
560                 Con_Printf ("ERROR: couldn't open.\n");
561                 return;
562         }
563
564         str = Qgetline (f);
565         sscanf (str, "%i\n", &version);
566         if (version != SAVEGAME_VERSION)
567         {
568                 Qclose (f);
569                 Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
570                 return;
571         }
572         str = Qgetline (f);
573         for (i=0 ; i<NUM_SPAWN_PARMS ; i++) {
574                 str = Qgetline (f);
575                 sscanf (str, "%f\n", &spawn_parms[i]);
576         }
577 // this silliness is so we can load 1.06 save files, which have float skill values
578         str = Qgetline (f);
579         sscanf (str, "%f\n", &tfloat);
580         current_skill = (int)(tfloat + 0.1);
581         Cvar_SetValue ("skill", (float)current_skill);
582
583         strcpy (mapname, Qgetline (f));
584
585         str = Qgetline (f);
586         sscanf (str, "%f\n",&time);
587
588         CL_Disconnect_f ();
589         
590         SV_SpawnServer (mapname);
591         if (!sv.active)
592         {
593                 Con_Printf ("Couldn't load map\n");
594                 return;
595         }
596         sv.paused = true;               // pause until all clients connect
597         sv.loadgame = true;
598
599 // load the light styles
600
601         for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
602         {
603                 str = Qgetline (f);
604                 sv.lightstyles[i] = Mem_Alloc(edictstring_mempool, strlen(str)+1);
605                 strcpy (sv.lightstyles[i], str);
606         }
607
608 // load the edicts out of the savegame file
609         entnum = -1;            // -1 is the globals
610         while (!Qeof(f))
611         {
612                 for (i=0 ; i<sizeof(buf)-1 ; i++)
613                 {
614                         r = Qgetc (f);
615                         if (r == EOF || !r)
616                                 break;
617                         buf[i] = r;
618                         if (r == '}')
619                         {
620                                 i++;
621                                 break;
622                         }
623                 }
624                 if (i == sizeof(buf)-1)
625                         Sys_Error ("Loadgame buffer overflow");
626                 buf[i] = 0;
627                 start = buf;
628                 start = COM_Parse(buf);
629                 if (!com_token[0])
630                         break;          // end of file
631                 if (strcmp(com_token,"{"))
632                         Sys_Error ("First token isn't a brace");
633                         
634                 if (entnum == -1)
635                 {       // parse the global vars
636                         ED_ParseGlobals (start);
637                 }
638                 else
639                 {       // parse an edict
640
641                         ent = EDICT_NUM(entnum);
642                         memset (&ent->v, 0, progs->entityfields * 4);
643                         ent->free = false;
644                         ED_ParseEdict (start, ent);
645         
646                 // link it into the bsp tree
647                         if (!ent->free)
648                                 SV_LinkEdict (ent, false);
649                 }
650
651                 entnum++;
652         }
653         
654         sv.num_edicts = entnum;
655         sv.time = time;
656
657         Qclose (f);
658
659         for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
660                 svs.clients->spawn_parms[i] = spawn_parms[i];
661
662         if (cls.state != ca_dedicated)
663         {
664                 CL_EstablishConnection ("local");
665                 Host_Reconnect_f ();
666         }
667 }
668
669 //============================================================================
670
671 /*
672 ======================
673 Host_Name_f
674 ======================
675 */
676 void Host_Name_f (void)
677 {
678         char newName[64];
679
680         if (Cmd_Argc () == 1)
681         {
682                 Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
683                 return;
684         }
685         //if (Cmd_Argc () == 2)
686         //      newName = Cmd_Argv(1);
687         //else
688         //      newName = Cmd_Args();
689         //newName[15] = 0;
690         if (Cmd_Argc () == 2)
691                 strncpy(newName, Cmd_Argv(1), 15);
692         else
693                 strncpy(newName, Cmd_Args(), 15);
694         newName[15] = 0;
695
696         if (cmd_source == src_command)
697         {
698                 if (strcmp(cl_name.string, newName) == 0)
699                         return;
700                 Cvar_Set ("_cl_name", newName);
701                 if (cls.state == ca_connected)
702                         Cmd_ForwardToServer ();
703                 return;
704         }
705
706         if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
707                 if (strcmp(host_client->name, newName) != 0)
708                         Con_Printf ("%s renamed to %s\n", host_client->name, newName);
709         strcpy (host_client->name, newName);
710         host_client->edict->v.netname = host_client->name - pr_strings;
711         
712 // send notification to all clients
713         
714         MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
715         MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
716         MSG_WriteString (&sv.reliable_datagram, host_client->name);
717 }
718
719         
720 void Host_Version_f (void)
721 {
722         Con_Printf ("Version: %s build %i\n", gamename, buildnumber);
723         Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
724 }
725
726 void Host_Say(qboolean teamonly)
727 {
728         client_t *client;
729         client_t *save;
730         int             j;
731         char    *p;
732         // LordHavoc: 256 char say messages
733         unsigned char   text[256];
734         qboolean        fromServer = false;
735
736         if (cmd_source == src_command)
737         {
738                 if (cls.state == ca_dedicated)
739                 {
740                         fromServer = true;
741                         teamonly = false;
742                 }
743                 else
744                 {
745                         Cmd_ForwardToServer ();
746                         return;
747                 }
748         }
749
750         if (Cmd_Argc () < 2)
751                 return;
752
753         save = host_client;
754
755         p = Cmd_Args();
756 // remove quotes if present
757         if (*p == '"')
758         {
759                 p++;
760                 p[strlen(p)-1] = 0;
761         }
762
763 // turn on color set 1
764         if (!fromServer)
765                 sprintf (text, "%c%s: ", 1, save->name);
766         else
767                 sprintf (text, "%c<%s> ", 1, hostname.string);
768
769         j = sizeof(text) - 2 - strlen(text);  // -2 for /n and null terminator
770         if (strlen(p) > j)
771                 p[j] = 0;
772
773         strcat (text, p);
774         strcat (text, "\n");
775
776         for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
777         {
778                 if (!client || !client->active || !client->spawned)
779                         continue;
780                 if (teamplay.integer && teamonly && client->edict->v.team != save->edict->v.team)
781                         continue;
782                 host_client = client;
783                 SV_ClientPrintf("%s", text);
784         }
785         host_client = save;
786
787         Sys_Printf("%s", &text[1]);
788 }
789
790
791 void Host_Say_f(void)
792 {
793         Host_Say(false);
794 }
795
796
797 void Host_Say_Team_f(void)
798 {
799         Host_Say(true);
800 }
801
802
803 void Host_Tell_f(void)
804 {
805         client_t *client;
806         client_t *save;
807         int             j;
808         char    *p;
809         char    text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
810
811         if (cmd_source == src_command)
812         {
813                 Cmd_ForwardToServer ();
814                 return;
815         }
816
817         if (Cmd_Argc () < 3)
818                 return;
819
820         strcpy(text, host_client->name);
821         strcat(text, ": ");
822
823         p = Cmd_Args();
824
825 // remove quotes if present
826         if (*p == '"')
827         {
828                 p++;
829                 p[strlen(p)-1] = 0;
830         }
831
832 // check length & truncate if necessary
833         j = sizeof(text) - 2 - strlen(text);  // -2 for /n and null terminator
834         if (strlen(p) > j)
835                 p[j] = 0;
836
837         strcat (text, p);
838         strcat (text, "\n");
839
840         save = host_client;
841         for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
842         {
843                 if (!client->active || !client->spawned)
844                         continue;
845                 if (Q_strcasecmp(client->name, Cmd_Argv(1)))
846                         continue;
847                 host_client = client;
848                 SV_ClientPrintf("%s", text);
849                 break;
850         }
851         host_client = save;
852 }
853
854
855 /*
856 ==================
857 Host_Color_f
858 ==================
859 */
860 void Host_Color_f(void)
861 {
862         int             top, bottom;
863         int             playercolor;
864         dfunction_t *f;
865         func_t  SV_ChangeTeam;
866         
867         if (Cmd_Argc() == 1)
868         {
869                 Con_Printf ("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15);
870                 Con_Printf ("color <0-13> [0-13]\n");
871                 return;
872         }
873
874         if (Cmd_Argc() == 2)
875                 top = bottom = atoi(Cmd_Argv(1));
876         else
877         {
878                 top = atoi(Cmd_Argv(1));
879                 bottom = atoi(Cmd_Argv(2));
880         }
881         
882         top &= 15;
883         // LordHavoc: allow skin colormaps 14 and 15 (was 13)
884         if (top > 15)
885                 top = 15;
886         bottom &= 15;
887         // LordHavoc: allow skin colormaps 14 and 15 (was 13)
888         if (bottom > 15)
889                 bottom = 15;
890         
891         playercolor = top*16 + bottom;
892
893         if (cmd_source == src_command)
894         {
895                 Cvar_SetValue ("_cl_color", playercolor);
896                 if (cls.state == ca_connected)
897                         Cmd_ForwardToServer ();
898                 return;
899         }
900
901         // void(float color) SV_ChangeTeam;
902         if ((f = ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - pr_functions)))
903         {
904                 Con_DPrintf("Calling SV_ChangeTeam\n");
905                 pr_global_struct->time = sv.time;
906                 pr_globals[0] = playercolor;
907                 pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
908                 PR_ExecuteProgram (SV_ChangeTeam, "");
909         }
910         else
911         {
912                 host_client->colors = playercolor;
913                 host_client->edict->v.team = bottom + 1;
914
915                 // send notification to all clients
916                 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
917                 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
918                 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
919         }
920 }
921
922 /*
923 ==================
924 Host_Kill_f
925 ==================
926 */
927 void Host_Kill_f (void)
928 {
929         if (cmd_source == src_command)
930         {
931                 Cmd_ForwardToServer ();
932                 return;
933         }
934
935         if (sv_player->v.health <= 0)
936         {
937                 SV_ClientPrintf ("Can't suicide -- already dead!\n");
938                 return;
939         }
940         
941         pr_global_struct->time = sv.time;
942         pr_global_struct->self = EDICT_TO_PROG(sv_player);
943         PR_ExecuteProgram (pr_global_struct->ClientKill, "QC function ClientKill is missing");
944 }
945
946
947 /*
948 ==================
949 Host_Pause_f
950 ==================
951 */
952 void Host_Pause_f (void)
953 {
954         
955         if (cmd_source == src_command)
956         {
957                 Cmd_ForwardToServer ();
958                 return;
959         }
960         if (!pausable.integer)
961                 SV_ClientPrintf ("Pause not allowed.\n");
962         else
963         {
964                 sv.paused ^= 1;
965
966                 if (sv.paused)
967                 {
968                         SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v.netname);
969                 }
970                 else
971                 {
972                         SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v.netname);
973                 }
974
975         // send notification to all clients
976                 MSG_WriteByte (&sv.reliable_datagram, svc_setpause);
977                 MSG_WriteByte (&sv.reliable_datagram, sv.paused);
978         }
979 }
980
981 //===========================================================================
982
983
984 /*
985 ==================
986 Host_PreSpawn_f
987 ==================
988 */
989 void Host_PreSpawn_f (void)
990 {
991         if (cmd_source == src_command)
992         {
993                 Con_Printf ("prespawn is not valid from the console\n");
994                 return;
995         }
996
997         if (host_client->spawned)
998         {
999                 Con_Printf ("prespawn not valid -- already spawned\n");
1000                 return;
1001         }
1002         
1003         SZ_Write (&host_client->message, sv.signon.data, sv.signon.cursize);
1004         MSG_WriteByte (&host_client->message, svc_signonnum);
1005         MSG_WriteByte (&host_client->message, 2);
1006         host_client->sendsignon = true;
1007 }
1008
1009 /*
1010 ==================
1011 Host_Spawn_f
1012 ==================
1013 */
1014 void Host_Spawn_f (void)
1015 {
1016         int             i;
1017         client_t        *client;
1018         edict_t *ent;
1019         func_t RestoreGame;
1020         dfunction_t *f;
1021
1022         if (cmd_source == src_command)
1023         {
1024                 Con_Printf ("spawn is not valid from the console\n");
1025                 return;
1026         }
1027
1028         if (host_client->spawned)
1029         {
1030                 Con_Printf ("Spawn not valid -- already spawned\n");
1031                 return;
1032         }
1033
1034         // LordHavoc: moved this above the QC calls at FrikaC's request
1035 // send all current names, colors, and frag counts
1036         SZ_Clear (&host_client->message);
1037
1038 // run the entrance script
1039         if (sv.loadgame)
1040         {       // loaded games are fully inited already
1041                 // if this is the last client to be connected, unpause
1042                 sv.paused = false;
1043
1044                 if ((f = ED_FindFunction ("RestoreGame")))
1045                 if ((RestoreGame = (func_t)(f - pr_functions)))
1046                 {
1047                         Con_DPrintf("Calling RestoreGame\n");
1048                         pr_global_struct->time = sv.time;
1049                         pr_global_struct->self = EDICT_TO_PROG(sv_player);
1050                         PR_ExecuteProgram (RestoreGame, "");
1051                 }
1052         }
1053         else
1054         {
1055                 eval_t *val;
1056                 // set up the edict
1057                 ent = host_client->edict;
1058
1059                 memset (&ent->v, 0, progs->entityfields * 4);
1060                 ent->v.colormap = NUM_FOR_EDICT(ent);
1061                 ent->v.team = (host_client->colors & 15) + 1;
1062                 ent->v.netname = host_client->name - pr_strings;
1063                 if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1064                         val->_float = host_client->pmodel;
1065
1066                 // copy spawn parms out of the client_t
1067
1068                 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1069                         (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
1070
1071                 // call the spawn function
1072
1073                 pr_global_struct->time = sv.time;
1074                 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1075                 PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
1076
1077                 if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= sv.time)
1078                         Sys_Printf ("%s entered the game\n", host_client->name);
1079
1080                 PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing");
1081         }
1082
1083
1084 // send time of update
1085         MSG_WriteByte (&host_client->message, svc_time);
1086         MSG_WriteFloat (&host_client->message, sv.time);
1087
1088         for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
1089         {
1090                 MSG_WriteByte (&host_client->message, svc_updatename);
1091                 MSG_WriteByte (&host_client->message, i);
1092                 MSG_WriteString (&host_client->message, client->name);
1093                 MSG_WriteByte (&host_client->message, svc_updatefrags);
1094                 MSG_WriteByte (&host_client->message, i);
1095                 MSG_WriteShort (&host_client->message, client->old_frags);
1096                 MSG_WriteByte (&host_client->message, svc_updatecolors);
1097                 MSG_WriteByte (&host_client->message, i);
1098                 MSG_WriteByte (&host_client->message, client->colors);
1099         }
1100         
1101 // send all current light styles
1102         for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1103         {
1104                 MSG_WriteByte (&host_client->message, svc_lightstyle);
1105                 MSG_WriteByte (&host_client->message, (char)i);
1106                 MSG_WriteString (&host_client->message, sv.lightstyles[i]);
1107         }
1108
1109 //
1110 // send some stats
1111 //
1112         MSG_WriteByte (&host_client->message, svc_updatestat);
1113         MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS);
1114         MSG_WriteLong (&host_client->message, pr_global_struct->total_secrets);
1115
1116         MSG_WriteByte (&host_client->message, svc_updatestat);
1117         MSG_WriteByte (&host_client->message, STAT_TOTALMONSTERS);
1118         MSG_WriteLong (&host_client->message, pr_global_struct->total_monsters);
1119
1120         MSG_WriteByte (&host_client->message, svc_updatestat);
1121         MSG_WriteByte (&host_client->message, STAT_SECRETS);
1122         MSG_WriteLong (&host_client->message, pr_global_struct->found_secrets);
1123
1124         MSG_WriteByte (&host_client->message, svc_updatestat);
1125         MSG_WriteByte (&host_client->message, STAT_MONSTERS);
1126         MSG_WriteLong (&host_client->message, pr_global_struct->killed_monsters);
1127
1128 //
1129 // send a fixangle
1130 // Never send a roll angle, because savegames can catch the server
1131 // in a state where it is expecting the client to correct the angle
1132 // and it won't happen if the game was just loaded, so you wind up
1133 // with a permanent head tilt
1134         ent = EDICT_NUM( 1 + (host_client - svs.clients) );
1135         MSG_WriteByte (&host_client->message, svc_setangle);
1136         for (i=0 ; i < 2 ; i++)
1137                 MSG_WriteAngle (&host_client->message, ent->v.angles[i] );
1138         MSG_WriteAngle (&host_client->message, 0 );
1139
1140         SV_WriteClientdataToMessage (sv_player, &host_client->message);
1141
1142         MSG_WriteByte (&host_client->message, svc_signonnum);
1143         MSG_WriteByte (&host_client->message, 3);
1144         host_client->sendsignon = true;
1145 }
1146
1147 /*
1148 ==================
1149 Host_Begin_f
1150 ==================
1151 */
1152 void Host_Begin_f (void)
1153 {
1154         if (cmd_source == src_command)
1155         {
1156                 Con_Printf ("begin is not valid from the console\n");
1157                 return;
1158         }
1159
1160         host_client->spawned = true;
1161 }
1162
1163 //===========================================================================
1164
1165
1166 /*
1167 ==================
1168 Host_Kick_f
1169
1170 Kicks a user off of the server
1171 ==================
1172 */
1173 void Host_Kick_f (void)
1174 {
1175         char            *who;
1176         char            *message = NULL;
1177         client_t        *save;
1178         int                     i;
1179         qboolean        byNumber = false;
1180
1181         if (cmd_source == src_command)
1182         {
1183                 if (!sv.active)
1184                 {
1185                         Cmd_ForwardToServer ();
1186                         return;
1187                 }
1188         }
1189         else if (pr_global_struct->deathmatch)
1190                 return;
1191
1192         save = host_client;
1193
1194         if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1195         {
1196                 i = atof(Cmd_Argv(2)) - 1;
1197                 if (i < 0 || i >= svs.maxclients)
1198                         return;
1199                 if (!svs.clients[i].active)
1200                         return;
1201                 host_client = &svs.clients[i];
1202                 byNumber = true;
1203         }
1204         else
1205         {
1206                 for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
1207                 {
1208                         if (!host_client->active)
1209                                 continue;
1210                         if (Q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1211                                 break;
1212                 }
1213         }
1214
1215         if (i < svs.maxclients)
1216         {
1217                 if (cmd_source == src_command)
1218                         if (cls.state == ca_dedicated)
1219                                 who = "Console";
1220                         else
1221                                 who = cl_name.string;
1222                 else
1223                         who = save->name;
1224
1225                 // can't kick yourself!
1226                 if (host_client == save)
1227                         return;
1228
1229                 if (Cmd_Argc() > 2)
1230                 {
1231                         message = COM_Parse(Cmd_Args());
1232                         if (byNumber)
1233                         {
1234                                 message++;                                                      // skip the #
1235                                 while (*message == ' ')                         // skip white space
1236                                         message++;
1237                                 message += strlen(Cmd_Argv(2)); // skip the number
1238                         }
1239                         while (*message && *message == ' ')
1240                                 message++;
1241                 }
1242                 if (message)
1243                         SV_ClientPrintf ("Kicked by %s: %s\n", who, message);
1244                 else
1245                         SV_ClientPrintf ("Kicked by %s\n", who);
1246                 SV_DropClient (false);
1247         }
1248
1249         host_client = save;
1250 }
1251
1252 /*
1253 ===============================================================================
1254
1255 DEBUGGING TOOLS
1256
1257 ===============================================================================
1258 */
1259
1260 /*
1261 ==================
1262 Host_Give_f
1263 ==================
1264 */
1265 void Host_Give_f (void)
1266 {
1267         char    *t;
1268         int             v;
1269         eval_t  *val;
1270
1271         if (cmd_source == src_command)
1272         {
1273                 Cmd_ForwardToServer ();
1274                 return;
1275         }
1276
1277         if (pr_global_struct->deathmatch)
1278                 return;
1279
1280         t = Cmd_Argv(1);
1281         v = atoi (Cmd_Argv(2));
1282
1283         switch (t[0])
1284         {
1285         case '0':
1286         case '1':
1287         case '2':
1288         case '3':
1289         case '4':
1290         case '5':
1291         case '6':
1292         case '7':
1293         case '8':
1294         case '9':
1295                 // MED 01/04/97 added hipnotic give stuff
1296                 if (gamemode == GAME_HIPNOTIC)
1297                 {
1298                         if (t[0] == '6')
1299                         {
1300                                 if (t[1] == 'a')
1301                                 sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN;
1302                                 else
1303                                 sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER;
1304                         }
1305                         else if (t[0] == '9')
1306                                 sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON;
1307                         else if (t[0] == '0')
1308                                 sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR;
1309                         else if (t[0] >= '2')
1310                                 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1311                 }
1312                 else
1313                 {
1314                         if (t[0] >= '2')
1315                                 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1316                 }
1317                 break;
1318
1319         case 's':
1320                 if (gamemode == GAME_ROGUE)
1321                 {
1322                         if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1)))
1323                                 val->_float = v;
1324                 }
1325
1326                 sv_player->v.ammo_shells = v;
1327                 break;
1328         case 'n':
1329                 if (gamemode == GAME_ROGUE)
1330                 {
1331                         if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1)))
1332                         {
1333                                 val->_float = v;
1334                                 if (sv_player->v.weapon <= IT_LIGHTNING)
1335                                         sv_player->v.ammo_nails = v;
1336                         }
1337                 }
1338                 else
1339                 {
1340                         sv_player->v.ammo_nails = v;
1341                 }
1342                 break;
1343         case 'l':
1344                 if (gamemode == GAME_ROGUE)
1345                 {
1346                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_lava_nails);
1347                         if (val)
1348                         {
1349                                 val->_float = v;
1350                                 if (sv_player->v.weapon > IT_LIGHTNING)
1351                                         sv_player->v.ammo_nails = v;
1352                         }
1353                 }
1354                 break;
1355         case 'r':
1356                 if (gamemode == GAME_ROGUE)
1357                 {
1358                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_rockets1);
1359                         if (val)
1360                         {
1361                                 val->_float = v;
1362                                 if (sv_player->v.weapon <= IT_LIGHTNING)
1363                                         sv_player->v.ammo_rockets = v;
1364                         }
1365                 }
1366                 else
1367                 {
1368                         sv_player->v.ammo_rockets = v;
1369                 }
1370                 break;
1371         case 'm':
1372                 if (gamemode == GAME_ROGUE)
1373                 {
1374                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_multi_rockets);
1375                         if (val)
1376                         {
1377                                 val->_float = v;
1378                                 if (sv_player->v.weapon > IT_LIGHTNING)
1379                                         sv_player->v.ammo_rockets = v;
1380                         }
1381                 }
1382                 break;
1383         case 'h':
1384                 sv_player->v.health = v;
1385                 break;
1386         case 'c':
1387                 if (gamemode == GAME_ROGUE)
1388                 {
1389                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_cells1);
1390                         if (val)
1391                         {
1392                                 val->_float = v;
1393                                 if (sv_player->v.weapon <= IT_LIGHTNING)
1394                                         sv_player->v.ammo_cells = v;
1395                         }
1396                 }
1397                 else
1398                 {
1399                         sv_player->v.ammo_cells = v;
1400                 }
1401                 break;
1402         case 'p':
1403                 if (gamemode == GAME_ROGUE)
1404                 {
1405                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_plasma);
1406                         if (val)
1407                         {
1408                                 val->_float = v;
1409                                 if (sv_player->v.weapon > IT_LIGHTNING)
1410                                         sv_player->v.ammo_cells = v;
1411                         }
1412                 }
1413                 break;
1414         }
1415 }
1416
1417 edict_t *FindViewthing (void)
1418 {
1419         int             i;
1420         edict_t *e;
1421
1422         for (i=0 ; i<sv.num_edicts ; i++)
1423         {
1424                 e = EDICT_NUM(i);
1425                 if ( !strcmp (pr_strings + e->v.classname, "viewthing") )
1426                         return e;
1427         }
1428         Con_Printf ("No viewthing on map\n");
1429         return NULL;
1430 }
1431
1432 /*
1433 ==================
1434 Host_Viewmodel_f
1435 ==================
1436 */
1437 void Host_Viewmodel_f (void)
1438 {
1439         edict_t *e;
1440         model_t *m;
1441
1442         e = FindViewthing ();
1443         if (!e)
1444                 return;
1445
1446         m = Mod_ForName (Cmd_Argv(1), false, true, false);
1447         if (!m)
1448         {
1449                 Con_Printf ("Can't load %s\n", Cmd_Argv(1));
1450                 return;
1451         }
1452         
1453         e->v.frame = 0;
1454         cl.model_precache[(int)e->v.modelindex] = m;
1455 }
1456
1457 /*
1458 ==================
1459 Host_Viewframe_f
1460 ==================
1461 */
1462 void Host_Viewframe_f (void)
1463 {
1464         edict_t *e;
1465         int             f;
1466         model_t *m;
1467
1468         e = FindViewthing ();
1469         if (!e)
1470                 return;
1471         m = cl.model_precache[(int)e->v.modelindex];
1472
1473         f = atoi(Cmd_Argv(1));
1474         if (f >= m->numframes)
1475                 f = m->numframes-1;
1476
1477         e->v.frame = f;         
1478 }
1479
1480
1481 void PrintFrameName (model_t *m, int frame)
1482 {
1483         if (m->animscenes)
1484                 Con_Printf("frame %i: %s\n", frame, m->animscenes[frame].name);
1485         else
1486                 Con_Printf("frame %i\n", frame);
1487 }
1488
1489 /*
1490 ==================
1491 Host_Viewnext_f
1492 ==================
1493 */
1494 void Host_Viewnext_f (void)
1495 {
1496         edict_t *e;
1497         model_t *m;
1498         
1499         e = FindViewthing ();
1500         if (!e)
1501                 return;
1502         m = cl.model_precache[(int)e->v.modelindex];
1503
1504         e->v.frame = e->v.frame + 1;
1505         if (e->v.frame >= m->numframes)
1506                 e->v.frame = m->numframes - 1;
1507
1508         PrintFrameName (m, e->v.frame);         
1509 }
1510
1511 /*
1512 ==================
1513 Host_Viewprev_f
1514 ==================
1515 */
1516 void Host_Viewprev_f (void)
1517 {
1518         edict_t *e;
1519         model_t *m;
1520
1521         e = FindViewthing ();
1522         if (!e)
1523                 return;
1524
1525         m = cl.model_precache[(int)e->v.modelindex];
1526
1527         e->v.frame = e->v.frame - 1;
1528         if (e->v.frame < 0)
1529                 e->v.frame = 0;
1530
1531         PrintFrameName (m, e->v.frame);         
1532 }
1533
1534 /*
1535 ===============================================================================
1536
1537 DEMO LOOP CONTROL
1538
1539 ===============================================================================
1540 */
1541
1542
1543 /*
1544 ==================
1545 Host_Startdemos_f
1546 ==================
1547 */
1548 void Host_Startdemos_f (void)
1549 {
1550         int             i, c;
1551
1552         if (cls.state == ca_dedicated)
1553         {
1554                 if (!sv.active)
1555                         Cbuf_AddText ("map start\n");
1556                 return;
1557         }
1558
1559         c = Cmd_Argc() - 1;
1560         if (c > MAX_DEMOS)
1561         {
1562                 Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS);
1563                 c = MAX_DEMOS;
1564         }
1565         Con_Printf ("%i demo(s) in loop\n", c);
1566
1567         for (i=1 ; i<c+1 ; i++)
1568                 strncpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0])-1);
1569
1570         if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1571         {
1572                 cls.demonum = 0;
1573                 CL_NextDemo ();
1574         }
1575         else
1576                 cls.demonum = -1;
1577 }
1578
1579
1580 /*
1581 ==================
1582 Host_Demos_f
1583
1584 Return to looping demos
1585 ==================
1586 */
1587 void Host_Demos_f (void)
1588 {
1589         if (cls.state == ca_dedicated)
1590                 return;
1591         if (cls.demonum == -1)
1592                 cls.demonum = 1;
1593         CL_Disconnect_f ();
1594         CL_NextDemo ();
1595 }
1596
1597 /*
1598 ==================
1599 Host_Stopdemo_f
1600
1601 Return to looping demos
1602 ==================
1603 */
1604 void Host_Stopdemo_f (void)
1605 {
1606         if (cls.state == ca_dedicated)
1607                 return;
1608         if (!cls.demoplayback)
1609                 return;
1610         CL_Disconnect ();
1611 }
1612
1613 //=============================================================================
1614
1615 /*
1616 ==================
1617 Host_InitCommands
1618 ==================
1619 */
1620 void Host_InitCommands (void)
1621 {
1622         Cmd_AddCommand ("status", Host_Status_f);
1623         Cmd_AddCommand ("quit", Host_Quit_f);
1624         if (gamemode == GAME_NEHAHRA)
1625         {
1626                 Cmd_AddCommand ("max", Host_God_f);
1627                 Cmd_AddCommand ("monster", Host_Notarget_f);
1628                 Cmd_AddCommand ("scrag", Host_Fly_f);
1629                 Cmd_AddCommand ("wraith", Host_Noclip_f);
1630                 Cmd_AddCommand ("gimme", Host_Give_f);
1631         }
1632         else
1633         {
1634                 Cmd_AddCommand ("god", Host_God_f);
1635                 Cmd_AddCommand ("notarget", Host_Notarget_f);
1636                 Cmd_AddCommand ("fly", Host_Fly_f);
1637                 Cmd_AddCommand ("noclip", Host_Noclip_f);
1638                 Cmd_AddCommand ("give", Host_Give_f);
1639         }
1640         Cmd_AddCommand ("map", Host_Map_f);
1641         Cmd_AddCommand ("restart", Host_Restart_f);
1642         Cmd_AddCommand ("changelevel", Host_Changelevel_f);
1643         Cmd_AddCommand ("connect", Host_Connect_f);
1644         Cmd_AddCommand ("reconnect", Host_Reconnect_f);
1645         Cmd_AddCommand ("name", Host_Name_f);
1646         Cmd_AddCommand ("version", Host_Version_f);
1647         Cmd_AddCommand ("say", Host_Say_f);
1648         Cmd_AddCommand ("say_team", Host_Say_Team_f);
1649         Cmd_AddCommand ("tell", Host_Tell_f);
1650         Cmd_AddCommand ("color", Host_Color_f);
1651         Cmd_AddCommand ("kill", Host_Kill_f);
1652         Cmd_AddCommand ("pause", Host_Pause_f);
1653         Cmd_AddCommand ("spawn", Host_Spawn_f);
1654         Cmd_AddCommand ("begin", Host_Begin_f);
1655         Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
1656         Cmd_AddCommand ("kick", Host_Kick_f);
1657         Cmd_AddCommand ("ping", Host_Ping_f);
1658         Cmd_AddCommand ("load", Host_Loadgame_f);
1659         Cmd_AddCommand ("save", Host_Savegame_f);
1660
1661         Cmd_AddCommand ("startdemos", Host_Startdemos_f);
1662         Cmd_AddCommand ("demos", Host_Demos_f);
1663         Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
1664
1665         Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
1666         Cmd_AddCommand ("viewframe", Host_Viewframe_f);
1667         Cmd_AddCommand ("viewnext", Host_Viewnext_f);
1668         Cmd_AddCommand ("viewprev", Host_Viewprev_f);
1669 }