summaryrefslogtreecommitdiff
path: root/src/common/resourcemanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/resourcemanager.cpp')
-rw-r--r--src/common/resourcemanager.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/common/resourcemanager.cpp b/src/common/resourcemanager.cpp
index 82675c7b..bd6961d9 100644
--- a/src/common/resourcemanager.cpp
+++ b/src/common/resourcemanager.cpp
@@ -49,11 +49,12 @@ void ResourceManager::initialize()
const std::string worldDataPath =
Configuration::getValue("worldDataPath", "example");
+ const std::string serverPath =
+ Configuration::getValue("serverPath", PKG_DATADIR);
// world first to allow overriding of server's libraries
- PHYSFS_addToSearchPath(worldDataPath.c_str(), 1);
- PHYSFS_addToSearchPath(".", 1);
- PHYSFS_addToSearchPath(PKG_DATADIR, 1);
+ PHYSFS_mount(worldDataPath.c_str(), nullptr, 1);
+ PHYSFS_mount(serverPath.c_str(), nullptr, 1);
}
/**
@@ -95,7 +96,7 @@ char *ResourceManager::loadFile(const std::string &fileName, int &fileSize)
if (file == nullptr)
{
LOG_WARN("Failed to load '" << fileName << "': "
- << PHYSFS_getLastError());
+ << PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
return nullptr;
}
@@ -104,11 +105,11 @@ char *ResourceManager::loadFile(const std::string &fileName, int &fileSize)
// Allocate memory and load the file
char *buffer = (char *) malloc(fileSize + 1);
- if (PHYSFS_read(file, buffer, 1, fileSize) != fileSize)
+ if (PHYSFS_readBytes(file, buffer, fileSize) != fileSize)
{
free(buffer);
LOG_WARN("Failed to load '" << fileName << "': "
- << PHYSFS_getLastError());
+ << PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
return nullptr;
}