Skip to content

Commit 3e91d38

Browse files
MajorCookemadame-rachelle
authored andcommitted
Fixed Pre(Un)Morph being called out of order.
- This had broken several mods that relied on the inventory being in place before the switch, which was the intended way to begin with.
1 parent 5fc3d44 commit 3e91d38

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

src/playsim/p_mobj.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5345,6 +5345,42 @@ int MorphPointerSubstitution(AActor* from, AActor* to)
53455345
return false;
53465346
}
53475347

5348+
// [MC] Had to move this here since ObtainInventory was also moved as well. Should be called
5349+
// before any transference of items since that's what was intended when introduced.
5350+
if (!from->alternative) // Morphing into
5351+
{
5352+
{
5353+
IFVIRTUALPTR(from, AActor, PreMorph)
5354+
{
5355+
VMValue params[] = { from, to, false };
5356+
VMCall(func, params, 3, nullptr, 0);
5357+
}
5358+
}
5359+
{
5360+
IFVIRTUALPTR(to, AActor, PreMorph)
5361+
{
5362+
VMValue params[] = { to, from, true };
5363+
VMCall(func, params, 3, nullptr, 0);
5364+
}
5365+
}
5366+
}
5367+
else // Unmorphing back
5368+
{
5369+
{
5370+
IFVIRTUALPTR(from, AActor, PreUnmorph)
5371+
{
5372+
VMValue params[] = { from, to, false };
5373+
VMCall(func, params, 3, nullptr, 0);
5374+
}
5375+
}
5376+
{
5377+
IFVIRTUALPTR(to, AActor, PreUnmorph)
5378+
{
5379+
VMValue params[] = { to, from, true };
5380+
VMCall(func, params, 3, nullptr, 0);
5381+
}
5382+
}
5383+
}
53485384
// Since the check is good, move the inventory items over. This should always be done when
53495385
// morphing to emulate Heretic/Hexen's behavior since those stored the inventory in their
53505386
// player structs.

wadsrc/static/zscript/actors/morph.zs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ extend class Actor
9999
}
100100

101101
// [MC] Called when an actor morphs, on both the previous form (!current) and present form (current).
102+
// Due to recent changes, these are now called internally instead of within the virtuals.
102103
virtual void PreMorph(Actor mo, bool current) {}
103104
virtual void PostMorph(Actor mo, bool current) {}
104105
virtual void PreUnmorph(Actor mo, bool current) {}

wadsrc/static/zscript/actors/player/player_morph.zs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ extend class PlayerPawn
129129
return false;
130130
}
131131

132-
PreMorph(morphed, false);
133-
morphed.PreMorph(self, true);
134-
135132
morphed.EndAllPowerupEffects();
136133

137134
if ((style & MRF_TRANSFERTRANSLATION) && !morphed.bDontTranslate)
@@ -259,9 +256,6 @@ extend class PlayerPawn
259256
if (!MorphInto(alt))
260257
return false;
261258

262-
PreUnmorph(alt, false); // This body's about to be left.
263-
alt.PreUnmorph(self, true); // This one's about to become current.
264-
265259
alt.EndAllPowerupEffects();
266260

267261
// Remove the morph power if the morph is being undone prematurely.

0 commit comments

Comments
 (0)