From 9dd7ac97faf9fc1548cc3d416cedaeef803e7528 Mon Sep 17 00:00:00 2001 From: TimePath Date: Thu, 15 Oct 2015 08:11:05 +1100 Subject: [PATCH] mapinfo: remove some IS_GAMETYPE macros --- qcsrc/common/gamemodes/gamemode/nexball/nexball.qc | 8 +++++--- qcsrc/common/mapinfo.qh | 7 ------- .../common/mutators/mutator/waypoints/waypointsprites.qc | 2 +- qcsrc/server/mutators/events.qh | 5 ++++- qcsrc/server/mutators/gamemode_deathmatch.qc | 2 +- qcsrc/server/mutators/gamemode_domination.qc | 5 ++++- qcsrc/server/mutators/gamemode_invasion.qc | 5 ++++- qcsrc/server/mutators/gamemode_keepaway.qc | 7 +------ qcsrc/server/mutators/gamemode_keyhunt.qc | 2 +- qcsrc/server/mutators/gamemode_lms.qc | 2 +- qcsrc/server/mutators/gamemode_onslaught.qc | 5 ++++- qcsrc/server/weapons/throwing.qc | 6 ++---- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 4d63b9a5f..93f60fe67 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -1011,10 +1011,12 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPhysics) MUTATOR_HOOKFUNCTION(nb, ForbidThrowCurrentWeapon) {SELFPARAM(); - if(self.weapon == WEP_NEXBALL.m_id) - return true; + return self.weapon == WEP_NEXBALL.m_id; +} - return false; +MUTATOR_HOOKFUNCTION(nb, ForbidDropCurrentWeapon) +{SELFPARAM(); + return self.weapon == WEP_MORTAR.m_id; // TODO: what is this for? } MUTATOR_HOOKFUNCTION(nb, FilterItem) diff --git a/qcsrc/common/mapinfo.qh b/qcsrc/common/mapinfo.qh index 6faef6e05..1238bfe4b 100644 --- a/qcsrc/common/mapinfo.qh +++ b/qcsrc/common/mapinfo.qh @@ -55,10 +55,8 @@ int MAPINFO_TYPE_ALL; (MapInfo_LoadedGametype == MAPINFO_TYPE_##NAME) REGISTER_GAMETYPE(_("Deathmatch"),dm,g_dm,DEATHMATCH,false,"timelimit=20 pointlimit=30 leadlimit=0",_("Score as many frags as you can.")); -#define g_dm IS_GAMETYPE(DEATHMATCH) REGISTER_GAMETYPE(_("Last Man Standing"),lms,g_lms,LMS,false,"timelimit=20 lives=9 leadlimit=0",_("Survive and kill until the enemies have no lives left.")); -#define g_lms IS_GAMETYPE(LMS) REGISTER_GAMETYPE(_("Race"),rc,g_race,RACE,false,"timelimit=20 qualifying_timelimit=5 laplimit=7 teamlaplimit=15 leadlimit=0",_("Race against other players to the finish line.")); #define g_race IS_GAMETYPE(RACE) @@ -76,16 +74,13 @@ REGISTER_GAMETYPE(_("Clan Arena"),ca,g_ca,CA,true,"timelimit=20 pointlimit=10 te #define g_ca IS_GAMETYPE(CA) REGISTER_GAMETYPE(_("Domination"),dom,g_domination,DOMINATION,true,"timelimit=20 pointlimit=200 teams=2 leadlimit=0",_("Capture and defend all the control points to win.")); -#define g_domination IS_GAMETYPE(DOMINATION) REGISTER_GAMETYPE(_("Key Hunt"),kh,g_keyhunt,KEYHUNT,true,"timelimit=20 pointlimit=1000 teams=3 leadlimit=0",_("Gather all the keys to win the round.")); -#define g_keyhunt IS_GAMETYPE(KEYHUNT) REGISTER_GAMETYPE(_("Assault"),as,g_assault,ASSAULT,true,"timelimit=20",_("Destroy obstacles to find and destroy the enemy power core before time runs out.")); #define g_assault IS_GAMETYPE(ASSAULT) REGISTER_GAMETYPE(_("Onslaught"),ons,g_onslaught,ONSLAUGHT,true,"pointlimit=1 timelimit=20",_("Capture control points to reach and destroy the enemy generator.")); -#define g_onslaught IS_GAMETYPE(ONSLAUGHT) REGISTER_GAMETYPE(_("Nexball"),nb,g_nexball,NEXBALL,true,"timelimit=20 pointlimit=5 leadlimit=0",_("Shoot and kick the ball into the enemies goal, keep your goal clean.")); #define g_nexball IS_GAMETYPE(NEXBALL) @@ -94,10 +89,8 @@ REGISTER_GAMETYPE(_("Freeze Tag"),ft,g_freezetag,FREEZETAG,true,"timelimit=20 po #define g_freezetag IS_GAMETYPE(FREEZETAG) REGISTER_GAMETYPE(_("Keepaway"),ka,g_keepaway,KEEPAWAY,true,"timelimit=20 pointlimit=30",_("Hold the ball to get points for kills.")); -#define g_keepaway IS_GAMETYPE(KEEPAWAY) REGISTER_GAMETYPE(_("Invasion"),inv,g_invasion,INVASION,false,"pointlimit=50 teams=0",_("Survive against waves of monsters.")); -#define g_invasion IS_GAMETYPE(INVASION) const int MAPINFO_FEATURE_WEAPONS = 1; // not defined for instagib-only maps const int MAPINFO_FEATURE_VEHICLES = 2; diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index 4f9116e73..f0b768c57 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -978,7 +978,7 @@ void WaypointSprite_Reset() {SELFPARAM(); // if a WP wants to time out, let it time out immediately; other WPs ought to be reset/killed by their owners - if (self.fade_time) // was there before: || g_keyhunt, do we really need this? + if (self.fade_time) WaypointSprite_Kill(self); } diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 4caacea7c..52a1aa351 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -147,9 +147,12 @@ string format_replacement; string format_message; MUTATOR_HOOKABLE(FormatMessage, EV_FormatMessage); -/** returns 1 if throwing the current weapon shall not be allowed */ +/** returns true if throwing the current weapon shall not be allowed */ MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_NO_ARGS); +/** returns true if dropping the current weapon shall not be allowed at any time including death */ +MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_NO_ARGS); + /** allows changing attack rate */ #define EV_WeaponRateFactor(i, o) \ /**/ i(float, weapon_rate) \ diff --git a/qcsrc/server/mutators/gamemode_deathmatch.qc b/qcsrc/server/mutators/gamemode_deathmatch.qc index 773c08d21..d5f9cbdc6 100644 --- a/qcsrc/server/mutators/gamemode_deathmatch.qc +++ b/qcsrc/server/mutators/gamemode_deathmatch.qc @@ -6,7 +6,7 @@ MUTATOR_HOOKFUNCTION(dm, Scores_CountFragsRemaining) return true; } -REGISTER_MUTATOR(dm, g_dm) +REGISTER_MUTATOR(dm, IS_GAMETYPE(DEATHMATCH)) { MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_domination.qc b/qcsrc/server/mutators/gamemode_domination.qc index 2c124b5de..504f31db0 100644 --- a/qcsrc/server/mutators/gamemode_domination.qc +++ b/qcsrc/server/mutators/gamemode_domination.qc @@ -4,6 +4,8 @@ #include "../teamplay.qh" +bool g_domination; + int autocvar_g_domination_default_teams; bool autocvar_g_domination_disable_frags; int autocvar_g_domination_point_amt; @@ -659,11 +661,12 @@ void dom_DelayedInit() // Do this check with a delay so we can wait for teams to void dom_Initialize() { + g_domination = true; InitializeEntity(world, dom_DelayedInit, INITPRIO_GAMETYPE); } -REGISTER_MUTATOR(dom, g_domination) +REGISTER_MUTATOR(dom, IS_GAMETYPE(DOMINATION)) { int fraglimit_override = autocvar_g_domination_point_limit; if(autocvar_g_domination_roundbased && autocvar_g_domination_roundbased_point_limit) diff --git a/qcsrc/server/mutators/gamemode_invasion.qc b/qcsrc/server/mutators/gamemode_invasion.qc index f1b942919..e752da96e 100644 --- a/qcsrc/server/mutators/gamemode_invasion.qc +++ b/qcsrc/server/mutators/gamemode_invasion.qc @@ -7,6 +7,8 @@ #include "../teamplay.qh" +bool g_invasion; + float autocvar_g_invasion_round_timelimit; int autocvar_g_invasion_teams; bool autocvar_g_invasion_team_spawns; @@ -468,7 +470,7 @@ void invasion_Initialize() InitializeEntity(world, invasion_DelayedInit, INITPRIO_GAMETYPE); } -REGISTER_MUTATOR(inv, g_invasion) +REGISTER_MUTATOR(inv, IS_GAMETYPE(INVASION)) { SetLimits(autocvar_g_invasion_point_limit, -1, -1, -1); if(autocvar_g_invasion_teams >= 2) @@ -482,6 +484,7 @@ REGISTER_MUTATOR(inv, g_invasion) { if(time > 1) // game loads at time 1 error("This is a game type and it cannot be added at runtime."); + g_invasion = true; invasion_Initialize(); cvar_settemp("g_monsters", "1"); diff --git a/qcsrc/server/mutators/gamemode_keepaway.qc b/qcsrc/server/mutators/gamemode_keepaway.qc index 61289b58f..f96aada3e 100644 --- a/qcsrc/server/mutators/gamemode_keepaway.qc +++ b/qcsrc/server/mutators/gamemode_keepaway.qc @@ -421,8 +421,6 @@ MUTATOR_HOOKFUNCTION(ka, DropSpecialItems) void ka_SpawnBall() // loads various values for the ball, runs only once at start of match { - if(!g_keepaway) { return; } - entity e; e = spawn(); e.model = "models/orbs/orbblue.md3"; @@ -456,15 +454,12 @@ void ka_ScoreRules() void ka_Initialize() // run at the start of a match, initiates game mode { - if(!g_keepaway) - return; - ka_ScoreRules(); ka_SpawnBall(); } -REGISTER_MUTATOR(ka, g_keepaway) +REGISTER_MUTATOR(ka, IS_GAMETYPE(KEEPAWAY)) { MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_keyhunt.qc b/qcsrc/server/mutators/gamemode_keyhunt.qc index 9b33d5d75..8f680ae64 100644 --- a/qcsrc/server/mutators/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/gamemode_keyhunt.qc @@ -1349,7 +1349,7 @@ MUTATOR_HOOKFUNCTION(kh, reset_map_global) return false; } -REGISTER_MUTATOR(kh, g_keyhunt) +REGISTER_MUTATOR(kh, IS_GAMETYPE(KEYHUNT)) { ActivateTeamplay(); SetLimits(autocvar_g_keyhunt_point_limit, autocvar_g_keyhunt_point_leadlimit, -1, -1); diff --git a/qcsrc/server/mutators/gamemode_lms.qc b/qcsrc/server/mutators/gamemode_lms.qc index dc56fb17a..65c85f73a 100644 --- a/qcsrc/server/mutators/gamemode_lms.qc +++ b/qcsrc/server/mutators/gamemode_lms.qc @@ -272,7 +272,7 @@ void lms_Initialize() lms_ScoreRules(); } -REGISTER_MUTATOR(lms, g_lms) +REGISTER_MUTATOR(lms, IS_GAMETYPE(LMS)) { SetLimits(((!autocvar_g_lms_lives_override) ? -1 : autocvar_g_lms_lives_override), 0, -1, -1); diff --git a/qcsrc/server/mutators/gamemode_onslaught.qc b/qcsrc/server/mutators/gamemode_onslaught.qc index 53cf0c798..3ebcb7eac 100644 --- a/qcsrc/server/mutators/gamemode_onslaught.qc +++ b/qcsrc/server/mutators/gamemode_onslaught.qc @@ -2,6 +2,8 @@ #include "../controlpoint.qh" #include "../generator.qh" +bool g_onslaught; + float autocvar_g_onslaught_debug; float autocvar_g_onslaught_teleport_wait; bool autocvar_g_onslaught_spawn_at_controlpoints; @@ -2177,6 +2179,7 @@ void ons_DelayedInit() // Do this check with a delay so we can wait for teams to void ons_Initialize() { + g_onslaught = true; ons_captureshield_force = autocvar_g_onslaught_shield_force; addstat(STAT_ROUNDLOST, AS_INT, ons_roundlost); @@ -2184,7 +2187,7 @@ void ons_Initialize() InitializeEntity(world, ons_DelayedInit, INITPRIO_GAMETYPE); } -REGISTER_MUTATOR(ons, g_onslaught) +REGISTER_MUTATOR(ons, IS_GAMETYPE(ONSLAUGHT)) { ActivateTeamplay(); SetLimits(autocvar_g_onslaught_point_limit, -1, -1, -1); diff --git a/qcsrc/server/weapons/throwing.qc b/qcsrc/server/weapons/throwing.qc index 83025da9a..ef243948a 100644 --- a/qcsrc/server/weapons/throwing.qc +++ b/qcsrc/server/weapons/throwing.qc @@ -141,8 +141,6 @@ float W_IsWeaponThrowable(float w) return 0; if (g_cts) return 0; - if (g_nexball && w == WEP_MORTAR.m_id) - return 0; if(w == 0) return 0; @@ -170,7 +168,7 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce) w = self.weapon; if (w == 0) return; // just in case - if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon)) + if(MUTATOR_CALLHOOK(ForbidThrowCurrentWeapon) || MUTATOR_CALLHOOK(ForbidDropCurrentWeapon)) return; if(!autocvar_g_weapon_throwable) return; @@ -193,6 +191,6 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce) void SpawnThrownWeapon(vector org, float w) {SELFPARAM(); if(self.weapons & WepSet_FromWeapon(self.weapon)) - if(W_IsWeaponThrowable(self.weapon)) + if(!MUTATOR_CALLHOOK(ForbidDropCurrentWeapon) && W_IsWeaponThrowable(self.weapon)) W_ThrowNewWeapon(self, self.weapon, false, org, randomvec() * 125 + '0 0 200'); } -- 2.39.2