Skip to content

Commit 7720365

Browse files
Merge commit 'refs/pull/2505/head' of https://github.com/coelckers/gzdoom
2 parents 949cd5b + 3a2784e commit 7720365

25 files changed

+873
-744
lines changed

src/g_level.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ int FLevelLocals::FinishTravel ()
17111711
pawn->flags2 &= ~MF2_BLASTED;
17121712
if (oldpawn != nullptr)
17131713
{
1714-
StaticPointerSubstitution (oldpawn, pawn);
1714+
PlayerPointerSubstitution (oldpawn, pawn, true);
17151715
oldpawn->Destroy();
17161716
}
17171717
if (pawndup != NULL)

src/g_statusbar/sbar_mugshot.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ FGameTexture *FMugShot::GetFace(player_t *player, const char *default_face, int
479479
if (CurrentState != NULL)
480480
{
481481
int skin = player->userinfo.GetSkin();
482-
const char *skin_face = (stateflags & FMugShot::CUSTOM) ? nullptr : (player->morphTics ? (GetDefaultByType(player->MorphedPlayerClass))->NameVar(NAME_Face).GetChars() : Skins[skin].Face.GetChars());
482+
const char *skin_face = (stateflags & FMugShot::CUSTOM) ? nullptr : (player->mo->alternative != nullptr ? (GetDefaultByType(player->MorphedPlayerClass))->NameVar(NAME_Face).GetChars() : Skins[skin].Face.GetChars());
483483
return CurrentState->GetCurrentFrameTexture(default_face, skin_face, level, angle);
484484
}
485485
return NULL;

src/m_cheat.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -626,10 +626,13 @@ class DSuicider : public DThinker
626626
double plyrdmgfact = Pawn->DamageFactor;
627627
Pawn->DamageFactor = 1.;
628628
P_DamageMobj (Pawn, Pawn, Pawn, TELEFRAG_DAMAGE, NAME_Suicide);
629-
Pawn->DamageFactor = plyrdmgfact;
630-
if (Pawn->health <= 0)
629+
if (Pawn != nullptr)
631630
{
632-
Pawn->flags &= ~MF_SHOOTABLE;
631+
Pawn->DamageFactor = plyrdmgfact;
632+
if (Pawn->health <= 0)
633+
{
634+
Pawn->flags &= ~MF_SHOOTABLE;
635+
}
633636
}
634637
Destroy();
635638
}

