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