]> icculus.org git repositories - divverent/darkplaces.git/blob - host_cmd.c
reduced skysphere from 2048 triangles to 1024
[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
568         SCR_BeginLoadingPlaque ();
569
570         str = Qgetline (f);
571         for (i=0 ; i<NUM_SPAWN_PARMS ; i++) {
572                 str = Qgetline (f);
573                 sscanf (str, "%f\n", &spawn_parms[i]);
574         }
575 // this silliness is so we can load 1.06 save files, which have float skill values
576         str = Qgetline (f);
577         sscanf (str, "%f\n", &tfloat);
578         current_skill = (int)(tfloat + 0.1);
579         Cvar_SetValue ("skill", (float)current_skill);
580
581         strcpy (mapname, Qgetline (f));
582
583         str = Qgetline (f);
584         sscanf (str, "%f\n",&time);
585
586         CL_Disconnect_f ();
587
588         SV_SpawnServer (mapname);
589         if (!sv.active)
590         {
591                 Con_Printf ("Couldn't load map\n");
592                 return;
593         }
594         sv.paused = true;               // pause until all clients connect
595         sv.loadgame = true;
596
597 // load the light styles
598
599         for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
600         {
601                 str = Qgetline (f);
602                 sv.lightstyles[i] = Mem_Alloc(edictstring_mempool, strlen(str)+1);
603                 strcpy (sv.lightstyles[i], str);
604         }
605
606 // load the edicts out of the savegame file
607         entnum = -1;            // -1 is the globals
608         while (!Qeof(f))
609         {
610                 for (i=0 ; i<sizeof(buf)-1 ; i++)
611                 {
612                         r = Qgetc (f);
613                         if (r == EOF || !r)
614                                 break;
615                         buf[i] = r;
616                         if (r == '}')
617                         {
618                                 i++;
619                                 break;
620                         }
621                 }
622                 if (i == sizeof(buf)-1)
623                         Sys_Error ("Loadgame buffer overflow");
624                 buf[i] = 0;
625                 start = buf;
626                 start = COM_Parse(buf);
627                 if (!com_token[0])
628                         break;          // end of file
629                 if (strcmp(com_token,"{"))
630                         Sys_Error ("First token isn't a brace");
631                         
632                 if (entnum == -1)
633                 {       // parse the global vars
634                         ED_ParseGlobals (start);
635                 }
636                 else
637                 {       // parse an edict
638
639                         ent = EDICT_NUM(entnum);
640                         memset (&ent->v, 0, progs->entityfields * 4);
641                         ent->free = false;
642                         ED_ParseEdict (start, ent);
643         
644                 // link it into the bsp tree
645                         if (!ent->free)
646                                 SV_LinkEdict (ent, false);
647                 }
648
649                 entnum++;
650         }
651         
652         sv.num_edicts = entnum;
653         sv.time = time;
654
655         Qclose (f);
656
657         for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
658                 svs.clients->spawn_parms[i] = spawn_parms[i];
659
660         if (cls.state != ca_dedicated)
661         {
662                 CL_EstablishConnection ("local");
663                 Host_Reconnect_f ();
664         }
665 }
666
667 //============================================================================
668
669 /*
670 ======================
671 Host_Name_f
672 ======================
673 */
674 void Host_Name_f (void)
675 {
676         char newName[64];
677
678         if (Cmd_Argc () == 1)
679         {
680                 Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
681                 return;
682         }
683         //if (Cmd_Argc () == 2)
684         //      newName = Cmd_Argv(1);
685         //else
686         //      newName = Cmd_Args();
687         //newName[15] = 0;
688         if (Cmd_Argc () == 2)
689                 strncpy(newName, Cmd_Argv(1), 15);
690         else
691                 strncpy(newName, Cmd_Args(), 15);
692         newName[15] = 0;
693
694         if (cmd_source == src_command)
695         {
696                 if (strcmp(cl_name.string, newName) == 0)
697                         return;
698                 Cvar_Set ("_cl_name", newName);
699                 if (cls.state == ca_connected)
700                         Cmd_ForwardToServer ();
701                 return;
702         }
703
704         if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
705                 if (strcmp(host_client->name, newName) != 0)
706                         Con_Printf ("%s renamed to %s\n", host_client->name, newName);
707         strcpy (host_client->name, newName);
708         host_client->edict->v.netname = host_client->name - pr_strings;
709         
710 // send notification to all clients
711         
712         MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
713         MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
714         MSG_WriteString (&sv.reliable_datagram, host_client->name);
715 }
716
717         
718 void Host_Version_f (void)
719 {
720         Con_Printf ("Version: %s build %s\n", gamename, buildstring);
721 }
722
723 void Host_Say(qboolean teamonly)
724 {
725         client_t *client;
726         client_t *save;
727         int             j;
728         char    *p;
729         // LordHavoc: 256 char say messages
730         unsigned char   text[256];
731         qboolean        fromServer = false;
732
733         if (cmd_source == src_command)
734         {
735                 if (cls.state == ca_dedicated)
736                 {
737                         fromServer = true;
738                         teamonly = false;
739                 }
740                 else
741                 {
742                         Cmd_ForwardToServer ();
743                         return;
744                 }
745         }
746
747         if (Cmd_Argc () < 2)
748                 return;
749
750         save = host_client;
751
752         p = Cmd_Args();
753 // remove quotes if present
754         if (*p == '"')
755         {
756                 p++;
757                 p[strlen(p)-1] = 0;
758         }
759
760 // turn on color set 1
761         if (!fromServer)
762                 sprintf (text, "%c%s: ", 1, save->name);
763         else
764                 sprintf (text, "%c<%s> ", 1, hostname.string);
765
766         j = sizeof(text) - 2 - strlen(text);  // -2 for /n and null terminator
767         if (strlen(p) > j)
768                 p[j] = 0;
769
770         strcat (text, p);
771         strcat (text, "\n");
772
773         for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
774         {
775                 if (!client || !client->active || !client->spawned)
776                         continue;
777                 if (teamplay.integer && teamonly && client->edict->v.team != save->edict->v.team)
778                         continue;
779                 host_client = client;
780                 SV_ClientPrintf("%s", text);
781         }
782         host_client = save;
783
784         Sys_Printf("%s", &text[1]);
785 }
786
787
788 void Host_Say_f(void)
789 {
790         Host_Say(false);
791 }
792
793
794 void Host_Say_Team_f(void)
795 {
796         Host_Say(true);
797 }
798
799
800 void Host_Tell_f(void)
801 {
802         client_t *client;
803         client_t *save;
804         int             j;
805         char    *p;
806         char    text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
807
808         if (cmd_source == src_command)
809         {
810                 Cmd_ForwardToServer ();
811                 return;
812         }
813
814         if (Cmd_Argc () < 3)
815                 return;
816
817         strcpy(text, host_client->name);
818         strcat(text, ": ");
819
820         p = Cmd_Args();
821
822 // remove quotes if present
823         if (*p == '"')
824         {
825                 p++;
826                 p[strlen(p)-1] = 0;
827         }
828
829 // check length & truncate if necessary
830         j = sizeof(text) - 2 - strlen(text);  // -2 for /n and null terminator
831         if (strlen(p) > j)
832                 p[j] = 0;
833
834         strcat (text, p);
835         strcat (text, "\n");
836
837         save = host_client;
838         for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
839         {
840                 if (!client->active || !client->spawned)
841                         continue;
842                 if (Q_strcasecmp(client->name, Cmd_Argv(1)))
843                         continue;
844                 host_client = client;
845                 SV_ClientPrintf("%s", text);
846                 break;
847         }
848         host_client = save;
849 }
850
851
852 /*
853 ==================
854 Host_Color_f
855 ==================
856 */
857 void Host_Color_f(void)
858 {
859         int             top, bottom;
860         int             playercolor;
861         dfunction_t *f;
862         func_t  SV_ChangeTeam;
863         
864         if (Cmd_Argc() == 1)
865         {
866                 Con_Printf ("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15);
867                 Con_Printf ("color <0-13> [0-13]\n");
868                 return;
869         }
870
871         if (Cmd_Argc() == 2)
872                 top = bottom = atoi(Cmd_Argv(1));
873         else
874         {
875                 top = atoi(Cmd_Argv(1));
876                 bottom = atoi(Cmd_Argv(2));
877         }
878         
879         top &= 15;
880         // LordHavoc: allow skin colormaps 14 and 15 (was 13)
881         if (top > 15)
882                 top = 15;
883         bottom &= 15;
884         // LordHavoc: allow skin colormaps 14 and 15 (was 13)
885         if (bottom > 15)
886                 bottom = 15;
887         
888         playercolor = top*16 + bottom;
889
890         if (cmd_source == src_command)
891         {
892                 Cvar_SetValue ("_cl_color", playercolor);
893                 if (cls.state == ca_connected)
894                         Cmd_ForwardToServer ();
895                 return;
896         }
897
898         // void(float color) SV_ChangeTeam;
899         if ((f = ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - pr_functions)))
900         {
901                 Con_DPrintf("Calling SV_ChangeTeam\n");
902                 pr_global_struct->time = sv.time;
903                 pr_globals[0] = playercolor;
904                 pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
905                 PR_ExecuteProgram (SV_ChangeTeam, "");
906         }
907         else
908         {
909                 host_client->colors = playercolor;
910                 host_client->edict->v.team = bottom + 1;
911
912                 // send notification to all clients
913                 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
914                 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
915                 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
916         }
917 }
918
919 /*
920 ==================
921 Host_Kill_f
922 ==================
923 */
924 void Host_Kill_f (void)
925 {
926         if (cmd_source == src_command)
927         {
928                 Cmd_ForwardToServer ();
929                 return;
930         }
931
932         if (sv_player->v.health <= 0)
933         {
934                 SV_ClientPrintf ("Can't suicide -- already dead!\n");
935                 return;
936         }
937         
938         pr_global_struct->time = sv.time;
939         pr_global_struct->self = EDICT_TO_PROG(sv_player);
940         PR_ExecuteProgram (pr_global_struct->ClientKill, "QC function ClientKill is missing");
941 }
942
943
944 /*
945 ==================
946 Host_Pause_f
947 ==================
948 */
949 void Host_Pause_f (void)
950 {
951         
952         if (cmd_source == src_command)
953         {
954                 Cmd_ForwardToServer ();
955                 return;
956         }
957         if (!pausable.integer)
958                 SV_ClientPrintf ("Pause not allowed.\n");
959         else
960         {
961                 sv.paused ^= 1;
962
963                 if (sv.paused)
964                 {
965                         SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v.netname);
966                 }
967                 else
968                 {
969                         SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v.netname);
970                 }
971
972         // send notification to all clients
973                 MSG_WriteByte (&sv.reliable_datagram, svc_setpause);
974                 MSG_WriteByte (&sv.reliable_datagram, sv.paused);
975         }
976 }
977
978 //===========================================================================
979
980
981 /*
982 ==================
983 Host_PreSpawn_f
984 ==================
985 */
986 void Host_PreSpawn_f (void)
987 {
988         if (cmd_source == src_command)
989         {
990                 Con_Printf ("prespawn is not valid from the console\n");
991                 return;
992         }
993
994         if (host_client->spawned)
995         {
996                 Con_Printf ("prespawn not valid -- already spawned\n");
997                 return;
998         }
999         
1000         SZ_Write (&host_client->message, sv.signon.data, sv.signon.cursize);
1001         MSG_WriteByte (&host_client->message, svc_signonnum);
1002         MSG_WriteByte (&host_client->message, 2);
1003         host_client->sendsignon = true;
1004 }
1005
1006 /*
1007 ==================
1008 Host_Spawn_f
1009 ==================
1010 */
1011 void Host_Spawn_f (void)
1012 {
1013         int             i;
1014         client_t        *client;
1015         edict_t *ent;
1016         func_t RestoreGame;
1017         dfunction_t *f;
1018
1019         if (cmd_source == src_command)
1020         {
1021                 Con_Printf ("spawn is not valid from the console\n");
1022                 return;
1023         }
1024
1025         if (host_client->spawned)
1026         {
1027                 Con_Printf ("Spawn not valid -- already spawned\n");
1028                 return;
1029         }
1030
1031         // LordHavoc: moved this above the QC calls at FrikaC's request
1032 // send all current names, colors, and frag counts
1033         SZ_Clear (&host_client->message);
1034
1035 // run the entrance script
1036         if (sv.loadgame)
1037         {       // loaded games are fully inited already
1038                 // if this is the last client to be connected, unpause
1039                 sv.paused = false;
1040
1041                 if ((f = ED_FindFunction ("RestoreGame")))
1042                 if ((RestoreGame = (func_t)(f - pr_functions)))
1043                 {
1044                         Con_DPrintf("Calling RestoreGame\n");
1045                         pr_global_struct->time = sv.time;
1046                         pr_global_struct->self = EDICT_TO_PROG(sv_player);
1047                         PR_ExecuteProgram (RestoreGame, "");
1048                 }
1049         }
1050         else
1051         {
1052                 eval_t *val;
1053                 // set up the edict
1054                 ent = host_client->edict;
1055
1056                 memset (&ent->v, 0, progs->entityfields * 4);
1057                 ent->v.colormap = NUM_FOR_EDICT(ent);
1058                 ent->v.team = (host_client->colors & 15) + 1;
1059                 ent->v.netname = host_client->name - pr_strings;
1060                 if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1061                         val->_float = host_client->pmodel;
1062
1063                 // copy spawn parms out of the client_t
1064
1065                 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1066                         (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
1067
1068                 // call the spawn function
1069
1070                 pr_global_struct->time = sv.time;
1071                 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1072                 PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
1073
1074                 if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= sv.time)
1075                         Sys_Printf ("%s entered the game\n", host_client->name);
1076
1077                 PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing");
1078         }
1079
1080
1081 // send time of update
1082         MSG_WriteByte (&host_client->message, svc_time);
1083         MSG_WriteFloat (&host_client->message, sv.time);
1084
1085         for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
1086         {
1087                 MSG_WriteByte (&host_client->message, svc_updatename);
1088                 MSG_WriteByte (&host_client->message, i);
1089                 MSG_WriteString (&host_client->message, client->name);
1090                 MSG_WriteByte (&host_client->message, svc_updatefrags);
1091                 MSG_WriteByte (&host_client->message, i);
1092                 MSG_WriteShort (&host_client->message, client->old_frags);
1093                 MSG_WriteByte (&host_client->message, svc_updatecolors);
1094                 MSG_WriteByte (&host_client->message, i);
1095                 MSG_WriteByte (&host_client->message, client->colors);
1096         }
1097         
1098 // send all current light styles
1099         for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1100         {
1101                 MSG_WriteByte (&host_client->message, svc_lightstyle);
1102                 MSG_WriteByte (&host_client->message, (char)i);
1103                 MSG_WriteString (&host_client->message, sv.lightstyles[i]);
1104         }
1105
1106 //
1107 // send some stats
1108 //
1109         MSG_WriteByte (&host_client->message, svc_updatestat);
1110         MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS);
1111         MSG_WriteLong (&host_client->message, pr_global_struct->total_secrets);
1112
1113         MSG_WriteByte (&host_client->message, svc_updatestat);
1114         MSG_WriteByte (&host_client->message, STAT_TOTALMONSTERS);
1115         MSG_WriteLong (&host_client->message, pr_global_struct->total_monsters);
1116
1117         MSG_WriteByte (&host_client->message, svc_updatestat);
1118         MSG_WriteByte (&host_client->message, STAT_SECRETS);
1119         MSG_WriteLong (&host_client->message, pr_global_struct->found_secrets);
1120
1121         MSG_WriteByte (&host_client->message, svc_updatestat);
1122         MSG_WriteByte (&host_client->message, STAT_MONSTERS);
1123         MSG_WriteLong (&host_client->message, pr_global_struct->killed_monsters);
1124
1125 //
1126 // send a fixangle
1127 // Never send a roll angle, because savegames can catch the server
1128 // in a state where it is expecting the client to correct the angle
1129 // and it won't happen if the game was just loaded, so you wind up
1130 // with a permanent head tilt
1131         ent = EDICT_NUM( 1 + (host_client - svs.clients) );
1132         MSG_WriteByte (&host_client->message, svc_setangle);
1133         for (i=0 ; i < 2 ; i++)
1134                 MSG_WriteAngle (&host_client->message, ent->v.angles[i] );
1135         MSG_WriteAngle (&host_client->message, 0 );
1136
1137         SV_WriteClientdataToMessage (sv_player, &host_client->message);
1138
1139         MSG_WriteByte (&host_client->message, svc_signonnum);
1140         MSG_WriteByte (&host_client->message, 3);
1141         host_client->sendsignon = true;
1142 }
1143
1144 /*
1145 ==================
1146 Host_Begin_f
1147 ==================
1148 */
1149 void Host_Begin_f (void)
1150 {
1151         if (cmd_source == src_command)
1152         {
1153                 Con_Printf ("begin is not valid from the console\n");
1154                 return;
1155         }
1156
1157         host_client->spawned = true;
1158 }
1159
1160 //===========================================================================
1161
1162
1163 /*
1164 ==================
1165 Host_Kick_f
1166
1167 Kicks a user off of the server
1168 ==================
1169 */
1170 void Host_Kick_f (void)
1171 {
1172         char            *who;
1173         char            *message = NULL;
1174         client_t        *save;
1175         int                     i;
1176         qboolean        byNumber = false;
1177
1178         if (cmd_source == src_command)
1179         {
1180                 if (!sv.active)
1181                 {
1182                         Cmd_ForwardToServer ();
1183                         return;
1184                 }
1185         }
1186         else if (pr_global_struct->deathmatch)
1187                 return;
1188
1189         save = host_client;
1190
1191         if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1192         {
1193                 i = atof(Cmd_Argv(2)) - 1;
1194                 if (i < 0 || i >= svs.maxclients)
1195                         return;
1196                 if (!svs.clients[i].active)
1197                         return;
1198                 host_client = &svs.clients[i];
1199                 byNumber = true;
1200         }
1201         else
1202         {
1203                 for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
1204                 {
1205                         if (!host_client->active)
1206                                 continue;
1207                         if (Q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1208                                 break;
1209                 }
1210         }
1211
1212         if (i < svs.maxclients)
1213         {
1214                 if (cmd_source == src_command)
1215                         if (cls.state == ca_dedicated)
1216                                 who = "Console";
1217                         else
1218                                 who = cl_name.string;
1219                 else
1220                         who = save->name;
1221
1222                 // can't kick yourself!
1223                 if (host_client == save)
1224                         return;
1225
1226                 if (Cmd_Argc() > 2)
1227                 {
1228                         message = COM_Parse(Cmd_Args());
1229                         if (byNumber)
1230                         {
1231                                 message++;                                                      // skip the #
1232                                 while (*message == ' ')                         // skip white space
1233                                         message++;
1234                                 message += strlen(Cmd_Argv(2)); // skip the number
1235                         }
1236                         while (*message && *message == ' ')
1237                                 message++;
1238                 }
1239                 if (message)
1240                         SV_ClientPrintf ("Kicked by %s: %s\n", who, message);
1241                 else
1242                         SV_ClientPrintf ("Kicked by %s\n", who);
1243                 SV_DropClient (false);
1244         }
1245
1246         host_client = save;
1247 }
1248
1249 /*
1250 ===============================================================================
1251
1252 DEBUGGING TOOLS
1253
1254 ===============================================================================
1255 */
1256
1257 /*
1258 ==================
1259 Host_Give_f
1260 ==================
1261 */
1262 void Host_Give_f (void)
1263 {
1264         char    *t;
1265         int             v;
1266         eval_t  *val;
1267
1268         if (cmd_source == src_command)
1269         {
1270                 Cmd_ForwardToServer ();
1271                 return;
1272         }
1273
1274         if (pr_global_struct->deathmatch)
1275                 return;
1276
1277         t = Cmd_Argv(1);
1278         v = atoi (Cmd_Argv(2));
1279
1280         switch (t[0])
1281         {
1282         case '0':
1283         case '1':
1284         case '2':
1285         case '3':
1286         case '4':
1287         case '5':
1288         case '6':
1289         case '7':
1290         case '8':
1291         case '9':
1292                 // MED 01/04/97 added hipnotic give stuff
1293                 if (gamemode == GAME_HIPNOTIC)
1294                 {
1295                         if (t[0] == '6')
1296                         {
1297                                 if (t[1] == 'a')
1298                                 sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN;
1299                                 else
1300                                 sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER;
1301                         }
1302                         else if (t[0] == '9')
1303                                 sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON;
1304                         else if (t[0] == '0')
1305                                 sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR;
1306                         else if (t[0] >= '2')
1307                                 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1308                 }
1309                 else
1310                 {
1311                         if (t[0] >= '2')
1312                                 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1313                 }
1314                 break;
1315
1316         case 's':
1317                 if (gamemode == GAME_ROGUE)
1318                 {
1319                         if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1)))
1320                                 val->_float = v;
1321                 }
1322
1323                 sv_player->v.ammo_shells = v;
1324                 break;
1325         case 'n':
1326                 if (gamemode == GAME_ROGUE)
1327                 {
1328                         if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1)))
1329                         {
1330                                 val->_float = v;
1331                                 if (sv_player->v.weapon <= IT_LIGHTNING)
1332                                         sv_player->v.ammo_nails = v;
1333                         }
1334                 }
1335                 else
1336                 {
1337                         sv_player->v.ammo_nails = v;
1338                 }
1339                 break;
1340         case 'l':
1341                 if (gamemode == GAME_ROGUE)
1342                 {
1343                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_lava_nails);
1344                         if (val)
1345                         {
1346                                 val->_float = v;
1347                                 if (sv_player->v.weapon > IT_LIGHTNING)
1348                                         sv_player->v.ammo_nails = v;
1349                         }
1350                 }
1351                 break;
1352         case 'r':
1353                 if (gamemode == GAME_ROGUE)
1354                 {
1355                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_rockets1);
1356                         if (val)
1357                         {
1358                                 val->_float = v;
1359                                 if (sv_player->v.weapon <= IT_LIGHTNING)
1360                                         sv_player->v.ammo_rockets = v;
1361                         }
1362                 }
1363                 else
1364                 {
1365                         sv_player->v.ammo_rockets = v;
1366                 }
1367                 break;
1368         case 'm':
1369                 if (gamemode == GAME_ROGUE)
1370                 {
1371                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_multi_rockets);
1372                         if (val)
1373                         {
1374                                 val->_float = v;
1375                                 if (sv_player->v.weapon > IT_LIGHTNING)
1376                                         sv_player->v.ammo_rockets = v;
1377                         }
1378                 }
1379                 break;
1380         case 'h':
1381                 sv_player->v.health = v;
1382                 break;
1383         case 'c':
1384                 if (gamemode == GAME_ROGUE)
1385                 {
1386                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_cells1);
1387                         if (val)
1388                         {
1389                                 val->_float = v;
1390                                 if (sv_player->v.weapon <= IT_LIGHTNING)
1391                                         sv_player->v.ammo_cells = v;
1392                         }
1393                 }
1394                 else
1395                 {
1396                         sv_player->v.ammo_cells = v;
1397                 }
1398                 break;
1399         case 'p':
1400                 if (gamemode == GAME_ROGUE)
1401                 {
1402                         val = GETEDICTFIELDVALUE(sv_player, eval_ammo_plasma);
1403                         if (val)
1404                         {
1405                                 val->_float = v;
1406                                 if (sv_player->v.weapon > IT_LIGHTNING)
1407                                         sv_player->v.ammo_cells = v;
1408                         }
1409                 }
1410                 break;
1411         }
1412 }
1413
1414 edict_t *FindViewthing (void)
1415 {
1416         int             i;
1417         edict_t *e;
1418
1419         for (i=0 ; i<sv.num_edicts ; i++)
1420         {
1421                 e = EDICT_NUM(i);
1422                 if ( !strcmp (pr_strings + e->v.classname, "viewthing") )
1423                         return e;
1424         }
1425         Con_Printf ("No viewthing on map\n");
1426         return NULL;
1427 }
1428
1429 /*
1430 ==================
1431 Host_Viewmodel_f
1432 ==================
1433 */
1434 void Host_Viewmodel_f (void)
1435 {
1436         edict_t *e;
1437         model_t *m;
1438
1439         e = FindViewthing ();
1440         if (!e)
1441                 return;
1442
1443         m = Mod_ForName (Cmd_Argv(1), false, true, false);
1444         if (!m)
1445         {
1446                 Con_Printf ("Can't load %s\n", Cmd_Argv(1));
1447                 return;
1448         }
1449         
1450         e->v.frame = 0;
1451         cl.model_precache[(int)e->v.modelindex] = m;
1452 }
1453
1454 /*
1455 ==================
1456 Host_Viewframe_f
1457 ==================
1458 */
1459 void Host_Viewframe_f (void)
1460 {
1461         edict_t *e;
1462         int             f;
1463         model_t *m;
1464
1465         e = FindViewthing ();
1466         if (!e)
1467                 return;
1468         m = cl.model_precache[(int)e->v.modelindex];
1469
1470         f = atoi(Cmd_Argv(1));
1471         if (f >= m->numframes)
1472                 f = m->numframes-1;
1473
1474         e->v.frame = f;         
1475 }
1476
1477
1478 void PrintFrameName (model_t *m, int frame)
1479 {
1480         if (m->animscenes)
1481                 Con_Printf("frame %i: %s\n", frame, m->animscenes[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.demoplayback)
1604                 return;
1605         CL_Disconnect ();
1606 }
1607
1608 //=============================================================================
1609
1610 /*
1611 ==================
1612 Host_InitCommands
1613 ==================
1614 */
1615 void Host_InitCommands (void)
1616 {
1617         Cmd_AddCommand ("status", Host_Status_f);
1618         Cmd_AddCommand ("quit", Host_Quit_f);
1619         if (gamemode == GAME_NEHAHRA)
1620         {
1621                 Cmd_AddCommand ("max", Host_God_f);
1622                 Cmd_AddCommand ("monster", Host_Notarget_f);
1623                 Cmd_AddCommand ("scrag", Host_Fly_f);
1624                 Cmd_AddCommand ("wraith", Host_Noclip_f);
1625                 Cmd_AddCommand ("gimme", Host_Give_f);
1626         }
1627         else
1628         {
1629                 Cmd_AddCommand ("god", Host_God_f);
1630                 Cmd_AddCommand ("notarget", Host_Notarget_f);
1631                 Cmd_AddCommand ("fly", Host_Fly_f);
1632                 Cmd_AddCommand ("noclip", Host_Noclip_f);
1633                 Cmd_AddCommand ("give", Host_Give_f);
1634         }
1635         Cmd_AddCommand ("map", Host_Map_f);
1636         Cmd_AddCommand ("restart", Host_Restart_f);
1637         Cmd_AddCommand ("changelevel", Host_Changelevel_f);
1638         Cmd_AddCommand ("connect", Host_Connect_f);
1639         Cmd_AddCommand ("reconnect", Host_Reconnect_f);
1640         Cmd_AddCommand ("name", Host_Name_f);
1641         Cmd_AddCommand ("version", Host_Version_f);
1642         Cmd_AddCommand ("say", Host_Say_f);
1643         Cmd_AddCommand ("say_team", Host_Say_Team_f);
1644         Cmd_AddCommand ("tell", Host_Tell_f);
1645         Cmd_AddCommand ("color", Host_Color_f);
1646         Cmd_AddCommand ("kill", Host_Kill_f);
1647         Cmd_AddCommand ("pause", Host_Pause_f);
1648         Cmd_AddCommand ("spawn", Host_Spawn_f);
1649         Cmd_AddCommand ("begin", Host_Begin_f);
1650         Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
1651         Cmd_AddCommand ("kick", Host_Kick_f);
1652         Cmd_AddCommand ("ping", Host_Ping_f);
1653         Cmd_AddCommand ("load", Host_Loadgame_f);
1654         Cmd_AddCommand ("save", Host_Savegame_f);
1655
1656         Cmd_AddCommand ("startdemos", Host_Startdemos_f);
1657         Cmd_AddCommand ("demos", Host_Demos_f);
1658         Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
1659
1660         Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
1661         Cmd_AddCommand ("viewframe", Host_Viewframe_f);
1662         Cmd_AddCommand ("viewnext", Host_Viewnext_f);
1663         Cmd_AddCommand ("viewprev", Host_Viewprev_f);
1664 }