diff --git a/engine/shared/library/sharedFoundation/src/shared/DataResourceList.h b/engine/shared/library/sharedFoundation/src/shared/DataResourceList.h index a86629e5..f2476eeb 100755 --- a/engine/shared/library/sharedFoundation/src/shared/DataResourceList.h +++ b/engine/shared/library/sharedFoundation/src/shared/DataResourceList.h @@ -82,13 +82,10 @@ private: template inline void DataResourceList::install() { - if (ms_bindings == nullptr) - { - ms_bindings = new CreateDataResourceMap(); - ms_loaded = new LoadedDataResourceMap(); + auto static *ms_bindings = new CreateDataResourceMap(); + auto static *ms_loaded = new LoadedDataResourceMap(); - ExitChain::add (remove, "DataResourceList::remove"); - } + ExitChain::add (remove, "DataResourceList::remove"); } // DataResourceList::install //---------------------------------------------------------------------- @@ -100,6 +97,9 @@ inline void DataResourceList::install() template inline void DataResourceList::remove(void) { + auto static *ms_bindings = new CreateDataResourceMap(); + auto static *ms_loaded = new LoadedDataResourceMap(); + if (ms_loaded != nullptr) { #ifdef _DEBUG @@ -122,13 +122,11 @@ inline void DataResourceList::remove(void) #endif // _DEBUG delete ms_loaded; - ms_loaded = nullptr; } if (ms_bindings != nullptr) { delete ms_bindings; - ms_bindings = nullptr; } } // DataResourceList::remove @@ -144,6 +142,9 @@ template inline void DataResourceList::registerTemplate(Tag id, CreateDataResourceFunc createFunc) { + auto static *ms_bindings = new CreateDataResourceMap(); + auto static *ms_loaded = new LoadedDataResourceMap(); + if (ms_bindings == nullptr) install(); @@ -197,8 +198,6 @@ template inline typename DataResourceList::CreateDataResourceFunc DataResourceList::removeBinding( Tag id) { - NOT_NULL(ms_bindings); - CreateDataResourceFunc oldFunc = (*ms_bindings)[id]; ms_bindings->erase(id); return oldFunc; @@ -233,7 +232,8 @@ inline const T * DataResourceList::fetch(const char * filename) template inline T * DataResourceList::fetch(Tag id) { - NOT_NULL(ms_bindings); + auto static *ms_bindings = new CreateDataResourceMap(); + auto static *ms_loaded = new LoadedDataResourceMap(); typename CreateDataResourceMap::iterator iter = ms_bindings->find(id); if (iter == ms_bindings->end()) @@ -254,7 +254,8 @@ inline T * DataResourceList::fetch(Tag id) template inline const T * DataResourceList::fetch(Iff &source) { - NOT_NULL(ms_bindings); + auto static *ms_bindings = new CreateDataResourceMap(); + auto static *ms_loaded = new LoadedDataResourceMap(); #ifdef _DEBUG DataLint::pushAsset(source.getFileName()); @@ -297,7 +298,8 @@ inline const T * DataResourceList::fetch(Iff &source) template inline const T * DataResourceList::fetch(const CrcString &filename) { - NOT_NULL(ms_loaded); + auto static *ms_bindings = new CreateDataResourceMap(); + auto static *ms_loaded = new LoadedDataResourceMap(); // see if we already have loaded the template typename LoadedDataResourceMap::iterator iter = ms_loaded->find(&filename); @@ -335,17 +337,18 @@ inline const T * DataResourceList::fetch(const CrcString &filename) template inline void DataResourceList::release(const T & dataResource) { - NOT_NULL(ms_loaded); + auto static *ms_bindings = new CreateDataResourceMap(); + auto static *ms_loaded = new LoadedDataResourceMap(); if (ms_loaded != nullptr && dataResource.getReferenceCount() == 0) { typename LoadedDataResourceMap::iterator iter = ms_loaded->find(&dataResource.getCrcName()); if (iter != ms_loaded->end()) { - const T * const temp = (*iter).second; + delete (*iter).second; (*iter).second = nullptr; - ms_loaded->erase(iter); - delete temp; + + iter = ms_loaded->erase(iter); } } } // DataResourceList::release diff --git a/external/3rd/library/libLeff/libLeff.h b/external/3rd/library/libLeff/libLeff.h index 455774e1..f74b9282 100644 --- a/external/3rd/library/libLeff/libLeff.h +++ b/external/3rd/library/libLeff/libLeff.h @@ -59,7 +59,7 @@ template template<> struct vxCplIndexes<0> { typedef vxCplIndexList<> Result; }; // Compile-time string encryption of a single character -const char vxCplEncryptCharKey = vxRANDOM(0, 0xFF); +const int vxCplEncryptCharKey = vxRANDOM(0, 0xFF); constexpr char vxCplEncryptChar(const char Ch, uint32_t Idx) { return Ch ^ (vxCplEncryptCharKey + Idx); }