]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix ItemTouch mutator hook usage (fixes #1572)
authorSamual Lenks <samual@xonotic.org>
Wed, 15 May 2013 01:00:19 +0000 (21:00 -0400)
committerSamual Lenks <samual@xonotic.org>
Wed, 15 May 2013 01:00:19 +0000 (21:00 -0400)
qcsrc/server/mutators/base.qh
qcsrc/server/mutators/gamemode_freezetag.qc
qcsrc/server/mutators/gamemode_lms.qc
qcsrc/server/mutators/mutator_minstagib.qc
qcsrc/server/mutators/mutator_superspec.qc
qcsrc/server/t_items.qc

index b2f9b29fda64b36d1df56e15536b2b3ad45168d2..a6c6f3a7e58a232bac1e04ddc2e15dc25faf9606 100644 (file)
@@ -292,6 +292,9 @@ MUTATOR_HOOKABLE(ItemTouch);
        // called at when a item is touched. Called early, can edit item properties.
        entity self;    // item
        entity other;   // player
+       #define MUT_ITEMTOUCH_CONTINUE 0 // return this flag to make the function continue as normal
+       #define MUT_ITEMTOUCH_RETURN 1 // return this flag to make the function return (handled entirely by mutator)
+       #define MUT_ITEMTOUCH_PICKUP 2 // return this flag to have the item "picked up" and taken even after mutator handled it
 
 MUTATOR_HOOKABLE(ClientConnect);
        // called at when a player connect
index 79ce5e2e14f47dfa67283af4980df1da83837c55..d1f123a8946291287e938779eff2cf1a2b78ee17 100644 (file)
@@ -549,8 +549,8 @@ MUTATOR_HOOKFUNCTION(freezetag_ForbidThrowCurrentWeapon)
 MUTATOR_HOOKFUNCTION(freezetag_ItemTouch)
 {
        if (other.freezetag_frozen)
-               return 1;
-       return 0;
+               return MUT_ITEMTOUCH_RETURN;
+       return MUT_ITEMTOUCH_CONTINUE;
 }
 
 MUTATOR_HOOKFUNCTION(freezetag_BotRoles)
index 82258ac77c115e33d144c7dc280526c0c3aa729c..193b5378ecf594af3e08e5891e1fe216a531f28d 100644 (file)
@@ -212,7 +212,7 @@ MUTATOR_HOOKFUNCTION(lms_ItemTouch)
                PlayerScore_Add(other, SP_LMS_LIVES, autocvar_g_lms_extra_lives);
        }
        
-       return FALSE;
+       return MUT_ITEMTOUCH_CONTINUE;
 }
 
 // scoreboard stuff
index 05354a2b1e1705dd01416ff5c6c9c07822898536..28e8623d69ddf191f72b47daef6ec8810c55a7e9 100644 (file)
@@ -350,15 +350,18 @@ MUTATOR_HOOKFUNCTION(minstagib_ItemTouch)
 
                if(other.health < 100)
                        other.health = 100;
+
+               return MUT_ITEMTOUCH_CONTINUE;
        }
        
        if(self.max_health)
        {
                other.armorvalue = bound(other.armorvalue, 999, other.armorvalue + autocvar_g_minstagib_extralives);
                Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_EXTRALIVES);
+               return MUT_ITEMTOUCH_PICKUP;
        }
                
-       return FALSE;
+       return MUT_ITEMTOUCH_RETURN;
 }
 
 MUTATOR_HOOKFUNCTION(minstagib_OnEntityPreSpawn)
index b11ee77ebc3d82cc1dba250e149953f43930ab80..a8e442abd390d7189ae6d440fe52b0acc99bbbca 100644 (file)
@@ -117,7 +117,7 @@ MUTATOR_HOOKFUNCTION(superspec_ItemTouch)
                                        _spectate(other);
 
                                        self = _oldself;
-                                       return FALSE;
+                                       return MUT_ITEMTOUCH_CONTINUE;
                                }
                        }
 
@@ -149,7 +149,7 @@ MUTATOR_HOOKFUNCTION(superspec_ItemTouch)
 
        self = _oldself;
 
-       return FALSE;
+       return MUT_ITEMTOUCH_CONTINUE;
 }
 
 MUTATOR_HOOKFUNCTION(superspec_SV_ParseClientCommand)
index cb6700a2cfb60a3a5e2e289ff82761976dada93a..926a4ab9df36a6faeec3214cab01510f72d7f274 100644 (file)
@@ -651,11 +651,6 @@ float Item_GiveTo(entity item, entity player)
                pickedup = TRUE;
                player.superweapons_finished = max(player.superweapons_finished, time) + item.superweapons_finished;
        }
-       if (item.max_health)
-       {
-               pickedup = TRUE;
-               // extra life powerup handled by mutators
-       }
 
 :skip
        
@@ -695,8 +690,12 @@ void Item_Touch (void)
                return;
        if (self.owner == other)
                return;
-       if(MUTATOR_CALLHOOK(ItemTouch))
-               return;
+
+       switch(MUTATOR_CALLHOOK(ItemTouch))
+       {
+               case MUT_ITEMTOUCH_RETURN: { return; }
+               case MUT_ITEMTOUCH_PICKUP: { goto pickup; }
+       }
 
        if (self.classname == "droppedweapon")
        {
@@ -717,6 +716,8 @@ void Item_Touch (void)
                return;
        }
 
+       :pickup
+
        other.last_pickup = time;
 
        pointparticles(particleeffectnum("item_pickup"), self.origin, '0 0 0', 1);