]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/items/items.qc
Clear item waypoints when deleting items to fix issues with dropped powerups
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / items / items.qc
index ade4795c523e420e56c77f4f5b5164cbc8250179..5758a7fda777d2b2191402661ea3c740f7cb3efc 100644 (file)
@@ -12,6 +12,7 @@
 #include <common/mutators/mutator/powerups/_mod.qh>
 #include <common/mutators/mutator/status_effects/_mod.qh>
 #include <common/notifications/all.qh>
+#include <common/resources/resources.qh>
 #include <common/util.qh>
 #include <common/weapons/_all.qh>
 #include <common/wepent.qh>
@@ -447,7 +448,7 @@ void GiveRandomWeapons(entity receiver, int num_weapons, string weapon_names,
        }
 }
 
-bool Item_GiveAmmoTo(entity item, entity player, int res_type, float ammomax)
+bool Item_GiveAmmoTo(entity item, entity player, Resource res_type, float ammomax)
 {
        float amount = GetResource(item, res_type);
        if (amount == 0)
@@ -483,7 +484,7 @@ bool Item_GiveTo(entity item, entity player)
        // if the player is using their best weapon before items are given, they
        // probably want to switch to an even better weapon after items are given
 
-       if(CS_CVAR(player).autoswitch)
+       if(CS_CVAR(player).cvar_cl_autoswitch)
        {
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
@@ -634,7 +635,7 @@ void Item_Touch(entity this, entity toucher)
        {
                if (ITEM_TOUCH_NEEDKILL())
                {
-                       delete(this);
+                       RemoveItem(this);
                        return;
                }
        }
@@ -786,6 +787,8 @@ void Item_FindTeam(entity this)
 void RemoveItem(entity this)
 {
        if(wasfreed(this) || !this) { return; }
+       if(this.waypointsprite_attached)
+               WaypointSprite_Kill(this.waypointsprite_attached);
        Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(this), '0 0 0', 1);
        delete(this);
 }
@@ -976,7 +979,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
 
        if (Item_IsLoot(this))
        {
-               this.reset = SUB_Remove;
+               this.reset = RemoveItem;
                set_movetype(this, MOVETYPE_TOSS);
 
                // Savage: remove thrown items after a certain period of time ("garbage collection")
@@ -1093,7 +1096,6 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
 
        // support skinned models for powerups
        this.skin = def.m_skin;
-       this.glowmod = def.m_color;
 
        setsize (this, this.pos1 =  def.m_mins, this.pos2 = def.m_maxs);
 
@@ -1109,6 +1111,8 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
 
        if(Item_IsLoot(this))
                this.gravity = 1;
+       else
+               this.glowmod = def.m_color;
 
        if(def.instanceOfWeaponPickup)
        {
@@ -1434,12 +1438,12 @@ void GiveSound(entity e, float v0, float v1, float t, Sound snd_incr, Sound snd_
        if(v1 <= v0 - t)
        {
                if(snd_decr != NULL)
-                       sound (e, CH_TRIGGER, snd_decr, VOL_BASE, ATTEN_NORM);
+                       sound(e, CH_TRIGGER, snd_decr, VOL_BASE, ATTEN_NORM);
        }
        else if(v0 >= v0 + t)
        {
                if(snd_incr != NULL)
-                       sound (e, CH_TRIGGER, snd_incr, VOL_BASE, ATTEN_NORM);
+                       sound(e, ((snd_incr == SND_POWERUP) ? CH_TRIGGER_SINGLE : CH_TRIGGER), snd_incr, VOL_BASE, ATTEN_NORM);
        }
 }
 
@@ -1450,7 +1454,7 @@ void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .floa
        else if(v0 > v1)
                e.(regenfield) = max(e.(regenfield), time + regentime);
 }
-bool GiveResourceValue(entity e, int res_type, int op, int val)
+bool GiveResourceValue(entity e, Resource res_type, int op, int val)
 {
        int v0 = GetResource(e, res_type);
        float new_val = 0;
@@ -1512,7 +1516,7 @@ float GiveItems(entity e, float beginarg, float endarg)
 
        int _switchweapon = 0;
 
-       if(CS_CVAR(e).autoswitch)
+       if(CS_CVAR(e).cvar_cl_autoswitch)
        {
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {