- fixed all issues with SWBOOL as pointed out by a type-safe wrapper class.

This commit is contained in:
Christoph Oelckers 2020-09-09 20:28:05 +02:00
parent 1a647e8104
commit e044582aef
24 changed files with 87 additions and 52 deletions

View file

@ -308,8 +308,7 @@ DoActorNoise(ANIMATORp Action, short SpriteNum)
return 0;
}
int
CanSeePlayer(short SpriteNum)
bool CanSeePlayer(short SpriteNum)
{
USERp u = User[SpriteNum];
SPRITEp sp = User[SpriteNum]->SpriteP;

View file

@ -76,7 +76,7 @@ SWBOOL ActorFlaming(short SpriteNum);
void DoActorSetSpeed(short SpriteNum,uint8_t speed);
short ChooseActionNumber(short decision[]);
int DoActorNoise(ANIMATORp Action,short SpriteNum);
int CanSeePlayer(short SpriteNum);
bool CanSeePlayer(short SpriteNum);
int CanHitPlayer(short SpriteNum);
int DoActorPickClosePlayer(short SpriteNum);
int CloseRangeDist(SPRITEp sp1,SPRITEp sp2);

View file

@ -668,7 +668,7 @@ SWBOOL UserBreakWall(WALLp wp, short)
int block_flags = CSTAT_WALL_BLOCK|CSTAT_WALL_BLOCK_HITSCAN;
int type_flags = CSTAT_WALL_TRANSLUCENT|CSTAT_WALL_MASKED|CSTAT_WALL_1WAY;
int flags = block_flags|type_flags;
short ret = false;
SWBOOL ret = false;
SpriteNum = FindBreakSpriteMatch(match);

View file

@ -855,7 +855,6 @@ DoBunnyBeginJumpAttack(short SpriteNum)
SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum];
SPRITEp psp = User[SpriteNum]->tgt_sp;
int CanSeePlayer(short SpriteNum);
short tang;
tang = getangle(psp->x - sp->x, psp->y - sp->y);

View file

@ -103,7 +103,7 @@ bool RestartCheat(cheatseq_t* c)
bool RoomCheat(cheatseq_t* c)
{
FAF_DebugView ^= 1;
FAF_DebugView = !FAF_DebugView;
return true;
}
@ -161,7 +161,7 @@ bool WarpCheat(cheatseq_t* c)
bool EveryCheatToggle(cheatseq_t* c)
{
EveryCheat ^= 1;
EveryCheat = !EveryCheat;
C_DoCommand("god");
C_DoCommand("give weapons");
C_DoCommand("give items");

View file

@ -97,7 +97,7 @@ extern int sw_snd_scratch;
int GameVersion = 20;
SWBOOL NoMeters = false;
SWBOOL FinishAnim = 0;
int FinishAnim = 0;
SWBOOL ReloadPrompt = false;
SWBOOL NewGame = false;
SWBOOL SavegameLoaded = false;
@ -127,7 +127,6 @@ GAME_SET gs;
SWBOOL PlayerTrackingMode = false;
SWBOOL SlowMode = false;
SWBOOL FrameAdvanceTics = 3;
SWBOOL DebugOperate = false;
void LoadingLevelScreen(void);
@ -292,7 +291,7 @@ void InitLevelGlobals2(void)
InitTimingVars();
TotalKillable = 0;
Bunny_Count = 0;
FinishAnim = 0;
FinishAnim = false;
}
//---------------------------------------------------------------------------
@ -576,7 +575,7 @@ void GameInterface::LevelCompleted(MapRecord *map, int skill)
if (map == nullptr)
{
STAT_Update(true);
FinishAnim = 0;
FinishAnim = false;
PlaySong(nullptr, ThemeSongs[0], ThemeTrack[0]);
if (SW_SHAREWARE) gameaction = ga_creditsmenu;
else gameaction = ga_mainmenu;
@ -687,7 +686,7 @@ void GameInterface::ErrorCleanup()
// Make sure we do not leave the game in an unstable state
TerminateLevel();
SavegameLoaded = false;
FinishAnim = 0;
FinishAnim = false;
}
//---------------------------------------------------------------------------
//

View file

@ -1926,7 +1926,7 @@ void EnemyDefaults(short SpriteNum, ACTOR_ACTION_SETp action, PERSONALITYp perso
void getzrangepoint(int x, int y, int z, short sectnum, int32_t* ceilz, int32_t* ceilhit, int32_t* florz, int32_t* florhit);
int move_sprite(short spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics);
int move_missile(short spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics);
int DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, SWBOOL skip_targets);
int DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, int skip_targets);
void change_sprite_stat(short, short);
void SetOwner(short, short);
@ -2044,7 +2044,7 @@ extern USER puser[MAX_SW_PLAYERS_REG];
///////////////////////////
extern double smoothratio;
extern SWBOOL MoveSkip4, MoveSkip2, MoveSkip8;
extern int MoveSkip4, MoveSkip2, MoveSkip8;
#define MASTER_SWITCHING 1

