mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-29 07:21:54 +00:00
SW: moved State out of the __legacyState struct.
This commit is contained in:
parent
1cb3a930f2
commit
215d929df7
12 changed files with 49 additions and 48 deletions
|
@ -1086,7 +1086,7 @@ void DSWActor::callAction()
|
|||
|
||||
void DSWActor::callStateAction()
|
||||
{
|
||||
user.__legacyState.State->CallAction(this);
|
||||
user.State->CallAction(this);
|
||||
}
|
||||
|
||||
END_SW_NS
|
||||
|
|
|
@ -1005,7 +1005,7 @@ bool NullActor(DSWActor* actor)
|
|||
return true;
|
||||
|
||||
// does not have a STATE or FUNC to control it
|
||||
if (!actor->user.__legacyState.State)
|
||||
if (!actor->user.State)
|
||||
return true;
|
||||
|
||||
// does not have a STATE or FUNC to control it
|
||||
|
|
|
@ -107,11 +107,11 @@ int SetActorRotation(tspriteArray& tsprites, int tSpriteNum, const DVector2& vie
|
|||
tspritetype* tsp = tsprites.get(tSpriteNum);
|
||||
auto ownerActor = static_cast<DSWActor*>(tsp->ownerActor);
|
||||
|
||||
if (!ownerActor->hasU() || ownerActor->user.__legacyState.State == nullptr)
|
||||
if (!ownerActor->hasU() || ownerActor->user.State == nullptr)
|
||||
return 0;
|
||||
|
||||
unsigned sprite = ownerActor->user.__legacyState.State->sprite;
|
||||
unsigned frame = ownerActor->user.__legacyState.State->Frame - 'A';
|
||||
unsigned sprite = ownerActor->user.State->sprite;
|
||||
unsigned frame = ownerActor->user.State->Frame - 'A';
|
||||
|
||||
if (SpriteDefs.Size() <= sprite) return 0;
|
||||
auto spdef = &SpriteDefs[sprite];
|
||||
|
@ -479,9 +479,9 @@ void DoStarView(tspritetype* tsp, DSWActor* tActor, double viewz)
|
|||
if (abs(zdiff) > 24)
|
||||
{
|
||||
if (tActor->user.__legacyState.StateStart == s_StarStuck)
|
||||
tsp->setspritetexture(picFromState(&s_StarDownStuck[tActor->user.__legacyState.State - s_StarStuck]));
|
||||
tsp->setspritetexture(picFromState(&s_StarDownStuck[tActor->user.State - s_StarStuck]));
|
||||
else
|
||||
tsp->setspritetexture(picFromState(&s_StarDown[tActor->user.__legacyState.State - s_Star]));
|
||||
tsp->setspritetexture(picFromState(&s_StarDown[tActor->user.State - s_Star]));
|
||||
|
||||
if (zdiff > 0)
|
||||
tsp->cstat |= (CSTAT_SPRITE_YFLIP);
|
||||
|
@ -1059,7 +1059,7 @@ void PreDrawStackedWater(void)
|
|||
|
||||
// copy everything reasonable from the user that
|
||||
// analyzesprites() needs to draw the image
|
||||
actorNew->user.__legacyState.State = itActor2->user.__legacyState.State;
|
||||
actorNew->user.State = itActor2->user.State;
|
||||
actorNew->user.__legacyState.Rot = itActor2->user.__legacyState.Rot;
|
||||
actorNew->user.__legacyState.StateStart = itActor2->user.__legacyState.StateStart;
|
||||
actorNew->user.__legacyState.StateEnd = itActor2->user.__legacyState.StateEnd;
|
||||
|
|
|
@ -706,9 +706,10 @@ struct USER
|
|||
VMFunction* ActorActionFunc;
|
||||
PERSONALITY* Personality;
|
||||
|
||||
FState* State;
|
||||
|
||||
struct LegacyState
|
||||
{
|
||||
FState* State;
|
||||
FState* Rot;
|
||||
FState* StateStart;
|
||||
FState* StateEnd;
|
||||
|
|
|
@ -156,7 +156,7 @@ FState s_GirlNinjaRise[] =
|
|||
{SPR_GIRLNINJA_STAND, 'A', GIRLNINJA_STAND_RATE, &AF(NullGirlNinja), &s_GirlNinjaRise[2]},
|
||||
{SPR_NULL, 0, 0, nullptr, &s_GirlNinjaRun[0]}, // JBF: s_GirlNinjaRun really is supposed to be the
|
||||
// pointer to the state group. See StateControl() where
|
||||
// it says "if (!actor->user.__legacyState.State->Pic)".
|
||||
// it says "if (!actor->user.State->Pic)".
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1544,7 +1544,7 @@ void SpawnPlayerUnderSprite(DSWPlayer* pp)
|
|||
actor->spr.cstat |= (CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
|
||||
actor->spr.extra |= (SPRX_PLAYER_OR_ENEMY);
|
||||
|
||||
actor->user.__legacyState.State = plActor->user.__legacyState.State;
|
||||
actor->user.State = plActor->user.State;
|
||||
NewStateGroup(pp->PlayerUnderActor, plActor->user.__legacyState.Rot);
|
||||
|
||||
actor->user.Radius = plActor->user.Radius;
|
||||
|
|
|
@ -1117,7 +1117,7 @@ void UpdatePlayerUnderSprite(DSWPlayer* pp)
|
|||
// add diff to ceiling
|
||||
act_under->spr.pos.Z = act_under->sector()->ceilingz + zdiff;
|
||||
|
||||
act_under->user.__legacyState.State = act_over->user.__legacyState.State;
|
||||
act_under->user.State = act_over->user.State;
|
||||
act_under->user.__legacyState.Rot = act_over->user.__legacyState.Rot;
|
||||
act_under->user.__legacyState.StateStart = act_over->user.__legacyState.StateStart;
|
||||
act_under->spr.setspritetexture(act_over->spr.spritetexture());
|
||||
|
@ -5889,31 +5889,31 @@ void PlayerStateControl(DSWActor* actor)
|
|||
actor->user.Tics += synctics;
|
||||
|
||||
// Skip states if too much time has passed
|
||||
while (actor->user.Tics >= (actor->user.__legacyState.State->Tics & SF_TICS_MASK))
|
||||
while (actor->user.Tics >= (actor->user.State->Tics & SF_TICS_MASK))
|
||||
{
|
||||
|
||||
// Set Tics
|
||||
actor->user.Tics -= (actor->user.__legacyState.State->Tics & SF_TICS_MASK);
|
||||
actor->user.Tics -= (actor->user.State->Tics & SF_TICS_MASK);
|
||||
|
||||
// Transition to the next state
|
||||
actor->user.__legacyState.State = actor->user.__legacyState.State->NextState;
|
||||
actor->user.State = actor->user.State->NextState;
|
||||
|
||||
// !JIM! Added this so I can do quick calls in player states!
|
||||
// Need this in order for floor blood and footprints to not get called more than once.
|
||||
while ((actor->user.__legacyState.State->Tics & SF_QUICK_CALL))
|
||||
while ((actor->user.State->Tics & SF_QUICK_CALL))
|
||||
{
|
||||
// Call it once and go to the next state
|
||||
actor->callStateAction();
|
||||
|
||||
// if still on the same QUICK_CALL should you
|
||||
// go to the next state.
|
||||
if ((actor->user.__legacyState.State->Tics & SF_QUICK_CALL))
|
||||
actor->user.__legacyState.State = actor->user.__legacyState.State->NextState;
|
||||
if ((actor->user.State->Tics & SF_QUICK_CALL))
|
||||
actor->user.State = actor->user.State->NextState;
|
||||
}
|
||||
|
||||
if (actor->user.__legacyState.State->sprite == SPR_NULL)
|
||||
if (actor->user.State->sprite == SPR_NULL)
|
||||
{
|
||||
NewStateGroup(actor, actor->user.__legacyState.State->NextState);
|
||||
NewStateGroup(actor, actor->user.State->NextState);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5921,7 +5921,7 @@ void PlayerStateControl(DSWActor* actor)
|
|||
actor->setPicFromState();
|
||||
|
||||
// Call the correct animator
|
||||
if ((actor->user.__legacyState.State->Tics & SF_PLAYER_FUNC))
|
||||
if ((actor->user.State->Tics & SF_PLAYER_FUNC))
|
||||
actor->callStateAction();
|
||||
|
||||
return;
|
||||
|
|
|
@ -604,7 +604,7 @@ int DoRipperHang(DSWActor* actor)
|
|||
|
||||
NewStateGroup(actor, s_RipperJumpAttack);
|
||||
// move to the 2nd frame - past the pause frame
|
||||
actor->user.Tics += actor->user.__legacyState.State->Tics;
|
||||
actor->user.Tics += actor->user.State->Tics;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -558,7 +558,7 @@ int DoRipper2Hang(DSWActor* actor)
|
|||
|
||||
NewStateGroup(actor, s_Ripper2JumpAttack);
|
||||
// move to the 2nd frame - past the pause frame
|
||||
actor->user.Tics += actor->user.__legacyState.State->Tics;
|
||||
actor->user.Tics += actor->user.State->Tics;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -593,13 +593,13 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def
|
|||
if (arc.BeginObject(keyname))
|
||||
{
|
||||
// The default serializer cannot handle the statically defined states so call these functons explicitly.
|
||||
_Serialize(arc, "State", w.__legacyState.State, &def->__legacyState.State);
|
||||
_Serialize(arc, "State", w.State, &def->State);
|
||||
_Serialize(arc, "Rot", w.__legacyState.Rot, &def->__legacyState.Rot);
|
||||
_Serialize(arc, "StateStart", w.__legacyState.StateStart, &def->__legacyState.StateStart);
|
||||
_Serialize(arc, "StateEnd", w.__legacyState.StateEnd, &def->__legacyState.StateEnd);
|
||||
_Serialize(arc, "StateFallOverride", w.__legacyState.StateFallOverride, &def->__legacyState.StateFallOverride);
|
||||
/*
|
||||
("State", w.__legacyState.State, def->__legacyState.State)
|
||||
("State", w.State, def->State)
|
||||
("Rot", w.__legacyState.Rot, def->__legacyState.Rot)
|
||||
("StateStart", w.__legacyState.StateStart, def->__legacyState.StateStart)
|
||||
("StateEnd", w.__legacyState.StateEnd, def->__legacyState.StateEnd)
|
||||
|
|
|
@ -690,7 +690,7 @@ void ChangeState(DSWActor* actor, FState* statep)
|
|||
return;
|
||||
|
||||
actor->user.Tics = 0;
|
||||
actor->user.__legacyState.State = actor->user.__legacyState.StateStart = statep;
|
||||
actor->user.State = actor->user.__legacyState.StateStart = statep;
|
||||
actor->spr.cstat2 |= CSTAT2_SPRITE_NOANIMATE; // just in case
|
||||
}
|
||||
|
||||
|
@ -761,7 +761,7 @@ void SpawnUser(DSWActor* actor, short id, FState* state)
|
|||
PRODUCTION_ASSERT(actor->hasU());
|
||||
|
||||
// be careful State can be nullptr
|
||||
actor->user.__legacyState.State = actor->user.__legacyState.StateStart = state;
|
||||
actor->user.State = actor->user.__legacyState.StateStart = state;
|
||||
|
||||
change_actor_stat(actor, actor->spr.statnum);
|
||||
|
||||
|
@ -822,7 +822,7 @@ DSWActor* SpawnActor(int stat, int id, FState* state, sectortype* sect, const DV
|
|||
SpawnUser(spawnedActor, id, state);
|
||||
|
||||
// be careful State can be nullptr
|
||||
if (spawnedActor->user.__legacyState.State)
|
||||
if (spawnedActor->user.State)
|
||||
{
|
||||
spawnedActor->setPicFromState();
|
||||
spawnedActor->spr.cstat2 |= CSTAT2_SPRITE_NOANIMATE; // just in case
|
||||
|
@ -4198,11 +4198,11 @@ int NewStateGroup(DSWActor* actor, FState* StateGroup)
|
|||
|
||||
// Kind of a goofy check, but it should catch alot of invalid states!
|
||||
|
||||
if (actor->user.__legacyState.State && (actor->user.__legacyState.State->sprite < 0 || actor->user.__legacyState.State->sprite > SPR_MAX)) // JBF: verify this!
|
||||
if (actor->user.State && (actor->user.State->sprite < 0 || actor->user.State->sprite > SPR_MAX)) // JBF: verify this!
|
||||
return 0;
|
||||
|
||||
actor->user.__legacyState.Rot = StateGroup;
|
||||
actor->user.__legacyState.State = actor->user.__legacyState.StateStart = StateGroup;
|
||||
actor->user.State = actor->user.__legacyState.StateStart = StateGroup;
|
||||
|
||||
actor->user.Tics = 0;
|
||||
|
||||
|
@ -4698,18 +4698,18 @@ int DoCoin(DSWActor* actor)
|
|||
{
|
||||
if (actor->user.__legacyState.StateStart != s_GreenCoin)
|
||||
{
|
||||
offset = int(actor->user.__legacyState.State - actor->user.__legacyState.StateStart);
|
||||
offset = int(actor->user.State - actor->user.__legacyState.StateStart);
|
||||
ChangeState(actor, s_GreenCoin);
|
||||
actor->user.__legacyState.State = actor->user.__legacyState.StateStart + offset;
|
||||
actor->user.State = actor->user.__legacyState.StateStart + offset;
|
||||
}
|
||||
}
|
||||
else if (actor->user.WaitTics < 20*120)
|
||||
{
|
||||
if (actor->user.__legacyState.StateStart != s_YellowCoin)
|
||||
{
|
||||
offset = int(actor->user.__legacyState.State - actor->user.__legacyState.StateStart);
|
||||
offset = int(actor->user.State - actor->user.__legacyState.StateStart);
|
||||
ChangeState(actor, s_YellowCoin);
|
||||
actor->user.__legacyState.State = actor->user.__legacyState.StateStart + offset;
|
||||
actor->user.State = actor->user.__legacyState.StateStart + offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5918,7 +5918,7 @@ int StateControl(DSWActor* actor)
|
|||
{
|
||||
short StateTics;
|
||||
|
||||
if (!actor->user.__legacyState.State)
|
||||
if (!actor->user.State)
|
||||
{
|
||||
actor->callAction();
|
||||
return 0;
|
||||
|
@ -5930,11 +5930,11 @@ int StateControl(DSWActor* actor)
|
|||
actor->user.Tics += ACTORMOVETICS;
|
||||
|
||||
// Skip states if too much time has passed
|
||||
while (actor->user.Tics >= (actor->user.__legacyState.State->Tics & SF_TICS_MASK))
|
||||
while (actor->user.Tics >= (actor->user.State->Tics & SF_TICS_MASK))
|
||||
{
|
||||
StateTics = (actor->user.__legacyState.State->Tics & SF_TICS_MASK);
|
||||
StateTics = (actor->user.State->Tics & SF_TICS_MASK);
|
||||
|
||||
if ((actor->user.__legacyState.State->Tics & SF_TIC_ADJUST))
|
||||
if ((actor->user.State->Tics & SF_TIC_ADJUST))
|
||||
{
|
||||
ASSERT(actor->user.__legacyState.Attrib);
|
||||
ASSERT(actor->user.speed < MAX_SPEED);
|
||||
|
@ -5947,10 +5947,10 @@ int StateControl(DSWActor* actor)
|
|||
actor->user.Tics -= StateTics;
|
||||
|
||||
// Transition to the next state
|
||||
actor->user.__legacyState.State = actor->user.__legacyState.State->NextState;
|
||||
actor->user.State = actor->user.State->NextState;
|
||||
|
||||
// Look for flags embedded into the Tics variable
|
||||
while ((actor->user.__legacyState.State->Tics & SF_QUICK_CALL))
|
||||
while ((actor->user.State->Tics & SF_QUICK_CALL))
|
||||
{
|
||||
// Call it once and go to the next state
|
||||
actor->callStateAction();
|
||||
|
@ -5962,27 +5962,27 @@ int StateControl(DSWActor* actor)
|
|||
|
||||
// if still on the same QUICK_CALL should you
|
||||
// go to the next state.
|
||||
if ((actor->user.__legacyState.State->Tics & SF_QUICK_CALL))
|
||||
actor->user.__legacyState.State = actor->user.__legacyState.State->NextState;
|
||||
if ((actor->user.State->Tics & SF_QUICK_CALL))
|
||||
actor->user.State = actor->user.State->NextState;
|
||||
}
|
||||
|
||||
if (!actor->hasU())
|
||||
break;
|
||||
|
||||
if (actor->user.__legacyState.State->sprite == SPR_NULL)
|
||||
if (actor->user.State->sprite == SPR_NULL)
|
||||
{
|
||||
NewStateGroup(actor, actor->user.__legacyState.State->NextState);
|
||||
NewStateGroup(actor, actor->user.State->NextState);
|
||||
}
|
||||
}
|
||||
|
||||
if (actor->hasU())
|
||||
{
|
||||
ASSERT(actor->user.__legacyState.State);
|
||||
ASSERT(actor->user.State);
|
||||
// Set the correct pic
|
||||
if ((actor->user.__legacyState.State->Tics & SF_WALL_STATE)) // never used anywhere...
|
||||
if ((actor->user.State->Tics & SF_WALL_STATE)) // never used anywhere...
|
||||
{
|
||||
ASSERT(actor->user.WallP);
|
||||
actor->user.WallP->setwalltexture(picFromState(actor->user.__legacyState.State));
|
||||
actor->user.WallP->setwalltexture(picFromState(actor->user.State));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
bool hasState(FName label, int substate = 0);
|
||||
void callAction();
|
||||
void callStateAction();
|
||||
void setPicFromState() { spr.setspritetexture(picFromState(user.__legacyState.State)); }
|
||||
void setPicFromState() { spr.setspritetexture(picFromState(user.State)); }
|
||||
};
|
||||
|
||||
inline void UpdateChangeXY(DSWActor* actor)
|
||||
|
|
Loading…
Reference in a new issue