‚char‘ review in Blood - part 2

This commit is contained in:
Christoph Oelckers 2021-11-16 18:36:34 +01:00
parent 5422bff683
commit 28eca1a023
16 changed files with 55 additions and 56 deletions

View file

@ -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;

View file

@ -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<class T>
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();
}

View file

@ -54,7 +54,7 @@ int XWallsUsed, XSectorsUsed;
char qsector_filler[kMaxSectors];
uint8_t qsector_filler[kMaxSectors];
int gVisibility;

View file

@ -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<MAXSPRITES> activeXSprites;
extern char qsector_filler[kMaxSectors];
extern uint8_t qsector_filler[kMaxSectors];
extern int gVisibility;
extern int gMapRev, gMattId, gSkyCount;

View file

@ -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)

View file

@ -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<uint8_t> 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;

View file

@ -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;

View file

@ -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];

View file

@ -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)

View file

@ -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);

View file

@ -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)
{

View file

@ -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

View file

@ -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,

View file

@ -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];

View file

@ -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:

View file

@ -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;