- turn the SO's Animator and PostMoveAnimator into non-functions as well.

What little is here can be done just as easily by more traditional means which are easier to serialize.
This commit is contained in:
Christoph Oelckers 2023-05-28 10:55:50 +02:00
parent 5e64d6c7aa
commit 8d57281101
7 changed files with 38 additions and 64 deletions

View file

@ -1209,11 +1209,18 @@ enum
extern TRACK Track[MAX_TRACKS]; extern TRACK Track[MAX_TRACKS];
enum
{
SOType_None = 0,
SOType_Floor = 1,
SOType_Tornado = 2,
SOType_AutoTurret = 3
};
struct SECTOR_OBJECT struct SECTOR_OBJECT
{ {
bool PreMoveScale; bool PreMoveScale;
soANIMATORp PostMoveAnimator; uint8_t AnimType;
soANIMATORp Animator;
TObjPtr<DSWActor*> controller; TObjPtr<DSWActor*> controller;
TObjPtr<DSWActor*> sp_child; // child sprite that holds info for the sector object TObjPtr<DSWActor*> sp_child; // child sprite that holds info for the sector object

View file

@ -533,21 +533,4 @@ void SpikeFloor(SECTOR_OBJECT* sop)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#include "saveable.h"
static saveable_code saveable_morph_code[] =
{
SAVE_CODE(MorphTornado),
SAVE_CODE(MorphFloor),
};
saveable_module saveable_morph =
{
// code
saveable_morph_code,
SIZ(saveable_morph_code),
// data
nullptr,0
};
END_SW_NS END_SW_NS

View file

@ -693,10 +693,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, SECTOR_OBJECT& w,
("limit_ang_center", w.limit_ang_center, def->limit_ang_center) ("limit_ang_center", w.limit_ang_center, def->limit_ang_center)
("limit_ang_delta", w.limit_ang_delta, def->limit_ang_delta) ("limit_ang_delta", w.limit_ang_delta, def->limit_ang_delta)
("premovescale", w.PreMoveScale, def->PreMoveScale); ("premovescale", w.PreMoveScale, def->PreMoveScale);
("animtype", w.AnimType, def->AnimType);
SerializeCodePtr(arc, "postanimator", (void**)&w.PostMoveAnimator);
SerializeCodePtr(arc, "animator", (void**)&w.Animator);
arc.EndObject(); arc.EndObject();
} }

View file

@ -50,7 +50,6 @@ void Saveable_Init(void)
MODULE(jweapon) MODULE(jweapon)
MODULE(lava) MODULE(lava)
MODULE(miscactr) MODULE(miscactr)
MODULE(morph)
MODULE(ninja) MODULE(ninja)
MODULE(panel) MODULE(panel)
MODULE(player) MODULE(player)
@ -61,7 +60,6 @@ void Saveable_Init(void)
MODULE(skull) MODULE(skull)
MODULE(sprite) MODULE(sprite)
MODULE(sumo) MODULE(sumo)
MODULE(track)
MODULE(weapon) MODULE(weapon)
MODULE(zilla) MODULE(zilla)
MODULE(zombie) MODULE(zombie)

View file

@ -74,6 +74,9 @@ void DoRotatorMatch(PLAYER* pp, short match, bool);
void DoSlidorOperate(PLAYER*, sectortype*); void DoSlidorOperate(PLAYER*, sectortype*);
void DoSlidorMatch(PLAYER* pp, short match, bool); void DoSlidorMatch(PLAYER* pp, short match, bool);
void DoTornadoObject(SECTOR_OBJECT* sop);
void DoAutoTurretObject(SECTOR_OBJECT* sop);
void KillMatchingCrackSprites(short match); void KillMatchingCrackSprites(short match);
int DoTrapReset(short match); int DoTrapReset(short match);
int DoTrapMatch(short match); int DoTrapMatch(short match);
@ -392,8 +395,7 @@ void SectorSetup(void)
memset(&SectorObject[ndx].so_actors, 0, sizeof(SectorObject[0].so_actors)); memset(&SectorObject[ndx].so_actors, 0, sizeof(SectorObject[0].so_actors));
SectorObject[ndx].match_event_actor = nullptr; SectorObject[ndx].match_event_actor = nullptr;
SectorObject[ndx].PreMoveScale = false; SectorObject[ndx].PreMoveScale = false;
SectorObject[ndx].PostMoveAnimator = nullptr; SectorObject[ndx].AnimType = SOType_None;
SectorObject[ndx].Animator = nullptr;
SectorObject[ndx].controller = nullptr; SectorObject[ndx].controller = nullptr;
SectorObject[ndx].sp_child = nullptr; SectorObject[ndx].sp_child = nullptr;
SectorObject[ndx].mid_sector = nullptr; SectorObject[ndx].mid_sector = nullptr;
@ -2933,10 +2935,14 @@ void DoSector(void)
} }
} }
if (sop->Animator) switch (sop->AnimType)
{ {
(*sop->Animator)(sop); case SOType_AutoTurret:
continue; DoAutoTurretObject(sop);
break;
case SOType_Tornado:
DoTornadoObject(sop);
break;
} }
// force sync SOs to be updated regularly // force sync SOs to be updated regularly

