summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-04-26 00:04:45 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-04-26 00:04:45 +0000
commit8b0e30d3798cd5bdce2c3a34a3c384e90dceac99 (patch)
tree3fdca13a0cc138ed65b72de8cd3747cc79916818 /src/resources
parenta31ba215a3043ebd62d415a7d855a531239fb630 (diff)
downloadmana-8b0e30d3798cd5bdce2c3a34a3c384e90dceac99.tar.gz
mana-8b0e30d3798cd5bdce2c3a34a3c384e90dceac99.tar.bz2
mana-8b0e30d3798cd5bdce2c3a34a3c384e90dceac99.tar.xz
mana-8b0e30d3798cd5bdce2c3a34a3c384e90dceac99.zip
Changed keyboard control to integrate better with mouse walk, changed location
of packet.list and chatlog.txt and removed name from player chat "balloon".
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/resourcemanager.cpp11
-rw-r--r--src/resources/resourcemanager.h35
2 files changed, 31 insertions, 15 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index b26aeb5d..8606816e 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -286,16 +286,19 @@ void *ResourceManager::loadFile(const std::string &fileName, int &fileSize)
PHYSFS_file* file = PHYSFS_openRead(fileName.c_str());
// If the handler is an invalid pointer indicate failure
- if (file == NULL) return NULL;
+ if (file == NULL) {
+ logger.log("Warning: %s failed to load!", fileName.c_str());
+ return NULL;
+ }
- // Print file information message
+ // Get the size of the file
fileSize = PHYSFS_fileLength(file);
- // Allocate memory in the buffer and load the file
+ // Allocate memory and load the file
void *buffer = malloc(fileSize);
PHYSFS_read(file, buffer, 1, fileSize);
- // Close the file and let the user deallocate the memory (safe?)
+ // Close the file and let the user deallocate the memory
PHYSFS_close(file);
return buffer;
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index d8f4cb90..3c72eb43 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -88,13 +88,36 @@ class ResourceManager
int flags = 0);
/**
- * Convenience wrappers around ResourceManager::create.
+ * Convenience wrapper around ResourceManager::create for loading
+ * images.
*/
Image *getImage(const std::string &idPath, int flags = 0);
+
+ /**
+ * Convenience wrapper around ResourceManager::create for loading
+ * songs.
+ */
Music *getMusic(const std::string &idPath);
+
+ /**
+ * Convenience wrapper around ResourceManager::create for loading
+ * samples.
+ */
SoundEffect *getSoundEffect(const std::string &idPath);
/**
+ * Allocates data into a buffer pointer for raw data loading. The
+ * returned data is expected to be freed using <code>free()</code>.
+ *
+ * @param fileName The name of the file to be loaded.
+ * @param fileSize The size of the file that was loaded.
+ *
+ * @return An allocated byte array containing the data that was loaded,
+ * or <code>NULL</code> on fail.
+ */
+ void *loadFile(const std::string &fileName, int &fileSize);
+
+ /**
* Returns an instance of the class, creating one if it does not
* already exist.
*/
@@ -111,16 +134,6 @@ class ResourceManager
*/
void searchAndAddZipFiles();
- /**
- * Allocates data into a buffer pointer for raw data loading
- *
- * @param fileName The name of the file to be loaded
- * @param buffer The empty buffer into which the data will be loaded
- *
- * @return The size of the file that was loaded
- */
- void *loadFile(const std::string &fileName, int &fileSize);
-
static ResourceManager *instance;
std::map<std::string, ResourceEntry> resources;