Declare variables as const when possible

According to cppcheck's `constVariable` error:

```
src\engine\client\backend\opengl\opengl_sl.cpp:74:43: style: Variable 'Define' can be declared as reference to const [constVariable]
  for(CGLSLCompiler::SGLSLCompilerDefine &Define : pCompiler->m_vDefines)
                                          ^

src\engine\client\backend\vulkan\backend_vulkan.cpp:2149:12: style: Variable 'GraphicThreadCommandBuffer' can be declared as reference to const [constVariable]
     auto &GraphicThreadCommandBuffer = m_vvThreadDrawCommandBuffers[i + 1][m_CurImageIndex];
           ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3192:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
  auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
        ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3200:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
   auto &DescrSet = m_vTextures[State.m_Texture].m_VKStandard3DTexturedDescrSet;
         ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3810:13: style: Variable 'Mode' can be declared as reference to const [constVariable]
  for(auto &Mode : vPresentModeList)
            ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:3818:13: style: Variable 'Mode' can be declared as reference to const [constVariable]
  for(auto &Mode : vPresentModeList)
            ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6511:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
   auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
         ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6555:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
   auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_VKStandard3DTexturedDescrSet;
         ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6660:9: style: Variable 'MemBlock' can be declared as reference to const [constVariable]
  auto &MemBlock = m_vBufferObjects[BufferIndex].m_BufferObject.m_Mem;
        ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6799:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
  auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
        ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6808:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
   auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
         ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6902:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
  auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
        ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6907:9: style: Variable 'TextTextureDescr' can be declared as reference to const [constVariable]
  auto &TextTextureDescr = m_vTextures[pCommand->m_TextTextureIndex].m_VKTextDescrSet;
        ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6961:9: style: Variable 'BufferObject' can be declared as reference to const [constVariable]
  auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
        ^
src\engine\client\backend\vulkan\backend_vulkan.cpp:6970:10: style: Variable 'DescrSet' can be declared as reference to const [constVariable]
   auto &DescrSet = m_vTextures[State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
         ^

src\game\client\components\hud.cpp:178:8: style: Variable 'aFlagCarrier' can be declared as const array [constVariable]
   int aFlagCarrier[2] = {
       ^
src\game\client\components\hud.cpp:519:16: style: Variable 's_aTextWidth' can be declared as const array [constVariable]
  static float s_aTextWidth[5] = {s_TextWidth0, s_TextWidth00, s_TextWidth000, s_TextWidth0000, s_TextWidth00000};
               ^

src\game\client\components\killmessages.cpp:305:30: style: Variable 'Client' can be declared as reference to const [constVariable]
   CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_KillerID];
                             ^
src\game\client\components\killmessages.cpp:314:30: style: Variable 'Client' can be declared as reference to const [constVariable]
   CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_VictimID];
                             ^

src\game\client\components\menus_ingame.cpp:243:12: style: Variable 'pInfoByName' can be declared as reference to const [constVariable]
 for(auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
           ^
src\game\client\components\menus_ingame.cpp:530:12: style: Variable 'pInfoByName' can be declared as reference to const [constVariable]
 for(auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
           ^

src\game\client\components\players.cpp:767:44: style: Variable 'CharacterInfo' can be declared as reference to const [constVariable]
  CGameClient::CSnapState::CCharacterInfo &CharacterInfo = m_pClient->m_Snap.m_aCharacters[i];
                                           ^

src\game\client\components\spectator.cpp:122:27: style: Variable 'Snap' can be declared as reference to const [constVariable]
 CGameClient::CSnapState &Snap = pSelf->m_pClient->m_Snap;
                          ^
src\game\client\components\spectator.cpp:221:12: style: Variable 'pInfo' can be declared as reference to const [constVariable]
 for(auto &pInfo : m_pClient->m_Snap.m_apInfoByDDTeamName)
           ^

src\game\client\gameclient.cpp:2220:15: style: Variable 'OwnClientData' can be declared as reference to const [constVariable]
 CClientData &OwnClientData = m_aClients[ownID];
              ^
src\game\client\gameclient.cpp:2227:16: style: Variable 'cData' can be declared as reference to const [constVariable]
  CClientData &cData = m_aClients[i];
               ^

src\game\client\prediction\entities\character.cpp:397:11: style: Variable 'aSpreading' can be declared as const array [constVariable]
    float aSpreading[] = {-0.185f, -0.070f, 0, 0.070f, 0.185f};
          ^

src\game\client\prediction\entities\laser.cpp:53:9: style: Variable 'HitPos' can be declared as reference to const [constVariable]
  vec2 &HitPos = pHit->Core()->m_Pos;
        ^

src\game\editor\auto_map.cpp:507:18: style: Variable 'Index' can be declared as reference to const [constVariable]
       for(auto &Index : pRule->m_vIndexList)
                 ^
src\game\editor\auto_map.cpp:518:18: style: Variable 'Index' can be declared as reference to const [constVariable]
       for(auto &Index : pRule->m_vIndexList)
                 ^

src\game\editor\editor.cpp:118:12: style: Variable 'Item' can be declared as reference to const [constVariable]
 for(auto &Item : vList)
           ^
src\game\editor\editor.cpp:2983:11: style: Variable 'aAspects' can be declared as const array [constVariable]
    float aAspects[] = {4.0f / 3.0f, 16.0f / 10.0f, 5.0f / 4.0f, 16.0f / 9.0f};
          ^
src\game\editor\editor.cpp:3141:15: style: Variable 's_aShift' can be declared as const array [constVariable]
   static int s_aShift[] = {24, 16, 8, 0};
              ^

src\engine\server\server.cpp:2807:14: style: Variable 'Client' can be declared as reference to const [constVariable]
   for(auto &Client : m_aClients)
             ^

src\engine\server\sql_string_helpers.cpp:51:6: style: Variable 'aTimes' can be declared as const array [constVariable]
 int aTimes[7] =
     ^

src\test\secure_random.cpp:24:6: style: Variable 'BOUNDS' can be declared as const array [constVariable]
 int BOUNDS[] = {2, 3, 4, 5, 10, 100, 127, 128, 129};
     ^
```
This commit is contained in:
Robert Müller 2022-11-13 16:29:13 +01:00
parent aa321cd887
commit faa9f27808
15 changed files with 38 additions and 44 deletions

