[Fixed] AbsorbDamage not handling destroyed items correctly

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

AbsorbDamage not handling destroyed items correctly

Postby Player701 » Tue Nov 17, 2020 2:21 am

If an item has an AbsorbDamage override that can result in said item immediately destroying itself, the rest of the damage will not be absorbed by the remaining items in the inventory chain. The latter usually includes armor, so it's very easy to notice. To reproduce, use this example ZScript:

Code: Select allExpand view
class TestInv : Inventory
{
    override void AbsorbDamage (int damage, Name damageType, out int newdamage, Actor inflictor, Actor source, int flags)
    {
        int absorbed = Min(1, damage);
        newdamage -= absorbed;
        Destroy();
    }
}

Load any map, give testinv and IDKFA. Note that the damage you receive from the first enemy shot passes right through your armor. After that, everything is OK.

This issue can be fixed by remembering the next inventory pointer in the AbsorbDamage loop in p_mobj.cpp.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: AbsorbDamage not handling destroyed items correctly

Postby Player701 » Tue Nov 17, 2020 5:26 am

Since this wasn't closed on sight as "user error", here is a PR to fix this.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 1 guest