Browse Source

Sanity checks to make sure Maps directory and Regions directory exists

Image 3 years ago
parent
commit
841f367139
2 changed files with 14 additions and 0 deletions
  1. 7 0
      EQ2/source/WorldServer/Zone/map.cpp
  2. 7 0
      EQ2/source/WorldServer/Zone/region_map.cpp

+ 7 - 0
EQ2/source/WorldServer/Zone/map.cpp

@@ -673,6 +673,13 @@ void Map::TranslateVertex(glm::vec3 &v, float tx, float ty, float tz) {
 void MapRange::AddVersionRange(std::string zoneName) {
   boost::filesystem::path targetDir("Maps/");
 
+  // crash fix since the dir isn't present
+  if(!boost::filesystem::is_directory(targetDir))
+  {
+	LogWrite(MAP__ERROR, 7, "Map", "Unable to find directory %s", targetDir.c_str());
+  	return;
+  }
+
   boost::filesystem::recursive_directory_iterator iter(targetDir), eod;
   boost::smatch base_match;
   std::string formula = "(.*\\/|.*\\\\)((" + zoneName + ")(\\-([0-9]+)\\-([0-9]+))?)(\\.EQ2Map|\\.EQ2MapDeflated)$";

+ 7 - 0
EQ2/source/WorldServer/Zone/region_map.cpp

@@ -85,6 +85,13 @@ RegionMap* RegionMap::LoadRegionMapfile(std::string filename, std::string zone_n
 void RegionMapRange::AddVersionRange(std::string zoneName) {
   boost::filesystem::path targetDir("Regions/");
 
+  // crash fix since the dir isn't present
+  if(!boost::filesystem::is_directory(targetDir))
+  {
+	LogWrite(REGION__ERROR, 7, "Region", "Unable to find directory %s", targetDir.c_str());
+  	return;
+  }
+
   boost::filesystem::recursive_directory_iterator iter(targetDir), eod;
   boost::smatch base_match;
   std::string formula = "(.*\\/|.*\\\\)((" + zoneName + ")(\\-([0-9]+)\\-([0-9]+))?)\\.EQ2Region$";