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.
23 extern cvar_t pausable;
27 void Mod_Print (void);
35 // LordHavoc: didn't like it asking me if I wanted to quit
36 //extern void M_Menu_Quit_f (void);
38 void Host_Quit_f (void)
41 if (key_dest != key_console && cls.state != ca_dedicated)
48 Host_ShutdownServer(false);
59 void Host_Status_f (void)
66 void (*print) (char *fmt, ...);
68 if (cmd_source == src_command)
72 Cmd_ForwardToServer ();
78 print = SV_ClientPrintf;
80 print ("host: %s\n", Cvar_VariableString ("hostname"));
81 print ("version: %4.2f\n", VERSION);
83 print ("tcp/ip: %s\n", my_tcpip_address);
85 print ("ipx: %s\n", my_ipx_address);
86 print ("map: %s\n", sv.name);
87 print ("players: %i active (%i max)\n\n", net_activeconnections, svs.maxclients);
88 for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
92 seconds = (int)(net_time - client->netconnection->connecttime);
93 minutes = seconds / 60;
96 seconds -= (minutes * 60);
99 minutes -= (hours * 60);
103 print ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->v.frags, hours, minutes, seconds);
104 print (" %s\n", client->netconnection->address);
113 Sets client to godmode
116 void Host_God_f (void)
118 if (cmd_source == src_command)
120 Cmd_ForwardToServer ();
124 if (pr_global_struct->deathmatch && !host_client->privileged)
127 sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
128 if (!((int)sv_player->v.flags & FL_GODMODE) )
129 SV_ClientPrintf ("godmode OFF\n");
131 SV_ClientPrintf ("godmode ON\n");
134 void Host_Notarget_f (void)
136 if (cmd_source == src_command)
138 Cmd_ForwardToServer ();
142 if (pr_global_struct->deathmatch && !host_client->privileged)
145 sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
146 if (!((int)sv_player->v.flags & FL_NOTARGET) )
147 SV_ClientPrintf ("notarget OFF\n");
149 SV_ClientPrintf ("notarget ON\n");
152 qboolean noclip_anglehack;
154 void Host_Noclip_f (void)
156 if (cmd_source == src_command)
158 Cmd_ForwardToServer ();
162 if (pr_global_struct->deathmatch && !host_client->privileged)
165 if (sv_player->v.movetype != MOVETYPE_NOCLIP)
167 noclip_anglehack = true;
168 sv_player->v.movetype = MOVETYPE_NOCLIP;
169 SV_ClientPrintf ("noclip ON\n");
173 noclip_anglehack = false;
174 sv_player->v.movetype = MOVETYPE_WALK;
175 SV_ClientPrintf ("noclip OFF\n");
183 Sets client to flymode
186 void Host_Fly_f (void)
188 if (cmd_source == src_command)
190 Cmd_ForwardToServer ();
194 if (pr_global_struct->deathmatch && !host_client->privileged)
197 if (sv_player->v.movetype != MOVETYPE_FLY)
199 sv_player->v.movetype = MOVETYPE_FLY;
200 SV_ClientPrintf ("flymode ON\n");
204 sv_player->v.movetype = MOVETYPE_WALK;
205 SV_ClientPrintf ("flymode OFF\n");
216 void Host_Ping_f (void)
222 if (cmd_source == src_command)
224 Cmd_ForwardToServer ();
228 SV_ClientPrintf ("Client ping times:\n");
229 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
234 for (j=0 ; j<NUM_PING_TIMES ; j++)
235 total+=client->ping_times[j];
236 total /= NUM_PING_TIMES;
237 SV_ClientPrintf ("%4i %s\n", (int)(total*1000), client->name);
242 ===============================================================================
246 ===============================================================================
251 ======================
256 command from the console. Active clients are kicked off.
257 ======================
259 void Host_Map_f (void)
262 char name[MAX_QPATH];
264 if (cmd_source != src_command)
267 cls.demonum = -1; // stop demo loop in case this fails
270 Host_ShutdownServer(false);
272 key_dest = key_game; // remove console or menu
273 SCR_BeginLoadingPlaque ();
275 cls.mapstring[0] = 0;
276 for (i=0 ; i<Cmd_Argc() ; i++)
278 strcat (cls.mapstring, Cmd_Argv(i));
279 strcat (cls.mapstring, " ");
281 strcat (cls.mapstring, "\n");
283 svs.serverflags = 0; // haven't completed an episode yet
284 strcpy (name, Cmd_Argv(1));
285 SV_SpawnServer (name);
289 if (cls.state != ca_dedicated)
291 strcpy (cls.spawnparms, "");
293 for (i=2 ; i<Cmd_Argc() ; i++)
295 strcat (cls.spawnparms, Cmd_Argv(i));
296 strcat (cls.spawnparms, " ");
299 Cmd_ExecuteString ("connect local", src_command);
307 Goes to a new map, taking all clients along
310 void Host_Changelevel_f (void)
312 char level[MAX_QPATH];
316 Con_Printf ("changelevel <levelname> : continue game on a new level\n");
319 if (!sv.active || cls.demoplayback)
321 Con_Printf ("Only the server may changelevel\n");
324 SV_SaveSpawnparms ();
325 strcpy (level, Cmd_Argv(1));
326 SV_SpawnServer (level);
333 Restarts the current server for a dead player
336 void Host_Restart_f (void)
338 char mapname[MAX_QPATH];
340 if (cls.demoplayback || !sv.active)
343 if (cmd_source != src_command)
345 strcpy (mapname, sv.name); // must copy out, because it gets cleared
347 SV_SpawnServer (mapname);
354 This command causes the client to wait for the signon messages again.
355 This is sent just before a server changes levels
358 void Host_Reconnect_f (void)
360 SCR_BeginLoadingPlaque ();
361 cls.signon = 0; // need new connection messages
365 =====================
368 User command to connect to server
369 =====================
371 void Host_Connect_f (void)
373 char name[MAX_QPATH];
375 cls.demonum = -1; // stop demo loop in case this fails
376 if (cls.demoplayback)
381 strcpy (name, Cmd_Argv(1));
382 CL_EstablishConnection (name);
388 ===============================================================================
392 ===============================================================================
395 #define SAVEGAME_VERSION 5
401 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
404 void Host_SavegameComment (char *text)
409 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
411 memcpy (text, cl.levelname, strlen(cl.levelname));
412 sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
413 memcpy (text+22, kills, strlen(kills));
414 // convert space to _ to make stdio happy
415 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
418 text[SAVEGAME_COMMENT_LENGTH] = '\0';
427 void Host_Savegame_f (void)
432 char comment[SAVEGAME_COMMENT_LENGTH+1];
434 if (cmd_source != src_command)
439 Con_Printf ("Not playing a local game.\n");
445 Con_Printf ("Can't save in intermission.\n");
449 if (svs.maxclients != 1)
451 Con_Printf ("Can't save multiplayer games.\n");
457 Con_Printf ("save <savename> : save a game\n");
461 if (strstr(Cmd_Argv(1), ".."))
463 Con_Printf ("Relative pathnames are not allowed.\n");
467 for (i=0 ; i<svs.maxclients ; i++)
469 if (svs.clients[i].active && (svs.clients[i].edict->v.health <= 0) )
471 Con_Printf ("Can't savegame with a dead player\n");
476 sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
477 COM_DefaultExtension (name, ".sav");
479 Con_Printf ("Saving game to %s...\n", name);
480 f = fopen (name, "w");
483 Con_Printf ("ERROR: couldn't open.\n");
487 fprintf (f, "%i\n", SAVEGAME_VERSION);
488 Host_SavegameComment (comment);
489 fprintf (f, "%s\n", comment);
490 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
491 fprintf (f, "%f\n", svs.clients->spawn_parms[i]);
492 fprintf (f, "%d\n", current_skill);
493 fprintf (f, "%s\n", sv.name);
494 fprintf (f, "%f\n",sv.time);
496 // write the light styles
498 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
500 if (sv.lightstyles[i])
501 fprintf (f, "%s\n", sv.lightstyles[i]);
508 for (i=0 ; i<sv.num_edicts ; i++)
510 ED_Write (f, EDICT_NUM(i));
514 Con_Printf ("done.\n");
523 void Host_Loadgame_f (void)
525 char name[MAX_OSPATH];
527 char mapname[MAX_QPATH];
529 char str[32768], *start;
534 float spawn_parms[NUM_SPAWN_PARMS];
536 if (cmd_source != src_command)
541 Con_Printf ("load <savename> : load a game\n");
545 cls.demonum = -1; // stop demo loop in case this fails
547 sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
548 COM_DefaultExtension (name, ".sav");
550 // we can't call SCR_BeginLoadingPlaque, because too much stack space has
551 // been used. The menu calls it before stuffing loadgame command
552 // SCR_BeginLoadingPlaque ();
554 Con_Printf ("Loading game from %s...\n", name);
555 f = fopen (name, "r");
558 Con_Printf ("ERROR: couldn't open.\n");
562 fscanf (f, "%i\n", &version);
563 if (version != SAVEGAME_VERSION)
566 Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
569 fscanf (f, "%s\n", str);
570 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
571 fscanf (f, "%f\n", &spawn_parms[i]);
572 // this silliness is so we can load 1.06 save files, which have float skill values
573 fscanf (f, "%f\n", &tfloat);
574 current_skill = (int)(tfloat + 0.1);
575 Cvar_SetValue ("skill", (float)current_skill);
577 fscanf (f, "%s\n",mapname);
578 fscanf (f, "%f\n",&time);
582 SV_SpawnServer (mapname);
585 Con_Printf ("Couldn't load map\n");
588 sv.paused = true; // pause until all clients connect
591 // load the light styles
593 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
595 fscanf (f, "%s\n", str);
596 sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
597 strcpy (sv.lightstyles[i], str);
600 // load the edicts out of the savegame file
601 entnum = -1; // -1 is the globals
604 for (i=0 ; i<sizeof(str)-1 ; i++)
616 if (i == sizeof(str)-1)
617 Sys_Error ("Loadgame buffer overflow");
620 start = COM_Parse(str);
622 break; // end of file
623 if (strcmp(com_token,"{"))
624 Sys_Error ("First token isn't a brace");
627 { // parse the global vars
628 ED_ParseGlobals (start);
633 ent = EDICT_NUM(entnum);
634 memset (&ent->v, 0, progs->entityfields * 4);
636 ED_ParseEdict (start, ent);
638 // link it into the bsp tree
640 SV_LinkEdict (ent, false);
646 sv.num_edicts = entnum;
651 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
652 svs.clients->spawn_parms[i] = spawn_parms[i];
654 if (cls.state != ca_dedicated)
656 CL_EstablishConnection ("local");
661 //============================================================================
664 ======================
666 ======================
668 void Host_Name_f (void)
672 if (Cmd_Argc () == 1)
674 Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
677 if (Cmd_Argc () == 2)
678 newName = Cmd_Argv(1);
680 newName = Cmd_Args();
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 %4.2f\n", VERSION);
710 Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
714 void Host_Please_f (void)
719 if (cmd_source != src_command)
722 if ((Cmd_Argc () == 3) && strcmp(Cmd_Argv(1), "#") == 0)
724 j = atof(Cmd_Argv(2)) - 1;
725 if (j < 0 || j >= svs.maxclients)
727 if (!svs.clients[j].active)
729 cl = &svs.clients[j];
732 cl->privileged = false;
733 cl->edict->v.flags = (int)cl->edict->v.flags & ~(FL_GODMODE|FL_NOTARGET);
734 cl->edict->v.movetype = MOVETYPE_WALK;
735 noclip_anglehack = false;
738 cl->privileged = true;
741 if (Cmd_Argc () != 2)
744 for (j=0, cl = svs.clients ; j<svs.maxclients ; j++, cl++)
748 if (strcasecmp(cl->name, Cmd_Argv(1)) == 0)
752 cl->privileged = false;
753 cl->edict->v.flags = (int)cl->edict->v.flags & ~(FL_GODMODE|FL_NOTARGET);
754 cl->edict->v.movetype = MOVETYPE_WALK;
755 noclip_anglehack = false;
758 cl->privileged = true;
766 void Host_Say(qboolean teamonly)
772 // LordHavoc: 256 char say messages
773 unsigned char text[256];
774 qboolean fromServer = false;
776 if (cmd_source == src_command)
778 if (cls.state == ca_dedicated)
785 Cmd_ForwardToServer ();
796 // remove quotes if present
803 // turn on color set 1
805 sprintf (text, "%c%s: ", 1, save->name);
807 sprintf (text, "%c<%s> ", 1, hostname.string);
809 j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator
816 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
818 if (!client || !client->active || !client->spawned)
820 if (teamplay.value && teamonly && client->edict->v.team != save->edict->v.team)
822 host_client = client;
823 SV_ClientPrintf("%s", text);
827 Sys_Printf("%s", &text[1]);
831 void Host_Say_f(void)
837 void Host_Say_Team_f(void)
843 void Host_Tell_f(void)
851 if (cmd_source == src_command)
853 Cmd_ForwardToServer ();
860 strcpy(text, host_client->name);
865 // remove quotes if present
872 // check length & truncate if necessary
873 j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator
881 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
883 if (!client->active || !client->spawned)
885 if (Q_strcasecmp(client->name, Cmd_Argv(1)))
887 host_client = client;
888 SV_ClientPrintf("%s", text);
900 void Host_Color_f(void)
907 Con_Printf ("\"color\" is \"%i %i\"\n", ((int)cl_color.value) >> 4, ((int)cl_color.value) & 0x0f);
908 Con_Printf ("color <0-13> [0-13]\n");
913 top = bottom = atoi(Cmd_Argv(1));
916 top = atoi(Cmd_Argv(1));
917 bottom = atoi(Cmd_Argv(2));
921 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
925 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
929 playercolor = top*16 + bottom;
931 if (cmd_source == src_command)
933 Cvar_SetValue ("_cl_color", playercolor);
934 if (cls.state == ca_connected)
935 Cmd_ForwardToServer ();
939 host_client->colors = playercolor;
940 host_client->edict->v.team = bottom + 1;
942 // send notification to all clients
943 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
944 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
945 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
953 void Host_Kill_f (void)
955 if (cmd_source == src_command)
957 Cmd_ForwardToServer ();
961 if (sv_player->v.health <= 0)
963 SV_ClientPrintf ("Can't suicide -- allready dead!\n");
967 pr_global_struct->time = sv.time;
968 pr_global_struct->self = EDICT_TO_PROG(sv_player);
969 PR_ExecuteProgram (pr_global_struct->ClientKill);
978 void Host_Pause_f (void)
981 if (cmd_source == src_command)
983 Cmd_ForwardToServer ();
987 SV_ClientPrintf ("Pause not allowed.\n");
994 SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v.netname);
998 SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v.netname);
1001 // send notification to all clients
1002 MSG_WriteByte (&sv.reliable_datagram, svc_setpause);
1003 MSG_WriteByte (&sv.reliable_datagram, sv.paused);
1007 //===========================================================================
1015 void Host_PreSpawn_f (void)
1017 if (cmd_source == src_command)
1019 Con_Printf ("prespawn is not valid from the console\n");
1023 if (host_client->spawned)
1025 Con_Printf ("prespawn not valid -- allready spawned\n");
1029 SZ_Write (&host_client->message, sv.signon.data, sv.signon.cursize);
1030 MSG_WriteByte (&host_client->message, svc_signonnum);
1031 MSG_WriteByte (&host_client->message, 2);
1032 host_client->sendsignon = true;
1035 dfunction_t *ED_FindFunction (char *name);
1042 void Host_Spawn_f (void)
1050 if (cmd_source == src_command)
1052 Con_Printf ("spawn is not valid from the console\n");
1056 if (host_client->spawned)
1058 Con_Printf ("Spawn not valid -- allready spawned\n");
1062 // run the entrance script
1064 { // loaded games are fully inited allready
1065 // if this is the last client to be connected, unpause
1068 if (f = ED_FindFunction ("RestoreGame"))
1069 if (RestoreGame = (func_t)(f - pr_functions))
1071 Con_DPrintf("Calling RestoreGame\n");
1072 pr_global_struct->time = sv.time;
1073 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1074 PR_ExecuteProgram (RestoreGame);
1081 ent = host_client->edict;
1083 memset (&ent->v, 0, progs->entityfields * 4);
1084 ent->v.colormap = NUM_FOR_EDICT(ent);
1085 ent->v.team = (host_client->colors & 15) + 1;
1086 ent->v.netname = host_client->name - pr_strings;
1087 if (val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel))
1088 val->_float = host_client->pmodel;
1090 // copy spawn parms out of the client_t
1092 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1093 (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
1095 // call the spawn function
1097 pr_global_struct->time = sv.time;
1098 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1099 PR_ExecuteProgram (pr_global_struct->ClientConnect);
1101 if ((Sys_FloatTime() - host_client->netconnection->connecttime) <= sv.time)
1102 Sys_Printf ("%s entered the game\n", host_client->name);
1104 PR_ExecuteProgram (pr_global_struct->PutClientInServer);
1108 // send all current names, colors, and frag counts
1109 SZ_Clear (&host_client->message);
1111 // send time of update
1112 MSG_WriteByte (&host_client->message, svc_time);
1113 MSG_WriteFloat (&host_client->message, sv.time);
1115 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
1117 MSG_WriteByte (&host_client->message, svc_updatename);
1118 MSG_WriteByte (&host_client->message, i);
1119 MSG_WriteString (&host_client->message, client->name);
1120 MSG_WriteByte (&host_client->message, svc_updatefrags);
1121 MSG_WriteByte (&host_client->message, i);
1122 MSG_WriteShort (&host_client->message, client->old_frags);
1123 MSG_WriteByte (&host_client->message, svc_updatecolors);
1124 MSG_WriteByte (&host_client->message, i);
1125 MSG_WriteByte (&host_client->message, client->colors);
1128 // send all current light styles
1129 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1131 MSG_WriteByte (&host_client->message, svc_lightstyle);
1132 MSG_WriteByte (&host_client->message, (char)i);
1133 MSG_WriteString (&host_client->message, sv.lightstyles[i]);
1139 MSG_WriteByte (&host_client->message, svc_updatestat);
1140 MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS);
1141 MSG_WriteLong (&host_client->message, pr_global_struct->total_secrets);
1143 MSG_WriteByte (&host_client->message, svc_updatestat);
1144 MSG_WriteByte (&host_client->message, STAT_TOTALMONSTERS);
1145 MSG_WriteLong (&host_client->message, pr_global_struct->total_monsters);
1147 MSG_WriteByte (&host_client->message, svc_updatestat);
1148 MSG_WriteByte (&host_client->message, STAT_SECRETS);
1149 MSG_WriteLong (&host_client->message, pr_global_struct->found_secrets);
1151 MSG_WriteByte (&host_client->message, svc_updatestat);
1152 MSG_WriteByte (&host_client->message, STAT_MONSTERS);
1153 MSG_WriteLong (&host_client->message, pr_global_struct->killed_monsters);
1157 // Never send a roll angle, because savegames can catch the server
1158 // in a state where it is expecting the client to correct the angle
1159 // and it won't happen if the game was just loaded, so you wind up
1160 // with a permanent head tilt
1161 ent = EDICT_NUM( 1 + (host_client - svs.clients) );
1162 MSG_WriteByte (&host_client->message, svc_setangle);
1163 for (i=0 ; i < 2 ; i++)
1164 MSG_WriteAngle (&host_client->message, ent->v.angles[i] );
1165 MSG_WriteAngle (&host_client->message, 0 );
1167 SV_WriteClientdataToMessage (sv_player, &host_client->message);
1169 MSG_WriteByte (&host_client->message, svc_signonnum);
1170 MSG_WriteByte (&host_client->message, 3);
1171 host_client->sendsignon = true;
1179 void Host_Begin_f (void)
1181 if (cmd_source == src_command)
1183 Con_Printf ("begin is not valid from the console\n");
1187 host_client->spawned = true;
1190 //===========================================================================
1197 Kicks a user off of the server
1200 void Host_Kick_f (void)
1203 char *message = NULL;
1206 qboolean byNumber = false;
1208 if (cmd_source == src_command)
1212 Cmd_ForwardToServer ();
1216 else if (pr_global_struct->deathmatch && !host_client->privileged)
1221 if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1223 i = atof(Cmd_Argv(2)) - 1;
1224 if (i < 0 || i >= svs.maxclients)
1226 if (!svs.clients[i].active)
1228 host_client = &svs.clients[i];
1233 for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
1235 if (!host_client->active)
1237 if (Q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1242 if (i < svs.maxclients)
1244 if (cmd_source == src_command)
1245 if (cls.state == ca_dedicated)
1248 who = cl_name.string;
1252 // can't kick yourself!
1253 if (host_client == save)
1258 message = COM_Parse(Cmd_Args());
1261 message++; // skip the #
1262 while (*message == ' ') // skip white space
1264 message += strlen(Cmd_Argv(2)); // skip the number
1266 while (*message && *message == ' ')
1270 SV_ClientPrintf ("Kicked by %s: %s\n", who, message);
1272 SV_ClientPrintf ("Kicked by %s\n", who);
1273 SV_DropClient (false);
1280 ===============================================================================
1284 ===============================================================================
1292 void Host_Give_f (void)
1298 if (cmd_source == src_command)
1300 Cmd_ForwardToServer ();
1304 if (pr_global_struct->deathmatch && !host_client->privileged)
1308 v = atoi (Cmd_Argv(2));
1322 // MED 01/04/97 added hipnotic give stuff
1328 sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN;
1330 sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER;
1332 else if (t[0] == '9')
1333 sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON;
1334 else if (t[0] == '0')
1335 sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR;
1336 else if (t[0] >= '2')
1337 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1342 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1349 if (val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1))
1353 sv_player->v.ammo_shells = v;
1358 if (val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1))
1361 if (sv_player->v.weapon <= IT_LIGHTNING)
1362 sv_player->v.ammo_nails = v;
1367 sv_player->v.ammo_nails = v;
1373 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_lava_nails);
1377 if (sv_player->v.weapon > IT_LIGHTNING)
1378 sv_player->v.ammo_nails = v;
1385 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_rockets1);
1389 if (sv_player->v.weapon <= IT_LIGHTNING)
1390 sv_player->v.ammo_rockets = v;
1395 sv_player->v.ammo_rockets = v;
1401 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_multi_rockets);
1405 if (sv_player->v.weapon > IT_LIGHTNING)
1406 sv_player->v.ammo_rockets = v;
1411 sv_player->v.health = v;
1416 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_cells1);
1420 if (sv_player->v.weapon <= IT_LIGHTNING)
1421 sv_player->v.ammo_cells = v;
1426 sv_player->v.ammo_cells = v;
1432 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_plasma);
1436 if (sv_player->v.weapon > IT_LIGHTNING)
1437 sv_player->v.ammo_cells = v;
1444 edict_t *FindViewthing (void)
1449 for (i=0 ; i<sv.num_edicts ; i++)
1452 if ( !strcmp (pr_strings + e->v.classname, "viewthing") )
1455 Con_Printf ("No viewthing on map\n");
1464 void Host_Viewmodel_f (void)
1469 e = FindViewthing ();
1473 m = Mod_ForName (Cmd_Argv(1), false);
1476 Con_Printf ("Can't load %s\n", Cmd_Argv(1));
1481 cl.model_precache[(int)e->v.modelindex] = m;
1489 void Host_Viewframe_f (void)
1495 e = FindViewthing ();
1498 m = cl.model_precache[(int)e->v.modelindex];
1500 f = atoi(Cmd_Argv(1));
1501 if (f >= m->numframes)
1508 void PrintFrameName (model_t *m, int frame)
1511 maliasframedesc_t *pframedesc;
1513 hdr = (aliashdr_t *)Mod_Extradata (m);
1516 pframedesc = &hdr->frames[frame];
1518 Con_Printf ("frame %i: %s\n", frame, pframedesc->name);
1526 void Host_Viewnext_f (void)
1531 e = FindViewthing ();
1534 m = cl.model_precache[(int)e->v.modelindex];
1536 e->v.frame = e->v.frame + 1;
1537 if (e->v.frame >= m->numframes)
1538 e->v.frame = m->numframes - 1;
1540 PrintFrameName (m, e->v.frame);
1548 void Host_Viewprev_f (void)
1553 e = FindViewthing ();
1557 m = cl.model_precache[(int)e->v.modelindex];
1559 e->v.frame = e->v.frame - 1;
1563 PrintFrameName (m, e->v.frame);
1567 ===============================================================================
1571 ===============================================================================
1580 void Host_Startdemos_f (void)
1584 if (cls.state == ca_dedicated)
1587 Cbuf_AddText ("map start\n");
1594 Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS);
1597 Con_Printf ("%i demo(s) in loop\n", c);
1599 for (i=1 ; i<c+1 ; i++)
1600 strncpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0])-1);
1602 if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1616 Return to looping demos
1619 void Host_Demos_f (void)
1621 if (cls.state == ca_dedicated)
1623 if (cls.demonum == -1)
1633 Return to looping demos
1636 void Host_Stopdemo_f (void)
1638 if (cls.state == ca_dedicated)
1640 if (!cls.demoplayback)
1646 //=============================================================================
1653 void Host_InitCommands (void)
1655 Cmd_AddCommand ("status", Host_Status_f);
1656 Cmd_AddCommand ("quit", Host_Quit_f);
1659 Cmd_AddCommand ("max", Host_God_f);
1660 Cmd_AddCommand ("monster", Host_Notarget_f);
1661 Cmd_AddCommand ("scrag", Host_Fly_f);
1662 Cmd_AddCommand ("wraith", Host_Noclip_f);
1663 Cmd_AddCommand ("gimme", Host_Give_f);
1667 Cmd_AddCommand ("god", Host_God_f);
1668 Cmd_AddCommand ("notarget", Host_Notarget_f);
1669 Cmd_AddCommand ("fly", Host_Fly_f);
1670 Cmd_AddCommand ("noclip", Host_Noclip_f);
1671 Cmd_AddCommand ("give", Host_Give_f);
1673 Cmd_AddCommand ("map", Host_Map_f);
1674 Cmd_AddCommand ("restart", Host_Restart_f);
1675 Cmd_AddCommand ("changelevel", Host_Changelevel_f);
1676 Cmd_AddCommand ("connect", Host_Connect_f);
1677 Cmd_AddCommand ("reconnect", Host_Reconnect_f);
1678 Cmd_AddCommand ("name", Host_Name_f);
1679 Cmd_AddCommand ("version", Host_Version_f);
1681 Cmd_AddCommand ("please", Host_Please_f);
1683 Cmd_AddCommand ("say", Host_Say_f);
1684 Cmd_AddCommand ("say_team", Host_Say_Team_f);
1685 Cmd_AddCommand ("tell", Host_Tell_f);
1686 Cmd_AddCommand ("color", Host_Color_f);
1687 Cmd_AddCommand ("kill", Host_Kill_f);
1688 Cmd_AddCommand ("pause", Host_Pause_f);
1689 Cmd_AddCommand ("spawn", Host_Spawn_f);
1690 Cmd_AddCommand ("begin", Host_Begin_f);
1691 Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
1692 Cmd_AddCommand ("kick", Host_Kick_f);
1693 Cmd_AddCommand ("ping", Host_Ping_f);
1694 Cmd_AddCommand ("load", Host_Loadgame_f);
1695 Cmd_AddCommand ("save", Host_Savegame_f);
1697 Cmd_AddCommand ("startdemos", Host_Startdemos_f);
1698 Cmd_AddCommand ("demos", Host_Demos_f);
1699 Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
1701 Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
1702 Cmd_AddCommand ("viewframe", Host_Viewframe_f);
1703 Cmd_AddCommand ("viewnext", Host_Viewnext_f);
1704 Cmd_AddCommand ("viewprev", Host_Viewprev_f);
1706 Cmd_AddCommand ("mcache", Mod_Print);