]> icculus.org git repositories - divverent/darkplaces.git/blob - host_cmd.c
added sky quality and show framerate options to menu
[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         QFile   *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 = Qopen (name, "w");
482         if (!f)
483         {
484                 Con_Printf ("ERROR: couldn't open.\n");
485                 return;
486         }
487         
488         Qprintf (f, "%i\n", SAVEGAME_VERSION);
489         Host_SavegameComment (comment);
490         Qprintf (f, "%s\n", comment);
491         for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
492                 Qprintf (f, "%f\n", svs.clients->spawn_parms[i]);
493         Qprintf (f, "%d\n", current_skill);
494         Qprintf (f, "%s\n", sv.name);
495         Qprintf (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                         Qprintf (f, "%s\n", sv.lightstyles[i]);
503                 else
504                         Qprintf (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                 Qflush (f);
513         }
514         Qclose (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         QFile   *f;
528         char    mapname[MAX_QPATH];
529         float   time, tfloat;
530         char    buf[32768], *start;
531         char    *str;
532         int             i, r;
533         edict_t *ent;
534         int             entnum;
535         int             version;
536         float                   spawn_parms[NUM_SPAWN_PARMS];
537
538         if (cmd_source != src_command)
539                 return;
540
541         if (Cmd_Argc() != 2)
542         {
543                 Con_Printf ("load <savename> : load a game\n");
544                 return;
545         }
546
547         cls.demonum = -1;               // stop demo loop in case this fails
548
549         sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
550         COM_DefaultExtension (name, ".sav");
551
552         // LordHavoc: made SCR_UpdateScreen use a great deal less stack space, no longer an issue
553         //// we can't call SCR_BeginLoadingPlaque, because too much stack space has
554         //// been used.  The menu calls it before stuffing loadgame command
555 //      SCR_BeginLoadingPlaque ();
556
557         Con_Printf ("Loading game from %s...\n", name);
558         f = Qopen (name, "rz");
559         if (!f)
560         {
561                 Con_Printf ("ERROR: couldn't open.\n");
562                 return;
563         }
564
565         str = Qgetline (f);
566         sscanf (str, "%i\n", &version);
567         if (version != SAVEGAME_VERSION)
568         {
569                 Qclose (f);
570                 Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
571                 return;
572         }
573         str = Qgetline (f);
574         for (i=0 ; i<NUM_SPAWN_PARMS ; i++) {
575                 str = Qgetline (f);
576                 sscanf (str, "%f\n", &spawn_parms[i]);
577         }
578 // this silliness is so we can load 1.06 save files, which have float skill values
579         str = Qgetline (f);
580         sscanf (str, "%f\n", &tfloat);
581         current_skill = (int)(tfloat + 0.1);
582         Cvar_SetValue ("skill", (float)current_skill);
583
584         strcpy (mapname, Qgetline (f));
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] = Hunk_AllocName (strlen(str)+1, "lightstyles");
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;
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
691         if (cmd_source == src_command)
692         {
693                 if (strcmp(cl_name.string, newName) == 0)
694                         return;
695                 Cvar_Set ("_cl_name", newName);
696                 if (cls.state == ca_connected)
697                         Cmd_ForwardToServer ();
698                 return;
699         }
700
701         if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
702                 if (strcmp(host_client->name, newName) != 0)
703                         Con_Printf ("%s renamed to %s\n", host_client->name, newName);
704         strcpy (host_client->name, newName);
705         host_client->edict->v.netname = host_client->name - pr_strings;
706         
707 // send notification to all clients
708         
709         MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
710         MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
711         MSG_WriteString (&sv.reliable_datagram, host_client->name);
712 }
713
714         
715 void Host_Version_f (void)
716 {
717         Con_Printf ("Version %4.2f (build %i)\n", VERSION, buildnumber);
718         Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
719 }
720
721 void Host_Say(qboolean teamonly)
722 {
723         client_t *client;
724         client_t *save;
725         int             j;
726         char    *p;
727         // LordHavoc: 256 char say messages
728         unsigned char   text[256];
729         qboolean        fromServer = false;
730
731         if (cmd_source == src_command)
732         {
733                 if (cls.state == ca_dedicated)
734                 {
735                         fromServer = true;
736                         teamonly = false;
737                 }
738                 else
739                 {
740                         Cmd_ForwardToServer ();
741                         return;
742                 }
743         }
744
745         if (Cmd_Argc () < 2)
746                 return;
747
748         save = host_client;
749
750         p = Cmd_Args();
751 // remove quotes if present
752         if (*p == '"')
753         {
754                 p++;
755                 p[strlen(p)-1] = 0;
756         }
757
758 // turn on color set 1
759         if (!fromServer)
760                 sprintf (text, "%c%s: ", 1, save->name);
761         else
762                 sprintf (text, "%c<%s> ", 1, hostname.string);
763
764         j = sizeof(text) - 2 - strlen(text);  // -2 for /n and null terminator
765         if (strlen(p) > j)
766                 p[j] = 0;
767
768         strcat (text, p);
769         strcat (text, "\n");
770
771         for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
772         {
773                 if (!client || !client->active || !client->spawned)
774                         continue;
775                 if (teamplay.value && teamonly && client->edict->v.team != save->edict->v.team)
776                         continue;
777                 host_client = client;
778                 SV_ClientPrintf("%s", text);
779         }
780         host_client = save;
781
782         Sys_Printf("%s", &text[1]);
783 }
784
785
786 void Host_Say_f(void)
787 {
788         Host_Say(false);
789 }
790
791
792 void Host_Say_Team_f(void)
793 {
794         Host_Say(true);
795 }
796
797
798 void Host_Tell_f(void)
799 {
800         client_t *client;
801         client_t *save;
802         int             j;
803         char    *p;
804         char    text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
805
806         if (cmd_source == src_command)
807         {
808                 Cmd_ForwardToServer ();
809                 return;
810         }
811
812         if (Cmd_Argc () < 3)
813                 return;
814
815         strcpy(text, host_client->name);
816         strcat(text, ": ");
817
818         p = Cmd_Args();
819
820 // remove quotes if present
821         if (*p == '"')
822         {
823                 p++;
824                 p[strlen(p)-1] = 0;
825         }
826
827 // check length & truncate if necessary
828         j = sizeof(text) - 2 - strlen(text);  // -2 for /n and null terminator
829         if (strlen(p) > j)
830                 p[j] = 0;
831
832         strcat (text, p);
833         strcat (text, "\n");
834
835         save = host_client;
836         for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
837         {
838                 if (!client->active || !client->spawned)
839                         continue;
840                 if (Q_strcasecmp(client->name, Cmd_Argv(1)))
841                         continue;
842                 host_client = client;
843                 SV_ClientPrintf("%s", text);
844                 break;
845         }
846         host_client = save;
847 }
848
849
850 /*
851 ==================
852 Host_Color_f
853 ==================
854 */
855 void Host_Color_f(void)
856 {
857         int             top, bottom;
858         int             playercolor;
859         dfunction_t *f;
860         func_t  SV_ChangeTeam;
861         
862         if (Cmd_Argc() == 1)
863         {
864                 Con_Printf ("\"color\" is \"%i %i\"\n", ((int)cl_color.value) >> 4, ((int)cl_color.value) & 0x0f);
865                 Con_Printf ("color <0-13> [0-13]\n");
866                 return;
867         }
868
869         if (Cmd_Argc() == 2)
870                 top = bottom = atoi(Cmd_Argv(1));
871         else
872         {
873                 top = atoi(Cmd_Argv(1));
874                 bottom = atoi(Cmd_Argv(2));
875         }
876         
877         top &= 15;
878         // LordHavoc: allow skin colormaps 14 and 15 (was 13)
879         if (top > 15)
880                 top = 15;
881         bottom &= 15;
882         // LordHavoc: allow skin colormaps 14 and 15 (was 13)
883         if (bottom > 15)
884                 bottom = 15;
885         
886         playercolor = top*16 + bottom;
887
888         if (cmd_source == src_command)
889         {
890                 Cvar_SetValue ("_cl_color", playercolor);
891                 if (cls.state == ca_connected)
892                         Cmd_ForwardToServer ();
893                 return;
894         }
895
896         // void(float color) SV_ChangeTeam;
897         if ((f = ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - pr_functions)))
898         {
899                 Con_DPrintf("Calling SV_ChangeTeam\n");
900                 pr_global_struct->time = sv.time;
901                 pr_globals[0] = playercolor;
902                 pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
903                 PR_ExecuteProgram (SV_ChangeTeam, "");
904         }
905         else
906         {
907                 host_client->colors = playercolor;
908                 host_client->edict->v.team = bottom + 1;
909
910                 // send notification to all clients
911                 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
912                 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
913                 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
914         }
915 }
916
917 /*
918 ==================
919 Host_Kill_f
920 ==================
921 */
922 void Host_Kill_f (void)
923 {
924         if (cmd_source == src_command)
925         {
926                 Cmd_ForwardToServer ();
927                 return;
928         }
929
930         if (sv_player->v.health <= 0)
931         {
932                 SV_ClientPrintf ("Can't suicide -- already dead!\n");
933                 return;
934         }
935         
936         pr_global_struct->time = sv.time;
937         pr_global_struct->self = EDICT_TO_PROG(sv_player);
938         PR_ExecuteProgram (pr_global_struct->ClientKill, "QC function ClientKill is missing");
939 }
940
941
942 /*
943 ==================
944 Host_Pause_f
945 ==================
946 */
947 void Host_Pause_f (void)
948 {
949         
950         if (cmd_source == src_command)
951         {
952                 Cmd_ForwardToServer ();
953                 return;
954         }
955         if (!pausable.value)
956                 SV_ClientPrintf ("Pause not allowed.\n");
957         else
958         {
959                 sv.paused ^= 1;
960
961                 if (sv.paused)
962                 {
963                         SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v.netname);
964                 }
965                 else
966                 {
967                         SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v.netname);
968                 }
969
970         // send notification to all clients
971                 MSG_WriteByte (&sv.reliable_datagram, svc_setpause);
972                 MSG_WriteByte (&sv.reliable_datagram, sv.paused);
973         }
974 }
975
976 //===========================================================================
977
978
979 /*
980 ==================
981 Host_PreSpawn_f
982 ==================
983 */
984 void Host_PreSpawn_f (void)
985 {
986         if (cmd_source == src_command)
987         {
988                 Con_Printf ("prespawn is not valid from the console\n");
989                 return;
990         }
991
992         if (host_client->spawned)
993         {
994                 Con_Printf ("prespawn not valid -- already spawned\n");
995                 return;
996         }
997         
998         SZ_Write (&host_client->message, sv.signon.data, sv.signon.cursize);
999         MSG_WriteByte (&host_client->message, svc_signonnum);
1000         MSG_WriteByte (&host_client->message, 2);
1001         host_client->sendsignon = true;
1002 }
1003
1004 /*
1005 ==================
1006 Host_Spawn_f
1007 ==================
1008 */
1009 void Host_Spawn_f (void)
1010 {
1011         int             i;
1012         client_t        *client;
1013         edict_t *ent;
1014         func_t RestoreGame;
1015         dfunction_t *f;
1016
1017         if (cmd_source == src_command)
1018         {
1019                 Con_Printf ("spawn is not valid from the console\n");
1020                 return;
1021         }
1022
1023         if (host_client->spawned)
1024         {
1025                 Con_Printf ("Spawn not valid -- already spawned\n");
1026                 return;
1027         }
1028
1029         // LordHavoc: moved this above the QC calls at FrikaC's request
1030 // send all current names, colors, and frag counts
1031         SZ_Clear (&host_client->message);
1032
1033 // run the entrance script
1034         if (sv.loadgame)
1035         {       // loaded games are fully inited already
1036                 // if this is the last client to be connected, unpause
1037                 sv.paused = false;
1038
1039                 if ((f = ED_FindFunction ("RestoreGame")))
1040                 if ((RestoreGame = (func_t)(f - pr_functions)))
1041                 {
1042                         Con_DPrintf("Calling RestoreGame\n");
1043                         pr_global_struct->time = sv.time;
1044                         pr_global_struct->self = EDICT_TO_PROG(sv_player);
1045                         PR_ExecuteProgram (RestoreGame, "");
1046                 }
1047         }
1048         else
1049         {
1050                 eval_t *val;
1051                 // set up the edict
1052                 ent = host_client->edict;
1053
1054                 memset (&ent->v, 0, progs->entityfields * 4);
1055                 ent->v.colormap = NUM_FOR_EDICT(ent);
1056                 ent->v.team = (host_client->colors & 15) + 1;
1057                 ent->v.netname = host_client->name - pr_strings;
1058                 if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1059                         val->_float = host_client->pmodel;
1060
1061                 // copy spawn parms out of the client_t
1062
1063                 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1064                         (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
1065
1066                 // call the spawn function
1067
1068                 pr_global_struct->time = sv.time;
1069                 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1070                 PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
1071
1072                 if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= sv.time)
1073                         Sys_Printf ("%s entered the game\n", host_client->name);
1074
1075                 PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing");
1076         }
1077
1078
1079 // send time of update
1080         MSG_WriteByte (&host_client->message, svc_time);
1081         MSG_WriteFloat (&host_client->message, sv.time);
1082
1083         for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
1084         {
1085                 MSG_WriteByte (&host_client->message, svc_updatename);
1086                 MSG_WriteByte (&host_client->message, i);
1087                 MSG_WriteString (&host_client->message, client->name);
1088                 MSG_WriteByte (&host_client->message, svc_updatefrags);
1089                 MSG_WriteByte (&host_client->message, i);
1090                 MSG_WriteShort (&host_client->message, client->old_frags);
1091                 MSG_WriteByte (&host_client->message, svc_updatecolors);
1092                 MSG_WriteByte (&host_client->message, i);
1093                 MSG_WriteByte (&host_client->message, client->colors);
1094         }
1095         
1096 // send all current light styles
1097         for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1098         {
1099                 MSG_WriteByte (&host_client->message, svc_lightstyle);
1100                 MSG_WriteByte (&host_client->message, (char)i);
1101                 MSG_WriteString (&host_client->message, sv.lightstyles[i]);
1102         }
1103
1104 //
1105 // send some stats
1106 //
1107         MSG_WriteByte (&host_client->message, svc_updatestat);
1108         MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS);
1109         MSG_WriteLong (&host_client->message, pr_global_struct->total_secrets);
1110
1111         MSG_WriteByte (&host_client->message, svc_updatestat);
1112         MSG_WriteByte (&host_client->message, STAT_TOTALMONSTERS);
1113         MSG_WriteLong (&host_client->message, pr_global_struct->total_monsters);
1114
1115         MSG_WriteByte (&host_client->message, svc_updatestat);
1116         MSG_WriteByte (&host_client->message, STAT_SECRETS);
1117         MSG_WriteLong (&host_client->message, pr_global_struct->found_secrets);
1118
1119         MSG_WriteByte (&host_client->message, svc_updatestat);
1120         MSG_WriteByte (&host_client->message, STAT_MONSTERS);
1121         MSG_WriteLong (&host_client->message, pr_global_struct->killed_monsters);
1122
1123 //
1124 // send a fixangle
1125 // Never send a roll angle, because savegames can catch the server
1126 // in a state where it is expecting the client to correct the angle
1127 // and it won't happen if the game was just loaded, so you wind up
1128 // with a permanent head tilt
1129         ent = EDICT_NUM( 1 + (host_client - svs.clients) );
1130         MSG_WriteByte (&host_client->message, svc_setangle);
1131         for (i=0 ; i < 2 ; i++)
1132                 MSG_WriteAngle (&host_client->message, ent->v.angles[i] );
1133         MSG_WriteAngle (&host_client->message, 0 );
1134
1135         SV_WriteClientdataToMessage (sv_player, &host_client->message);
1136
1137         MSG_WriteByte (&host_client->message, svc_signonnum);
1138         MSG_WriteByte (&host_client->message, 3);
1139         host_client->sendsignon = true;
1140 }
1141
1142 /*
1143 ==================
1144 Host_Begin_f
1145 ==================
1146 */
1147 void Host_Begin_f (void)
1148 {
1149         if (cmd_source == src_command)
1150         {
1151                 Con_Printf ("begin is not valid from the console\n");
1152                 return;
1153         }
1154
1155         host_client->spawned = true;
1156 }
1157
1158 //===========================================================================
1159
1160
1161 /*
1162 ==================
1163 Host_Kick_f
1164
1165 Kicks a user off of the server
1166 ==================
1167 */
1168 void Host_Kick_f (void)
1169 {
1170         char            *who;
1171         char            *message = NULL;
1172         client_t        *save;
1173         int                     i;
1174         qboolean        byNumber = false;
1175
1176         if (cmd_source == src_command)
1177         {
1178                 if (!sv.active)
1179                 {
1180                         Cmd_ForwardToServer ();
1181                         return;
1182                 }
1183         }
1184         else if (pr_global_struct->deathmatch)
1185                 return;
1186
1187         save = host_client;
1188
1189         if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1190         {
1191                 i = atof(Cmd_Argv(2)) - 1;
1192                 if (i < 0 || i >= svs.maxclients)
1193                         return;
1194                 if (!svs.clients[i].active)
1195                         return;
1196                 host_client = &svs.clients[i];
1197                 byNumber = true;
1198         }
1199         else
1200         {
1201                 for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
1202                 {
1203                         if (!host_client->active)
1204                                 continue;
1205                         if (Q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1206                                 break;
1207                 }
1208         }
1209
1210         if (i < svs.maxclients)
1211         {
1212                 if (cmd_source == src_command)
1213                         if (cls.state == ca_dedicated)
1214                                 who = "Console";
1215                         else
1216                                 who = cl_name.string;
1217                 else
1218                         who = save->name;
1219
1220                 // can't kick yourself!
1221                 if (host_client == save)
1222                         return;
1223
1224                 if (Cmd_Argc() > 2)
1225                 {
1226                         message = COM_Parse(Cmd_Args());
1227                         if (byNumber)
1228                         {
1229                                 message++;                                                      // skip the #
1230                                 while (*message == ' ')                         // skip white space
1231                                         message++;
1232                                 message += strlen(Cmd_Argv(2)); // skip the number
1233                         }
1234                         while (*message && *message == ' ')
1235                                 message++;
1236                 }
1237                 if (message)
1238                         SV_ClientPrintf ("Kicked by %s: %s\n", who, message);
1239                 else
1240                         SV_ClientPrintf ("Kicked by %s\n", who);
1241                 SV_DropClient (false);
1242         }
1243
1244         host_client = save;
1245 }
1246
1247 /*
1248 ===============================================================================
1249
1250 DEBUGGING TOOLS
1251
1252 ===============================================================================
1253 */
1254
1255 /*
1256 ==================
1257 Host_Give_f
1258 ==================
1259 */
1260 void Host_Give_f (void)
1261 {
1262         char    *t;
1263         int             v;
1264         eval_t  *val;
1265
1266         if (cmd_source == src_command)
1267         {
1268                 Cmd_ForwardToServer ();
1269                 return;
1270         }
1271
1272         if (pr_global_struct->deathmatch)
1273                 return;
1274
1275         t = Cmd_Argv(1);
1276         v = atoi (Cmd_Argv(2));
1277         
1278         switch (t[0])
1279         {
1280    case '0':
1281    case '1':
1282    case '2':
1283    case '3':
1284    case '4':
1285    case '5':
1286    case '6':
1287    case '7':
1288    case '8':
1289    case '9':
1290       // MED 01/04/97 added hipnotic give stuff
1291       if (hipnotic)
1292       {
1293          if (t[0] == '6')
1294          {
1295             if (t[1] == 'a')
1296                sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN;
1297             else
1298                sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER;
1299          }
1300          else if (t[0] == '9')
1301             sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON;
1302          else if (t[0] == '0')
1303             sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR;
1304          else if (t[0] >= '2')
1305             sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1306       }
1307       else
1308       {
1309          if (t[0] >= '2')
1310             sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1311       }
1312                 break;
1313         
1314     case 's':
1315                 if (rogue)
1316                 {
1317                     if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1)))
1318                             val->_float = v;
1319                 }
1320
1321         sv_player->v.ammo_shells = v;
1322         break;          
1323     case 'n':
1324                 if (rogue)
1325                 {
1326                     if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1)))
1327                         {
1328                             val->_float = v;
1329                                 if (sv_player->v.weapon <= IT_LIGHTNING)
1330                                         sv_player->v.ammo_nails = v;
1331                         }
1332                 }
1333                 else
1334                 {
1335                         sv_player->v.ammo_nails = v;
1336                 }
1337         break;          
1338     case 'l':
1339                 if (rogue)
1340                 {
1341                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_lava_nails);
1342                         if (val)
1343                         {
1344                                 val->_float = v;
1345                                 if (sv_player->v.weapon > IT_LIGHTNING)
1346                                         sv_player->v.ammo_nails = v;
1347                         }
1348                 }
1349         break;
1350     case 'r':
1351                 if (rogue)
1352                 {
1353                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_rockets1);
1354                         if (val)
1355                         {
1356                                 val->_float = v;
1357                                 if (sv_player->v.weapon <= IT_LIGHTNING)
1358                                         sv_player->v.ammo_rockets = v;
1359                         }
1360                 }
1361                 else
1362                 {
1363                         sv_player->v.ammo_rockets = v;
1364                 }
1365         break;          
1366     case 'm':
1367                 if (rogue)
1368                 {
1369                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_multi_rockets);
1370                         if (val)
1371                         {
1372                                 val->_float = v;
1373                                 if (sv_player->v.weapon > IT_LIGHTNING)
1374                                         sv_player->v.ammo_rockets = v;
1375                         }
1376                 }
1377         break;          
1378     case 'h':
1379         sv_player->v.health = v;
1380         break;          
1381     case 'c':
1382                 if (rogue)
1383                 {
1384                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_cells1);
1385                         if (val)
1386                         {
1387                                 val->_float = v;
1388                                 if (sv_player->v.weapon <= IT_LIGHTNING)
1389                                         sv_player->v.ammo_cells = v;
1390                         }
1391                 }
1392                 else
1393                 {
1394                         sv_player->v.ammo_cells = v;
1395                 }
1396         break;          
1397     case 'p':
1398                 if (rogue)
1399                 {
1400                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_plasma);
1401                         if (val)
1402                         {
1403                                 val->_float = v;
1404                                 if (sv_player->v.weapon > IT_LIGHTNING)
1405                                         sv_player->v.ammo_cells = v;
1406                         }
1407                 }
1408         break;          
1409     }
1410 }
1411
1412 edict_t *FindViewthing (void)
1413 {
1414         int             i;
1415         edict_t *e;
1416         
1417         for (i=0 ; i<sv.num_edicts ; i++)
1418         {
1419                 e = EDICT_NUM(i);
1420                 if ( !strcmp (pr_strings + e->v.classname, "viewthing") )
1421                         return e;
1422         }
1423         Con_Printf ("No viewthing on map\n");
1424         return NULL;
1425 }
1426
1427 /*
1428 ==================
1429 Host_Viewmodel_f
1430 ==================
1431 */
1432 void Host_Viewmodel_f (void)
1433 {
1434         edict_t *e;
1435         model_t *m;
1436
1437         e = FindViewthing ();
1438         if (!e)
1439                 return;
1440
1441         m = Mod_ForName (Cmd_Argv(1), false);
1442         if (!m)
1443         {
1444                 Con_Printf ("Can't load %s\n", Cmd_Argv(1));
1445                 return;
1446         }
1447         
1448         e->v.frame = 0;
1449         cl.model_precache[(int)e->v.modelindex] = m;
1450 }
1451
1452 /*
1453 ==================
1454 Host_Viewframe_f
1455 ==================
1456 */
1457 void Host_Viewframe_f (void)
1458 {
1459         edict_t *e;
1460         int             f;
1461         model_t *m;
1462
1463         e = FindViewthing ();
1464         if (!e)
1465                 return;
1466         m = cl.model_precache[(int)e->v.modelindex];
1467
1468         f = atoi(Cmd_Argv(1));
1469         if (f >= m->numframes)
1470                 f = m->numframes-1;
1471
1472         e->v.frame = f;         
1473 }
1474
1475
1476 void PrintFrameName (model_t *m, int frame)
1477 {
1478         int data;
1479         data = (int) Mod_Extradata(m);
1480         if (m->ofs_scenes && data)
1481                 Con_Printf("frame %i: %s\n", frame, ((animscene_t *) (m->ofs_scenes + data))[frame].name);
1482         else
1483                 Con_Printf("frame %i\n", frame);
1484 }
1485
1486 /*
1487 ==================
1488 Host_Viewnext_f
1489 ==================
1490 */
1491 void Host_Viewnext_f (void)
1492 {
1493         edict_t *e;
1494         model_t *m;
1495         
1496         e = FindViewthing ();
1497         if (!e)
1498                 return;
1499         m = cl.model_precache[(int)e->v.modelindex];
1500
1501         e->v.frame = e->v.frame + 1;
1502         if (e->v.frame >= m->numframes)
1503                 e->v.frame = m->numframes - 1;
1504
1505         PrintFrameName (m, e->v.frame);         
1506 }
1507
1508 /*
1509 ==================
1510 Host_Viewprev_f
1511 ==================
1512 */
1513 void Host_Viewprev_f (void)
1514 {
1515         edict_t *e;
1516         model_t *m;
1517
1518         e = FindViewthing ();
1519         if (!e)
1520                 return;
1521
1522         m = cl.model_precache[(int)e->v.modelindex];
1523
1524         e->v.frame = e->v.frame - 1;
1525         if (e->v.frame < 0)
1526                 e->v.frame = 0;
1527
1528         PrintFrameName (m, e->v.frame);         
1529 }
1530
1531 /*
1532 ===============================================================================
1533
1534 DEMO LOOP CONTROL
1535
1536 ===============================================================================
1537 */
1538
1539
1540 /*
1541 ==================
1542 Host_Startdemos_f
1543 ==================
1544 */
1545 void Host_Startdemos_f (void)
1546 {
1547         int             i, c;
1548
1549         if (cls.state == ca_dedicated)
1550         {
1551                 if (!sv.active)
1552                         Cbuf_AddText ("map start\n");
1553                 return;
1554         }
1555
1556         c = Cmd_Argc() - 1;
1557         if (c > MAX_DEMOS)
1558         {
1559                 Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS);
1560                 c = MAX_DEMOS;
1561         }
1562         Con_Printf ("%i demo(s) in loop\n", c);
1563
1564         for (i=1 ; i<c+1 ; i++)
1565                 strncpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0])-1);
1566
1567         if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1568         {
1569                 cls.demonum = 0;
1570                 CL_NextDemo ();
1571         }
1572         else
1573                 cls.demonum = -1;
1574 }
1575
1576
1577 /*
1578 ==================
1579 Host_Demos_f
1580
1581 Return to looping demos
1582 ==================
1583 */
1584 void Host_Demos_f (void)
1585 {
1586         if (cls.state == ca_dedicated)
1587                 return;
1588         if (cls.demonum == -1)
1589                 cls.demonum = 1;
1590         CL_Disconnect_f ();
1591         CL_NextDemo ();
1592 }
1593
1594 /*
1595 ==================
1596 Host_Stopdemo_f
1597
1598 Return to looping demos
1599 ==================
1600 */
1601 void Host_Stopdemo_f (void)
1602 {
1603         if (cls.state == ca_dedicated)
1604                 return;
1605         if (!cls.demoplayback)
1606                 return;
1607         CL_StopPlayback ();
1608         CL_Disconnect ();
1609 }
1610
1611 //=============================================================================
1612
1613 /*
1614 ==================
1615 Host_InitCommands
1616 ==================
1617 */
1618 void Host_InitCommands (void)
1619 {
1620         Cmd_AddCommand ("status", Host_Status_f);
1621         Cmd_AddCommand ("quit", Host_Quit_f);
1622         if (nehahra)
1623         {
1624                 Cmd_AddCommand ("max", Host_God_f);
1625                 Cmd_AddCommand ("monster", Host_Notarget_f);
1626                 Cmd_AddCommand ("scrag", Host_Fly_f);
1627                 Cmd_AddCommand ("wraith", Host_Noclip_f);
1628                 Cmd_AddCommand ("gimme", Host_Give_f);
1629         }
1630         else
1631         {
1632                 Cmd_AddCommand ("god", Host_God_f);
1633                 Cmd_AddCommand ("notarget", Host_Notarget_f);
1634                 Cmd_AddCommand ("fly", Host_Fly_f);
1635                 Cmd_AddCommand ("noclip", Host_Noclip_f);
1636                 Cmd_AddCommand ("give", Host_Give_f);
1637         }
1638         Cmd_AddCommand ("map", Host_Map_f);
1639         Cmd_AddCommand ("restart", Host_Restart_f);
1640         Cmd_AddCommand ("changelevel", Host_Changelevel_f);
1641         Cmd_AddCommand ("connect", Host_Connect_f);
1642         Cmd_AddCommand ("reconnect", Host_Reconnect_f);
1643         Cmd_AddCommand ("name", Host_Name_f);
1644         Cmd_AddCommand ("version", Host_Version_f);
1645         Cmd_AddCommand ("say", Host_Say_f);
1646         Cmd_AddCommand ("say_team", Host_Say_Team_f);
1647         Cmd_AddCommand ("tell", Host_Tell_f);
1648         Cmd_AddCommand ("color", Host_Color_f);
1649         Cmd_AddCommand ("kill", Host_Kill_f);
1650         Cmd_AddCommand ("pause", Host_Pause_f);
1651         Cmd_AddCommand ("spawn", Host_Spawn_f);
1652         Cmd_AddCommand ("begin", Host_Begin_f);
1653         Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
1654         Cmd_AddCommand ("kick", Host_Kick_f);
1655         Cmd_AddCommand ("ping", Host_Ping_f);
1656         Cmd_AddCommand ("load", Host_Loadgame_f);
1657         Cmd_AddCommand ("save", Host_Savegame_f);
1658
1659         Cmd_AddCommand ("startdemos", Host_Startdemos_f);
1660         Cmd_AddCommand ("demos", Host_Demos_f);
1661         Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
1662
1663         Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
1664         Cmd_AddCommand ("viewframe", Host_Viewframe_f);
1665         Cmd_AddCommand ("viewnext", Host_Viewnext_f);
1666         Cmd_AddCommand ("viewprev", Host_Viewprev_f);
1667
1668         Cmd_AddCommand ("mcache", Mod_Print);
1669 }