TrinityCore
Loading...
Searching...
No Matches
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 <mutex>
22#include <unordered_map>
23#include <vector>
24#include "Define.h"
25#include "IVMapManager.h"
26
27//===========================================================
28
29#define MAP_FILENAME_EXTENSION2 ".vmtree"
30
31#define FILENAMEBUFFER_SIZE 500
32
41//===========================================================
42
43namespace G3D
44{
45 class Vector3;
46}
47
48namespace VMAP
49{
50 class StaticMapTree;
51 class WorldModel;
52
54 {
55 public:
56 ManagedModel() : iModel(nullptr), iRefCount(0) { }
57 void setModel(WorldModel* model) { iModel = model; }
58 WorldModel* getModel() { return iModel; }
59 void incRefCount() { ++iRefCount; }
60 int decRefCount() { return --iRefCount; }
61 protected:
64 };
65
66 typedef std::unordered_map<uint32, StaticMapTree*> InstanceTreeMap;
67 typedef std::unordered_map<std::string, ManagedModel> ModelFileMap;
68
76
78 {
79 protected:
80 // Tree to check collision
84 // Mutex for iLoadedModelFiles
86
87 bool _loadMap(uint32 mapId, const std::string& basePath, uint32 tileX, uint32 tileY);
88 /* void _unloadMap(uint32 pMapId, uint32 x, uint32 y); */
89
90 static uint32 GetLiquidFlagsDummy(uint32) { return 0; }
91 static bool IsVMAPDisabledForDummy(uint32 /*entry*/, uint8 /*flags*/) { return false; }
92
93 InstanceTreeMap::const_iterator GetMapTree(uint32 mapId) const;
94
95 public:
96 // public for debug
97 G3D::Vector3 convertPositionToInternalRep(float x, float y, float z) const;
98 static std::string getMapFileName(unsigned int mapId);
99
100 VMapManager2();
101 ~VMapManager2(void);
102
103 void InitializeThreadUnsafe(const std::vector<uint32>& mapIds);
104 int loadMap(char const* pBasePath, unsigned int mapId, int x, int y) override;
105
106 void unloadMap(unsigned int mapId, int x, int y) override;
107 void unloadMap(unsigned int mapId) override;
108
109 bool isInLineOfSight(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, ModelIgnoreFlags ignoreFlags) override ;
113 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;
114 float getHeight(unsigned int mapId, float x, float y, float z, float maxSearchDist) override;
115
116 bool processCommand(char* /*command*/) override { return false; } // for debug and extensions
117
118 bool getAreaAndLiquidData(uint32 mapId, float x, float y, float z, Optional<uint8> reqLiquidType, AreaAndLiquidData& data) const override;
119
120 WorldModel* acquireModelInstance(const std::string& basepath, const std::string& filename, uint32 flags = 0);
121 void releaseModelInstance(const std::string& filename);
122
123 // what's the use of this? o.O
124 virtual std::string getDirFileName(unsigned int mapId, int /*x*/, int /*y*/) const override
125 {
126 return getMapFileName(mapId);
127 }
128 virtual LoadResult existsMap(char const* basePath, unsigned int mapId, int x, int y) override;
129
130 void getInstanceMapTree(InstanceTreeMap &instanceMapTree);
131
132 typedef uint32(*GetLiquidFlagsFn)(uint32 liquidType);
133 GetLiquidFlagsFn GetLiquidFlagsPtr;
134
135 typedef bool(*IsVMAPDisabledForFn)(uint32 entry, uint8 flags);
136 IsVMAPDisabledForFn IsVMAPDisabledForPtr;
137 };
138}
139
140#endif
uint8_t uint8
Definition Define.h:135
#define TC_COMMON_API
Definition Define.h:96
uint32_t uint32
Definition Define.h:133
uint16 flags
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
WorldModel * getModel()
WorldModel * iModel
void setModel(WorldModel *model)
std::mutex LoadedModelFilesLock
ModelFileMap iLoadedModelFiles
IsVMAPDisabledForFn IsVMAPDisabledForPtr
static bool IsVMAPDisabledForDummy(uint32, uint8)
bool processCommand(char *) override
virtual std::string getDirFileName(unsigned int mapId, int, int) const override
InstanceTreeMap iInstanceMapTrees
GetLiquidFlagsFn GetLiquidFlagsPtr
static uint32 GetLiquidFlagsDummy(uint32)
std::unordered_map< uint32, StaticMapTree * > InstanceTreeMap
std::unordered_map< std::string, ManagedModel > ModelFileMap
@ VMAP_DISABLE_LIQUIDSTATUS
@ VMAP_DISABLE_LOS
@ VMAP_DISABLE_HEIGHT
@ VMAP_DISABLE_AREAFLAG