mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 17:48:19 +00:00
Add readability-container-size-empty
This commit is contained in:
parent
bcb50c1b29
commit
7aac8b5386
|
@ -40,6 +40,7 @@ Checks: >
|
|||
readability-const-return-type,
|
||||
readability-container-data-pointer,
|
||||
readability-qualified-auto,
|
||||
readability-container-size-empty,
|
||||
readability-delete-null-pointer,
|
||||
performance-*,
|
||||
-performance-no-int-to-ptr,
|
||||
|
|
|
@ -2706,7 +2706,7 @@ void CClient::Update()
|
|||
|
||||
if(State() == IClient::STATE_ONLINE)
|
||||
{
|
||||
if(m_EditJobs.size() > 0)
|
||||
if(!m_EditJobs.empty())
|
||||
{
|
||||
std::shared_ptr<CDemoEdit> e = m_EditJobs.front();
|
||||
if(e->Status() == IJob::STATE_DONE)
|
||||
|
|
|
@ -1275,7 +1275,7 @@ void CGraphics_Threaded::QuadContainerUpload(int ContainerIndex)
|
|||
if(IsQuadContainerBufferingEnabled())
|
||||
{
|
||||
SQuadContainer &Container = m_QuadContainers[ContainerIndex];
|
||||
if(Container.m_Quads.size() > 0)
|
||||
if(!Container.m_Quads.empty())
|
||||
{
|
||||
if(Container.m_QuadBufferObjectIndex == -1)
|
||||
{
|
||||
|
|
|
@ -977,7 +977,7 @@ public:
|
|||
|
||||
AppendTextContainer(pCursor, ContainerIndex, pText, Length);
|
||||
|
||||
if(TextContainer.m_StringInfo.m_CharacterQuads.size() == 0 && TextContainer.m_StringInfo.m_SelectionQuadContainerIndex == -1 && IsRendered)
|
||||
if(TextContainer.m_StringInfo.m_CharacterQuads.empty() && TextContainer.m_StringInfo.m_SelectionQuadContainerIndex == -1 && IsRendered)
|
||||
{
|
||||
FreeTextContainer(ContainerIndex);
|
||||
return -1;
|
||||
|
@ -1402,7 +1402,7 @@ public:
|
|||
GotNewLineLast = 0;
|
||||
}
|
||||
|
||||
if(TextContainer.m_StringInfo.m_CharacterQuads.size() != 0 && IsRendered)
|
||||
if(!TextContainer.m_StringInfo.m_CharacterQuads.empty() && IsRendered)
|
||||
{
|
||||
TextContainer.m_StringInfo.m_QuadNum = TextContainer.m_StringInfo.m_CharacterQuads.size();
|
||||
// setup the buffers
|
||||
|
|
|
@ -394,7 +394,7 @@ void mem_copy_special(void *pDest, void *pSource, size_t Size, size_t Count, siz
|
|||
CMapLayers::~CMapLayers()
|
||||
{
|
||||
//clear everything and destroy all buffers
|
||||
if(m_TileLayerVisuals.size() != 0)
|
||||
if(!m_TileLayerVisuals.empty())
|
||||
{
|
||||
int s = m_TileLayerVisuals.size();
|
||||
for(int i = 0; i < s; ++i)
|
||||
|
@ -402,7 +402,7 @@ CMapLayers::~CMapLayers()
|
|||
delete m_TileLayerVisuals[i];
|
||||
}
|
||||
}
|
||||
if(m_QuadLayerVisuals.size() != 0)
|
||||
if(!m_QuadLayerVisuals.empty())
|
||||
{
|
||||
int s = m_QuadLayerVisuals.size();
|
||||
for(int i = 0; i < s; ++i)
|
||||
|
@ -417,7 +417,7 @@ void CMapLayers::OnMapLoad()
|
|||
if(!Graphics()->IsTileBufferingEnabled() && !Graphics()->IsQuadBufferingEnabled())
|
||||
return;
|
||||
//clear everything and destroy all buffers
|
||||
if(m_TileLayerVisuals.size() != 0)
|
||||
if(!m_TileLayerVisuals.empty())
|
||||
{
|
||||
int s = m_TileLayerVisuals.size();
|
||||
for(int i = 0; i < s; ++i)
|
||||
|
@ -427,7 +427,7 @@ void CMapLayers::OnMapLoad()
|
|||
}
|
||||
m_TileLayerVisuals.clear();
|
||||
}
|
||||
if(m_QuadLayerVisuals.size() != 0)
|
||||
if(!m_QuadLayerVisuals.empty())
|
||||
{
|
||||
int s = m_QuadLayerVisuals.size();
|
||||
for(int i = 0; i < s; ++i)
|
||||
|
@ -823,8 +823,8 @@ void CMapLayers::OnMapLoad()
|
|||
tmpTileTexCoords.insert(tmpTileTexCoords.end(), tmpBorderRightTilesTexCoords.begin(), tmpBorderRightTilesTexCoords.end());
|
||||
|
||||
//setup params
|
||||
float *pTmpTiles = (tmpTiles.size() == 0) ? NULL : (float *)&tmpTiles[0];
|
||||
unsigned char *pTmpTileTexCoords = (tmpTileTexCoords.size() == 0) ? NULL : (unsigned char *)&tmpTileTexCoords[0];
|
||||
float *pTmpTiles = (tmpTiles.empty()) ? NULL : (float *)&tmpTiles[0];
|
||||
unsigned char *pTmpTileTexCoords = (tmpTileTexCoords.empty()) ? NULL : (unsigned char *)&tmpTileTexCoords[0];
|
||||
|
||||
Visuals.m_BufferContainerIndex = -1;
|
||||
size_t UploadDataSize = tmpTileTexCoords.size() * sizeof(SGraphicTileTexureCoords) + tmpTiles.size() * sizeof(SGraphicTile);
|
||||
|
|
|
@ -389,7 +389,7 @@ void CMenuBackground::ChangePosition(int PositionNumber)
|
|||
|
||||
std::vector<CTheme> &CMenuBackground::GetThemes()
|
||||
{
|
||||
if(m_lThemes.size() == 0) // not loaded yet
|
||||
if(m_lThemes.empty()) // not loaded yet
|
||||
{
|
||||
// when adding more here, make sure to change the value of PREDEFINED_THEMES_COUNT too
|
||||
m_lThemes.push_back(CTheme("", true, true)); // no theme
|
||||
|
|
|
@ -17,7 +17,7 @@ void CUIElement::Init(CUI *pUI, int RequestedRectCount)
|
|||
|
||||
void CUIElement::InitRects(int RequestedRectCount)
|
||||
{
|
||||
dbg_assert(m_UIRects.size() == 0, "UI rects can only be initialized once, create another ui element instead.");
|
||||
dbg_assert(m_UIRects.empty(), "UI rects can only be initialized once, create another ui element instead.");
|
||||
m_UIRects.resize(RequestedRectCount);
|
||||
}
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ public:
|
|||
|
||||
bool AreRectsInit()
|
||||
{
|
||||
return m_UIRects.size() != 0;
|
||||
return !m_UIRects.empty();
|
||||
}
|
||||
|
||||
void InitRects(int RequestedRectCount);
|
||||
|
|
|
@ -299,7 +299,7 @@ void CCharacterCore::Tick(bool UseInput)
|
|||
m_HookState = HOOK_RETRACT_START;
|
||||
}
|
||||
|
||||
if(GoingThroughTele && m_pWorld && m_pTeleOuts && m_pTeleOuts->size() && (*m_pTeleOuts)[teleNr - 1].size())
|
||||
if(GoingThroughTele && m_pWorld && m_pTeleOuts && !m_pTeleOuts->empty() && !(*m_pTeleOuts)[teleNr - 1].empty())
|
||||
{
|
||||
m_TriggeredEvents = 0;
|
||||
m_HookedPlayer = -1;
|
||||
|
|
|
@ -283,7 +283,7 @@ void CGameContext::ConToTeleporter(IConsole::IResult *pResult, void *pUserData)
|
|||
unsigned int TeleTo = pResult->GetInteger(0);
|
||||
CGameControllerDDRace *pGameControllerDDRace = (CGameControllerDDRace *)pSelf->m_pController;
|
||||
|
||||
if(pGameControllerDDRace->m_TeleOuts[TeleTo - 1].size())
|
||||
if(!pGameControllerDDRace->m_TeleOuts[TeleTo - 1].empty())
|
||||
{
|
||||
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
||||
if(pChr)
|
||||
|
@ -304,7 +304,7 @@ void CGameContext::ConToCheckTeleporter(IConsole::IResult *pResult, void *pUserD
|
|||
unsigned int TeleTo = pResult->GetInteger(0);
|
||||
CGameControllerDDRace *pGameControllerDDRace = (CGameControllerDDRace *)pSelf->m_pController;
|
||||
|
||||
if(pGameControllerDDRace->m_TeleCheckOuts[TeleTo - 1].size())
|
||||
if(!pGameControllerDDRace->m_TeleCheckOuts[TeleTo - 1].empty())
|
||||
{
|
||||
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
||||
if(pChr)
|
||||
|
|
|
@ -1901,7 +1901,7 @@ void CCharacter::HandleTiles(int Index)
|
|||
}
|
||||
|
||||
int z = GameServer()->Collision()->IsTeleport(MapIndex);
|
||||
if(!g_Config.m_SvOldTeleportHook && !g_Config.m_SvOldTeleportWeapons && z && (*m_pTeleOuts)[z - 1].size())
|
||||
if(!g_Config.m_SvOldTeleportHook && !g_Config.m_SvOldTeleportWeapons && z && !(*m_pTeleOuts)[z - 1].empty())
|
||||
{
|
||||
if(m_Super)
|
||||
return;
|
||||
|
@ -1916,7 +1916,7 @@ void CCharacter::HandleTiles(int Index)
|
|||
return;
|
||||
}
|
||||
int evilz = GameServer()->Collision()->IsEvilTeleport(MapIndex);
|
||||
if(evilz && (*m_pTeleOuts)[evilz - 1].size())
|
||||
if(evilz && !(*m_pTeleOuts)[evilz - 1].empty())
|
||||
{
|
||||
if(m_Super)
|
||||
return;
|
||||
|
@ -1945,7 +1945,7 @@ void CCharacter::HandleTiles(int Index)
|
|||
// first check if there is a TeleCheckOut for the current recorded checkpoint, if not check previous checkpoints
|
||||
for(int k = m_TeleCheckpoint - 1; k >= 0; k--)
|
||||
{
|
||||
if((*m_pTeleCheckOuts)[k].size())
|
||||
if(!(*m_pTeleCheckOuts)[k].empty())
|
||||
{
|
||||
int TeleOut = m_Core.m_pWorld->RandomOr0((*m_pTeleCheckOuts)[k].size());
|
||||
m_Core.m_Pos = (*m_pTeleCheckOuts)[k][TeleOut];
|
||||
|
@ -1982,7 +1982,7 @@ void CCharacter::HandleTiles(int Index)
|
|||
// first check if there is a TeleCheckOut for the current recorded checkpoint, if not check previous checkpoints
|
||||
for(int k = m_TeleCheckpoint - 1; k >= 0; k--)
|
||||
{
|
||||
if((*m_pTeleCheckOuts)[k].size())
|
||||
if(!(*m_pTeleCheckOuts)[k].empty())
|
||||
{
|
||||
int TeleOut = m_Core.m_pWorld->RandomOr0((*m_pTeleCheckOuts)[k].size());
|
||||
m_Core.m_Pos = (*m_pTeleCheckOuts)[k][TeleOut];
|
||||
|
|
|
@ -129,7 +129,7 @@ void CLaser::DoBounce()
|
|||
m_Energy -= distance(m_From, m_Pos) + GameServer()->TuningList()[m_TuneZone].m_LaserBounceCost;
|
||||
|
||||
CGameControllerDDRace *pControllerDDRace = (CGameControllerDDRace *)GameServer()->m_pController;
|
||||
if(Res == TILE_TELEINWEAPON && pControllerDDRace->m_TeleOuts[z - 1].size())
|
||||
if(Res == TILE_TELEINWEAPON && !pControllerDDRace->m_TeleOuts[z - 1].empty())
|
||||
{
|
||||
int TeleOut = GameServer()->m_World.m_Core.RandomOr0(pControllerDDRace->m_TeleOuts[z - 1].size());
|
||||
m_TelePos = pControllerDDRace->m_TeleOuts[z - 1][TeleOut];
|
||||
|
|
|
@ -273,7 +273,7 @@ void CProjectile::Tick()
|
|||
else
|
||||
z = GameServer()->Collision()->IsTeleportWeapon(x);
|
||||
CGameControllerDDRace *pControllerDDRace = (CGameControllerDDRace *)GameServer()->m_pController;
|
||||
if(z && pControllerDDRace->m_TeleOuts[z - 1].size())
|
||||
if(z && !pControllerDDRace->m_TeleOuts[z - 1].empty())
|
||||
{
|
||||
int TeleOut = GameServer()->m_World.m_Core.RandomOr0(pControllerDDRace->m_TeleOuts[z - 1].size());
|
||||
m_Pos = pControllerDDRace->m_TeleOuts[z - 1][TeleOut];
|
||||
|
|
Loading…
Reference in a new issue