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