- moved ActorActionFunc and Personality out of __LegacyState again.

This commit is contained in:
Christoph Oelckers 2023-05-24 19:54:58 +02:00
parent b07a182df4
commit e97dfb3687
17 changed files with 67 additions and 67 deletions

View file

@ -1071,11 +1071,11 @@ bool DSWActor::hasState(FName label, int subl)
return getLegacyState(a, label, subl) != nullptr;
}
void DSWActor::setActionDecide() { user.__legacyState.ActorActionFunc = AF(DoActorDecide); }
void DSWActor::setActionDecide() { user.ActorActionFunc = AF(DoActorDecide); }
void DSWActor::callAction()
{
callFunction(user.__legacyState.ActorActionFunc);
callFunction(user.ActorActionFunc);
}
void DSWActor::callStateAction()

View file

@ -66,7 +66,7 @@ bool ActorMoveHitReact(DSWActor* actor)
{
// if you ran into a player - call close range functions
DoActorPickClosePlayer(actor);
auto action = ChooseAction(actor->user.__legacyState.Personality->TouchTarget);
auto action = ChooseAction(actor->user.Personality->TouchTarget);
actor->callFunction(action);
}
}
@ -451,7 +451,7 @@ VMFunction* DoActorActionDecide(DSWActor* actor)
// REMINDER: This function is not even called if SpriteControl doesn't let
// it get called
ASSERT(actor->user.__legacyState.Personality);
ASSERT(actor->user.Personality);
actor->user.Dist = 0;
action = AF(InitActorDecide);
@ -497,7 +497,7 @@ VMFunction* DoActorActionDecide(DSWActor* actor)
actor->user.Flags &= ~(SPR_ACTIVE);
// You've lost the player - now decide what to do
action = ChooseAction(actor->user.__legacyState.Personality->LostTarget);
action = ChooseAction(actor->user.Personality->LostTarget);
//CON_Message("LostTarget");
return action;
}
@ -509,9 +509,9 @@ VMFunction* DoActorActionDecide(DSWActor* actor)
(pActor && pActor->hasU() && pActor->user.WeaponNum == WPN_FIST && actor->user.ID != RIPPER2_RUN_R0 && actor->user.ID != RIPPER_RUN_R0))
{
if ((actor->user.ID == COOLG_RUN_R0 && (actor->spr.cstat & CSTAT_SPRITE_TRANSLUCENT)) || (actor->spr.cstat & CSTAT_SPRITE_INVISIBLE))
action = ChooseAction(actor->user.__legacyState.Personality->Evasive);
action = ChooseAction(actor->user.Personality->Evasive);
else
action = ChooseAction(actor->user.__legacyState.Personality->CloseRange);
action = ChooseAction(actor->user.Personality->CloseRange);
//CON_Message("CloseRange");
return action;
}
@ -531,9 +531,9 @@ VMFunction* DoActorActionDecide(DSWActor* actor)
else
{
if ((actor->user.ID == COOLG_RUN_R0 && (actor->spr.cstat & CSTAT_SPRITE_TRANSLUCENT)) || (actor->spr.cstat & CSTAT_SPRITE_INVISIBLE))
action = ChooseAction(actor->user.__legacyState.Personality->Evasive);
action = ChooseAction(actor->user.Personality->Evasive);
else
action = ChooseAction(actor->user.__legacyState.Personality->Battle);
action = ChooseAction(actor->user.Personality->Battle);
}
//CON_Message("Battle 1");
return action;
@ -543,9 +543,9 @@ VMFunction* DoActorActionDecide(DSWActor* actor)
else
{
if ((actor->user.ID == COOLG_RUN_R0 && (actor->spr.cstat & CSTAT_SPRITE_TRANSLUCENT)) || (actor->spr.cstat & CSTAT_SPRITE_INVISIBLE))
action = ChooseAction(actor->user.__legacyState.Personality->Evasive);
action = ChooseAction(actor->user.Personality->Evasive);
else
action = ChooseAction(actor->user.__legacyState.Personality->Battle);
action = ChooseAction(actor->user.Personality->Battle);
//CON_Message("Battle 2");
return action;
}
@ -555,16 +555,16 @@ VMFunction* DoActorActionDecide(DSWActor* actor)
else if (ICanSee)
{
if ((actor->user.ID == COOLG_RUN_R0 && (actor->spr.cstat & CSTAT_SPRITE_TRANSLUCENT)) || (actor->spr.cstat & CSTAT_SPRITE_INVISIBLE))
action = ChooseAction(actor->user.__legacyState.Personality->Evasive);
action = ChooseAction(actor->user.Personality->Evasive);
else
action = ChooseAction(actor->user.__legacyState.Personality->Offense);
action = ChooseAction(actor->user.Personality->Offense);
//CON_Message("Offense");
return action;
}
else
{
// You've lost the player - now decide what to do
action = ChooseAction(actor->user.__legacyState.Personality->LostTarget);
action = ChooseAction(actor->user.Personality->LostTarget);
//CON_Message("Close but cant see, LostTarget");
return action;
}
@ -586,7 +586,7 @@ VMFunction* DoActorActionDecide(DSWActor* actor)
DoActorOperate(actor);
// Don't let player completely sneek up behind you
action = ChooseAction(actor->user.__legacyState.Personality->Surprised);
action = ChooseAction(actor->user.Personality->Surprised);
//CON_Message("Surprised");
if (!actor->user.DidAlert && ICanSee)
{
@ -601,7 +601,7 @@ VMFunction* DoActorActionDecide(DSWActor* actor)
// Player has not seen actor, to be fair let him know actor
// are there
;
DoActorNoise(actor, ChooseNoise(actor->user.__legacyState.Personality->Broadcast));
DoActorNoise(actor, ChooseNoise(actor->user.Personality->Broadcast));
return action;
}
}
@ -687,7 +687,7 @@ int DoActorDecide(DSWActor* actor)
int InitActorMoveCloser(DSWActor* actor)
{
actor->user.__legacyState.ActorActionFunc = AF(DoActorMoveCloser);
actor->user.ActorActionFunc = AF(DoActorMoveCloser);
if (!actor->checkStateGroup(NAME_Run))
actor->setStateGroup(NAME_Run);
@ -745,7 +745,7 @@ int DoActorMoveCloser(DSWActor* actor)
}
// Do a noise if ok
DoActorNoise(actor, ChooseNoise(actor->user.__legacyState.Personality->Broadcast));
DoActorNoise(actor, ChooseNoise(actor->user.Personality->Broadcast));
// after moving a ways check to see if player is still in sight
if (actor->user.DistCheck > 34.375)
@ -1040,7 +1040,7 @@ int InitActorAttack(DSWActor* actor)
return 0;
}
actor->user.__legacyState.ActorActionFunc = AF(DoActorAttack);
actor->user.ActorActionFunc = AF(DoActorAttack);
// move into standing frame
//actor->setStateGroup(NAME_Stand);
@ -1087,7 +1087,7 @@ int DoActorAttack(DSWActor* actor)
{
int rand_num;
DoActorNoise(actor, ChooseNoise(actor->user.__legacyState.Personality->Broadcast));
DoActorNoise(actor, ChooseNoise(actor->user.Personality->Broadcast));
double dist =(actor->spr.pos.XY() - actor->user.targetActor->spr.pos.XY()).Length();
@ -1211,7 +1211,7 @@ int InitActorDuck(DSWActor* actor)
return 0;
}
actor->user.__legacyState.ActorActionFunc = AF(DoActorDuck);
actor->user.ActorActionFunc = AF(DoActorDuck);
actor->setStateGroup(NAME_Duck);
double dist = (actor->spr.pos.XY() - actor->user.targetActor->spr.pos.XY()).LengthSquared();
@ -1562,7 +1562,7 @@ int InitActorReposition(DSWActor* actor)
}
actor->user.__legacyState.ActorActionFunc = AF(DoActorReposition);
actor->user.ActorActionFunc = AF(DoActorReposition);
if (!(actor->user.Flags & SPR_SWIMMING))
actor->setStateGroup(NAME_Run);
@ -1608,7 +1608,7 @@ int DoActorReposition(DSWActor* actor)
int InitActorPause(DSWActor* actor)
{
actor->user.__legacyState.ActorActionFunc = AF(DoActorPause);
actor->user.ActorActionFunc = AF(DoActorPause);
actor->callAction();

View file

@ -1021,7 +1021,7 @@ bool NullActor(DSWActor* actor)
return true;
// does not have a STATE or FUNC to control it
if (!actor->user.__legacyState.ActorActionFunc)
if (!actor->user.ActorActionFunc)
return true;
return false;

View file

@ -1171,7 +1171,7 @@ void BunnyHatch(DSWActor* actor)
actorNew->user.ShellNum = 0; // Not Pregnant right now
actorNew->setStateGroup(NAME_Jump);
actorNew->user.__legacyState.ActorActionFunc = AF(DoActorMoveJump);
actorNew->user.ActorActionFunc = AF(DoActorMoveJump);
DoActorSetSpeed(actorNew, FAST_SPEED);
PickJumpMaxSpeed(actorNew, -600);
@ -1219,7 +1219,7 @@ DSWActor* BunnyHatch2(DSWActor* actor)
actorNew->user.ShellNum = 0; // Not Pregnant right now
actorNew->setStateGroup(NAME_Jump);
actorNew->user.__legacyState.ActorActionFunc = AF(DoActorMoveJump);
actorNew->user.ActorActionFunc = AF(DoActorMoveJump);
DoActorSetSpeed(actorNew, FAST_SPEED);
if (TEST_BOOL3(actor))
{
@ -1308,7 +1308,7 @@ int DoBunnyMove(DSWActor* actor)
actor->spr.Angles.Yaw = RandomAngle();
actor->user.jump_speed = -350;
DoActorBeginJump(actor);
actor->user.__legacyState.ActorActionFunc = AF(DoActorMoveJump);
actor->user.ActorActionFunc = AF(DoActorMoveJump);
}
}