View file

@ -349,7 +349,7 @@ SWBOOL so_writeinterpolations(MFILE_WRITE fil)
int32_t i;
SECTOR_OBJECTp sop;
so_interp *interp;
SWBOOL saveisshot = false;
int saveisshot = 0;
for (sop = SectorObject, interp = so_interpdata;
sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++)
@ -364,17 +364,17 @@ SWBOOL so_writeinterpolations(MFILE_WRITE fil)
MWRITE(&data->spriteofang,sizeof(data->spriteofang),1,fil);
}
}
return saveisshot;
return !!saveisshot;
}
int LoadSymDataInfo(MFILE_READ fil, void **ptr);
int LoadSymDataInfo(MFILE_READ fil, void** ptr);
SWBOOL so_readinterpolations(MFILE_READ fil)
{
int32_t i;
SECTOR_OBJECTp sop;
so_interp *interp;
SWBOOL saveisshot = false;
int saveisshot = 0;
for (sop = SectorObject, interp = so_interpdata;
sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++)
@ -393,7 +393,7 @@ SWBOOL so_readinterpolations(MFILE_READ fil)
interp->tic = 0;
interp->lasttic = synctics;
}
return saveisshot;
return !!saveisshot;
}
END_SW_NS

View file

@ -560,7 +560,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
if (TEST_GOTPIC(cnt + MIRRORLABEL) || ((unsigned)mirror[cnt].campic < MAXTILES && TEST_GOTPIC(mirror[cnt].campic)))
{
// Do not change any global state here!
bIsWallMirror = (TEST_GOTPIC(cnt + MIRRORLABEL));
bIsWallMirror = !!(TEST_GOTPIC(cnt + MIRRORLABEL));
dist = 0x7fffffff;
if (bIsWallMirror)

View file

@ -34,7 +34,47 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#define OFF 0
#define ON 1
typedef unsigned char SWBOOL;
class SWBOOL
{
bool value;
public:
SWBOOL(bool val) { value = val; }
SWBOOL() = default;
SWBOOL(unsigned char) = delete;
SWBOOL(signed char) = delete;
SWBOOL(char) = delete;
SWBOOL(unsigned short) = delete;
SWBOOL(short) = delete;
SWBOOL(unsigned int) = delete;
SWBOOL(int) = delete;
SWBOOL(double) = delete;
SWBOOL(float) = delete;
SWBOOL(const void *) = delete;
SWBOOL& operator=(bool v) { value = v; return *this; }
SWBOOL& operator=(char v) = delete;
SWBOOL& operator=(signed char v) = delete;
SWBOOL& operator=(unsigned char v) = delete;
SWBOOL& operator=(signed short v) = delete;
SWBOOL& operator=(unsigned short v) = delete;
SWBOOL& operator=(signed int v) = delete;
SWBOOL& operator=(unsigned int v) = delete;
SWBOOL& operator=(float v) = delete;
SWBOOL& operator=(double v) = delete;
SWBOOL& operator=(const void *v) = delete;
operator bool() { return value; }
SWBOOL& operator |=(bool b) { value |= b; return*this; }
SWBOOL& operator|=(char v) = delete;
SWBOOL& operator|=(signed char v) = delete;
SWBOOL& operator|=(unsigned char v) = delete;
SWBOOL& operator|=(signed short v) = delete;
SWBOOL& operator|=(unsigned short v) = delete;
SWBOOL& operator|=(signed int v) = delete;
SWBOOL& operator|=(unsigned int v) = delete;
SWBOOL& operator|=(float v) = delete;
SWBOOL& operator|=(double v) = delete;
SWBOOL& operator|=(const void* v) = delete;
};
/*
===========================

View file

@ -2384,7 +2384,7 @@ void
pUziAction(PANEL_SPRITEp psp)
{
char shooting;
static SWBOOL alternate = false;
static int alternate = 0;
shooting = (psp->PlayerP->input.actions & SB_FIRE) && (psp->PlayerP->KeyPressBits & SB_FIRE);

View file

@ -81,7 +81,7 @@ USER puser[MAX_SW_PLAYERS_REG];
//int16_t gNet.MultiGameType = MULTI_GAME_NONE;
SWBOOL NightVision = false;
extern SWBOOL FinishAnim;
extern int FinishAnim;
// the smaller the number the slower the going
@ -1180,7 +1180,7 @@ FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects,
int32_t xe, int32_t ye, int32_t ze, int16_t secte);
int
DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, SWBOOL skip_targets)
DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, int skip_targets)
{
#define PICK_DIST 40000L
@ -4212,7 +4212,7 @@ PlayerOnLadder(PLAYERp pp)
};
if (Prediction)
return 0;
return false;
neartag(pp->posx, pp->posy, pp->posz, pp->cursectnum, FixedToInt(pp->q16ang),
&neartagsector, &neartagwall, &neartagsprite,

View file

@ -125,7 +125,7 @@ int SetVisHigh(void);
int SetVisNorm(void);
void DoWeapon(void);
void HeadBobStateControl(void);
int DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, SWBOOL skip_targets);
int DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, int skip_targets);
void DoPlayer(void);
void domovethings(void);
void InitAllPlayers(void);

View file

@ -1089,7 +1089,6 @@ DoRipperBeginJumpAttack(short SpriteNum)
SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum];
SPRITEp psp = User[SpriteNum]->tgt_sp;
int CanSeePlayer(short SpriteNum);
short tang;
tang = getangle(psp->x - sp->x, psp->y - sp->y);

View file

@ -1096,7 +1096,6 @@ DoRipper2BeginJumpAttack(short SpriteNum)
SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum];
SPRITEp psp = User[SpriteNum]->tgt_sp;
int CanSeePlayer(short SpriteNum);
short tang;
tang = getangle(psp->x - sp->x, psp->y - sp->y);

View file

@ -53,7 +53,7 @@ typedef struct
SAVE save;
SWBOOL FAF_DebugView = 0;
SWBOOL FAF_DebugView = false;
void COVERupdatesector(int32_t x, int32_t y, int16_t* newsector)
{
@ -282,7 +282,7 @@ FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects,
// early out to regular routine
if ((sects < 0 || !FAF_Sector(sects)) && (secte < 0 || !FAF_Sector(secte)))
{
return cansee(xs,ys,zs,sects,xe,ye,ze,secte);
return !!cansee(xs,ys,zs,sects,xe,ye,ze,secte);
}
// get angle
@ -336,11 +336,11 @@ FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects,
}
else
{
return cansee(xs,ys,zs,sects,xe,ye,ze,secte);
return !!cansee(xs,ys,zs,sects,xe,ye,ze,secte);
}
if (plax_found)
return cansee(hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,newsectnum,xe,ye,ze,secte);
return !!cansee(hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,newsectnum,xe,ye,ze,secte);
return false;
}

View file

@ -73,7 +73,7 @@ extern short Bunny_Count;
extern SWBOOL NewGame;
extern int GodMode;
extern int FinishTimer;
extern SWBOOL FinishAnim;
extern int FinishAnim;
extern int GameVersion;
//extern short Zombies;

View file

@ -1625,7 +1625,7 @@ SWBOOL ComboSwitchTest(short combo_type, short match)
{
short i,nexti;
SPRITEp sp;
SWBOOL state;
int state;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_DEFAULT], i, nexti)
{

View file

@ -78,7 +78,7 @@ void PlaySpriteSound(short spritenum, int attrib_ndx, Voc3D_Flags flags);
void DeleteNoSoundOwner(short spritenum);
void DeleteNoFollowSoundOwner(short spritenum);
inline SWBOOL CacheSound(int num, int type) { return false; }
inline bool CacheSound(int num, int type) { return false; }
void COVER_SetReverb(int amt);
void UnInitSound(void);
void InitFX(void);

View file

@ -104,7 +104,7 @@ void SetSpikeActive(short SpriteNum)
else
short_setinterpolation(&sectp->floorheinum);
InterpSectorSprites(sp->sectnum, ON);
InterpSectorSprites(sp->sectnum, true);
// play activate sound
DoSoundSpotMatch(SP_TAG2(sp), 1, SOUND_OBJECT_TYPE);
@ -132,7 +132,7 @@ void SetSpikeInactive(short SpriteNum)
else
short_stopinterpolation(&sectp->floorheinum);
InterpSectorSprites(sp->sectnum, OFF);
InterpSectorSprites(sp->sectnum, false);
// play activate sound
DoSoundSpotMatch(SP_TAG2(sp), 2, SOUND_OBJECT_TYPE);

View file

@ -91,7 +91,7 @@ void InitWeaponRocket(PLAYERp);
void InitWeaponUzi(PLAYERp);
SWBOOL FAF_Sector(short sectnum);
SWBOOL MoveSkip4, MoveSkip2, MoveSkip8;
int MoveSkip4, MoveSkip2, MoveSkip8;
extern STATE s_CarryFlag[];
extern STATE s_CarryFlagNoDet[];
@ -1128,7 +1128,7 @@ void PreCachePachinko(void);
SWBOOL
ActorSpawn(SPRITEp sp)
{
int ret = true;
bool ret = true;
short SpriteNum = sp - sprite;
switch (sp->picnum)
@ -2329,7 +2329,7 @@ SpriteSetup(void)
sectp->floorz += amt;
u->z_tgt = u->sz;
MoveSpritesWithSector(sp->sectnum, amt, 0); // floor
MoveSpritesWithSector(sp->sectnum, amt, false); // floor
}
// set orig z
@ -2350,7 +2350,7 @@ SpriteSetup(void)
sectp->ceilingz += amt;
u->z_tgt = u->sz;
MoveSpritesWithSector(sp->sectnum, amt, 1); // ceiling
MoveSpritesWithSector(sp->sectnum, amt, true); // ceiling
}
// set orig z

View file

@ -857,7 +857,7 @@ BossHealthMeter(void)
// Frank, good optimization for other levels, but it broke level 20. :(
// I kept this but had to add a fix.
bosswasseen = serpwasseen|sumowasseen|zillawasseen;
bosswasseen = serpwasseen || sumowasseen || zillawasseen;
// Only show the meter when you can see the boss
if ((currentLevel->levelNumber == 20 && (!serpwasseen || !sumowasseen || !zillawasseen)) || !bosswasseen)

View file

@ -109,7 +109,7 @@ void SetVatorActive(short SpriteNum)
else
setinterpolation(&sectp->floorz);
InterpSectorSprites(sp->sectnum, ON);
InterpSectorSprites(sp->sectnum, true);
// play activate sound
DoSoundSpotMatch(SP_TAG2(sp), 1, SOUND_OBJECT_TYPE);
@ -137,7 +137,7 @@ void SetVatorInactive(short SpriteNum)
else
stopinterpolation(&sectp->floorz);
InterpSectorSprites(sp->sectnum, OFF);
InterpSectorSprites(sp->sectnum, false);
// play inactivate sound
DoSoundSpotMatch(SP_TAG2(sp), 2, SOUND_OBJECT_TYPE);
@ -465,13 +465,13 @@ int DoVator(short SpriteNum)
{
lptr = &sectp->ceilingz;
amt = DoVatorMove(SpriteNum, lptr);
MoveSpritesWithSector(sp->sectnum, amt, 1); // ceiling
MoveSpritesWithSector(sp->sectnum, amt, true); // ceiling
}
else
{
lptr = &sectp->floorz;
amt = DoVatorMove(SpriteNum, lptr);
MoveSpritesWithSector(sp->sectnum, amt, 0); // floor
MoveSpritesWithSector(sp->sectnum, amt, false); // floor
}
// EQUAL this entry has finished
@ -626,13 +626,13 @@ int DoVatorAuto(short SpriteNum)
{
lptr = &sectp->ceilingz;
amt = DoVatorMove(SpriteNum, lptr);
MoveSpritesWithSector(sp->sectnum, amt, 1); // ceiling
MoveSpritesWithSector(sp->sectnum, amt, true); // ceiling
}
else
{
lptr = &sectp->floorz;
amt = DoVatorMove(SpriteNum, lptr);
MoveSpritesWithSector(sp->sectnum, amt, 0); // floor
MoveSpritesWithSector(sp->sectnum, amt, false); // floor
}
// EQUAL this entry has finished

View file

@ -5320,7 +5320,7 @@ ActorHealth(short SpriteNum, short amt)
{
SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum];
extern SWBOOL FinishAnim;
extern int FinishAnim;
if (u->ID == TRASHCAN && amt > -75)
{
@ -12675,7 +12675,7 @@ MissileSetPos(short Weapon, ANIMATORp DoWeapon, int dist)
USERp wu = User[Weapon];
int oldvel, oldzvel;
int oldxc, oldyc, oldzc;
char retval = false;
bool retval = false;
// backup values
oldxc = wu->xchange;
@ -12721,7 +12721,7 @@ TestMissileSetPos(short Weapon, ANIMATORp DoWeapon, int dist, int zvel)
USERp wu = User[Weapon];
int oldvel, oldzvel;
int oldxc, oldyc, oldzc;
char retval = false;
bool retval = false;
// backup values
oldxc = wu->xchange;
@ -16113,7 +16113,7 @@ WallSpriteInsideSprite(SPRITEp wsp, SPRITEp sp)
y1 -= mulscale16(day, mid_dist);
y2 = y1 + mulscale16(day, xsiz);
return clipinsideboxline(sp->x, sp->y, x1, y1, x2, y2, ((int) sp->clipdist) << 2);
return !!clipinsideboxline(sp->x, sp->y, x1, y1, x2, y2, ((int) sp->clipdist) << 2);
}