From 6c6c6d282666308afb1f1bb425a409235e74caf8 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 15 Oct 2015 00:10:14 +1000 Subject: [PATCH] More gamemode specific checks gone boom --- .../gamemodes/gamemode/nexball/nexball.qc | 6 ++++++ qcsrc/server/miscfunctions.qc | 18 ++++++++++-------- qcsrc/server/mutators/events.qh | 15 ++++++++++++++- qcsrc/server/mutators/gamemode_ca.qc | 6 ++++++ qcsrc/server/mutators/gamemode_cts.qc | 7 +++++++ qcsrc/server/mutators/gamemode_lms.qc | 6 ++++++ 6 files changed, 49 insertions(+), 9 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 385e4eb09..decb4c7de 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -1023,6 +1023,12 @@ MUTATOR_HOOKFUNCTION(nb, GetTeamCount) return true; } +MUTATOR_HOOKFUNCTION(nb, WantWeapon) +{ + ret_float = 0; // weapon is set a few lines later, apparently + return true; +} + REGISTER_MUTATOR(nb, g_nexball) { ActivateTeamplay(); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 43036b409..e8edabc2c 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -485,25 +485,27 @@ float want_weapon(entity weaponinfo, float allguns) // WEAPONTODO: what still ne { int i = weaponinfo.weapon; int d = 0; + bool allow_mutatorblocked = false; - if (!i) + if(!i) return 0; - if (g_lms || g_ca || allguns) + bool mutator_returnvalue = MUTATOR_CALLHOOK(WantWeapon, weaponinfo, d, allguns, allow_mutatorblocked); + d = ret_float; + allguns = want_allguns; + allow_mutatorblocked = false; + + if(allguns) { if(weaponinfo.spawnflags & WEP_FLAG_NORMAL) d = true; else d = false; } - else if (g_cts) - d = (i == WEP_SHOTGUN.m_id); - else if (g_nexball) - d = 0; // weapon is set a few lines later - else + else if(!mutator_returnvalue) d = !(!weaponinfo.weaponstart); - if(!g_cts && (weaponinfo.spawnflags & WEP_FLAG_MUTATORBLOCKED)) // never default mutator blocked guns + if(!allow_mutatorblocked && (weaponinfo.spawnflags & WEP_FLAG_MUTATORBLOCKED)) // never default mutator blocked guns d = 0; float t = weaponinfo.weaponstartoverride; diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 8a69dba0e..2066e768c 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -715,7 +715,6 @@ enum { MUT_SPECCMD_FORCE // return this flag to force the player to spectate, even if they're not a player }; -/** called when player triggered kill (or is changing teams), return error to not do anything */ #define EV_CheckRules_World(i, o) \ /* status */ i(float, ret_float) \ /* status */ o(float, ret_float) \ @@ -725,4 +724,18 @@ enum { float checkrules_timelimit; int checkrules_fraglimit; MUTATOR_HOOKABLE(CheckRules_World, EV_CheckRules_World); + +#define EV_WantWeapon(i, o) \ + /**/ i(entity, want_weaponinfo) \ + /**/ i(float, ret_float) \ + /**/ o(float, ret_float) \ + /**/ i(bool, want_allguns) \ + /**/ o(bool, want_allguns) \ + /**/ i(bool, want_mutatorblocked) \ + /**/ o(bool, want_mutatorblocked) \ + /**/ +entity want_weaponinfo; +bool want_allguns; +bool want_mutatorblocked; +MUTATOR_HOOKABLE(WantWeapon, EV_WantWeapon); #endif diff --git a/qcsrc/server/mutators/gamemode_ca.qc b/qcsrc/server/mutators/gamemode_ca.qc index 8881ab2ee..84b56daba 100644 --- a/qcsrc/server/mutators/gamemode_ca.qc +++ b/qcsrc/server/mutators/gamemode_ca.qc @@ -456,6 +456,12 @@ MUTATOR_HOOKFUNCTION(ca, ClientCommand_Spectate) return MUT_SPECCMD_CONTINUE; } +MUTATOR_HOOKFUNCTION(ca, WantWeapon) +{ + want_allguns = true; + return false; +} + void ca_Initialize() { allowed_to_spawn = true; diff --git a/qcsrc/server/mutators/gamemode_cts.qc b/qcsrc/server/mutators/gamemode_cts.qc index ae148fd47..a45367afa 100644 --- a/qcsrc/server/mutators/gamemode_cts.qc +++ b/qcsrc/server/mutators/gamemode_cts.qc @@ -347,6 +347,13 @@ MUTATOR_HOOKFUNCTION(cts, FixClientCvars) return false; } +MUTATOR_HOOKFUNCTION(cts, WantWeapon) +{ + ret_float = (want_weaponinfo.weapon == WEP_SHOTGUN.m_id); + want_mutatorblocked = true; + return true; +} + void cts_Initialize() { cts_ScoreRules(); diff --git a/qcsrc/server/mutators/gamemode_lms.qc b/qcsrc/server/mutators/gamemode_lms.qc index 999eb7aa4..aab3b5542 100644 --- a/qcsrc/server/mutators/gamemode_lms.qc +++ b/qcsrc/server/mutators/gamemode_lms.qc @@ -236,6 +236,12 @@ MUTATOR_HOOKFUNCTION(lms, CheckRules_World) return true; } +MUTATOR_HOOKFUNCTION(lms, WantWeapon) +{ + want_allguns = true; + return false; +} + // scoreboard stuff void lms_ScoreRules() { -- 2.39.2