View file

@ -552,7 +552,7 @@ int NewCoolg(DSWActor* actor)
actorNew->user.__legacyState.ActorActionSet = &CoolgActionSet;
actorNew->spr.shade = actor->spr.shade;
actorNew->user.__legacyState.Personality = &CoolgPersonality;
actorNew->user.Personality = &CoolgPersonality;
actorNew->user.__legacyState.Attrib = &CoolgAttrib;
// special case
@ -695,7 +695,7 @@ int DoCoolgMatchPlayerZ(DSWActor* actor)
int InitCoolgCircle(DSWActor* actor)
{
actor->user.__legacyState.ActorActionFunc = AF(DoCoolgCircle);
actor->user.ActorActionFunc = AF(DoCoolgCircle);
actor->setStateGroup(NAME_Run);

View file

@ -412,7 +412,7 @@ void EnemyDefaults(DSWActor* actor, ACTOR_ACTION_SET* action, PERSONALITY* perso
actor->spr.picnum = actor->user.__legacyState.State->Pic;
change_actor_stat(actor, STAT_ENEMY);
actor->user.__legacyState.Personality = person;
actor->user.Personality = person;
actor->user.__legacyState.ActorActionSet = action;
DoActorZrange(actor);

View file

@ -699,6 +699,8 @@ struct USER
TArray<int8_t> WallShade;
walltype* WallP; // operate on wall instead of sprite
VMFunction* ActorActionFunc;
PERSONALITY* Personality;
struct LegacyState
{
@ -709,8 +711,6 @@ struct USER
STATE** StateFallOverride; // a bit kludgy - override std fall state
ACTOR_ACTION_SET* ActorActionSet;
int16_t RotNum;
VMFunction* ActorActionFunc;
PERSONALITY* Personality;
ATTRIBUTE* Attrib;
};

View file

@ -413,7 +413,7 @@ int DoHornetMatchPlayerZ(DSWActor* actor)
int InitHornetCircle(DSWActor* actor)
{
actor->user.__legacyState.ActorActionFunc = AF(DoHornetCircle);
actor->user.ActorActionFunc = AF(DoHornetCircle);
actor->setStateGroup(NAME_Run);

View file

@ -183,7 +183,7 @@ void JS_SpriteSetup(void)
itActor->user.__legacyState.RotNum = 0;
itActor->user.WaitTics = itActor->spr.lotag * 120;
itActor->user.__legacyState.ActorActionFunc = AF(GenerateDrips);
itActor->user.ActorActionFunc = AF(GenerateDrips);
change_actor_stat(itActor, STAT_NO_STATE);
itActor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;

View file

@ -1785,14 +1785,14 @@ int SetupNinja(DSWActor* actor)
{
actor->user.__legacyState.Attrib = &NinjaAttrib;
actor->user.__legacyState.ActorActionSet = &NinjaActionSet;
actor->user.__legacyState.Personality = &NinjaPersonality;
actor->user.Personality = &NinjaPersonality;
ChangeState(actor, s_NinjaCeiling[0]);
}
else
{
actor->user.__legacyState.Attrib = &NinjaAttrib;
actor->user.__legacyState.ActorActionSet = &NinjaSniperActionSet;
actor->user.__legacyState.Personality = &NinjaSniperPersonality;
actor->user.Personality = &NinjaSniperPersonality;
ChangeState(actor, s_NinjaDuck[0]);
}
}
@ -1810,14 +1810,14 @@ int SetupNinja(DSWActor* actor)
{
actor->user.__legacyState.Attrib = &NinjaAttrib;
actor->user.__legacyState.ActorActionSet = &NinjaActionSet;
actor->user.__legacyState.Personality = &NinjaPersonality;
actor->user.Personality = &NinjaPersonality;
ChangeState(actor, s_NinjaCeiling[0]);
}
else
{
actor->user.__legacyState.Attrib = &NinjaAttrib;
actor->user.__legacyState.ActorActionSet = &NinjaSniperActionSet;
actor->user.__legacyState.Personality = &NinjaSniperPersonality;
actor->user.Personality = &NinjaSniperPersonality;
ChangeState(actor, s_NinjaDuck[0]);
}
}
@ -1849,7 +1849,7 @@ int SetupNinja(DSWActor* actor)
{
actor->user.__legacyState.Attrib = &NinjaAttrib;
actor->user.__legacyState.ActorActionSet = &NinjaSniperActionSet;
actor->user.__legacyState.Personality = &NinjaSniperPersonality;
actor->user.Personality = &NinjaSniperPersonality;
ChangeState(actor, s_NinjaDuck[0]);
}
}

