diff --git a/fileformats/ArchiveManager.cpp b/fileformats/ArchiveManager.cpp index 7c777c3..5fd4d7a 100644 --- a/fileformats/ArchiveManager.cpp +++ b/fileformats/ArchiveManager.cpp @@ -35,13 +35,12 @@ void ArchiveManager::Destroy() { m_OpenArchives.clear(); - std::vector::iterator iArchive = m_ArchiveList.begin(); - std::vector::iterator eArchive = m_ArchiveList.end(); - for (; iArchive != eArchive; ++iArchive) + for (Archive *archive : m_ArchiveList) { - (*iArchive)->Close(); - xlDelete (*iArchive); + archive->Close(); + xlDelete archive; } + m_ArchiveList.clear(); TextureLoader::Destroy(); } diff --git a/movieplayback/LFD_Film.cpp b/movieplayback/LFD_Film.cpp index 138f9ce..d351f72 100644 --- a/movieplayback/LFD_Film.cpp +++ b/movieplayback/LFD_Film.cpp @@ -81,17 +81,15 @@ void LFD_Film::Stop() if ( m_Graphics.size() > 0 ) { - std::vector::iterator iter = m_Graphics.begin(); - std::vector::iterator end = m_Graphics.end(); - for (; iter!=end; ++iter) + for (Graphic *graphic : m_Graphics) { - if ( *iter ) + if (graphic != nullptr) { - Graphic *pGraphic = *iter; - pGraphic->pAnim->Destroy(); - xlDelete pGraphic->pAnim; + graphic->pAnim->Destroy(); + xlDelete graphic->pAnim; } } + m_Graphics.clear(); } diff --git a/movieplayback/MovieManager.cpp b/movieplayback/MovieManager.cpp index e4c8d44..47e9749 100644 --- a/movieplayback/MovieManager.cpp +++ b/movieplayback/MovieManager.cpp @@ -23,12 +23,11 @@ void MovieManager::Destroy() { m_MoviePlayers.clear(); - std::vector::iterator iMoviePlayer = m_MoviePlayerList.begin(); - std::vector::iterator eMoviePlayer = m_MoviePlayerList.end(); - for (; iMoviePlayer != eMoviePlayer; ++iMoviePlayer) + for (MoviePlayer *moviePlayer : m_MoviePlayerList) { - xlDelete (*iMoviePlayer); + xlDelete moviePlayer; } + m_MoviePlayerList.clear(); } diff --git a/os/Input.cpp b/os/Input.cpp index 40e8946..824c6e8 100644 --- a/os/Input.cpp +++ b/os/Input.cpp @@ -33,20 +33,18 @@ void Input::Init() void Input::Destroy() { - std::vector::iterator iKeyCB = m_KeyDownCB.begin(); - std::vector::iterator eKeyCB = m_KeyDownCB.end(); - for (; iKeyCB != eKeyCB; ++iKeyCB) + for (KeyDownCB_t *keyCB : m_KeyDownCB) { - xlDelete (*iKeyCB); + xlDelete keyCB; } + m_KeyDownCB.clear(); - std::vector::iterator iCharCB = m_CharDownCB.begin(); - std::vector::iterator eCharCB = m_CharDownCB.end(); - for (; iCharCB != eCharCB; ++iCharCB) + for (KeyDownCB_t *charCB : m_CharDownCB) { - xlDelete (*iCharCB); + xlDelete charCB; } + m_CharDownCB.clear(); } diff --git a/render/Driver3D_Soft.cpp b/render/Driver3D_Soft.cpp index 9dd881d..f898657 100644 --- a/render/Driver3D_Soft.cpp +++ b/render/Driver3D_Soft.cpp @@ -109,20 +109,19 @@ Driver3D_Soft::~Driver3D_Soft() //delete textures. if ( m_Textures.size() ) { - std::vector::iterator iTex = m_Textures.begin(); - std::vector::iterator eTex = m_Textures.end(); - for (; iTex != eTex; ++iTex) + for (Texture *tex : m_Textures) { - Texture *pTex = *iTex; - if (!pTex) - continue; - - for (int32_t f=0; fm_nFrameCnt; f++) + if (tex != nullptr) { - free( pTex->m_pData[f] ); + for (int32_t f = 0; f < tex->m_nFrameCnt; f++) + { + free(tex->m_pData[f]); + } + + delete tex; } - delete pTex; } + m_Textures.clear(); } diff --git a/render/FontManager.cpp b/render/FontManager.cpp index ae223ee..735957c 100644 --- a/render/FontManager.cpp +++ b/render/FontManager.cpp @@ -73,12 +73,11 @@ bool FontManager::Init(const std::string& szFontPath, IDriver3D *pDriver) void FontManager::Destroy() { //delete the fonts. - FontMap::iterator iFont = m_Fonts.begin(); - FontMap::iterator eFont = m_Fonts.end(); - for (; iFont != eFont; ++iFont) + for (auto &pair : m_Fonts) { - xlDelete (*iFont).second; + xlDelete pair.second; } + m_Fonts.clear(); if ( m_pVB ) diff --git a/render/MeshCache.cpp b/render/MeshCache.cpp index 89a7dd5..495486f 100644 --- a/render/MeshCache.cpp +++ b/render/MeshCache.cpp @@ -15,20 +15,18 @@ bool MeshCache::Init() void MeshCache::Destroy() { - MeshMap::iterator iMesh = m_MeshMap.begin(); - MeshMap::iterator eMesh = m_MeshMap.end(); - for (; iMesh != eMesh; ++iMesh) + for (auto &pair : m_MeshMap) { - delete iMesh->second; + delete pair.second; } + m_MeshMap.clear(); - MeshCollisionMap::iterator iMeshCol = m_MeshCollisionMap.begin(); - MeshCollisionMap::iterator eMeshCol = m_MeshCollisionMap.end(); - for (; iMeshCol != eMeshCol; ++iMeshCol) + for (auto &pair : m_MeshCollisionMap) { - delete iMeshCol->second; + delete pair.second; } + m_MeshCollisionMap.clear(); } diff --git a/ui/UI_System.cpp b/ui/UI_System.cpp index 2d0d092..3cae0ff 100644 --- a/ui/UI_System.cpp +++ b/ui/UI_System.cpp @@ -98,21 +98,19 @@ void UI_System::Destroy() UI_FreeImage( Editor_UI_Atlas ); } - std::vector::iterator iScreen = m_ScreenList.begin(); - std::vector::iterator eScreen = m_ScreenList.end(); - for (; iScreen != eScreen; ++iScreen) + for (UI_Screen *screen : m_ScreenList) { - xlDelete *iScreen; + xlDelete screen; } + m_ScreenList.clear(); m_ScreenMap.clear(); - std::vector::iterator iWindow = m_WindowList.begin(); - std::vector::iterator eWindow = m_WindowList.end(); - for (; iWindow != eWindow; ++iWindow) + for (UI_Window *window : m_WindowList) { - xlDelete *iWindow; + xlDelete window; } + m_WindowList.clear(); FreeRenderFramePool(); diff --git a/world/LevelFunc.cpp b/world/LevelFunc.cpp index 14ebd96..9c395a4 100644 --- a/world/LevelFunc.cpp +++ b/world/LevelFunc.cpp @@ -27,20 +27,14 @@ LevelFunc::LevelFunc(WorldCell *pWorldCell, int32_t nSector, int32_t nWall) LevelFunc::~LevelFunc() { - std::vector::iterator iState = m_States.begin(); - std::vector::iterator eState = m_States.end(); - - for (; iState != eState; ++iState) + for (State *state : m_States) { - xlDelete (*iState); + xlDelete state; } - std::vector::iterator iCObj = m_ClientObjects.begin(); - std::vector::iterator eCObj = m_ClientObjects.end(); - - for (; iCObj != eCObj; ++iCObj) + for (ClientObject *cObj : m_ClientObjects) { - xlDelete (*iCObj); + xlDelete cObj; } } diff --git a/world/LevelFuncMgr.cpp b/world/LevelFuncMgr.cpp index e65fcf3..7c70b55 100644 --- a/world/LevelFuncMgr.cpp +++ b/world/LevelFuncMgr.cpp @@ -23,12 +23,11 @@ void LevelFuncMgr::Destroy() m_AddList.clear(); m_RemoveList.clear(); - std::vector::iterator iFunc = m_FuncList.begin(); - std::vector::iterator eFunc = m_FuncList.end(); - for (; iFunc != eFunc; ++iFunc) + for (LevelFunc *func : m_FuncList) { - delete (*iFunc); + delete func; } + m_FuncList.clear(); } diff --git a/world/LogicManager.cpp b/world/LogicManager.cpp index 839629f..bdb0604 100644 --- a/world/LogicManager.cpp +++ b/world/LogicManager.cpp @@ -9,12 +9,9 @@ bool LogicManager::Init() void LogicManager::Destroy() { - std::map::iterator iLogic = m_Logics.begin(); - std::map::iterator eLogic = m_Logics.end(); - - for (; iLogic != eLogic; ++iLogic) + for (auto &pair : m_Logics) { - xlDelete iLogic->second; + xlDelete pair.second; } m_Logics.clear(); diff --git a/world/ObjectManager.cpp b/world/ObjectManager.cpp index c8ebc2e..7a8bb71 100644 --- a/world/ObjectManager.cpp +++ b/world/ObjectManager.cpp @@ -40,13 +40,11 @@ void ObjectManager::Destroy() { LogicManager::Destroy(); - std::vector::iterator iObjPool = m_ObjectPool.begin(); - std::vector::iterator eObjPool = m_ObjectPool.end(); - for (; iObjPool != eObjPool; ++iObjPool) + for (Object *pool : m_ObjectPool) { - Object *pool = *iObjPool; - xlDelete [] pool; + xlDelete[] pool; } + m_ObjectPool.clear(); m_FreeObjects.clear(); m_ActiveObjects.clear(); diff --git a/world/Sector.cpp b/world/Sector.cpp index 96848cf..d4e6902 100644 --- a/world/Sector.cpp +++ b/world/Sector.cpp @@ -15,12 +15,11 @@ Sector::Sector() Sector::~Sector() { - std::vector::iterator iLight = m_Lights.begin(); - std::vector::iterator eLight = m_Lights.end(); - for (; iLight != eLight; ++iLight) + for (LightObject *light : m_Lights) { - xlDelete *iLight; + xlDelete light; } + m_Lights.clear(); xlDelete [] m_pValidNodes; } diff --git a/world/World.cpp b/world/World.cpp index 9472ce1..978c52d 100644 --- a/world/World.cpp +++ b/world/World.cpp @@ -32,12 +32,11 @@ World::~World() void World::UnloadWorldCells() { - std::vector::iterator iCell = m_WorldCells.begin(); - std::vector::iterator eCell = m_WorldCells.end(); - for (; iCell != eCell; ++iCell) + for (WorldCell *cell : m_WorldCells) { - xlDelete *iCell; + xlDelete cell; } + m_WorldCells.clear(); }