Fix for the problem that SDL applications exited
[AROS-Contrib.git] / Games / Quake / host_cmd.c
blob79c20a3ee94a97fcbbcb6c2107d1d558b4ad94df
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
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.
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.
13 See the GNU General Public License for more details.
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.
21 #include "quakedef.h"
23 extern cvar_t pausable;
25 int current_skill;
27 void Mod_Print (void);
30 ==================
31 Host_Quit_f
32 ==================
35 extern void M_Menu_Quit_f (void);
37 void Host_Quit_f (void)
39 if (key_dest != key_console && cls.state != ca_dedicated)
41 M_Menu_Quit_f ();
42 return;
44 CL_Disconnect ();
45 Host_ShutdownServer(false);
47 Sys_Quit ();
52 ==================
53 Host_Status_f
54 ==================
56 void Host_Status_f (void)
58 client_t *client;
59 int seconds;
60 int minutes;
61 int hours = 0;
62 int j;
63 void (*print) (char *fmt, ...);
65 if (cmd_source == src_command)
67 if (!sv.active)
69 Cmd_ForwardToServer ();
70 return;
72 print = Con_Printf;
74 else
75 print = SV_ClientPrintf;
77 print ("host: %s\n", Cvar_VariableString ("hostname"));
78 print ("version: %4.2f\n", VERSION);
79 if (tcpipAvailable)
80 print ("tcp/ip: %s\n", my_tcpip_address);
81 if (ipxAvailable)
82 print ("ipx: %s\n", my_ipx_address);
83 print ("map: %s\n", sv.name);
84 print ("players: %i active (%i max)\n\n", net_activeconnections, svs.maxclients);
85 for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
87 if (!client->active)
88 continue;
89 seconds = (int)(net_time - client->netconnection->connecttime);
90 minutes = seconds / 60;
91 if (minutes)
93 seconds -= (minutes * 60);
94 hours = minutes / 60;
95 if (hours)
96 minutes -= (hours * 60);
98 else
99 hours = 0;
100 print ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->v.frags, hours, minutes, seconds);
101 print (" %s\n", client->netconnection->address);
107 ==================
108 Host_God_f
110 Sets client to godmode
111 ==================
113 void Host_God_f (void)
115 if (cmd_source == src_command)
117 Cmd_ForwardToServer ();
118 return;
121 if (pr_global_struct->deathmatch && !host_client->privileged)
122 return;
124 sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
125 if (!((int)sv_player->v.flags & FL_GODMODE) )
126 SV_ClientPrintf ("godmode OFF\n");
127 else
128 SV_ClientPrintf ("godmode ON\n");
131 void Host_Notarget_f (void)
133 if (cmd_source == src_command)
135 Cmd_ForwardToServer ();
136 return;
139 if (pr_global_struct->deathmatch && !host_client->privileged)
140 return;
142 sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
143 if (!((int)sv_player->v.flags & FL_NOTARGET) )
144 SV_ClientPrintf ("notarget OFF\n");
145 else
146 SV_ClientPrintf ("notarget ON\n");
149 qboolean noclip_anglehack;
151 void Host_Noclip_f (void)
153 if (cmd_source == src_command)
155 Cmd_ForwardToServer ();
156 return;
159 if (pr_global_struct->deathmatch && !host_client->privileged)
160 return;
162 if (sv_player->v.movetype != MOVETYPE_NOCLIP)
164 noclip_anglehack = true;
165 sv_player->v.movetype = MOVETYPE_NOCLIP;
166 SV_ClientPrintf ("noclip ON\n");
168 else
170 noclip_anglehack = false;
171 sv_player->v.movetype = MOVETYPE_WALK;
172 SV_ClientPrintf ("noclip OFF\n");
177 ==================
178 Host_Fly_f
180 Sets client to flymode
181 ==================
183 void Host_Fly_f (void)
185 if (cmd_source == src_command)
187 Cmd_ForwardToServer ();
188 return;
191 if (pr_global_struct->deathmatch && !host_client->privileged)
192 return;
194 if (sv_player->v.movetype != MOVETYPE_FLY)
196 sv_player->v.movetype = MOVETYPE_FLY;
197 SV_ClientPrintf ("flymode ON\n");
199 else
201 sv_player->v.movetype = MOVETYPE_WALK;
202 SV_ClientPrintf ("flymode OFF\n");
208 ==================
209 Host_Ping_f
211 ==================
213 void Host_Ping_f (void)
215 int i, j;
216 float total;
217 client_t *client;
219 if (cmd_source == src_command)
221 Cmd_ForwardToServer ();
222 return;
225 SV_ClientPrintf ("Client ping times:\n");
226 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
228 if (!client->active)
229 continue;
230 total = 0;
231 for (j=0 ; j<NUM_PING_TIMES ; j++)
232 total+=client->ping_times[j];
233 total /= NUM_PING_TIMES;
234 SV_ClientPrintf ("%4i %s\n", (int)(total*1000), client->name);
239 ===============================================================================
241 SERVER TRANSITIONS
243 ===============================================================================
248 ======================
249 Host_Map_f
251 handle a
252 map <servername>
253 command from the console. Active clients are kicked off.
254 ======================
256 void Host_Map_f (void)
258 int i;
259 char name[MAX_QPATH];
261 if (cmd_source != src_command)
262 return;
264 cls.demonum = -1; // stop demo loop in case this fails
266 CL_Disconnect ();
267 Host_ShutdownServer(false);
269 key_dest = key_game; // remove console or menu
270 SCR_BeginLoadingPlaque ();
272 cls.mapstring[0] = 0;
273 for (i=0 ; i<Cmd_Argc() ; i++)
275 strcat (cls.mapstring, Cmd_Argv(i));
276 strcat (cls.mapstring, " ");
278 strcat (cls.mapstring, "\n");
280 svs.serverflags = 0; // haven't completed an episode yet
281 strcpy (name, Cmd_Argv(1));
282 #ifdef QUAKE2
283 SV_SpawnServer (name, NULL);
284 #else
285 SV_SpawnServer (name);
286 #endif
287 if (!sv.active)
288 return;
290 if (cls.state != ca_dedicated)
292 strcpy (cls.spawnparms, "");
294 for (i=2 ; i<Cmd_Argc() ; i++)
296 strcat (cls.spawnparms, Cmd_Argv(i));
297 strcat (cls.spawnparms, " ");
300 Cmd_ExecuteString ("connect local", src_command);
305 ==================
306 Host_Changelevel_f
308 Goes to a new map, taking all clients along
309 ==================
311 void Host_Changelevel_f (void)
313 #ifdef QUAKE2
314 char level[MAX_QPATH];
315 char _startspot[MAX_QPATH];
316 char *startspot;
318 if (Cmd_Argc() < 2)
320 Con_Printf ("changelevel <levelname> : continue game on a new level\n");
321 return;
323 if (!sv.active || cls.demoplayback)
325 Con_Printf ("Only the server may changelevel\n");
326 return;
329 strcpy (level, Cmd_Argv(1));
330 if (Cmd_Argc() == 2)
331 startspot = NULL;
332 else
334 strcpy (_startspot, Cmd_Argv(2));
335 startspot = _startspot;
338 SV_SaveSpawnparms ();
339 SV_SpawnServer (level, startspot);
340 #else
341 char level[MAX_QPATH];
343 if (Cmd_Argc() != 2)
345 Con_Printf ("changelevel <levelname> : continue game on a new level\n");
346 return;
348 if (!sv.active || cls.demoplayback)
350 Con_Printf ("Only the server may changelevel\n");
351 return;
353 SV_SaveSpawnparms ();
354 strcpy (level, Cmd_Argv(1));
355 SV_SpawnServer (level);
356 #endif
360 ==================
361 Host_Restart_f
363 Restarts the current server for a dead player
364 ==================
366 void Host_Restart_f (void)
368 char mapname[MAX_QPATH];
369 #ifdef QUAKE2
370 char startspot[MAX_QPATH];
371 #endif
373 if (cls.demoplayback || !sv.active)
374 return;
376 if (cmd_source != src_command)
377 return;
378 strcpy (mapname, sv.name); // must copy out, because it gets cleared
379 // in sv_spawnserver
380 #ifdef QUAKE2
381 strcpy(startspot, sv.startspot);
382 SV_SpawnServer (mapname, startspot);
383 #else
384 SV_SpawnServer (mapname);
385 #endif
389 ==================
390 Host_Reconnect_f
392 This command causes the client to wait for the signon messages again.
393 This is sent just before a server changes levels
394 ==================
396 void Host_Reconnect_f (void)
398 SCR_BeginLoadingPlaque ();
399 cls.signon = 0; // need new connection messages
403 =====================
404 Host_Connect_f
406 User command to connect to server
407 =====================
409 void Host_Connect_f (void)
411 char name[MAX_QPATH];
413 cls.demonum = -1; // stop demo loop in case this fails
414 if (cls.demoplayback)
416 CL_StopPlayback ();
417 CL_Disconnect ();
419 strcpy (name, Cmd_Argv(1));
420 CL_EstablishConnection (name);
421 Host_Reconnect_f ();
426 ===============================================================================
428 LOAD / SAVE GAME
430 ===============================================================================
433 #define SAVEGAME_VERSION 5
436 ===============
437 Host_SavegameComment
439 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
440 ===============
442 void Host_SavegameComment (char *text)
444 int i;
445 char kills[20];
447 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
448 text[i] = ' ';
449 memcpy (text, cl.levelname, strlen(cl.levelname));
450 sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
451 memcpy (text+22, kills, strlen(kills));
452 // convert space to _ to make stdio happy
453 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
454 if (text[i] == ' ')
455 text[i] = '_';
456 text[SAVEGAME_COMMENT_LENGTH] = '\0';
461 ===============
462 Host_Savegame_f
463 ===============
465 void Host_Savegame_f (void)
467 char name[256];
468 FILE *f;
469 int i;
470 char comment[SAVEGAME_COMMENT_LENGTH+1];
472 if (cmd_source != src_command)
473 return;
475 if (!sv.active)
477 Con_Printf ("Not playing a local game.\n");
478 return;
481 if (cl.intermission)
483 Con_Printf ("Can't save in intermission.\n");
484 return;
487 if (svs.maxclients != 1)
489 Con_Printf ("Can't save multiplayer games.\n");
490 return;
493 if (Cmd_Argc() != 2)
495 Con_Printf ("save <savename> : save a game\n");
496 return;
499 if (strstr(Cmd_Argv(1), ".."))
501 Con_Printf ("Relative pathnames are not allowed.\n");
502 return;
505 for (i=0 ; i<svs.maxclients ; i++)
507 if (svs.clients[i].active && (svs.clients[i].edict->v.health <= 0) )
509 Con_Printf ("Can't savegame with a dead player\n");
510 return;
514 sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
515 COM_DefaultExtension (name, ".sav");
517 Con_Printf ("Saving game to %s...\n", name);
518 f = fopen (name, "w");
519 if (!f)
521 Con_Printf ("ERROR: couldn't open.\n");
522 return;
525 fprintf (f, "%i\n", SAVEGAME_VERSION);
526 Host_SavegameComment (comment);
527 fprintf (f, "%s\n", comment);
528 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
529 fprintf (f, "%f\n", svs.clients->spawn_parms[i]);
530 fprintf (f, "%d\n", current_skill);
531 fprintf (f, "%s\n", sv.name);
532 fprintf (f, "%f\n",sv.time);
534 // write the light styles
536 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
538 if (sv.lightstyles[i])
539 fprintf (f, "%s\n", sv.lightstyles[i]);
540 else
541 fprintf (f,"m\n");
545 ED_WriteGlobals (f);
546 for (i=0 ; i<sv.num_edicts ; i++)
548 ED_Write (f, EDICT_NUM(i));
549 fflush (f);
551 fclose (f);
552 Con_Printf ("done.\n");
557 ===============
558 Host_Loadgame_f
559 ===============
561 void Host_Loadgame_f (void)
563 char name[MAX_OSPATH];
564 FILE *f;
565 char mapname[MAX_QPATH];
566 float time, tfloat;
567 char str[32768], *start;
568 int i, r;
569 edict_t *ent;
570 int entnum;
571 int version;
572 float spawn_parms[NUM_SPAWN_PARMS];
574 if (cmd_source != src_command)
575 return;
577 if (Cmd_Argc() != 2)
579 Con_Printf ("load <savename> : load a game\n");
580 return;
583 cls.demonum = -1; // stop demo loop in case this fails
585 sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
586 COM_DefaultExtension (name, ".sav");
588 // we can't call SCR_BeginLoadingPlaque, because too much stack space has
589 // been used. The menu calls it before stuffing loadgame command
590 // SCR_BeginLoadingPlaque ();
592 Con_Printf ("Loading game from %s...\n", name);
593 f = fopen (name, "r");
594 if (!f)
596 Con_Printf ("ERROR: couldn't open.\n");
597 return;
600 fscanf (f, "%i\n", &version);
601 if (version != SAVEGAME_VERSION)
603 fclose (f);
604 Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
605 return;
607 fscanf (f, "%s\n", str);
608 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
609 fscanf (f, "%f\n", &spawn_parms[i]);
610 // this silliness is so we can load 1.06 save files, which have float skill values
611 fscanf (f, "%f\n", &tfloat);
612 current_skill = (int)(tfloat + 0.1);
613 Cvar_SetValue ("skill", (float)current_skill);
615 #ifdef QUAKE2
616 Cvar_SetValue ("deathmatch", 0);
617 Cvar_SetValue ("coop", 0);
618 Cvar_SetValue ("teamplay", 0);
619 #endif
621 fscanf (f, "%s\n",mapname);
622 fscanf (f, "%f\n",&time);
624 CL_Disconnect_f ();
626 #ifdef QUAKE2
627 SV_SpawnServer (mapname, NULL);
628 #else
629 SV_SpawnServer (mapname);
630 #endif
631 if (!sv.active)
633 Con_Printf ("Couldn't load map\n");
634 return;
636 sv.paused = true; // pause until all clients connect
637 sv.loadgame = true;
639 // load the light styles
641 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
643 fscanf (f, "%s\n", str);
644 sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
645 strcpy (sv.lightstyles[i], str);
648 // load the edicts out of the savegame file
649 entnum = -1; // -1 is the globals
650 while (!feof(f))
652 for (i=0 ; i<sizeof(str)-1 ; i++)
654 r = fgetc (f);
655 if (r == EOF || !r)
656 break;
657 str[i] = r;
658 if (r == '}')
660 i++;
661 break;
664 if (i == sizeof(str)-1)
665 Sys_Error ("Loadgame buffer overflow");
666 str[i] = 0;
667 start = str;
668 start = COM_Parse(str);
669 if (!com_token[0])
670 break; // end of file
671 if (strcmp(com_token,"{"))
672 Sys_Error ("First token isn't a brace");
674 if (entnum == -1)
675 { // parse the global vars
676 ED_ParseGlobals (start);
678 else
679 { // parse an edict
681 ent = EDICT_NUM(entnum);
682 memset (&ent->v, 0, progs->entityfields * 4);
683 ent->free = false;
684 ED_ParseEdict (start, ent);
686 // link it into the bsp tree
687 if (!ent->free)
688 SV_LinkEdict (ent, false);
691 entnum++;
694 sv.num_edicts = entnum;
695 sv.time = time;
697 fclose (f);
699 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
700 svs.clients->spawn_parms[i] = spawn_parms[i];
702 if (cls.state != ca_dedicated)
704 CL_EstablishConnection ("local");
705 Host_Reconnect_f ();
709 #ifdef QUAKE2
710 void SaveGamestate()
712 char name[256];
713 FILE *f;
714 int i;
715 char comment[SAVEGAME_COMMENT_LENGTH+1];
716 edict_t *ent;
718 sprintf (name, "%s/%s.gip", com_gamedir, sv.name);
720 Con_Printf ("Saving game to %s...\n", name);
721 f = fopen (name, "w");
722 if (!f)
724 Con_Printf ("ERROR: couldn't open.\n");
725 return;
728 fprintf (f, "%i\n", SAVEGAME_VERSION);
729 Host_SavegameComment (comment);
730 fprintf (f, "%s\n", comment);
731 // for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
732 // fprintf (f, "%f\n", svs.clients->spawn_parms[i]);
733 fprintf (f, "%f\n", skill.value);
734 fprintf (f, "%s\n", sv.name);
735 fprintf (f, "%f\n", sv.time);
737 // write the light styles
739 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
741 if (sv.lightstyles[i])
742 fprintf (f, "%s\n", sv.lightstyles[i]);
743 else
744 fprintf (f,"m\n");
748 for (i=svs.maxclients+1 ; i<sv.num_edicts ; i++)
750 ent = EDICT_NUM(i);
751 if ((int)ent->v.flags & FL_ARCHIVE_OVERRIDE)
752 continue;
753 fprintf (f, "%i\n",i);
754 ED_Write (f, ent);
755 fflush (f);
757 fclose (f);
758 Con_Printf ("done.\n");
761 int LoadGamestate(char *level, char *startspot)
763 char name[MAX_OSPATH];
764 FILE *f;
765 char mapname[MAX_QPATH];
766 float time, sk;
767 char str[32768], *start;
768 int i, r;
769 edict_t *ent;
770 int entnum;
771 int version;
772 // float spawn_parms[NUM_SPAWN_PARMS];
774 sprintf (name, "%s/%s.gip", com_gamedir, level);
776 Con_Printf ("Loading game from %s...\n", name);
777 f = fopen (name, "r");
778 if (!f)
780 Con_Printf ("ERROR: couldn't open.\n");
781 return -1;
784 fscanf (f, "%i\n", &version);
785 if (version != SAVEGAME_VERSION)
787 fclose (f);
788 Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
789 return -1;
791 fscanf (f, "%s\n", str);
792 // for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
793 // fscanf (f, "%f\n", &spawn_parms[i]);
794 fscanf (f, "%f\n", &sk);
795 Cvar_SetValue ("skill", sk);
797 fscanf (f, "%s\n",mapname);
798 fscanf (f, "%f\n",&time);
800 SV_SpawnServer (mapname, startspot);
802 if (!sv.active)
804 Con_Printf ("Couldn't load map\n");
805 return -1;
808 // load the light styles
809 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
811 fscanf (f, "%s\n", str);
812 sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
813 strcpy (sv.lightstyles[i], str);
816 // load the edicts out of the savegame file
817 while (!feof(f))
819 fscanf (f, "%i\n",&entnum);
820 for (i=0 ; i<sizeof(str)-1 ; i++)
822 r = fgetc (f);
823 if (r == EOF || !r)
824 break;
825 str[i] = r;
826 if (r == '}')
828 i++;
829 break;
832 if (i == sizeof(str)-1)
833 Sys_Error ("Loadgame buffer overflow");
834 str[i] = 0;
835 start = str;
836 start = COM_Parse(str);
837 if (!com_token[0])
838 break; // end of file
839 if (strcmp(com_token,"{"))
840 Sys_Error ("First token isn't a brace");
842 // parse an edict
844 ent = EDICT_NUM(entnum);
845 memset (&ent->v, 0, progs->entityfields * 4);
846 ent->free = false;
847 ED_ParseEdict (start, ent);
849 // link it into the bsp tree
850 if (!ent->free)
851 SV_LinkEdict (ent, false);
854 // sv.num_edicts = entnum;
855 sv.time = time;
856 fclose (f);
858 // for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
859 // svs.clients->spawn_parms[i] = spawn_parms[i];
861 return 0;
864 // changing levels within a unit
865 void Host_Changelevel2_f (void)
867 char level[MAX_QPATH];
868 char _startspot[MAX_QPATH];
869 char *startspot;
871 if (Cmd_Argc() < 2)
873 Con_Printf ("changelevel2 <levelname> : continue game on a new level in the unit\n");
874 return;
876 if (!sv.active || cls.demoplayback)
878 Con_Printf ("Only the server may changelevel\n");
879 return;
882 strcpy (level, Cmd_Argv(1));
883 if (Cmd_Argc() == 2)
884 startspot = NULL;
885 else
887 strcpy (_startspot, Cmd_Argv(2));
888 startspot = _startspot;
891 SV_SaveSpawnparms ();
893 // save the current level's state
894 SaveGamestate ();
896 // try to restore the new level
897 if (LoadGamestate (level, startspot))
898 SV_SpawnServer (level, startspot);
900 #endif
903 //============================================================================
906 ======================
907 Host_Name_f
908 ======================
910 void Host_Name_f (void)
912 char *newName;
914 if (Cmd_Argc () == 1)
916 Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
917 return;
919 if (Cmd_Argc () == 2)
920 newName = Cmd_Argv(1);
921 else
922 newName = Cmd_Args();
923 newName[15] = 0;
925 if (cmd_source == src_command)
927 if (Q_strcmp(cl_name.string, newName) == 0)
928 return;
929 Cvar_Set ("_cl_name", newName);
930 if (cls.state == ca_connected)
931 Cmd_ForwardToServer ();
932 return;
935 if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
936 if (Q_strcmp(host_client->name, newName) != 0)
937 Con_Printf ("%s renamed to %s\n", host_client->name, newName);
938 Q_strcpy (host_client->name, newName);
939 host_client->edict->v.netname = host_client->name - pr_strings;
941 // send notification to all clients
943 MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
944 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
945 MSG_WriteString (&sv.reliable_datagram, host_client->name);
949 void Host_Version_f (void)
951 Con_Printf ("Version %4.2f\n", VERSION);
952 Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
955 #ifdef IDGODS
956 void Host_Please_f (void)
958 client_t *cl;
959 int j;
961 if (cmd_source != src_command)
962 return;
964 if ((Cmd_Argc () == 3) && Q_strcmp(Cmd_Argv(1), "#") == 0)
966 j = Q_atof(Cmd_Argv(2)) - 1;
967 if (j < 0 || j >= svs.maxclients)
968 return;
969 if (!svs.clients[j].active)
970 return;
971 cl = &svs.clients[j];
972 if (cl->privileged)
974 cl->privileged = false;
975 cl->edict->v.flags = (int)cl->edict->v.flags & ~(FL_GODMODE|FL_NOTARGET);
976 cl->edict->v.movetype = MOVETYPE_WALK;
977 noclip_anglehack = false;
979 else
980 cl->privileged = true;
983 if (Cmd_Argc () != 2)
984 return;
986 for (j=0, cl = svs.clients ; j<svs.maxclients ; j++, cl++)
988 if (!cl->active)
989 continue;
990 if (Q_strcasecmp(cl->name, Cmd_Argv(1)) == 0)
992 if (cl->privileged)
994 cl->privileged = false;
995 cl->edict->v.flags = (int)cl->edict->v.flags & ~(FL_GODMODE|FL_NOTARGET);
996 cl->edict->v.movetype = MOVETYPE_WALK;
997 noclip_anglehack = false;
999 else
1000 cl->privileged = true;
1001 break;
1005 #endif
1008 void Host_Say(qboolean teamonly)
1010 client_t *client;
1011 client_t *save;
1012 int j;
1013 char *p;
1014 unsigned char text[64];
1015 qboolean fromServer = false;
1017 if (cmd_source == src_command)
1019 if (cls.state == ca_dedicated)
1021 fromServer = true;
1022 teamonly = false;
1024 else
1026 Cmd_ForwardToServer ();
1027 return;
1031 if (Cmd_Argc () < 2)
1032 return;
1034 save = host_client;
1036 p = Cmd_Args();
1037 // remove quotes if present
1038 if (*p == '"')
1040 p++;
1041 p[Q_strlen(p)-1] = 0;
1044 // turn on color set 1
1045 if (!fromServer)
1046 sprintf (text, "%c%s: ", 1, save->name);
1047 else
1048 sprintf (text, "%c<%s> ", 1, hostname.string);
1050 j = sizeof(text) - 2 - Q_strlen(text); // -2 for /n and null terminator
1051 if (Q_strlen(p) > j)
1052 p[j] = 0;
1054 strcat (text, p);
1055 strcat (text, "\n");
1057 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
1059 if (!client || !client->active || !client->spawned)
1060 continue;
1061 if (teamplay.value && teamonly && client->edict->v.team != save->edict->v.team)
1062 continue;
1063 host_client = client;
1064 SV_ClientPrintf("%s", text);
1066 host_client = save;
1068 Sys_Printf("%s", &text[1]);
1072 void Host_Say_f(void)
1074 Host_Say(false);
1078 void Host_Say_Team_f(void)
1080 Host_Say(true);
1084 void Host_Tell_f(void)
1086 client_t *client;
1087 client_t *save;
1088 int j;
1089 char *p;
1090 char text[64];
1092 if (cmd_source == src_command)
1094 Cmd_ForwardToServer ();
1095 return;
1098 if (Cmd_Argc () < 3)
1099 return;
1101 Q_strcpy(text, host_client->name);
1102 Q_strcat(text, ": ");
1104 p = Cmd_Args();
1106 // remove quotes if present
1107 if (*p == '"')
1109 p++;
1110 p[Q_strlen(p)-1] = 0;
1113 // check length & truncate if necessary
1114 j = sizeof(text) - 2 - Q_strlen(text); // -2 for /n and null terminator
1115 if (Q_strlen(p) > j)
1116 p[j] = 0;
1118 strcat (text, p);
1119 strcat (text, "\n");
1121 save = host_client;
1122 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
1124 if (!client->active || !client->spawned)
1125 continue;
1126 if (Q_strcasecmp(client->name, Cmd_Argv(1)))
1127 continue;
1128 host_client = client;
1129 SV_ClientPrintf("%s", text);
1130 break;
1132 host_client = save;
1137 ==================
1138 Host_Color_f
1139 ==================
1141 void Host_Color_f(void)
1143 int top, bottom;
1144 int playercolor;
1146 if (Cmd_Argc() == 1)
1148 Con_Printf ("\"color\" is \"%i %i\"\n", ((int)cl_color.value) >> 4, ((int)cl_color.value) & 0x0f);
1149 Con_Printf ("color <0-13> [0-13]\n");
1150 return;
1153 if (Cmd_Argc() == 2)
1154 top = bottom = atoi(Cmd_Argv(1));
1155 else
1157 top = atoi(Cmd_Argv(1));
1158 bottom = atoi(Cmd_Argv(2));
1161 top &= 15;
1162 if (top > 13)
1163 top = 13;
1164 bottom &= 15;
1165 if (bottom > 13)
1166 bottom = 13;
1168 playercolor = top*16 + bottom;
1170 if (cmd_source == src_command)
1172 Cvar_SetValue ("_cl_color", playercolor);
1173 if (cls.state == ca_connected)
1174 Cmd_ForwardToServer ();
1175 return;
1178 host_client->colors = playercolor;
1179 host_client->edict->v.team = bottom + 1;
1181 // send notification to all clients
1182 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
1183 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
1184 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
1188 ==================
1189 Host_Kill_f
1190 ==================
1192 void Host_Kill_f (void)
1194 if (cmd_source == src_command)
1196 Cmd_ForwardToServer ();
1197 return;
1200 if (sv_player->v.health <= 0)
1202 SV_ClientPrintf ("Can't suicide -- allready dead!\n");
1203 return;
1206 pr_global_struct->time = sv.time;
1207 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1208 PR_ExecuteProgram (pr_global_struct->ClientKill);
1213 ==================
1214 Host_Pause_f
1215 ==================
1217 void Host_Pause_f (void)
1220 if (cmd_source == src_command)
1222 Cmd_ForwardToServer ();
1223 return;
1225 if (!pausable.value)
1226 SV_ClientPrintf ("Pause not allowed.\n");
1227 else
1229 sv.paused ^= 1;
1231 if (sv.paused)
1233 SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v.netname);
1235 else
1237 SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v.netname);
1240 // send notification to all clients
1241 MSG_WriteByte (&sv.reliable_datagram, svc_setpause);
1242 MSG_WriteByte (&sv.reliable_datagram, sv.paused);
1246 //===========================================================================
1250 ==================
1251 Host_PreSpawn_f
1252 ==================
1254 void Host_PreSpawn_f (void)
1256 if (cmd_source == src_command)
1258 Con_Printf ("prespawn is not valid from the console\n");
1259 return;
1262 if (host_client->spawned)
1264 Con_Printf ("prespawn not valid -- allready spawned\n");
1265 return;
1268 SZ_Write (&host_client->message, sv.signon.data, sv.signon.cursize);
1269 MSG_WriteByte (&host_client->message, svc_signonnum);
1270 MSG_WriteByte (&host_client->message, 2);
1271 host_client->sendsignon = true;
1275 ==================
1276 Host_Spawn_f
1277 ==================
1279 void Host_Spawn_f (void)
1281 int i;
1282 client_t *client;
1283 edict_t *ent;
1285 if (cmd_source == src_command)
1287 Con_Printf ("spawn is not valid from the console\n");
1288 return;
1291 if (host_client->spawned)
1293 Con_Printf ("Spawn not valid -- allready spawned\n");
1294 return;
1297 // run the entrance script
1298 if (sv.loadgame)
1299 { // loaded games are fully inited allready
1300 // if this is the last client to be connected, unpause
1301 sv.paused = false;
1303 else
1305 // set up the edict
1306 ent = host_client->edict;
1308 memset (&ent->v, 0, progs->entityfields * 4);
1309 ent->v.colormap = NUM_FOR_EDICT(ent);
1310 ent->v.team = (host_client->colors & 15) + 1;
1311 ent->v.netname = host_client->name - pr_strings;
1313 // copy spawn parms out of the client_t
1315 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1316 (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
1318 // call the spawn function
1320 pr_global_struct->time = sv.time;
1321 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1322 PR_ExecuteProgram (pr_global_struct->ClientConnect);
1324 if ((Sys_FloatTime() - host_client->netconnection->connecttime) <= sv.time)
1325 Sys_Printf ("%s entered the game\n", host_client->name);
1327 PR_ExecuteProgram (pr_global_struct->PutClientInServer);
1331 // send all current names, colors, and frag counts
1332 SZ_Clear (&host_client->message);
1334 // send time of update
1335 MSG_WriteByte (&host_client->message, svc_time);
1336 MSG_WriteFloat (&host_client->message, sv.time);
1338 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
1340 MSG_WriteByte (&host_client->message, svc_updatename);
1341 MSG_WriteByte (&host_client->message, i);
1342 MSG_WriteString (&host_client->message, client->name);
1343 MSG_WriteByte (&host_client->message, svc_updatefrags);
1344 MSG_WriteByte (&host_client->message, i);
1345 MSG_WriteShort (&host_client->message, client->old_frags);
1346 MSG_WriteByte (&host_client->message, svc_updatecolors);
1347 MSG_WriteByte (&host_client->message, i);
1348 MSG_WriteByte (&host_client->message, client->colors);
1351 // send all current light styles
1352 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1354 MSG_WriteByte (&host_client->message, svc_lightstyle);
1355 MSG_WriteByte (&host_client->message, (char)i);
1356 MSG_WriteString (&host_client->message, sv.lightstyles[i]);
1360 // send some stats
1362 MSG_WriteByte (&host_client->message, svc_updatestat);
1363 MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS);
1364 MSG_WriteLong (&host_client->message, pr_global_struct->total_secrets);
1366 MSG_WriteByte (&host_client->message, svc_updatestat);
1367 MSG_WriteByte (&host_client->message, STAT_TOTALMONSTERS);
1368 MSG_WriteLong (&host_client->message, pr_global_struct->total_monsters);
1370 MSG_WriteByte (&host_client->message, svc_updatestat);
1371 MSG_WriteByte (&host_client->message, STAT_SECRETS);
1372 MSG_WriteLong (&host_client->message, pr_global_struct->found_secrets);
1374 MSG_WriteByte (&host_client->message, svc_updatestat);
1375 MSG_WriteByte (&host_client->message, STAT_MONSTERS);
1376 MSG_WriteLong (&host_client->message, pr_global_struct->killed_monsters);
1380 // send a fixangle
1381 // Never send a roll angle, because savegames can catch the server
1382 // in a state where it is expecting the client to correct the angle
1383 // and it won't happen if the game was just loaded, so you wind up
1384 // with a permanent head tilt
1385 ent = EDICT_NUM( 1 + (host_client - svs.clients) );
1386 MSG_WriteByte (&host_client->message, svc_setangle);
1387 for (i=0 ; i < 2 ; i++)
1388 MSG_WriteAngle (&host_client->message, ent->v.angles[i] );
1389 MSG_WriteAngle (&host_client->message, 0 );
1391 SV_WriteClientdataToMessage (sv_player, &host_client->message);
1393 MSG_WriteByte (&host_client->message, svc_signonnum);
1394 MSG_WriteByte (&host_client->message, 3);
1395 host_client->sendsignon = true;
1399 ==================
1400 Host_Begin_f
1401 ==================
1403 void Host_Begin_f (void)
1405 if (cmd_source == src_command)
1407 Con_Printf ("begin is not valid from the console\n");
1408 return;
1411 host_client->spawned = true;
1414 //===========================================================================
1418 ==================
1419 Host_Kick_f
1421 Kicks a user off of the server
1422 ==================
1424 void Host_Kick_f (void)
1426 char *who;
1427 char *message = NULL;
1428 client_t *save;
1429 int i;
1430 qboolean byNumber = false;
1432 if (cmd_source == src_command)
1434 if (!sv.active)
1436 Cmd_ForwardToServer ();
1437 return;
1440 else if (pr_global_struct->deathmatch && !host_client->privileged)
1441 return;
1443 save = host_client;
1445 if (Cmd_Argc() > 2 && Q_strcmp(Cmd_Argv(1), "#") == 0)
1447 i = Q_atof(Cmd_Argv(2)) - 1;
1448 if (i < 0 || i >= svs.maxclients)
1449 return;
1450 if (!svs.clients[i].active)
1451 return;
1452 host_client = &svs.clients[i];
1453 byNumber = true;
1455 else
1457 for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
1459 if (!host_client->active)
1460 continue;
1461 if (Q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1462 break;
1466 if (i < svs.maxclients)
1468 if (cmd_source == src_command)
1469 if (cls.state == ca_dedicated)
1470 who = "Console";
1471 else
1472 who = cl_name.string;
1473 else
1474 who = save->name;
1476 // can't kick yourself!
1477 if (host_client == save)
1478 return;
1480 if (Cmd_Argc() > 2)
1482 message = COM_Parse(Cmd_Args());
1483 if (byNumber)
1485 message++; // skip the #
1486 while (*message == ' ') // skip white space
1487 message++;
1488 message += Q_strlen(Cmd_Argv(2)); // skip the number
1490 while (*message && *message == ' ')
1491 message++;
1493 if (message)
1494 SV_ClientPrintf ("Kicked by %s: %s\n", who, message);
1495 else
1496 SV_ClientPrintf ("Kicked by %s\n", who);
1497 SV_DropClient (false);
1500 host_client = save;
1504 ===============================================================================
1506 DEBUGGING TOOLS
1508 ===============================================================================
1512 ==================
1513 Host_Give_f
1514 ==================
1516 void Host_Give_f (void)
1518 char *t;
1519 int v;
1520 eval_t *val;
1522 if (cmd_source == src_command)
1524 Cmd_ForwardToServer ();
1525 return;
1528 if (pr_global_struct->deathmatch && !host_client->privileged)
1529 return;
1531 t = Cmd_Argv(1);
1532 v = atoi (Cmd_Argv(2));
1534 switch (t[0])
1536 case '0':
1537 case '1':
1538 case '2':
1539 case '3':
1540 case '4':
1541 case '5':
1542 case '6':
1543 case '7':
1544 case '8':
1545 case '9':
1546 // MED 01/04/97 added hipnotic give stuff
1547 if (hipnotic)
1549 if (t[0] == '6')
1551 if (t[1] == 'a')
1552 sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN;
1553 else
1554 sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER;
1556 else if (t[0] == '9')
1557 sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON;
1558 else if (t[0] == '0')
1559 sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR;
1560 else if (t[0] >= '2')
1561 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1563 else
1565 if (t[0] >= '2')
1566 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1568 break;
1570 case 's':
1571 if (rogue)
1573 val = GetEdictFieldValue(sv_player, "ammo_shells1");
1574 if (val)
1575 val->_float = v;
1578 sv_player->v.ammo_shells = v;
1579 break;
1580 case 'n':
1581 if (rogue)
1583 val = GetEdictFieldValue(sv_player, "ammo_nails1");
1584 if (val)
1586 val->_float = v;
1587 if (sv_player->v.weapon <= IT_LIGHTNING)
1588 sv_player->v.ammo_nails = v;
1591 else
1593 sv_player->v.ammo_nails = v;
1595 break;
1596 case 'l':
1597 if (rogue)
1599 val = GetEdictFieldValue(sv_player, "ammo_lava_nails");
1600 if (val)
1602 val->_float = v;
1603 if (sv_player->v.weapon > IT_LIGHTNING)
1604 sv_player->v.ammo_nails = v;
1607 break;
1608 case 'r':
1609 if (rogue)
1611 val = GetEdictFieldValue(sv_player, "ammo_rockets1");
1612 if (val)
1614 val->_float = v;
1615 if (sv_player->v.weapon <= IT_LIGHTNING)
1616 sv_player->v.ammo_rockets = v;
1619 else
1621 sv_player->v.ammo_rockets = v;
1623 break;
1624 case 'm':
1625 if (rogue)
1627 val = GetEdictFieldValue(sv_player, "ammo_multi_rockets");
1628 if (val)
1630 val->_float = v;
1631 if (sv_player->v.weapon > IT_LIGHTNING)
1632 sv_player->v.ammo_rockets = v;
1635 break;
1636 case 'h':
1637 sv_player->v.health = v;
1638 break;
1639 case 'c':
1640 if (rogue)
1642 val = GetEdictFieldValue(sv_player, "ammo_cells1");
1643 if (val)
1645 val->_float = v;
1646 if (sv_player->v.weapon <= IT_LIGHTNING)
1647 sv_player->v.ammo_cells = v;
1650 else
1652 sv_player->v.ammo_cells = v;
1654 break;
1655 case 'p':
1656 if (rogue)
1658 val = GetEdictFieldValue(sv_player, "ammo_plasma");
1659 if (val)
1661 val->_float = v;
1662 if (sv_player->v.weapon > IT_LIGHTNING)
1663 sv_player->v.ammo_cells = v;
1666 break;
1670 edict_t *FindViewthing (void)
1672 int i;
1673 edict_t *e;
1675 for (i=0 ; i<sv.num_edicts ; i++)
1677 e = EDICT_NUM(i);
1678 if ( !strcmp (pr_strings + e->v.classname, "viewthing") )
1679 return e;
1681 Con_Printf ("No viewthing on map\n");
1682 return NULL;
1686 ==================
1687 Host_Viewmodel_f
1688 ==================
1690 void Host_Viewmodel_f (void)
1692 edict_t *e;
1693 model_t *m;
1695 e = FindViewthing ();
1696 if (!e)
1697 return;
1699 m = Mod_ForName (Cmd_Argv(1), false);
1700 if (!m)
1702 Con_Printf ("Can't load %s\n", Cmd_Argv(1));
1703 return;
1706 e->v.frame = 0;
1707 cl.model_precache[(int)e->v.modelindex] = m;
1711 ==================
1712 Host_Viewframe_f
1713 ==================
1715 void Host_Viewframe_f (void)
1717 edict_t *e;
1718 int f;
1719 model_t *m;
1721 e = FindViewthing ();
1722 if (!e)
1723 return;
1724 m = cl.model_precache[(int)e->v.modelindex];
1726 f = atoi(Cmd_Argv(1));
1727 if (f >= m->numframes)
1728 f = m->numframes-1;
1730 e->v.frame = f;
1734 void PrintFrameName (model_t *m, int frame)
1736 aliashdr_t *hdr;
1737 maliasframedesc_t *pframedesc;
1739 hdr = (aliashdr_t *)Mod_Extradata (m);
1740 if (!hdr)
1741 return;
1742 pframedesc = &hdr->frames[frame];
1744 Con_Printf ("frame %i: %s\n", frame, pframedesc->name);
1748 ==================
1749 Host_Viewnext_f
1750 ==================
1752 void Host_Viewnext_f (void)
1754 edict_t *e;
1755 model_t *m;
1757 e = FindViewthing ();
1758 if (!e)
1759 return;
1760 m = cl.model_precache[(int)e->v.modelindex];
1762 e->v.frame = e->v.frame + 1;
1763 if (e->v.frame >= m->numframes)
1764 e->v.frame = m->numframes - 1;
1766 PrintFrameName (m, e->v.frame);
1770 ==================
1771 Host_Viewprev_f
1772 ==================
1774 void Host_Viewprev_f (void)
1776 edict_t *e;
1777 model_t *m;
1779 e = FindViewthing ();
1780 if (!e)
1781 return;
1783 m = cl.model_precache[(int)e->v.modelindex];
1785 e->v.frame = e->v.frame - 1;
1786 if (e->v.frame < 0)
1787 e->v.frame = 0;
1789 PrintFrameName (m, e->v.frame);
1793 ===============================================================================
1795 DEMO LOOP CONTROL
1797 ===============================================================================
1802 ==================
1803 Host_Startdemos_f
1804 ==================
1806 void Host_Startdemos_f (void)
1808 int i, c;
1810 if (cls.state == ca_dedicated)
1812 if (!sv.active)
1813 Cbuf_AddText ("map start\n");
1814 return;
1817 c = Cmd_Argc() - 1;
1818 if (c > MAX_DEMOS)
1820 Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS);
1821 c = MAX_DEMOS;
1823 Con_Printf ("%i demo(s) in loop\n", c);
1825 for (i=1 ; i<c+1 ; i++)
1826 strncpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0])-1);
1828 if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1830 cls.demonum = 0;
1831 CL_NextDemo ();
1833 else
1834 cls.demonum = -1;
1839 ==================
1840 Host_Demos_f
1842 Return to looping demos
1843 ==================
1845 void Host_Demos_f (void)
1847 if (cls.state == ca_dedicated)
1848 return;
1849 if (cls.demonum == -1)
1850 cls.demonum = 1;
1851 CL_Disconnect_f ();
1852 CL_NextDemo ();
1856 ==================
1857 Host_Stopdemo_f
1859 Return to looping demos
1860 ==================
1862 void Host_Stopdemo_f (void)
1864 if (cls.state == ca_dedicated)
1865 return;
1866 if (!cls.demoplayback)
1867 return;
1868 CL_StopPlayback ();
1869 CL_Disconnect ();
1872 //=============================================================================
1875 ==================
1876 Host_InitCommands
1877 ==================
1879 void Host_InitCommands (void)
1881 Cmd_AddCommand ("status", Host_Status_f);
1882 Cmd_AddCommand ("quit", Host_Quit_f);
1883 Cmd_AddCommand ("god", Host_God_f);
1884 Cmd_AddCommand ("notarget", Host_Notarget_f);
1885 Cmd_AddCommand ("fly", Host_Fly_f);
1886 Cmd_AddCommand ("map", Host_Map_f);
1887 Cmd_AddCommand ("restart", Host_Restart_f);
1888 Cmd_AddCommand ("changelevel", Host_Changelevel_f);
1889 #ifdef QUAKE2
1890 Cmd_AddCommand ("changelevel2", Host_Changelevel2_f);
1891 #endif
1892 Cmd_AddCommand ("connect", Host_Connect_f);
1893 Cmd_AddCommand ("reconnect", Host_Reconnect_f);
1894 Cmd_AddCommand ("name", Host_Name_f);
1895 Cmd_AddCommand ("noclip", Host_Noclip_f);
1896 Cmd_AddCommand ("version", Host_Version_f);
1897 #ifdef IDGODS
1898 Cmd_AddCommand ("please", Host_Please_f);
1899 #endif
1900 Cmd_AddCommand ("say", Host_Say_f);
1901 Cmd_AddCommand ("say_team", Host_Say_Team_f);
1902 Cmd_AddCommand ("tell", Host_Tell_f);
1903 Cmd_AddCommand ("color", Host_Color_f);
1904 Cmd_AddCommand ("kill", Host_Kill_f);
1905 Cmd_AddCommand ("pause", Host_Pause_f);
1906 Cmd_AddCommand ("spawn", Host_Spawn_f);
1907 Cmd_AddCommand ("begin", Host_Begin_f);
1908 Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
1909 Cmd_AddCommand ("kick", Host_Kick_f);
1910 Cmd_AddCommand ("ping", Host_Ping_f);
1911 Cmd_AddCommand ("load", Host_Loadgame_f);
1912 Cmd_AddCommand ("save", Host_Savegame_f);
1913 Cmd_AddCommand ("give", Host_Give_f);
1915 Cmd_AddCommand ("startdemos", Host_Startdemos_f);
1916 Cmd_AddCommand ("demos", Host_Demos_f);
1917 Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
1919 Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
1920 Cmd_AddCommand ("viewframe", Host_Viewframe_f);
1921 Cmd_AddCommand ("viewnext", Host_Viewnext_f);
1922 Cmd_AddCommand ("viewprev", Host_Viewprev_f);
1924 Cmd_AddCommand ("mcache", Mod_Print);