Fix readability-container-data-pointer

This commit is contained in:
Robert Müller 2022-07-10 21:22:50 +02:00
parent bf686342df
commit ec4175277e
8 changed files with 25 additions and 25 deletions

View file

@ -4775,7 +4775,7 @@ SWarning *CClient::GetCurWarning()
} }
else else
{ {
return &m_vWarnings[0]; return m_vWarnings.data();
} }
} }

View file

@ -354,9 +354,9 @@ IGraphics::CTextureHandle CGraphics_Threaded::LoadSpriteTextureImpl(CImageInfo &
m_vSpriteHelper.resize((size_t)w * h * bpp); m_vSpriteHelper.resize((size_t)w * h * bpp);
CopyTextureFromTextureBufferSub(&m_vSpriteHelper[0], w, h, (uint8_t *)FromImageInfo.m_pData, FromImageInfo.m_Width, FromImageInfo.m_Height, bpp, x, y, w, h); CopyTextureFromTextureBufferSub(m_vSpriteHelper.data(), w, h, (uint8_t *)FromImageInfo.m_pData, FromImageInfo.m_Width, FromImageInfo.m_Height, bpp, x, y, w, h);
IGraphics::CTextureHandle RetHandle = LoadTextureRaw(w, h, FromImageInfo.m_Format, &m_vSpriteHelper[0], FromImageInfo.m_Format, 0); IGraphics::CTextureHandle RetHandle = LoadTextureRaw(w, h, FromImageInfo.m_Format, m_vSpriteHelper.data(), FromImageInfo.m_Format, 0);
return RetHandle; return RetHandle;
} }
@ -1413,12 +1413,12 @@ void CGraphics_Threaded::QuadContainerUpload(int ContainerIndex)
if(Container.m_QuadBufferObjectIndex == -1) if(Container.m_QuadBufferObjectIndex == -1)
{ {
size_t UploadDataSize = Container.m_vQuads.size() * sizeof(SQuadContainer::SQuad); size_t UploadDataSize = Container.m_vQuads.size() * sizeof(SQuadContainer::SQuad);
Container.m_QuadBufferObjectIndex = CreateBufferObject(UploadDataSize, &Container.m_vQuads[0], 0); Container.m_QuadBufferObjectIndex = CreateBufferObject(UploadDataSize, Container.m_vQuads.data(), 0);
} }
else else
{ {
size_t UploadDataSize = Container.m_vQuads.size() * sizeof(SQuadContainer::SQuad); size_t UploadDataSize = Container.m_vQuads.size() * sizeof(SQuadContainer::SQuad);
RecreateBufferObject(Container.m_QuadBufferObjectIndex, UploadDataSize, &Container.m_vQuads[0], 0); RecreateBufferObject(Container.m_QuadBufferObjectIndex, UploadDataSize, Container.m_vQuads.data(), 0);
} }
if(Container.m_QuadBufferContainerIndex == -1) if(Container.m_QuadBufferContainerIndex == -1)
@ -2808,7 +2808,7 @@ SWarning *CGraphics_Threaded::GetCurWarning()
return NULL; return NULL;
else else
{ {
SWarning *pCurWarning = &m_vWarnings[0]; SWarning *pCurWarning = m_vWarnings.data();
return pCurWarning; return pCurWarning;
} }
} }

View file

@ -137,7 +137,7 @@ void CInput::UpdateActiveJoystick()
} }
// Fall back to first joystick if no match was found // Fall back to first joystick if no match was found
if(!m_pActiveJoystick) if(!m_pActiveJoystick)
m_pActiveJoystick = &m_vJoysticks[0]; m_pActiveJoystick = &m_vJoysticks[0]; // NOLINT(readability-container-data-pointer)
} }
void CInput::ConchainJoystickGuidChanged(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) void CInput::ConchainJoystickGuidChanged(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)

View file

