- use TArrays instead of TMaps to store damage factors and pain chances.

For these fields maps have no advantage. Linearly searching a small array with up to 10 entries is nearly always faster than generating a hash for finding the entry in the map.
This commit is contained in:
Christoph Oelckers 2017-04-11 23:29:37 +02:00
commit 854053a14f
12 changed files with 89 additions and 101 deletions

View file

@ -7822,7 +7822,7 @@ int AActor::ApplyDamageFactor(FName damagetype, int damage) const
damage = int(damage * DamageFactor);
if (damage > 0)
{
damage = DamageTypeDefinition::ApplyMobjDamageFactor(damage, damagetype, GetClass()->DamageFactors);
damage = DamageTypeDefinition::ApplyMobjDamageFactor(damage, damagetype, &GetClass()->DamageFactors);
}
return damage;
}
@ -8273,10 +8273,10 @@ DEFINE_ACTION_FUNCTION(AActor, ApplyDamageFactors)
PARAM_INT(damage);
PARAM_INT(defdamage);
DmgFactors *df = itemcls->DamageFactors;
if (df != nullptr && df->CountUsed() != 0)
DmgFactors &df = itemcls->DamageFactors;
if (df.Size() != 0)
{
ACTION_RETURN_INT(df->Apply(damagetype, damage));
ACTION_RETURN_INT(df.Apply(damagetype, damage));
}
else
{