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);
29 dfunction_t *ED_FindFunction (char *name);
37 // LordHavoc: didn't like it asking me if I wanted to quit
38 //extern void M_Menu_Quit_f (void);
40 void Host_Quit_f (void)
43 if (key_dest != key_console && cls.state != ca_dedicated)
50 Host_ShutdownServer(false);
61 void Host_Status_f (void)
68 void (*print) (char *fmt, ...);
70 if (cmd_source == src_command)
74 Cmd_ForwardToServer ();
80 print = SV_ClientPrintf;
82 print ("host: %s\n", Cvar_VariableString ("hostname"));
83 print ("version: %4.2f (build %i)\n", VERSION, buildnumber);
85 print ("tcp/ip: %s\n", my_tcpip_address);
87 print ("ipx: %s\n", my_ipx_address);
88 print ("map: %s\n", sv.name);
89 print ("players: %i active (%i max)\n\n", net_activeconnections, svs.maxclients);
90 for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
94 seconds = (int)(net_time - client->netconnection->connecttime);
95 minutes = seconds / 60;
98 seconds -= (minutes * 60);
101 minutes -= (hours * 60);
105 print ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->v.frags, hours, minutes, seconds);
106 print (" %s\n", client->netconnection->address);
115 Sets client to godmode
118 void Host_God_f (void)
120 if (cmd_source == src_command)
122 Cmd_ForwardToServer ();
126 if (pr_global_struct->deathmatch)
129 sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
130 if (!((int)sv_player->v.flags & FL_GODMODE) )
131 SV_ClientPrintf ("godmode OFF\n");
133 SV_ClientPrintf ("godmode ON\n");
136 void Host_Notarget_f (void)
138 if (cmd_source == src_command)
140 Cmd_ForwardToServer ();
144 if (pr_global_struct->deathmatch)
147 sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
148 if (!((int)sv_player->v.flags & FL_NOTARGET) )
149 SV_ClientPrintf ("notarget OFF\n");
151 SV_ClientPrintf ("notarget ON\n");
154 qboolean noclip_anglehack;
156 void Host_Noclip_f (void)
158 if (cmd_source == src_command)
160 Cmd_ForwardToServer ();
164 if (pr_global_struct->deathmatch)
167 if (sv_player->v.movetype != MOVETYPE_NOCLIP)
169 noclip_anglehack = true;
170 sv_player->v.movetype = MOVETYPE_NOCLIP;
171 SV_ClientPrintf ("noclip ON\n");
175 noclip_anglehack = false;
176 sv_player->v.movetype = MOVETYPE_WALK;
177 SV_ClientPrintf ("noclip OFF\n");
185 Sets client to flymode
188 void Host_Fly_f (void)
190 if (cmd_source == src_command)
192 Cmd_ForwardToServer ();
196 if (pr_global_struct->deathmatch)
199 if (sv_player->v.movetype != MOVETYPE_FLY)
201 sv_player->v.movetype = MOVETYPE_FLY;
202 SV_ClientPrintf ("flymode ON\n");
206 sv_player->v.movetype = MOVETYPE_WALK;
207 SV_ClientPrintf ("flymode OFF\n");
218 void Host_Ping_f (void)
224 if (cmd_source == src_command)
226 Cmd_ForwardToServer ();
230 SV_ClientPrintf ("Client ping times:\n");
231 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
236 for (j=0 ; j<NUM_PING_TIMES ; j++)
237 total+=client->ping_times[j];
238 total /= NUM_PING_TIMES;
239 SV_ClientPrintf ("%4i %s\n", (int)(total*1000), client->name);
244 ===============================================================================
248 ===============================================================================
253 ======================
258 command from the console. Active clients are kicked off.
259 ======================
261 void Host_Map_f (void)
264 char name[MAX_QPATH];
266 if (cmd_source != src_command)
269 cls.demonum = -1; // stop demo loop in case this fails
272 Host_ShutdownServer(false);
274 key_dest = key_game; // remove console or menu
275 SCR_BeginLoadingPlaque ();
277 cls.mapstring[0] = 0;
278 for (i=0 ; i<Cmd_Argc() ; i++)
280 strcat (cls.mapstring, Cmd_Argv(i));
281 strcat (cls.mapstring, " ");
283 strcat (cls.mapstring, "\n");
285 svs.serverflags = 0; // haven't completed an episode yet
286 strcpy (name, Cmd_Argv(1));
287 SV_SpawnServer (name);
291 if (cls.state != ca_dedicated)
293 strcpy (cls.spawnparms, "");
295 for (i=2 ; i<Cmd_Argc() ; i++)
297 strcat (cls.spawnparms, Cmd_Argv(i));
298 strcat (cls.spawnparms, " ");
301 Cmd_ExecuteString ("connect local", src_command);
309 Goes to a new map, taking all clients along
312 void Host_Changelevel_f (void)
314 char level[MAX_QPATH];
318 Con_Printf ("changelevel <levelname> : continue game on a new level\n");
321 if (!sv.active || cls.demoplayback)
323 Con_Printf ("Only the server may changelevel\n");
326 SV_SaveSpawnparms ();
327 strcpy (level, Cmd_Argv(1));
328 SV_SpawnServer (level);
335 Restarts the current server for a dead player
338 void Host_Restart_f (void)
340 char mapname[MAX_QPATH];
342 if (cls.demoplayback || !sv.active)
345 if (cmd_source != src_command)
347 strcpy (mapname, sv.name); // must copy out, because it gets cleared
349 SV_SpawnServer (mapname);
356 This command causes the client to wait for the signon messages again.
357 This is sent just before a server changes levels
360 void Host_Reconnect_f (void)
362 SCR_BeginLoadingPlaque ();
363 cls.signon = 0; // need new connection messages
367 =====================
370 User command to connect to server
371 =====================
373 void Host_Connect_f (void)
375 char name[MAX_QPATH];
377 cls.demonum = -1; // stop demo loop in case this fails
378 if (cls.demoplayback)
383 strcpy (name, Cmd_Argv(1));
384 CL_EstablishConnection (name);
390 ===============================================================================
394 ===============================================================================
397 #define SAVEGAME_VERSION 5
403 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
406 void Host_SavegameComment (char *text)
411 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
413 memcpy (text, cl.levelname, strlen(cl.levelname));
414 sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
415 memcpy (text+22, kills, strlen(kills));
416 // convert space to _ to make stdio happy
417 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
420 text[SAVEGAME_COMMENT_LENGTH] = '\0';
429 void Host_Savegame_f (void)
434 char comment[SAVEGAME_COMMENT_LENGTH+1];
436 if (cmd_source != src_command)
441 Con_Printf ("Not playing a local game.\n");
447 Con_Printf ("Can't save in intermission.\n");
451 if (svs.maxclients != 1)
453 Con_Printf ("Can't save multiplayer games.\n");
459 Con_Printf ("save <savename> : save a game\n");
463 if (strstr(Cmd_Argv(1), ".."))
465 Con_Printf ("Relative pathnames are not allowed.\n");
469 for (i=0 ; i<svs.maxclients ; i++)
471 if (svs.clients[i].active && (svs.clients[i].edict->v.health <= 0) )
473 Con_Printf ("Can't savegame with a dead player\n");
478 sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
479 COM_DefaultExtension (name, ".sav");
481 Con_Printf ("Saving game to %s...\n", name);
482 f = fopen (name, "w");
485 Con_Printf ("ERROR: couldn't open.\n");
489 fprintf (f, "%i\n", SAVEGAME_VERSION);
490 Host_SavegameComment (comment);
491 fprintf (f, "%s\n", comment);
492 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
493 fprintf (f, "%f\n", svs.clients->spawn_parms[i]);
494 fprintf (f, "%d\n", current_skill);
495 fprintf (f, "%s\n", sv.name);
496 fprintf (f, "%f\n",sv.time);
498 // write the light styles
500 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
502 if (sv.lightstyles[i])
503 fprintf (f, "%s\n", sv.lightstyles[i]);
510 for (i=0 ; i<sv.num_edicts ; i++)
512 ED_Write (f, EDICT_NUM(i));
516 Con_Printf ("done.\n");
525 void Host_Loadgame_f (void)
527 char name[MAX_OSPATH];
529 char mapname[MAX_QPATH];
531 char str[32768], *start;
536 float spawn_parms[NUM_SPAWN_PARMS];
538 if (cmd_source != src_command)
543 Con_Printf ("load <savename> : load a game\n");
547 cls.demonum = -1; // stop demo loop in case this fails
549 sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
550 COM_DefaultExtension (name, ".sav");
552 // we can't call SCR_BeginLoadingPlaque, because too much stack space has
553 // been used. The menu calls it before stuffing loadgame command
554 // SCR_BeginLoadingPlaque ();
556 Con_Printf ("Loading game from %s...\n", name);
557 f = fopen (name, "r");
560 Con_Printf ("ERROR: couldn't open.\n");
564 fscanf (f, "%i\n", &version);
565 if (version != SAVEGAME_VERSION)
568 Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
571 fscanf (f, "%s\n", str);
572 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
573 fscanf (f, "%f\n", &spawn_parms[i]);
574 // this silliness is so we can load 1.06 save files, which have float skill values
575 fscanf (f, "%f\n", &tfloat);
576 current_skill = (int)(tfloat + 0.1);
577 Cvar_SetValue ("skill", (float)current_skill);
579 fscanf (f, "%s\n",mapname);
580 fscanf (f, "%f\n",&time);
584 SV_SpawnServer (mapname);
587 Con_Printf ("Couldn't load map\n");
590 sv.paused = true; // pause until all clients connect
593 // load the light styles
595 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
597 fscanf (f, "%s\n", str);
598 sv.lightstyles[i] = Hunk_AllocName (strlen(str)+1, "lightstyles");
599 strcpy (sv.lightstyles[i], str);
602 // load the edicts out of the savegame file
603 entnum = -1; // -1 is the globals
606 for (i=0 ; i<sizeof(str)-1 ; i++)
618 if (i == sizeof(str)-1)
619 Sys_Error ("Loadgame buffer overflow");
622 start = COM_Parse(str);
624 break; // end of file
625 if (strcmp(com_token,"{"))
626 Sys_Error ("First token isn't a brace");
629 { // parse the global vars
630 ED_ParseGlobals (start);
635 ent = EDICT_NUM(entnum);
636 memset (&ent->v, 0, progs->entityfields * 4);
638 ED_ParseEdict (start, ent);
640 // link it into the bsp tree
642 SV_LinkEdict (ent, false);
648 sv.num_edicts = entnum;
653 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
654 svs.clients->spawn_parms[i] = spawn_parms[i];
656 if (cls.state != ca_dedicated)
658 CL_EstablishConnection ("local");
663 //============================================================================
666 ======================
668 ======================
670 void Host_Name_f (void)
674 if (Cmd_Argc () == 1)
676 Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
679 if (Cmd_Argc () == 2)
680 newName = Cmd_Argv(1);
682 newName = Cmd_Args();
685 if (cmd_source == src_command)
687 if (strcmp(cl_name.string, newName) == 0)
689 Cvar_Set ("_cl_name", newName);
690 if (cls.state == ca_connected)
691 Cmd_ForwardToServer ();
695 if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
696 if (strcmp(host_client->name, newName) != 0)
697 Con_Printf ("%s renamed to %s\n", host_client->name, newName);
698 strcpy (host_client->name, newName);
699 host_client->edict->v.netname = host_client->name - pr_strings;
701 // send notification to all clients
703 MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
704 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
705 MSG_WriteString (&sv.reliable_datagram, host_client->name);
709 void Host_Version_f (void)
711 Con_Printf ("Version %4.2f (build %i)\n", VERSION, buildnumber);
712 Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
715 void Host_Say(qboolean teamonly)
721 // LordHavoc: 256 char say messages
722 unsigned char text[256];
723 qboolean fromServer = false;
725 if (cmd_source == src_command)
727 if (cls.state == ca_dedicated)
734 Cmd_ForwardToServer ();
745 // remove quotes if present
752 // turn on color set 1
754 sprintf (text, "%c%s: ", 1, save->name);
756 sprintf (text, "%c<%s> ", 1, hostname.string);
758 j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator
765 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
767 if (!client || !client->active || !client->spawned)
769 if (teamplay.value && teamonly && client->edict->v.team != save->edict->v.team)
771 host_client = client;
772 SV_ClientPrintf("%s", text);
776 Sys_Printf("%s", &text[1]);
780 void Host_Say_f(void)
786 void Host_Say_Team_f(void)
792 void Host_Tell_f(void)
798 char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
800 if (cmd_source == src_command)
802 Cmd_ForwardToServer ();
809 strcpy(text, host_client->name);
814 // remove quotes if present
821 // check length & truncate if necessary
822 j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator
830 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
832 if (!client->active || !client->spawned)
834 if (Q_strcasecmp(client->name, Cmd_Argv(1)))
836 host_client = client;
837 SV_ClientPrintf("%s", text);
849 void Host_Color_f(void)
854 func_t SV_ChangeTeam;
858 Con_Printf ("\"color\" is \"%i %i\"\n", ((int)cl_color.value) >> 4, ((int)cl_color.value) & 0x0f);
859 Con_Printf ("color <0-13> [0-13]\n");
864 top = bottom = atoi(Cmd_Argv(1));
867 top = atoi(Cmd_Argv(1));
868 bottom = atoi(Cmd_Argv(2));
872 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
876 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
880 playercolor = top*16 + bottom;
882 if (cmd_source == src_command)
884 Cvar_SetValue ("_cl_color", playercolor);
885 if (cls.state == ca_connected)
886 Cmd_ForwardToServer ();
890 // void(float color) SV_ChangeTeam;
891 if ((f = ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - pr_functions)))
893 Con_DPrintf("Calling SV_ChangeTeam\n");
894 pr_global_struct->time = sv.time;
895 pr_globals[0] = playercolor;
896 pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
897 PR_ExecuteProgram (SV_ChangeTeam, "");
901 host_client->colors = playercolor;
902 host_client->edict->v.team = bottom + 1;
904 // send notification to all clients
905 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
906 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
907 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
916 void Host_Kill_f (void)
918 if (cmd_source == src_command)
920 Cmd_ForwardToServer ();
924 if (sv_player->v.health <= 0)
926 SV_ClientPrintf ("Can't suicide -- allready dead!\n");
930 pr_global_struct->time = sv.time;
931 pr_global_struct->self = EDICT_TO_PROG(sv_player);
932 PR_ExecuteProgram (pr_global_struct->ClientKill, "QC function ClientKill is missing");
941 void Host_Pause_f (void)
944 if (cmd_source == src_command)
946 Cmd_ForwardToServer ();
950 SV_ClientPrintf ("Pause not allowed.\n");
957 SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v.netname);
961 SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v.netname);
964 // send notification to all clients
965 MSG_WriteByte (&sv.reliable_datagram, svc_setpause);
966 MSG_WriteByte (&sv.reliable_datagram, sv.paused);
970 //===========================================================================
978 void Host_PreSpawn_f (void)
980 if (cmd_source == src_command)
982 Con_Printf ("prespawn is not valid from the console\n");
986 if (host_client->spawned)
988 Con_Printf ("prespawn not valid -- allready spawned\n");
992 SZ_Write (&host_client->message, sv.signon.data, sv.signon.cursize);
993 MSG_WriteByte (&host_client->message, svc_signonnum);
994 MSG_WriteByte (&host_client->message, 2);
995 host_client->sendsignon = true;
1003 void Host_Spawn_f (void)
1011 if (cmd_source == src_command)
1013 Con_Printf ("spawn is not valid from the console\n");
1017 if (host_client->spawned)
1019 Con_Printf ("Spawn not valid -- allready spawned\n");
1023 // LordHavoc: moved this above the QC calls at FrikaC's request
1024 // send all current names, colors, and frag counts
1025 SZ_Clear (&host_client->message);
1027 // run the entrance script
1029 { // loaded games are fully inited allready
1030 // if this is the last client to be connected, unpause
1033 if ((f = ED_FindFunction ("RestoreGame")))
1034 if ((RestoreGame = (func_t)(f - pr_functions)))
1036 Con_DPrintf("Calling RestoreGame\n");
1037 pr_global_struct->time = sv.time;
1038 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1039 PR_ExecuteProgram (RestoreGame, "");
1046 ent = host_client->edict;
1048 memset (&ent->v, 0, progs->entityfields * 4);
1049 ent->v.colormap = NUM_FOR_EDICT(ent);
1050 ent->v.team = (host_client->colors & 15) + 1;
1051 ent->v.netname = host_client->name - pr_strings;
1052 if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1053 val->_float = host_client->pmodel;
1055 // copy spawn parms out of the client_t
1057 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1058 (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
1060 // call the spawn function
1062 pr_global_struct->time = sv.time;
1063 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1064 PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
1066 if ((Sys_FloatTime() - host_client->netconnection->connecttime) <= sv.time)
1067 Sys_Printf ("%s entered the game\n", host_client->name);
1069 PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing");
1073 // send time of update
1074 MSG_WriteByte (&host_client->message, svc_time);
1075 MSG_WriteFloat (&host_client->message, sv.time);
1077 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
1079 MSG_WriteByte (&host_client->message, svc_updatename);
1080 MSG_WriteByte (&host_client->message, i);
1081 MSG_WriteString (&host_client->message, client->name);
1082 MSG_WriteByte (&host_client->message, svc_updatefrags);
1083 MSG_WriteByte (&host_client->message, i);
1084 MSG_WriteShort (&host_client->message, client->old_frags);
1085 MSG_WriteByte (&host_client->message, svc_updatecolors);
1086 MSG_WriteByte (&host_client->message, i);
1087 MSG_WriteByte (&host_client->message, client->colors);
1090 // send all current light styles
1091 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1093 MSG_WriteByte (&host_client->message, svc_lightstyle);
1094 MSG_WriteByte (&host_client->message, (char)i);
1095 MSG_WriteString (&host_client->message, sv.lightstyles[i]);
1101 MSG_WriteByte (&host_client->message, svc_updatestat);
1102 MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS);
1103 MSG_WriteLong (&host_client->message, pr_global_struct->total_secrets);
1105 MSG_WriteByte (&host_client->message, svc_updatestat);
1106 MSG_WriteByte (&host_client->message, STAT_TOTALMONSTERS);
1107 MSG_WriteLong (&host_client->message, pr_global_struct->total_monsters);
1109 MSG_WriteByte (&host_client->message, svc_updatestat);
1110 MSG_WriteByte (&host_client->message, STAT_SECRETS);
1111 MSG_WriteLong (&host_client->message, pr_global_struct->found_secrets);
1113 MSG_WriteByte (&host_client->message, svc_updatestat);
1114 MSG_WriteByte (&host_client->message, STAT_MONSTERS);
1115 MSG_WriteLong (&host_client->message, pr_global_struct->killed_monsters);
1119 // Never send a roll angle, because savegames can catch the server
1120 // in a state where it is expecting the client to correct the angle
1121 // and it won't happen if the game was just loaded, so you wind up
1122 // with a permanent head tilt
1123 ent = EDICT_NUM( 1 + (host_client - svs.clients) );
1124 MSG_WriteByte (&host_client->message, svc_setangle);
1125 for (i=0 ; i < 2 ; i++)
1126 MSG_WriteAngle (&host_client->message, ent->v.angles[i] );
1127 MSG_WriteAngle (&host_client->message, 0 );
1129 SV_WriteClientdataToMessage (sv_player, &host_client->message);
1131 MSG_WriteByte (&host_client->message, svc_signonnum);
1132 MSG_WriteByte (&host_client->message, 3);
1133 host_client->sendsignon = true;
1141 void Host_Begin_f (void)
1143 if (cmd_source == src_command)
1145 Con_Printf ("begin is not valid from the console\n");
1149 host_client->spawned = true;
1152 //===========================================================================
1159 Kicks a user off of the server
1162 void Host_Kick_f (void)
1165 char *message = NULL;
1168 qboolean byNumber = false;
1170 if (cmd_source == src_command)
1174 Cmd_ForwardToServer ();
1178 else if (pr_global_struct->deathmatch)
1183 if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1185 i = atof(Cmd_Argv(2)) - 1;
1186 if (i < 0 || i >= svs.maxclients)
1188 if (!svs.clients[i].active)
1190 host_client = &svs.clients[i];
1195 for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
1197 if (!host_client->active)
1199 if (Q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1204 if (i < svs.maxclients)
1206 if (cmd_source == src_command)
1207 if (cls.state == ca_dedicated)
1210 who = cl_name.string;
1214 // can't kick yourself!
1215 if (host_client == save)
1220 message = COM_Parse(Cmd_Args());
1223 message++; // skip the #
1224 while (*message == ' ') // skip white space
1226 message += strlen(Cmd_Argv(2)); // skip the number
1228 while (*message && *message == ' ')
1232 SV_ClientPrintf ("Kicked by %s: %s\n", who, message);
1234 SV_ClientPrintf ("Kicked by %s\n", who);
1235 SV_DropClient (false);
1242 ===============================================================================
1246 ===============================================================================
1254 void Host_Give_f (void)
1260 if (cmd_source == src_command)
1262 Cmd_ForwardToServer ();
1266 if (pr_global_struct->deathmatch)
1270 v = atoi (Cmd_Argv(2));
1284 // MED 01/04/97 added hipnotic give stuff
1290 sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN;
1292 sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER;
1294 else if (t[0] == '9')
1295 sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON;
1296 else if (t[0] == '0')
1297 sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR;
1298 else if (t[0] >= '2')
1299 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1304 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1311 if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1)))
1315 sv_player->v.ammo_shells = v;
1320 if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1)))
1323 if (sv_player->v.weapon <= IT_LIGHTNING)
1324 sv_player->v.ammo_nails = v;
1329 sv_player->v.ammo_nails = v;
1335 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_lava_nails);
1339 if (sv_player->v.weapon > IT_LIGHTNING)
1340 sv_player->v.ammo_nails = v;
1347 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_rockets1);
1351 if (sv_player->v.weapon <= IT_LIGHTNING)
1352 sv_player->v.ammo_rockets = v;
1357 sv_player->v.ammo_rockets = v;
1363 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_multi_rockets);
1367 if (sv_player->v.weapon > IT_LIGHTNING)
1368 sv_player->v.ammo_rockets = v;
1373 sv_player->v.health = v;
1378 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_cells1);
1382 if (sv_player->v.weapon <= IT_LIGHTNING)
1383 sv_player->v.ammo_cells = v;
1388 sv_player->v.ammo_cells = v;
1394 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_plasma);
1398 if (sv_player->v.weapon > IT_LIGHTNING)
1399 sv_player->v.ammo_cells = v;
1406 edict_t *FindViewthing (void)
1411 for (i=0 ; i<sv.num_edicts ; i++)
1414 if ( !strcmp (pr_strings + e->v.classname, "viewthing") )
1417 Con_Printf ("No viewthing on map\n");
1426 void Host_Viewmodel_f (void)
1431 e = FindViewthing ();
1435 m = Mod_ForName (Cmd_Argv(1), false);
1438 Con_Printf ("Can't load %s\n", Cmd_Argv(1));
1443 cl.model_precache[(int)e->v.modelindex] = m;
1451 void Host_Viewframe_f (void)
1457 e = FindViewthing ();
1460 m = cl.model_precache[(int)e->v.modelindex];
1462 f = atoi(Cmd_Argv(1));
1463 if (f >= m->numframes)
1470 void PrintFrameName (model_t *m, int frame)
1472 if (m->type != mod_alias)
1474 switch(m->aliastype)
1478 maliashdr_t *mheader;
1479 maliasframe_t *frameinfo;
1481 mheader = (maliashdr_t *)Mod_Extradata (m);
1484 if (frame < 0 || frame >= mheader->numframes)
1486 frameinfo = &((maliasframe_t *)(mheader->framedata + (int) mheader))[frame];
1488 Con_Printf ("frame %i: %s\n", frame, frameinfo->name);
1494 md2memframe_t *frameinfo;
1496 mheader = (md2mem_t *)Mod_Extradata (m);
1499 if (frame < 0 || frame >= mheader->num_frames)
1501 frameinfo = (md2memframe_t *)(mheader->ofs_frames + (int) mheader) + frame;
1503 Con_Printf ("frame %i: %s\n", frame, frameinfo->name);
1508 zymtype1header_t *mheader;
1511 mheader = (zymtype1header_t *)Mod_Extradata (m);
1514 if (frame < 0 || frame >= mheader->numscenes)
1516 scene = (zymscene_t *)(mheader->lump_scenes.start + (int) mheader) + frame;
1518 Con_Printf ("frame %i: %s\n", frame, scene->name);
1522 Con_Printf("frame %i: (unknown alias model type)\n", frame);
1532 void Host_Viewnext_f (void)
1537 e = FindViewthing ();
1540 m = cl.model_precache[(int)e->v.modelindex];
1542 e->v.frame = e->v.frame + 1;
1543 if (e->v.frame >= m->numframes)
1544 e->v.frame = m->numframes - 1;
1546 PrintFrameName (m, e->v.frame);
1554 void Host_Viewprev_f (void)
1559 e = FindViewthing ();
1563 m = cl.model_precache[(int)e->v.modelindex];
1565 e->v.frame = e->v.frame - 1;
1569 PrintFrameName (m, e->v.frame);
1573 ===============================================================================
1577 ===============================================================================
1586 void Host_Startdemos_f (void)
1590 if (cls.state == ca_dedicated)
1593 Cbuf_AddText ("map start\n");
1600 Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS);
1603 Con_Printf ("%i demo(s) in loop\n", c);
1605 for (i=1 ; i<c+1 ; i++)
1606 strncpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0])-1);
1608 if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1622 Return to looping demos
1625 void Host_Demos_f (void)
1627 if (cls.state == ca_dedicated)
1629 if (cls.demonum == -1)
1639 Return to looping demos
1642 void Host_Stopdemo_f (void)
1644 if (cls.state == ca_dedicated)
1646 if (!cls.demoplayback)
1652 //=============================================================================
1659 void Host_InitCommands (void)
1661 Cmd_AddCommand ("status", Host_Status_f);
1662 Cmd_AddCommand ("quit", Host_Quit_f);
1665 Cmd_AddCommand ("max", Host_God_f);
1666 Cmd_AddCommand ("monster", Host_Notarget_f);
1667 Cmd_AddCommand ("scrag", Host_Fly_f);
1668 Cmd_AddCommand ("wraith", Host_Noclip_f);
1669 Cmd_AddCommand ("gimme", Host_Give_f);
1673 Cmd_AddCommand ("god", Host_God_f);
1674 Cmd_AddCommand ("notarget", Host_Notarget_f);
1675 Cmd_AddCommand ("fly", Host_Fly_f);
1676 Cmd_AddCommand ("noclip", Host_Noclip_f);
1677 Cmd_AddCommand ("give", Host_Give_f);
1679 Cmd_AddCommand ("map", Host_Map_f);
1680 Cmd_AddCommand ("restart", Host_Restart_f);
1681 Cmd_AddCommand ("changelevel", Host_Changelevel_f);
1682 Cmd_AddCommand ("connect", Host_Connect_f);
1683 Cmd_AddCommand ("reconnect", Host_Reconnect_f);
1684 Cmd_AddCommand ("name", Host_Name_f);
1685 Cmd_AddCommand ("version", Host_Version_f);
1686 Cmd_AddCommand ("say", Host_Say_f);
1687 Cmd_AddCommand ("say_team", Host_Say_Team_f);
1688 Cmd_AddCommand ("tell", Host_Tell_f);
1689 Cmd_AddCommand ("color", Host_Color_f);
1690 Cmd_AddCommand ("kill", Host_Kill_f);
1691 Cmd_AddCommand ("pause", Host_Pause_f);
1692 Cmd_AddCommand ("spawn", Host_Spawn_f);
1693 Cmd_AddCommand ("begin", Host_Begin_f);
1694 Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
1695 Cmd_AddCommand ("kick", Host_Kick_f);
1696 Cmd_AddCommand ("ping", Host_Ping_f);
1697 Cmd_AddCommand ("load", Host_Loadgame_f);
1698 Cmd_AddCommand ("save", Host_Savegame_f);
1700 Cmd_AddCommand ("startdemos", Host_Startdemos_f);
1701 Cmd_AddCommand ("demos", Host_Demos_f);
1702 Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
1704 Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
1705 Cmd_AddCommand ("viewframe", Host_Viewframe_f);
1706 Cmd_AddCommand ("viewnext", Host_Viewnext_f);
1707 Cmd_AddCommand ("viewprev", Host_Viewprev_f);
1709 Cmd_AddCommand ("mcache", Mod_Print);