View file

@ -71,7 +71,7 @@ bool CGLSL::LoadShader(CGLSLCompiler *pCompiler, IStorage *pStorage, const char
}
}
for(CGLSLCompiler::SGLSLCompilerDefine &Define : pCompiler->m_vDefines)
for(const CGLSLCompiler::SGLSLCompilerDefine &Define : pCompiler->m_vDefines)
{
vLines.push_back(std::string("#define ") + Define.m_DefineName + std::string(" ") + Define.m_DefineValue + std::string("\r\n"));
}

View file

@ -2146,7 +2146,7 @@ protected:
{
if(m_vvUsedThreadDrawCommandBuffer[i + 1][m_CurImageIndex])
{
auto &GraphicThreadCommandBuffer = m_vvThreadDrawCommandBuffers[i + 1][m_CurImageIndex];
const auto &GraphicThreadCommandBuffer = m_vvThreadDrawCommandBuffers[i + 1][m_CurImageIndex];
m_vHelperThreadDrawCommandBuffers[ThreadedCommandsUsedCount++] = GraphicThreadCommandBuffer;
m_vvUsedThreadDrawCommandBuffer[i + 1][m_CurImageIndex] = false;
@ -3189,7 +3189,7 @@ protected:
void RenderTileLayer_FillExecuteBuffer(SRenderCommandExecuteBuffer &ExecBuffer, size_t DrawCalls, const CCommandBuffer::SState &State, size_t BufferContainerIndex)
{
size_t BufferObjectIndex = (size_t)m_vBufferContainers[BufferContainerIndex].m_BufferObjectIndex;
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
const auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
ExecBuffer.m_Buffer = BufferObject.m_CurBuffer;
ExecBuffer.m_BufferOff = BufferObject.m_CurBufferOffset;
@ -3197,8 +3197,7 @@ protected:
bool IsTextured = GetIsTextured(State);
if(IsTextured)
{
auto &DescrSet = m_vTextures[State.m_Texture].m_VKStandard3DTexturedDescrSet;
ExecBuffer.m_aDescriptors[0] = DescrSet;
ExecBuffer.m_aDescriptors[0] = m_vTextures[State.m_Texture].m_VKStandard3DTexturedDescrSet;
}
ExecBuffer.m_IndexBuffer = m_RenderIndexBuffer;
@ -3807,7 +3806,7 @@ public:
}
VKIOMode = g_Config.m_GfxVsync ? VK_PRESENT_MODE_FIFO_KHR : VK_PRESENT_MODE_IMMEDIATE_KHR;
for(auto &Mode : vPresentModeList)
for(const auto &Mode : vPresentModeList)
{
if(Mode == VKIOMode)
return true;
@ -3815,7 +3814,7 @@ public:
dbg_msg("vulkan", "warning: requested presentation mode was not available. falling back to mailbox / fifo relaxed.");
VKIOMode = g_Config.m_GfxVsync ? VK_PRESENT_MODE_FIFO_RELAXED_KHR : VK_PRESENT_MODE_MAILBOX_KHR;
for(auto &Mode : vPresentModeList)
for(const auto &Mode : vPresentModeList)
{
if(Mode == VKIOMode)
return true;
@ -6508,8 +6507,7 @@ public:
if(IsTextured)
{
size_t AddressModeIndex = GetAddressModeIndex(pCommand->m_State);
auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
ExecBuffer.m_aDescriptors[0] = DescrSet;
ExecBuffer.m_aDescriptors[0] = m_vTextures[pCommand->m_State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
}
ExecBuffer.m_IndexBuffer = m_IndexBuffer;
@ -6552,8 +6550,7 @@ public:
bool IsTextured = GetIsTextured(pCommand->m_State);
if(IsTextured)
{
auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_VKStandard3DTexturedDescrSet;
ExecBuffer.m_aDescriptors[0] = DescrSet;
ExecBuffer.m_aDescriptors[0] = m_vTextures[pCommand->m_State.m_Texture].m_VKStandard3DTexturedDescrSet;
}
ExecBuffer.m_IndexBuffer = m_IndexBuffer;
@ -6657,7 +6654,7 @@ public:
auto StagingBuffer = GetStagingBuffer(pUploadData, DataSize);
auto &MemBlock = m_vBufferObjects[BufferIndex].m_BufferObject.m_Mem;
const auto &MemBlock = m_vBufferObjects[BufferIndex].m_BufferObject.m_Mem;
VkBuffer VertexBuffer = MemBlock.m_Buffer;
MemoryBarrier(VertexBuffer, Offset + MemBlock.m_HeapData.m_OffsetToAlign, DataSize, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT, true);
CopyBuffer(StagingBuffer.m_Buffer, VertexBuffer, StagingBuffer.m_HeapData.m_OffsetToAlign, Offset + MemBlock.m_HeapData.m_OffsetToAlign, DataSize);
@ -6796,7 +6793,7 @@ public:
{
size_t BufferContainerIndex = (size_t)pCommand->m_BufferContainerIndex;
size_t BufferObjectIndex = (size_t)m_vBufferContainers[BufferContainerIndex].m_BufferObjectIndex;
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
const auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
ExecBuffer.m_Buffer = BufferObject.m_CurBuffer;
ExecBuffer.m_BufferOff = BufferObject.m_CurBufferOffset;
@ -6805,8 +6802,7 @@ public:
if(IsTextured)
{
size_t AddressModeIndex = GetAddressModeIndex(pCommand->m_State);
auto &DescrSet = m_vTextures[pCommand->m_State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
ExecBuffer.m_aDescriptors[0] = DescrSet;
ExecBuffer.m_aDescriptors[0] = m_vTextures[pCommand->m_State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
}
ExecBuffer.m_IndexBuffer = m_RenderIndexBuffer;
@ -6899,13 +6895,12 @@ public:
{
size_t BufferContainerIndex = (size_t)pCommand->m_BufferContainerIndex;
size_t BufferObjectIndex = (size_t)m_vBufferContainers[BufferContainerIndex].m_BufferObjectIndex;
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
const auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
ExecBuffer.m_Buffer = BufferObject.m_CurBuffer;
ExecBuffer.m_BufferOff = BufferObject.m_CurBufferOffset;
auto &TextTextureDescr = m_vTextures[pCommand->m_TextTextureIndex].m_VKTextDescrSet;
ExecBuffer.m_aDescriptors[0] = TextTextureDescr;
ExecBuffer.m_aDescriptors[0] = m_vTextures[pCommand->m_TextTextureIndex].m_VKTextDescrSet;
ExecBuffer.m_IndexBuffer = m_RenderIndexBuffer;
@ -6958,7 +6953,7 @@ public:
void BufferContainer_FillExecuteBuffer(SRenderCommandExecuteBuffer &ExecBuffer, const CCommandBuffer::SState &State, size_t BufferContainerIndex, size_t DrawCalls)
{
size_t BufferObjectIndex = (size_t)m_vBufferContainers[BufferContainerIndex].m_BufferObjectIndex;
auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
const auto &BufferObject = m_vBufferObjects[BufferObjectIndex];
ExecBuffer.m_Buffer = BufferObject.m_CurBuffer;
ExecBuffer.m_BufferOff = BufferObject.m_CurBufferOffset;
@ -6967,8 +6962,7 @@ public:
if(IsTextured)
{
size_t AddressModeIndex = GetAddressModeIndex(State);
auto &DescrSet = m_vTextures[State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
ExecBuffer.m_aDescriptors[0] = DescrSet;
ExecBuffer.m_aDescriptors[0] = m_vTextures[State.m_Texture].m_aVKStandardTexturedDescrSets[AddressModeIndex];
}
ExecBuffer.m_IndexBuffer = m_RenderIndexBuffer;

View file

@ -2809,7 +2809,7 @@ int CServer::Run()
NonActive = true;
for(auto &Client : m_aClients)
for(const auto &Client : m_aClients)
{
if(Client.m_State != CClient::STATE_EMPTY)
{

View file

@ -48,7 +48,7 @@ void sqlstr::AgoTimeToString(int AgoTime, char *pAgoString, int Size)
}
char aBuf[20];
int aTimes[7] =
const int aTimes[7] =
{
60 * 60 * 24 * 365,
60 * 60 * 24 * 30,
@ -57,7 +57,7 @@ void sqlstr::AgoTimeToString(int AgoTime, char *pAgoString, int Size)
60 * 60,
60,
1};
char aaNames[7][6] =
const char aaNames[7][6] =
{
"year",
"month",

View file

@ -175,7 +175,7 @@ void CHud::RenderScoreHud()
bool aRecreateTeamScore[2] = {str_comp(aScoreTeam[0], m_aScoreInfo[0].m_aScoreText) != 0, str_comp(aScoreTeam[1], m_aScoreInfo[1].m_aScoreText) != 0};
int aFlagCarrier[2] = {
const int aFlagCarrier[2] = {
m_pClient->m_Snap.m_pGameDataObj->m_FlagCarrierRed,
m_pClient->m_Snap.m_pGameDataObj->m_FlagCarrierBlue};
@ -516,7 +516,7 @@ void CHud::RenderTextInfo()
static float s_TextWidth000 = TextRender()->TextWidth(0, 12.f, "000", -1, -1.0f);
static float s_TextWidth0000 = TextRender()->TextWidth(0, 12.f, "0000", -1, -1.0f);
static float s_TextWidth00000 = TextRender()->TextWidth(0, 12.f, "00000", -1, -1.0f);
static float s_aTextWidth[5] = {s_TextWidth0, s_TextWidth00, s_TextWidth000, s_TextWidth0000, s_TextWidth00000};
static const float s_aTextWidth[5] = {s_TextWidth0, s_TextWidth00, s_TextWidth000, s_TextWidth0000, s_TextWidth00000};
int DigitIndex = GetDigitsIndex(FrameTime, 4);
//TextRender()->Text(0, m_Width-10-TextRender()->TextWidth(0,12,Buf,-1,-1.0f), 5, 12, Buf, -1.0f);

View file

@ -302,7 +302,7 @@ void CKillMessages::RefindSkins()
if(m_aKillmsgs[r].m_KillerID >= 0)
{
CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_KillerID];
const CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_KillerID];
if(Client.m_aSkinName[0] != '\0')
m_aKillmsgs[r].m_KillerRenderInfo = Client.m_RenderInfo;
else
@ -311,7 +311,7 @@ void CKillMessages::RefindSkins()
if(m_aKillmsgs[r].m_VictimID >= 0)
{
CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_VictimID];
const CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_VictimID];
if(Client.m_aSkinName[0] != '\0')
m_aKillmsgs[r].m_VictimRenderInfo = Client.m_RenderInfo;
else

View file

@ -240,7 +240,7 @@ void CMenus::RenderPlayers(CUIRect MainView)
int TotalPlayers = 0;
for(auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
for(const auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
{
if(!pInfoByName)
continue;
@ -527,7 +527,7 @@ bool CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators)
int NumOptions = 0;
int Selected = 0;
static int aPlayerIDs[MAX_CLIENTS];
for(auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
for(const auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
{
if(!pInfoByName)
continue;

View file

@ -764,7 +764,7 @@ void CPlayers::OnRender()
if(m_pClient->m_aClients[i].m_LiveFrozen)
m_aRenderInfo[i].m_TeeRenderFlags |= TEE_EFFECT_FROZEN;
CGameClient::CSnapState::CCharacterInfo &CharacterInfo = m_pClient->m_Snap.m_aCharacters[i];
const CGameClient::CSnapState::CCharacterInfo &CharacterInfo = m_pClient->m_Snap.m_aCharacters[i];
if((CharacterInfo.m_Cur.m_Weapon == WEAPON_NINJA || (CharacterInfo.m_HasExtendedData && CharacterInfo.m_ExtendedData.m_FreezeEnd != 0)) && g_Config.m_ClShowNinja)
{
// change the skin for the player to the ninja

View file

@ -119,7 +119,7 @@ void CSpectator::ConSpectateClosest(IConsole::IResult *pResult, void *pUserData)
if(!pSelf->CanChangeSpectator())
return;
CGameClient::CSnapState &Snap = pSelf->m_pClient->m_Snap;
const CGameClient::CSnapState &Snap = pSelf->m_pClient->m_Snap;
int SpectatorID = Snap.m_SpecInfo.m_SpectatorID;
int NewSpectatorID = -1;
@ -218,7 +218,7 @@ void CSpectator::OnRender()
float BoxMove = -10.0f;
float BoxOffset = 0.0f;
for(auto &pInfo : m_pClient->m_Snap.m_apInfoByDDTeamName)
for(const auto &pInfo : m_pClient->m_Snap.m_apInfoByDDTeamName)
{
if(!pInfo || pInfo->m_Team == TEAM_SPECTATORS)
continue;

View file

@ -2217,14 +2217,14 @@ int CGameClient::IntersectCharacter(vec2 HookPos, vec2 NewPos, vec2 &NewPos2, in
float Distance = 0.0f;
int ClosestID = -1;
CClientData &OwnClientData = m_aClients[ownID];
const CClientData &OwnClientData = m_aClients[ownID];
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(i == ownID)
continue;
CClientData &cData = m_aClients[i];
const CClientData &cData = m_aClients[i];
if(!cData.m_Active)
continue;

View file

@ -394,7 +394,7 @@ void CCharacter::FireWeapon()
int ShotSpread = 2;
for(int i = -ShotSpread; i <= ShotSpread; ++i)
{
float aSpreading[] = {-0.185f, -0.070f, 0, 0.070f, 0.185f};
const float aSpreading[] = {-0.185f, -0.070f, 0, 0.070f, 0.185f};
float a = angle(Direction);
a += aSpreading[i + 2];
float v = 1 - (absolute(i) / (float)ShotSpread);

View file

@ -50,7 +50,7 @@ bool CLaser::HitCharacter(vec2 From, vec2 To)
{
vec2 Temp;
float Strength = GetTuning(m_TuneZone)->m_ShotgunStrength;
vec2 &HitPos = pHit->Core()->m_Pos;
const vec2 &HitPos = pHit->Core()->m_Pos;
if(!g_Config.m_SvOldLaser)
{
if(m_PrevPos != HitPos)

View file

@ -504,7 +504,7 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID, int Seed, int SeedO
if(pRule->m_Value == CPosRule::INDEX)
{
RespectRules = false;
for(auto &Index : pRule->m_vIndexList)
for(const auto &Index : pRule->m_vIndexList)
{
if(CheckIndex == Index.m_ID && (!Index.m_TestFlag || CheckFlags == Index.m_Flag))
{
@ -515,7 +515,7 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID, int Seed, int SeedO
}
else if(pRule->m_Value == CPosRule::NOTINDEX)
{
for(auto &Index : pRule->m_vIndexList)
for(const auto &Index : pRule->m_vIndexList)
{
if(CheckIndex == Index.m_ID && (!Index.m_TestFlag || CheckFlags == Index.m_Flag))
{

View file

@ -115,8 +115,8 @@ CLayerGroup::CLayerGroup()
template<typename T>
static void DeleteAll(std::vector<T> &vList)
{
for(auto &Item : vList)
delete Item;
for(const auto &pItem : vList)
delete pItem;
vList.clear();
}
@ -2986,7 +2986,7 @@ void CEditor::DoMapEditor(CUIRect View)
for(int i = 0; i < 2; i++)
{
float aPoints[4];
float aAspects[] = {4.0f / 3.0f, 16.0f / 10.0f, 5.0f / 4.0f, 16.0f / 9.0f};
const float aAspects[] = {4.0f / 3.0f, 16.0f / 10.0f, 5.0f / 4.0f, 16.0f / 9.0f};
float Aspect = aAspects[i];
RenderTools()->MapScreenToWorld(
@ -3143,7 +3143,7 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *
else if(pProps[i].m_Type == PROPTYPE_COLOR)
{
static const char *s_apTexts[4] = {"R", "G", "B", "A"};
static int s_aShift[] = {24, 16, 8, 0};
static const int s_aShift[] = {24, 16, 8, 0};
int NewColor = 0;
// extra space

View file

@ -21,7 +21,7 @@ TEST(SecureRandom, Below1)
TEST(SecureRandom, Below)
{
int BOUNDS[] = {2, 3, 4, 5, 10, 100, 127, 128, 129};
const int BOUNDS[] = {2, 3, 4, 5, 10, 100, 127, 128, 129};
for(auto Below : BOUNDS)
{
for(int j = 0; j < 10; j++)