summaryrefslogtreecommitdiff
path: root/src/resources/resourcemanager.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-07-14 00:41:48 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-07-14 00:41:48 +0000
commit06111415b117fc47b5b8bf6396d855616778f3b0 (patch)
tree54d21336701541b77750554e248b9a92dcba95c6 /src/resources/resourcemanager.cpp
parent4ecc89dcc6516b10c6dab8b79dcaa435ec9e1435 (diff)
downloadmana-06111415b117fc47b5b8bf6396d855616778f3b0.tar.gz
mana-06111415b117fc47b5b8bf6396d855616778f3b0.tar.bz2
mana-06111415b117fc47b5b8bf6396d855616778f3b0.tar.xz
mana-06111415b117fc47b5b8bf6396d855616778f3b0.zip
Committed resource manager cleanup patch by Doener, and properly implemented
the custom mouse cursor option, which is now also dynamically changeable through the setup window.
Diffstat (limited to 'src/resources/resourcemanager.cpp')
-rw-r--r--src/resources/resourcemanager.cpp74
1 files changed, 18 insertions, 56 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index a884f63e..50d0f4b8 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -84,82 +84,44 @@ ResourceManager::get(const E_RESOURCE_TYPE &type, const std::string &idPath)
logger->log("ResourceManager::get(%s)", idPath.c_str());
+ int fileSize;
+ void *buffer = loadFile(idPath, fileSize);
+
+ if (!buffer) {
+ logger->log("Warning: resource doesn't exist!");
+ return NULL;
+ }
+
Resource *resource = NULL;
// Create an object of the specified type.
switch (type)
{
- case MAP:
- logger->log("Warning: Map resource not supported.");
- break;
case MUSIC:
{
- // Load the music resource file
- int fileSize;
- void *buffer = loadFile(idPath, fileSize);
-
- if (buffer != NULL)
- {
- // Let the music class load it
- resource = Music::load(buffer, fileSize);
-
- // Cleanup
- free(buffer);
- }
- else {
- logger->log("Warning: resource doesn't exist!");
- }
+ // Let the music class load it
+ resource = Music::load(buffer, fileSize);
}
break;
case IMAGE:
{
- // Load the image resource file
- int fileSize;
- void *buffer = loadFile(idPath, fileSize);
-
- if (buffer != NULL)
- {
- // Let the image class load it
- resource = Image::load(buffer, fileSize);
-
- // Cleanup
- free(buffer);
- }
- else {
- logger->log("Warning: resource doesn't exist!");
- }
+ // Let the image class load it
+ resource = Image::load(buffer, fileSize);
}
break;
- case SCRIPT:
- logger->log("Warning: Script resource not supported.");
- break;
- case TILESET:
- logger->log("Warning: Tileset resource not supported.");
- break;
case SOUND_EFFECT:
{
- // Load the sample resource file
- int fileSize;
- void *buffer = loadFile(idPath, fileSize);
-
- if (buffer != NULL)
- {
- // Let the sound effect class load it
- resource = SoundEffect::load(buffer, fileSize);
-
- // Cleanup
- free(buffer);
- }
- else {
- logger->log("Warning: resource doesn't exist!");
- }
+ // Let the sound effect class load it
+ resource = SoundEffect::load(buffer, fileSize);
}
break;
- default:
- logger->log("Warning: Unknown resource type");
+ default:
+ /* Nothing to do here, just avoid compiler warnings... */
break;
}
+ free(buffer);
+
if (resource) {
resource->incRef();
resource->setIdPath(idPath);