View file

@ -42,8 +42,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
BEGIN_SW_NS BEGIN_SW_NS
DVector2 DoTrack(SECTOR_OBJECT* sop, short locktics); DVector2 DoTrack(SECTOR_OBJECT* sop, short locktics);
void DoAutoTurretObject(SECTOR_OBJECT* sop);
void DoTornadoObject(SECTOR_OBJECT* sop);
int PickJumpSpeed(DSWActor*, int pix_height); int PickJumpSpeed(DSWActor*, int pix_height);
DSWActor* FindNearSprite(DSWActor, short); DSWActor* FindNearSprite(DSWActor, short);
@ -929,11 +927,6 @@ void SetupSectorObject(sectortype* sectp, short tag)
// initialize stuff first time through // initialize stuff first time through
if (sop->num_sectors == -1) if (sop->num_sectors == -1)
{ {
void DoTornadoObject(SECTOR_OBJECT* sop);
void MorphTornado(SECTOR_OBJECT* sop);
void MorphFloor(SECTOR_OBJECT* sop);
void DoAutoTurretObject(SECTOR_OBJECT* sop);
memset(sop->sectp, 0, sizeof(sop->sectp)); memset(sop->sectp, 0, sizeof(sop->sectp));
memset(sop->so_actors, 0, sizeof(sop->so_actors)); memset(sop->so_actors, 0, sizeof(sop->so_actors));
sop->morph_wall_point = nullptr; sop->morph_wall_point = nullptr;
@ -987,8 +980,7 @@ void SetupSectorObject(sectortype* sectp, short tag)
sop->morph_off = { 0,0 }; sop->morph_off = { 0,0 };
sop->PreMoveScale = false; sop->PreMoveScale = false;
sop->PostMoveAnimator = nullptr; sop->AnimType = SOType_None;
sop->Animator = nullptr;
} }
switch (tag % 5) switch (tag % 5)
@ -1074,7 +1066,7 @@ void SetupSectorObject(sectortype* sectp, short tag)
break; break;
case SO_AUTO_TURRET: case SO_AUTO_TURRET:
sop->Animator = DoAutoTurretObject; sop->AnimType = SOType_AutoTurret;
KillActor(actor); KillActor(actor);
break; break;
@ -1087,9 +1079,8 @@ void SetupSectorObject(sectortype* sectp, short tag)
sop->spin_speed = DAngle22_5 * (1. / 16); sop->spin_speed = DAngle22_5 * (1. / 16);
sop->last_ang = sop->ang; sop->last_ang = sop->ang;
// animators // animators
sop->Animator = DoTornadoObject;
sop->PreMoveScale = true; sop->PreMoveScale = true;
sop->PostMoveAnimator = MorphTornado; sop->AnimType = SOType_Tornado;
// clip // clip
sop->clipdist = 156.25; sop->clipdist = 156.25;
// morph point // morph point
@ -1106,7 +1097,7 @@ void SetupSectorObject(sectortype* sectp, short tag)
sop->scale_type = SO_SCALE_NONE; sop->scale_type = SO_SCALE_NONE;
sop->morph_speed = 7.5; sop->morph_speed = 7.5;
sop->morph_z_speed = 7; sop->morph_z_speed = 7;
sop->PostMoveAnimator = MorphFloor; sop->AnimType = SOType_Floor;
sop->morph_dist_max = 250; sop->morph_dist_max = 250;
sop->morph_rand_freq = 8; sop->morph_rand_freq = 8;
KillActor(actor); KillActor(actor);
@ -1841,8 +1832,18 @@ void RefreshPoints(SECTOR_OBJECT* sop, const DVector2& move, bool dynamic)
MovePoints(sop, delta_ang_from_orig, move); MovePoints(sop, delta_ang_from_orig, move);
// do morphing - angle independent // do morphing - angle independent
if (dynamic && sop->PostMoveAnimator) if (dynamic)
(*sop->PostMoveAnimator)(sop); {
switch (sop->AnimType)
{
case SOType_Floor:
MorphFloor(sop);
break;
case SOType_Tornado:
MorphTornado(sop);
break;
}
}
} }
void KillSectorObjectSprites(SECTOR_OBJECT* sop) void KillSectorObjectSprites(SECTOR_OBJECT* sop)
@ -3465,22 +3466,4 @@ int ActorFollowTrack(DSWActor* actor, short locktics)
} }
#include "saveable.h"
static saveable_code saveable_track_code[] =
{
SAVE_CODE(DoTornadoObject),
SAVE_CODE(DoAutoTurretObject),
};
saveable_module saveable_track =
{
// code
saveable_track_code,
SIZ(saveable_track_code),
// data
nullptr,0
};
END_SW_NS END_SW_NS

View file

@ -16107,7 +16107,7 @@ int InitTurretMgun(SECTOR_OBJECT* sop)
double daz = npos.Z; double daz = npos.Z;
// if its not operated by a player // if its not operated by a player
if (sop->Animator) if (sop->AnimType == SOType_AutoTurret)
{ {
// only auto aim for Z // only auto aim for Z
daang = DAngle90; daang = DAngle90;