View file

@ -1227,7 +1227,7 @@ void RipperHatch(DSWActor* actor)
actorNew->user.Flags |= (SPR_ACTIVE);
actorNew->setStateGroup(NAME_Jump);
actorNew->user.__legacyState.ActorActionFunc = AF(DoActorMoveJump);
actorNew->user.ActorActionFunc = AF(DoActorMoveJump);
DoActorSetSpeed(actorNew, FAST_SPEED);
PickJumpMaxSpeed(actorNew, -600);

View file

@ -1235,7 +1235,7 @@ void Ripper2Hatch(DSWActor* actor)
actorNew->user.Flags |= (SPR_ACTIVE);
actorNew->setStateGroup(NAME_Jump);
actorNew->user.__legacyState.ActorActionFunc = AF(DoActorMoveJump);
actorNew->user.ActorActionFunc = AF(DoActorMoveJump);
DoActorSetSpeed(actorNew, FAST_SPEED);
PickJumpMaxSpeed(actorNew, -600);

View file

@ -745,7 +745,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def
("StateEnd", w.__legacyState.StateEnd, def->__legacyState.StateEnd)
("StateFallOverride", w.__legacyState.StateFallOverride, def->__legacyState.StateFallOverride)
("ActorActionSet", w.__legacyState.ActorActionSet, def->__legacyState.ActorActionSet)
("Personality", w.__legacyState.Personality, def->__legacyState.Personality)
("Personality", w.Personality, def->Personality)
("Attrib", w.__legacyState.Attrib, def->__legacyState.Attrib)
("sop_parent", w.sop_parent, def->sop_parent)
("flags", w.Flags, def->Flags)
@ -826,7 +826,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def
("filler", w.filler, def->filler)
("wallshade", w.WallShade)
("rotator", w.rotator)
("actoractionfunc", w.__legacyState.ActorActionFunc)
("actoractionfunc", w.ActorActionFunc)
("oz", w.oz, def->oz);
arc.EndObject();

