summaryrefslogtreecommitdiff
path: root/src/resources
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
parent4ecc89dcc6516b10c6dab8b79dcaa435ec9e1435 (diff)
downloadmana-client-06111415b117fc47b5b8bf6396d855616778f3b0.tar.gz
mana-client-06111415b117fc47b5b8bf6396d855616778f3b0.tar.bz2
mana-client-06111415b117fc47b5b8bf6396d855616778f3b0.tar.xz
mana-client-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')
-rw-r--r--src/resources/resourcemanager.cpp74
-rw-r--r--src/resources/resourcemanager.h6
2 files changed, 21 insertions, 59 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);
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index f95acadc..e3ad1e94 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -42,11 +42,11 @@ class ResourceManager
*/
enum E_RESOURCE_TYPE
{
- MAP,
+ //MAP,
MUSIC,
IMAGE,
- SCRIPT,
- TILESET,
+ //SCRIPT,
+ //TILESET,
SOUND_EFFECT
};