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)
56 void (*print) (char *fmt, ...);
58 if (cmd_source == src_command)
62 Cmd_ForwardToServer ();
68 print = SV_ClientPrintf;
70 print ("host: %s\n", Cvar_VariableString ("hostname"));
71 print ("version: %s build %s\n", gamename, buildstring);
73 print ("tcp/ip: %s\n", my_tcpip_address);
75 print ("ipx: %s\n", my_ipx_address);
76 print ("map: %s\n", sv.name);
77 print ("players: %i active (%i max)\n\n", net_activeconnections, svs.maxclients);
78 for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
82 seconds = (int)(net_time - client->netconnection->connecttime);
83 minutes = seconds / 60;
86 seconds -= (minutes * 60);
89 minutes -= (hours * 60);
93 print ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->v.frags, hours, minutes, seconds);
94 print (" %s\n", client->netconnection->address);
103 Sets client to godmode
106 void Host_God_f (void)
108 if (cmd_source == src_command)
110 Cmd_ForwardToServer ();
114 if (pr_global_struct->deathmatch)
117 sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
118 if (!((int)sv_player->v.flags & FL_GODMODE) )
119 SV_ClientPrintf ("godmode OFF\n");
121 SV_ClientPrintf ("godmode ON\n");
124 void Host_Notarget_f (void)
126 if (cmd_source == src_command)
128 Cmd_ForwardToServer ();
132 if (pr_global_struct->deathmatch)
135 sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
136 if (!((int)sv_player->v.flags & FL_NOTARGET) )
137 SV_ClientPrintf ("notarget OFF\n");
139 SV_ClientPrintf ("notarget ON\n");
142 qboolean noclip_anglehack;
144 void Host_Noclip_f (void)
146 if (cmd_source == src_command)
148 Cmd_ForwardToServer ();
152 if (pr_global_struct->deathmatch)
155 if (sv_player->v.movetype != MOVETYPE_NOCLIP)
157 noclip_anglehack = true;
158 sv_player->v.movetype = MOVETYPE_NOCLIP;
159 SV_ClientPrintf ("noclip ON\n");
163 noclip_anglehack = false;
164 sv_player->v.movetype = MOVETYPE_WALK;
165 SV_ClientPrintf ("noclip OFF\n");
173 Sets client to flymode
176 void Host_Fly_f (void)
178 if (cmd_source == src_command)
180 Cmd_ForwardToServer ();
184 if (pr_global_struct->deathmatch)
187 if (sv_player->v.movetype != MOVETYPE_FLY)
189 sv_player->v.movetype = MOVETYPE_FLY;
190 SV_ClientPrintf ("flymode ON\n");
194 sv_player->v.movetype = MOVETYPE_WALK;
195 SV_ClientPrintf ("flymode OFF\n");
206 void Host_Ping_f (void)
212 if (cmd_source == src_command)
214 Cmd_ForwardToServer ();
218 SV_ClientPrintf ("Client ping times:\n");
219 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
224 for (j=0 ; j<NUM_PING_TIMES ; j++)
225 total+=client->ping_times[j];
226 total /= NUM_PING_TIMES;
227 SV_ClientPrintf ("%4i %s\n", (int)(total*1000), client->name);
232 ===============================================================================
236 ===============================================================================
241 ======================
246 command from the console. Active clients are kicked off.
247 ======================
249 void Host_Map_f (void)
252 char name[MAX_QPATH];
254 if (cmd_source != src_command)
257 cls.demonum = -1; // stop demo loop in case this fails
259 SCR_BeginLoadingPlaque ();
262 Host_ShutdownServer(false);
264 key_dest = key_game; // remove console or menu
266 cls.mapstring[0] = 0;
267 for (i=0 ; i<Cmd_Argc() ; i++)
269 strcat (cls.mapstring, Cmd_Argv(i));
270 strcat (cls.mapstring, " ");
272 strcat (cls.mapstring, "\n");
274 svs.serverflags = 0; // haven't completed an episode yet
275 strcpy (name, Cmd_Argv(1));
276 SV_SpawnServer (name);
280 if (cls.state != ca_dedicated)
283 strcpy (cls.spawnparms, "");
285 for (i=2 ; i<Cmd_Argc() ; i++)
287 strcat (cls.spawnparms, Cmd_Argv(i));
288 strcat (cls.spawnparms, " ");
291 Cmd_ExecuteString ("connect local", src_command);
299 Goes to a new map, taking all clients along
302 void Host_Changelevel_f (void)
304 char level[MAX_QPATH];
308 Con_Printf ("changelevel <levelname> : continue game on a new level\n");
311 if (!sv.active || cls.demoplayback)
313 Con_Printf ("Only the server may changelevel\n");
316 SV_SaveSpawnparms ();
317 strcpy (level, Cmd_Argv(1));
318 SV_SpawnServer (level);
325 Restarts the current server for a dead player
328 void Host_Restart_f (void)
330 char mapname[MAX_QPATH];
332 if (cls.demoplayback || !sv.active)
335 if (cmd_source != src_command)
337 strcpy (mapname, sv.name); // must copy out, because it gets cleared
339 SV_SpawnServer (mapname);
346 This command causes the client to wait for the signon messages again.
347 This is sent just before a server changes levels
350 void Host_Reconnect_f (void)
352 SCR_BeginLoadingPlaque ();
353 cls.signon = 0; // need new connection messages
357 =====================
360 User command to connect to server
361 =====================
363 void Host_Connect_f (void)
365 char name[MAX_QPATH];
367 cls.demonum = -1; // stop demo loop in case this fails
368 if (cls.demoplayback)
370 strcpy (name, Cmd_Argv(1));
371 CL_EstablishConnection (name);
377 ===============================================================================
381 ===============================================================================
384 #define SAVEGAME_VERSION 5
390 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
393 void Host_SavegameComment (char *text)
398 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
400 memcpy (text, cl.levelname, strlen(cl.levelname));
401 sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
402 memcpy (text+22, kills, strlen(kills));
403 // convert space to _ to make stdio happy
404 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
407 text[SAVEGAME_COMMENT_LENGTH] = '\0';
416 void Host_Savegame_f (void)
421 char comment[SAVEGAME_COMMENT_LENGTH+1];
423 if (cmd_source != src_command)
428 Con_Printf ("Not playing a local game.\n");
434 Con_Printf ("Can't save in intermission.\n");
438 if (svs.maxclients != 1)
440 Con_Printf ("Can't save multiplayer games.\n");
446 Con_Printf ("save <savename> : save a game\n");
450 if (strstr(Cmd_Argv(1), ".."))
452 Con_Printf ("Relative pathnames are not allowed.\n");
456 for (i=0 ; i<svs.maxclients ; i++)
458 if (svs.clients[i].active && (svs.clients[i].edict->v.health <= 0) )
460 Con_Printf ("Can't savegame with a dead player\n");
465 sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
466 COM_DefaultExtension (name, ".sav");
468 Con_Printf ("Saving game to %s...\n", name);
469 f = Qopen (name, "w");
472 Con_Printf ("ERROR: couldn't open.\n");
476 Qprintf (f, "%i\n", SAVEGAME_VERSION);
477 Host_SavegameComment (comment);
478 Qprintf (f, "%s\n", comment);
479 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
480 Qprintf (f, "%f\n", svs.clients->spawn_parms[i]);
481 Qprintf (f, "%d\n", current_skill);
482 Qprintf (f, "%s\n", sv.name);
483 Qprintf (f, "%f\n",sv.time);
485 // write the light styles
487 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
489 if (sv.lightstyles[i])
490 Qprintf (f, "%s\n", sv.lightstyles[i]);
497 for (i=0 ; i<sv.num_edicts ; i++)
499 ED_Write (f, EDICT_NUM(i));
503 Con_Printf ("done.\n");
507 extern mempool_t *edictstring_mempool;
514 void Host_Loadgame_f (void)
516 char name[MAX_OSPATH];
518 char mapname[MAX_QPATH];
520 char buf[32768], *start;
526 float spawn_parms[NUM_SPAWN_PARMS];
528 if (cmd_source != src_command)
533 Con_Printf ("load <savename> : load a game\n");
537 cls.demonum = -1; // stop demo loop in case this fails
539 sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
540 COM_DefaultExtension (name, ".sav");
542 Con_Printf ("Loading game from %s...\n", name);
543 f = Qopen (name, "rz");
546 Con_Printf ("ERROR: couldn't open.\n");
551 sscanf (str, "%i\n", &version);
552 if (version != SAVEGAME_VERSION)
555 Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
559 SCR_BeginLoadingPlaque ();
562 for (i=0 ; i<NUM_SPAWN_PARMS ; i++) {
564 sscanf (str, "%f\n", &spawn_parms[i]);
566 // this silliness is so we can load 1.06 save files, which have float skill values
568 sscanf (str, "%f\n", &tfloat);
569 current_skill = (int)(tfloat + 0.1);
570 Cvar_SetValue ("skill", (float)current_skill);
572 strcpy (mapname, Qgetline (f));
575 sscanf (str, "%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++)
593 sv.lightstyles[i] = Mem_Alloc(edictstring_mempool, 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(buf)-1 ; i++)
613 if (i == sizeof(buf)-1)
614 Sys_Error ("Loadgame buffer overflow");
617 start = COM_Parse(buf);
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);
675 if (Cmd_Argc () == 2)
676 strncpy(newName, Cmd_Argv(1), 15);
678 strncpy(newName, Cmd_Args(), 15);
681 if (cmd_source == src_command)
683 if (strcmp(cl_name.string, newName) == 0)
685 Cvar_Set ("_cl_name", newName);
686 if (cls.state == ca_connected)
687 Cmd_ForwardToServer ();
691 if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
692 if (strcmp(host_client->name, newName) != 0)
693 Con_Printf ("%s renamed to %s\n", host_client->name, newName);
694 strcpy (host_client->name, newName);
695 host_client->edict->v.netname = host_client->name - pr_strings;
697 // send notification to all clients
699 MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
700 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
701 MSG_WriteString (&sv.reliable_datagram, host_client->name);
705 void Host_Version_f (void)
707 Con_Printf ("Version: %s build %s\n", gamename, buildstring);
710 void Host_Say(qboolean teamonly)
716 // LordHavoc: 256 char say messages
717 unsigned char text[256];
718 qboolean fromServer = false;
720 if (cmd_source == src_command)
722 if (cls.state == ca_dedicated)
729 Cmd_ForwardToServer ();
740 // remove quotes if present
747 // turn on color set 1
749 sprintf (text, "%c%s: ", 1, save->name);
751 sprintf (text, "%c<%s> ", 1, hostname.string);
753 j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator
760 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
762 if (!client || !client->active || !client->spawned)
764 if (teamplay.integer && teamonly && client->edict->v.team != save->edict->v.team)
766 host_client = client;
767 SV_ClientPrintf("%s", text);
771 Sys_Printf("%s", &text[1]);
775 void Host_Say_f(void)
781 void Host_Say_Team_f(void)
787 void Host_Tell_f(void)
793 char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
795 if (cmd_source == src_command)
797 Cmd_ForwardToServer ();
804 strcpy(text, host_client->name);
809 // remove quotes if present
816 // check length & truncate if necessary
817 j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator
825 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
827 if (!client->active || !client->spawned)
829 if (Q_strcasecmp(client->name, Cmd_Argv(1)))
831 host_client = client;
832 SV_ClientPrintf("%s", text);
844 void Host_Color_f(void)
849 func_t SV_ChangeTeam;
853 Con_Printf ("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15);
854 Con_Printf ("color <0-13> [0-13]\n");
859 top = bottom = atoi(Cmd_Argv(1));
862 top = atoi(Cmd_Argv(1));
863 bottom = atoi(Cmd_Argv(2));
867 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
871 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
875 playercolor = top*16 + bottom;
877 if (cmd_source == src_command)
879 Cvar_SetValue ("_cl_color", playercolor);
880 if (cls.state == ca_connected)
881 Cmd_ForwardToServer ();
885 if ((f = ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - pr_functions)))
887 Con_DPrintf("Calling SV_ChangeTeam\n");
888 pr_global_struct->time = sv.time;
889 pr_globals[0] = playercolor;
890 pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
891 PR_ExecuteProgram (SV_ChangeTeam, "");
895 host_client->colors = playercolor;
896 host_client->edict->v.team = bottom + 1;
898 // send notification to all clients
899 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
900 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
901 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
910 void Host_Kill_f (void)
912 if (cmd_source == src_command)
914 Cmd_ForwardToServer ();
918 if (sv_player->v.health <= 0)
920 SV_ClientPrintf ("Can't suicide -- already dead!\n");
924 pr_global_struct->time = sv.time;
925 pr_global_struct->self = EDICT_TO_PROG(sv_player);
926 PR_ExecuteProgram (pr_global_struct->ClientKill, "QC function ClientKill is missing");
935 void Host_Pause_f (void)
938 if (cmd_source == src_command)
940 Cmd_ForwardToServer ();
943 if (!pausable.integer)
944 SV_ClientPrintf ("Pause not allowed.\n");
951 SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v.netname);
955 SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v.netname);
958 // send notification to all clients
959 MSG_WriteByte (&sv.reliable_datagram, svc_setpause);
960 MSG_WriteByte (&sv.reliable_datagram, sv.paused);
964 //===========================================================================
972 void Host_PreSpawn_f (void)
974 if (cmd_source == src_command)
976 Con_Printf ("prespawn is not valid from the console\n");
980 if (host_client->spawned)
982 Con_Printf ("prespawn not valid -- already spawned\n");
986 SZ_Write (&host_client->message, sv.signon.data, sv.signon.cursize);
987 MSG_WriteByte (&host_client->message, svc_signonnum);
988 MSG_WriteByte (&host_client->message, 2);
989 host_client->sendsignon = true;
997 void Host_Spawn_f (void)
1005 if (cmd_source == src_command)
1007 Con_Printf ("spawn is not valid from the console\n");
1011 if (host_client->spawned)
1013 Con_Printf ("Spawn not valid -- already spawned\n");
1017 // LordHavoc: moved this above the QC calls at FrikaC's request
1018 // send all current names, colors, and frag counts
1019 SZ_Clear (&host_client->message);
1021 // run the entrance script
1024 // loaded games are fully initialized already
1025 // if this is the last client to be connected, unpause
1028 if ((f = ED_FindFunction ("RestoreGame")))
1029 if ((RestoreGame = (func_t)(f - pr_functions)))
1031 Con_DPrintf("Calling RestoreGame\n");
1032 pr_global_struct->time = sv.time;
1033 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1034 PR_ExecuteProgram (RestoreGame, "");
1041 ent = host_client->edict;
1043 memset (&ent->v, 0, progs->entityfields * 4);
1044 ent->v.colormap = NUM_FOR_EDICT(ent);
1045 ent->v.team = (host_client->colors & 15) + 1;
1046 ent->v.netname = host_client->name - pr_strings;
1047 if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1048 val->_float = host_client->pmodel;
1050 // copy spawn parms out of the client_t
1052 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1053 (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
1055 // call the spawn function
1057 pr_global_struct->time = sv.time;
1058 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1059 PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
1061 if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= sv.time)
1062 Sys_Printf ("%s entered the game\n", host_client->name);
1064 PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing");
1068 // send time of update
1069 MSG_WriteByte (&host_client->message, svc_time);
1070 MSG_WriteFloat (&host_client->message, sv.time);
1072 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
1074 MSG_WriteByte (&host_client->message, svc_updatename);
1075 MSG_WriteByte (&host_client->message, i);
1076 MSG_WriteString (&host_client->message, client->name);
1077 MSG_WriteByte (&host_client->message, svc_updatefrags);
1078 MSG_WriteByte (&host_client->message, i);
1079 MSG_WriteShort (&host_client->message, client->old_frags);
1080 MSG_WriteByte (&host_client->message, svc_updatecolors);
1081 MSG_WriteByte (&host_client->message, i);
1082 MSG_WriteByte (&host_client->message, client->colors);
1085 // send all current light styles
1086 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1088 MSG_WriteByte (&host_client->message, svc_lightstyle);
1089 MSG_WriteByte (&host_client->message, (char)i);
1090 MSG_WriteString (&host_client->message, sv.lightstyles[i]);
1096 MSG_WriteByte (&host_client->message, svc_updatestat);
1097 MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS);
1098 MSG_WriteLong (&host_client->message, pr_global_struct->total_secrets);
1100 MSG_WriteByte (&host_client->message, svc_updatestat);
1101 MSG_WriteByte (&host_client->message, STAT_TOTALMONSTERS);
1102 MSG_WriteLong (&host_client->message, pr_global_struct->total_monsters);
1104 MSG_WriteByte (&host_client->message, svc_updatestat);
1105 MSG_WriteByte (&host_client->message, STAT_SECRETS);
1106 MSG_WriteLong (&host_client->message, pr_global_struct->found_secrets);
1108 MSG_WriteByte (&host_client->message, svc_updatestat);
1109 MSG_WriteByte (&host_client->message, STAT_MONSTERS);
1110 MSG_WriteLong (&host_client->message, pr_global_struct->killed_monsters);
1113 // Never send a roll angle, because savegames can catch the server
1114 // in a state where it is expecting the client to correct the angle
1115 // and it won't happen if the game was just loaded, so you wind up
1116 // with a permanent head tilt
1117 ent = EDICT_NUM( 1 + (host_client - svs.clients) );
1118 MSG_WriteByte (&host_client->message, svc_setangle);
1119 for (i=0 ; i < 2 ; i++)
1120 MSG_WriteAngle (&host_client->message, ent->v.angles[i] );
1121 MSG_WriteAngle (&host_client->message, 0 );
1123 SV_WriteClientdataToMessage (sv_player, &host_client->message);
1125 MSG_WriteByte (&host_client->message, svc_signonnum);
1126 MSG_WriteByte (&host_client->message, 3);
1127 host_client->sendsignon = true;
1135 void Host_Begin_f (void)
1137 if (cmd_source == src_command)
1139 Con_Printf ("begin is not valid from the console\n");
1143 host_client->spawned = true;
1146 //===========================================================================
1153 Kicks a user off of the server
1156 void Host_Kick_f (void)
1159 char *message = NULL;
1162 qboolean byNumber = false;
1164 if (cmd_source == src_command)
1168 Cmd_ForwardToServer ();
1172 else if (pr_global_struct->deathmatch)
1177 if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1179 i = atof(Cmd_Argv(2)) - 1;
1180 if (i < 0 || i >= svs.maxclients)
1182 if (!svs.clients[i].active)
1184 host_client = &svs.clients[i];
1189 for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
1191 if (!host_client->active)
1193 if (Q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1198 if (i < svs.maxclients)
1200 if (cmd_source == src_command)
1201 if (cls.state == ca_dedicated)
1204 who = cl_name.string;
1208 // can't kick yourself!
1209 if (host_client == save)
1214 message = COM_Parse(Cmd_Args());
1217 message++; // skip the #
1218 while (*message == ' ') // skip white space
1220 message += strlen(Cmd_Argv(2)); // skip the number
1222 while (*message && *message == ' ')
1226 SV_ClientPrintf ("Kicked by %s: %s\n", who, message);
1228 SV_ClientPrintf ("Kicked by %s\n", who);
1229 SV_DropClient (false);
1236 ===============================================================================
1240 ===============================================================================
1248 void Host_Give_f (void)
1254 if (cmd_source == src_command)
1256 Cmd_ForwardToServer ();
1260 if (pr_global_struct->deathmatch)
1264 v = atoi (Cmd_Argv(2));
1278 // MED 01/04/97 added hipnotic give stuff
1279 if (gamemode == GAME_HIPNOTIC)
1284 sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN;
1286 sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER;
1288 else if (t[0] == '9')
1289 sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON;
1290 else if (t[0] == '0')
1291 sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR;
1292 else if (t[0] >= '2')
1293 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1298 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1303 if (gamemode == GAME_ROGUE)
1305 if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1)))
1309 sv_player->v.ammo_shells = v;
1312 if (gamemode == GAME_ROGUE)
1314 if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1)))
1317 if (sv_player->v.weapon <= IT_LIGHTNING)
1318 sv_player->v.ammo_nails = v;
1323 sv_player->v.ammo_nails = v;
1327 if (gamemode == GAME_ROGUE)
1329 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_lava_nails);
1333 if (sv_player->v.weapon > IT_LIGHTNING)
1334 sv_player->v.ammo_nails = v;
1339 if (gamemode == GAME_ROGUE)
1341 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_rockets1);
1345 if (sv_player->v.weapon <= IT_LIGHTNING)
1346 sv_player->v.ammo_rockets = v;
1351 sv_player->v.ammo_rockets = v;
1355 if (gamemode == GAME_ROGUE)
1357 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_multi_rockets);
1361 if (sv_player->v.weapon > IT_LIGHTNING)
1362 sv_player->v.ammo_rockets = v;
1367 sv_player->v.health = v;
1370 if (gamemode == GAME_ROGUE)
1372 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_cells1);
1376 if (sv_player->v.weapon <= IT_LIGHTNING)
1377 sv_player->v.ammo_cells = v;
1382 sv_player->v.ammo_cells = v;
1386 if (gamemode == GAME_ROGUE)
1388 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_plasma);
1392 if (sv_player->v.weapon > IT_LIGHTNING)
1393 sv_player->v.ammo_cells = v;
1400 edict_t *FindViewthing (void)
1405 for (i=0 ; i<sv.num_edicts ; i++)
1408 if ( !strcmp (pr_strings + e->v.classname, "viewthing") )
1411 Con_Printf ("No viewthing on map\n");
1420 void Host_Viewmodel_f (void)
1425 e = FindViewthing ();
1429 m = Mod_ForName (Cmd_Argv(1), false, true, false);
1432 Con_Printf ("Can't load %s\n", Cmd_Argv(1));
1437 cl.model_precache[(int)e->v.modelindex] = m;
1445 void Host_Viewframe_f (void)
1451 e = FindViewthing ();
1454 m = cl.model_precache[(int)e->v.modelindex];
1456 f = atoi(Cmd_Argv(1));
1457 if (f >= m->numframes)
1464 void PrintFrameName (model_t *m, int frame)
1467 Con_Printf("frame %i: %s\n", frame, m->animscenes[frame].name);
1469 Con_Printf("frame %i\n", frame);
1477 void Host_Viewnext_f (void)
1482 e = FindViewthing ();
1485 m = cl.model_precache[(int)e->v.modelindex];
1487 e->v.frame = e->v.frame + 1;
1488 if (e->v.frame >= m->numframes)
1489 e->v.frame = m->numframes - 1;
1491 PrintFrameName (m, e->v.frame);
1499 void Host_Viewprev_f (void)
1504 e = FindViewthing ();
1508 m = cl.model_precache[(int)e->v.modelindex];
1510 e->v.frame = e->v.frame - 1;
1514 PrintFrameName (m, e->v.frame);
1518 ===============================================================================
1522 ===============================================================================
1531 void Host_Startdemos_f (void)
1535 if (cls.state == ca_dedicated)
1538 Cbuf_AddText ("map start\n");
1545 Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS);
1548 Con_Printf ("%i demo(s) in loop\n", c);
1550 for (i=1 ; i<c+1 ; i++)
1551 strncpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0])-1);
1553 if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1567 Return to looping demos
1570 void Host_Demos_f (void)
1572 if (cls.state == ca_dedicated)
1574 if (cls.demonum == -1)
1584 Return to looping demos
1587 void Host_Stopdemo_f (void)
1589 if (!cls.demoplayback)
1594 //=============================================================================
1601 void Host_InitCommands (void)
1603 Cmd_AddCommand ("status", Host_Status_f);
1604 Cmd_AddCommand ("quit", Host_Quit_f);
1605 if (gamemode == GAME_NEHAHRA)
1607 Cmd_AddCommand ("max", Host_God_f);
1608 Cmd_AddCommand ("monster", Host_Notarget_f);
1609 Cmd_AddCommand ("scrag", Host_Fly_f);
1610 Cmd_AddCommand ("wraith", Host_Noclip_f);
1611 Cmd_AddCommand ("gimme", Host_Give_f);
1615 Cmd_AddCommand ("god", Host_God_f);
1616 Cmd_AddCommand ("notarget", Host_Notarget_f);
1617 Cmd_AddCommand ("fly", Host_Fly_f);
1618 Cmd_AddCommand ("noclip", Host_Noclip_f);
1619 Cmd_AddCommand ("give", Host_Give_f);
1621 Cmd_AddCommand ("map", Host_Map_f);
1622 Cmd_AddCommand ("restart", Host_Restart_f);
1623 Cmd_AddCommand ("changelevel", Host_Changelevel_f);
1624 Cmd_AddCommand ("connect", Host_Connect_f);
1625 Cmd_AddCommand ("reconnect", Host_Reconnect_f);
1626 Cmd_AddCommand ("name", Host_Name_f);
1627 Cmd_AddCommand ("version", Host_Version_f);
1628 Cmd_AddCommand ("say", Host_Say_f);
1629 Cmd_AddCommand ("say_team", Host_Say_Team_f);
1630 Cmd_AddCommand ("tell", Host_Tell_f);
1631 Cmd_AddCommand ("color", Host_Color_f);
1632 Cmd_AddCommand ("kill", Host_Kill_f);
1633 Cmd_AddCommand ("pause", Host_Pause_f);
1634 Cmd_AddCommand ("spawn", Host_Spawn_f);
1635 Cmd_AddCommand ("begin", Host_Begin_f);
1636 Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
1637 Cmd_AddCommand ("kick", Host_Kick_f);
1638 Cmd_AddCommand ("ping", Host_Ping_f);
1639 Cmd_AddCommand ("load", Host_Loadgame_f);
1640 Cmd_AddCommand ("save", Host_Savegame_f);
1642 Cmd_AddCommand ("startdemos", Host_Startdemos_f);
1643 Cmd_AddCommand ("demos", Host_Demos_f);
1644 Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
1646 Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
1647 Cmd_AddCommand ("viewframe", Host_Viewframe_f);
1648 Cmd_AddCommand ("viewnext", Host_Viewnext_f);
1649 Cmd_AddCommand ("viewprev", Host_Viewprev_f);