]> icculus.org git repositories - divverent/darkplaces.git/blob - host_cmd.c
cleaned up nearly all of the externs in .c files (moved to appropriate .h files)
[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
25 void Mod_Print (void);
26
27 dfunction_t *ED_FindFunction (char *name);
28
29 /*
30 ==================
31 Host_Quit_f
32 ==================
33 */
34
35 // LordHavoc: didn't like it asking me if I wanted to quit
36 //extern void M_Menu_Quit_f (void);
37
38 void Host_Quit_f (void)
39 {
40         /*
41         if (key_dest != key_console && cls.state != ca_dedicated)
42         {
43                 M_Menu_Quit_f ();
44                 return;
45         }
46         */
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: %4.2f (build %i)\n", VERSION, 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         {
379                 CL_StopPlayback ();
380                 CL_Disconnect ();
381         }
382         strcpy (name, Cmd_Argv(1));
383         CL_EstablishConnection (name);
384         Host_Reconnect_f ();
385 }
386
387
388 /*
389 ===============================================================================
390
391 LOAD / SAVE GAME
392
393 ===============================================================================
394 */
395
396 #define SAVEGAME_VERSION        5
397
398 /*
399 ===============
400 Host_SavegameComment
401
402 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current 
403 ===============
404 */
405 void Host_SavegameComment (char *text)
406 {
407         int             i;
408         char    kills[20];
409
410         for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
411                 text[i] = ' ';
412         memcpy (text, cl.levelname, strlen(cl.levelname));
413         sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
414         memcpy (text+22, kills, strlen(kills));
415 // convert space to _ to make stdio happy
416         for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
417                 if (text[i] == ' ')
418                         text[i] = '_';
419         text[SAVEGAME_COMMENT_LENGTH] = '\0';
420 }
421
422
423 /*
424 ===============
425 Host_Savegame_f
426 ===============
427 */
428 void Host_Savegame_f (void)
429 {
430         char    name[256];
431         FILE    *f;
432         int             i;
433         char    comment[SAVEGAME_COMMENT_LENGTH+1];
434
435         if (cmd_source != src_command)
436                 return;
437
438         if (!sv.active)
439         {
440                 Con_Printf ("Not playing a local game.\n");
441                 return;
442         }
443
444         if (cl.intermission)
445         {
446                 Con_Printf ("Can't save in intermission.\n");
447                 return;
448         }
449
450         if (svs.maxclients != 1)
451         {
452                 Con_Printf ("Can't save multiplayer games.\n");
453                 return;
454         }
455
456         if (Cmd_Argc() != 2)
457         {
458                 Con_Printf ("save <savename> : save a game\n");
459                 return;
460         }
461
462         if (strstr(Cmd_Argv(1), ".."))
463         {
464                 Con_Printf ("Relative pathnames are not allowed.\n");
465                 return;
466         }
467                 
468         for (i=0 ; i<svs.maxclients ; i++)
469         {
470                 if (svs.clients[i].active && (svs.clients[i].edict->v.health <= 0) )
471                 {
472                         Con_Printf ("Can't savegame with a dead player\n");
473                         return;
474                 }
475         }
476
477         sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
478         COM_DefaultExtension (name, ".sav");
479         
480         Con_Printf ("Saving game to %s...\n", name);
481         f = fopen (name, "w");
482         if (!f)
483         {
484                 Con_Printf ("ERROR: couldn't open.\n");
485                 return;
486         }
487         
488         fprintf (f, "%i\n", SAVEGAME_VERSION);
489         Host_SavegameComment (comment);
490         fprintf (f, "%s\n", comment);
491         for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
492                 fprintf (f, "%f\n", svs.clients->spawn_parms[i]);
493         fprintf (f, "%d\n", current_skill);
494         fprintf (f, "%s\n", sv.name);
495         fprintf (f, "%f\n",sv.time);
496
497 // write the light styles
498
499         for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
500         {
501                 if (sv.lightstyles[i])
502                         fprintf (f, "%s\n", sv.lightstyles[i]);
503                 else
504                         fprintf (f,"m\n");
505         }
506
507
508         ED_WriteGlobals (f);
509         for (i=0 ; i<sv.num_edicts ; i++)
510         {
511                 ED_Write (f, EDICT_NUM(i));
512                 fflush (f);
513         }
514         fclose (f);
515         Con_Printf ("done.\n");
516 }
517
518
519 /*
520 ===============
521 Host_Loadgame_f
522 ===============
523 */
524 void Host_Loadgame_f (void)
525 {
526         char    name[MAX_OSPATH];
527         FILE    *f;
528         char    mapname[MAX_QPATH];
529         float   time, tfloat;
530         char    str[32768], *start;
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 = fopen (name, "r");
558         if (!f)
559         {
560                 Con_Printf ("ERROR: couldn't open.\n");
561                 return;
562         }
563
564         fscanf (f, "%i\n", &version);
565         if (version != SAVEGAME_VERSION)
566         {
567                 fclose (f);
568                 Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
569                 return;
570         }
571         fscanf (f, "%s\n", str);
572         for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
573                 fscanf (f, "%f\n", &spawn_parms[i]);
574 // this silliness is so we can load 1.06 save files, which have float skill values
575         fscanf (f, "%f\n", &tfloat);
576         current_skill = (int)(tfloat + 0.1);
577         Cvar_SetValue ("skill", (float)current_skill);
578
579         fscanf (f, "%s\n",mapname);
580         fscanf (f, "%f\n",&time);
581
582         CL_Disconnect_f ();
583         
584         SV_SpawnServer (mapname);
585         if (!sv.active)
586         {
587                 Con_Printf ("Couldn't load map\n");
588                 return;
589         }
590         sv.paused = true;               // pause until all clients connect
591         sv.loadgame = true;
592
593 // load the light styles
594
595         for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
596         {
597                 fscanf (f, "%s\n", str);
598                 sv.lightstyles[i] = Hunk_AllocName (strlen(str)+1, "lightstyles");
599                 strcpy (sv.lightstyles[i], str);
600         }
601
602 // load the edicts out of the savegame file
603         entnum = -1;            // -1 is the globals
604         while (!feof(f))
605         {
606                 for (i=0 ; i<sizeof(str)-1 ; i++)
607                 {
608                         r = fgetc (f);
609                         if (r == EOF || !r)
610                                 break;
611                         str[i] = r;
612                         if (r == '}')
613                         {
614                                 i++;
615                                 break;
616                         }
617                 }
618                 if (i == sizeof(str)-1)
619                         Sys_Error ("Loadgame buffer overflow");
620                 str[i] = 0;
621                 start = str;
622                 start = COM_Parse(str);
623                 if (!com_token[0])
624                         break;          // end of file
625                 if (strcmp(com_token,"{"))
626                         Sys_Error ("First token isn't a brace");
627                         
628                 if (entnum == -1)
629                 {       // parse the global vars
630                         ED_ParseGlobals (start);
631                 }
632                 else
633                 {       // parse an edict
634
635                         ent = EDICT_NUM(entnum);
636                         memset (&ent->v, 0, progs->entityfields * 4);
637                         ent->free = false;
638                         ED_ParseEdict (start, ent);
639         
640                 // link it into the bsp tree
641                         if (!ent->free)
642                                 SV_LinkEdict (ent, false);
643                 }
644
645                 entnum++;
646         }
647         
648         sv.num_edicts = entnum;
649         sv.time = time;
650
651         fclose (f);
652
653         for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
654                 svs.clients->spawn_parms[i] = spawn_parms[i];
655
656         if (cls.state != ca_dedicated)
657         {
658                 CL_EstablishConnection ("local");
659                 Host_Reconnect_f ();
660         }
661 }
662
663 //============================================================================
664
665 /*
666 ======================
667 Host_Name_f
668 ======================
669 */
670 void Host_Name_f (void)
671 {
672         char    *newName;
673
674         if (Cmd_Argc () == 1)
675         {
676                 Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
677                 return;
678         }
679         if (Cmd_Argc () == 2)
680                 newName = Cmd_Argv(1);  
681         else
682                 newName = Cmd_Args();
683         newName[15] = 0;
684
685         if (cmd_source == src_command)
686         {
687                 if (strcmp(cl_name.string, newName) == 0)
688                         return;
689                 Cvar_Set ("_cl_name", newName);
690                 if (cls.state == ca_connected)
691                         Cmd_ForwardToServer ();
692                 return;
693         }
694
695         if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
696                 if (strcmp(host_client->name, newName) != 0)
697                         Con_Printf ("%s renamed to %s\n", host_client->name, newName);
698         strcpy (host_client->name, newName);
699         host_client->edict->v.netname = host_client->name - pr_strings;
700         
701 // send notification to all clients
702         
703         MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
704         MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
705         MSG_WriteString (&sv.reliable_datagram, host_client->name);
706 }
707
708         
709 void Host_Version_f (void)
710 {
711         Con_Printf ("Version %4.2f (build %i)\n", VERSION, buildnumber);
712         Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
713 }
714
715 void Host_Say(qboolean teamonly)
716 {
717         client_t *client;
718         client_t *save;
719         int             j;
720         char    *p;
721         // LordHavoc: 256 char say messages
722         unsigned char   text[256];
723         qboolean        fromServer = false;
724
725         if (cmd_source == src_command)
726         {
727                 if (cls.state == ca_dedicated)
728                 {
729                         fromServer = true;
730                         teamonly = false;
731                 }
732                 else
733                 {
734                         Cmd_ForwardToServer ();
735                         return;
736                 }
737         }
738
739         if (Cmd_Argc () < 2)
740                 return;
741
742         save = host_client;
743
744         p = Cmd_Args();
745 // remove quotes if present
746         if (*p == '"')
747         {
748                 p++;
749                 p[strlen(p)-1] = 0;
750         }
751
752 // turn on color set 1
753         if (!fromServer)
754                 sprintf (text, "%c%s: ", 1, save->name);
755         else
756                 sprintf (text, "%c<%s> ", 1, hostname.string);
757
758         j = sizeof(text) - 2 - strlen(text);  // -2 for /n and null terminator
759         if (strlen(p) > j)
760                 p[j] = 0;
761
762         strcat (text, p);
763         strcat (text, "\n");
764
765         for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
766         {
767                 if (!client || !client->active || !client->spawned)
768                         continue;
769                 if (teamplay.value && teamonly && client->edict->v.team != save->edict->v.team)
770                         continue;
771                 host_client = client;
772                 SV_ClientPrintf("%s", text);
773         }
774         host_client = save;
775
776         Sys_Printf("%s", &text[1]);
777 }
778
779
780 void Host_Say_f(void)
781 {
782         Host_Say(false);
783 }
784
785
786 void Host_Say_Team_f(void)
787 {
788         Host_Say(true);
789 }
790
791
792 void Host_Tell_f(void)
793 {
794         client_t *client;
795         client_t *save;
796         int             j;
797         char    *p;
798         char    text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
799
800         if (cmd_source == src_command)
801         {
802                 Cmd_ForwardToServer ();
803                 return;
804         }
805
806         if (Cmd_Argc () < 3)
807                 return;
808
809         strcpy(text, host_client->name);
810         strcat(text, ": ");
811
812         p = Cmd_Args();
813
814 // remove quotes if present
815         if (*p == '"')
816         {
817                 p++;
818                 p[strlen(p)-1] = 0;
819         }
820
821 // check length & truncate if necessary
822         j = sizeof(text) - 2 - strlen(text);  // -2 for /n and null terminator
823         if (strlen(p) > j)
824                 p[j] = 0;
825
826         strcat (text, p);
827         strcat (text, "\n");
828
829         save = host_client;
830         for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
831         {
832                 if (!client->active || !client->spawned)
833                         continue;
834                 if (Q_strcasecmp(client->name, Cmd_Argv(1)))
835                         continue;
836                 host_client = client;
837                 SV_ClientPrintf("%s", text);
838                 break;
839         }
840         host_client = save;
841 }
842
843
844 /*
845 ==================
846 Host_Color_f
847 ==================
848 */
849 void Host_Color_f(void)
850 {
851         int             top, bottom;
852         int             playercolor;
853         dfunction_t *f;
854         func_t  SV_ChangeTeam;
855         
856         if (Cmd_Argc() == 1)
857         {
858                 Con_Printf ("\"color\" is \"%i %i\"\n", ((int)cl_color.value) >> 4, ((int)cl_color.value) & 0x0f);
859                 Con_Printf ("color <0-13> [0-13]\n");
860                 return;
861         }
862
863         if (Cmd_Argc() == 2)
864                 top = bottom = atoi(Cmd_Argv(1));
865         else
866         {
867                 top = atoi(Cmd_Argv(1));
868                 bottom = atoi(Cmd_Argv(2));
869         }
870         
871         top &= 15;
872         // LordHavoc: allow skin colormaps 14 and 15 (was 13)
873         if (top > 15)
874                 top = 15;
875         bottom &= 15;
876         // LordHavoc: allow skin colormaps 14 and 15 (was 13)
877         if (bottom > 15)
878                 bottom = 15;
879         
880         playercolor = top*16 + bottom;
881
882         if (cmd_source == src_command)
883         {
884                 Cvar_SetValue ("_cl_color", playercolor);
885                 if (cls.state == ca_connected)
886                         Cmd_ForwardToServer ();
887                 return;
888         }
889
890         // void(float color) SV_ChangeTeam;
891         if ((f = ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - pr_functions)))
892         {
893                 Con_DPrintf("Calling SV_ChangeTeam\n");
894                 pr_global_struct->time = sv.time;
895                 pr_globals[0] = playercolor;
896                 pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
897                 PR_ExecuteProgram (SV_ChangeTeam, "");
898         }
899         else
900         {
901                 host_client->colors = playercolor;
902                 host_client->edict->v.team = bottom + 1;
903
904                 // send notification to all clients
905                 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
906                 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
907                 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
908         }
909 }
910
911 /*
912 ==================
913 Host_Kill_f
914 ==================
915 */
916 void Host_Kill_f (void)
917 {
918         if (cmd_source == src_command)
919         {
920                 Cmd_ForwardToServer ();
921                 return;
922         }
923
924         if (sv_player->v.health <= 0)
925         {
926                 SV_ClientPrintf ("Can't suicide -- already dead!\n");
927                 return;
928         }
929         
930         pr_global_struct->time = sv.time;
931         pr_global_struct->self = EDICT_TO_PROG(sv_player);
932         PR_ExecuteProgram (pr_global_struct->ClientKill, "QC function ClientKill is missing");
933 }
934
935
936 /*
937 ==================
938 Host_Pause_f
939 ==================
940 */
941 void Host_Pause_f (void)
942 {
943         
944         if (cmd_source == src_command)
945         {
946                 Cmd_ForwardToServer ();
947                 return;
948         }
949         if (!pausable.value)
950                 SV_ClientPrintf ("Pause not allowed.\n");
951         else
952         {
953                 sv.paused ^= 1;
954
955                 if (sv.paused)
956                 {
957                         SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v.netname);
958                 }
959                 else
960                 {
961                         SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v.netname);
962                 }
963
964         // send notification to all clients
965                 MSG_WriteByte (&sv.reliable_datagram, svc_setpause);
966                 MSG_WriteByte (&sv.reliable_datagram, sv.paused);
967         }
968 }
969
970 //===========================================================================
971
972
973 /*
974 ==================
975 Host_PreSpawn_f
976 ==================
977 */
978 void Host_PreSpawn_f (void)
979 {
980         if (cmd_source == src_command)
981         {
982                 Con_Printf ("prespawn is not valid from the console\n");
983                 return;
984         }
985
986         if (host_client->spawned)
987         {
988                 Con_Printf ("prespawn not valid -- already spawned\n");
989                 return;
990         }
991         
992         SZ_Write (&host_client->message, sv.signon.data, sv.signon.cursize);
993         MSG_WriteByte (&host_client->message, svc_signonnum);
994         MSG_WriteByte (&host_client->message, 2);
995         host_client->sendsignon = true;
996 }
997
998 /*
999 ==================
1000 Host_Spawn_f
1001 ==================
1002 */
1003 void Host_Spawn_f (void)
1004 {
1005         int             i;
1006         client_t        *client;
1007         edict_t *ent;
1008         func_t RestoreGame;
1009         dfunction_t *f;
1010
1011         if (cmd_source == src_command)
1012         {
1013                 Con_Printf ("spawn is not valid from the console\n");
1014                 return;
1015         }
1016
1017         if (host_client->spawned)
1018         {
1019                 Con_Printf ("Spawn not valid -- already spawned\n");
1020                 return;
1021         }
1022
1023         // LordHavoc: moved this above the QC calls at FrikaC's request
1024 // send all current names, colors, and frag counts
1025         SZ_Clear (&host_client->message);
1026
1027 // run the entrance script
1028         if (sv.loadgame)
1029         {       // loaded games are fully inited already
1030                 // if this is the last client to be connected, unpause
1031                 sv.paused = false;
1032
1033                 if ((f = ED_FindFunction ("RestoreGame")))
1034                 if ((RestoreGame = (func_t)(f - pr_functions)))
1035                 {
1036                         Con_DPrintf("Calling RestoreGame\n");
1037                         pr_global_struct->time = sv.time;
1038                         pr_global_struct->self = EDICT_TO_PROG(sv_player);
1039                         PR_ExecuteProgram (RestoreGame, "");
1040                 }
1041         }
1042         else
1043         {
1044                 eval_t *val;
1045                 // set up the edict
1046                 ent = host_client->edict;
1047
1048                 memset (&ent->v, 0, progs->entityfields * 4);
1049                 ent->v.colormap = NUM_FOR_EDICT(ent);
1050                 ent->v.team = (host_client->colors & 15) + 1;
1051                 ent->v.netname = host_client->name - pr_strings;
1052                 if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1053                         val->_float = host_client->pmodel;
1054
1055                 // copy spawn parms out of the client_t
1056
1057                 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1058                         (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
1059
1060                 // call the spawn function
1061
1062                 pr_global_struct->time = sv.time;
1063                 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1064                 PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
1065
1066                 if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= sv.time)
1067                         Sys_Printf ("%s entered the game\n", host_client->name);
1068
1069                 PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing");
1070         }
1071
1072
1073 // send time of update
1074         MSG_WriteByte (&host_client->message, svc_time);
1075         MSG_WriteFloat (&host_client->message, sv.time);
1076
1077         for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
1078         {
1079                 MSG_WriteByte (&host_client->message, svc_updatename);
1080                 MSG_WriteByte (&host_client->message, i);
1081                 MSG_WriteString (&host_client->message, client->name);
1082                 MSG_WriteByte (&host_client->message, svc_updatefrags);
1083                 MSG_WriteByte (&host_client->message, i);
1084                 MSG_WriteShort (&host_client->message, client->old_frags);
1085                 MSG_WriteByte (&host_client->message, svc_updatecolors);
1086                 MSG_WriteByte (&host_client->message, i);
1087                 MSG_WriteByte (&host_client->message, client->colors);
1088         }
1089         
1090 // send all current light styles
1091         for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1092         {
1093                 MSG_WriteByte (&host_client->message, svc_lightstyle);
1094                 MSG_WriteByte (&host_client->message, (char)i);
1095                 MSG_WriteString (&host_client->message, sv.lightstyles[i]);
1096         }
1097
1098 //
1099 // send some stats
1100 //
1101         MSG_WriteByte (&host_client->message, svc_updatestat);
1102         MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS);
1103         MSG_WriteLong (&host_client->message, pr_global_struct->total_secrets);
1104
1105         MSG_WriteByte (&host_client->message, svc_updatestat);
1106         MSG_WriteByte (&host_client->message, STAT_TOTALMONSTERS);
1107         MSG_WriteLong (&host_client->message, pr_global_struct->total_monsters);
1108
1109         MSG_WriteByte (&host_client->message, svc_updatestat);
1110         MSG_WriteByte (&host_client->message, STAT_SECRETS);
1111         MSG_WriteLong (&host_client->message, pr_global_struct->found_secrets);
1112
1113         MSG_WriteByte (&host_client->message, svc_updatestat);
1114         MSG_WriteByte (&host_client->message, STAT_MONSTERS);
1115         MSG_WriteLong (&host_client->message, pr_global_struct->killed_monsters);
1116
1117 //
1118 // send a fixangle
1119 // Never send a roll angle, because savegames can catch the server
1120 // in a state where it is expecting the client to correct the angle
1121 // and it won't happen if the game was just loaded, so you wind up
1122 // with a permanent head tilt
1123         ent = EDICT_NUM( 1 + (host_client - svs.clients) );
1124         MSG_WriteByte (&host_client->message, svc_setangle);
1125         for (i=0 ; i < 2 ; i++)
1126                 MSG_WriteAngle (&host_client->message, ent->v.angles[i] );
1127         MSG_WriteAngle (&host_client->message, 0 );
1128
1129         SV_WriteClientdataToMessage (sv_player, &host_client->message);
1130
1131         MSG_WriteByte (&host_client->message, svc_signonnum);
1132         MSG_WriteByte (&host_client->message, 3);
1133         host_client->sendsignon = true;
1134 }
1135
1136 /*
1137 ==================
1138 Host_Begin_f
1139 ==================
1140 */
1141 void Host_Begin_f (void)
1142 {
1143         if (cmd_source == src_command)
1144         {
1145                 Con_Printf ("begin is not valid from the console\n");
1146                 return;
1147         }
1148
1149         host_client->spawned = true;
1150 }
1151
1152 //===========================================================================
1153
1154
1155 /*
1156 ==================
1157 Host_Kick_f
1158
1159 Kicks a user off of the server
1160 ==================
1161 */
1162 void Host_Kick_f (void)
1163 {
1164         char            *who;
1165         char            *message = NULL;
1166         client_t        *save;
1167         int                     i;
1168         qboolean        byNumber = false;
1169
1170         if (cmd_source == src_command)
1171         {
1172                 if (!sv.active)
1173                 {
1174                         Cmd_ForwardToServer ();
1175                         return;
1176                 }
1177         }
1178         else if (pr_global_struct->deathmatch)
1179                 return;
1180
1181         save = host_client;
1182
1183         if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1184         {
1185                 i = atof(Cmd_Argv(2)) - 1;
1186                 if (i < 0 || i >= svs.maxclients)
1187                         return;
1188                 if (!svs.clients[i].active)
1189                         return;
1190                 host_client = &svs.clients[i];
1191                 byNumber = true;
1192         }
1193         else
1194         {
1195                 for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
1196                 {
1197                         if (!host_client->active)
1198                                 continue;
1199                         if (Q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1200                                 break;
1201                 }
1202         }
1203
1204         if (i < svs.maxclients)
1205         {
1206                 if (cmd_source == src_command)
1207                         if (cls.state == ca_dedicated)
1208                                 who = "Console";
1209                         else
1210                                 who = cl_name.string;
1211                 else
1212                         who = save->name;
1213
1214                 // can't kick yourself!
1215                 if (host_client == save)
1216                         return;
1217
1218                 if (Cmd_Argc() > 2)
1219                 {
1220                         message = COM_Parse(Cmd_Args());
1221                         if (byNumber)
1222                         {
1223                                 message++;                                                      // skip the #
1224                                 while (*message == ' ')                         // skip white space
1225                                         message++;
1226                                 message += strlen(Cmd_Argv(2)); // skip the number
1227                         }
1228                         while (*message && *message == ' ')
1229                                 message++;
1230                 }
1231                 if (message)
1232                         SV_ClientPrintf ("Kicked by %s: %s\n", who, message);
1233                 else
1234                         SV_ClientPrintf ("Kicked by %s\n", who);
1235                 SV_DropClient (false);
1236         }
1237
1238         host_client = save;
1239 }
1240
1241 /*
1242 ===============================================================================
1243
1244 DEBUGGING TOOLS
1245
1246 ===============================================================================
1247 */
1248
1249 /*
1250 ==================
1251 Host_Give_f
1252 ==================
1253 */
1254 void Host_Give_f (void)
1255 {
1256         char    *t;
1257         int             v;
1258         eval_t  *val;
1259
1260         if (cmd_source == src_command)
1261         {
1262                 Cmd_ForwardToServer ();
1263                 return;
1264         }
1265
1266         if (pr_global_struct->deathmatch)
1267                 return;
1268
1269         t = Cmd_Argv(1);
1270         v = atoi (Cmd_Argv(2));
1271         
1272         switch (t[0])
1273         {
1274    case '0':
1275    case '1':
1276    case '2':
1277    case '3':
1278    case '4':
1279    case '5':
1280    case '6':
1281    case '7':
1282    case '8':
1283    case '9':
1284       // MED 01/04/97 added hipnotic give stuff
1285       if (hipnotic)
1286       {
1287          if (t[0] == '6')
1288          {
1289             if (t[1] == 'a')
1290                sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN;
1291             else
1292                sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER;
1293          }
1294          else if (t[0] == '9')
1295             sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON;
1296          else if (t[0] == '0')
1297             sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR;
1298          else if (t[0] >= '2')
1299             sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1300       }
1301       else
1302       {
1303          if (t[0] >= '2')
1304             sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1305       }
1306                 break;
1307         
1308     case 's':
1309                 if (rogue)
1310                 {
1311                     if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1)))
1312                             val->_float = v;
1313                 }
1314
1315         sv_player->v.ammo_shells = v;
1316         break;          
1317     case 'n':
1318                 if (rogue)
1319                 {
1320                     if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1)))
1321                         {
1322                             val->_float = v;
1323                                 if (sv_player->v.weapon <= IT_LIGHTNING)
1324                                         sv_player->v.ammo_nails = v;
1325                         }
1326                 }
1327                 else
1328                 {
1329                         sv_player->v.ammo_nails = v;
1330                 }
1331         break;          
1332     case 'l':
1333                 if (rogue)
1334                 {
1335                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_lava_nails);
1336                         if (val)
1337                         {
1338                                 val->_float = v;
1339                                 if (sv_player->v.weapon > IT_LIGHTNING)
1340                                         sv_player->v.ammo_nails = v;
1341                         }
1342                 }
1343         break;
1344     case 'r':
1345                 if (rogue)
1346                 {
1347                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_rockets1);
1348                         if (val)
1349                         {
1350                                 val->_float = v;
1351                                 if (sv_player->v.weapon <= IT_LIGHTNING)
1352                                         sv_player->v.ammo_rockets = v;
1353                         }
1354                 }
1355                 else
1356                 {
1357                         sv_player->v.ammo_rockets = v;
1358                 }
1359         break;          
1360     case 'm':
1361                 if (rogue)
1362                 {
1363                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_multi_rockets);
1364                         if (val)
1365                         {
1366                                 val->_float = v;
1367                                 if (sv_player->v.weapon > IT_LIGHTNING)
1368                                         sv_player->v.ammo_rockets = v;
1369                         }
1370                 }
1371         break;          
1372     case 'h':
1373         sv_player->v.health = v;
1374         break;          
1375     case 'c':
1376                 if (rogue)
1377                 {
1378                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_cells1);
1379                         if (val)
1380                         {
1381                                 val->_float = v;
1382                                 if (sv_player->v.weapon <= IT_LIGHTNING)
1383                                         sv_player->v.ammo_cells = v;
1384                         }
1385                 }
1386                 else
1387                 {
1388                         sv_player->v.ammo_cells = v;
1389                 }
1390         break;          
1391     case 'p':
1392                 if (rogue)
1393                 {
1394                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_plasma);
1395                         if (val)
1396                         {
1397                                 val->_float = v;
1398                                 if (sv_player->v.weapon > IT_LIGHTNING)
1399                                         sv_player->v.ammo_cells = v;
1400                         }
1401                 }
1402         break;          
1403     }
1404 }
1405
1406 edict_t *FindViewthing (void)
1407 {
1408         int             i;
1409         edict_t *e;
1410         
1411         for (i=0 ; i<sv.num_edicts ; i++)
1412         {
1413                 e = EDICT_NUM(i);
1414                 if ( !strcmp (pr_strings + e->v.classname, "viewthing") )
1415                         return e;
1416         }
1417         Con_Printf ("No viewthing on map\n");
1418         return NULL;
1419 }
1420
1421 /*
1422 ==================
1423 Host_Viewmodel_f
1424 ==================
1425 */
1426 void Host_Viewmodel_f (void)
1427 {
1428         edict_t *e;
1429         model_t *m;
1430
1431         e = FindViewthing ();
1432         if (!e)
1433                 return;
1434
1435         m = Mod_ForName (Cmd_Argv(1), false);
1436         if (!m)
1437         {
1438                 Con_Printf ("Can't load %s\n", Cmd_Argv(1));
1439                 return;
1440         }
1441         
1442         e->v.frame = 0;
1443         cl.model_precache[(int)e->v.modelindex] = m;
1444 }
1445
1446 /*
1447 ==================
1448 Host_Viewframe_f
1449 ==================
1450 */
1451 void Host_Viewframe_f (void)
1452 {
1453         edict_t *e;
1454         int             f;
1455         model_t *m;
1456
1457         e = FindViewthing ();
1458         if (!e)
1459                 return;
1460         m = cl.model_precache[(int)e->v.modelindex];
1461
1462         f = atoi(Cmd_Argv(1));
1463         if (f >= m->numframes)
1464                 f = m->numframes-1;
1465
1466         e->v.frame = f;         
1467 }
1468
1469
1470 void PrintFrameName (model_t *m, int frame)
1471 {
1472         int data;
1473         data = (int) Mod_Extradata(m);
1474         if (m->ofs_scenes && data)
1475                 Con_Printf("frame %i: %s\n", frame, ((animscene_t *) (m->ofs_scenes + data))[frame].name);
1476         else
1477                 Con_Printf("frame %i\n", frame);
1478 }
1479
1480 /*
1481 ==================
1482 Host_Viewnext_f
1483 ==================
1484 */
1485 void Host_Viewnext_f (void)
1486 {
1487         edict_t *e;
1488         model_t *m;
1489         
1490         e = FindViewthing ();
1491         if (!e)
1492                 return;
1493         m = cl.model_precache[(int)e->v.modelindex];
1494
1495         e->v.frame = e->v.frame + 1;
1496         if (e->v.frame >= m->numframes)
1497                 e->v.frame = m->numframes - 1;
1498
1499         PrintFrameName (m, e->v.frame);         
1500 }
1501
1502 /*
1503 ==================
1504 Host_Viewprev_f
1505 ==================
1506 */
1507 void Host_Viewprev_f (void)
1508 {
1509         edict_t *e;
1510         model_t *m;
1511
1512         e = FindViewthing ();
1513         if (!e)
1514                 return;
1515
1516         m = cl.model_precache[(int)e->v.modelindex];
1517
1518         e->v.frame = e->v.frame - 1;
1519         if (e->v.frame < 0)
1520                 e->v.frame = 0;
1521
1522         PrintFrameName (m, e->v.frame);         
1523 }
1524
1525 /*
1526 ===============================================================================
1527
1528 DEMO LOOP CONTROL
1529
1530 ===============================================================================
1531 */
1532
1533
1534 /*
1535 ==================
1536 Host_Startdemos_f
1537 ==================
1538 */
1539 void Host_Startdemos_f (void)
1540 {
1541         int             i, c;
1542
1543         if (cls.state == ca_dedicated)
1544         {
1545                 if (!sv.active)
1546                         Cbuf_AddText ("map start\n");
1547                 return;
1548         }
1549
1550         c = Cmd_Argc() - 1;
1551         if (c > MAX_DEMOS)
1552         {
1553                 Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS);
1554                 c = MAX_DEMOS;
1555         }
1556         Con_Printf ("%i demo(s) in loop\n", c);
1557
1558         for (i=1 ; i<c+1 ; i++)
1559                 strncpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0])-1);
1560
1561         if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1562         {
1563                 cls.demonum = 0;
1564                 CL_NextDemo ();
1565         }
1566         else
1567                 cls.demonum = -1;
1568 }
1569
1570
1571 /*
1572 ==================
1573 Host_Demos_f
1574
1575 Return to looping demos
1576 ==================
1577 */
1578 void Host_Demos_f (void)
1579 {
1580         if (cls.state == ca_dedicated)
1581                 return;
1582         if (cls.demonum == -1)
1583                 cls.demonum = 1;
1584         CL_Disconnect_f ();
1585         CL_NextDemo ();
1586 }
1587
1588 /*
1589 ==================
1590 Host_Stopdemo_f
1591
1592 Return to looping demos
1593 ==================
1594 */
1595 void Host_Stopdemo_f (void)
1596 {
1597         if (cls.state == ca_dedicated)
1598                 return;
1599         if (!cls.demoplayback)
1600                 return;
1601         CL_StopPlayback ();
1602         CL_Disconnect ();
1603 }
1604
1605 //=============================================================================
1606
1607 /*
1608 ==================
1609 Host_InitCommands
1610 ==================
1611 */
1612 void Host_InitCommands (void)
1613 {
1614         Cmd_AddCommand ("status", Host_Status_f);
1615         Cmd_AddCommand ("quit", Host_Quit_f);
1616         if (nehahra)
1617         {
1618                 Cmd_AddCommand ("max", Host_God_f);
1619                 Cmd_AddCommand ("monster", Host_Notarget_f);
1620                 Cmd_AddCommand ("scrag", Host_Fly_f);
1621                 Cmd_AddCommand ("wraith", Host_Noclip_f);
1622                 Cmd_AddCommand ("gimme", Host_Give_f);
1623         }
1624         else
1625         {
1626                 Cmd_AddCommand ("god", Host_God_f);
1627                 Cmd_AddCommand ("notarget", Host_Notarget_f);
1628                 Cmd_AddCommand ("fly", Host_Fly_f);
1629                 Cmd_AddCommand ("noclip", Host_Noclip_f);
1630                 Cmd_AddCommand ("give", Host_Give_f);
1631         }
1632         Cmd_AddCommand ("map", Host_Map_f);
1633         Cmd_AddCommand ("restart", Host_Restart_f);
1634         Cmd_AddCommand ("changelevel", Host_Changelevel_f);
1635         Cmd_AddCommand ("connect", Host_Connect_f);
1636         Cmd_AddCommand ("reconnect", Host_Reconnect_f);
1637         Cmd_AddCommand ("name", Host_Name_f);
1638         Cmd_AddCommand ("version", Host_Version_f);
1639         Cmd_AddCommand ("say", Host_Say_f);
1640         Cmd_AddCommand ("say_team", Host_Say_Team_f);
1641         Cmd_AddCommand ("tell", Host_Tell_f);
1642         Cmd_AddCommand ("color", Host_Color_f);
1643         Cmd_AddCommand ("kill", Host_Kill_f);
1644         Cmd_AddCommand ("pause", Host_Pause_f);
1645         Cmd_AddCommand ("spawn", Host_Spawn_f);
1646         Cmd_AddCommand ("begin", Host_Begin_f);
1647         Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
1648         Cmd_AddCommand ("kick", Host_Kick_f);
1649         Cmd_AddCommand ("ping", Host_Ping_f);
1650         Cmd_AddCommand ("load", Host_Loadgame_f);
1651         Cmd_AddCommand ("save", Host_Savegame_f);
1652
1653         Cmd_AddCommand ("startdemos", Host_Startdemos_f);
1654         Cmd_AddCommand ("demos", Host_Demos_f);
1655         Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
1656
1657         Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
1658         Cmd_AddCommand ("viewframe", Host_Viewframe_f);
1659         Cmd_AddCommand ("viewnext", Host_Viewnext_f);
1660         Cmd_AddCommand ("viewprev", Host_Viewprev_f);
1661
1662         Cmd_AddCommand ("mcache", Mod_Print);
1663 }