mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-22 16:28:28 +00:00
[File Paths] Implement Path Manager (#2440)
* Push up branch for testing * Path manager * Tweaks * Changes * More path work * Update paths for eqemu_server.pl * More path work * Import and export client files * Path remove * More path work * Update eqemu_config.h * Fix tests * Tests disable temp * Update eqemu_config.h * Update .drone.yml * Hook tests back up * Update main.cpp * Platform tests * Fix include * Use std::filesystem on windows * Fix IPCMutex name on windows * std::filesystem changes * Update path_manager.cpp * Explicit string cast * Explicit string cast * Update path_manager.cpp * Windows fixes * Mapped files * Relative fixes * Use relative paths off of cwd * Update Debian image to Debian 11 (updates GCC) Co-authored-by: hg <4683435+hgtw@users.noreply.github.com>
This commit is contained in:
+7
-25
@@ -4,21 +4,14 @@
|
||||
#include "water_map_v1.h"
|
||||
#include "water_map_v2.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/file.h"
|
||||
#include "../common/path_manager.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
inline bool file_exists(const std::string& name) {
|
||||
std::ifstream f(name.c_str());
|
||||
return f.good();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param zone_name
|
||||
* @return
|
||||
@@ -26,18 +19,7 @@ inline bool file_exists(const std::string& name) {
|
||||
WaterMap* WaterMap::LoadWaterMapfile(std::string zone_name) {
|
||||
std::transform(zone_name.begin(), zone_name.end(), zone_name.begin(), ::tolower);
|
||||
|
||||
std::string filename;
|
||||
if (file_exists("maps")) {
|
||||
filename = "maps";
|
||||
}
|
||||
else if (file_exists("Maps")) {
|
||||
filename = "Maps";
|
||||
}
|
||||
else {
|
||||
filename = Config->MapDir;
|
||||
}
|
||||
|
||||
std::string file_path = filename + "/water/" + zone_name + std::string(".wtr");
|
||||
std::string file_path = fmt::format("{}/water/{}.wtr", path.GetMapsPath(), zone_name);
|
||||
LogDebug("Attempting to load water map with path [{}]", file_path.c_str());
|
||||
FILE *f = fopen(file_path.c_str(), "rb");
|
||||
if(f) {
|
||||
@@ -48,19 +30,19 @@ WaterMap* WaterMap::LoadWaterMapfile(std::string zone_name) {
|
||||
fclose(f);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
if(strncmp(magic, "EQEMUWATER", 10)) {
|
||||
LogDebug("Failed to load water map, bad magic string in header");
|
||||
fclose(f);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
if(fread(&version, sizeof(version), 1, f) != 1) {
|
||||
LogDebug("Failed to load water map, error reading version");
|
||||
fclose(f);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
LogDebug("Attempting to V[{}] load water map [{}]", version, file_path.c_str());
|
||||
if(version == 1) {
|
||||
auto wm = new WaterMapV1();
|
||||
@@ -90,7 +72,7 @@ WaterMap* WaterMap::LoadWaterMapfile(std::string zone_name) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LogDebug("Failed to load water map, could not open file for reading [{}]", file_path.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user