2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 char sv_spawnmap[MAX_QPATH];
25 char sv_loadgame[MAX_OSPATH];
27 mfunction_t *ED_FindFunction (char *name);
35 extern qboolean host_shuttingdown;
36 void Host_Quit_f (void)
38 host_shuttingdown = true;
40 Host_ShutdownServer(false);
51 void Host_Status_f (void)
54 int seconds, minutes, hours = 0, j, players;
55 void (*print) (const char *fmt, ...);
57 if (cmd_source == src_command)
61 Cmd_ForwardToServer ();
67 print = SV_ClientPrintf;
69 for (players = 0, j = 0;j < svs.maxclients;j++)
70 if (svs.clients[j].active)
72 print ("host: %s\n", Cvar_VariableString ("hostname"));
73 print ("version: %s build %s\n", gamename, buildstring);
74 print ("map: %s\n", sv.name);
75 print ("players: %i active (%i max)\n\n", players, svs.maxclients);
76 for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
80 seconds = (int)(realtime - client->netconnection->connecttime);
81 minutes = seconds / 60;
84 seconds -= (minutes * 60);
87 minutes -= (hours * 60);
91 print ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->v->frags, hours, minutes, seconds);
92 print (" %s\n", client->netconnection->address);
101 Sets client to godmode
104 void Host_God_f (void)
106 if (cmd_source == src_command)
108 Cmd_ForwardToServer ();
112 if (pr_global_struct->deathmatch)
115 sv_player->v->flags = (int)sv_player->v->flags ^ FL_GODMODE;
116 if (!((int)sv_player->v->flags & FL_GODMODE) )
117 SV_ClientPrintf ("godmode OFF\n");
119 SV_ClientPrintf ("godmode ON\n");
122 void Host_Notarget_f (void)
124 if (cmd_source == src_command)
126 Cmd_ForwardToServer ();
130 if (pr_global_struct->deathmatch)
133 sv_player->v->flags = (int)sv_player->v->flags ^ FL_NOTARGET;
134 if (!((int)sv_player->v->flags & FL_NOTARGET) )
135 SV_ClientPrintf ("notarget OFF\n");
137 SV_ClientPrintf ("notarget ON\n");
140 qboolean noclip_anglehack;
142 void Host_Noclip_f (void)
144 if (cmd_source == src_command)
146 Cmd_ForwardToServer ();
150 if (pr_global_struct->deathmatch)
153 if (sv_player->v->movetype != MOVETYPE_NOCLIP)
155 noclip_anglehack = true;
156 sv_player->v->movetype = MOVETYPE_NOCLIP;
157 SV_ClientPrintf ("noclip ON\n");
161 noclip_anglehack = false;
162 sv_player->v->movetype = MOVETYPE_WALK;
163 SV_ClientPrintf ("noclip OFF\n");
171 Sets client to flymode
174 void Host_Fly_f (void)
176 if (cmd_source == src_command)
178 Cmd_ForwardToServer ();
182 if (pr_global_struct->deathmatch)
185 if (sv_player->v->movetype != MOVETYPE_FLY)
187 sv_player->v->movetype = MOVETYPE_FLY;
188 SV_ClientPrintf ("flymode ON\n");
192 sv_player->v->movetype = MOVETYPE_WALK;
193 SV_ClientPrintf ("flymode OFF\n");
204 void Host_Ping_f (void)
210 if (cmd_source == src_command)
212 Cmd_ForwardToServer ();
216 SV_ClientPrintf ("Client ping times:\n");
217 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
222 for (j=0 ; j<NUM_PING_TIMES ; j++)
223 total+=client->ping_times[j];
224 total /= NUM_PING_TIMES;
225 SV_ClientPrintf ("%4i %s\n", (int)(total*1000), client->name);
230 ===============================================================================
234 ===============================================================================
238 ======================
243 command from the console. Active clients are kicked off.
244 ======================
246 void Host_Map_f (void)
248 if (cmd_source != src_command)
251 cls.demonum = -1; // stop demo loop in case this fails
253 SCR_BeginLoadingPlaque ();
256 Host_ShutdownServer(false);
258 key_dest = key_game; // remove console or menu
260 svs.serverflags = 0; // haven't completed an episode yet
261 strcpy (sv_spawnmap, Cmd_Argv(1));
268 Goes to a new map, taking all clients along
271 void Host_Changelevel_f (void)
275 Con_Printf ("changelevel <levelname> : continue game on a new level\n");
278 if (!sv.active || cls.demoplayback)
280 Con_Printf ("Only the server may changelevel\n");
283 SV_SaveSpawnparms ();
284 strcpy (sv_spawnmap, Cmd_Argv(1));
291 Restarts the current server for a dead player
294 void Host_Restart_f (void)
296 if (cls.demoplayback || !sv.active)
299 if (cmd_source != src_command)
301 strcpy (sv_spawnmap, sv.name);
308 This command causes the client to wait for the signon messages again.
309 This is sent just before a server changes levels
312 void Host_Reconnect_f (void)
314 SCR_BeginLoadingPlaque();
315 cls.signon = 0; // need new connection messages
319 =====================
322 User command to connect to server
323 =====================
325 void Host_Connect_f (void)
327 CL_EstablishConnection(Cmd_Argv(1));
332 ===============================================================================
336 ===============================================================================
339 #define SAVEGAME_VERSION 5
345 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
348 void Host_SavegameComment (char *text)
353 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
355 memcpy (text, cl.levelname, strlen(cl.levelname));
356 sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
357 memcpy (text+22, kills, strlen(kills));
358 // convert space to _ to make stdio happy
359 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
362 text[SAVEGAME_COMMENT_LENGTH] = '\0';
371 void Host_Savegame_f (void)
376 char comment[SAVEGAME_COMMENT_LENGTH+1];
378 if (cmd_source != src_command)
383 Con_Printf ("Not playing a local game.\n");
389 Con_Printf ("Can't save in intermission.\n");
393 if (svs.maxclients != 1)
395 Con_Printf ("Can't save multiplayer games.\n");
401 Con_Printf ("save <savename> : save a game\n");
405 if (strstr(Cmd_Argv(1), ".."))
407 Con_Printf ("Relative pathnames are not allowed.\n");
411 for (i=0 ; i<svs.maxclients ; i++)
413 if (svs.clients[i].active && (svs.clients[i].edict->v->health <= 0) )
415 Con_Printf ("Can't savegame with a dead player\n");
420 strncpy (name, Cmd_Argv(1), sizeof (name) - 1);
421 name[sizeof (name) - 1] = '\0';
422 FS_DefaultExtension (name, ".sav");
424 Con_Printf ("Saving game to %s...\n", name);
425 f = FS_Open (name, "w", false);
428 Con_Printf ("ERROR: couldn't open.\n");
432 FS_Printf (f, "%i\n", SAVEGAME_VERSION);
433 Host_SavegameComment (comment);
434 FS_Printf (f, "%s\n", comment);
435 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
436 FS_Printf (f, "%f\n", svs.clients->spawn_parms[i]);
437 FS_Printf (f, "%d\n", current_skill);
438 FS_Printf (f, "%s\n", sv.name);
439 FS_Printf (f, "%f\n",sv.time);
441 // write the light styles
443 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
445 if (sv.lightstyles[i])
446 FS_Printf (f, "%s\n", sv.lightstyles[i]);
453 for (i=0 ; i<sv.num_edicts ; i++)
455 ED_Write (f, EDICT_NUM(i));
459 Con_Printf ("done.\n");
463 extern mempool_t *edictstring_mempool;
470 void Host_Loadgame_f (void)
472 if (cmd_source != src_command)
477 Con_Printf ("load <savename> : load a game\n");
481 strcpy (sv_loadgame, Cmd_Argv(1));
482 FS_DefaultExtension (sv_loadgame, ".sav");
484 Con_Printf ("Loading game from %s...\n", sv_loadgame);
487 void Host_PerformLoadGame(char *name)
490 char mapname[MAX_QPATH];
499 float spawn_parms[NUM_SPAWN_PARMS];
501 cls.demonum = -1; // stop demo loop in case this fails
503 f = FS_Open (name, "r", false);
506 Con_Printf ("ERROR: couldn't open.\n");
510 str = FS_Getline (f);
511 sscanf (str, "%i\n", &version);
512 if (version != SAVEGAME_VERSION)
515 Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
519 SCR_BeginLoadingPlaque ();
521 str = FS_Getline (f);
522 for (i = 0;i < NUM_SPAWN_PARMS;i++)
524 str = FS_Getline (f);
525 sscanf (str, "%f\n", &spawn_parms[i]);
527 // this silliness is so we can load 1.06 save files, which have float skill values
528 str = FS_Getline (f);
529 sscanf (str, "%f\n", &tfloat);
530 current_skill = (int)(tfloat + 0.1);
531 Cvar_SetValue ("skill", (float)current_skill);
533 strcpy (mapname, FS_Getline (f));
535 str = FS_Getline (f);
536 sscanf (str, "%f\n",&time);
538 SV_SpawnServer (mapname);
541 Con_Printf ("Couldn't load map\n");
544 sv.paused = true; // pause until all clients connect
547 // load the light styles
549 for (i = 0;i < MAX_LIGHTSTYLES;i++)
551 str = FS_Getline (f);
552 sv.lightstyles[i] = Mem_Alloc(edictstring_mempool, strlen(str)+1);
553 strcpy (sv.lightstyles[i], str);
556 // load the edicts out of the savegame file
561 for (i = 0;i < (int)sizeof(buf) - 1;i++)
573 if (i == sizeof(buf)-1)
574 Host_Error ("Loadgame buffer overflow");
577 if (!COM_ParseToken(&start))
582 if (strcmp(com_token,"{"))
583 Host_Error ("First token isn't a brace");
587 // parse the global vars
588 ED_ParseGlobals (start);
593 if (entnum >= MAX_EDICTS)
594 Host_Error("Host_PerformLoadGame: too many edicts in save file (reached MAX_EDICTS %i)\n", MAX_EDICTS);
595 while (entnum >= sv.max_edicts)
597 ent = EDICT_NUM(entnum);
598 memset (ent->v, 0, progs->entityfields * 4);
599 ent->e->free = false;
600 ED_ParseEdict (start, ent);
602 // link it into the bsp tree
604 SV_LinkEdict (ent, false);
610 sv.num_edicts = entnum;
615 for (i = 0;i < NUM_SPAWN_PARMS;i++)
616 svs.clients->spawn_parms[i] = spawn_parms[i];
618 // make sure we're connected to loopback
619 if (cls.state == ca_disconnected || !(cls.state == ca_connected && cls.netcon != NULL && LHNETADDRESS_GetAddressType(&cls.netcon->peeraddress) == LHNETADDRESSTYPE_LOOP))
620 CL_EstablishConnection("local");
623 //============================================================================
626 ======================
628 ======================
630 cvar_t cl_name = {CVAR_SAVE, "_cl_name", "player"};
631 void Host_Name_f (void)
633 char newName[sizeof(host_client->name)];
635 if (Cmd_Argc () == 1)
637 Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
641 if (Cmd_Argc () == 2)
642 strncpy(newName, Cmd_Argv(1), sizeof(host_client->name) - 1);
644 strncpy(newName, Cmd_Args(), sizeof(host_client->name) - 1);
645 newName[sizeof(host_client->name) - 1] = 0;
647 if (cmd_source == src_command)
649 if (strcmp(cl_name.string, newName) == 0)
651 Cvar_Set ("_cl_name", newName);
652 if (cls.state == ca_connected)
653 Cmd_ForwardToServer ();
657 if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
658 if (strcmp(host_client->name, newName) != 0)
659 Con_Printf ("%s renamed to %s\n", host_client->name, newName);
660 strcpy (host_client->name, newName);
661 strcpy (host_client->old_name, newName);
662 sv_player->v->netname = PR_SetString(host_client->name);
664 // send notification to all clients
666 MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
667 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
668 MSG_WriteString (&sv.reliable_datagram, host_client->name);
672 void Host_Version_f (void)
674 Con_Printf ("Version: %s build %s\n", gamename, buildstring);
677 void Host_Say(qboolean teamonly)
683 // LordHavoc: 256 char say messages
684 unsigned char text[256];
685 qboolean fromServer = false;
687 if (cmd_source == src_command)
689 if (cls.state == ca_dedicated)
696 Cmd_ForwardToServer ();
704 // turn on color set 1
706 sprintf (text, "%c%s: ", 1, host_client->name);
708 sprintf (text, "%c<%s> ", 1, hostname.string);
713 p2 = p1 + strlen(p1);
714 // remove trailing newlines
715 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
717 // remove quotes if present
724 Con_Printf("Host_Say: missing end quote\n");
726 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
728 for (j = strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;)
733 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
735 if (!client || !client->active || !client->spawned)
737 if (teamplay.integer && teamonly && client->edict->v->team != save->edict->v->team)
739 host_client = client;
740 SV_ClientPrintf("%s", text);
744 Sys_Printf("%s", &text[1]);
748 void Host_Say_f(void)
754 void Host_Say_Team_f(void)
760 void Host_Tell_f(void)
766 char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
767 qboolean fromServer = false;
769 if (cmd_source == src_command)
771 if (cls.state == ca_dedicated)
775 Cmd_ForwardToServer ();
784 sprintf (text, "%s: ", host_client->name);
786 sprintf (text, "<%s> ", hostname.string);
789 p2 = p1 + strlen(p1);
790 // remove the target name
791 while (p1 < p2 && *p1 != ' ')
793 while (p1 < p2 && *p1 == ' ')
795 // remove trailing newlines
796 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
798 // remove quotes if present
805 Con_Printf("Host_Say: missing end quote\n");
807 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
809 for (j = strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;)
815 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
817 if (!client->active || !client->spawned)
819 if (strcasecmp(client->name, Cmd_Argv(1)))
821 host_client = client;
822 SV_ClientPrintf("%s", text);
834 cvar_t cl_color = {CVAR_SAVE, "_cl_color", "0"};
835 void Host_Color_f(void)
840 func_t SV_ChangeTeam;
844 Con_Printf ("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15);
845 Con_Printf ("color <0-15> [0-15]\n");
850 top = bottom = atoi(Cmd_Argv(1));
853 top = atoi(Cmd_Argv(1));
854 bottom = atoi(Cmd_Argv(2));
858 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
862 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
866 playercolor = top*16 + bottom;
868 if (cmd_source == src_command)
870 Cvar_SetValue ("_cl_color", playercolor);
871 if (cls.state == ca_connected)
872 Cmd_ForwardToServer ();
876 if ((f = ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - pr_functions)))
878 Con_DPrintf("Calling SV_ChangeTeam\n");
879 pr_global_struct->time = sv.time;
880 pr_globals[OFS_PARM0] = playercolor;
881 pr_global_struct->self = EDICT_TO_PROG(sv_player);
882 PR_ExecuteProgram (SV_ChangeTeam, "");
887 if ((val = GETEDICTFIELDVALUE(sv_player, eval_clientcolors)))
888 val->_float = playercolor;
889 host_client->colors = playercolor;
890 host_client->old_colors = playercolor;
891 sv_player->v->team = bottom + 1;
893 // send notification to all clients
894 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
895 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
896 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
905 void Host_Kill_f (void)
907 if (cmd_source == src_command)
909 Cmd_ForwardToServer ();
913 if (sv_player->v->health <= 0)
915 SV_ClientPrintf ("Can't suicide -- already dead!\n");
919 pr_global_struct->time = sv.time;
920 pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
921 PR_ExecuteProgram (pr_global_struct->ClientKill, "QC function ClientKill is missing");
930 void Host_Pause_f (void)
933 if (cmd_source == src_command)
935 Cmd_ForwardToServer ();
938 if (!pausable.integer)
939 SV_ClientPrintf ("Pause not allowed.\n");
946 SV_BroadcastPrintf ("%s paused the game\n", PR_GetString(sv_player->v->netname));
950 SV_BroadcastPrintf ("%s unpaused the game\n", PR_GetString(sv_player->v->netname));
953 // send notification to all clients
954 MSG_WriteByte (&sv.reliable_datagram, svc_setpause);
955 MSG_WriteByte (&sv.reliable_datagram, sv.paused);
960 ======================
962 LordHavoc: only supported for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
963 ======================
965 cvar_t cl_pmodel = {CVAR_SAVE, "_cl_pmodel", "0"};
966 static void Host_PModel_f (void)
971 if (Cmd_Argc () == 1)
973 Con_Printf ("\"pmodel\" is \"%s\"\n", cl_pmodel.string);
976 i = atoi(Cmd_Argv(1));
978 if (cmd_source == src_command)
980 if (cl_pmodel.integer == i)
982 Cvar_SetValue ("_cl_pmodel", i);
983 if (cls.state == ca_connected)
984 Cmd_ForwardToServer ();
988 host_client->pmodel = i;
989 if ((val = GETEDICTFIELDVALUE(sv_player, eval_pmodel)))
993 //===========================================================================
1001 void Host_PreSpawn_f (void)
1003 if (cmd_source == src_command)
1005 Con_Printf ("prespawn is not valid from the console\n");
1009 if (host_client->spawned)
1011 Con_Printf ("prespawn not valid -- already spawned\n");
1015 SZ_Write (&host_client->message, sv.signon.data, sv.signon.cursize);
1016 MSG_WriteByte (&host_client->message, svc_signonnum);
1017 MSG_WriteByte (&host_client->message, 2);
1018 host_client->sendsignon = true;
1026 void Host_Spawn_f (void)
1034 if (cmd_source == src_command)
1036 Con_Printf ("spawn is not valid from the console\n");
1040 if (host_client->spawned)
1042 Con_Printf ("Spawn not valid -- already spawned\n");
1046 // LordHavoc: moved this above the QC calls at FrikaC's request
1047 // send all current names, colors, and frag counts
1048 SZ_Clear (&host_client->message);
1052 // run the entrance script
1055 // loaded games are fully initialized already
1056 // if this is the last client to be connected, unpause
1059 if ((f = ED_FindFunction ("RestoreGame")))
1060 if ((RestoreGame = (func_t)(f - pr_functions)))
1062 Con_DPrintf("Calling RestoreGame\n");
1063 pr_global_struct->time = sv.time;
1064 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1065 PR_ExecuteProgram (RestoreGame, "");
1070 // copy spawn parms out of the client_t
1071 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1072 (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
1074 // call the spawn function
1075 pr_global_struct->time = sv.time;
1076 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1077 PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
1079 if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= sv.time)
1080 Sys_Printf ("%s entered the game\n", host_client->name);
1082 PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing");
1086 // send time of update
1087 MSG_WriteByte (&host_client->message, svc_time);
1088 MSG_WriteFloat (&host_client->message, sv.time);
1090 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
1092 MSG_WriteByte (&host_client->message, svc_updatename);
1093 MSG_WriteByte (&host_client->message, i);
1094 MSG_WriteString (&host_client->message, client->old_name);
1095 MSG_WriteByte (&host_client->message, svc_updatefrags);
1096 MSG_WriteByte (&host_client->message, i);
1097 MSG_WriteShort (&host_client->message, client->old_frags);
1098 MSG_WriteByte (&host_client->message, svc_updatecolors);
1099 MSG_WriteByte (&host_client->message, i);
1100 MSG_WriteByte (&host_client->message, client->old_colors);
1103 // send all current light styles
1104 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1106 MSG_WriteByte (&host_client->message, svc_lightstyle);
1107 MSG_WriteByte (&host_client->message, (char)i);
1108 MSG_WriteString (&host_client->message, sv.lightstyles[i]);
1112 MSG_WriteByte (&host_client->message, svc_updatestat);
1113 MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS);
1114 MSG_WriteLong (&host_client->message, pr_global_struct->total_secrets);
1116 MSG_WriteByte (&host_client->message, svc_updatestat);
1117 MSG_WriteByte (&host_client->message, STAT_TOTALMONSTERS);
1118 MSG_WriteLong (&host_client->message, pr_global_struct->total_monsters);
1120 MSG_WriteByte (&host_client->message, svc_updatestat);
1121 MSG_WriteByte (&host_client->message, STAT_SECRETS);
1122 MSG_WriteLong (&host_client->message, pr_global_struct->found_secrets);
1124 MSG_WriteByte (&host_client->message, svc_updatestat);
1125 MSG_WriteByte (&host_client->message, STAT_MONSTERS);
1126 MSG_WriteLong (&host_client->message, pr_global_struct->killed_monsters);
1129 // Never send a roll angle, because savegames can catch the server
1130 // in a state where it is expecting the client to correct the angle
1131 // and it won't happen if the game was just loaded, so you wind up
1132 // with a permanent head tilt
1133 MSG_WriteByte (&host_client->message, svc_setangle);
1134 for (i=0 ; i < 2 ; i++)
1135 MSG_WriteAngle (&host_client->message, ent->v->angles[i] );
1136 MSG_WriteAngle (&host_client->message, 0 );
1138 SV_WriteClientdataToMessage (sv_player, &host_client->message);
1140 MSG_WriteByte (&host_client->message, svc_signonnum);
1141 MSG_WriteByte (&host_client->message, 3);
1142 host_client->sendsignon = true;
1150 void Host_Begin_f (void)
1152 if (cmd_source == src_command)
1154 Con_Printf ("begin is not valid from the console\n");
1158 host_client->spawned = true;
1161 //===========================================================================
1168 Kicks a user off of the server
1171 void Host_Kick_f (void)
1174 const char *message = NULL;
1177 qboolean byNumber = false;
1179 if (cmd_source == src_command)
1183 Cmd_ForwardToServer ();
1187 else if (pr_global_struct->deathmatch)
1192 if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1194 i = atof(Cmd_Argv(2)) - 1;
1195 if (i < 0 || i >= svs.maxclients)
1197 if (!svs.clients[i].active)
1199 host_client = &svs.clients[i];
1204 for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
1206 if (!host_client->active)
1208 if (strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1213 if (i < svs.maxclients)
1215 if (cmd_source == src_command)
1217 if (cls.state == ca_dedicated)
1220 who = cl_name.string;
1225 // can't kick yourself!
1226 if (host_client == save)
1231 message = Cmd_Args();
1232 COM_ParseToken(&message);
1235 message++; // skip the #
1236 while (*message == ' ') // skip white space
1238 message += strlen(Cmd_Argv(2)); // skip the number
1240 while (*message && *message == ' ')
1244 SV_ClientPrintf ("Kicked by %s: %s\n", who, message);
1246 SV_ClientPrintf ("Kicked by %s\n", who);
1247 SV_DropClient (false); // kicked
1254 ===============================================================================
1258 ===============================================================================
1266 void Host_Give_f (void)
1272 if (cmd_source == src_command)
1274 Cmd_ForwardToServer ();
1278 if (pr_global_struct->deathmatch)
1282 v = atoi (Cmd_Argv(2));
1296 // MED 01/04/97 added hipnotic give stuff
1297 if (gamemode == GAME_HIPNOTIC)
1302 sv_player->v->items = (int)sv_player->v->items | HIT_PROXIMITY_GUN;
1304 sv_player->v->items = (int)sv_player->v->items | IT_GRENADE_LAUNCHER;
1306 else if (t[0] == '9')
1307 sv_player->v->items = (int)sv_player->v->items | HIT_LASER_CANNON;
1308 else if (t[0] == '0')
1309 sv_player->v->items = (int)sv_player->v->items | HIT_MJOLNIR;
1310 else if (t[0] >= '2')
1311 sv_player->v->items = (int)sv_player->v->items | (IT_SHOTGUN << (t[0] - '2'));
1316 sv_player->v->items = (int)sv_player->v->items | (IT_SHOTGUN << (t[0] - '2'));
1321 if (gamemode == GAME_ROGUE)
1323 if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1)))
1327 sv_player->v->ammo_shells = v;
1330 if (gamemode == GAME_ROGUE)
1332 if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1)))
1335 if (sv_player->v->weapon <= IT_LIGHTNING)
1336 sv_player->v->ammo_nails = v;
1341 sv_player->v->ammo_nails = v;
1345 if (gamemode == GAME_ROGUE)
1347 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_lava_nails);
1351 if (sv_player->v->weapon > IT_LIGHTNING)
1352 sv_player->v->ammo_nails = v;
1357 if (gamemode == GAME_ROGUE)
1359 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_rockets1);
1363 if (sv_player->v->weapon <= IT_LIGHTNING)
1364 sv_player->v->ammo_rockets = v;
1369 sv_player->v->ammo_rockets = v;
1373 if (gamemode == GAME_ROGUE)
1375 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_multi_rockets);
1379 if (sv_player->v->weapon > IT_LIGHTNING)
1380 sv_player->v->ammo_rockets = v;
1385 sv_player->v->health = v;
1388 if (gamemode == GAME_ROGUE)
1390 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_cells1);
1394 if (sv_player->v->weapon <= IT_LIGHTNING)
1395 sv_player->v->ammo_cells = v;
1400 sv_player->v->ammo_cells = v;
1404 if (gamemode == GAME_ROGUE)
1406 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_plasma);
1410 if (sv_player->v->weapon > IT_LIGHTNING)
1411 sv_player->v->ammo_cells = v;
1418 edict_t *FindViewthing (void)
1423 for (i=0 ; i<sv.num_edicts ; i++)
1426 if (!strcmp (PR_GetString(e->v->classname), "viewthing"))
1429 Con_Printf ("No viewthing on map\n");
1438 void Host_Viewmodel_f (void)
1443 e = FindViewthing ();
1447 m = Mod_ForName (Cmd_Argv(1), false, true, false);
1450 Con_Printf ("Can't load %s\n", Cmd_Argv(1));
1455 cl.model_precache[(int)e->v->modelindex] = m;
1463 void Host_Viewframe_f (void)
1469 e = FindViewthing ();
1472 m = cl.model_precache[(int)e->v->modelindex];
1474 f = atoi(Cmd_Argv(1));
1475 if (f >= m->numframes)
1482 void PrintFrameName (model_t *m, int frame)
1485 Con_Printf("frame %i: %s\n", frame, m->animscenes[frame].name);
1487 Con_Printf("frame %i\n", frame);
1495 void Host_Viewnext_f (void)
1500 e = FindViewthing ();
1503 m = cl.model_precache[(int)e->v->modelindex];
1505 e->v->frame = e->v->frame + 1;
1506 if (e->v->frame >= m->numframes)
1507 e->v->frame = m->numframes - 1;
1509 PrintFrameName (m, e->v->frame);
1517 void Host_Viewprev_f (void)
1522 e = FindViewthing ();
1526 m = cl.model_precache[(int)e->v->modelindex];
1528 e->v->frame = e->v->frame - 1;
1529 if (e->v->frame < 0)
1532 PrintFrameName (m, e->v->frame);
1536 ===============================================================================
1540 ===============================================================================
1549 void Host_Startdemos_f (void)
1553 if (cls.state == ca_dedicated)
1555 if (!sv.active && !sv_spawnmap[0])
1557 if (gamemode == GAME_TRANSFUSION)
1558 Cbuf_AddText ("map bb1\n");
1560 Cbuf_AddText ("map start\n");
1568 Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS);
1571 Con_DPrintf ("%i demo(s) in loop\n", c);
1573 for (i=1 ; i<c+1 ; i++)
1574 strncpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0])-1);
1576 // LordHavoc: clear the remaining slots
1577 for (;i <= MAX_DEMOS;i++)
1578 cls.demos[i-1][0] = 0;
1580 if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1594 Return to looping demos
1597 void Host_Demos_f (void)
1599 if (cls.state == ca_dedicated)
1601 if (cls.demonum == -1)
1611 Return to looping demos
1614 void Host_Stopdemo_f (void)
1616 if (!cls.demoplayback)
1621 // LordHavoc: because we don't want to load things before the video starts,
1622 // we have to delay map and game loads until AFTER video is initialized
1623 void Host_PerformSpawnServerAndLoadGame(void)
1625 if (vid_hidden && cls.state != ca_dedicated)
1628 Host_PerformLoadGame(sv_loadgame);
1629 else if (sv_spawnmap[0])
1630 SV_SpawnServer(sv_spawnmap);
1633 if (sv.active && cls.state == ca_disconnected)
1634 Cmd_ExecuteString ("connect local", src_command);
1637 //=============================================================================
1644 void Host_InitCommands (void)
1646 Cmd_AddCommand ("status", Host_Status_f);
1647 Cmd_AddCommand ("quit", Host_Quit_f);
1648 if (gamemode == GAME_NEHAHRA)
1650 Cmd_AddCommand ("max", Host_God_f);
1651 Cmd_AddCommand ("monster", Host_Notarget_f);
1652 Cmd_AddCommand ("scrag", Host_Fly_f);
1653 Cmd_AddCommand ("wraith", Host_Noclip_f);
1654 Cmd_AddCommand ("gimme", Host_Give_f);
1658 Cmd_AddCommand ("god", Host_God_f);
1659 Cmd_AddCommand ("notarget", Host_Notarget_f);
1660 Cmd_AddCommand ("fly", Host_Fly_f);
1661 Cmd_AddCommand ("noclip", Host_Noclip_f);
1662 Cmd_AddCommand ("give", Host_Give_f);
1664 Cmd_AddCommand ("map", Host_Map_f);
1665 Cmd_AddCommand ("restart", Host_Restart_f);
1666 Cmd_AddCommand ("changelevel", Host_Changelevel_f);
1667 Cmd_AddCommand ("connect", Host_Connect_f);
1668 Cmd_AddCommand ("reconnect", Host_Reconnect_f);
1669 Cmd_AddCommand ("version", Host_Version_f);
1670 Cmd_AddCommand ("say", Host_Say_f);
1671 Cmd_AddCommand ("say_team", Host_Say_Team_f);
1672 Cmd_AddCommand ("tell", Host_Tell_f);
1673 Cmd_AddCommand ("kill", Host_Kill_f);
1674 Cmd_AddCommand ("pause", Host_Pause_f);
1675 Cmd_AddCommand ("kick", Host_Kick_f);
1676 Cmd_AddCommand ("ping", Host_Ping_f);
1677 Cmd_AddCommand ("load", Host_Loadgame_f);
1678 Cmd_AddCommand ("save", Host_Savegame_f);
1680 Cmd_AddCommand ("startdemos", Host_Startdemos_f);
1681 Cmd_AddCommand ("demos", Host_Demos_f);
1682 Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
1684 Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
1685 Cmd_AddCommand ("viewframe", Host_Viewframe_f);
1686 Cmd_AddCommand ("viewnext", Host_Viewnext_f);
1687 Cmd_AddCommand ("viewprev", Host_Viewprev_f);
1689 Cvar_RegisterVariable (&cl_name);
1690 Cmd_AddCommand ("name", Host_Name_f);
1691 Cvar_RegisterVariable (&cl_color);
1692 Cmd_AddCommand ("color", Host_Color_f);
1693 if (gamemode == GAME_NEHAHRA)
1695 Cvar_RegisterVariable (&cl_pmodel);
1696 Cmd_AddCommand ("pmodel", Host_PModel_f);
1698 Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
1699 Cmd_AddCommand ("spawn", Host_Spawn_f);
1700 Cmd_AddCommand ("begin", Host_Begin_f);