- Fixed: Armor did not use damagefactor "Normal" as a fallback factor.

SVN r3469 (trunk)
This commit is contained in:
Randy Heit 2012-03-23 01:20:45 +00:00
parent bff5a9b8d8
commit 9fcc6ebc89
5 changed files with 29 additions and 10 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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;
}
//==========================================================================
//
//

View file

@ -177,7 +177,10 @@ struct FPlayerColorSet
ExtraRange Extra[6];
};
typedef TMap<FName, fixed_t> DmgFactors;
struct DmgFactors : public TMap<FName, fixed_t>
{
fixed_t *CheckFactor(FName type);
};
typedef TMap<FName, int> PainChanceList;
typedef TMap<FName, PalEntry> PainFlashList;
typedef TMap<int, FPlayerColorSet> FPlayerColorSetMap;

View file

@ -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);