# HG changeset patch # User Adam Kaminski # Date 1607028220 18000 # Thu Dec 03 15:43:40 2020 -0500 # Node ID c601bdc2ddb87c1dbda592b3fb6b49070a11ab39 # Parent 2c46abb35ba3fb7cf94c06b42b8d427cbc2ac042 Rewrote ABasicArmorPickup::Use so that it's structured almost like in GZDoom 1.8.6 while still functioning like it does in Zandronum. This also fixes faulty armor behaviour that occurred when the player's inventory was cleared. diff -r 2c46abb35ba3 -r c601bdc2ddb8 docs/zandronum-history.txt --- a/docs/zandronum-history.txt Sun Nov 29 05:56:49 2020 -0500 +++ b/docs/zandronum-history.txt Thu Dec 03 15:43:40 2020 -0500 @@ -46,6 +46,7 @@ - - Fixed missiles with the STEPMISSILE flag disappearing in online games. [Kaminsky] - - Fixed sound channels containing looped sounds not being synced with newly connected clients. [Kaminsky] - - Fixed the StopSound ACS function not working in online games. [Kaminsky] +- - Fixed faulty armor behaviour that occurred when the player's inventory was cleared. [Kaminsky] ! - sv_forcegldefaults renamed to sv_forcevideodefaults. The old name still exists for compatibility. [Dusk] ! - r_3dfloors is now forced to be true when sv_forcevideodefaults is true. [Dusk] ! - When the wad authentication fails for a connecting client, the client only reports the missing and incompatible PWADS instead of all of them. [Pol Marcet] diff -r 2c46abb35ba3 -r c601bdc2ddb8 src/g_shared/a_armor.cpp --- a/src/g_shared/a_armor.cpp Sun Nov 29 05:56:49 2020 -0500 +++ b/src/g_shared/a_armor.cpp Thu Dec 03 15:43:40 2020 -0500 @@ -248,54 +248,51 @@ bool ABasicArmorPickup::Use (bool pickup) { ABasicArmor *armor = Owner->FindInventory (); - LONG lMaxAmount; + LONG lMaxAmount = SaveAmount; if (armor == NULL) { armor = Spawn (0,0,0, NO_REPLACE); armor->BecomeItem (); - armor->SavePercent = SavePercent; - armor->Amount = armor->MaxAmount = SaveAmount; - armor->Icon = Icon; Owner->AddInventory (armor); - return true; } + else + { + // [BC] Handle max. armor bonuses, and the prosperity rune. + if ( Owner->player ) + { + if ( Owner->player->cheats & CF_PROSPERITY ) + lMaxAmount = ( deh.BlueAC * 100 ) + 50; + else + lMaxAmount += armor->BonusCount; + } - // [BC] Handle max. armor bonuses, and the prosperity rune. - lMaxAmount = SaveAmount; - if ( Owner->player ) - { - if ( Owner->player->cheats & CF_PROSPERITY ) - lMaxAmount = ( deh.BlueAC * 100 ) + 50; - else - lMaxAmount += armor->BonusCount; - } + // [BC] Changed ">=" to ">" so we can do a check below to potentially pick up armor + // that offers the same amount of armor, but a better SavePercent. - // [BC] Changed ">=" to ">" so we can do a check below to potentially pick up armor - // that offers the same amount of armor, but a better SavePercent. - - // If you already have more armor than this item gives you, you can't - // use it. - if (armor->Amount > lMaxAmount) - { - return false; - } + // If you already have more armor than this item gives you, you can't + // use it. + if (armor->Amount > lMaxAmount) + { + return false; + } - // [BC] If we have the same amount of the armor we're trying to use, but our armor offers - // better protection, don't pick it up. - if (( armor->Amount == lMaxAmount ) && ( armor->SavePercent >= SavePercent )) - return ( false ); + // [BC] If we have the same amount of the armor we're trying to use, but our armor offers + // better protection, don't pick it up. + if (( armor->Amount == lMaxAmount ) && ( armor->SavePercent >= SavePercent )) + return ( false ); - // Don't use it if you're picking it up and already have some. - if (pickup && armor->Amount > 0 && MaxAmount > 0) - { - return false; + // Don't use it if you're picking it up and already have some. + if (pickup && armor->Amount > 0 && MaxAmount > 0) + { + return false; + } } armor->SavePercent = SavePercent; - armor->MaxAmount = SaveAmount; - armor->Amount += SaveAmount; + armor->Amount += SaveAmount; // [BC] if ( armor->Amount > lMaxAmount ) armor->Amount = lMaxAmount; + armor->MaxAmount = SaveAmount; armor->Icon = Icon; armor->MaxAbsorb = MaxAbsorb; armor->MaxFullAbsorb = MaxFullAbsorb;