Add modernize-use-bool-literals

This commit is contained in:
Dennis Felsing 2022-02-15 00:12:52 +01:00
parent 984aed2e03
commit 68e4eb21d5
29 changed files with 66 additions and 65 deletions

View file

@ -48,6 +48,7 @@ Checks: >
modernize-replace-disallow-copy-and-assign-macro,
modernize-replace-random-shuffle,
modernize-shrink-to-fit,
modernize-use-bool-literals,
readability-*,
-readability-braces-around-statements,
-readability-convert-member-functions-to-static,

View file

@ -557,7 +557,7 @@ static void aio_thread(void *user)
ASYNCIO *aio = (ASYNCIO *)user;
lock_wait(aio->lock);
while(1)
while(true)
{
struct BUFFERS buffers;
int result_io_error;
@ -1347,7 +1347,7 @@ static int parse_int(int *out, const char **str)
i = **str - '0';
(*str)++;
while(1)
while(true)
{
if(**str < '0' || **str > '9')
{
@ -2727,7 +2727,7 @@ void str_clean_whitespaces(char *str_in)
read++;
/* end of read string is detected in the loop */
while(1)
while(true)
{
/* skip whitespace */
int found_whitespace = 0;
@ -3439,7 +3439,7 @@ int str_utf8_decode(const char **ptr)
int utf8_code_point = 0;
int utf8_bytes_seen = 0;
int utf8_bytes_needed = 0;
while(1)
while(true)
{
unsigned char byte = str_byte_next(ptr);
if(utf8_bytes_needed == 0)
@ -3904,7 +3904,7 @@ int secure_rand_below(int below)
{
unsigned int mask = find_next_power_of_two_minus_one(below);
dbg_assert(below > 0, "below must be positive");
while(1)
while(true)
{
unsigned int n;
secure_random_fill(&n, sizeof(n));
@ -4054,7 +4054,7 @@ int os_version_str(char *version, int length)
*newline = 0;
}
str_format(extra, sizeof(extra), "; %s", buf + offset + 12);
} while(0);
} while(false);
str_format(version, length, "%s %s (%s, %s)%s", u.sysname, u.release, u.machine, u.version, extra);
return 0;

View file

@ -88,7 +88,7 @@ int str_utf8_comp_confusable(const char *str1, const char *str2)
str_utf8_skeleton_begin(&skel1, str1);
str_utf8_skeleton_begin(&skel2, str2);
while(1)
while(true)
{
int ch1 = str_utf8_skeleton_next(&skel1);
int ch2 = str_utf8_skeleton_next(&skel2);

View file

@ -72,7 +72,7 @@ void CGLSLProgram::DetachAllShaders()
{
TWGLuint aShaders[100];
GLsizei ReturnedCount = 0;
while(1)
while(true)
{
glGetAttachedShaders(m_ProgramID, 100, &ReturnedCount, aShaders);

View file

@ -376,7 +376,7 @@ CClient::CClient() :
m_CurrentInput[0] = 0;
m_CurrentInput[1] = 0;
m_LastDummy = 0;
m_LastDummy = false;
mem_zero(&m_aInputs, sizeof(m_aInputs));
@ -2518,7 +2518,7 @@ void CClient::Update()
{
// switch dummy snapshot
int64_t Now = m_GameTime[!g_Config.m_ClDummy].Get(time_get());
while(1)
while(true)
{
CSnapshotStorage::CHolder *pCur = m_aSnapshots[!g_Config.m_ClDummy][SNAP_CURRENT];
int64_t TickStart = (pCur->m_Tick) * time_freq() / 50;
@ -2557,7 +2557,7 @@ void CClient::Update()
Repredict = 1;
}
while(1)
while(true)
{
CSnapshotStorage::CHolder *pCur = m_aSnapshots[g_Config.m_ClDummy][SNAP_CURRENT];
int64_t TickStart = (pCur->m_Tick) * time_freq() / 50;
@ -2979,7 +2979,7 @@ void CClient::Run()
int64_t LastTime = time_get_microseconds();
int64_t LastRenderTime = time_get();
while(1)
while(true)
{
set_new_tick();

View file

@ -1194,7 +1194,7 @@ void CServerBrowser::Update(bool ForceResort)
CServerEntry *pEntry = m_pFirstReqServer;
int Count = 0;
while(1)
while(true)
{
if(!pEntry) // no more entries
break;
@ -1223,7 +1223,7 @@ void CServerBrowser::Update(bool ForceResort)
{
//reset old ones
pEntry = m_pFirstReqServer;
while(1)
while(true)
{
if(!pEntry) // no more entries
break;
@ -1239,7 +1239,7 @@ void CServerBrowser::Update(bool ForceResort)
else if(Count == 0 && m_CurrentMaxRequests == 1) //we reached the limit, just release all left requests. IF a server sends us a packet, a new request will be added automatically, so we can delete all
{
pEntry = m_pFirstReqServer;
while(1)
while(true)
{
if(!pEntry) // no more entries
break;

View file

@ -264,7 +264,7 @@ class CTextRender : public IEngineTextRender
int WordLength(const char *pText)
{
const char *pCursor = pText;
while(1)
while(true)
{
if(*pCursor == 0)
return pCursor - pText;

View file

@ -132,7 +132,7 @@ void CDbConnectionPool::Worker()
// enter fail mode when a sql request fails, skip read request during it and
// write to the backup database until all requests are handled
bool FailMode = false;
while(1)
while(true)
{
if(FailMode && m_NumElem.GetApproximateValue() == 0)
{

View file

@ -159,7 +159,7 @@ int CConsole::ParseArgs(CResult *pResult, const char *pFormat)
pStr = pResult->m_pArgsStart;
while(1)
while(true)
{
if(!Command)
break;
@ -198,7 +198,7 @@ int CConsole::ParseArgs(CResult *pResult, const char *pFormat)
pResult->AddArgument(pStr);
pDst = pStr; // we might have to process escape data
while(1)
while(true)
{
if(pStr[0] == '"')
break;

View file

@ -126,7 +126,7 @@ bool CDataFileReader::Open(class IStorage *pStorage, const char *pFilename, int
sha256_init(&Sha256Ctxt);
unsigned char aBuffer[BUFFER_SIZE];
while(1)
while(true)
{
unsigned Bytes = io_read(File, aBuffer, BUFFER_SIZE);
if(Bytes <= 0)
@ -144,14 +144,14 @@ bool CDataFileReader::Open(class IStorage *pStorage, const char *pFilename, int
if(sizeof(Header) != io_read(File, &Header, sizeof(Header)))
{
dbg_msg("datafile", "couldn't load header");
return 0;
return false;
}
if(Header.m_aID[0] != 'A' || Header.m_aID[1] != 'T' || Header.m_aID[2] != 'A' || Header.m_aID[3] != 'D')
{
if(Header.m_aID[0] != 'D' || Header.m_aID[1] != 'A' || Header.m_aID[2] != 'T' || Header.m_aID[3] != 'A')
{
dbg_msg("datafile", "wrong signature. %x %x %x %x", Header.m_aID[0], Header.m_aID[1], Header.m_aID[2], Header.m_aID[3]);
return 0;
return false;
}
}
@ -161,7 +161,7 @@ bool CDataFileReader::Open(class IStorage *pStorage, const char *pFilename, int
if(Header.m_Version != 3 && Header.m_Version != 4)
{
dbg_msg("datafile", "wrong version. version=%x", Header.m_Version);
return 0;
return false;
}
// read in the rest except the data

View file

@ -152,7 +152,7 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con
else
{
// write map data
while(1)
while(true)
{
unsigned char aChunk[1024 * 64];
int Bytes = io_read(MapFile, &aChunk, sizeof(aChunk));
@ -487,7 +487,7 @@ void CDemoPlayer::ScanFile()
StartPos = io_tell(m_File);
m_Info.m_SeekablePoints = 0;
while(1)
while(true)
{
long CurrentPos = io_tell(m_File);
@ -554,7 +554,7 @@ void CDemoPlayer::DoTick()
if(m_UpdateIntraTimesFunc)
m_UpdateIntraTimesFunc();
while(1)
while(true)
{
if(ReadChunkHeader(&ChunkType, &ChunkSize, &ChunkTick))
{
@ -672,7 +672,7 @@ void CDemoPlayer::DoTick()
void CDemoPlayer::Pause()
{
m_Info.m_Info.m_Paused = 1;
m_Info.m_Info.m_Paused = true;
#if defined(CONF_VIDEORECORDER)
if(IVideo::Current() && g_Config.m_ClVideoPauseWithDemo)
IVideo::Current()->Pause(true);
@ -685,7 +685,7 @@ void CDemoPlayer::Unpause()
{
/*m_Info.start_tick = m_Info.current_tick;
m_Info.start_time = time_get();*/
m_Info.m_Info.m_Paused = 0;
m_Info.m_Info.m_Paused = false;
}
#if defined(CONF_VIDEORECORDER)
if(IVideo::Current() && g_Config.m_ClVideoPauseWithDemo)
@ -991,7 +991,7 @@ int CDemoPlayer::Update(bool RealTime)
int64_t Freq = time_freq();
m_Info.m_CurrentTime += (int64_t)(Deltatime * (double)m_Info.m_Info.m_Speed);
while(1)
while(true)
{
int64_t CurtickStart = (m_Info.m_Info.m_CurrentTick) * Freq / SERVER_TICK_SPEED;

View file

@ -211,7 +211,7 @@ int CHuffman::Decompress(const void *pInput, int InputSize, void *pOutput, int O
CNode *pEof = &m_aNodes[HUFFMAN_EOF_SYMBOL];
CNode *pNode = 0;
while(1)
while(true)
{
// {A} try to load a node now, this will reduce dependency at location {D}
pNode = 0;
@ -246,7 +246,7 @@ int CHuffman::Decompress(const void *pInput, int InputSize, void *pOutput, int O
Bitcount -= HUFFMAN_LUTBITS;
// walk the tree bit by bit
while(1)
while(true)
{
// traverse tree
pNode = &m_aNodes[pNode->m_aLeafs[Bits & 1]];

View file

@ -15,7 +15,7 @@ char *CLineReader::Get()
unsigned LineStart = m_BufferPos;
bool CRLFBreak = false;
while(1)
while(true)
{
if(m_BufferPos >= m_BufferSize)
{

View file

@ -155,7 +155,7 @@ public:
CLineReader LineReader;
LineReader.Init(File);
while(1)
while(true)
{
CMasterInfo Info = {{0}};
const char *pLine = LineReader.Get();

View file

@ -26,7 +26,7 @@ int CNetRecvUnpacker::FetchChunk(CNetChunk *pChunk)
CNetChunkHeader Header;
unsigned char *pEnd = m_Data.m_aChunkData + m_Data.m_DataSize;
while(1)
while(true)
{
unsigned char *pData = m_Data.m_aChunkData;

View file

@ -57,7 +57,7 @@ int CNetClient::ResetErrorString()
int CNetClient::Recv(CNetChunk *pChunk)
{
while(1)
while(true)
{
// check for a chunk
if(m_RecvUnpacker.FetchChunk(pChunk))

View file

@ -68,7 +68,7 @@ void CNetConnection::Init(NETSOCKET Socket, bool BlockCloseMsg)
void CNetConnection::AckChunks(int Ack)
{
while(1)
while(true)
{
CNetChunkResend *pResend = m_Buffer.First();
if(!pResend)

View file

@ -627,7 +627,7 @@ static bool IsDDNetControlMsg(const CNetPacketConstruct *pPacket)
*/
int CNetServer::Recv(CNetChunk *pChunk, SECURITY_TOKEN *pResponseToken)
{
while(1)
while(true)
{
NETADDR Addr;

View file

@ -66,7 +66,7 @@ void *CRingBufferBase::Allocate(int Size)
if(WantedSize > m_Size)
return 0;
while(1)
while(true)
{
// check for space
if(m_pProduce->m_Free)
@ -153,7 +153,7 @@ void *CRingBufferBase::Prev(void *pCurrent)
{
CItem *pItem = ((CItem *)pCurrent) - 1;
while(1)
while(true)
{
pItem = PrevBlock(pItem);
if(pItem == m_pProduce)
@ -167,7 +167,7 @@ void *CRingBufferBase::Next(void *pCurrent)
{
CItem *pItem = ((CItem *)pCurrent) - 1;
while(1)
while(true)
{
pItem = NextBlock(pItem);
if(pItem == m_pProduce)

View file

@ -67,7 +67,7 @@ int ParseUuid(CUuid *pUuid, const char *pBuffer)
return 1;
}
aCopy[8] = aCopy[13] = aCopy[18] = aCopy[23] = 0;
if(0 ||
if(false ||
str_hex_decode(pUuid->m_aData + 0, 4, aCopy + 0) ||
str_hex_decode(pUuid->m_aData + 4, 2, aCopy + 9) ||
str_hex_decode(pUuid->m_aData + 6, 2, aCopy + 14) ||

View file

@ -1344,8 +1344,8 @@ void CGameClient::OnNewSnapshot()
}
else if(Item.m_Type == NETOBJTYPE_GAMEINFO)
{
static bool s_GameOver = 0;
static bool s_GamePaused = 0;
static bool s_GameOver = false;
static bool s_GamePaused = false;
m_Snap.m_pGameInfoObj = (const CNetObj_GameInfo *)pData;
bool CurrentTickGameOver = (bool)(m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_GAMEOVER);
if(!s_GameOver && CurrentTickGameOver)
@ -1813,7 +1813,7 @@ void CGameClient::OnPredict()
// detect mispredictions of other players and make corrections smoother when possible
static vec2 s_aLastPos[MAX_CLIENTS] = {{0, 0}};
static bool s_aLastActive[MAX_CLIENTS] = {0};
static bool s_aLastActive[MAX_CLIENTS] = {false};
if(g_Config.m_ClAntiPingSmooth && Predict() && AntiPingPlayers() && m_NewTick && abs(m_PredictedTick - Client()->PredGameTick(g_Config.m_ClDummy)) <= 1 && abs(Client()->GameTick(g_Config.m_ClDummy) - Client()->PrevGameTick(g_Config.m_ClDummy)) <= 2)
{
@ -2622,7 +2622,7 @@ int CGameClient::SwitchStateTeam()
bool CGameClient::IsLocalCharSuper()
{
if(m_Snap.m_LocalClientID < 0)
return 0;
return false;
return m_aClients[m_Snap.m_LocalClientID].m_Super;
}

View file

@ -369,8 +369,8 @@ void CCharacter::FireWeapon()
ProjStartPos, //Pos
Direction, //Dir
Lifetime, //Span
0, //Freeze
0, //Explosive
false, //Freeze
false, //Explosive
0, //Force
-1 //SoundImpact
);
@ -397,8 +397,8 @@ void CCharacter::FireWeapon()
ProjStartPos, //Pos
vec2(cosf(a), sinf(a)) * Speed, //Dir
(int)(GameWorld()->GameTickSpeed() * Tuning()->m_ShotgunLifetime), //Span
0, //Freeze
0, //Explosive
false, //Freeze
false, //Explosive
0, //Force
-1 //SoundImpact
);
@ -424,7 +424,7 @@ void CCharacter::FireWeapon()
ProjStartPos, //Pos
Direction, //Dir
Lifetime, //Span
0, //Freeze
false, //Freeze
true, //Explosive
0, //Force
SOUND_GRENADE_EXPLODE //SoundImpact
@ -1064,7 +1064,7 @@ CCharacter::CCharacter(CGameWorld *pGameWorld, int ID, CNetObj_Character *pChar,
mem_zero(&m_SavedInput, sizeof(m_SavedInput));
m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput;
m_ProximityRadius = ms_PhysSize;
m_Core.m_LeftWall = 1;
m_Core.m_LeftWall = true;
m_ReloadTimer = 0;
m_NumObjectsHit = 0;
m_LastRefillJumps = false;
@ -1101,8 +1101,8 @@ void CCharacter::ResetPrediction()
m_NumInputs = 0;
m_FreezeTime = 0;
m_FreezeTick = 0;
m_DeepFreeze = 0;
m_LiveFreeze = 0;
m_DeepFreeze = false;
m_LiveFreeze = false;
m_FrozenLastTick = false;
m_Super = false;
for(int w = 0; w < NUM_WEAPONS; w++)

View file

@ -173,7 +173,7 @@ CProjectile::CProjectile(CGameWorld *pGameWorld, int ID, CProjectileData *pProj,
{
m_Owner = -1;
m_Bouncing = 0;
m_Freeze = 0;
m_Freeze = false;
m_Explosive = (pProj->m_Type == WEAPON_GRENADE) && (fabs(1.0f - length(m_Direction)) < 0.015f);
}
m_Type = pProj->m_Type;

View file

@ -484,8 +484,8 @@ void CCharacter::FireWeapon()
ProjStartPos, //Pos
Direction, //Dir
Lifetime, //Span
0, //Freeze
0, //Explosive
false, //Freeze
false, //Explosive
0, //Force
-1 //SoundImpact
);
@ -541,7 +541,7 @@ void CCharacter::FireWeapon()
ProjStartPos, //Pos
Direction, //Dir
Lifetime, //Span
0, //Freeze
false, //Freeze
true, //Explosive
0, //Force
SOUND_GRENADE_EXPLODE //SoundImpact

View file

@ -3872,7 +3872,7 @@ void CGameContext::Whisper(int ClientID, char *pStr)
pName = pStr;
char *pDst = pStr; // we might have to process escape data
while(1)
while(true)
{
if(pStr[0] == '"')
{
@ -3911,7 +3911,7 @@ void CGameContext::Whisper(int ClientID, char *pStr)
else
{
pName = pStr;
while(1)
while(true)
{
if(pStr[0] == 0)
{

View file

@ -106,7 +106,7 @@ void CPlayer::Reset()
m_ShowOthers = g_Config.m_SvShowOthersDefault;
m_ShowAll = g_Config.m_SvShowAllDefault;
m_ShowDistance = vec2(1200, 800);
m_SpecTeam = 0;
m_SpecTeam = false;
m_NinjaJetpack = false;
m_Paused = PAUSE_NONE;

View file

@ -53,7 +53,7 @@ void Run(unsigned short Port, NETADDR Dest)
MMSGS m;
net_init_mmsgs(&m);
while(1)
while(true)
{
static int Lastcfg = 0;
int n = ((time_get() / time_freq()) / m_ConfigInterval) % m_ConfigNumpingconfs;
@ -64,7 +64,7 @@ void Run(unsigned short Port, NETADDR Dest)
Lastcfg = n;
// handle incoming packets
while(1)
while(true)
{
// fetch data
int DataTrash = 0;
@ -142,7 +142,7 @@ void Run(unsigned short Port, NETADDR Dest)
{*/
CPacket *p = 0;
CPacket *pNext = m_pFirst;
while(1)
while(true)
{
p = pNext;
if(!p)

View file

@ -116,7 +116,7 @@ static int Run()
if(!pNet->Open(BindAddr, 0, 0, 0, 0))
return 0;
while(1)
while(true)
{
CNetChunk p;
pNet->Update();

View file

@ -17,7 +17,7 @@ void Run(NETADDR Dest)
Socket = net_udp_create(BindAddr);
}
while(1)
while(true)
{
unsigned char aData[1024];
int Size = 0;