src/p_saveg.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ void FLevelLocals::UnSnapshotLevel(bool hubLoad)
11381138
// If this isn't the unmorphed original copy of a player, destroy it, because it's extra.
11391139
for (i = 0; i < MAXPLAYERS; ++i)
11401140
{
1141-
if (PlayerInGame(i) && Players[i]->morphTics && Players[i]->mo->alternative == pawn)
1141+
if (PlayerInGame(i) && Players[i]->mo->alternative == pawn)
11421142
{
11431143
break;
11441144
}

src/playsim/a_morph.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ bool P_MorphActor(AActor *activator, AActor *victim, PClassActor *ptype, PClassA
3737

3838
bool P_UnmorphActor(AActor *activator, AActor *morphed, int flags, bool force)
3939
{
40-
IFVIRTUALPTR(morphed, AActor, UnMorph)
40+
IFVIRTUALPTR(morphed, AActor, Unmorph)
4141
{
4242
VMValue params[] = { morphed, activator, flags, force };
4343
int retval;

src/playsim/a_morph.h

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ enum
2626
MORPH_UNDOBYTIMEOUT = 0x00001000, // Player unmorphs once countdown expires
2727
MORPH_UNDOALWAYS = 0x00002000, // Powerups must always unmorph, no matter what.
2828
MORPH_TRANSFERTRANSLATION = 0x00004000, // Transfer translation from the original actor to the morphed one
29+
MORPH_KEEPARMOR = 0x00008000, // Don't lose current armor value when morphing.
30+
MORPH_IGNOREINVULN = 0x00010000, // Completely ignore invulnerability status on players.
2931

3032
MORPH_STANDARDUNDOING = MORPH_UNDOBYTOMEOFPOWER | MORPH_UNDOBYCHAOSDEVICE | MORPH_UNDOBYTIMEOUT,
3133
};

src/playsim/actor.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1747,8 +1747,8 @@ struct FTranslatedLineTarget
17471747
bool unlinked; // found by a trace that went through an unlinked portal.
17481748
};
17491749

1750-
1751-
void StaticPointerSubstitution(AActor* old, AActor* notOld);
1750+
void PlayerPointerSubstitution(AActor* oldPlayer, AActor* newPlayer, bool removeOld);
1751+
int MorphPointerSubstitution(AActor* from, AActor* to);
17521752

17531753
#define S_FREETARGMOBJ 1
17541754

src/playsim/p_enemy.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3139,7 +3139,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Pain)
31393139
PARAM_SELF_PROLOGUE(AActor);
31403140

31413141
// [RH] Vary player pain sounds depending on health (ala Quake2)
3142-
if (self->player && self->player->morphTics == 0)
3142+
if (self->player && self->alternative == nullptr)
31433143
{
31443144
const char *pain_amount;
31453145
FSoundID sfx_id = NO_SOUND;

src/playsim/p_interaction.cpp

+40-22
Original file line numberDiff line numberDiff line change
@@ -313,36 +313,54 @@ EXTERN_CVAR (Int, fraglimit)
313313

314314
void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOfDeath)
315315
{
316-
// Handle possible unmorph on death
317316
bool wasgibbed = (health < GetGibHealth());
318317

318+
// Check to see if unmorph Actors need to be killed as well. Originally this was always
319+
// called but that puts an unnecessary burden on the modder to determine whether it's
320+
// a valid call or not.
321+
if (alternative != nullptr && !(flags & MF_UNMORPHED))
319322
{
320323
IFVIRTUAL(AActor, MorphedDeath)
321324
{
322-
AActor *realthis = NULL;
323-
int realstyle = 0;
324-
int realhealth = 0;
325+
// Return values are no longer used to ensure things stay properly managed.
326+
AActor* const realMo = alternative;
327+
int morphStyle = 0;
325328

326329
VMValue params[] = { this };
327-
VMReturn returns[3];
328-
returns[0].PointerAt((void**)&realthis);
329-
returns[1].IntAt(&realstyle);
330-
returns[2].IntAt(&realhealth);
331-
VMCall(func, params, 1, returns, 3);
332330

333-
if (realthis && !(realstyle & MORPH_UNDOBYDEATHSAVES))
334331
{
335-
if (wasgibbed)
332+
IFVM(Actor, GetMorphStyle)
336333
{
337-
int realgibhealth = realthis->GetGibHealth();
338-
if (realthis->health >= realgibhealth)
339-
{
340-
realthis->health = realgibhealth - 1; // if morphed was gibbed, so must original be (where allowed)l
341-
}
334+
VMReturn ret[] = { &morphStyle };
335+
VMCall(func, params, 1, ret, 1);
342336
}
343-
realthis->CallDie(source, inflictor, dmgflags, MeansOfDeath);
344337
}
345338

339+
VMCall(func, params, 1, nullptr, 0);
340+
341+
// Kill the dummy Actor if it didn't unmorph, otherwise checking the morph flags. Player pawns need
342+
// to stay, otherwise they won't respawn correctly.
343+
if (realMo != nullptr && !(realMo->flags6 & MF6_KILLED)
344+
&& ((alternative != nullptr && player == nullptr) || (alternative == nullptr && !(morphStyle & MORPH_UNDOBYDEATHSAVES))))
345+
{
346+
if (wasgibbed)
347+
{
348+
const int realGibHealth = realMo->GetGibHealth();
349+
if (realMo->health >= realGibHealth)
350+
realMo->health = realGibHealth - 1; // If morphed was gibbed, so must original be (where allowed).
351+
}
352+
else if (realMo->health > 0)
353+
{
354+
realMo->health = 0;
355+
}
356+
357+
// Pass appropriate damage information along when it's confirmed to die.
358+
realMo->DamageTypeReceived = DamageTypeReceived;
359+
realMo->DamageType = DamageType;
360+
realMo->special1 = special1;
361+
362+
realMo->CallDie(source, inflictor, dmgflags, MeansOfDeath);
363+
}
346364
}
347365
}
348366

@@ -458,7 +476,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
458476
++source->player->spreecount;
459477
}
460478

461-
if (source->player->morphTics)
479+
if (source->alternative != nullptr)
462480
{ // Make a super chicken
463481
source->GiveInventoryType (PClass::FindActor(NAME_PowerWeaponLevel2));
464482
}
@@ -1329,7 +1347,7 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da
13291347

13301348
if (damage >= player->health && !telefragDamage
13311349
&& (G_SkillProperty(SKILLP_AutoUseHealth) || deathmatch)
1332-
&& !player->morphTics)
1350+
&& target->alternative == nullptr)
13331351
{ // Try to use some inventory health
13341352
P_AutoUseHealth (player, damage - player->health + 1);
13351353
}
@@ -1463,7 +1481,7 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da
14631481
// check for special fire damage or ice damage deaths
14641482
if (mod == NAME_Fire)
14651483
{
1466-
if (player && !player->morphTics)
1484+
if (player && target->alternative == nullptr)
14671485
{ // Check for flame death
14681486
if (!inflictor ||
14691487
((target->health > -50) && (damage > 25)) ||
@@ -1797,7 +1815,7 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage, bool playPain
17971815
}
17981816
if (damage >= player->health
17991817
&& (G_SkillProperty(SKILLP_AutoUseHealth) || deathmatch)
1800-
&& !player->morphTics)
1818+
&& target->alternative == nullptr)
18011819
{ // Try to use some inventory health
18021820
P_AutoUseHealth(player, damage - player->health+1);
18031821
}
@@ -1827,7 +1845,7 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage, bool playPain
18271845
else
18281846
{
18291847
target->special1 = damage;
1830-
if (player && !player->morphTics)
1848+
if (player && target->alternative == nullptr)
18311849
{ // Check for flame death
18321850
if ((player->poisontype == NAME_Fire) && (target->health > -50) && (damage > 25))
18331851
{

0 commit comments

Comments
 (0)