From ce54a0d07506f9c0b374d035fe5e8036bbac6c96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Mon, 23 May 2022 22:48:56 +0200 Subject: [PATCH] Use std::vector instead of array --- src/game/client/components/menus.cpp | 14 ++++++-------- src/game/client/components/menus.h | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 6e24a59ff..874efb1e7 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -1053,7 +1053,7 @@ void CMenus::OnInit() m_IsInit = true; // load menu images - m_lMenuImages.clear(); + m_vMenuImages.clear(); Storage()->ListDirectory(IStorage::TYPE_ALL, "menuimages", MenuImageScan, this); } @@ -2762,7 +2762,7 @@ int CMenus::MenuImageScan(const char *pName, int IsDir, int DirType, void *pUser // set menu image data str_truncate(MenuImage.m_aName, sizeof(MenuImage.m_aName), pName, str_length(pName) - 4); - pSelf->m_lMenuImages.add(MenuImage); + pSelf->m_vMenuImages.push_back(MenuImage); pSelf->RenderLoading(true); return 0; @@ -2770,12 +2770,10 @@ int CMenus::MenuImageScan(const char *pName, int IsDir, int DirType, void *pUser const CMenus::CMenuImage *CMenus::FindMenuImage(const char *pName) { - for(int i = 0; i < m_lMenuImages.size(); i++) - { - if(str_comp(m_lMenuImages[i].m_aName, pName) == 0) - return &m_lMenuImages[i]; - } - return 0; + for(auto &Image : m_vMenuImages) + if(str_comp(Image.m_aName, pName) == 0) + return &Image; + return nullptr; } void CMenus::SetMenuPage(int NewPage) diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 1482e07a0..137a025c8 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -296,7 +296,7 @@ protected: IGraphics::CTextureHandle m_OrgTexture; IGraphics::CTextureHandle m_GreyTexture; }; - array m_lMenuImages; + std::vector m_vMenuImages; static int MenuImageScan(const char *pName, int IsDir, int DirType, void *pUser);