@ -1442,7 +1442,7 @@ public:
if(Graphics()->IsTextBufferingEnabled()) if(Graphics()->IsTextBufferingEnabled())
{ {
size_t DataSize = TextContainer.m_StringInfo.m_vCharacterQuads.size() * sizeof(STextCharQuad); size_t DataSize = TextContainer.m_StringInfo.m_vCharacterQuads.size() * sizeof(STextCharQuad);
void *pUploadData = &TextContainer.m_StringInfo.m_vCharacterQuads[0]; void *pUploadData = TextContainer.m_StringInfo.m_vCharacterQuads.data();
if(TextContainer.m_StringInfo.m_QuadBufferObjectIndex != -1 && (TextContainer.m_RenderFlags & TEXT_RENDER_FLAG_NO_AUTOMATIC_QUAD_UPLOAD) == 0) if(TextContainer.m_StringInfo.m_QuadBufferObjectIndex != -1 && (TextContainer.m_RenderFlags & TEXT_RENDER_FLAG_NO_AUTOMATIC_QUAD_UPLOAD) == 0)
{ {
@ -1503,7 +1503,7 @@ public:
if(HasCursor) if(HasCursor)
Graphics()->QuadContainerAddQuads(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, aCursorQuads, 2); Graphics()->QuadContainerAddQuads(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, aCursorQuads, 2);
if(HasSelection) if(HasSelection)
Graphics()->QuadContainerAddQuads(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, &vSelectionQuads[0], (int)vSelectionQuads.size()); Graphics()->QuadContainerAddQuads(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, vSelectionQuads.data(), (int)vSelectionQuads.size());
Graphics()->QuadContainerUpload(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex); Graphics()->QuadContainerUpload(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex);
TextContainer.m_HasCursor = HasCursor; TextContainer.m_HasCursor = HasCursor;

View file

@ -27,7 +27,7 @@ static void LibPNGWarning(png_structp png_ptr, png_const_charp warning_msg)
static bool FileMatchesImageType(SImageByteBuffer &ByteLoader) static bool FileMatchesImageType(SImageByteBuffer &ByteLoader)
{ {
if(ByteLoader.m_pLoadedImageBytes->size() >= 8) if(ByteLoader.m_pLoadedImageBytes->size() >= 8)
return png_sig_cmp((png_bytep) & (*ByteLoader.m_pLoadedImageBytes)[0], 0, 8) == 0; return png_sig_cmp((png_bytep)ByteLoader.m_pLoadedImageBytes->data(), 0, 8) == 0;
return false; return false;
} }

View file

@ -833,8 +833,8 @@ void CMapLayers::OnMapLoad()
vtmpTileTexCoords.insert(vtmpTileTexCoords.end(), vtmpBorderRightTilesTexCoords.begin(), vtmpBorderRightTilesTexCoords.end()); vtmpTileTexCoords.insert(vtmpTileTexCoords.end(), vtmpBorderRightTilesTexCoords.begin(), vtmpBorderRightTilesTexCoords.end());
//setup params //setup params
float *pTmpTiles = (vtmpTiles.empty()) ? NULL : (float *)&vtmpTiles[0]; float *pTmpTiles = vtmpTiles.empty() ? NULL : (float *)vtmpTiles.data();
unsigned char *pTmpTileTexCoords = (vtmpTileTexCoords.empty()) ? NULL : (unsigned char *)&vtmpTileTexCoords[0]; unsigned char *pTmpTileTexCoords = vtmpTileTexCoords.empty() ? NULL : (unsigned char *)vtmpTileTexCoords.data();
Visuals.m_BufferContainerIndex = -1; Visuals.m_BufferContainerIndex = -1;
size_t UploadDataSize = vtmpTileTexCoords.size() * sizeof(SGraphicTileTexureCoords) + vtmpTiles.size() * sizeof(SGraphicTile); size_t UploadDataSize = vtmpTileTexCoords.size() * sizeof(SGraphicTileTexureCoords) + vtmpTiles.size() * sizeof(SGraphicTile);
@ -951,9 +951,9 @@ void CMapLayers::OnMapLoad()
{ {
void *pUploadData = NULL; void *pUploadData = NULL;
if(Textured) if(Textured)
pUploadData = &vtmpQuadsTextured[0]; pUploadData = vtmpQuadsTextured.data();
else else
pUploadData = &vtmpQuads[0]; pUploadData = vtmpQuads.data();
// create the buffer object // create the buffer object
int BufferObjectIndex = Graphics()->CreateBufferObject(UploadDataSize, pUploadData, 0); int BufferObjectIndex = Graphics()->CreateBufferObject(UploadDataSize, pUploadData, 0);
// then create the buffer container // then create the buffer container
@ -1087,7 +1087,7 @@ void CMapLayers::RenderTileLayer(int LayerIndex, ColorRGBA &Color, CMapItemLayer
int DrawCount = s_vpIndexOffsets.size(); int DrawCount = s_vpIndexOffsets.size();
if(DrawCount != 0) if(DrawCount != 0)
{ {
Graphics()->RenderTileLayer(Visuals.m_BufferContainerIndex, Color, &s_vpIndexOffsets[0], &s_vDrawCounts[0], DrawCount); Graphics()->RenderTileLayer(Visuals.m_BufferContainerIndex, Color, s_vpIndexOffsets.data(), s_vDrawCounts.data(), DrawCount);
} }
} }
@ -1416,7 +1416,7 @@ void CMapLayers::RenderQuadLayer(int LayerIndex, CMapItemLayerQuads *pQuadLayer,
if(NeedsFlush) if(NeedsFlush)
{ {
// render quads of the current offset directly(cancel batching) // render quads of the current offset directly(cancel batching)
Graphics()->RenderQuadLayer(Visuals.m_BufferContainerIndex, &s_vQuadRenderInfo[0], QuadsRenderCount, CurQuadOffset); Graphics()->RenderQuadLayer(Visuals.m_BufferContainerIndex, s_vQuadRenderInfo.data(), QuadsRenderCount, CurQuadOffset);
QuadsRenderCount = 0; QuadsRenderCount = 0;
CurQuadOffset = i; CurQuadOffset = i;
if(Color.a == 0) if(Color.a == 0)
@ -1435,7 +1435,7 @@ void CMapLayers::RenderQuadLayer(int LayerIndex, CMapItemLayerQuads *pQuadLayer,
QInfo.m_Rotation = Rot; QInfo.m_Rotation = Rot;
} }
} }
Graphics()->RenderQuadLayer(Visuals.m_BufferContainerIndex, &s_vQuadRenderInfo[0], QuadsRenderCount, CurQuadOffset); Graphics()->RenderQuadLayer(Visuals.m_BufferContainerIndex, s_vQuadRenderInfo.data(), QuadsRenderCount, CurQuadOffset);
} }
void CMapLayers::LayersOfGroupCount(CMapItemGroup *pGroup, int &TileLayerCount, int &QuadLayerCount, bool &PassedGameLayer) void CMapLayers::LayersOfGroupCount(CMapItemGroup *pGroup, int &TileLayerCount, int &QuadLayerCount, bool &PassedGameLayer)

View file

@ -290,7 +290,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
// add the data // add the data
Item.m_NumQuads = pLayerQuads->m_vQuads.size(); Item.m_NumQuads = pLayerQuads->m_vQuads.size();
Item.m_Data = df.AddDataSwapped(pLayerQuads->m_vQuads.size() * sizeof(CQuad), &pLayerQuads->m_vQuads[0]); Item.m_Data = df.AddDataSwapped(pLayerQuads->m_vQuads.size() * sizeof(CQuad), pLayerQuads->m_vQuads.data());
// save layer name // save layer name
StrToInts(Item.m_aName, sizeof(Item.m_aName) / sizeof(int), pLayerQuads->m_aName); StrToInts(Item.m_aName, sizeof(Item.m_aName) / sizeof(int), pLayerQuads->m_aName);
@ -319,7 +319,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
// add the data // add the data
Item.m_NumSources = pLayerSounds->m_vSources.size(); Item.m_NumSources = pLayerSounds->m_vSources.size();
Item.m_Data = df.AddDataSwapped(pLayerSounds->m_vSources.size() * sizeof(CSoundSource), &pLayerSounds->m_vSources[0]); Item.m_Data = df.AddDataSwapped(pLayerSounds->m_vSources.size() * sizeof(CSoundSource), pLayerSounds->m_vSources.data());
// save layer name // save layer name
StrToInts(Item.m_aName, sizeof(Item.m_aName) / sizeof(int), pLayerSounds->m_aName); StrToInts(Item.m_aName, sizeof(Item.m_aName) / sizeof(int), pLayerSounds->m_aName);
@ -358,7 +358,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
for(const auto &pEnvelope : m_vpEnvelopes) for(const auto &pEnvelope : m_vpEnvelopes)
{ {
int Count = pEnvelope->m_vPoints.size(); int Count = pEnvelope->m_vPoints.size();
mem_copy(&pPoints[PointCount], &pEnvelope->m_vPoints[0], sizeof(CEnvPoint) * Count); mem_copy(&pPoints[PointCount], pEnvelope->m_vPoints.data(), sizeof(CEnvPoint) * Count);
PointCount += Count; PointCount += Count;
} }
@ -848,7 +848,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
void *pData = DataFile.GetDataSwapped(pQuadsItem->m_Data); void *pData = DataFile.GetDataSwapped(pQuadsItem->m_Data);
pGroup->AddLayer(pQuads); pGroup->AddLayer(pQuads);
pQuads->m_vQuads.resize(pQuadsItem->m_NumQuads); pQuads->m_vQuads.resize(pQuadsItem->m_NumQuads);
mem_copy(&pQuads->m_vQuads[0], pData, sizeof(CQuad) * pQuadsItem->m_NumQuads); mem_copy(pQuads->m_vQuads.data(), pData, sizeof(CQuad) * pQuadsItem->m_NumQuads);
DataFile.UnloadData(pQuadsItem->m_Data); DataFile.UnloadData(pQuadsItem->m_Data);
} }
else if(pLayerItem->m_Type == LAYERTYPE_SOUNDS) else if(pLayerItem->m_Type == LAYERTYPE_SOUNDS)
@ -874,7 +874,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
void *pData = DataFile.GetDataSwapped(pSoundsItem->m_Data); void *pData = DataFile.GetDataSwapped(pSoundsItem->m_Data);
pGroup->AddLayer(pSounds); pGroup->AddLayer(pSounds);
pSounds->m_vSources.resize(pSoundsItem->m_NumSources); pSounds->m_vSources.resize(pSoundsItem->m_NumSources);
mem_copy(&pSounds->m_vSources[0], pData, sizeof(CSoundSource) * pSoundsItem->m_NumSources); mem_copy(pSounds->m_vSources.data(), pData, sizeof(CSoundSource) * pSoundsItem->m_NumSources);
DataFile.UnloadData(pSoundsItem->m_Data); DataFile.UnloadData(pSoundsItem->m_Data);
} }
else if(pLayerItem->m_Type == LAYERTYPE_SOUNDS_DEPRECATED) else if(pLayerItem->m_Type == LAYERTYPE_SOUNDS_DEPRECATED)
@ -949,7 +949,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
CMapItemEnvelope *pItem = (CMapItemEnvelope *)DataFile.GetItem(Start + e, nullptr, nullptr); CMapItemEnvelope *pItem = (CMapItemEnvelope *)DataFile.GetItem(Start + e, nullptr, nullptr);
CEnvelope *pEnv = new CEnvelope(pItem->m_Channels); CEnvelope *pEnv = new CEnvelope(pItem->m_Channels);
pEnv->m_vPoints.resize(pItem->m_NumPoints); pEnv->m_vPoints.resize(pItem->m_NumPoints);
mem_copy(&pEnv->m_vPoints[0], &pPoints[pItem->m_StartPoint], sizeof(CEnvPoint) * pItem->m_NumPoints); mem_copy(pEnv->m_vPoints.data(), &pPoints[pItem->m_StartPoint], sizeof(CEnvPoint) * pItem->m_NumPoints);
if(pItem->m_aName[0] != -1) // compatibility with old maps if(pItem->m_aName[0] != -1) // compatibility with old maps
IntsToStr(pItem->m_aName, sizeof(pItem->m_aName) / sizeof(int), pEnv->m_aName); IntsToStr(pItem->m_aName, sizeof(pItem->m_aName) / sizeof(int), pEnv->m_aName);
m_vpEnvelopes.push_back(pEnv); m_vpEnvelopes.push_back(pEnv);

