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 = [](fkyaml::node const& n, char const* key, float& out)
172 {
173 if (n.contains(key)) out = n[key].get_value<float>();
174 };
175 auto tryInt = [](fkyaml::node const& n, char const* key, int& out)
176 {
177 if (n.contains(key)) out = n[key].get_value<int>();
178 };
179 auto tryBoolean = [](fkyaml::node const& n, char const* key, bool& out)
180 {
181 if (n.contains(key)) out = n[key].get_value<bool>();
182 };
183 auto tryString = [](fkyaml::node const& n, char const* key, std::string& out)
184 {
185 if (n.contains(key)) out = n[key].get_value<std::string>();
186 };
187
193
194 if (mmapsNode.contains("offmeshConnections") && mmapsNode["offmeshConnections"].is_sequence())
195 {
196 _offmeshConnections = mmapsNode[
"offmeshConnections"].get_value<std::vector<std::string>>();
197 }
198 else
199 {
201 }
202
203 std::string dataDirPath;
204 tryString(mmapsNode, "dataDir", dataDirPath);
206
207 mmapsNode = mmapsNode["meshSettings"];
208
209
217
218
219 if (mmapsNode.contains("mapsOverrides"))
220 {
221 fkyaml::node maps = mmapsNode["mapsOverrides"];
222 for (auto const& mapEntry : maps.as_map())
223 {
224 uint32 mapId = std::stoi(mapEntry.first.as_str());
225
226 MapOverride override;
227 fkyaml::node mapNode = mapEntry.second;
228
229 if (mapNode.contains("walkableSlopeAngle"))
230 override.walkableSlopeAngle = mapNode["walkableSlopeAngle"].get_value<float>();
231 if (mapNode.contains("walkableRadius"))
232 override.walkableRadius = mapNode["walkableRadius"].get_value<int>();
233 if (mapNode.contains("walkableHeight"))
234 override.walkableHeight = mapNode["walkableHeight"].get_value<int>();
235 if (mapNode.contains("walkableClimb"))
236 override.walkableClimb = mapNode["walkableClimb"].get_value<int>();
237 if (mapNode.contains("verticesPerMapEdge"))
238 override.vertexPerMapEdge = mapNode["verticesPerMapEdge"].get_value<int>();
239 if (mapNode.contains("verticesPerTileEdge"))
240 override.vertexPerTileEdge = mapNode["verticesPerTileEdge"].get_value<int>();
241 if (mapNode.contains("cellSizeHorizontal"))
242 override.cellSizeHorizontal = mapNode["cellSizeHorizontal"].get_value<float>();
243 if (mapNode.contains("cellSizeVertical"))
244 override.cellSizeVertical = mapNode["cellSizeVertical"].get_value<float>();
245
246
247 if (mapNode.contains("tilesOverrides"))
248 {
249 fkyaml::node tiles = mapNode["tilesOverrides"];
250 for (auto const& tileEntry : tiles.as_map())
251 {
252 std::string key = tileEntry.first.as_str();
253 fkyaml::node tileNode = tileEntry.second;
254
255 size_t comma = key.find(',');
256 if (comma == std::string::npos)
257 continue;
258
259 uint32 tileX =
static_cast<uint32>(std::stoi(key.substr(0, comma)));
260 uint32 tileY =
static_cast<uint32>(std::stoi(key.substr(comma + 1)));
261
262 TileOverride tileOverride;
263 if (tileNode.contains("walkableSlopeAngle"))
264 tileOverride.walkableSlopeAngle = tileNode["walkableSlopeAngle"].get_value<float>();
265 if (tileNode.contains("walkableRadius"))
266 tileOverride.walkableRadius = tileNode["walkableRadius"].get_value<int>();
267 if (tileNode.contains("walkableHeight"))
268 tileOverride.walkableHeight = tileNode["walkableHeight"].get_value<int>();
269 if (tileNode.contains("walkableClimb"))
270 tileOverride.walkableClimb = tileNode["walkableClimb"].get_value<int>();
271
272 override.tileOverrides[{tileX, tileY}] = std::move(tileOverride);
273 }
274 }
275
276 _maps[mapId] = std::move(
override);
277 }
278 }
279
280
282 if (
auto execPath = std::filesystem::path(
executableDirectoryPath()); std::filesystem::exists(execPath/
"maps"))
284
285 return true;
286 }
std::uint32_t uint32
Definition Define.h:107
std::string MapsPath() const
Definition Config.h:75
bool _skipContinents
Definition Config.h:152
bool _skipBattlegrounds
Definition Config.h:154
std::vector< std::string > _offmeshConnections
Definition Config.h:159
bool _skipJunkMaps
Definition Config.h:153
bool _skipLiquid
Definition Config.h:151
std::string executableDirectoryPath()
Definition PathCommon.h:39
bool isCurrentDirectory(std::string const &pathStr)
Definition Config.cpp:36