mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
- fixed: ParseParameter should not make any assumptions about the necessity of a type cast between int and float.
With late resolving it cannot be guaranteed at this point and caused some incorrectly compiled code. Since the cast gets optimized away anyway when not needed there's no point being this selective with applying it.
This commit is contained in:
parent
a7254a4af5
commit
85a3cd984d
2 changed files with 40 additions and 46 deletions
|
@ -1043,58 +1043,58 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage,
|
|||
if ((rawdamage < TELEFRAG_DAMAGE) || (target->flags7 & MF7_LAXTELEFRAGDMG)) // TELEFRAG_DAMAGE may only be reduced with LAXTELEFRAGDMG or it may not guarantee its effect.
|
||||
{
|
||||
if (player && damage > 1)
|
||||
{
|
||||
// Take half damage in trainer mode
|
||||
damage = FixedMul(damage, G_SkillProperty(SKILLP_DamageFactor));
|
||||
}
|
||||
// Special damage types
|
||||
if (inflictor)
|
||||
{
|
||||
if (inflictor->flags4 & MF4_SPECTRAL)
|
||||
{
|
||||
if (player != NULL)
|
||||
{
|
||||
if (!deathmatch && inflictor->FriendPlayer > 0)
|
||||
return -1;
|
||||
}
|
||||
else if (target->flags4 & MF4_SPECTRAL)
|
||||
{
|
||||
if (inflictor->FriendPlayer == 0 && !target->IsHostile(inflictor))
|
||||
return -1;
|
||||
}
|
||||
// Take half damage in trainer mode
|
||||
damage = FixedMul(damage, G_SkillProperty(SKILLP_DamageFactor));
|
||||
}
|
||||
// Special damage types
|
||||
if (inflictor)
|
||||
{
|
||||
if (inflictor->flags4 & MF4_SPECTRAL)
|
||||
{
|
||||
if (player != NULL)
|
||||
{
|
||||
if (!deathmatch && inflictor->FriendPlayer > 0)
|
||||
return -1;
|
||||
}
|
||||
else if (target->flags4 & MF4_SPECTRAL)
|
||||
{
|
||||
if (inflictor->FriendPlayer == 0 && !target->IsHostile(inflictor))
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
damage = inflictor->DoSpecialDamage(target, damage, mod);
|
||||
if (damage < 0)
|
||||
{
|
||||
return -1;
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int olddam = damage;
|
||||
|
||||
if (damage > 0 && source != NULL)
|
||||
{
|
||||
damage = FixedMul(damage, source->DamageMultiply);
|
||||
damage = FixedMul(damage, source->DamageMultiply);
|
||||
|
||||
// Handle active damage modifiers (e.g. PowerDamage)
|
||||
if (damage > 0 && source->Inventory != NULL)
|
||||
{
|
||||
source->Inventory->ModifyDamage(damage, mod, damage, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Handle passive damage modifiers (e.g. PowerProtection), provided they are not afflicted with protection penetrating powers.
|
||||
// Handle passive damage modifiers (e.g. PowerProtection), provided they are not afflicted with protection penetrating powers.
|
||||
if (damage > 0 && (target->Inventory != NULL) && !(flags & DMG_NO_PROTECT))
|
||||
{
|
||||
{
|
||||
target->Inventory->ModifyDamage(damage, mod, damage, true);
|
||||
}
|
||||
if (damage > 0 && !(flags & DMG_NO_FACTOR))
|
||||
{
|
||||
damage = FixedMul(damage, target->DamageFactor);
|
||||
if (damage > 0)
|
||||
{
|
||||
damage = DamageTypeDefinition::ApplyMobjDamageFactor(damage, mod, target->GetClass()->DamageFactors);
|
||||
}
|
||||
damage = FixedMul(damage, target->DamageFactor);
|
||||
if (damage > 0)
|
||||
{
|
||||
damage = DamageTypeDefinition::ApplyMobjDamageFactor(damage, mod, target->GetClass()->DamageFactors);
|
||||
}
|
||||
}
|
||||
|
||||
if (damage >= 0)
|
||||
|
@ -1105,23 +1105,23 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage,
|
|||
// '<0' is handled below. This only handles the case where damage gets reduced to 0.
|
||||
if (damage == 0 && olddam > 0)
|
||||
{
|
||||
{ // Still allow FORCEPAIN
|
||||
if (forcedPain)
|
||||
{ // Still allow FORCEPAIN
|
||||
if (forcedPain)
|
||||
{
|
||||
goto dopain;
|
||||
goto dopain;
|
||||
}
|
||||
else if (fakedPain)
|
||||
else if (fakedPain)
|
||||
{
|
||||
goto fakepain;
|
||||
goto fakepain;
|
||||
}
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (target->flags5 & MF5_NODAMAGE)
|
||||
{
|
||||
damage = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (damage < 0)
|
||||
{
|
||||
|
|
|
@ -88,17 +88,11 @@ FxExpression *ParseParameter(FScanner &sc, PClassActor *cls, PType *type, bool c
|
|||
// Do automatic coercion between ints and floats.
|
||||
if (type == TypeSInt32)
|
||||
{
|
||||
if (x->ValueType != VAL_Int)
|
||||
{
|
||||
x = new FxIntCast(x);
|
||||
}
|
||||
x = new FxIntCast(x);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x->ValueType != VAL_Float)
|
||||
{
|
||||
x = new FxFloatCast(x);
|
||||
}
|
||||
x = new FxFloatCast(x);
|
||||
}
|
||||
}
|
||||
else if (type == TypeName || type == TypeString)
|
||||
|
|
Loading…
Reference in a new issue