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