TrinityCore
Loading...
Searching...
No Matches
MMapManager.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _MMAP_MANAGER_H
19#define _MMAP_MANAGER_H
20
21#include "Define.h"
22#include "MMapDefines.h"
23#include <DetourNavMeshQuery.h>
24#include <memory>
25#include <string_view>
26#include <unordered_map>
27#include <vector>
28
29// move map related classes
30namespace MMAP
31{
32 struct MMapData;
33
34 typedef std::unordered_map<uint32, std::unique_ptr<MMapData>> MMapDataSet;
35
45
46 // singleton class
47 // holds all all access to mmap loading unloading and meshes
49 {
50 public:
52 MMapManager(MMapManager const& other) = delete;
53 MMapManager(MMapManager&& other) noexcept = delete;
54 MMapManager& operator=(MMapManager const& other) = delete;
55 MMapManager& operator=(MMapManager&& other) noexcept = delete;
57
58 static MMapManager* instance();
59
60 void InitializeThreadUnsafe(std::unordered_map<uint32, std::vector<uint32>> const& mapData);
61 static LoadResult parseNavMeshParamsFile(std::string_view basePath, uint32 mapId, dtNavMeshParams* params, std::vector<OffMeshData>* offmeshConnections = nullptr);
62 LoadResult loadMap(std::string_view basePath, uint32 mapId, uint32 instanceId, int32 x, int32 y);
63 bool loadMapInstance(std::string_view basePath, uint32 meshMapId, uint32 instanceMapId, uint32 instanceId);
64 void unloadMap(uint32 mapId, int32 x, int32 y);
65 void unloadMap(uint32 mapId);
66 void unloadMapInstance(uint32 meshMapId, uint32 instanceMapId, uint32 instanceId);
67
68 // the returned [dtNavMeshQuery const*] is NOT threadsafe
69 dtNavMeshQuery const* GetNavMeshQuery(uint32 meshMapId, uint32 instanceMapId, uint32 instanceId);
70 dtNavMesh* GetNavMesh(uint32 mapId, uint32 instanceId);
71
72 uint32 getLoadedTilesCount() const { return loadedTiles; }
73 uint32 getLoadedMapsCount() const { return uint32(loadedMMaps.size()); }
74
75 static bool isRebuildingTilesEnabledOnMap(uint32 mapId);
76
77 private:
78 LoadResult loadMapData(std::string_view basePath, uint32 mapId, uint32 instanceId);
79 uint32 packTileID(int32 x, int32 y);
80
81 MMapDataSet::const_iterator GetMMapData(uint32 mapId) const;
83 uint32 loadedTiles = 0;
84
85 std::unordered_map<uint32, uint32> parentMapData;
86 };
87}
88
89#endif
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
#define TC_MMAPS_COMMON_API
Definition Define.h:135
uint32_t uint32
Definition Define.h:154
std::unordered_set< uint32 > params[2]
uint32 getLoadedMapsCount() const
Definition MMapManager.h:73
MMapManager & operator=(MMapManager &&other) noexcept=delete
std::unordered_map< uint32, uint32 > parentMapData
Definition MMapManager.h:85
MMapManager(MMapManager &&other) noexcept=delete
MMapDataSet loadedMMaps
Definition MMapManager.h:82
MMapManager & operator=(MMapManager const &other)=delete
MMapManager(MMapManager const &other)=delete
uint32 getLoadedTilesCount() const
Definition MMapManager.h:72
std::unordered_map< uint32, std::unique_ptr< MMapData > > MMapDataSet
Definition MMapManager.h:34