From f43f63adecb47d769d29815248315220832b9304 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 31 Dec 2021 15:10:37 +0100 Subject: [PATCH] - all typedefs in jsector.h and inv.h plus a bit of cleanup and #define removal. --- source/games/sw/src/inv.cpp | 6 ++--- source/games/sw/src/inv.h | 44 +++++++++++++++++----------------- source/games/sw/src/jsector.h | 37 +++++++++++++++------------- source/games/sw/src/menus.cpp | 15 ++---------- source/games/sw/src/network.h | 12 ++++++---- source/games/sw/src/panel.cpp | 13 ++++------ source/games/sw/src/player.cpp | 2 +- 7 files changed, 59 insertions(+), 70 deletions(-) diff --git a/source/games/sw/src/inv.cpp b/source/games/sw/src/inv.cpp index eea965848..aee0cf24e 100644 --- a/source/games/sw/src/inv.cpp +++ b/source/games/sw/src/inv.cpp @@ -493,7 +493,7 @@ void InventoryTimer(PLAYERp pp) { // called every time through loop short inv = 0; - INVENTORY_DATAp id; + INVENTORY_DATA* id; // if bar is up if (pp->InventoryBarTics) @@ -569,7 +569,7 @@ void InventoryTimer(PLAYERp pp) void InventoryUse(PLAYERp pp) { - INVENTORY_DATAp id = &InventoryData[pp->InventoryNum]; + INVENTORY_DATA* id = &InventoryData[pp->InventoryNum]; if (id->Init) (*id->Init)(pp); @@ -577,7 +577,7 @@ void InventoryUse(PLAYERp pp) void InventoryStop(PLAYERp pp, short InventoryNum) { - INVENTORY_DATAp id = &InventoryData[InventoryNum]; + INVENTORY_DATA* id = &InventoryData[InventoryNum]; if (id->Stop) (*id->Stop)(pp, InventoryNum); diff --git a/source/games/sw/src/inv.h b/source/games/sw/src/inv.h index 505486aed..1e5bc7dd9 100644 --- a/source/games/sw/src/inv.h +++ b/source/games/sw/src/inv.h @@ -26,37 +26,37 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms enum InventoryNames { - INVENTORY_MEDKIT, - INVENTORY_REPAIR_KIT, - INVENTORY_CLOAK, // de-cloak when firing - INVENTORY_NIGHT_VISION, - INVENTORY_CHEMBOMB, - INVENTORY_FLASHBOMB, - INVENTORY_CALTROPS, - MAX_INVENTORY + INVENTORY_MEDKIT, + INVENTORY_REPAIR_KIT, + INVENTORY_CLOAK, // de-cloak when firing + INVENTORY_NIGHT_VISION, + INVENTORY_CHEMBOMB, + INVENTORY_FLASHBOMB, + INVENTORY_CALTROPS, + MAX_INVENTORY }; -typedef struct +struct INVENTORY_DATA { - const char *Name; - void (*Init)(PLAYERp); - void (*Stop)(PLAYERp, short); - short DecPerSec; - short MaxInv; - int Scale; - short Flags; -} INVENTORY_DATA, *INVENTORY_DATAp; + const char* Name; + void (*Init)(PLAYERp); + void (*Stop)(PLAYERp, short); + short DecPerSec; + short MaxInv; + int Scale; + short Flags; +}; -extern INVENTORY_DATA InventoryData[MAX_INVENTORY+1]; +extern INVENTORY_DATA InventoryData[MAX_INVENTORY + 1]; enum EInvFlags { - INVF_AUTO_USE = 1, - INVF_TIMED = 2, - INVF_COUNT = 4 + INVF_AUTO_USE = 1, + INVF_TIMED = 2, + INVF_COUNT = 4 }; -void PlayerUpdateInventory(PLAYERp pp,short InventoryNum); +void PlayerUpdateInventory(PLAYERp pp, short InventoryNum); void InventoryKeys(PLAYERp pp); void UseInventoryRepairKit(PLAYERp pp); void InventoryTimer(PLAYERp pp); diff --git a/source/games/sw/src/jsector.h b/source/games/sw/src/jsector.h index 04aad6125..3e66b1447 100644 --- a/source/games/sw/src/jsector.h +++ b/source/games/sw/src/jsector.h @@ -30,28 +30,31 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS -#define MAXMIRRORDIST 3300 // At this distance, or less, the magic mirrors activate. -#define MAXMIRRORMONSTERS 4 // Max monsters any one magic mirror can spawn - -typedef enum +enum { - m_normal, m_viewon, m_pissed -} MIRRORSTATE; + MAXMIRRORDIST = 3300, // At this distance, or less, the magic mirrors activate. + MAXMIRRORMONSTERS = 4 // Max monsters any one magic mirror can spawn +}; -typedef struct +enum +{ + m_normal, m_viewon, m_pissed +}; + +struct MIRRORTYPE { TObjPtr cameraActor; // Contains number of ST1 sprite used as a camera - TObjPtr camspriteActor; // sprite pointing to campic + TObjPtr camspriteActor; // sprite pointing to campic walltype* mirrorWall; // Wall number containing the mirror tile - sectortype* mirrorSector; // used internally to draw mirror rooms - short campic; // Editart tile number to draw a screen to - short numspawnspots; // Number of spawnspots used - short spawnspots[MAXMIRRORMONSTERS]; // One spot for each possible skill level for a max of up to 4 coolie ghosts to spawn. - bool ismagic; // Is this a magic mirror? - uint8_t mstate; // What state the mirror is currently in - int maxtics; // Tic count used to time mirror events - int tics; // How much viewing time has been used on mirror? -} MIRRORTYPE, *MIRRORTYPEp; + sectortype* mirrorSector; // used internally to draw mirror rooms + short campic; // Editart tile number to draw a screen to + short numspawnspots; // Number of spawnspots used + short spawnspots[MAXMIRRORMONSTERS]; // One spot for each possible skill level for a max of up to 4 coolie ghosts to spawn. + bool ismagic; // Is this a magic mirror? + uint8_t mstate; // What state the mirror is currently in + int maxtics; // Tic count used to time mirror events + int tics; // How much viewing time has been used on mirror? +}; extern MIRRORTYPE mirror[MAXMIRRORS]; diff --git a/source/games/sw/src/menus.cpp b/source/games/sw/src/menus.cpp index 52a6f2415..fcb46e0fe 100644 --- a/source/games/sw/src/menus.cpp +++ b/source/games/sw/src/menus.cpp @@ -76,14 +76,6 @@ static int faderamp[32] = }; -typedef struct RGB_color_typ -{ - uint8_t red; - uint8_t green; - uint8_t blue; -} RGB_color, * RGB_color_ptr; - - ////////////////////////////////////////// // Set the amount of redness for damage // the player just took @@ -93,7 +85,6 @@ void SetFadeAmt(PLAYERp pp, short damage, uint8_t startcolor) const int FADE_DAMAGE_FACTOR = 3; // 100 health / 32 shade cycles = 3.125 short fadedamage = 0; - RGB_color color; //Printf("SetAmt: fadeamt = %d, startcolor = %d, pp = %d",pp->FadeAmt,startcolor,pp->StartColor); @@ -138,14 +129,12 @@ void SetFadeAmt(PLAYERp pp, short damage, uint8_t startcolor) pp->FadeTics = 0; - color.red = GPalette.BaseColors[pp->StartColor].r; - color.green = GPalette.BaseColors[pp->StartColor].g; - color.blue = GPalette.BaseColors[pp->StartColor].b; + auto color = GPalette.BaseColors[pp->StartColor]; // Do initial palette set if (pp == Player + screenpeek) { - videoFadePalette(color.red, color.green, color.blue, faderamp[min(31, max(0, 32 - abs(pp->FadeAmt)))]); + videoFadePalette(color.r, color.g, color.b, faderamp[min(31, max(0, 32 - abs(pp->FadeAmt)))]); if (damage < -1000) pp->FadeAmt = 1000; // Don't call DoPaletteFlash for underwater stuff } diff --git a/source/games/sw/src/network.h b/source/games/sw/src/network.h index c65d3aa09..b12436e12 100644 --- a/source/games/sw/src/network.h +++ b/source/games/sw/src/network.h @@ -26,9 +26,11 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms //------------------------------------------------------------------------- BEGIN_SW_NS -#define SYNC_TEST 0 -#define MAXSYNCBYTES 16 - +enum +{ + SYNC_TEST = 0, + MAXSYNCBYTES = 16 +}; extern bool PredictionOn; extern PLAYER PredictPlayer; extern PLAYERp ppp; @@ -55,7 +57,7 @@ enum MultiGameTypes // global net vars // not saved in .CFG file // used for current game -typedef struct +struct gNET { int32_t KillLimit; int32_t TimeLimit; @@ -67,7 +69,7 @@ typedef struct bool AutoAim; bool NoRespawn; // for commbat type games bool Nuke; -} gNET,*gNETp; +}; extern gNET gNet; diff --git a/source/games/sw/src/panel.cpp b/source/games/sw/src/panel.cpp index d26a26fb9..70800a454 100644 --- a/source/games/sw/src/panel.cpp +++ b/source/games/sw/src/panel.cpp @@ -58,17 +58,12 @@ int InitGrenade(PLAYERp pp); int InitMine(PLAYERp pp); int InitFistAttack(PLAYERp pp); -#define PANF_UZI_XFLIP (BIT(21)) - -#define XDIM 320 -#define YDIM 200 - -typedef struct +struct PANEL_SHRAP { short xoff, yoff, skip; int lo_jump_speed, hi_jump_speed, lo_xspeed, hi_xspeed; PANEL_STATE* state[2]; -} PANEL_SHRAP, *PANEL_SHRAPp; +}; void PanelInvTestSuicide(PANEL_SPRITEp psp); @@ -4590,7 +4585,7 @@ void SpawnHeartBlood(PANEL_SPRITEp psp) { PLAYERp pp = psp->PlayerP; PANEL_SPRITEp blood; - PANEL_SHRAPp hsp; + PANEL_SHRAP* hsp; static PANEL_SHRAP HeartShrap[] = { @@ -4629,7 +4624,7 @@ void SpawnSmallHeartBlood(PANEL_SPRITEp psp) { PLAYERp pp = psp->PlayerP; PANEL_SPRITEp blood; - PANEL_SHRAPp hsp; + PANEL_SHRAP* hsp; static PANEL_SHRAP HeartShrap[] = { diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 32d23f8e5..774fabc23 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -7217,7 +7217,7 @@ DEFINE_ACTION_FUNCTION(_SW, InventoryFlags) { PARAM_PROLOGUE; PARAM_INT(inv); - INVENTORY_DATAp id = &InventoryData[inv]; + INVENTORY_DATA* id = &InventoryData[inv]; ACTION_RETURN_INT(id->Flags); }