TrinityCore
VMapManager2.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 _VMAPMANAGER2_H
19#define _VMAPMANAGER2_H
20
21#include "Define.h"
22#include "IVMapManager.h"
23#include <memory>
24#include <mutex>
25#include <unordered_map>
26#include <vector>
27
28//===========================================================
29
38//===========================================================
39
40namespace G3D
41{
42 class Vector3;
43}
44
45namespace VMAP
46{
47 class ManagedModel;
48 class StaticMapTree;
49 class WorldModel;
50
51 typedef std::unordered_map<uint32, StaticMapTree*> InstanceTreeMap;
52 typedef std::unordered_map<std::string, std::weak_ptr<ManagedModel>> ModelFileMap;
53
55 {
60 };
61
63 {
64 protected:
65 // Tree to check collision
68 std::unordered_map<uint32, uint32> iParentMapData;
70 // Mutex for iLoadedModelFiles
72
73 static uint32 GetLiquidFlagsDummy(uint32) { return 0; }
74 static bool IsVMAPDisabledForDummy(uint32 /*entry*/, uint8 /*flags*/) { return false; }
75
76 InstanceTreeMap::const_iterator GetMapTree(uint32 mapId) const;
77
78 public:
79 // public for debug
80 G3D::Vector3 convertPositionToInternalRep(float x, float y, float z) const;
81 static std::string getMapFileName(unsigned int mapId);
82
85
86 void InitializeThreadUnsafe(std::unordered_map<uint32, std::vector<uint32>> const& mapData);
87
88 LoadResult loadMap(char const* pBasePath, unsigned int mapId, int x, int y) override;
89
90 void unloadMap(unsigned int mapId, int x, int y) override;
91
92 void unloadMap(unsigned int mapId) override;
93
94 bool isInLineOfSight(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, ModelIgnoreFlags ignoreFlags) override ;
98 bool getObjectHitPos(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float& ry, float& rz, float modifyDist) override;
99 float getHeight(unsigned int mapId, float x, float y, float z, float maxSearchDist) override;
100
101 bool processCommand(char* /*command*/) override { return false; } // for debug and extensions
102
103 bool getAreaAndLiquidData(uint32 mapId, float x, float y, float z, Optional<uint8> reqLiquidType, AreaAndLiquidData& data) const override;
104
105 std::shared_ptr<WorldModel> acquireModelInstance(std::string const& basepath, std::string const& filename);
106 void releaseModelInstance(std::string const& filename);
107
108 // what's the use of this? o.O
109 virtual std::string getDirFileName(unsigned int mapId, int /*x*/, int /*y*/) const override
110 {
111 return getMapFileName(mapId);
112 }
113 virtual LoadResult existsMap(char const* basePath, unsigned int mapId, int x, int y) override;
114
115 void getInstanceMapTree(InstanceTreeMap &instanceMapTree);
116
117 int32 getParentMapId(uint32 mapId) const;
118
119 typedef uint32(*GetLiquidFlagsFn)(uint32 liquidType);
120 GetLiquidFlagsFn GetLiquidFlagsPtr;
121
122 typedef bool(*IsVMAPDisabledForFn)(uint32 entry, uint8 flags);
123 IsVMAPDisabledForFn IsVMAPDisabledForPtr;
124 };
125}
126
127#endif
uint8_t uint8
Definition: Define.h:150
#define TC_COMMON_API
Definition: Define.h:99
int32_t int32
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:148
uint16 flags
Definition: DisableMgr.cpp:49
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
std::mutex LoadedModelFilesLock
Definition: VMapManager2.h:71
ModelFileMap iLoadedModelFiles
Definition: VMapManager2.h:66
std::unordered_map< uint32, uint32 > iParentMapData
Definition: VMapManager2.h:68
IsVMAPDisabledForFn IsVMAPDisabledForPtr
Definition: VMapManager2.h:123
static bool IsVMAPDisabledForDummy(uint32, uint8)
Definition: VMapManager2.h:74
bool thread_safe_environment
Definition: VMapManager2.h:69
bool processCommand(char *) override
Definition: VMapManager2.h:101
virtual std::string getDirFileName(unsigned int mapId, int, int) const override
Definition: VMapManager2.h:109
InstanceTreeMap iInstanceMapTrees
Definition: VMapManager2.h:67
GetLiquidFlagsFn GetLiquidFlagsPtr
Definition: VMapManager2.h:120
static uint32 GetLiquidFlagsDummy(uint32)
Definition: VMapManager2.h:73
std::unordered_map< uint32, StaticMapTree * > InstanceTreeMap
Definition: VMapManager2.h:51
LoadResult
Definition: IVMapManager.h:35
std::unordered_map< std::string, std::weak_ptr< ManagedModel > > ModelFileMap
Definition: VMapManager2.h:52
DisableTypes
Definition: VMapManager2.h:55
@ VMAP_DISABLE_LIQUIDSTATUS
Definition: VMapManager2.h:59
@ VMAP_DISABLE_LOS
Definition: VMapManager2.h:58
@ VMAP_DISABLE_HEIGHT
Definition: VMapManager2.h:57
@ VMAP_DISABLE_AREAFLAG
Definition: VMapManager2.h:56