2020#include " IntermediateValues.h"
2121#include " MMapDefines.h"
2222#include " MapTree.h"
23+ #include " Memory.h"
2324#include " ModelInstance.h"
2425#include " PathCommon.h"
2526#include " StringFormat.h"
@@ -60,7 +61,6 @@ namespace MMAP
6061 bool debugOutput, bool bigBaseUnit, int mapid, char const * offMeshFilePath, unsigned int threads) :
6162 m_terrainBuilder (nullptr ),
6263 m_debugOutput (debugOutput),
63- m_offMeshFilePath (offMeshFilePath),
6464 m_threads (threads),
6565 m_skipContinents (skipContinents),
6666 m_skipJunkMaps (skipJunkMaps),
@@ -83,6 +83,8 @@ namespace MMAP
8383 m_threads = std::max (1u , m_threads);
8484
8585 discoverTiles ();
86+
87+ ParseOffMeshConnectionsFile (offMeshFilePath);
8688 }
8789
8890 /* *************************************************************************/
@@ -193,6 +195,41 @@ namespace MMAP
193195 }
194196 }
195197
198+ /* *************************************************************************/
199+ void MapBuilder::ParseOffMeshConnectionsFile (char const * offMeshFilePath)
200+ {
201+ // no meshfile input given?
202+ if (offMeshFilePath == nullptr )
203+ return ;
204+
205+ auto fp = Trinity::make_unique_ptr_with_deleter (fopen (offMeshFilePath, " rb" ), &::fclose);
206+ if (!fp)
207+ {
208+ printf (" loadOffMeshConnections:: input file %s not found!\n " , offMeshFilePath);
209+ return ;
210+ }
211+
212+ char buf[512 ] = { };
213+ while (fgets (buf, 512 , fp.get ()))
214+ {
215+ OffMeshData offMesh;
216+ int32 scanned = sscanf (buf, " %u %u,%u (%f %f %f) (%f %f %f) %f %hhu %hu" , &offMesh.MapId , &offMesh.TileX , &offMesh.TileY ,
217+ &offMesh.From [0 ], &offMesh.From [1 ], &offMesh.From [2 ], &offMesh.To [0 ], &offMesh.To [1 ], &offMesh.To [2 ],
218+ &offMesh.Radius , &offMesh.AreaId , &offMesh.Flags );
219+ if (scanned < 10 )
220+ continue ;
221+
222+ offMesh.Bidirectional = true ;
223+ if (scanned < 12 )
224+ offMesh.Flags = NAV_GROUND;
225+
226+ if (scanned < 11 )
227+ offMesh.AreaId = NAV_AREA_GROUND;
228+
229+ m_offMeshConnections.push_back (offMesh);
230+ }
231+ }
232+
196233 /* *************************************************************************/
197234 std::set<uint32>* MapBuilder::getTileList (uint32 mapID)
198235 {
@@ -508,7 +545,7 @@ namespace MMAP
508545 float bmin[3 ], bmax[3 ];
509546 m_mapBuilder->getTileBounds (tileX, tileY, allVerts.getCArray (), allVerts.size () / 3 , bmin, bmax);
510547
511- m_terrainBuilder->loadOffMeshConnections (mapID, tileX, tileY, meshData, m_mapBuilder->m_offMeshFilePath );
548+ m_terrainBuilder->loadOffMeshConnections (mapID, tileX, tileY, meshData, m_mapBuilder->m_offMeshConnections );
512549
513550 // build navmesh tile
514551 buildMoveMapTile (mapID, tileX, tileY, meshData, bmin, bmax, navMesh);
0 commit comments