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