diff options
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/image.h | 1 | ||||
-rw-r--r-- | src/resources/itemmanager.cpp | 20 | ||||
-rw-r--r-- | src/resources/resource.cpp | 5 | ||||
-rw-r--r-- | src/resources/resource.h | 5 |
4 files changed, 21 insertions, 10 deletions
diff --git a/src/resources/image.h b/src/resources/image.h index 807f0fb0..ebc2c971 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -155,7 +155,6 @@ class SubImage : public Image /** * Constructor. */ - //SubImage(SDL_Surface *timage, int x, int y, int width, int height); #ifndef USE_OPENGL SubImage(Image *parent, SDL_Surface *image, int x, int y, int width, int height); diff --git a/src/resources/itemmanager.cpp b/src/resources/itemmanager.cpp index 05b0ff44..8ac05e08 100644 --- a/src/resources/itemmanager.cpp +++ b/src/resources/itemmanager.cpp @@ -26,6 +26,7 @@ #include <iostream> #include "itemmanager.h" +#include "resourcemanager.h" #include "../main.h" #include "../log.h" @@ -38,16 +39,16 @@ ItemManager::ItemManager() { - // Check that file exists before trying to parse it - std::fstream dbFile; - dbFile.open(TMW_DATADIR "data/items.xml", std::ios::in); - if (!dbFile.is_open()) { - logger->error("Cannot find item database (items.xml)!"); - return; + ResourceManager *resman = ResourceManager::getInstance(); + int size; + char *data = (char*)resman->loadFile("items.xml", size); + + if (!data) { + logger->error("Could not find items.xml!"); } - dbFile.close(); - xmlDocPtr doc = xmlParseFile(TMW_DATADIR "data/items.xml"); + xmlDocPtr doc = xmlParseMemory(data, size); + free(data); if (doc) { xmlNodePtr node = xmlDocGetRootElement(doc); @@ -104,7 +105,8 @@ ItemManager::ItemManager() } xmlFreeDoc(doc); - } else { + } + else { logger->error("Error while parsing item database (items.xml)!"); } diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp index ad76f266..b3aa80f6 100644 --- a/src/resources/resource.cpp +++ b/src/resources/resource.cpp @@ -28,6 +28,11 @@ Resource::Resource(): { } +Resource::~Resource() +{ + // TODO: Notify resource manager about this resource being deleted +} + bool Resource::isLoaded() const { return loaded; diff --git a/src/resources/resource.h b/src/resources/resource.h index bd6bfcc5..266b4198 100644 --- a/src/resources/resource.h +++ b/src/resources/resource.h @@ -36,6 +36,11 @@ class Resource Resource(); /** + * Destructor. + */ + virtual ~Resource(); + + /** * Frees this objects internal resources. */ virtual void unload() = 0; |