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 // LordHavoc: didn't like it asking me if I wanted to quit
34 //extern void M_Menu_Quit_f (void);
36 extern qboolean host_shuttingdown;
37 void Host_Quit_f (void)
40 if (key_dest != key_console && cls.state != ca_dedicated)
46 host_shuttingdown = true;
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: %s build %s\n", gamename, buildstring);
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)
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)
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)
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)
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
269 // SCR_BeginLoadingPlaque ();
272 Host_ShutdownServer(false);
274 key_dest = key_game; // remove console or menu
276 cls.mapstring[0] = 0;
277 for (i=0 ; i<Cmd_Argc() ; i++)
279 strcat (cls.mapstring, Cmd_Argv(i));
280 strcat (cls.mapstring, " ");
282 strcat (cls.mapstring, "\n");
284 svs.serverflags = 0; // haven't completed an episode yet
285 strcpy (name, Cmd_Argv(1));
286 SV_SpawnServer (name);
290 if (cls.state != ca_dedicated)
292 strcpy (cls.spawnparms, "");
294 for (i=2 ; i<Cmd_Argc() ; i++)
296 strcat (cls.spawnparms, Cmd_Argv(i));
297 strcat (cls.spawnparms, " ");
300 Cmd_ExecuteString ("connect local", src_command);
308 Goes to a new map, taking all clients along
311 void Host_Changelevel_f (void)
313 char level[MAX_QPATH];
317 Con_Printf ("changelevel <levelname> : continue game on a new level\n");
320 if (!sv.active || cls.demoplayback)
322 Con_Printf ("Only the server may changelevel\n");
325 SV_SaveSpawnparms ();
326 strcpy (level, Cmd_Argv(1));
327 SV_SpawnServer (level);
334 Restarts the current server for a dead player
337 void Host_Restart_f (void)
339 char mapname[MAX_QPATH];
341 if (cls.demoplayback || !sv.active)
344 if (cmd_source != src_command)
346 strcpy (mapname, sv.name); // must copy out, because it gets cleared
348 SV_SpawnServer (mapname);
355 This command causes the client to wait for the signon messages again.
356 This is sent just before a server changes levels
359 void Host_Reconnect_f (void)
361 // SCR_BeginLoadingPlaque ();
362 cls.signon = 0; // need new connection messages
366 =====================
369 User command to connect to server
370 =====================
372 void Host_Connect_f (void)
374 char name[MAX_QPATH];
376 cls.demonum = -1; // stop demo loop in case this fails
377 if (cls.demoplayback)
379 strcpy (name, Cmd_Argv(1));
380 CL_EstablishConnection (name);
386 ===============================================================================
390 ===============================================================================
393 #define SAVEGAME_VERSION 5
399 Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
402 void Host_SavegameComment (char *text)
407 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
409 memcpy (text, cl.levelname, strlen(cl.levelname));
410 sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
411 memcpy (text+22, kills, strlen(kills));
412 // convert space to _ to make stdio happy
413 for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
416 text[SAVEGAME_COMMENT_LENGTH] = '\0';
425 void Host_Savegame_f (void)
430 char comment[SAVEGAME_COMMENT_LENGTH+1];
432 if (cmd_source != src_command)
437 Con_Printf ("Not playing a local game.\n");
443 Con_Printf ("Can't save in intermission.\n");
447 if (svs.maxclients != 1)
449 Con_Printf ("Can't save multiplayer games.\n");
455 Con_Printf ("save <savename> : save a game\n");
459 if (strstr(Cmd_Argv(1), ".."))
461 Con_Printf ("Relative pathnames are not allowed.\n");
465 for (i=0 ; i<svs.maxclients ; i++)
467 if (svs.clients[i].active && (svs.clients[i].edict->v.health <= 0) )
469 Con_Printf ("Can't savegame with a dead player\n");
474 sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
475 COM_DefaultExtension (name, ".sav");
477 Con_Printf ("Saving game to %s...\n", name);
478 f = Qopen (name, "w");
481 Con_Printf ("ERROR: couldn't open.\n");
485 Qprintf (f, "%i\n", SAVEGAME_VERSION);
486 Host_SavegameComment (comment);
487 Qprintf (f, "%s\n", comment);
488 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
489 Qprintf (f, "%f\n", svs.clients->spawn_parms[i]);
490 Qprintf (f, "%d\n", current_skill);
491 Qprintf (f, "%s\n", sv.name);
492 Qprintf (f, "%f\n",sv.time);
494 // write the light styles
496 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
498 if (sv.lightstyles[i])
499 Qprintf (f, "%s\n", sv.lightstyles[i]);
506 for (i=0 ; i<sv.num_edicts ; i++)
508 ED_Write (f, EDICT_NUM(i));
512 Con_Printf ("done.\n");
516 extern mempool_t *edictstring_mempool;
523 void Host_Loadgame_f (void)
525 char name[MAX_OSPATH];
527 char mapname[MAX_QPATH];
529 char buf[32768], *start;
535 float spawn_parms[NUM_SPAWN_PARMS];
537 if (cmd_source != src_command)
542 Con_Printf ("load <savename> : load a game\n");
546 cls.demonum = -1; // stop demo loop in case this fails
548 sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
549 COM_DefaultExtension (name, ".sav");
551 Con_Printf ("Loading game from %s...\n", name);
552 f = Qopen (name, "rz");
555 Con_Printf ("ERROR: couldn't open.\n");
560 sscanf (str, "%i\n", &version);
561 if (version != SAVEGAME_VERSION)
564 Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
568 for (i=0 ; i<NUM_SPAWN_PARMS ; i++) {
570 sscanf (str, "%f\n", &spawn_parms[i]);
572 // this silliness is so we can load 1.06 save files, which have float skill values
574 sscanf (str, "%f\n", &tfloat);
575 current_skill = (int)(tfloat + 0.1);
576 Cvar_SetValue ("skill", (float)current_skill);
578 strcpy (mapname, Qgetline (f));
581 sscanf (str, "%f\n",&time);
585 SV_SpawnServer (mapname);
588 Con_Printf ("Couldn't load map\n");
591 sv.paused = true; // pause until all clients connect
594 // load the light styles
596 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
599 sv.lightstyles[i] = Mem_Alloc(edictstring_mempool, strlen(str)+1);
600 strcpy (sv.lightstyles[i], str);
603 // load the edicts out of the savegame file
604 entnum = -1; // -1 is the globals
607 for (i=0 ; i<sizeof(buf)-1 ; i++)
619 if (i == sizeof(buf)-1)
620 Sys_Error ("Loadgame buffer overflow");
623 start = COM_Parse(buf);
625 break; // end of file
626 if (strcmp(com_token,"{"))
627 Sys_Error ("First token isn't a brace");
630 { // parse the global vars
631 ED_ParseGlobals (start);
636 ent = EDICT_NUM(entnum);
637 memset (&ent->v, 0, progs->entityfields * 4);
639 ED_ParseEdict (start, ent);
641 // link it into the bsp tree
643 SV_LinkEdict (ent, false);
649 sv.num_edicts = entnum;
654 for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
655 svs.clients->spawn_parms[i] = spawn_parms[i];
657 if (cls.state != ca_dedicated)
659 CL_EstablishConnection ("local");
664 //============================================================================
667 ======================
669 ======================
671 void Host_Name_f (void)
675 if (Cmd_Argc () == 1)
677 Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
680 //if (Cmd_Argc () == 2)
681 // newName = Cmd_Argv(1);
683 // newName = Cmd_Args();
685 if (Cmd_Argc () == 2)
686 strncpy(newName, Cmd_Argv(1), 15);
688 strncpy(newName, Cmd_Args(), 15);
691 if (cmd_source == src_command)
693 if (strcmp(cl_name.string, newName) == 0)
695 Cvar_Set ("_cl_name", newName);
696 if (cls.state == ca_connected)
697 Cmd_ForwardToServer ();
701 if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
702 if (strcmp(host_client->name, newName) != 0)
703 Con_Printf ("%s renamed to %s\n", host_client->name, newName);
704 strcpy (host_client->name, newName);
705 host_client->edict->v.netname = host_client->name - pr_strings;
707 // send notification to all clients
709 MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
710 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
711 MSG_WriteString (&sv.reliable_datagram, host_client->name);
715 void Host_Version_f (void)
717 Con_Printf ("Version: %s build %s\n", gamename, buildstring);
720 void Host_Say(qboolean teamonly)
726 // LordHavoc: 256 char say messages
727 unsigned char text[256];
728 qboolean fromServer = false;
730 if (cmd_source == src_command)
732 if (cls.state == ca_dedicated)
739 Cmd_ForwardToServer ();
750 // remove quotes if present
757 // turn on color set 1
759 sprintf (text, "%c%s: ", 1, save->name);
761 sprintf (text, "%c<%s> ", 1, hostname.string);
763 j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator
770 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
772 if (!client || !client->active || !client->spawned)
774 if (teamplay.integer && teamonly && client->edict->v.team != save->edict->v.team)
776 host_client = client;
777 SV_ClientPrintf("%s", text);
781 Sys_Printf("%s", &text[1]);
785 void Host_Say_f(void)
791 void Host_Say_Team_f(void)
797 void Host_Tell_f(void)
803 char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
805 if (cmd_source == src_command)
807 Cmd_ForwardToServer ();
814 strcpy(text, host_client->name);
819 // remove quotes if present
826 // check length & truncate if necessary
827 j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator
835 for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
837 if (!client->active || !client->spawned)
839 if (Q_strcasecmp(client->name, Cmd_Argv(1)))
841 host_client = client;
842 SV_ClientPrintf("%s", text);
854 void Host_Color_f(void)
859 func_t SV_ChangeTeam;
863 Con_Printf ("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15);
864 Con_Printf ("color <0-13> [0-13]\n");
869 top = bottom = atoi(Cmd_Argv(1));
872 top = atoi(Cmd_Argv(1));
873 bottom = atoi(Cmd_Argv(2));
877 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
881 // LordHavoc: allow skin colormaps 14 and 15 (was 13)
885 playercolor = top*16 + bottom;
887 if (cmd_source == src_command)
889 Cvar_SetValue ("_cl_color", playercolor);
890 if (cls.state == ca_connected)
891 Cmd_ForwardToServer ();
895 // void(float color) SV_ChangeTeam;
896 if ((f = ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - pr_functions)))
898 Con_DPrintf("Calling SV_ChangeTeam\n");
899 pr_global_struct->time = sv.time;
900 pr_globals[0] = playercolor;
901 pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
902 PR_ExecuteProgram (SV_ChangeTeam, "");
906 host_client->colors = playercolor;
907 host_client->edict->v.team = bottom + 1;
909 // send notification to all clients
910 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
911 MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
912 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
921 void Host_Kill_f (void)
923 if (cmd_source == src_command)
925 Cmd_ForwardToServer ();
929 if (sv_player->v.health <= 0)
931 SV_ClientPrintf ("Can't suicide -- already dead!\n");
935 pr_global_struct->time = sv.time;
936 pr_global_struct->self = EDICT_TO_PROG(sv_player);
937 PR_ExecuteProgram (pr_global_struct->ClientKill, "QC function ClientKill is missing");
946 void Host_Pause_f (void)
949 if (cmd_source == src_command)
951 Cmd_ForwardToServer ();
954 if (!pausable.integer)
955 SV_ClientPrintf ("Pause not allowed.\n");
962 SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v.netname);
966 SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v.netname);
969 // send notification to all clients
970 MSG_WriteByte (&sv.reliable_datagram, svc_setpause);
971 MSG_WriteByte (&sv.reliable_datagram, sv.paused);
975 //===========================================================================
983 void Host_PreSpawn_f (void)
985 if (cmd_source == src_command)
987 Con_Printf ("prespawn is not valid from the console\n");
991 if (host_client->spawned)
993 Con_Printf ("prespawn not valid -- already spawned\n");
997 SZ_Write (&host_client->message, sv.signon.data, sv.signon.cursize);
998 MSG_WriteByte (&host_client->message, svc_signonnum);
999 MSG_WriteByte (&host_client->message, 2);
1000 host_client->sendsignon = true;
1008 void Host_Spawn_f (void)
1016 if (cmd_source == src_command)
1018 Con_Printf ("spawn is not valid from the console\n");
1022 if (host_client->spawned)
1024 Con_Printf ("Spawn not valid -- already spawned\n");
1028 // LordHavoc: moved this above the QC calls at FrikaC's request
1029 // send all current names, colors, and frag counts
1030 SZ_Clear (&host_client->message);
1032 // run the entrance script
1034 { // loaded games are fully inited already
1035 // if this is the last client to be connected, unpause
1038 if ((f = ED_FindFunction ("RestoreGame")))
1039 if ((RestoreGame = (func_t)(f - pr_functions)))
1041 Con_DPrintf("Calling RestoreGame\n");
1042 pr_global_struct->time = sv.time;
1043 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1044 PR_ExecuteProgram (RestoreGame, "");
1051 ent = host_client->edict;
1053 memset (&ent->v, 0, progs->entityfields * 4);
1054 ent->v.colormap = NUM_FOR_EDICT(ent);
1055 ent->v.team = (host_client->colors & 15) + 1;
1056 ent->v.netname = host_client->name - pr_strings;
1057 if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
1058 val->_float = host_client->pmodel;
1060 // copy spawn parms out of the client_t
1062 for (i=0 ; i< NUM_SPAWN_PARMS ; i++)
1063 (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
1065 // call the spawn function
1067 pr_global_struct->time = sv.time;
1068 pr_global_struct->self = EDICT_TO_PROG(sv_player);
1069 PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
1071 if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= sv.time)
1072 Sys_Printf ("%s entered the game\n", host_client->name);
1074 PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing");
1078 // send time of update
1079 MSG_WriteByte (&host_client->message, svc_time);
1080 MSG_WriteFloat (&host_client->message, sv.time);
1082 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
1084 MSG_WriteByte (&host_client->message, svc_updatename);
1085 MSG_WriteByte (&host_client->message, i);
1086 MSG_WriteString (&host_client->message, client->name);
1087 MSG_WriteByte (&host_client->message, svc_updatefrags);
1088 MSG_WriteByte (&host_client->message, i);
1089 MSG_WriteShort (&host_client->message, client->old_frags);
1090 MSG_WriteByte (&host_client->message, svc_updatecolors);
1091 MSG_WriteByte (&host_client->message, i);
1092 MSG_WriteByte (&host_client->message, client->colors);
1095 // send all current light styles
1096 for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1098 MSG_WriteByte (&host_client->message, svc_lightstyle);
1099 MSG_WriteByte (&host_client->message, (char)i);
1100 MSG_WriteString (&host_client->message, sv.lightstyles[i]);
1106 MSG_WriteByte (&host_client->message, svc_updatestat);
1107 MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS);
1108 MSG_WriteLong (&host_client->message, pr_global_struct->total_secrets);
1110 MSG_WriteByte (&host_client->message, svc_updatestat);
1111 MSG_WriteByte (&host_client->message, STAT_TOTALMONSTERS);
1112 MSG_WriteLong (&host_client->message, pr_global_struct->total_monsters);
1114 MSG_WriteByte (&host_client->message, svc_updatestat);
1115 MSG_WriteByte (&host_client->message, STAT_SECRETS);
1116 MSG_WriteLong (&host_client->message, pr_global_struct->found_secrets);
1118 MSG_WriteByte (&host_client->message, svc_updatestat);
1119 MSG_WriteByte (&host_client->message, STAT_MONSTERS);
1120 MSG_WriteLong (&host_client->message, pr_global_struct->killed_monsters);
1124 // Never send a roll angle, because savegames can catch the server
1125 // in a state where it is expecting the client to correct the angle
1126 // and it won't happen if the game was just loaded, so you wind up
1127 // with a permanent head tilt
1128 ent = EDICT_NUM( 1 + (host_client - svs.clients) );
1129 MSG_WriteByte (&host_client->message, svc_setangle);
1130 for (i=0 ; i < 2 ; i++)
1131 MSG_WriteAngle (&host_client->message, ent->v.angles[i] );
1132 MSG_WriteAngle (&host_client->message, 0 );
1134 SV_WriteClientdataToMessage (sv_player, &host_client->message);
1136 MSG_WriteByte (&host_client->message, svc_signonnum);
1137 MSG_WriteByte (&host_client->message, 3);
1138 host_client->sendsignon = true;
1146 void Host_Begin_f (void)
1148 if (cmd_source == src_command)
1150 Con_Printf ("begin is not valid from the console\n");
1154 host_client->spawned = true;
1157 //===========================================================================
1164 Kicks a user off of the server
1167 void Host_Kick_f (void)
1170 char *message = NULL;
1173 qboolean byNumber = false;
1175 if (cmd_source == src_command)
1179 Cmd_ForwardToServer ();
1183 else if (pr_global_struct->deathmatch)
1188 if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
1190 i = atof(Cmd_Argv(2)) - 1;
1191 if (i < 0 || i >= svs.maxclients)
1193 if (!svs.clients[i].active)
1195 host_client = &svs.clients[i];
1200 for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
1202 if (!host_client->active)
1204 if (Q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
1209 if (i < svs.maxclients)
1211 if (cmd_source == src_command)
1212 if (cls.state == ca_dedicated)
1215 who = cl_name.string;
1219 // can't kick yourself!
1220 if (host_client == save)
1225 message = COM_Parse(Cmd_Args());
1228 message++; // skip the #
1229 while (*message == ' ') // skip white space
1231 message += strlen(Cmd_Argv(2)); // skip the number
1233 while (*message && *message == ' ')
1237 SV_ClientPrintf ("Kicked by %s: %s\n", who, message);
1239 SV_ClientPrintf ("Kicked by %s\n", who);
1240 SV_DropClient (false);
1247 ===============================================================================
1251 ===============================================================================
1259 void Host_Give_f (void)
1265 if (cmd_source == src_command)
1267 Cmd_ForwardToServer ();
1271 if (pr_global_struct->deathmatch)
1275 v = atoi (Cmd_Argv(2));
1289 // MED 01/04/97 added hipnotic give stuff
1290 if (gamemode == GAME_HIPNOTIC)
1295 sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN;
1297 sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER;
1299 else if (t[0] == '9')
1300 sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON;
1301 else if (t[0] == '0')
1302 sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR;
1303 else if (t[0] >= '2')
1304 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1309 sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
1314 if (gamemode == GAME_ROGUE)
1316 if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1)))
1320 sv_player->v.ammo_shells = v;
1323 if (gamemode == GAME_ROGUE)
1325 if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1)))
1328 if (sv_player->v.weapon <= IT_LIGHTNING)
1329 sv_player->v.ammo_nails = v;
1334 sv_player->v.ammo_nails = v;
1338 if (gamemode == GAME_ROGUE)
1340 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_lava_nails);
1344 if (sv_player->v.weapon > IT_LIGHTNING)
1345 sv_player->v.ammo_nails = v;
1350 if (gamemode == GAME_ROGUE)
1352 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_rockets1);
1356 if (sv_player->v.weapon <= IT_LIGHTNING)
1357 sv_player->v.ammo_rockets = v;
1362 sv_player->v.ammo_rockets = v;
1366 if (gamemode == GAME_ROGUE)
1368 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_multi_rockets);
1372 if (sv_player->v.weapon > IT_LIGHTNING)
1373 sv_player->v.ammo_rockets = v;
1378 sv_player->v.health = v;
1381 if (gamemode == GAME_ROGUE)
1383 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_cells1);
1387 if (sv_player->v.weapon <= IT_LIGHTNING)
1388 sv_player->v.ammo_cells = v;
1393 sv_player->v.ammo_cells = v;
1397 if (gamemode == GAME_ROGUE)
1399 val = GETEDICTFIELDVALUE(sv_player, eval_ammo_plasma);
1403 if (sv_player->v.weapon > IT_LIGHTNING)
1404 sv_player->v.ammo_cells = v;
1411 edict_t *FindViewthing (void)
1416 for (i=0 ; i<sv.num_edicts ; i++)
1419 if ( !strcmp (pr_strings + e->v.classname, "viewthing") )
1422 Con_Printf ("No viewthing on map\n");
1431 void Host_Viewmodel_f (void)
1436 e = FindViewthing ();
1440 m = Mod_ForName (Cmd_Argv(1), false, true, false);
1443 Con_Printf ("Can't load %s\n", Cmd_Argv(1));
1448 cl.model_precache[(int)e->v.modelindex] = m;
1456 void Host_Viewframe_f (void)
1462 e = FindViewthing ();
1465 m = cl.model_precache[(int)e->v.modelindex];
1467 f = atoi(Cmd_Argv(1));
1468 if (f >= m->numframes)
1475 void PrintFrameName (model_t *m, int frame)
1478 Con_Printf("frame %i: %s\n", frame, m->animscenes[frame].name);
1480 Con_Printf("frame %i\n", frame);
1488 void Host_Viewnext_f (void)
1493 e = FindViewthing ();
1496 m = cl.model_precache[(int)e->v.modelindex];
1498 e->v.frame = e->v.frame + 1;
1499 if (e->v.frame >= m->numframes)
1500 e->v.frame = m->numframes - 1;
1502 PrintFrameName (m, e->v.frame);
1510 void Host_Viewprev_f (void)
1515 e = FindViewthing ();
1519 m = cl.model_precache[(int)e->v.modelindex];
1521 e->v.frame = e->v.frame - 1;
1525 PrintFrameName (m, e->v.frame);
1529 ===============================================================================
1533 ===============================================================================
1542 void Host_Startdemos_f (void)
1546 if (cls.state == ca_dedicated)
1549 Cbuf_AddText ("map start\n");
1556 Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS);
1559 Con_Printf ("%i demo(s) in loop\n", c);
1561 for (i=1 ; i<c+1 ; i++)
1562 strncpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0])-1);
1564 if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
1578 Return to looping demos
1581 void Host_Demos_f (void)
1583 if (cls.state == ca_dedicated)
1585 if (cls.demonum == -1)
1595 Return to looping demos
1598 void Host_Stopdemo_f (void)
1600 if (!cls.demoplayback)
1605 //=============================================================================
1612 void Host_InitCommands (void)
1614 Cmd_AddCommand ("status", Host_Status_f);
1615 Cmd_AddCommand ("quit", Host_Quit_f);
1616 if (gamemode == GAME_NEHAHRA)
1618 Cmd_AddCommand ("max", Host_God_f);
1619 Cmd_AddCommand ("monster", Host_Notarget_f);
1620 Cmd_AddCommand ("scrag", Host_Fly_f);
1621 Cmd_AddCommand ("wraith", Host_Noclip_f);
1622 Cmd_AddCommand ("gimme", Host_Give_f);
1626 Cmd_AddCommand ("god", Host_God_f);
1627 Cmd_AddCommand ("notarget", Host_Notarget_f);
1628 Cmd_AddCommand ("fly", Host_Fly_f);
1629 Cmd_AddCommand ("noclip", Host_Noclip_f);
1630 Cmd_AddCommand ("give", Host_Give_f);
1632 Cmd_AddCommand ("map", Host_Map_f);
1633 Cmd_AddCommand ("restart", Host_Restart_f);
1634 Cmd_AddCommand ("changelevel", Host_Changelevel_f);
1635 Cmd_AddCommand ("connect", Host_Connect_f);
1636 Cmd_AddCommand ("reconnect", Host_Reconnect_f);
1637 Cmd_AddCommand ("name", Host_Name_f);
1638 Cmd_AddCommand ("version", Host_Version_f);
1639 Cmd_AddCommand ("say", Host_Say_f);
1640 Cmd_AddCommand ("say_team", Host_Say_Team_f);
1641 Cmd_AddCommand ("tell", Host_Tell_f);
1642 Cmd_AddCommand ("color", Host_Color_f);
1643 Cmd_AddCommand ("kill", Host_Kill_f);
1644 Cmd_AddCommand ("pause", Host_Pause_f);
1645 Cmd_AddCommand ("spawn", Host_Spawn_f);
1646 Cmd_AddCommand ("begin", Host_Begin_f);
1647 Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
1648 Cmd_AddCommand ("kick", Host_Kick_f);
1649 Cmd_AddCommand ("ping", Host_Ping_f);
1650 Cmd_AddCommand ("load", Host_Loadgame_f);
1651 Cmd_AddCommand ("save", Host_Savegame_f);
1653 Cmd_AddCommand ("startdemos", Host_Startdemos_f);
1654 Cmd_AddCommand ("demos", Host_Demos_f);
1655 Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
1657 Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
1658 Cmd_AddCommand ("viewframe", Host_Viewframe_f);
1659 Cmd_AddCommand ("viewnext", Host_Viewnext_f);
1660 Cmd_AddCommand ("viewprev", Host_Viewprev_f);