mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
Fix water map loading case sensitivity issues when using lowercase water maps like the rest of the map code
This commit is contained in:
parent
0643df3dbe
commit
4b6a1242f5
4
.gitignore
vendored
4
.gitignore
vendored
@ -33,4 +33,6 @@ perl/
|
||||
*cbp
|
||||
|
||||
submodules/*
|
||||
cmake-build-debug/
|
||||
cmake-build-debug/
|
||||
|
||||
.nfs.*
|
||||
55
zone/map.cpp
55
zone/map.cpp
@ -242,46 +242,65 @@ bool Map::Load(std::string filename, bool force_mmf_overwrite)
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
bool Map::Load(std::string filename)
|
||||
|
||||
/**
|
||||
* @param filename
|
||||
* @return
|
||||
*/
|
||||
bool Map::Load(const std::string &filename)
|
||||
{
|
||||
#endif /*USE_MAP_MMFS*/
|
||||
|
||||
FILE *f = fopen(filename.c_str(), "rb");
|
||||
if(f) {
|
||||
FILE *map_file = fopen(filename.c_str(), "rb");
|
||||
if (map_file) {
|
||||
uint32 version;
|
||||
if(fread(&version, sizeof(version), 1, f) != 1) {
|
||||
fclose(f);
|
||||
if (fread(&version, sizeof(version), 1, map_file) != 1) {
|
||||
fclose(map_file);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(version == 0x01000000) {
|
||||
|
||||
if (version == 0x01000000) {
|
||||
LogInfo("Loaded V1 Map File [{}]", filename.c_str());
|
||||
bool v = LoadV1(f);
|
||||
fclose(f);
|
||||
bool loaded_map_file = LoadV1(map_file);
|
||||
fclose(map_file);
|
||||
|
||||
if (loaded_map_file) {
|
||||
LogInfo("Loaded V1 Map File [{}]", filename.c_str());
|
||||
} else {
|
||||
LogError("Failed to load V1 Map File [{}]", filename.c_str());
|
||||
}
|
||||
|
||||
#ifdef USE_MAP_MMFS
|
||||
if (v)
|
||||
return SaveMMF(filename, force_mmf_overwrite);
|
||||
#endif /*USE_MAP_MMFS*/
|
||||
|
||||
return v;
|
||||
} else if(version == 0x02000000) {
|
||||
LogInfo("Loaded V2 Map File [{}]", filename.c_str());
|
||||
bool v = LoadV2(f);
|
||||
fclose(f);
|
||||
return loaded_map_file;
|
||||
}
|
||||
else if (version == 0x02000000) {
|
||||
LogInfo("Loading V2 Map File [{}]", filename.c_str());
|
||||
bool loaded_map_file = LoadV2(map_file);
|
||||
fclose(map_file);
|
||||
|
||||
if (loaded_map_file) {
|
||||
LogInfo("Loaded V2 Map File [{}]", filename.c_str());
|
||||
} else {
|
||||
LogError("Failed to load V2 Map File [{}]", filename.c_str());
|
||||
}
|
||||
|
||||
#ifdef USE_MAP_MMFS
|
||||
if (v)
|
||||
return SaveMMF(filename, force_mmf_overwrite);
|
||||
#endif /*USE_MAP_MMFS*/
|
||||
|
||||
return v;
|
||||
} else {
|
||||
fclose(f);
|
||||
return loaded_map_file;
|
||||
}
|
||||
else {
|
||||
fclose(map_file);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ public:
|
||||
#ifdef USE_MAP_MMFS
|
||||
bool Load(std::string filename, bool force_mmf_overwrite = false);
|
||||
#else
|
||||
bool Load(std::string filename);
|
||||
bool Load(const std::string& filename);
|
||||
#endif
|
||||
|
||||
static Map *LoadMapFile(std::string file);
|
||||
|
||||
@ -10,10 +10,34 @@
|
||||
#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
|
||||
*/
|
||||
WaterMap* WaterMap::LoadWaterMapfile(std::string zone_name) {
|
||||
std::transform(zone_name.begin(), zone_name.end(), zone_name.begin(), ::tolower);
|
||||
|
||||
std::string file_path = Config->MapDir + "water/" + zone_name + std::string(".wtr");
|
||||
|
||||
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");
|
||||
LogDebug("Attempting to load water map with path [{}]", file_path.c_str());
|
||||
FILE *f = fopen(file_path.c_str(), "rb");
|
||||
if(f) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user