- fixed: A global variable was used to pass MeansOfDeath to ClientObituary.

The problem here is that this affects the public scripting interface so it cannot be committed to master without further adjustments.

# Conflicts:
#	src/p_interaction.cpp
This commit is contained in:
Christoph Oelckers 2018-04-23 21:26:05 +02:00
commit ff69d945e1
10 changed files with 32 additions and 33 deletions

View file

@ -78,8 +78,6 @@ CVAR (Float, sv_damagefactormobj, 1.0, CVAR_SERVERINFO|CVAR_CHEAT)
CVAR (Float, sv_damagefactorfriendly, 1.0, CVAR_SERVERINFO|CVAR_CHEAT)
CVAR (Float, sv_damagefactorplayer, 1.0, CVAR_SERVERINFO|CVAR_CHEAT)
FName MeansOfDeath;
//
// GET STUFF
//
@ -182,7 +180,7 @@ void SexMessage (const char *from, char *to, int gender, const char *victim, con
// [RH]
// ClientObituary: Show a message when a player dies
//
void ClientObituary (AActor *self, AActor *inflictor, AActor *attacker, int dmgflags)
void ClientObituary (AActor *self, AActor *inflictor, AActor *attacker, int dmgflags, FName MeansOfDeath)
{
FName mod;
FString ret;
@ -284,7 +282,7 @@ void ClientObituary (AActor *self, AActor *inflictor, AActor *attacker, int dmgf
//
EXTERN_CVAR (Int, fraglimit)
void AActor::Die (AActor *source, AActor *inflictor, int dmgflags)
void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOfDeath)
{
// Handle possible unmorph on death
bool wasgibbed = (health < GetGibHealth());
@ -303,7 +301,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags)
realthis->health = realgibhealth -1; // if morphed was gibbed, so must original be (where allowed)l
}
}
realthis->CallDie(source, inflictor, dmgflags);
realthis->CallDie(source, inflictor, dmgflags, MeansOfDeath);
}
return;
}
@ -555,7 +553,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags)
if (player)
{
// [RH] Death messages
ClientObituary (this, inflictor, source, dmgflags);
ClientObituary (this, inflictor, source, dmgflags, MeansOfDeath);
// [ZZ] fire player death hook
E_PlayerDied(int(player - players));
@ -728,18 +726,19 @@ DEFINE_ACTION_FUNCTION(AActor, Die)
PARAM_OBJECT(source, AActor);
PARAM_OBJECT(inflictor, AActor);
PARAM_INT_DEF(dmgflags);
self->Die(source, inflictor, dmgflags);
PARAM_NAME_DEF(MeansOfDeath);
self->Die(source, inflictor, dmgflags, MeansOfDeath);
return 0;
}
void AActor::CallDie(AActor *source, AActor *inflictor, int dmgflags)
void AActor::CallDie(AActor *source, AActor *inflictor, int dmgflags, FName MeansOfDeath)
{
IFVIRTUAL(AActor, Die)
{
VMValue params[4] = { (DObject*)this, source, inflictor, dmgflags };
VMCall(func, params, 4, nullptr, 0);
VMValue params[] = { (DObject*)this, source, inflictor, dmgflags, MeansOfDeath.GetIndex() };
VMCall(func, params, 5, nullptr, 0);
}
else return Die(source, inflictor, dmgflags);
else return Die(source, inflictor, dmgflags, MeansOfDeath);
}
@ -936,6 +935,7 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da
{ // Shouldn't happen
return 0;
}
FName MeansOfDeath = mod;
// Rather than unnecessarily call the function over and over again, let's be a little more efficient.
// But first, check and see if it's even needed, which it won't be if pain must not be triggered.
@ -1015,7 +1015,6 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da
flags |= DMG_NO_ARMOR;
}
MeansOfDeath = mod;
// [RH] Andy Baker's Stealth monsters
if (target->flags & MF_STEALTH)
{
@ -1510,7 +1509,7 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da
E_WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle);
needevent = false;
target->CallDie (source, inflictor, flags);
target->CallDie (source, inflictor, flags, MeansOfDeath);
return realdamage;
}
}
@ -1641,7 +1640,7 @@ DEFINE_ACTION_FUNCTION(AActor, DamageMobj)
int realdamage = DamageMobj(self, inflictor, source, damage, mod, flags, angle, needevent);
if (realdamage && needevent)
{
E_WorldThingDamaged(self, inflictor, source, realdamage, mod, flags, angle);
E_WorldThingDamaged(self, inflictor, source, realdamage, mod, flags, angle);
}
ACTION_RETURN_INT(realdamage);
}
@ -1663,8 +1662,8 @@ int P_DamageMobj(AActor *target, AActor *inflictor, AActor *source, int damage,
int realdamage = DamageMobj(target, inflictor, source, damage, mod, flags, angle, needevent);
if (realdamage && needevent)
{
// [ZZ] event handlers only need the resultant damage (they can't do anything about it anyway)
E_WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle);
// [ZZ] event handlers only need the resultant damage (they can't do anything about it anyway)
E_WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle);
}
return realdamage;
}