diff --git a/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.cpp b/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.cpp index ca9bc63f..bfa3795b 100644 --- a/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.cpp @@ -41,6 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com *==LICENSE==*/ #include "HeadSpin.h" +#include #include "hsStream.h" #include "hsResMgr.h" @@ -61,9 +62,7 @@ plClientResMgr& plClientResMgr::Instance(void) plClientResMgr::~plClientResMgr() { - std::map::iterator it; - - for (it = ClientResources.begin(); it != ClientResources.end(); ++it) { + for (auto it = ClientResources.begin(); it != ClientResources.end(); ++it) { if (it->second) it->second->UnRef(); } @@ -71,9 +70,8 @@ plClientResMgr::~plClientResMgr() void plClientResMgr::ILoadResources(const plFileName& resfile) { - if (!resfile.IsValid()) { + if (!resfile.IsValid()) return; - } hsUNIXStream in; @@ -87,19 +85,19 @@ void plClientResMgr::ILoadResources(const plFileName& resfile) num_resources = in.ReadLE32(); for (int i = 0; i < num_resources; i++) { - plMipmap* res_data = NULL; + plMipmap* res_data = nullptr; uint32_t res_size = 0; plString res_name = in.ReadSafeStringLong(); - plString res_type = res_name.Substr(res_name.GetSize() - 4, 4); + plString extension = plFileName(res_name).GetFileExt(); // Version 1 doesn't encode format, so we'll try some simple // extension sniffing - if (res_type == ".png") { + if (extension == "png") { // Read resource stream size, but the PNG has that info in the header // so it's not needed res_size = in.ReadLE32(); res_data = plPNG::Instance().ReadFromStream(&in); - } else if (res_type == ".jpg") { + } else if (extension == "jpg") { // Don't read resource stream size, as plJPEG's reader will need it res_data = plJPEG::Instance().ReadFromStream(&in); } else { @@ -126,7 +124,7 @@ void plClientResMgr::ILoadResources(const plFileName& resfile) plMipmap* plClientResMgr::getResource(const plString& resname) { plMipmap* resmipmap = nullptr; - std::map::iterator it = ClientResources.find(resname); + auto it = ClientResources.find(resname); if (it != ClientResources.end()) { resmipmap = it->second; diff --git a/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.h b/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.h index 1dc2e241..5738f393 100644 --- a/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.h +++ b/Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.h @@ -43,7 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #ifndef _plClientResMgr_h #define _plClientResMgr_h -#include +#include class plMipmap; class plString; @@ -51,7 +51,7 @@ class plFileName; class plClientResMgr { protected: - std::map ClientResources; + std::unordered_map ClientResources; public: plClientResMgr() { }