From 28eca1a0230c09bf8c9e6b39127059ac4ea4ea64 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 16 Nov 2021 18:36:34 +0100 Subject: [PATCH] =?UTF-8?q?=E2=80=9Achar=E2=80=98=20review=20in=20Blood=20?= =?UTF-8?q?-=20part=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/games/blood/src/barf.cpp | 4 ++-- source/games/blood/src/common_game.h | 8 ++++---- source/games/blood/src/db.cpp | 2 +- source/games/blood/src/db.h | 4 ++-- source/games/blood/src/dude.h | 2 +- source/games/blood/src/fire.cpp | 12 ++++++------ source/games/blood/src/levels.h | 10 +++++----- source/games/blood/src/misc.h | 2 +- source/games/blood/src/player.cpp | 28 ++++++++++++++------------- source/games/blood/src/player.h | 8 ++++---- source/games/blood/src/prediction.cpp | 11 ++++------- source/games/blood/src/qav.h | 2 +- source/games/blood/src/sectorfx.cpp | 10 +++++----- source/games/blood/src/tile.cpp | 2 +- source/games/blood/src/triggers.cpp | 4 ++-- source/games/blood/src/view.cpp | 2 +- 16 files changed, 55 insertions(+), 56 deletions(-) diff --git a/source/games/blood/src/barf.cpp b/source/games/blood/src/barf.cpp index 9e87f3a77..bf32fbbce 100644 --- a/source/games/blood/src/barf.cpp +++ b/source/games/blood/src/barf.cpp @@ -586,7 +586,7 @@ void ParseScript(int lumpnum) } strcpy(inp, scriptBuffer); - char nFlags = 0; + uint8_t nFlags = 0; int ID = 0; bool isDefine = false; @@ -773,7 +773,7 @@ void ParseScript(int lumpnum) // eg strcpy(fileName, "AMB1.SFX"); strcpy(fileName, scriptBuffer); - char nFlags = 0; + uint8_t nFlags = 0; int ID = 0; bool isDefine = false; diff --git a/source/games/blood/src/common_game.h b/source/games/blood/src/common_game.h index 30768ba05..2919bbb30 100644 --- a/source/games/blood/src/common_game.h +++ b/source/games/blood/src/common_game.h @@ -531,7 +531,7 @@ inline int ClipRange(int a, int b, int c) return a; } -inline char Chance(int a1) +inline uint8_t Chance(int a1) { return wrand() < (a1>>1); } @@ -576,10 +576,10 @@ inline void ClearBitString(T *pArray, int nIndex) } template -inline char TestBitString(T *pArray, int nIndex) +inline bool TestBitString(T *pArray, int nIndex) { static_assert(sizeof(T) == 1, "Bit array element too large"); - return pArray[nIndex>>3] & (1<<(nIndex&7)); + return !!(pArray[nIndex>>3] & (1<<(nIndex&7))); } // This is to override the namepace prioritization without altering the actual calls. @@ -637,7 +637,7 @@ public: { return x0 < x1 && y0 < y1; } - char isEmpty(void) const + bool isEmpty(void) const { return !isValid(); } diff --git a/source/games/blood/src/db.cpp b/source/games/blood/src/db.cpp index f72381f2d..607a207a8 100644 --- a/source/games/blood/src/db.cpp +++ b/source/games/blood/src/db.cpp @@ -54,7 +54,7 @@ int XWallsUsed, XSectorsUsed; -char qsector_filler[kMaxSectors]; +uint8_t qsector_filler[kMaxSectors]; int gVisibility; diff --git a/source/games/blood/src/db.h b/source/games/blood/src/db.h index df05e9646..aec675fc1 100644 --- a/source/games/blood/src/db.h +++ b/source/games/blood/src/db.h @@ -288,7 +288,7 @@ struct MAPHEADER2 { int numxsprites; // xsprite size int numxwalls; // xwall size int numxsectors; // xsector size - char pad[52]; + uint8_t pad[52]; }; #pragma pack(pop) @@ -305,7 +305,7 @@ extern XWALL xwall[kMaxXWalls]; extern FixedBitArray activeXSprites; -extern char qsector_filler[kMaxSectors]; +extern uint8_t qsector_filler[kMaxSectors]; extern int gVisibility; extern int gMapRev, gMattId, gSkyCount; diff --git a/source/games/blood/src/dude.h b/source/games/blood/src/dude.h index b121cb4a7..a7983125e 100644 --- a/source/games/blood/src/dude.h +++ b/source/games/blood/src/dude.h @@ -42,7 +42,7 @@ struct DUDEINFO { int changeTarget; // chance to change target when attacked someone else int changeTargetKin; // chance to change target when attacked by same type int alertChance; - char lockOut; // indicates if this dude can trigger something via trigger flags + uint8_t lockOut; // indicates if this dude can trigger something via trigger flags int frontSpeed; // acceleration int sideSpeed; // dodge int backSpeed; // backward speed (unused) diff --git a/source/games/blood/src/fire.cpp b/source/games/blood/src/fire.cpp index 9b76b20cd..332f19670 100644 --- a/source/games/blood/src/fire.cpp +++ b/source/games/blood/src/fire.cpp @@ -34,12 +34,12 @@ BEGIN_BLD_NS int fireSize = 128; int gDamping = 6; -char CoolTable[1024]; +uint8_t CoolTable[1024]; -void CellularFrame(char *pFrame, int sizeX, int sizeY); +void CellularFrame(uint8_t *pFrame, int sizeX, int sizeY); -char FrameBuffer[17280]; -char SeedBuffer[16][128]; +static uint8_t FrameBuffer[17280]; +static uint8_t SeedBuffer[16][128]; static TArray gCLU; void InitSeedBuffers(void) @@ -64,7 +64,7 @@ void DoFireFrame(void) } CellularFrame(FrameBuffer, 128, 132); auto pData = TileFiles.tileMakeWritable(2342); - char *pSource = FrameBuffer; + uint8_t *pSource = FrameBuffer; int x = fireSize; do { @@ -106,7 +106,7 @@ void FireProcess(void) } } -void CellularFrame(char *pFrame, int sizeX, int sizeY) +void CellularFrame(uint8_t *pFrame, int sizeX, int sizeY) { int nSquare = sizeX * sizeY; uint8_t *pPtr1 = (uint8_t*)pFrame; diff --git a/source/games/blood/src/levels.h b/source/games/blood/src/levels.h index 0b3568667..c10778547 100644 --- a/source/games/blood/src/levels.h +++ b/source/games/blood/src/levels.h @@ -48,13 +48,13 @@ enum EGameFlag struct GAMEOPTIONS { uint8_t nGameType; uint8_t nDifficulty; - char nMonsterSettings; + uint8_t nMonsterSettings; int uGameFlags; int uNetGameFlags; - char nWeaponSettings; - char nItemSettings; - char nRespawnSettings; - char nTeamSettings; + uint8_t nWeaponSettings; + uint8_t nItemSettings; + uint8_t nRespawnSettings; + uint8_t nTeamSettings; int nMonsterRespawnTime; int nWeaponRespawnTime; int nItemRespawnTime; diff --git a/source/games/blood/src/misc.h b/source/games/blood/src/misc.h index edba869fe..2565b0ad5 100644 --- a/source/games/blood/src/misc.h +++ b/source/games/blood/src/misc.h @@ -102,7 +102,7 @@ enum SurfaceType { kSurfMax }; -extern char surfType[MAXTILES]; +extern uint8_t surfType[MAXTILES]; extern int8_t tileShade[MAXTILES]; extern short voxelIndex[MAXTILES]; diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index cba5b8e72..4f80ac750 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -237,7 +237,7 @@ int powerupCheck(PLAYER *pPlayer, int nPowerUp) } -char powerupActivate(PLAYER *pPlayer, int nPowerUp) +bool powerupActivate(PLAYER *pPlayer, int nPowerUp) { if (powerupCheck(pPlayer, nPowerUp) > 0 && gPowerUpInfo[nPowerUp].pickupOnce) return 0; @@ -353,7 +353,7 @@ void powerupDeactivate(PLAYER *pPlayer, int nPowerUp) } } -void powerupSetState(PLAYER *pPlayer, int nPowerUp, char bState) +void powerupSetState(PLAYER *pPlayer, int nPowerUp, bool bState) { if (!bState) powerupActivate(pPlayer, nPowerUp); @@ -439,7 +439,7 @@ int powerupToPackItem(int nPowerUp) return -1; } -char packAddItem(PLAYER *pPlayer, unsigned int nPack) +bool packAddItem(PLAYER *pPlayer, unsigned int nPack) { if (nPack <= 4) { @@ -471,7 +471,7 @@ bool packItemActive(PLAYER *pPlayer, int nPack) void packUseItem(PLAYER *pPlayer, int nPack) { - char v4 = 0; + bool v4 = 0; int nPowerUp = -1; if (pPlayer->packSlots[nPack].curAmount > 0) { @@ -562,7 +562,7 @@ void packNextItem(PLAYER* pPlayer) pPlayer->packItemTime = 600; } -char playerSeqPlaying(PLAYER * pPlayer, int nSeq) +bool playerSeqPlaying(PLAYER * pPlayer, int nSeq) { int nCurSeq = seqGetID(pPlayer->actor); if (pPlayer->pDudeInfo->seqStartID+nSeq == nCurSeq && seqGetStatus(pPlayer->actor) >= 0) @@ -866,11 +866,13 @@ bool findDroppedLeech(PLAYER *a1, DBloodActor *a2) return 0; } -char PickupItem(PLAYER *pPlayer, DBloodActor* itemactor) +bool PickupItem(PLAYER *pPlayer, DBloodActor* itemactor) { spritetype* pItem = &itemactor->s(); spritetype *pSprite = pPlayer->pSprite; - char buffer[80]; int pickupSnd = 775; int nType = pItem->type - kItemBase; + char buffer[80]; + int pickupSnd = 775; + int nType = pItem->type - kItemBase; switch (pItem->type) { case kItemShadowCloak: @@ -1093,7 +1095,7 @@ char PickupItem(PLAYER *pPlayer, DBloodActor* itemactor) return 1; } -char PickupAmmo(PLAYER* pPlayer, DBloodActor* ammoactor) +bool PickupAmmo(PLAYER* pPlayer, DBloodActor* ammoactor) { spritetype* pAmmo = &ammoactor->s(); const AMMOITEMDATA* pAmmoItemData = &gAmmoItemData[pAmmo->type - kItemAmmoBase]; @@ -1112,7 +1114,7 @@ char PickupAmmo(PLAYER* pPlayer, DBloodActor* ammoactor) return 1; } -char PickupWeapon(PLAYER *pPlayer, DBloodActor* weaponactor) +bool PickupWeapon(PLAYER *pPlayer, DBloodActor* weaponactor) { spritetype* pWeapon = &weaponactor->s(); const WEAPONITEMDATA *pWeaponItemData = &gWeaponItemData[pWeapon->type - kItemWeaponBase]; @@ -1157,7 +1159,7 @@ void PickUp(PLAYER *pPlayer, DBloodActor* actor) spritetype* pSprite = &actor->s(); const char *msg = nullptr; int nType = pSprite->type; - char pickedUp = 0; + bool pickedUp = 0; int customMsg = -1; #ifdef NOONE_EXTENSIONS if (gModernMap && actor->hasX()) { // allow custom INI message instead "Picked up" @@ -1335,7 +1337,7 @@ void doslopetilting(PLAYER* pPlayer, double const scaleAdjust = 1) auto* const pSprite = pPlayer->pSprite; auto* const pXSprite = pPlayer->pXSprite; int const florhit = pPlayer->actor->hit.florhit.type; - char const va = pXSprite->height < 16 && (florhit == kHitSector || florhit == 0) ? 1 : 0; + bool const va = pXSprite->height < 16 && (florhit == kHitSector || florhit == 0) ? 1 : 0; pPlayer->horizon.calcviewpitch(pSprite->pos.vec2, buildang(pSprite->ang), va, sector[pSprite->sectnum].floorstat & 2, pSprite->sectnum, scaleAdjust); } @@ -1369,7 +1371,7 @@ void ProcessInput(PLAYER *pPlayer) WeaponProcess(pPlayer); if (pXSprite->health == 0) { - char bSeqStat = playerSeqPlaying(pPlayer, 16); + bool bSeqStat = playerSeqPlaying(pPlayer, 16); auto fragger = pPlayer->fragger; if (fragger) { @@ -1939,7 +1941,7 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nDeathSeqID = -1; int nKneelingPlayer = -1; - char va = playerSeqPlaying(pPlayer, 16); + bool va = playerSeqPlaying(pPlayer, 16); if (!pXSprite->health) { if (va) diff --git a/source/games/blood/src/player.h b/source/games/blood/src/player.h index 5a08a24e8..fe58f2dcc 100644 --- a/source/games/blood/src/player.h +++ b/source/games/blood/src/player.h @@ -238,20 +238,20 @@ inline bool IsTargetTeammate(spritetype *pSourceSprite, spritetype *pTargetSprit } int powerupCheck(PLAYER *pPlayer, int nPowerUp); -char powerupActivate(PLAYER *pPlayer, int nPowerUp); +bool powerupActivate(PLAYER *pPlayer, int nPowerUp); void powerupDeactivate(PLAYER *pPlayer, int nPowerUp); -void powerupSetState(PLAYER *pPlayer, int nPowerUp, char bState); +void powerupSetState(PLAYER *pPlayer, int nPowerUp, bool bState); void powerupProcess(PLAYER *pPlayer); void powerupClear(PLAYER *pPlayer); int packItemToPowerup(int nPack); int powerupToPackItem(int nPowerUp); -char packAddItem(PLAYER *pPlayer, unsigned int nPack); +bool packAddItem(PLAYER *pPlayer, unsigned int nPack); int packCheckItem(PLAYER *pPlayer, int nPack); bool packItemActive(PLAYER *pPlayer, int nPack); void packUseItem(PLAYER *pPlayer, int nPack); void packPrevItem(PLAYER *pPlayer); void packNextItem(PLAYER *pPlayer); -char playerSeqPlaying(PLAYER *pPlayer, int nSeq); +bool playerSeqPlaying(PLAYER *pPlayer, int nSeq); void playerSetRace(PLAYER *pPlayer, int nLifeMode); void playerSetGodMode(PLAYER *pPlayer, bool bGodMode); void playerResetInertia(PLAYER *pPlayer); diff --git a/source/games/blood/src/prediction.cpp b/source/games/blood/src/prediction.cpp index 1855bb347..9fd42f406 100644 --- a/source/games/blood/src/prediction.cpp +++ b/source/games/blood/src/prediction.cpp @@ -233,11 +233,8 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput) int nSector = predict.sectnum; int florhit = predict.at75.florhit.type; - char va; - if (predict.floordist < 16 && (florhit == kHitSector || florhit == 0)) - va = 1; - else - va = 0; + bool va = (predict.floordist < 16 && (florhit == kHitSector || florhit == 0)); + if (va && (sector[nSector].floorstat&2) != 0) { int z1 = getflorzofslope(nSector, predict.x, predict.y); @@ -424,8 +421,8 @@ static void fakeMoveDude(spritetype *pSprite) assert(nSector >= 0 && nSector < kMaxSectors); predict.sectnum = nSector; } - char bUnderwater = 0; - char bDepth = 0; + bool bUnderwater = 0; + bool bDepth = 0; int nXSector = sector[nSector].extra; if (nXSector > 0) { diff --git a/source/games/blood/src/qav.h b/source/games/blood/src/qav.h index 2add19986..9ace03f4e 100644 --- a/source/games/blood/src/qav.h +++ b/source/games/blood/src/qav.h @@ -209,7 +209,7 @@ struct SOUNDINFO uint8_t priority; uint8_t sndFlags; // (by NoOne) Various sound flags uint8_t sndRange; // (by NoOne) Random sound range - char reserved[1]; + uint8_t reserved[1]; }; struct FRAMEINFO diff --git a/source/games/blood/src/sectorfx.cpp b/source/games/blood/src/sectorfx.cpp index b82e50a37..d1cdf70b8 100644 --- a/source/games/blood/src/sectorfx.cpp +++ b/source/games/blood/src/sectorfx.cpp @@ -30,28 +30,28 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS -char flicker1[] = { +static const uint8_t flicker1[] = { 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1 }; -char flicker2[] = { +static const uint8_t flicker2[] = { 1, 2, 4, 2, 3, 4, 3, 2, 0, 0, 1, 2, 4, 3, 2, 0, 2, 1, 0, 1, 0, 2, 3, 4, 3, 2, 1, 1, 2, 0, 0, 1, 1, 2, 3, 4, 4, 3, 2, 1, 2, 3, 4, 4, 2, 1, 0, 1, 0, 0, 0, 0, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2 }; -char flicker3[] = { +static const uint8_t flicker3[] = { 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 2, 4, 3, 4, 4, 4, 4, 2, 1, 3, 3, 3, 4, 3, 4, 4, 4, 4, 4, 2, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 1, 0, 1, 0, 1, 0, 1, 0, 2, 3, 4, 4, 4, 4, 4, 4, 4, 3, 4 }; -char flicker4[] = { +static const uint8_t flicker4[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 3, 0, 1, 0, 1, 0, 4, 4, 4, 4, 4, 2, 0, 0, 0, 0, 4, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, @@ -62,7 +62,7 @@ char flicker4[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0, 0, 0 ,0, 0 }; -char strobe[] = { +static const uint8_t strobe[] = { 64, 64, 64, 48, 36, 27, 20, 15, 11, 9, 6, 5, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/source/games/blood/src/tile.cpp b/source/games/blood/src/tile.cpp index 906979900..0c65d5622 100644 --- a/source/games/blood/src/tile.cpp +++ b/source/games/blood/src/tile.cpp @@ -39,7 +39,7 @@ int tileStart[256]; int tileEnd[256]; int hTileFile[256]; -char surfType[kMaxTiles]; +uint8_t surfType[kMaxTiles]; int8_t tileShade[kMaxTiles]; short voxelIndex[kMaxTiles]; diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index 087788671..db21f65a9 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -631,7 +631,7 @@ void SetupGibWallState(walltype *pWall, XWALL *pXWall) } return; } - char bVector = pXWall->triggerVector != 0; + bool bVector = pXWall->triggerVector != 0; pWall->cstat |= 1; if (bVector) pWall->cstat |= 64; @@ -668,7 +668,7 @@ void OperateWall(int nWall, XWALL *pXWall, EVENT event) { switch (pWall->type) { case kWallGib: if (GetWallType(nWall) != pWall->type) break; - char bStatus; + bool bStatus; switch (event.cmd) { case kCmdOn: case kCmdWallImpact: diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 5672e6a93..d0413b927 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -88,7 +88,7 @@ void viewCorrectViewOffsets(int nPlayer, vec3_t const *oldpos) pView->viewz += pPlayer->pSprite->z-oldpos->z; } -void viewDrawText(FFont* pFont, const char *pString, int x, int y, int nShade, int nPalette, int position, char shadow) +void viewDrawText(FFont* pFont, const char *pString, int x, int y, int nShade, int nPalette, int position, bool shadow) { if (!pString) return;