diff options
Diffstat (limited to 'Minecraft.Client/Common/DLC')
| -rw-r--r-- | Minecraft.Client/Common/DLC/DLCAudioFile.cpp | 2 | ||||
| -rw-r--r-- | Minecraft.Client/Common/DLC/DLCManager.cpp | 59 | ||||
| -rw-r--r-- | Minecraft.Client/Common/DLC/DLCPack.cpp | 20 |
3 files changed, 33 insertions, 48 deletions
diff --git a/Minecraft.Client/Common/DLC/DLCAudioFile.cpp b/Minecraft.Client/Common/DLC/DLCAudioFile.cpp index 49ba52cd..6faf0c3b 100644 --- a/Minecraft.Client/Common/DLC/DLCAudioFile.cpp +++ b/Minecraft.Client/Common/DLC/DLCAudioFile.cpp @@ -178,7 +178,7 @@ bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength) { //EAudioParameterType paramType = e_AudioParamType_Invalid; - AUTO_VAR(it, parameterMapping.find( pParams->dwType )); + auto it = parameterMapping.find(pParams->dwType); if(it != parameterMapping.end() ) { diff --git a/Minecraft.Client/Common/DLC/DLCManager.cpp b/Minecraft.Client/Common/DLC/DLCManager.cpp index 17c9fc6d..36f4d7f7 100644 --- a/Minecraft.Client/Common/DLC/DLCManager.cpp +++ b/Minecraft.Client/Common/DLC/DLCManager.cpp @@ -32,10 +32,10 @@ DLCManager::DLCManager() DLCManager::~DLCManager() { - for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) + for ( DLCPack *pack : m_packs ) { - DLCPack *pack = *it; - delete pack; + if ( pack ) + delete pack; } } @@ -60,10 +60,9 @@ DWORD DLCManager::getPackCount(EDLCType type /*= e_DLCType_All*/) DWORD packCount = 0; if( type != e_DLCType_All ) { - for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) + for( DLCPack *pack : m_packs ) { - DLCPack *pack = *it; - if( pack->getDLCItemsCount(type) > 0 ) + if( pack && pack->getDLCItemsCount(type) > 0 ) { ++packCount; } @@ -85,7 +84,7 @@ void DLCManager::removePack(DLCPack *pack) { if(pack != NULL) { - AUTO_VAR(it, find(m_packs.begin(),m_packs.end(),pack)); + auto it = find(m_packs.begin(), m_packs.end(), pack); if(it != m_packs.end() ) m_packs.erase(it); delete pack; } @@ -93,10 +92,10 @@ void DLCManager::removePack(DLCPack *pack) void DLCManager::removeAllPacks(void) { - for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) + for( DLCPack *pack : m_packs ) { - DLCPack *pack = (DLCPack *)*it; - delete pack; + if ( pack ) + delete pack; } m_packs.clear(); @@ -104,23 +103,19 @@ void DLCManager::removeAllPacks(void) void DLCManager::LanguageChanged(void) { - for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) + for( DLCPack *pack : m_packs ) { - DLCPack *pack = (DLCPack *)*it; // update the language pack->UpdateLanguage(); } - } DLCPack *DLCManager::getPack(const wstring &name) { DLCPack *pack = NULL; //DWORD currentIndex = 0; - DLCPack *currentPack = NULL; - for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) + for( DLCPack * currentPack : m_packs ) { - currentPack = *it; wstring wsName=currentPack->getName(); if(wsName.compare(name) == 0) @@ -136,11 +131,8 @@ DLCPack *DLCManager::getPack(const wstring &name) DLCPack *DLCManager::getPackFromProductID(const wstring &productID) { DLCPack *pack = NULL; - //DWORD currentIndex = 0; - DLCPack *currentPack = NULL; - for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) + for( DLCPack *currentPack : m_packs ) { - currentPack = *it; wstring wsName=currentPack->getPurchaseOfferId(); if(wsName.compare(productID) == 0) @@ -159,10 +151,8 @@ DLCPack *DLCManager::getPack(DWORD index, EDLCType type /*= e_DLCType_All*/) if( type != e_DLCType_All ) { DWORD currentIndex = 0; - DLCPack *currentPack = NULL; - for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) + for( DLCPack *currentPack : m_packs ) { - currentPack = *it; if(currentPack->getDLCItemsCount(type)>0) { if(currentIndex == index) @@ -200,9 +190,8 @@ DWORD DLCManager::getPackIndex(DLCPack *pack, bool &found, EDLCType type /*= e_D if( type != e_DLCType_All ) { DWORD index = 0; - for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) + for( DLCPack *thisPack : m_packs ) { - DLCPack *thisPack = *it; if(thisPack->getDLCItemsCount(type)>0) { if(thisPack == pack) @@ -218,9 +207,8 @@ DWORD DLCManager::getPackIndex(DLCPack *pack, bool &found, EDLCType type /*= e_D else { DWORD index = 0; - for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) + for( DLCPack *thisPack : m_packs ) { - DLCPack *thisPack = *it; if(thisPack == pack) { found = true; @@ -238,9 +226,8 @@ DWORD DLCManager::getPackIndexContainingSkin(const wstring &path, bool &found) DWORD foundIndex = 0; found = false; DWORD index = 0; - for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) + for( DLCPack *pack : m_packs ) { - DLCPack *pack = *it; if(pack->getDLCItemsCount(e_DLCType_Skin)>0) { if(pack->doesPackContainSkin(path)) @@ -258,9 +245,8 @@ DWORD DLCManager::getPackIndexContainingSkin(const wstring &path, bool &found) DLCPack *DLCManager::getPackContainingSkin(const wstring &path) { DLCPack *foundPack = NULL; - for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) + for( DLCPack *pack : m_packs ) { - DLCPack *pack = *it; if(pack->getDLCItemsCount(e_DLCType_Skin)>0) { if(pack->doesPackContainSkin(path)) @@ -276,9 +262,8 @@ DLCPack *DLCManager::getPackContainingSkin(const wstring &path) DLCSkinFile *DLCManager::getSkinFile(const wstring &path) { DLCSkinFile *foundSkinfile = NULL; - for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) + for( DLCPack *pack : m_packs ) { - DLCPack *pack = *it; foundSkinfile=pack->getSkinFile(path); if(foundSkinfile!=NULL) { @@ -291,12 +276,10 @@ DLCSkinFile *DLCManager::getSkinFile(const wstring &path) DWORD DLCManager::checkForCorruptDLCAndAlert(bool showMessage /*= true*/) { DWORD corruptDLCCount = m_dwUnnamedCorruptDLCCount; - DLCPack *pack = NULL; DLCPack *firstCorruptPack = NULL; - for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) + for( DLCPack *pack : m_packs ) { - pack = *it; if( pack->IsCorrupt() ) { ++corruptDLCCount; @@ -468,7 +451,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD { //DLCManager::EDLCParameterType paramType = DLCManager::e_DLCParamType_Invalid; - AUTO_VAR(it, parameterMapping.find( pParams->dwType )); + auto it = parameterMapping.find(pParams->dwType); if(it != parameterMapping.end() ) { @@ -658,7 +641,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp; for(unsigned int j=0;j<uiParameterCount;j++) { - AUTO_VAR(it, parameterMapping.find( pParams->dwType )); + auto it = parameterMapping.find(pParams->dwType); if(it != parameterMapping.end() ) { diff --git a/Minecraft.Client/Common/DLC/DLCPack.cpp b/Minecraft.Client/Common/DLC/DLCPack.cpp index 4a003d05..ea8a270f 100644 --- a/Minecraft.Client/Common/DLC/DLCPack.cpp +++ b/Minecraft.Client/Common/DLC/DLCPack.cpp @@ -54,16 +54,18 @@ DLCPack::DLCPack(const wstring &name,const wstring &productID,DWORD dwLicenseMas DLCPack::~DLCPack() { - for(AUTO_VAR(it, m_childPacks.begin()); it != m_childPacks.end(); ++it) + for( auto& it : m_childPacks ) { - delete *it; + if ( it ) + delete it; } for(unsigned int i = 0; i < DLCManager::e_DLCType_Max; ++i) { - for(AUTO_VAR(it,m_files[i].begin()); it != m_files[i].end(); ++it) + for (auto& it : m_files[i] ) { - delete *it; + if ( it ) + delete it; } } @@ -161,7 +163,7 @@ void DLCPack::addParameter(DLCManager::EDLCParameterType type, const wstring &va bool DLCPack::getParameterAsUInt(DLCManager::EDLCParameterType type, unsigned int ¶m) { - AUTO_VAR(it,m_parameters.find((int)type)); + auto it = m_parameters.find((int)type); if(it != m_parameters.end()) { switch(type) @@ -270,7 +272,7 @@ bool DLCPack::doesPackContainFile(DLCManager::EDLCType type, const wstring &path else { g_pathCmpString = &path; - AUTO_VAR(it, find_if( m_files[type].begin(), m_files[type].end(), pathCmp )); + auto it = find_if(m_files[type].begin(), m_files[type].end(), pathCmp); hasFile = it != m_files[type].end(); if(!hasFile && m_parentPack ) { @@ -316,7 +318,7 @@ DLCFile *DLCPack::getFile(DLCManager::EDLCType type, const wstring &path) else { g_pathCmpString = &path; - AUTO_VAR(it, find_if( m_files[type].begin(), m_files[type].end(), pathCmp )); + auto it = find_if(m_files[type].begin(), m_files[type].end(), pathCmp); if(it == m_files[type].end()) { @@ -368,9 +370,9 @@ DWORD DLCPack::getFileIndexAt(DLCManager::EDLCType type, const wstring &path, bo DWORD foundIndex = 0; found = false; DWORD index = 0; - for(AUTO_VAR(it, m_files[type].begin()); it != m_files[type].end(); ++it) + for( auto& it : m_files[type] ) { - if(path.compare((*it)->getPath()) == 0) + if(path.compare(it->getPath()) == 0) { foundIndex = index; found = true; |
