From 87d2b3274b4309350b7f61d5a5ed02171d50712f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 31 Dec 2021 15:27:18 +0100 Subject: [PATCH] - cleaned out most of the less frequent typedef types in SW. --- source/games/sw/src/bots.h | 17 +++++------- source/games/sw/src/coolie.cpp | 2 +- source/games/sw/src/game.h | 48 +++++++++++++-------------------- source/games/sw/src/player.cpp | 2 +- source/games/sw/src/rotator.cpp | 6 ++--- source/games/sw/src/save.cpp | 2 +- source/games/sw/src/sector.cpp | 4 +-- source/games/sw/src/sector.h | 2 +- source/games/sw/src/slidor.cpp | 6 ++--- source/games/sw/src/sumo.cpp | 35 ------------------------ source/games/sw/src/weapon.cpp | 6 ++--- source/games/sw/src/zilla.cpp | 35 ------------------------ 12 files changed, 39 insertions(+), 126 deletions(-) diff --git a/source/games/sw/src/bots.h b/source/games/sw/src/bots.h index 741785d2b..9021c99a1 100644 --- a/source/games/sw/src/bots.h +++ b/source/games/sw/src/bots.h @@ -41,29 +41,24 @@ typedef enum } BOT_Actions; // Linked lists containing node trees that are chosen based on desired actions -struct NODEstruct; -typedef struct NODEstruct NODE, *NODEp; -struct NODEstruct +struct NODE { - NODEp p, l, r; // Pointers to tree nodes + NODE* p,* l,* r; // Pointers to tree nodes int goalx, goaly, goalz; // x,y,z point bot wants to get to BOT_Actions action; // Action to take if this node is reached int tics; // Optionally stay in this node for x tics. }; -struct NODETREEstruct; -typedef struct NODETREEstruct NODETREE, *NODETREEp; - -struct NODETREEstruct +struct NODETREE { - NODEp tree; // This is the node tree used to navigate to goal + NODE* tree; // This is the node tree used to navigate to goal bool Locked; // If list is locked, a bot is using/modifying it and // other bots cannot modify it while it's locked }; // Bots main action variables -typedef struct BOT_BRAIN +struct BOT_BRAIN { int16_t tgt_inv; // Inventory item it wants to use int16_t tgt_weapon; // weapon in wants to activate and use @@ -72,7 +67,7 @@ typedef struct BOT_BRAIN int16_t tgt_sector; // Sector it wants to get to int16_t tgt_wall; // Wall it wants to touch BOT_Actions action; // Bot's current action -} BotBrain, *BotBrain_p; +}; // NOTE: // The following arrays should be saved off with save games! diff --git a/source/games/sw/src/coolie.cpp b/source/games/sw/src/coolie.cpp index e10aa55dc..e107e435a 100644 --- a/source/games/sw/src/coolie.cpp +++ b/source/games/sw/src/coolie.cpp @@ -370,7 +370,7 @@ ACTOR_ACTION_SET CoolieActionSet = }; // later. This is used by multiple enemies. -void EnemyDefaults(DSWActor* actor, ACTOR_ACTION_SETp action, PERSONALITYp person) +void EnemyDefaults(DSWActor* actor, ACTOR_ACTION_SET* action, PERSONALITYp person) { unsigned int wpn; int wpn_cnt; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 81e29a815..b21296462 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -855,7 +855,8 @@ enum MAX_ACTOR_CLOSE_ATTACK = 2, MAX_ACTOR_ATTACK = 6, }; -typedef struct + +struct ACTOR_ACTION_SET { STATEp *Stand; STATEp *Run; @@ -884,7 +885,7 @@ typedef struct STATEp *Special[2]; STATEp *Duck; STATEp *Dive; -} ACTOR_ACTION_SET,*ACTOR_ACTION_SETp; +}; struct ROTATOR { @@ -914,8 +915,6 @@ struct ROTATOR }; -using ROTATORp = ROTATOR*; - // // User Extension record // @@ -945,7 +944,7 @@ struct USER STATEp *StateFallOverride; // a bit kludgy - override std fall state ANIMATORp ActorActionFunc; - ACTOR_ACTION_SETp ActorActionSet; + ACTOR_ACTION_SET* ActorActionSet; PERSONALITYp Personality; ATTRIBUTEp Attrib; SECTOR_OBJECTp sop_parent; // denotes that this sprite is a part of the @@ -1191,12 +1190,6 @@ enum }; -typedef struct -{ - int16_t high; -} RANGE,*RANGEp; - - /////////////////////////////////////////////////////////////////////////////////////////// // // Sector Stuff - Sector Objects and Tracks @@ -1242,11 +1235,10 @@ enum }; #define MAKE_STAG_ENUM -enum stag_id +enum STAG_ID { #include "stag.h" }; -typedef enum stag_id STAG_ID; #undef MAKE_STAG_ENUM @@ -1291,19 +1283,19 @@ enum ShrapType # define CallocMem(size, num) M_Calloc(size, num) # define FreeMem(ptr) M_Free(ptr) -typedef struct TARGET_SORT +struct TARGET_SORT { DSWActor* actor; int16_t dang; int dist; int weight; -} *TARGET_SORTp; +}; enum { MAX_TARGET_SORT = 16 }; extern TARGET_SORT TargetSort[MAX_TARGET_SORT]; extern unsigned TargetSortCount; -enum DoorType +enum DOOR_TYPE { OPERATE_TYPE, DOOR_HORIZ_TYPE, @@ -1312,30 +1304,28 @@ enum DoorType DOOR_ROTATE_TYPE }; -typedef enum DoorType DOOR_TYPE; - -typedef struct +struct DOOR_AUTO_CLOSE { DOOR_TYPE Type; int Sector; int16_t Speed; int16_t TimeOut; -} DOOR_AUTO_CLOSE, *DOOR_AUTO_CLOSEp; +}; -typedef struct +struct SWING { int origx[17], origy[17]; int sector; int16_t angopen, angclosed, angopendir, sang, anginc; -} SWING; +}; -typedef struct SINE_WAVE_FLOOR +struct SINE_WAVE_FLOOR { sectortype* sectp; int floor_origz, ceiling_origz, range; int16_t sintable_ndx, speed_shift; uint8_t flags; -} *SINE_WAVE_FLOORp; +}; enum { @@ -1346,12 +1336,12 @@ enum extern SINE_WAVE_FLOOR SineWaveFloor[MAX_SINE_WAVE][21]; -typedef struct SINE_WALL +struct SINE_WALL { walltype* wallp; int orig_xy, range; int16_t sintable_ndx, speed_shift, type; -} *SINE_WALLp; +}; extern SINE_WALL SineWall[MAX_SINE_WALL][MAX_SINE_WALL_POINTS]; @@ -1373,9 +1363,7 @@ enum extern DOOR_AUTO_CLOSE DoorAutoClose[MAX_DOOR_AUTO_CLOSE]; -typedef void ANIM_CALLBACK (ANIMp, void *); -typedef ANIM_CALLBACK *ANIM_CALLBACKp; -typedef void *ANIM_DATAp; +typedef void (*ANIM_CALLBACKp) (ANIMp, void *); enum { @@ -1694,7 +1682,7 @@ int AnimSet(int animtype, sectortype* animindex, int thegoal, int thevel) short AnimSetCallback(short anim_ndx, ANIM_CALLBACKp call, SECTOR_OBJECTp data); short AnimSetVelAdj(short anim_ndx, short vel_adj); -void EnemyDefaults(DSWActor* actor, ACTOR_ACTION_SETp action, PERSONALITYp person); +void EnemyDefaults(DSWActor* actor, ACTOR_ACTION_SET* action, PERSONALITYp person); void getzrangepoint(int x, int y, int z, sectortype* sect, int32_t* ceilz, Collision* ceilhit, int32_t* florz, Collision* florhit); Collision move_sprite(DSWActor* , int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 774fabc23..aede7b469 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1133,7 +1133,7 @@ DSWActor* DoPickTarget(DSWActor* actor, uint32_t max_delta_ang, int skip_targets int16_t* shp; int ezh, ezhl, ezhm; unsigned ndx; - TARGET_SORTp ts; + TARGET_SORT* ts; int ang_weight, dist_weight; // !JIM! Watch out for max_delta_ang of zero! diff --git a/source/games/sw/src/rotator.cpp b/source/games/sw/src/rotator.cpp index 0c061472b..c9114cb14 100644 --- a/source/games/sw/src/rotator.cpp +++ b/source/games/sw/src/rotator.cpp @@ -46,7 +46,7 @@ void DoRotatorStopInterp(DSWActor*); void ReverseRotator(DSWActor* actor) { - ROTATORp r; + ROTATOR* r; r = actor->user.rotator.Data(); @@ -90,7 +90,7 @@ bool RotatorSwitch(short match, short setting) void SetRotatorActive(DSWActor* actor) { - ROTATORp r; + ROTATOR* r; r = actor->user.rotator.Data(); @@ -241,7 +241,7 @@ void DoRotatorStopInterp(DSWActor* actor) int DoRotator(DSWActor* actor) { - ROTATORp r; + ROTATOR* r; short ndx,w,startwall,endwall; DSWActor* pivot = nullptr; vec2_t nxy; diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index a7bcf7609..ebe398a12 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -182,7 +182,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, STATEp*& w, STATEp return SerializeDataPtr(arc, keyname, *(void**)&w, sizeof(STATEp)); } -FSerializer& Serialize(FSerializer& arc, const char* keyname, ACTOR_ACTION_SETp& w, ACTOR_ACTION_SETp* def) +FSerializer& Serialize(FSerializer& arc, const char* keyname, ACTOR_ACTION_SET*& w, ACTOR_ACTION_SET** def) { return SerializeDataPtr(arc, keyname, *(void**)&w, sizeof(ACTOR_ACTION_SET)); } diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 591d53e67..4fb6bfb00 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -250,7 +250,7 @@ void WallSetup(void) { walltype* wall_num; int cnt, num_points, type, tag_end; - SINE_WALLp sw; + SINE_WALL* sw; int range = 250, speed = 3, peak = 0; tag_end = wal.lotag + 2; @@ -541,7 +541,7 @@ void SectorSetup(void) // setup the sintable_ndx based on the actual number of // sectors (swf_ndx) - for (swf = &SineWaveFloor[NextSineWave][0], cnt = 0; swf->sectp != 0 && swf < (SINE_WAVE_FLOORp)&SineWaveFloor[SIZ(SineWaveFloor)]; swf++, cnt++) + for (swf = &SineWaveFloor[NextSineWave][0], cnt = 0; swf->sectp != 0 && swf < (SINE_WAVE_FLOOR*)&SineWaveFloor[SIZ(SineWaveFloor)]; swf++, cnt++) { if (peak_dist) swf->sintable_ndx = cnt * (2048 / peak_dist); diff --git a/source/games/sw/src/sector.h b/source/games/sw/src/sector.h index d666d1f23..a0b21139e 100644 --- a/source/games/sw/src/sector.h +++ b/source/games/sw/src/sector.h @@ -30,7 +30,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS void SectorSetup(void); -DOOR_AUTO_CLOSEp SetDoorAutoClose(short SectorNum, short Type); +DOOR_AUTO_CLOSE* SetDoorAutoClose(short SectorNum, short Type); void DoDragging(void); int MoveDoorVert(short door_sector, short dir, short door_speed); int MoveDoorUp(short door_sector, short auto_close, short door_speed); diff --git a/source/games/sw/src/slidor.cpp b/source/games/sw/src/slidor.cpp index f2470affa..5d635aac3 100644 --- a/source/games/sw/src/slidor.cpp +++ b/source/games/sw/src/slidor.cpp @@ -41,7 +41,7 @@ BEGIN_SW_NS void ReverseSlidor(DSWActor* actor) { - ROTATORp r; + ROTATOR* r; r = actor->user.rotator.Data(); @@ -86,7 +86,7 @@ bool SlidorSwitch(short match, short setting) void SetSlidorActive(DSWActor* actor) { - ROTATORp r; + ROTATOR* r; r = actor->user.rotator.Data(); @@ -412,7 +412,7 @@ int DoSlidorInstantClose(DSWActor* actor) int DoSlidor(DSWActor* actor) { - ROTATORp r; + ROTATOR* r; int old_pos; bool kill = false; diff --git a/source/games/sw/src/sumo.cpp b/source/games/sw/src/sumo.cpp index 7e9d79142..1c833fe62 100644 --- a/source/games/sw/src/sumo.cpp +++ b/source/games/sw/src/sumo.cpp @@ -540,41 +540,6 @@ STATEp sg_SumoDead[] = s_SumoDead }; -/* -struct -{ -#define MAX_ACTOR_CLOSE_ATTACK 2 -#define MAX_ACTOR_ATTACK 6 -STATEp *Stand; -STATEp *Run; -STATEp *Jump; -STATEp *Fall; -STATEp *Crawl; -STATEp *Swim; -STATEp *Fly; -STATEp *Rise; -STATEp *Sit; -STATEp *Look; -STATEp *Climb; -STATEp *Pain; -STATEp *Death1; -STATEp *Death2; -STATEp *Dead; -STATEp *DeathJump; -STATEp *DeathFall; - -STATEp *CloseAttack[MAX_ACTOR_CLOSE_ATTACK]; -short CloseAttackPercent[MAX_ACTOR_CLOSE_ATTACK]; - -STATEp *Attack[MAX_ACTOR_ATTACK]; -short AttackPercent[MAX_ACTOR_ATTACK]; - -STATEp *Special[2]; -STATEp *Duck; -STATEp *Dive; -}ACTOR_ACTION_SET,*ACTOR_ACTION_SETp; -*/ - ACTOR_ACTION_SET SumoActionSet = { sg_SumoStand, diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 33aa359d3..92ed44ef9 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -7623,7 +7623,7 @@ int DoPlasmaDone(DSWActor* actor) DSWActor* PickEnemyTarget(DSWActor* actor, short aware_range) { - TARGET_SORTp ts; + TARGET_SORT* ts; DoPickTarget(actor, aware_range, false); @@ -13654,7 +13654,7 @@ int InitMicro(PLAYERp pp) DSWActor* actor = pp->actor; int nx, ny, nz, dist; short i,ang; - TARGET_SORTp ts = TargetSort; + TARGET_SORT* ts = TargetSort; DSWActor* picked = nullptr; nx = pp->pos.X; @@ -15415,7 +15415,7 @@ int InitTurretMicro(DSWActor* actor, PLAYERp pp) DSWActor* plActor = pp->actor; int nx, ny, nz, dist; short i,ang; - TARGET_SORTp ts = TargetSort; + TARGET_SORT* ts = TargetSort; DSWActor* picked = nullptr; if (SW_SHAREWARE) return false; // JBF: verify diff --git a/source/games/sw/src/zilla.cpp b/source/games/sw/src/zilla.cpp index 1b2a08fd8..511bee535 100644 --- a/source/games/sw/src/zilla.cpp +++ b/source/games/sw/src/zilla.cpp @@ -575,41 +575,6 @@ STATEp sg_ZillaDead[] = s_ZillaDead }; -/* -struct -{ -#define MAX_ACTOR_CLOSE_ATTACK 2 -#define MAX_ACTOR_ATTACK 6 -STATEp *Stand; -STATEp *Run; -STATEp *Jump; -STATEp *Fall; -STATEp *Crawl; -STATEp *Swim; -STATEp *Fly; -STATEp *Rise; -STATEp *Sit; -STATEp *Look; -STATEp *Climb; -STATEp *Pain; -STATEp *Death1; -STATEp *Death2; -STATEp *Dead; -STATEp *DeathJump; -STATEp *DeathFall; - -STATEp *CloseAttack[MAX_ACTOR_CLOSE_ATTACK]; -short CloseAttackPercent[MAX_ACTOR_CLOSE_ATTACK]; - -STATEp *Attack[MAX_ACTOR_ATTACK]; -short AttackPercent[MAX_ACTOR_ATTACK]; - -STATEp *Special[2]; -STATEp *Duck; -STATEp *Dive; -}ACTOR_ACTION_SET,*ACTOR_ACTION_SETp; -*/ - ACTOR_ACTION_SET ZillaActionSet = { sg_ZillaStand,