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 extern void M_Menu_Quit_f (void);
37 void Host_Quit_f (void)
39 if (key_dest != key_console && cls.state != ca_dedicated)
45 Host_ShutdownServer(false);
56 void Host_Status_f (void)
63 void (*print) (char *fmt, ...);
65 if (cmd_source == src_command)
69 Cmd_ForwardToServer ();
75 print = SV_ClientPrintf;
77 print ("host: %s\n", Cvar_VariableString ("hostname"));
78 print ("version: %4.2f\n", VERSION);
80 print ("tcp/ip: %s\n", my_tcpip_address);
82 print ("ipx: %s\n", my_ipx_address);
83 print ("map: %s\n", sv.name);
84 print ("players: %i active (%i max)\n\n", net_activeconnections, svs.maxclients);
85 for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
89 seconds = (int)(net_time - client->netconnection->connecttime);
90 minutes = seconds / 60;
93 seconds -= (minutes * 60);
96 minutes -= (hours * 60);
100 print ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->v.frags, hours, minutes, seconds);
101 print (" %s\n", client->netconnection->address);
110 Sets client to godmode
113 void Host_God_f (void)
115 if (cmd_source == src_command)
117 Cmd_ForwardToServer ();
121 if (pr_global_struct->deathmatch && !host_client->privileged)
124 sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
125 if (!((int)sv_player->v.flags & FL_GODMODE) )
126 SV_ClientPrintf ("godmode OFF\n");
128 SV_ClientPrintf ("godmode ON\n");
131 void Host_Notarget_f (void)
133 if (cmd_source == src_command)
135 Cmd_ForwardToServer ();
139 if (pr_global_struct->deathmatch && !host_client->privileged)
142 sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
143 if (!((int)sv_player->v.flags & FL_NOTARGET) )
144 SV_ClientPrintf ("notarget OFF\n");
146 SV_ClientPrintf ("notarget ON\n");
149 qboolean noclip_anglehack;
151 void Host_Noclip_f (void)
153 if (cmd_source == src_command)
155 Cmd_ForwardToServer ();
159 if (pr_global_struct->deathmatch && !host_client->privileged)
162 if (sv_player->v.movetype != MOVETYPE_NOCLIP)
164 noclip_anglehack = true;
165 sv_player->v.movetype = MOVETYPE_NOCLIP;
166 SV_ClientPrintf ("noclip ON\n");
170 noclip_anglehack = false;
171 sv_player->v.movetype = MOVETYPE_WALK;
172 SV_ClientPrintf ("noclip OFF\n");
180 Sets client to flymode
183 void Host_Fly_f (void)
185 if (cmd_source == src_command)
187 Cmd_ForwardToServer ();
191 if (pr_global_struct->deathmatch && !host_client->privileged)
194 if (sv_player->v.movetype != MOVETYPE_FLY)
196 sv_player->v.movetype = MOVETYPE_FLY;
197 SV_ClientPrintf ("flymode ON\n");
201 sv_player->v.movetype = MOVETYPE_WALK;
202 SV_ClientPrintf ("flymode OFF\n");
213 void Host_Ping_f (void)
219 if (cmd_source == src_command)
221 Cmd_ForwardToServer ();
225 SV_ClientPrintf ("Client ping times:\n");
226 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
231 for (j=0 ; j<NUM_PING_TIMES ; j++)
232 total+=client->ping_times[j];
233 total /= NUM_PING_TIMES;
234 SV_ClientPrintf ("%4i %s\n", (int)(total*1000), client->name);
239 ===============================================================================
243 ===============================================================================
248 ======================
253 command from the console. Active clients are kicked off.
254 ======================
256 void Host_Map_f (void)
259 char name[MAX_QPATH];
261 if (cmd_source != src_command)
264 cls.demonum = -1; // stop demo loop in case this fails
267 Host_ShutdownServer(false);
269 key_dest = key_game; // remove console or menu
270 SCR_BeginLoadingPlaque ();
272 cls.mapstring[0] = 0;
273 for (i=0 ; i<Cmd_Argc() ; i++)
275 strcat (cls.mapstring, Cmd_Argv(i));
276 strcat (cls.mapstring, " ");
278 strcat (cls.mapstring, "\n");
280 svs.serverflags = 0; // haven't completed an episode yet
281 strcpy (name, Cmd_Argv(1));
282 SV_SpawnServer (name);
286 if (cls.state != ca_dedicated)
288 strcpy (cls.spawnparms, "");
290 for (i=2 ; i<Cmd_Argc() ; i++)
292 strcat (cls.spawnparms, Cmd_Argv(i));
293 strcat (cls.spawnparms, " ");
296 Cmd_ExecuteString ("connect local", src_command);
304 Goes to a new map, taking all clients along
307 void Host_Changelevel_f (void)
309 char level[MAX_QPATH];
313 Con_Printf ("changelevel <levelname> : continue game on a new level\n");
316 if (!sv.active || cls.demoplayback)
318 Con_Printf ("Only the server may changelevel\n");
321 SV_SaveSpawnparms ();
322 strcpy (level, Cmd_Argv(1));
323 SV_SpawnServer (level);
330 Restarts the current server for a dead player
333 void Host_Restart_f (void)
335 char mapname[MAX_QPATH];
337 if (cls.demoplayback || !sv.active)
340 if (cmd_source != src_command)
342 strcpy (mapname, sv.name); // must copy out, because it gets cleared
344 SV_SpawnServer (mapname);
351 This command causes the client to wait for the signon messages again.
352 This is sent just before a server changes levels
355 void Host_Reconnect_f (void)
357 SCR_BeginLoadingPlaque ();
358 cls.signon = 0; // need new connection messages
362 =====================
365 User command to connect to server
366 =====================
368 void Host_Connect_f (void)
370 char name[MAX_QPATH];
372 cls.demonum = -1; // stop demo loop in case this fails
373 if (cls.demoplayback)
378 strcpy (name, Cmd_Argv(1));
379 CL_EstablishConnection (name);
385 ===============================================================================
389 ===============================================================================
392 #define SAVEGAME_VERSION 5
398 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
401 void Host_SavegameComment (char *text)
406 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
408 memcpy (text, cl.levelname, strlen(cl.levelname));
409 sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
410 memcpy (text+22, kills, strlen(kills));
411 // convert space to _ to make stdio happy
412 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
415 text[SAVEGAME_COMMENT_LENGTH] = '\0';
424 void Host_Savegame_f (void)
429 char comment[SAVEGAME_COMMENT_LENGTH+1];
431 if (cmd_source != src_command)
436 Con_Printf ("Not playing a local game.\n");
442 Con_Printf ("Can't save in intermission.\n");
446 if (svs.maxclients != 1)
448 Con_Printf ("Can't save multiplayer games.\n");
454 Con_Printf ("save <savename> : save a game\n");
458 if (strstr(Cmd_Argv(1), ".."))
460 Con_Printf ("Relative pathnames are not allowed.\n");
464 for (i=0 ; i<svs.maxclients ; i++)
466 if (svs.clients[i].active && (svs.clients[i].edict->v.health <= 0) )
468 Con_Printf ("Can't savegame with a dead player\n");
473 sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
474 COM_DefaultExtension (name, ".sav");
476 Con_Printf ("Saving game to %s...\n", name);
477 f = fopen (name, "w");
480 Con_Printf ("ERROR: couldn't open.\n");
484 fprintf (f, "%i\n", SAVEGAME_VERSION);
485 Host_SavegameComment (comment);
486 fprintf (f, "%s\n", comment);
487 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
488 fprintf (f, "%f\n", svs.clients->spawn_parms[i]);
489 fprintf (f, "%d\n", current_skill);
490 fprintf (f, "%s\n", sv.name);
491 fprintf (f, "%f\n",sv.time);
493 // write the light styles
495 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
497 if (sv.lightstyles[i])
498 fprintf (f, "%s\n", sv.lightstyles[i]);
505 for (i=0 ; i<sv.num_edicts ; i++)
507 ED_Write (f, EDICT_NUM(i));
511 Con_Printf ("done.\n");
520 void Host_Loadgame_f (void)
522 char name[MAX_OSPATH];
524 char mapname[MAX_QPATH];
526 char str[32768], *start;
531 float spawn_parms[NUM_SPAWN_PARMS];
533 if (cmd_source != src_command)
538 Con_Printf ("load <savename> : load a game\n");
542 cls.demonum = -1; // stop demo loop in case this fails
544 sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
545 COM_DefaultExtension (name, ".sav");
547 // we can't call SCR_BeginLoadingPlaque, because too much stack space has
548 // been used. The menu calls it before stuffing loadgame command
549 // SCR_BeginLoadingPlaque ();
551 Con_Printf ("Loading game from %s...\n", name);
552 f = fopen (name, "r");
555 Con_Printf ("ERROR: couldn't open.\n");
559 fscanf (f, "%i\n", &version);
560 if (version != SAVEGAME_VERSION)
563 Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
566 fscanf (f, "%s\n", str);
567 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
568 fscanf (f, "%f\n", &spawn_parms[i]);
569 // this silliness is so we can load 1.06 save files, which have float skill values
570 fscanf (f, "%f\n", &tfloat);
571 current_skill = (int)(tfloat + 0.1);
572 Cvar_SetValue ("skill", (float)current_skill);
574 fscanf (f, "%s\n",mapname);
575 fscanf (f, "%f\n",&time);
579 SV_SpawnServer (mapname);
582 Con_Printf ("Couldn't load map\n");
585 sv.paused = true; // pause until all clients connect
588 // load the light styles
590 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
592 fscanf (f, "%s\n", str);
593 sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
594 strcpy (sv.lightstyles[i], str);
597 // load the edicts out of the savegame file
598 entnum = -1; // -1 is the globals
601 for (i=0 ; i<sizeof(str)-1 ; i++)
613 if (i == sizeof(str)-1)
614 Sys_Error ("Loadgame buffer overflow");
617 start = COM_Parse(str);
619 break; // end of file
620 if (strcmp(com_token,"{"))
621 Sys_Error ("First token isn't a brace");
624 { // parse the global vars
625 ED_ParseGlobals (start);
630 ent = EDICT_NUM(entnum);
631 memset (&ent->v, 0, progs->entityfields * 4);
633 ED_ParseEdict (start, ent);
635 // link it into the bsp tree
637 SV_LinkEdict (ent, false);
643 sv.num_edicts = entnum;
648 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
649 svs.clients->spawn_parms[i] = spawn_parms[i];
651 if (cls.state != ca_dedicated)
653 CL_EstablishConnection ("local");
658 //============================================================================
661 ======================
663 ======================
665 void Host_Name_f (void)
669 if (Cmd_Argc () == 1)
671 Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
674 if (Cmd_Argc () == 2)
675 newName = Cmd_Argv(1);
677 newName = Cmd_Args();
680 if (cmd_source == src_command)
682 if (strcmp(cl_name.string, newName) == 0)
684 Cvar_Set ("_cl_name", newName);
685 if (cls.state == ca_connected)
686 Cmd_ForwardToServer ();
690 if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
691 if (strcmp(host_client->name, newName) != 0)
692 Con_Printf ("%s renamed to %s\n", host_client->name, newName);
693 strcpy (host_client->name, newName);
694 host_client->edict->v.netname = host_client->name - pr_strings;
696 // send notification to all clients
698 MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
699 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
700 MSG_WriteString (&sv.reliable_datagram, host_client->name);
704 void Host_Version_f (void)
706 Con_Printf ("Version %4.2f\n", VERSION);
707 Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
711 void Host_Please_f (void)
716 if (cmd_source != src_command)
719 if ((Cmd_Argc () == 3) && strcmp(Cmd_Argv(1), "#") == 0)
721 j = atof(Cmd_Argv(2)) - 1;
722 if (j < 0 || j >= svs.maxclients)
724 if (!svs.clients[j].active)
726 cl = &svs.clients[j];
729 cl->privileged = false;
730 cl->edict->v.flags = (int)cl->edict->v.flags & ~(FL_GODMODE|FL_NOTARGET);
731 cl->edict->v.movetype = MOVETYPE_WALK;
732 noclip_anglehack = false;
735 cl->privileged = true;
738 if (Cmd_Argc () != 2)
741 for (j=0, cl = svs.clients ; j<svs.maxclients ; j++, cl++)
745 if (strcasecmp(cl->name, Cmd_Argv(1)) == 0)
749 cl->privileged = false;
750 cl->edict->v.flags = (int)cl->edict->v.flags & ~(FL_GODMODE|FL_NOTARGET);
751 cl->edict->v.movetype = MOVETYPE_WALK;
752 noclip_anglehack = false;
755 cl->privileged = true;
763 void Host_Say(qboolean teamonly)
769 // LordHavoc: 256 char say messages
770 unsigned char text[256];
771 qboolean fromServer = false;
773 if (cmd_source == src_command)
775 if (cls.state == ca_dedicated)
782 Cmd_ForwardToServer ();
793 // remove quotes if present
800 // turn on color set 1
802 sprintf (text, "%c%s: ", 1, save->name);
804 sprintf (text, "%c<%s> ", 1, hostname.string);
806 j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator
813 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
815 if (!client || !client->active || !client->spawned)
817 if (teamplay.value && teamonly && client->edict->v.team != save->edict->v.team)
819 host_client = client;
820 SV_ClientPrintf("%s", text);
824 Sys_Printf("%s", &text[1]);
828 void Host_Say_f(void)
834 void Host_Say_Team_f(void)
840 void Host_Tell_f(void)
848 if (cmd_source == src_command)
850 Cmd_ForwardToServer ();
857 strcpy(text, host_client->name);
862 // remove quotes if present
869 // check length & truncate if necessary
870 j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator
878 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
880 if (!client->active || !client->spawned)
882 if (Q_strcasecmp(client->name, Cmd_Argv(1)))
884 host_client = client;
885 SV_ClientPrintf("%s", text);
897 void Host_Color_f(void)
904 Con_Printf ("\"color\" is \"%i %i\"\n", ((int)cl_color.value) >> 4, ((int)cl_color.value) & 0x0f);
905 Con_Printf ("color <0-13> [0-13]\n");
910 top = bottom = atoi(Cmd_Argv(1));
913 top = atoi(Cmd_Argv(1));
914 bottom = atoi(Cmd_Argv(2));
918 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
922 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
926 playercolor = top*16 + bottom;
928 if (cmd_source == src_command)
930 Cvar_SetValue ("_cl_color", playercolor);
931 if (cls.state == ca_connected)
932 Cmd_ForwardToServer ();
936 host_client->colors = playercolor;
937 host_client->edict->v.team = bottom + 1;
939 // send notification to all clients
940 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
941 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
942 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
950 void Host_Kill_f (void)
952 if (cmd_source == src_command)
954 Cmd_ForwardToServer ();
958 if (sv_player->v.health <= 0)
960 SV_ClientPrintf ("Can't suicide -- allready dead!\n");
964 pr_global_struct->time = sv.time;
965 pr_global_struct->self = EDICT_TO_PROG(sv_player);
966 PR_ExecuteProgram (pr_global_struct->ClientKill);
975 void Host_Pause_f (void)
978 if (cmd_source == src_command)
980 Cmd_ForwardToServer ();
984 SV_ClientPrintf ("Pause not allowed.\n");
991 SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v.netname);
995 SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v.netname);
998 // send notification to all clients
999 MSG_WriteByte (&sv.reliable_datagram, svc_setpause);
1000 MSG_WriteByte (&sv.reliable_datagram, sv.paused);
1004 //===========================================================================
1012 void Host_PreSpawn_f (void)
1014 if (cmd_source == src_command)
1016 Con_Printf ("prespawn is not valid from the console\n");
1020 if (host_client->spawned)
1022 Con_Printf ("prespawn not valid -- allready spawned\n");
1026 SZ_Write (&host_client->message, sv.signon.data, sv.signon.cursize);
1027 MSG_WriteByte (&host_client->message, svc_signonnum);
1028 MSG_WriteByte (&host_client->message, 2);
1029 host_client->sendsignon = true;
1032 dfunction_t *ED_FindFunction (char *name);
1039 void Host_Spawn_f (void)
1047 if (cmd_source == src_command)
1049 Con_Printf ("spawn is not valid from the console\n");
1053 if (host_client->spawned)
1055 Con_Printf ("Spawn not valid -- allready spawned\n");
1059 // run the entrance script
1061 { // loaded games are fully inited allready
1062 // if this is the last client to be connected, unpause
1065 if (f = ED_FindFunction ("RestoreGame"))
1066 if (RestoreGame = (func_t)(f - pr_functions))
1068 Con_DPrintf("Calling RestoreGame\n");
1069 pr_global_struct->time = sv.time;
1070 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1071 PR_ExecuteProgram (RestoreGame);
1077 ent = host_client->edict;
1079 memset (&ent->v, 0, progs->entityfields * 4);
1080 ent->v.colormap = NUM_FOR_EDICT(ent);
1081 ent->v.team = (host_client->colors & 15) + 1;
1082 ent->v.netname = host_client->name - pr_strings;
1084 // copy spawn parms out of the client_t
1086 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1087 (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
1089 // call the spawn function
1091 pr_global_struct->time = sv.time;
1092 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1093 PR_ExecuteProgram (pr_global_struct->ClientConnect);
1095 if ((Sys_FloatTime() - host_client->netconnection->connecttime) <= sv.time)
1096 Sys_Printf ("%s entered the game\n", host_client->name);
1098 PR_ExecuteProgram (pr_global_struct->PutClientInServer);
1102 // send all current names, colors, and frag counts
1103 SZ_Clear (&host_client->message);
1105 // send time of update
1106 MSG_WriteByte (&host_client->message, svc_time);
1107 MSG_WriteFloat (&host_client->message, sv.time);
1109 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
1111 MSG_WriteByte (&host_client->message, svc_updatename);
1112 MSG_WriteByte (&host_client->message, i);
1113 MSG_WriteString (&host_client->message, client->name);
1114 MSG_WriteByte (&host_client->message, svc_updatefrags);
1115 MSG_WriteByte (&host_client->message, i);
1116 MSG_WriteShort (&host_client->message, client->old_frags);
1117 MSG_WriteByte (&host_client->message, svc_updatecolors);
1118 MSG_WriteByte (&host_client->message, i);
1119 MSG_WriteByte (&host_client->message, client->colors);
1122 // send all current light styles
1123 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1125 MSG_WriteByte (&host_client->message, svc_lightstyle);
1126 MSG_WriteByte (&host_client->message, (char)i);
1127 MSG_WriteString (&host_client->message, sv.lightstyles[i]);
1133 MSG_WriteByte (&host_client->message, svc_updatestat);
1134 MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS);
1135 MSG_WriteLong (&host_client->message, pr_global_struct->total_secrets);
1137 MSG_WriteByte (&host_client->message, svc_updatestat);
1138 MSG_WriteByte (&host_client->message, STAT_TOTALMONSTERS);
1139 MSG_WriteLong (&host_client->message, pr_global_struct->total_monsters);
1141 MSG_WriteByte (&host_client->message, svc_updatestat);
1142 MSG_WriteByte (&host_client->message, STAT_SECRETS);
1143 MSG_WriteLong (&host_client->message, pr_global_struct->found_secrets);
1145 MSG_WriteByte (&host_client->message, svc_updatestat);
1146 MSG_WriteByte (&host_client->message, STAT_MONSTERS);
1147 MSG_WriteLong (&host_client->message, pr_global_struct->killed_monsters);
1151 // Never send a roll angle, because savegames can catch the server
1152 // in a state where it is expecting the client to correct the angle
1153 // and it won't happen if the game was just loaded, so you wind up
1154 // with a permanent head tilt
1155 ent = EDICT_NUM( 1 + (host_client - svs.clients) );
1156 MSG_WriteByte (&host_client->message, svc_setangle);
1157 for (i=0 ; i < 2 ; i++)
1158 MSG_WriteAngle (&host_client->message, ent->v.angles[i] );
1159 MSG_WriteAngle (&host_client->message, 0 );
1161 SV_WriteClientdataToMessage (sv_player, &host_client->message);
1163 MSG_WriteByte (&host_client->message, svc_signonnum);
1164 MSG_WriteByte (&host_client->message, 3);
1165 host_client->sendsignon = true;
1173 void Host_Begin_f (void)
1175 if (cmd_source == src_command)
1177 Con_Printf ("begin is not valid from the console\n");
1181 host_client->spawned = true;
1184 //===========================================================================
1191 Kicks a user off of the server
1194 void Host_Kick_f (void)
1197 char *message = NULL;
1200 qboolean byNumber = false;
1202 if (cmd_source == src_command)
1206 Cmd_ForwardToServer ();
1210 else if (pr_global_struct->deathmatch && !host_client->privileged)
1215 if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1217 i = atof(Cmd_Argv(2)) - 1;
1218 if (i < 0 || i >= svs.maxclients)
1220 if (!svs.clients[i].active)
1222 host_client = &svs.clients[i];
1227 for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
1229 if (!host_client->active)
1231 if (Q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1236 if (i < svs.maxclients)
1238 if (cmd_source == src_command)
1239 if (cls.state == ca_dedicated)
1242 who = cl_name.string;
1246 // can't kick yourself!
1247 if (host_client == save)
1252 message = COM_Parse(Cmd_Args());
1255 message++; // skip the #
1256 while (*message == ' ') // skip white space
1258 message += strlen(Cmd_Argv(2)); // skip the number
1260 while (*message && *message == ' ')
1264 SV_ClientPrintf ("Kicked by %s: %s\n", who, message);
1266 SV_ClientPrintf ("Kicked by %s\n", who);
1267 SV_DropClient (false);
1274 ===============================================================================
1278 ===============================================================================
1286 void Host_Give_f (void)
1292 if (cmd_source == src_command)
1294 Cmd_ForwardToServer ();
1298 if (pr_global_struct->deathmatch && !host_client->privileged)
1302 v = atoi (Cmd_Argv(2));
1316 // MED 01/04/97 added hipnotic give stuff
1322 sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN;
1324 sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER;
1326 else if (t[0] == '9')
1327 sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON;
1328 else if (t[0] == '0')
1329 sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR;
1330 else if (t[0] >= '2')
1331 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1336 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1343 if (val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1))
1347 sv_player->v.ammo_shells = v;
1352 if (val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1))
1355 if (sv_player->v.weapon <= IT_LIGHTNING)
1356 sv_player->v.ammo_nails = v;
1361 sv_player->v.ammo_nails = v;
1367 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_lava_nails);
1371 if (sv_player->v.weapon > IT_LIGHTNING)
1372 sv_player->v.ammo_nails = v;
1379 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_rockets1);
1383 if (sv_player->v.weapon <= IT_LIGHTNING)
1384 sv_player->v.ammo_rockets = v;
1389 sv_player->v.ammo_rockets = v;
1395 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_multi_rockets);
1399 if (sv_player->v.weapon > IT_LIGHTNING)
1400 sv_player->v.ammo_rockets = v;
1405 sv_player->v.health = v;
1410 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_cells1);
1414 if (sv_player->v.weapon <= IT_LIGHTNING)
1415 sv_player->v.ammo_cells = v;
1420 sv_player->v.ammo_cells = v;
1426 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_plasma);
1430 if (sv_player->v.weapon > IT_LIGHTNING)
1431 sv_player->v.ammo_cells = v;
1438 edict_t *FindViewthing (void)
1443 for (i=0 ; i<sv.num_edicts ; i++)
1446 if ( !strcmp (pr_strings + e->v.classname, "viewthing") )
1449 Con_Printf ("No viewthing on map\n");
1458 void Host_Viewmodel_f (void)
1463 e = FindViewthing ();
1467 m = Mod_ForName (Cmd_Argv(1), false);
1470 Con_Printf ("Can't load %s\n", Cmd_Argv(1));
1475 cl.model_precache[(int)e->v.modelindex] = m;
1483 void Host_Viewframe_f (void)
1489 e = FindViewthing ();
1492 m = cl.model_precache[(int)e->v.modelindex];
1494 f = atoi(Cmd_Argv(1));
1495 if (f >= m->numframes)
1502 void PrintFrameName (model_t *m, int frame)
1505 maliasframedesc_t *pframedesc;
1507 hdr = (aliashdr_t *)Mod_Extradata (m);
1510 pframedesc = &hdr->frames[frame];
1512 Con_Printf ("frame %i: %s\n", frame, pframedesc->name);
1520 void Host_Viewnext_f (void)
1525 e = FindViewthing ();
1528 m = cl.model_precache[(int)e->v.modelindex];
1530 e->v.frame = e->v.frame + 1;
1531 if (e->v.frame >= m->numframes)
1532 e->v.frame = m->numframes - 1;
1534 PrintFrameName (m, e->v.frame);
1542 void Host_Viewprev_f (void)
1547 e = FindViewthing ();
1551 m = cl.model_precache[(int)e->v.modelindex];
1553 e->v.frame = e->v.frame - 1;
1557 PrintFrameName (m, e->v.frame);
1561 ===============================================================================
1565 ===============================================================================
1574 void Host_Startdemos_f (void)
1578 if (cls.state == ca_dedicated)
1581 Cbuf_AddText ("map start\n");
1588 Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS);
1591 Con_Printf ("%i demo(s) in loop\n", c);
1593 for (i=1 ; i<c+1 ; i++)
1594 strncpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0])-1);
1596 if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1610 Return to looping demos
1613 void Host_Demos_f (void)
1615 if (cls.state == ca_dedicated)
1617 if (cls.demonum == -1)
1627 Return to looping demos
1630 void Host_Stopdemo_f (void)
1632 if (cls.state == ca_dedicated)
1634 if (!cls.demoplayback)
1641 ======================
1643 LordHavoc: Intended for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
1644 ======================
1646 void Host_PModel_f (void)
1651 if (Cmd_Argc () == 1)
1653 Con_Printf ("usage: pmodel modelnumber\n");
1656 i = atoi(Cmd_Argv(1));
1658 if (cmd_source == src_command)
1660 if (cls.state == ca_connected)
1661 Cmd_ForwardToServer ();
1665 if (val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel))
1669 //=============================================================================
1676 void Host_InitCommands (void)
1678 Cmd_AddCommand ("status", Host_Status_f);
1679 Cmd_AddCommand ("quit", Host_Quit_f);
1682 Cmd_AddCommand ("max", Host_God_f);
1683 Cmd_AddCommand ("monster", Host_Notarget_f);
1684 Cmd_AddCommand ("scrag", Host_Fly_f);
1685 Cmd_AddCommand ("wraith", Host_Noclip_f);
1686 Cmd_AddCommand ("gimme", Host_Give_f);
1690 Cmd_AddCommand ("god", Host_God_f);
1691 Cmd_AddCommand ("notarget", Host_Notarget_f);
1692 Cmd_AddCommand ("fly", Host_Fly_f);
1693 Cmd_AddCommand ("noclip", Host_Noclip_f);
1694 Cmd_AddCommand ("give", Host_Give_f);
1696 Cmd_AddCommand ("map", Host_Map_f);
1697 Cmd_AddCommand ("restart", Host_Restart_f);
1698 Cmd_AddCommand ("changelevel", Host_Changelevel_f);
1699 Cmd_AddCommand ("connect", Host_Connect_f);
1700 Cmd_AddCommand ("reconnect", Host_Reconnect_f);
1701 Cmd_AddCommand ("name", Host_Name_f);
1702 Cmd_AddCommand ("version", Host_Version_f);
1704 Cmd_AddCommand ("please", Host_Please_f);
1706 Cmd_AddCommand ("say", Host_Say_f);
1707 Cmd_AddCommand ("say_team", Host_Say_Team_f);
1708 Cmd_AddCommand ("tell", Host_Tell_f);
1709 Cmd_AddCommand ("color", Host_Color_f);
1710 Cmd_AddCommand ("kill", Host_Kill_f);
1711 Cmd_AddCommand ("pause", Host_Pause_f);
1712 Cmd_AddCommand ("spawn", Host_Spawn_f);
1713 Cmd_AddCommand ("begin", Host_Begin_f);
1714 Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
1715 Cmd_AddCommand ("kick", Host_Kick_f);
1716 Cmd_AddCommand ("ping", Host_Ping_f);
1717 Cmd_AddCommand ("load", Host_Loadgame_f);
1718 Cmd_AddCommand ("save", Host_Savegame_f);
1719 Cmd_AddCommand ("pmodel", Host_PModel_f);
1721 Cmd_AddCommand ("startdemos", Host_Startdemos_f);
1722 Cmd_AddCommand ("demos", Host_Demos_f);
1723 Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
1725 Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
1726 Cmd_AddCommand ("viewframe", Host_Viewframe_f);
1727 Cmd_AddCommand ("viewnext", Host_Viewnext_f);
1728 Cmd_AddCommand ("viewprev", Host_Viewprev_f);
1730 Cmd_AddCommand ("mcache", Mod_Print);