View file

@ -23,9 +23,9 @@ void CLayerQuads::Render(bool QuadPicker)
Graphics()->TextureSet(m_pEditor->m_Map.m_vpImages[m_Image]->m_Texture); Graphics()->TextureSet(m_pEditor->m_Map.m_vpImages[m_Image]->m_Texture);
Graphics()->BlendNone(); Graphics()->BlendNone();
m_pEditor->RenderTools()->ForceRenderQuads(&m_vQuads[0], m_vQuads.size(), LAYERRENDERFLAG_OPAQUE, m_pEditor->EnvelopeEval, m_pEditor); m_pEditor->RenderTools()->ForceRenderQuads(m_vQuads.data(), m_vQuads.size(), LAYERRENDERFLAG_OPAQUE, m_pEditor->EnvelopeEval, m_pEditor);
Graphics()->BlendNormal(); Graphics()->BlendNormal();
m_pEditor->RenderTools()->ForceRenderQuads(&m_vQuads[0], m_vQuads.size(), LAYERRENDERFLAG_TRANSPARENT, m_pEditor->EnvelopeEval, m_pEditor); m_pEditor->RenderTools()->ForceRenderQuads(m_vQuads.data(), m_vQuads.size(), LAYERRENDERFLAG_TRANSPARENT, m_pEditor->EnvelopeEval, m_pEditor);
} }
CQuad *CLayerQuads::NewQuad(int x, int y, int Width, int Height) CQuad *CLayerQuads::NewQuad(int x, int y, int Width, int Height)