Fix water map loading case sensitivity issues when using lowercase water maps like the rest of the map code

This commit is contained in:
Akkadius
2019-12-28 22:45:35 -06:00
parent 0643df3dbe
commit 4b6a1242f5
4 changed files with 67 additions and 22 deletions
+26 -2
View 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) {