Fix bug with reapplying Advance Shield not properly re-enabling the shield drop timer causing the shield to last permanently on the player character. Add test case to cover this edge case. Release Build 11094.

This commit is contained in:
sigonasr2 2024-08-28 18:12:53 -05:00
parent 182e492991
commit beb8e38b36
5 changed files with 13 additions and 2 deletions

View File

@ -1088,6 +1088,12 @@ namespace EnchantTests
game->SetElapsedTime(9.f);
game->OnUserUpdate(9.f);
Assert::AreEqual(0U,player->GetShield(),L"The Advance Shield enchant shield lasts 9 seconds. It should have worn off after that time.");
player->GetRightClickAbility().charges=1;
player->CheckAndPerformAbility(player->GetRightClickAbility(),testKeyboardInput);
Assert::AreEqual(int(player->GetMaxHealth()*0.2f),int(player->GetShield()),L"The Advance Shield enchant provides a 20% health player shield.");
game->SetElapsedTime(9.f);
game->OnUserUpdate(9.f);
Assert::AreEqual(0U,player->GetShield(),L"The Advance Shield enchant shield lasts 9 seconds. It should have worn off after that time."); //Double check that reapplication still works for applying shields, since it's possible the timer already existing in the array could be bugged.... Cover this edge case!
}
TEST_METHOD(BattleShoutNoEnchantCheck){
testKey->bHeld=true; //Force the key to be held down for testing purposes.

View File

@ -178,6 +178,11 @@ void MonsterData::InitializeMonsterData(){
DATA["Monsters"][MonsterName]["CollisionDmg"].GetInt()
);
if(DATA["Monsters"][MonsterName].HasProperty("Immovable")){
monster.immovable=DATA["Monsters"][MonsterName]["Immovable"].GetBool();
if(DATA["Monsters"][MonsterName].HasProperty("Fadeout"))monster.fadeout=DATA["Monsters"][MonsterName]["Fadeout"].GetBool();
else monster.fadeout=true;
}
if(DATA["Monsters"][MonsterName].HasProperty("Fadeout"))monster.fadeout=DATA["Monsters"][MonsterName]["Fadeout"].GetBool();
if(DATA["Monsters"][MonsterName].HasProperty("No Facing"))monster.noFacing=DATA["Monsters"][MonsterName]["No Facing"].GetBool();
if(DATA["Monsters"][MonsterName].HasProperty("Ignore Collisions"))monster.ignoresCollision=DATA["Monsters"][MonsterName]["Ignore Collisions"].GetBool();
@ -186,7 +191,6 @@ void MonsterData::InitializeMonsterData(){
if(DATA["Monsters"][MonsterName]["Mounted Animation Offset"].GetValueCount()==2)monster.mountedAnimationOffset={DATA["Monsters"][MonsterName]["Mounted Animation Offset"].GetReal(0),DATA["Monsters"][MonsterName]["Mounted Animation Offset"].GetReal(1)};
else ERR(std::format("WARNING! Monster {} containing a mounted animation offset has {} for reading in a vector, when vectors are supposed to only have two values! Please check the \"Mounted Animation Offset\" configuration value for {}",MonsterName,DATA["Monsters"][MonsterName]["Mounted Animation Offset"].GetValueCount(),MonsterName));
}
if(DATA["Monsters"][MonsterName].HasProperty("Immovable"))monster.immovable=DATA["Monsters"][MonsterName]["Immovable"].GetBool();
if(DATA["Monsters"][MonsterName].HasProperty("Invulnerable"))monster.invulnerable=DATA["Monsters"][MonsterName]["Invulnerable"].GetBool();
if(DATA["Monsters"][MonsterName].HasProperty("Lifetime"))monster.lifetime=DATA["Monsters"][MonsterName]["Lifetime"].GetReal();

View File

@ -2171,6 +2171,7 @@ void Player::AddShield(const ShieldAmount shieldAmt,const float shieldTimer, con
if(shieldIt!=shield.end()){
std::pair<PlayerTimerType,ShieldAmount>&shieldData{*shieldIt};
shieldData.second=std::max(shieldData.second,shieldAmt);
AddTimer(shieldType,Timer{std::format("Shield Type {}",int(shieldType)),shieldTimer,[&shieldData,this](){shieldData.second=0U;}});
}else ERR(std::format("WARNING! The shield type {} does not have a corresponding entry! All shields when generated should have made one! THIS SHOULD NOT BE HAPPENING!",int(shieldType)));
}else{
std::pair<PlayerTimerType,ShieldAmount>&newShield{shield.emplace_back(std::pair<PlayerTimerType,ShieldAmount>{shieldType,shieldAmt})};

View File

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_PATCH 3
#define VERSION_BUILD 11085
#define VERSION_BUILD 11094
#define stringify(a) stringify_(a)
#define stringify_(a) #a