From 9fcc6ebc89ff66b7fb1d3648d237f9ae14fb1317 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 23 Mar 2012 01:20:45 +0000 Subject: [PATCH] - Fixed: Armor did not use damagefactor "Normal" as a fallback factor. SVN r3469 (trunk) --- src/g_shared/a_armor.cpp | 6 +++--- src/g_shared/a_artifacts.cpp | 6 ++---- src/info.cpp | 19 +++++++++++++++++++ src/info.h | 5 ++++- src/p_interaction.cpp | 3 +-- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/g_shared/a_armor.cpp b/src/g_shared/a_armor.cpp index 8b6f289535..bcd48d804b 100644 --- a/src/g_shared/a_armor.cpp +++ b/src/g_shared/a_armor.cpp @@ -171,13 +171,13 @@ void ABasicArmor::AbsorbDamage (int damage, FName damageType, int &newdamage) if ((damage > 0) && (ArmorType != NAME_None)) // BasicArmor is not going to have any damage factor, so skip it. { // This code is taken and adapted from APowerProtection::ModifyDamage(). - // The differences include not checking for the NAME_None key (doesn't seem appropriate here), - // not using a default value, and of course the way the damage factor info is obtained. + // The differences include not using a default value, and of course the way + // the damage factor info is obtained. const fixed_t *pdf = NULL; DmgFactors *df = PClass::FindClass(ArmorType)->ActorInfo->DamageFactors; if (df != NULL && df->CountUsed() != 0) { - pdf = df->CheckKey(damageType); + pdf = df->CheckFactor(damageType); if (pdf != NULL) { damage = newdamage = FixedMul(damage, *pdf); diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 0499b51b1b..ede148c6e7 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -1511,8 +1511,7 @@ void APowerDamage::ModifyDamage(int damage, FName damageType, int &newdamage, bo DmgFactors * df = GetClass()->ActorInfo->DamageFactors; if (df != NULL && df->CountUsed() != 0) { - pdf = df->CheckKey(damageType); - if (pdf== NULL && damageType != NAME_None) pdf = df->CheckKey(NAME_None); + pdf = df->CheckFactor(damageType); } else { @@ -1592,8 +1591,7 @@ void APowerProtection::ModifyDamage(int damage, FName damageType, int &newdamage DmgFactors *df = GetClass()->ActorInfo->DamageFactors; if (df != NULL && df->CountUsed() != 0) { - pdf = df->CheckKey(damageType); - if (pdf == NULL && damageType != NAME_None) pdf = df->CheckKey(NAME_None); + pdf = df->CheckFactor(damageType); } else pdf = &def; diff --git a/src/info.cpp b/src/info.cpp index 3a59380cf3..fe06e6f6b5 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -344,6 +344,25 @@ void FActorInfo::SetColorSet(int index, const FPlayerColorSet *set) } } +//========================================================================== +// +// DmgFactors :: CheckFactor +// +// Checks for the existance of a certain damage type. If that type does not +// exist, the damage factor for type 'None' will be returned, if present. +// +//========================================================================== + +fixed_t *DmgFactors::CheckFactor(FName type) +{ + fixed_t *pdf = CheckKey(type); + if (pdf == NULL && type != NAME_None) + { + pdf = CheckKey(NAME_None); + } + return pdf; +} + //========================================================================== // // diff --git a/src/info.h b/src/info.h index f29871903f..60397d7f9b 100644 --- a/src/info.h +++ b/src/info.h @@ -177,7 +177,10 @@ struct FPlayerColorSet ExtraRange Extra[6]; }; -typedef TMap DmgFactors; +struct DmgFactors : public TMap +{ + fixed_t *CheckFactor(FName type); +}; typedef TMap PainChanceList; typedef TMap PainFlashList; typedef TMap FPlayerColorSetMap; diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index ca75ffe6ce..47a971c44a 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1000,8 +1000,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage DmgFactors *df = target->GetClass()->ActorInfo->DamageFactors; if (df != NULL) { - fixed_t *pdf = df->CheckKey(mod); - if (pdf== NULL && mod != NAME_None) pdf = df->CheckKey(NAME_None); + fixed_t *pdf = df->CheckFactor(mod); if (pdf != NULL) { damage = FixedMul(damage, *pdf);