View file

@ -1008,7 +1008,7 @@ void DoSpawnSpotsForKill(short match)
if (actor->spr.hitag == SPAWN_SPOT && actor->spr.lotag == match)
{
change_actor_stat(actor, STAT_NO_STATE);
actor->user.__legacyState.ActorActionFunc = AF(DoSpawnSpot);
actor->user.ActorActionFunc = AF(DoSpawnSpot);
actor->user.WaitTics = SP_TAG5(actor) * 15;
SetActorZ(actor, actor->spr.pos);
// setting for Killed
@ -1035,7 +1035,7 @@ void DoSpawnSpotsForDamage(short match)
if (actor->spr.hitag == SPAWN_SPOT && actor->spr.lotag == match)
{
change_actor_stat(actor, STAT_NO_STATE);
actor->user.__legacyState.ActorActionFunc = AF(DoSpawnSpot);
actor->user.ActorActionFunc = AF(DoSpawnSpot);
actor->user.WaitTics = SP_TAG7(actor) * 15;
// setting for Damaged
actor->user.LastDamage = 0;
@ -1778,7 +1778,7 @@ int OperateSprite(DSWActor* actor, short player_is_operating)
SpawnUser(actor, 0, nullptr);
actor->user.__legacyState.ActorActionFunc = AF(DoGrating);
actor->user.ActorActionFunc = AF(DoGrating);
actor->spr.lotag = 0;
actor->spr.hitag /= 2;

View file

@ -1468,7 +1468,7 @@ void SpriteSetupPost(void)
jActor->user.ceiling_dist = 4;
jActor->user.floor_dist = -2;
jActor->user.__legacyState.ActorActionFunc = AF(DoActorDebris);
jActor->user.ActorActionFunc = AF(DoActorDebris);
jActor->spr.cstat |= CSTAT_SPRITE_BREAKABLE;
jActor->spr.extra |= SPRX_BREAKABLE;
@ -1960,18 +1960,18 @@ void SpriteSetup(void)
{
case 0:
actor->user.Flags &= ~(SPR_ACTIVE);
actor->user.__legacyState.ActorActionFunc = AF(DoVator);
actor->user.ActorActionFunc = AF(DoVator);
break;
case 1:
actor->user.Flags &= ~(SPR_ACTIVE);
actor->user.__legacyState.ActorActionFunc = AF(DoVator);
actor->user.ActorActionFunc = AF(DoVator);
break;
case 2:
actor->user.__legacyState.ActorActionFunc = AF(DoVatorAuto);
actor->user.ActorActionFunc = AF(DoVatorAuto);
break;
case 3:
actor->user.Flags &= ~(SPR_ACTIVE);
actor->user.__legacyState.ActorActionFunc = AF(DoVatorAuto);
actor->user.ActorActionFunc = AF(DoVatorAuto);
break;
}
@ -2068,11 +2068,11 @@ void SpriteSetup(void)
{
case 0:
actor->user.Flags &= ~(SPR_ACTIVE);
actor->user.__legacyState.ActorActionFunc = AF(DoRotator);
actor->user.ActorActionFunc = AF(DoRotator);
break;
case 1:
actor->user.Flags &= ~(SPR_ACTIVE);
actor->user.__legacyState.ActorActionFunc = AF(DoRotator);
actor->user.ActorActionFunc = AF(DoRotator);
break;
}
@ -2113,11 +2113,11 @@ void SpriteSetup(void)
{
case 0:
actor->user.Flags &= ~(SPR_ACTIVE);
actor->user.__legacyState.ActorActionFunc = AF(DoSlidor);
actor->user.ActorActionFunc = AF(DoSlidor);
break;
case 1:
actor->user.Flags &= ~(SPR_ACTIVE);
actor->user.__legacyState.ActorActionFunc = AF(DoSlidor);
actor->user.ActorActionFunc = AF(DoSlidor);
break;
}
@ -2161,18 +2161,18 @@ void SpriteSetup(void)
{
case 0:
actor->user.Flags &= ~(SPR_ACTIVE);
actor->user.__legacyState.ActorActionFunc = AF(DoSpike);
actor->user.ActorActionFunc = AF(DoSpike);
break;
case 1:
actor->user.Flags &= ~(SPR_ACTIVE);
actor->user.__legacyState.ActorActionFunc = AF(DoSpike);
actor->user.ActorActionFunc = AF(DoSpike);
break;
case 2:
actor->user.__legacyState.ActorActionFunc = AF(DoSpikeAuto);
actor->user.ActorActionFunc = AF(DoSpikeAuto);
break;
case 3:
actor->user.Flags &= ~(SPR_ACTIVE);
actor->user.__legacyState.ActorActionFunc = AF(DoSpikeAuto);
actor->user.ActorActionFunc = AF(DoSpikeAuto);
break;
}
@ -2349,7 +2349,7 @@ void SpriteSetup(void)
SpawnUser(actor, ST1, nullptr);
change_actor_stat(actor, STAT_NO_STATE);
actor->user.__legacyState.ActorActionFunc = AF(DoLavaErupt);
actor->user.ActorActionFunc = AF(DoLavaErupt);
// interval between erupts
if (SP_TAG10(actor) == 0)

View file

@ -47,7 +47,7 @@ public:
// wrappers that hide legacy implementation details.
void ChangeStateEnd();
void clearActionFunc() { user.__legacyState.ActorActionFunc = nullptr; }
void clearActionFunc() { user.ActorActionFunc = nullptr; }
void setActionDecide();
void setStateGroup(FName label, int substate = 0); // substate is only valid for Attack and CloseAttack
bool checkStateGroup(FName label, int substate = 0);

View file

@ -2594,7 +2594,7 @@ void VehicleSetSmoke(SECTOR_OBJECT* sop, VMFunction* animator)
DoSoundSpotStopSound(actor->spr.lotag);
}
actor->user.__legacyState.ActorActionFunc = animator;
actor->user.ActorActionFunc = animator;
}
break;
}
@ -2910,7 +2910,7 @@ bool ActorTrackDecide(TRACK_POINT* tpoint, DSWActor* actor)
actor->user.jump_speed = -tpoint->tag_high;
DoActorBeginJump(actor);
actor->user.__legacyState.ActorActionFunc = AF(DoActorMoveJump);
actor->user.ActorActionFunc = AF(DoActorMoveJump);
}
break;
@ -2956,7 +2956,7 @@ bool ActorTrackDecide(TRACK_POINT* tpoint, DSWActor* actor)
}
DoActorBeginJump(actor);
actor->user.__legacyState.ActorActionFunc = AF(DoActorMoveJump);
actor->user.ActorActionFunc = AF(DoActorMoveJump);
return false;
}
@ -2981,7 +2981,7 @@ bool ActorTrackDecide(TRACK_POINT* tpoint, DSWActor* actor)
}
DoActorBeginJump(actor);
actor->user.__legacyState.ActorActionFunc = AF(DoActorMoveJump);
actor->user.ActorActionFunc = AF(DoActorMoveJump);
return false;
}
@ -3011,7 +3011,7 @@ bool ActorTrackDecide(TRACK_POINT* tpoint, DSWActor* actor)
actor->user.WaitTics = tpoint->tag_high * 128;
InitActorDuck(actor);
actor->user.__legacyState.ActorActionFunc = AF(DoActorDuck);
actor->user.ActorActionFunc = AF(DoActorDuck);
return false;
}
@ -3435,7 +3435,7 @@ int ActorFollowTrack(DSWActor* actor, short locktics)
actor->spr.pos.Z += actor->user.pos.Y;
DoActorSetSpeed(actor, SLOW_SPEED);
actor->user.__legacyState.ActorActionFunc = AF(NinjaJumpActionFunc);
actor->user.ActorActionFunc = AF(NinjaJumpActionFunc);
actor->user.jump_speed = -650;
DoActorBeginJump(actor);