diff options
Diffstat (limited to '')
-rw-r--r-- | src/wmresourcemng.cpp | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/src/wmresourcemng.cpp b/src/wmresourcemng.cpp deleted file mode 100644 index 4a71753..0000000 --- a/src/wmresourcemng.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "worldmap.h" - - - - -dWMResourceMng_c::dWMResourceMng_c() { - hasSetPath = false; - isSetLoaded = false; - isLoadingComplete = false; -} - -dWMResourceMng_c::~dWMResourceMng_c() { - if (isSetLoaded) { - for (int i = 0; i < setData->count; i++) { - resLoaders[i].unload(); - } - - delete[] resLoaders; - } - - setLoader.unload(); -} - - - -bool dWMResourceMng_c::isLoaded() { - return isLoadingComplete; -} - - -bool dWMResourceMng_c::loadSet(const char *setName) { - if (isLoadingComplete) - return true; - - // only start the loading process if we haven't done that already - if (!isSetLoaded) { - if (!hasSetPath) { - snprintf(setPath, sizeof(setPath), "/Maps/%s.fileset", setName); - hasSetPath = true; - } - - void *result = setLoader.load(setPath); - if (result == 0) - return false; - - // cool, we've got it, now load everything here - setData = (WMResSetHeader*)result; - - resLoaders = new dDvdLoader_c[setData->count]; - - isSetLoaded = true; - } - - // now try to load every resource - // if even ONE of them fails, then don't return true - bool isLoadingComplete = true; - - for (int i = 0; i < setData->count; i++) { - isLoadingComplete &= (resLoaders[i].load(setData->getName(i)) != 0); - } - - // if they are ALL loaded, then we'll return true! - return isLoadingComplete; -} - - -void *dWMResourceMng_c::operator[](u32 key) { - if (!isLoadingComplete) - return 0; - - for (int i = 0; i < setData->count; i++) { - if (key == setData->entries[i].key) - return resLoaders[i].buffer; - } - - return 0; -} - |