Skip to content

Commit

Permalink
SW: preparations for making StateFallOverride a static actor property.
Browse files Browse the repository at this point in the history
Instead of setting or clearing this variable when needed it now uses a flag for that, allowing to keep the state static later.
  • Loading branch information
coelckers committed Nov 13, 2023
1 parent cb947a2 commit d78d58a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions source/games/sw/src/actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ int DoActorBeginJump(DSWActor* actor)
else
actor->setStateGroup(NAME_Jump);

actor->user.__legacyState.StateFallOverride = nullptr;
actor->user.Flags2 &= ~SPR2_FALLOVERRIDE;

//DO NOT CALL DoActorJump! DoActorStopFall can cause an infinite loop and
//stack overflow if it is called.
Expand Down Expand Up @@ -733,7 +733,7 @@ int DoActorBeginFall(DSWActor* actor)
else
actor->setStateGroup(NAME_Fall);

if (actor->user.__legacyState.StateFallOverride)
if (actor->user.Flags2 & SPR2_FALLOVERRIDE)
{
NewStateGroup(actor, actor->user.__legacyState.StateFallOverride);
}
Expand Down
5 changes: 3 additions & 2 deletions source/games/sw/src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,8 @@ struct USER
struct LegacyState
{
FState* Rot;
FState* StateEnd;
FState* StateFallOverride; // a bit kludgy - override std fall state
FState* StateEnd; // make this a static class property, it's never use for anything else but statically set up data on actor spawn.
FState* StateFallOverride; // a bit kludgy - override std fall state (this one must also become a static class property.)
ACTOR_ACTION_SET* ActorActionSet;
int16_t RotNum;
ATTRIBUTE* Attrib;
Expand Down Expand Up @@ -972,6 +972,7 @@ enum
SPR2_VIS_SHADING = BIT(23), // Sprite shading to go along with vis adjustments
SPR2_DONT_TARGET_OWNER = BIT(24),
SPR2_FLAMEDIE = BIT(25), // was previously 'flame == -2'
SPR2_FALLOVERRIDE = BIT(26), // use the FallOverride state
};


Expand Down
3 changes: 2 additions & 1 deletion source/games/sw/src/ripper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ int SetupRipper(DSWActor* actor)
actor->user.__legacyState.Attrib = &RipperAttrib;
DoActorSetSpeed(actor, FAST_SPEED);
actor->user.__legacyState.StateEnd = s_RipperDie;
actor->user.__legacyState.StateFallOverride = s_RipperHangFall;
actor->spr.scale = DVector2(1, 1);

if (actor->spr.pal == PALETTE_BROWN_RIPPER)
Expand Down Expand Up @@ -575,7 +576,7 @@ int InitRipperHang(DSWActor* actor)
}

NewStateGroup(actor, s_RipperHangJump);
actor->user.__legacyState.StateFallOverride = s_RipperHangFall;
actor->user.Flags2 |= SPR2_FALLOVERRIDE;
DoActorSetSpeed(actor, FAST_SPEED);

PickJumpMaxSpeed(actor, -800);
Expand Down
3 changes: 2 additions & 1 deletion source/games/sw/src/ripper2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ int SetupRipper2(DSWActor* actor)
actor->user.__legacyState.Attrib = &Ripper2Attrib;
DoActorSetSpeed(actor, NORM_SPEED);
actor->user.__legacyState.StateEnd = s_Ripper2Die;
actor->user.__legacyState.StateFallOverride = s_Ripper2HangFall;
actor->clipdist = 32; // This actor is bigger, needs bigger box.
actor->spr.scale = DVector2(0.859375, 0.859375);

Expand Down Expand Up @@ -529,7 +530,7 @@ int InitRipper2Hang(DSWActor* actor)
}

NewStateGroup(actor, s_Ripper2HangJump);
actor->user.__legacyState.StateFallOverride = s_Ripper2HangFall;
actor->user.Flags2 |= SPR2_FALLOVERRIDE;
DoActorSetSpeed(actor, FAST_SPEED);

PickJumpMaxSpeed(actor, -(RandomRange(400)+100));
Expand Down
2 changes: 0 additions & 2 deletions source/games/sw/src/save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def
/*
("State", w.State, def->State)
("Rot", w.__legacyState.Rot, def->__legacyState.Rot)
("StateEnd", w.__legacyState.StateEnd, def->__legacyState.StateEnd)
("StateFallOverride", w.__legacyState.StateFallOverride, def->__legacyState.StateFallOverride)
*/
arc
("WallP", w.WallP, def->WallP)
Expand Down

0 comments on commit d78d58a

Please sign in to comment.