X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=host_cmd.c;h=1dec6eca1da66f36d5590bc3d6243f18aaac0009;hb=c0f7a1b5470bc222b7a1d01ca95205c1825a5c6a;hp=97372b39ed0624ebd1f6c7275969cb4336a9b543;hpb=590a07608279a8a21604a83620d77abe9c731796;p=xonotic%2Fdarkplaces.git diff --git a/host_cmd.c b/host_cmd.c index 97372b39..1dec6eca 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -20,11 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" -extern cvar_t pausable; - int current_skill; -void Mod_Print (void); +dfunction_t *ED_FindFunction (char *name); /* ================== @@ -32,17 +30,12 @@ Host_Quit_f ================== */ -extern void M_Menu_Quit_f (void); - +extern qboolean host_shuttingdown; void Host_Quit_f (void) { - if (key_dest != key_console && cls.state != ca_dedicated) - { - M_Menu_Quit_f (); - return; - } + host_shuttingdown = true; CL_Disconnect (); - Host_ShutdownServer(false); + Host_ShutdownServer(false); Sys_Quit (); } @@ -61,7 +54,7 @@ void Host_Status_f (void) int hours = 0; int j; void (*print) (char *fmt, ...); - + if (cmd_source == src_command) { if (!sv.active) @@ -75,7 +68,7 @@ void Host_Status_f (void) print = SV_ClientPrintf; print ("host: %s\n", Cvar_VariableString ("hostname")); - print ("version: %4.2f\n", VERSION); + print ("version: %s build %s\n", gamename, buildstring); if (tcpipAvailable) print ("tcp/ip: %s\n", my_tcpip_address); if (ipxAvailable) @@ -118,7 +111,7 @@ void Host_God_f (void) return; } - if (pr_global_struct->deathmatch && !host_client->privileged) + if (pr_global_struct->deathmatch) return; sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE; @@ -136,7 +129,7 @@ void Host_Notarget_f (void) return; } - if (pr_global_struct->deathmatch && !host_client->privileged) + if (pr_global_struct->deathmatch) return; sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET; @@ -156,7 +149,7 @@ void Host_Noclip_f (void) return; } - if (pr_global_struct->deathmatch && !host_client->privileged) + if (pr_global_struct->deathmatch) return; if (sv_player->v.movetype != MOVETYPE_NOCLIP) @@ -188,7 +181,7 @@ void Host_Fly_f (void) return; } - if (pr_global_struct->deathmatch && !host_client->privileged) + if (pr_global_struct->deathmatch) return; if (sv_player->v.movetype != MOVETYPE_FLY) @@ -263,11 +256,12 @@ void Host_Map_f (void) cls.demonum = -1; // stop demo loop in case this fails + SCR_BeginLoadingPlaque (); + CL_Disconnect (); Host_ShutdownServer(false); key_dest = key_game; // remove console or menu - SCR_BeginLoadingPlaque (); cls.mapstring[0] = 0; for (i=0 ; iv.health <= 0) ) @@ -472,32 +463,32 @@ void Host_Savegame_f (void) sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1)); COM_DefaultExtension (name, ".sav"); - + Con_Printf ("Saving game to %s...\n", name); - f = fopen (name, "w"); + f = Qopen (name, "w"); if (!f) { Con_Printf ("ERROR: couldn't open.\n"); return; } - - fprintf (f, "%i\n", SAVEGAME_VERSION); + + Qprintf (f, "%i\n", SAVEGAME_VERSION); Host_SavegameComment (comment); - fprintf (f, "%s\n", comment); + Qprintf (f, "%s\n", comment); for (i=0 ; ispawn_parms[i]); - fprintf (f, "%d\n", current_skill); - fprintf (f, "%s\n", sv.name); - fprintf (f, "%f\n",sv.time); + Qprintf (f, "%f\n", svs.clients->spawn_parms[i]); + Qprintf (f, "%d\n", current_skill); + Qprintf (f, "%s\n", sv.name); + Qprintf (f, "%f\n",sv.time); // write the light styles for (i=0 ; ispawn_parms[i] = spawn_parms[i]; @@ -664,17 +663,18 @@ Host_Name_f */ void Host_Name_f (void) { - char *newName; + char newName[64]; if (Cmd_Argc () == 1) { Con_Printf ("\"name\" is \"%s\"\n", cl_name.string); return; } + if (Cmd_Argc () == 2) - newName = Cmd_Argv(1); + strncpy(newName, Cmd_Argv(1), 15); else - newName = Cmd_Args(); + strncpy(newName, Cmd_Args(), 15); newName[15] = 0; if (cmd_source == src_command) @@ -703,62 +703,8 @@ void Host_Name_f (void) void Host_Version_f (void) { - Con_Printf ("Version %4.2f\n", VERSION); - Con_Printf ("Exe: "__TIME__" "__DATE__"\n"); -} - -#ifdef IDGODS -void Host_Please_f (void) -{ - client_t *cl; - int j; - - if (cmd_source != src_command) - return; - - if ((Cmd_Argc () == 3) && strcmp(Cmd_Argv(1), "#") == 0) - { - j = atof(Cmd_Argv(2)) - 1; - if (j < 0 || j >= svs.maxclients) - return; - if (!svs.clients[j].active) - return; - cl = &svs.clients[j]; - if (cl->privileged) - { - cl->privileged = false; - cl->edict->v.flags = (int)cl->edict->v.flags & ~(FL_GODMODE|FL_NOTARGET); - cl->edict->v.movetype = MOVETYPE_WALK; - noclip_anglehack = false; - } - else - cl->privileged = true; - } - - if (Cmd_Argc () != 2) - return; - - for (j=0, cl = svs.clients ; jactive) - continue; - if (strcasecmp(cl->name, Cmd_Argv(1)) == 0) - { - if (cl->privileged) - { - cl->privileged = false; - cl->edict->v.flags = (int)cl->edict->v.flags & ~(FL_GODMODE|FL_NOTARGET); - cl->edict->v.movetype = MOVETYPE_WALK; - noclip_anglehack = false; - } - else - cl->privileged = true; - break; - } - } + Con_Printf ("Version: %s build %s\n", gamename, buildstring); } -#endif - void Host_Say(qboolean teamonly) { @@ -814,7 +760,7 @@ void Host_Say(qboolean teamonly) { if (!client || !client->active || !client->spawned) continue; - if (teamplay.value && teamonly && client->edict->v.team != save->edict->v.team) + if (teamplay.integer && teamonly && client->edict->v.team != save->edict->v.team) continue; host_client = client; SV_ClientPrintf("%s", text); @@ -843,7 +789,7 @@ void Host_Tell_f(void) client_t *save; int j; char *p; - char text[64]; + char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64) if (cmd_source == src_command) { @@ -898,10 +844,12 @@ void Host_Color_f(void) { int top, bottom; int playercolor; + dfunction_t *f; + func_t SV_ChangeTeam; if (Cmd_Argc() == 1) { - Con_Printf ("\"color\" is \"%i %i\"\n", ((int)cl_color.value) >> 4, ((int)cl_color.value) & 0x0f); + Con_Printf ("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15); Con_Printf ("color <0-13> [0-13]\n"); return; } @@ -933,13 +881,24 @@ void Host_Color_f(void) return; } - host_client->colors = playercolor; - host_client->edict->v.team = bottom + 1; + if ((f = ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - pr_functions))) + { + Con_DPrintf("Calling SV_ChangeTeam\n"); + pr_global_struct->time = sv.time; + pr_globals[0] = playercolor; + pr_global_struct->self = EDICT_TO_PROG(host_client->edict); + PR_ExecuteProgram (SV_ChangeTeam, ""); + } + else + { + host_client->colors = playercolor; + host_client->edict->v.team = bottom + 1; -// send notification to all clients - MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors); - MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients); - MSG_WriteByte (&sv.reliable_datagram, host_client->colors); + // send notification to all clients + MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors); + MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients); + MSG_WriteByte (&sv.reliable_datagram, host_client->colors); + } } /* @@ -957,13 +916,13 @@ void Host_Kill_f (void) if (sv_player->v.health <= 0) { - SV_ClientPrintf ("Can't suicide -- allready dead!\n"); + SV_ClientPrintf ("Can't suicide -- already dead!\n"); return; } pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(sv_player); - PR_ExecuteProgram (pr_global_struct->ClientKill); + PR_ExecuteProgram (pr_global_struct->ClientKill, "QC function ClientKill is missing"); } @@ -980,7 +939,7 @@ void Host_Pause_f (void) Cmd_ForwardToServer (); return; } - if (!pausable.value) + if (!pausable.integer) SV_ClientPrintf ("Pause not allowed.\n"); else { @@ -1019,7 +978,7 @@ void Host_PreSpawn_f (void) if (host_client->spawned) { - Con_Printf ("prespawn not valid -- allready spawned\n"); + Con_Printf ("prespawn not valid -- already spawned\n"); return; } @@ -1029,8 +988,6 @@ void Host_PreSpawn_f (void) host_client->sendsignon = true; } -dfunction_t *ED_FindFunction (char *name); - /* ================== Host_Spawn_f @@ -1052,23 +1009,27 @@ void Host_Spawn_f (void) if (host_client->spawned) { - Con_Printf ("Spawn not valid -- allready spawned\n"); + Con_Printf ("Spawn not valid -- already spawned\n"); return; } + // LordHavoc: moved this above the QC calls at FrikaC's request +// send all current names, colors, and frag counts + SZ_Clear (&host_client->message); + // run the entrance script if (sv.loadgame) - { // loaded games are fully inited allready + { // loaded games are fully inited already // if this is the last client to be connected, unpause sv.paused = false; - if (f = ED_FindFunction ("RestoreGame")) - if (RestoreGame = (func_t)(f - pr_functions)) + if ((f = ED_FindFunction ("RestoreGame"))) + if ((RestoreGame = (func_t)(f - pr_functions))) { Con_DPrintf("Calling RestoreGame\n"); pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(sv_player); - PR_ExecuteProgram (RestoreGame); + PR_ExecuteProgram (RestoreGame, ""); } } else @@ -1081,7 +1042,7 @@ void Host_Spawn_f (void) ent->v.colormap = NUM_FOR_EDICT(ent); ent->v.team = (host_client->colors & 15) + 1; ent->v.netname = host_client->name - pr_strings; - if (val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)) + if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel))) val->_float = host_client->pmodel; // copy spawn parms out of the client_t @@ -1093,18 +1054,15 @@ void Host_Spawn_f (void) pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(sv_player); - PR_ExecuteProgram (pr_global_struct->ClientConnect); + PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing"); - if ((Sys_FloatTime() - host_client->netconnection->connecttime) <= sv.time) + if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= sv.time) Sys_Printf ("%s entered the game\n", host_client->name); - PR_ExecuteProgram (pr_global_struct->PutClientInServer); + PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing"); } -// send all current names, colors, and frag counts - SZ_Clear (&host_client->message); - // send time of update MSG_WriteByte (&host_client->message, svc_time); MSG_WriteFloat (&host_client->message, sv.time); @@ -1149,7 +1107,6 @@ void Host_Spawn_f (void) MSG_WriteByte (&host_client->message, STAT_MONSTERS); MSG_WriteLong (&host_client->message, pr_global_struct->killed_monsters); -// // send a fixangle // Never send a roll angle, because savegames can catch the server // in a state where it is expecting the client to correct the angle @@ -1210,7 +1167,7 @@ void Host_Kick_f (void) return; } } - else if (pr_global_struct->deathmatch && !host_client->privileged) + else if (pr_global_struct->deathmatch) return; save = host_client; @@ -1298,63 +1255,63 @@ void Host_Give_f (void) return; } - if (pr_global_struct->deathmatch && !host_client->privileged) + if (pr_global_struct->deathmatch) return; t = Cmd_Argv(1); v = atoi (Cmd_Argv(2)); - + switch (t[0]) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - // MED 01/04/97 added hipnotic give stuff - if (hipnotic) - { - if (t[0] == '6') - { - if (t[1] == 'a') - sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN; - else - sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER; - } - else if (t[0] == '9') - sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON; - else if (t[0] == '0') - sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR; - else if (t[0] >= '2') - sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2')); - } - else - { - if (t[0] >= '2') - sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2')); - } + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + // MED 01/04/97 added hipnotic give stuff + if (gamemode == GAME_HIPNOTIC) + { + if (t[0] == '6') + { + if (t[1] == 'a') + sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN; + else + sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER; + } + else if (t[0] == '9') + sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON; + else if (t[0] == '0') + sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR; + else if (t[0] >= '2') + sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2')); + } + else + { + if (t[0] >= '2') + sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2')); + } break; - - case 's': - if (rogue) + + case 's': + if (gamemode == GAME_ROGUE) { - if (val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1)) - val->_float = v; + if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1))) + val->_float = v; } - sv_player->v.ammo_shells = v; - break; - case 'n': - if (rogue) + sv_player->v.ammo_shells = v; + break; + case 'n': + if (gamemode == GAME_ROGUE) { - if (val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1)) + if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1))) { - val->_float = v; + val->_float = v; if (sv_player->v.weapon <= IT_LIGHTNING) sv_player->v.ammo_nails = v; } @@ -1363,9 +1320,9 @@ void Host_Give_f (void) { sv_player->v.ammo_nails = v; } - break; - case 'l': - if (rogue) + break; + case 'l': + if (gamemode == GAME_ROGUE) { val = GETEDICTFIELDVALUE(sv_player, eval_ammo_lava_nails); if (val) @@ -1375,9 +1332,9 @@ void Host_Give_f (void) sv_player->v.ammo_nails = v; } } - break; - case 'r': - if (rogue) + break; + case 'r': + if (gamemode == GAME_ROGUE) { val = GETEDICTFIELDVALUE(sv_player, eval_ammo_rockets1); if (val) @@ -1391,9 +1348,9 @@ void Host_Give_f (void) { sv_player->v.ammo_rockets = v; } - break; - case 'm': - if (rogue) + break; + case 'm': + if (gamemode == GAME_ROGUE) { val = GETEDICTFIELDVALUE(sv_player, eval_ammo_multi_rockets); if (val) @@ -1403,12 +1360,12 @@ void Host_Give_f (void) sv_player->v.ammo_rockets = v; } } - break; - case 'h': - sv_player->v.health = v; - break; - case 'c': - if (rogue) + break; + case 'h': + sv_player->v.health = v; + break; + case 'c': + if (gamemode == GAME_ROGUE) { val = GETEDICTFIELDVALUE(sv_player, eval_ammo_cells1); if (val) @@ -1422,9 +1379,9 @@ void Host_Give_f (void) { sv_player->v.ammo_cells = v; } - break; - case 'p': - if (rogue) + break; + case 'p': + if (gamemode == GAME_ROGUE) { val = GETEDICTFIELDVALUE(sv_player, eval_ammo_plasma); if (val) @@ -1434,15 +1391,15 @@ void Host_Give_f (void) sv_player->v.ammo_cells = v; } } - break; - } + break; + } } edict_t *FindViewthing (void) { int i; edict_t *e; - + for (i=0 ; iframes[frame]; - - Con_Printf ("frame %i: %s\n", frame, pframedesc->name); + if (m->animscenes) + Con_Printf("frame %i: %s\n", frame, m->animscenes[frame].name); + else + Con_Printf("frame %i\n", frame); } /* @@ -1632,11 +1584,8 @@ Return to looping demos */ void Host_Stopdemo_f (void) { - if (cls.state == ca_dedicated) - return; if (!cls.demoplayback) return; - CL_StopPlayback (); CL_Disconnect (); } @@ -1651,7 +1600,7 @@ void Host_InitCommands (void) { Cmd_AddCommand ("status", Host_Status_f); Cmd_AddCommand ("quit", Host_Quit_f); - if (nehahra) + if (gamemode == GAME_NEHAHRA) { Cmd_AddCommand ("max", Host_God_f); Cmd_AddCommand ("monster", Host_Notarget_f); @@ -1674,9 +1623,6 @@ void Host_InitCommands (void) Cmd_AddCommand ("reconnect", Host_Reconnect_f); Cmd_AddCommand ("name", Host_Name_f); Cmd_AddCommand ("version", Host_Version_f); -#ifdef IDGODS - Cmd_AddCommand ("please", Host_Please_f); -#endif Cmd_AddCommand ("say", Host_Say_f); Cmd_AddCommand ("say_team", Host_Say_Team_f); Cmd_AddCommand ("tell", Host_Tell_f); @@ -1699,6 +1645,5 @@ void Host_InitCommands (void) Cmd_AddCommand ("viewframe", Host_Viewframe_f); Cmd_AddCommand ("viewnext", Host_Viewnext_f); Cmd_AddCommand ("viewprev", Host_Viewprev_f); - - Cmd_AddCommand ("mcache", Mod_Print); } +