]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
More gamemode specific checks gone boom
authorMario <mario@smbclan.net>
Wed, 14 Oct 2015 14:10:14 +0000 (00:10 +1000)
committerMario <mario@smbclan.net>
Wed, 14 Oct 2015 14:10:14 +0000 (00:10 +1000)
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/gamemode_ca.qc
qcsrc/server/mutators/gamemode_cts.qc
qcsrc/server/mutators/gamemode_lms.qc

index 385e4eb097b072dddb363cfe68709808b3a16733..decb4c7decf9a1e74fd1c0f6b50c2e443d7a7a9d 100644 (file)
@@ -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();
index 43036b4099a64d0972097ca50d3d91dc5bdf80b9..e8edabc2c881e9db7666962db09cdd0cacfbdcfb 100644 (file)
@@ -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;
index 8a69dba0eb0c886a0d65297dec66f61ceeacd46f..2066e768c1e5a151452bf993a1c24f2c018ae1f1 100644 (file)
@@ -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
index 8881ab2eed11be043460a2bc7e759453f8328947..84b56dabad3976a761c1708463698fa78364c810 100644 (file)
@@ -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;
index ae148fd47d1d26e65c6477c6ca50d6d3a5e127b8..a45367afae314916a8c35495eb52485b33ca2cd7 100644 (file)
@@ -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();
index 999eb7aa4c25432731d9a75082966431c6cdc2ce..aab3b5542fa317b4b7a2b7aa97c57240aa20ff11 100644 (file)
@@ -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()
 {