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.
25 dfunction_t *ED_FindFunction (char *name);
33 extern qboolean host_shuttingdown;
34 void Host_Quit_f (void)
36 host_shuttingdown = true;
38 Host_ShutdownServer(false);
49 void Host_Status_f (void)
52 int seconds, minutes, hours = 0, j;
53 void (*print) (const char *fmt, ...);
55 if (cmd_source == src_command)
59 Cmd_ForwardToServer ();
65 print = SV_ClientPrintf;
67 print ("host: %s\n", Cvar_VariableString ("hostname"));
68 print ("version: %s build %s\n", gamename, buildstring);
70 print ("tcp/ip: %s\n", my_tcpip_address);
72 print ("ipx: %s\n", my_ipx_address);
73 print ("map: %s\n", sv.name);
74 print ("players: %i active (%i max)\n\n", net_activeconnections, svs.maxclients);
75 for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
79 seconds = (int)(net_time - client->netconnection->connecttime);
80 minutes = seconds / 60;
83 seconds -= (minutes * 60);
86 minutes -= (hours * 60);
90 print ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->v.frags, hours, minutes, seconds);
91 print (" %s\n", client->netconnection->address);
100 Sets client to godmode
103 void Host_God_f (void)
105 if (cmd_source == src_command)
107 Cmd_ForwardToServer ();
111 if (pr_global_struct->deathmatch)
114 sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
115 if (!((int)sv_player->v.flags & FL_GODMODE) )
116 SV_ClientPrintf ("godmode OFF\n");
118 SV_ClientPrintf ("godmode ON\n");
121 void Host_Notarget_f (void)
123 if (cmd_source == src_command)
125 Cmd_ForwardToServer ();
129 if (pr_global_struct->deathmatch)
132 sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
133 if (!((int)sv_player->v.flags & FL_NOTARGET) )
134 SV_ClientPrintf ("notarget OFF\n");
136 SV_ClientPrintf ("notarget ON\n");
139 qboolean noclip_anglehack;
141 void Host_Noclip_f (void)
143 if (cmd_source == src_command)
145 Cmd_ForwardToServer ();
149 if (pr_global_struct->deathmatch)
152 if (sv_player->v.movetype != MOVETYPE_NOCLIP)
154 noclip_anglehack = true;
155 sv_player->v.movetype = MOVETYPE_NOCLIP;
156 SV_ClientPrintf ("noclip ON\n");
160 noclip_anglehack = false;
161 sv_player->v.movetype = MOVETYPE_WALK;
162 SV_ClientPrintf ("noclip OFF\n");
170 Sets client to flymode
173 void Host_Fly_f (void)
175 if (cmd_source == src_command)
177 Cmd_ForwardToServer ();
181 if (pr_global_struct->deathmatch)
184 if (sv_player->v.movetype != MOVETYPE_FLY)
186 sv_player->v.movetype = MOVETYPE_FLY;
187 SV_ClientPrintf ("flymode ON\n");
191 sv_player->v.movetype = MOVETYPE_WALK;
192 SV_ClientPrintf ("flymode OFF\n");
203 void Host_Ping_f (void)
209 if (cmd_source == src_command)
211 Cmd_ForwardToServer ();
215 SV_ClientPrintf ("Client ping times:\n");
216 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
221 for (j=0 ; j<NUM_PING_TIMES ; j++)
222 total+=client->ping_times[j];
223 total /= NUM_PING_TIMES;
224 SV_ClientPrintf ("%4i %s\n", (int)(total*1000), client->name);
229 ===============================================================================
233 ===============================================================================
238 ======================
243 command from the console. Active clients are kicked off.
244 ======================
246 void Host_Map_f (void)
249 char name[MAX_QPATH];
251 if (cmd_source != src_command)
254 cls.demonum = -1; // stop demo loop in case this fails
256 SCR_BeginLoadingPlaque ();
259 Host_ShutdownServer(false);
261 key_dest = key_game; // remove console or menu
263 cls.mapstring[0] = 0;
264 for (i=0 ; i<Cmd_Argc() ; i++)
266 strcat (cls.mapstring, Cmd_Argv(i));
267 strcat (cls.mapstring, " ");
269 strcat (cls.mapstring, "\n");
271 svs.serverflags = 0; // haven't completed an episode yet
272 strcpy (name, Cmd_Argv(1));
273 SV_SpawnServer (name);
277 if (cls.state != ca_dedicated)
280 strcpy (cls.spawnparms, "");
282 for (i=2 ; i<Cmd_Argc() ; i++)
284 strcat (cls.spawnparms, Cmd_Argv(i));
285 strcat (cls.spawnparms, " ");
288 Cmd_ExecuteString ("connect local", src_command);
296 Goes to a new map, taking all clients along
299 void Host_Changelevel_f (void)
301 char level[MAX_QPATH];
305 Con_Printf ("changelevel <levelname> : continue game on a new level\n");
308 if (!sv.active || cls.demoplayback)
310 Con_Printf ("Only the server may changelevel\n");
313 SV_SaveSpawnparms ();
314 strcpy (level, Cmd_Argv(1));
315 SV_SpawnServer (level);
322 Restarts the current server for a dead player
325 void Host_Restart_f (void)
327 char mapname[MAX_QPATH];
329 if (cls.demoplayback || !sv.active)
332 if (cmd_source != src_command)
334 strcpy (mapname, sv.name); // must copy out, because it gets cleared
336 SV_SpawnServer (mapname);
343 This command causes the client to wait for the signon messages again.
344 This is sent just before a server changes levels
347 void Host_Reconnect_f (void)
349 SCR_BeginLoadingPlaque ();
350 cls.signon = 0; // need new connection messages
354 =====================
357 User command to connect to server
358 =====================
360 void Host_Connect_f (void)
362 char name[MAX_QPATH];
364 cls.demonum = -1; // stop demo loop in case this fails
365 if (cls.demoplayback)
367 strcpy (name, Cmd_Argv(1));
368 CL_EstablishConnection (name);
374 ===============================================================================
378 ===============================================================================
381 #define SAVEGAME_VERSION 5
387 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
390 void Host_SavegameComment (char *text)
395 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
397 memcpy (text, cl.levelname, strlen(cl.levelname));
398 sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
399 memcpy (text+22, kills, strlen(kills));
400 // convert space to _ to make stdio happy
401 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
404 text[SAVEGAME_COMMENT_LENGTH] = '\0';
413 void Host_Savegame_f (void)
418 char comment[SAVEGAME_COMMENT_LENGTH+1];
420 if (cmd_source != src_command)
425 Con_Printf ("Not playing a local game.\n");
431 Con_Printf ("Can't save in intermission.\n");
435 if (svs.maxclients != 1)
437 Con_Printf ("Can't save multiplayer games.\n");
443 Con_Printf ("save <savename> : save a game\n");
447 if (strstr(Cmd_Argv(1), ".."))
449 Con_Printf ("Relative pathnames are not allowed.\n");
453 for (i=0 ; i<svs.maxclients ; i++)
455 if (svs.clients[i].active && (svs.clients[i].edict->v.health <= 0) )
457 Con_Printf ("Can't savegame with a dead player\n");
462 sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
463 COM_DefaultExtension (name, ".sav");
465 Con_Printf ("Saving game to %s...\n", name);
466 f = Qopen (name, "w");
469 Con_Printf ("ERROR: couldn't open.\n");
473 Qprintf (f, "%i\n", SAVEGAME_VERSION);
474 Host_SavegameComment (comment);
475 Qprintf (f, "%s\n", comment);
476 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
477 Qprintf (f, "%f\n", svs.clients->spawn_parms[i]);
478 Qprintf (f, "%d\n", current_skill);
479 Qprintf (f, "%s\n", sv.name);
480 Qprintf (f, "%f\n",sv.time);
482 // write the light styles
484 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
486 if (sv.lightstyles[i])
487 Qprintf (f, "%s\n", sv.lightstyles[i]);
494 for (i=0 ; i<sv.num_edicts ; i++)
496 ED_Write (f, EDICT_NUM(i));
500 Con_Printf ("done.\n");
504 extern mempool_t *edictstring_mempool;
511 void Host_Loadgame_f (void)
513 char name[MAX_OSPATH];
515 char mapname[MAX_QPATH];
524 float spawn_parms[NUM_SPAWN_PARMS];
526 if (cmd_source != src_command)
531 Con_Printf ("load <savename> : load a game\n");
535 cls.demonum = -1; // stop demo loop in case this fails
537 sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
538 COM_DefaultExtension (name, ".sav");
540 Con_Printf ("Loading game from %s...\n", name);
541 f = Qopen (name, "rz");
544 Con_Printf ("ERROR: couldn't open.\n");
549 sscanf (str, "%i\n", &version);
550 if (version != SAVEGAME_VERSION)
553 Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
557 SCR_BeginLoadingPlaque ();
560 for (i=0 ; i<NUM_SPAWN_PARMS ; i++) {
562 sscanf (str, "%f\n", &spawn_parms[i]);
564 // this silliness is so we can load 1.06 save files, which have float skill values
566 sscanf (str, "%f\n", &tfloat);
567 current_skill = (int)(tfloat + 0.1);
568 Cvar_SetValue ("skill", (float)current_skill);
570 strcpy (mapname, Qgetline (f));
573 sscanf (str, "%f\n",&time);
577 SV_SpawnServer (mapname);
580 Con_Printf ("Couldn't load map\n");
583 sv.paused = true; // pause until all clients connect
586 // load the light styles
588 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
591 sv.lightstyles[i] = Mem_Alloc(edictstring_mempool, strlen(str)+1);
592 strcpy (sv.lightstyles[i], str);
595 // load the edicts out of the savegame file
600 for (i=0 ; i<sizeof(buf)-1 ; i++)
612 if (i == sizeof(buf)-1)
613 Host_Error ("Loadgame buffer overflow");
616 if (!COM_ParseToken(&start))
621 if (strcmp(com_token,"{"))
622 Host_Error ("First token isn't a brace");
626 // parse the global vars
627 ED_ParseGlobals (start);
632 ent = EDICT_NUM(entnum);
633 memset (&ent->v, 0, progs->entityfields * 4);
635 ED_ParseEdict (start, ent);
637 // link it into the bsp tree
639 SV_LinkEdict (ent, false);
645 sv.num_edicts = entnum;
650 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
651 svs.clients->spawn_parms[i] = spawn_parms[i];
653 if (cls.state != ca_dedicated)
655 CL_EstablishConnection ("local");
660 //============================================================================
663 ======================
665 ======================
667 void Host_Name_f (void)
671 if (Cmd_Argc () == 1)
673 Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
677 if (Cmd_Argc () == 2)
678 strncpy(newName, Cmd_Argv(1), 15);
680 strncpy(newName, Cmd_Args(), 15);
683 if (cmd_source == src_command)
685 if (strcmp(cl_name.string, newName) == 0)
687 Cvar_Set ("_cl_name", newName);
688 if (cls.state == ca_connected)
689 Cmd_ForwardToServer ();
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;
699 // send notification to all clients
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);
707 void Host_Version_f (void)
709 Con_Printf ("Version: %s build %s\n", gamename, buildstring);
712 void Host_Say(qboolean teamonly)
718 // LordHavoc: 256 char say messages
719 unsigned char text[256];
720 qboolean fromServer = false;
722 if (cmd_source == src_command)
724 if (cls.state == ca_dedicated)
731 Cmd_ForwardToServer ();
739 // turn on color set 1
741 sprintf (text, "%c%s: ", 1, host_client->name);
743 sprintf (text, "%c<%s> ", 1, hostname.string);
748 p2 = p1 + strlen(p1);
749 // remove trailing newlines
750 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
752 // remove quotes if present
759 Con_Printf("Host_Say: missing end quote\n");
761 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
763 for (j = strlen(text);j < (sizeof(text) - 2) && p1 < p2;)
768 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
770 if (!client || !client->active || !client->spawned)
772 if (teamplay.integer && teamonly && client->edict->v.team != save->edict->v.team)
774 host_client = client;
775 SV_ClientPrintf("%s", text);
779 Sys_Printf("%s", &text[1]);
783 void Host_Say_f(void)
789 void Host_Say_Team_f(void)
795 void Host_Tell_f(void)
801 char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
802 qboolean fromServer = false;
804 if (cmd_source == src_command)
806 if (cls.state == ca_dedicated)
810 Cmd_ForwardToServer ();
819 sprintf (text, "%s: ", host_client->name);
821 sprintf (text, "<%s> ", hostname.string);
824 p2 = p1 + strlen(p1);
825 // remove the target name
826 while (p1 < p2 && *p1 != ' ')
828 while (p1 < p2 && *p1 == ' ')
830 // remove trailing newlines
831 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
833 // remove quotes if present
840 Con_Printf("Host_Say: missing end quote\n");
842 while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
844 for (j = strlen(text);j < (sizeof(text) - 2) && p1 < p2;)
850 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
852 if (!client->active || !client->spawned)
854 if (Q_strcasecmp(client->name, Cmd_Argv(1)))
856 host_client = client;
857 SV_ClientPrintf("%s", text);
869 void Host_Color_f(void)
874 func_t SV_ChangeTeam;
878 Con_Printf ("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15);
879 Con_Printf ("color <0-15> [0-15]\n");
884 top = bottom = atoi(Cmd_Argv(1));
887 top = atoi(Cmd_Argv(1));
888 bottom = atoi(Cmd_Argv(2));
892 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
896 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
900 playercolor = top*16 + bottom;
902 if (cmd_source == src_command)
904 Cvar_SetValue ("_cl_color", playercolor);
905 if (cls.state == ca_connected)
906 Cmd_ForwardToServer ();
910 if ((f = ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - pr_functions)))
912 Con_DPrintf("Calling SV_ChangeTeam\n");
913 pr_global_struct->time = sv.time;
914 pr_globals[OFS_PARM0] = playercolor;
915 pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
916 PR_ExecuteProgram (SV_ChangeTeam, "");
920 host_client->colors = playercolor;
921 host_client->edict->v.team = bottom + 1;
923 // send notification to all clients
924 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
925 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
926 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
935 void Host_Kill_f (void)
937 if (cmd_source == src_command)
939 Cmd_ForwardToServer ();
943 if (sv_player->v.health <= 0)
945 SV_ClientPrintf ("Can't suicide -- already dead!\n");
949 pr_global_struct->time = sv.time;
950 pr_global_struct->self = EDICT_TO_PROG(sv_player);
951 PR_ExecuteProgram (pr_global_struct->ClientKill, "QC function ClientKill is missing");
960 void Host_Pause_f (void)
963 if (cmd_source == src_command)
965 Cmd_ForwardToServer ();
968 if (!pausable.integer)
969 SV_ClientPrintf ("Pause not allowed.\n");
976 SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v.netname);
980 SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v.netname);
983 // send notification to all clients
984 MSG_WriteByte (&sv.reliable_datagram, svc_setpause);
985 MSG_WriteByte (&sv.reliable_datagram, sv.paused);
989 //===========================================================================
997 void Host_PreSpawn_f (void)
999 if (cmd_source == src_command)
1001 Con_Printf ("prespawn is not valid from the console\n");
1005 if (host_client->spawned)
1007 Con_Printf ("prespawn not valid -- already spawned\n");
1011 SZ_Write (&host_client->message, sv.signon.data, sv.signon.cursize);
1012 MSG_WriteByte (&host_client->message, svc_signonnum);
1013 MSG_WriteByte (&host_client->message, 2);
1014 host_client->sendsignon = true;
1022 void Host_Spawn_f (void)
1030 if (cmd_source == src_command)
1032 Con_Printf ("spawn is not valid from the console\n");
1036 if (host_client->spawned)
1038 Con_Printf ("Spawn not valid -- already spawned\n");
1042 // LordHavoc: moved this above the QC calls at FrikaC's request
1043 // send all current names, colors, and frag counts
1044 SZ_Clear (&host_client->message);
1046 // run the entrance script
1049 // loaded games are fully initialized already
1050 // if this is the last client to be connected, unpause
1053 if ((f = ED_FindFunction ("RestoreGame")))
1054 if ((RestoreGame = (func_t)(f - pr_functions)))
1056 Con_DPrintf("Calling RestoreGame\n");
1057 pr_global_struct->time = sv.time;
1058 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1059 PR_ExecuteProgram (RestoreGame, "");
1066 ent = host_client->edict;
1068 memset (&ent->v, 0, progs->entityfields * 4);
1069 ent->v.colormap = NUM_FOR_EDICT(ent);
1070 ent->v.team = (host_client->colors & 15) + 1;
1071 ent->v.netname = host_client->name - pr_strings;
1072 if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1073 val->_float = host_client->pmodel;
1075 // copy spawn parms out of the client_t
1077 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1078 (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
1080 // call the spawn function
1082 pr_global_struct->time = sv.time;
1083 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1084 PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
1086 if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= sv.time)
1087 Sys_Printf ("%s entered the game\n", host_client->name);
1089 PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing");
1093 // send time of update
1094 MSG_WriteByte (&host_client->message, svc_time);
1095 MSG_WriteFloat (&host_client->message, sv.time);
1097 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
1099 MSG_WriteByte (&host_client->message, svc_updatename);
1100 MSG_WriteByte (&host_client->message, i);
1101 MSG_WriteString (&host_client->message, client->name);
1102 MSG_WriteByte (&host_client->message, svc_updatefrags);
1103 MSG_WriteByte (&host_client->message, i);
1104 MSG_WriteShort (&host_client->message, client->old_frags);
1105 MSG_WriteByte (&host_client->message, svc_updatecolors);
1106 MSG_WriteByte (&host_client->message, i);
1107 MSG_WriteByte (&host_client->message, client->colors);
1110 // send all current light styles
1111 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1113 MSG_WriteByte (&host_client->message, svc_lightstyle);
1114 MSG_WriteByte (&host_client->message, (char)i);
1115 MSG_WriteString (&host_client->message, sv.lightstyles[i]);
1121 MSG_WriteByte (&host_client->message, svc_updatestat);
1122 MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS);
1123 MSG_WriteLong (&host_client->message, pr_global_struct->total_secrets);
1125 MSG_WriteByte (&host_client->message, svc_updatestat);
1126 MSG_WriteByte (&host_client->message, STAT_TOTALMONSTERS);
1127 MSG_WriteLong (&host_client->message, pr_global_struct->total_monsters);
1129 MSG_WriteByte (&host_client->message, svc_updatestat);
1130 MSG_WriteByte (&host_client->message, STAT_SECRETS);
1131 MSG_WriteLong (&host_client->message, pr_global_struct->found_secrets);
1133 MSG_WriteByte (&host_client->message, svc_updatestat);
1134 MSG_WriteByte (&host_client->message, STAT_MONSTERS);
1135 MSG_WriteLong (&host_client->message, pr_global_struct->killed_monsters);
1138 // Never send a roll angle, because savegames can catch the server
1139 // in a state where it is expecting the client to correct the angle
1140 // and it won't happen if the game was just loaded, so you wind up
1141 // with a permanent head tilt
1142 ent = EDICT_NUM( 1 + (host_client - svs.clients) );
1143 MSG_WriteByte (&host_client->message, svc_setangle);
1144 for (i=0 ; i < 2 ; i++)
1145 MSG_WriteAngle (&host_client->message, ent->v.angles[i] );
1146 MSG_WriteAngle (&host_client->message, 0 );
1148 SV_WriteClientdataToMessage (sv_player, &host_client->message);
1150 MSG_WriteByte (&host_client->message, svc_signonnum);
1151 MSG_WriteByte (&host_client->message, 3);
1152 host_client->sendsignon = true;
1160 void Host_Begin_f (void)
1162 if (cmd_source == src_command)
1164 Con_Printf ("begin is not valid from the console\n");
1168 host_client->spawned = true;
1171 //===========================================================================
1178 Kicks a user off of the server
1181 void Host_Kick_f (void)
1184 const char *message = NULL;
1187 qboolean byNumber = false;
1189 if (cmd_source == src_command)
1193 Cmd_ForwardToServer ();
1197 else if (pr_global_struct->deathmatch)
1202 if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1204 i = atof(Cmd_Argv(2)) - 1;
1205 if (i < 0 || i >= svs.maxclients)
1207 if (!svs.clients[i].active)
1209 host_client = &svs.clients[i];
1214 for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
1216 if (!host_client->active)
1218 if (Q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1223 if (i < svs.maxclients)
1225 if (cmd_source == src_command)
1227 if (cls.state == ca_dedicated)
1230 who = cl_name.string;
1235 // can't kick yourself!
1236 if (host_client == save)
1241 message = Cmd_Args();
1242 COM_ParseToken(&message);
1245 message++; // skip the #
1246 while (*message == ' ') // skip white space
1248 message += strlen(Cmd_Argv(2)); // skip the number
1250 while (*message && *message == ' ')
1254 SV_ClientPrintf ("Kicked by %s: %s\n", who, message);
1256 SV_ClientPrintf ("Kicked by %s\n", who);
1257 SV_DropClient (false);
1264 ===============================================================================
1268 ===============================================================================
1276 void Host_Give_f (void)
1282 if (cmd_source == src_command)
1284 Cmd_ForwardToServer ();
1288 if (pr_global_struct->deathmatch)
1292 v = atoi (Cmd_Argv(2));
1306 // MED 01/04/97 added hipnotic give stuff
1307 if (gamemode == GAME_HIPNOTIC)
1312 sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN;
1314 sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER;
1316 else if (t[0] == '9')
1317 sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON;
1318 else if (t[0] == '0')
1319 sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR;
1320 else if (t[0] >= '2')
1321 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1326 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1331 if (gamemode == GAME_ROGUE)
1333 if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1)))
1337 sv_player->v.ammo_shells = v;
1340 if (gamemode == GAME_ROGUE)
1342 if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1)))
1345 if (sv_player->v.weapon <= IT_LIGHTNING)
1346 sv_player->v.ammo_nails = v;
1351 sv_player->v.ammo_nails = v;
1355 if (gamemode == GAME_ROGUE)
1357 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_lava_nails);
1361 if (sv_player->v.weapon > IT_LIGHTNING)
1362 sv_player->v.ammo_nails = v;
1367 if (gamemode == GAME_ROGUE)
1369 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_rockets1);
1373 if (sv_player->v.weapon <= IT_LIGHTNING)
1374 sv_player->v.ammo_rockets = v;
1379 sv_player->v.ammo_rockets = v;
1383 if (gamemode == GAME_ROGUE)
1385 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_multi_rockets);
1389 if (sv_player->v.weapon > IT_LIGHTNING)
1390 sv_player->v.ammo_rockets = v;
1395 sv_player->v.health = v;
1398 if (gamemode == GAME_ROGUE)
1400 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_cells1);
1404 if (sv_player->v.weapon <= IT_LIGHTNING)
1405 sv_player->v.ammo_cells = v;
1410 sv_player->v.ammo_cells = v;
1414 if (gamemode == GAME_ROGUE)
1416 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_plasma);
1420 if (sv_player->v.weapon > IT_LIGHTNING)
1421 sv_player->v.ammo_cells = v;
1428 edict_t *FindViewthing (void)
1433 for (i=0 ; i<sv.num_edicts ; i++)
1436 if ( !strcmp (pr_strings + e->v.classname, "viewthing") )
1439 Con_Printf ("No viewthing on map\n");
1448 void Host_Viewmodel_f (void)
1453 e = FindViewthing ();
1457 m = Mod_ForName (Cmd_Argv(1), false, true, false);
1460 Con_Printf ("Can't load %s\n", Cmd_Argv(1));
1465 cl.model_precache[(int)e->v.modelindex] = m;
1473 void Host_Viewframe_f (void)
1479 e = FindViewthing ();
1482 m = cl.model_precache[(int)e->v.modelindex];
1484 f = atoi(Cmd_Argv(1));
1485 if (f >= m->numframes)
1492 void PrintFrameName (model_t *m, int frame)
1495 Con_Printf("frame %i: %s\n", frame, m->animscenes[frame].name);
1497 Con_Printf("frame %i\n", frame);
1505 void Host_Viewnext_f (void)
1510 e = FindViewthing ();
1513 m = cl.model_precache[(int)e->v.modelindex];
1515 e->v.frame = e->v.frame + 1;
1516 if (e->v.frame >= m->numframes)
1517 e->v.frame = m->numframes - 1;
1519 PrintFrameName (m, e->v.frame);
1527 void Host_Viewprev_f (void)
1532 e = FindViewthing ();
1536 m = cl.model_precache[(int)e->v.modelindex];
1538 e->v.frame = e->v.frame - 1;
1542 PrintFrameName (m, e->v.frame);
1546 ===============================================================================
1550 ===============================================================================
1559 void Host_Startdemos_f (void)
1563 if (cls.state == ca_dedicated)
1566 Cbuf_AddText ("map start\n");
1573 Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS);
1576 Con_Printf ("%i demo(s) in loop\n", c);
1578 for (i=1 ; i<c+1 ; i++)
1579 strncpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0])-1);
1581 if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1595 Return to looping demos
1598 void Host_Demos_f (void)
1600 if (cls.state == ca_dedicated)
1602 if (cls.demonum == -1)
1612 Return to looping demos
1615 void Host_Stopdemo_f (void)
1617 if (!cls.demoplayback)
1622 //=============================================================================
1629 void Host_InitCommands (void)
1631 Cmd_AddCommand ("status", Host_Status_f);
1632 Cmd_AddCommand ("quit", Host_Quit_f);
1633 if (gamemode == GAME_NEHAHRA)
1635 Cmd_AddCommand ("max", Host_God_f);
1636 Cmd_AddCommand ("monster", Host_Notarget_f);
1637 Cmd_AddCommand ("scrag", Host_Fly_f);
1638 Cmd_AddCommand ("wraith", Host_Noclip_f);
1639 Cmd_AddCommand ("gimme", Host_Give_f);
1643 Cmd_AddCommand ("god", Host_God_f);
1644 Cmd_AddCommand ("notarget", Host_Notarget_f);
1645 Cmd_AddCommand ("fly", Host_Fly_f);
1646 Cmd_AddCommand ("noclip", Host_Noclip_f);
1647 Cmd_AddCommand ("give", Host_Give_f);
1649 Cmd_AddCommand ("map", Host_Map_f);
1650 Cmd_AddCommand ("restart", Host_Restart_f);
1651 Cmd_AddCommand ("changelevel", Host_Changelevel_f);
1652 Cmd_AddCommand ("connect", Host_Connect_f);
1653 Cmd_AddCommand ("reconnect", Host_Reconnect_f);
1654 Cmd_AddCommand ("name", Host_Name_f);
1655 Cmd_AddCommand ("version", Host_Version_f);
1656 Cmd_AddCommand ("say", Host_Say_f);
1657 Cmd_AddCommand ("say_team", Host_Say_Team_f);
1658 Cmd_AddCommand ("tell", Host_Tell_f);
1659 Cmd_AddCommand ("color", Host_Color_f);
1660 Cmd_AddCommand ("kill", Host_Kill_f);
1661 Cmd_AddCommand ("pause", Host_Pause_f);
1662 Cmd_AddCommand ("spawn", Host_Spawn_f);
1663 Cmd_AddCommand ("begin", Host_Begin_f);
1664 Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
1665 Cmd_AddCommand ("kick", Host_Kick_f);
1666 Cmd_AddCommand ("ping", Host_Ping_f);
1667 Cmd_AddCommand ("load", Host_Loadgame_f);
1668 Cmd_AddCommand ("save", Host_Savegame_f);
1670 Cmd_AddCommand ("startdemos", Host_Startdemos_f);
1671 Cmd_AddCommand ("demos", Host_Demos_f);
1672 Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
1674 Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
1675 Cmd_AddCommand ("viewframe", Host_Viewframe_f);
1676 Cmd_AddCommand ("viewnext", Host_Viewnext_f);
1677 Cmd_AddCommand ("viewprev", Host_Viewprev_f);