28 {
29
31
32 FILE* file = fopen(fileName.c_str(), "rb");
33 if (!file)
34 {
35 LOG_DEBUG(
"maps",
"MMAP:loadMapData: Error: Could not open mmap file '{}'", fileName);
36 return nullptr;
37 }
38
39 dtNavMeshParams params;
40 uint32 count =
uint32(fread(¶ms,
sizeof(dtNavMeshParams), 1, file));
41 fclose(file);
42 if (count != 1)
43 {
44 LOG_DEBUG(
"maps",
"MMAP:loadMapData: Error: Could not read params from file '{}'", fileName);
45 return nullptr;
46 }
47
48 dtNavMesh* mesh = dtAllocNavMesh();
50 if (DT_SUCCESS != mesh->init(¶ms))
51 {
52 dtFreeNavMesh(mesh);
53 LOG_ERROR(
"maps",
"MMAP:loadMapData: Failed to initialize dtNavMesh for mmap {:03} from file {}", mapId, fileName);
54 return nullptr;
55 }
56
57 LOG_DEBUG(
"maps",
"MMAP:loadMapData: Loaded {:03}.mmap", mapId);
58
59 std::shared_ptr<dtNavMesh> navMesh = std::shared_ptr<dtNavMesh>(mesh, NavMeshDeleter());
60 return navMesh;
61 }
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:158
#define LOG_DEBUG(filterType__,...)
Definition Log.h:170
#define sConfigMgr
Definition Config.h:93
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition StringFormat.h:44
static char const *const MAP_FILE_NAME_FORMAT
Definition MMapMgr.h:48