158 {
159 FILE* f = std::fopen(configFile.data(), "r");
160 if (!f)
161 return false;
162
163 fkyaml::node root = fkyaml::node::deserialize(f);
164 std::fclose(f);
165
166 if (!root.contains("mmapsConfig"))
167 return false;
168
169 fkyaml::node mmapsNode = root["mmapsConfig"];
170
171 auto tryFloat = [](const fkyaml::node& n, const char* key, float& out)
172 {
173 if (n.contains(key)) out = n[key].get_value<float>();
174 };
175 auto tryInt = [](const fkyaml::node& n, const char* key, int& out)
176 {
177 if (n.contains(key)) out = n[key].get_value<int>();
178 };
179 auto tryBoolean = [](const fkyaml::node& n, const char* key, bool& out)
180 {
181 if (n.contains(key)) out = n[key].get_value<bool>();
182 };
183 auto tryString = [](const fkyaml::node& n, const char* key, std::string& out)
184 {
185 if (n.contains(key)) out = n[key].get_value<std::string>();
186 };
187
193
194 std::string dataDirPath;
195 tryString(mmapsNode, "dataDir", dataDirPath);
197
198 mmapsNode = mmapsNode["meshSettings"];
199
200
208
209
210 if (mmapsNode.contains("mapsOverrides"))
211 {
212 fkyaml::node maps = mmapsNode["mapsOverrides"];
213 for (auto const& mapEntry : maps.as_map())
214 {
215 uint32 mapId = std::stoi(mapEntry.first.as_str());
216
217 MapOverride override;
218 fkyaml::node mapNode = mapEntry.second;
219
220 if (mapNode.contains("walkableSlopeAngle"))
221 override.walkableSlopeAngle = mapNode["walkableSlopeAngle"].get_value<float>();
222 if (mapNode.contains("walkableRadius"))
223 override.walkableRadius = mapNode["walkableRadius"].get_value<int>();
224 if (mapNode.contains("walkableHeight"))
225 override.walkableHeight = mapNode["walkableHeight"].get_value<int>();
226 if (mapNode.contains("walkableClimb"))
227 override.walkableClimb = mapNode["walkableClimb"].get_value<int>();
228 if (mapNode.contains("vertexPerMapEdge"))
229 override.vertexPerMapEdge = mapNode["vertexPerMapEdge"].get_value<int>();
230 if (mapNode.contains("cellSizeHorizontal"))
231 override.cellSizeHorizontal = mapNode["cellSizeHorizontal"].get_value<float>();
232 if (mapNode.contains("cellSizeVertical"))
233 override.cellSizeVertical = mapNode["cellSizeVertical"].get_value<float>();
234
235
236 if (mapNode.contains("tilesOverrides"))
237 {
238 fkyaml::node tiles = mapNode["tilesOverrides"];
239 for (auto const& tileEntry : tiles.as_map())
240 {
241 std::string key = tileEntry.first.as_str();
242 fkyaml::node tileNode = tileEntry.second;
243
244 size_t comma = key.find(',');
245 if (comma == std::string::npos)
246 continue;
247
248 uint32 tileX =
static_cast<uint32>(std::stoi(key.substr(0, comma)));
249 uint32 tileY =
static_cast<uint32>(std::stoi(key.substr(comma + 1)));
250
251 TileOverride tileOverride;
252 if (tileNode.contains("walkableSlopeAngle"))
253 tileOverride.walkableSlopeAngle = tileNode["walkableSlopeAngle"].get_value<float>();
254 if (tileNode.contains("walkableRadius"))
255 tileOverride.walkableRadius = tileNode["walkableRadius"].get_value<int>();
256 if (tileNode.contains("walkableHeight"))
257 tileOverride.walkableHeight = tileNode["walkableHeight"].get_value<int>();
258 if (tileNode.contains("walkableClimb"))
259 tileOverride.walkableClimb = tileNode["walkableClimb"].get_value<int>();
260
261 override.tileOverrides[{tileX, tileY}] = std::move(tileOverride);
262 }
263 }
264
265 _maps[mapId] = std::move(
override);
266 }
267 }
268
269
271 if (
auto execPath = std::filesystem::path(
executableDirectoryPath()); std::filesystem::exists(execPath/
"maps"))
273
274 return true;
275 }
std::uint32_t uint32
Definition Define.h:107
std::string MapsPath() const
Definition Config.h:75
bool _skipContinents
Definition Config.h:150
bool _skipBattlegrounds
Definition Config.h:152
bool _skipJunkMaps
Definition Config.h:151
bool _skipLiquid
Definition Config.h:149
bool isCurrentDirectory(const std::string &pathStr)
Definition Config.cpp:36
std::string executableDirectoryPath()
Definition PathCommon.h:39