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 <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 ManagedModel;
51 class StaticMapTree;
52 class WorldModel;
53
54 typedef std::unordered_map<uint32, StaticMapTree*> InstanceTreeMap;
55 typedef std::unordered_map<std::string, ManagedModel*> ModelFileMap;
56
58 {
63 };
64
66 {
67 protected:
68 // Tree to check collision
71 std::unordered_map<uint32, uint32> iParentMapData;
73 // Mutex for iLoadedModelFiles
75
76 static uint32 GetLiquidFlagsDummy(uint32) { return 0; }
77 static bool IsVMAPDisabledForDummy(uint32 /*entry*/, uint8 /*flags*/) { return false; }
78
79 InstanceTreeMap::const_iterator GetMapTree(uint32 mapId) const;
80
81 public:
82 // public for debug
83 G3D::Vector3 convertPositionToInternalRep(float x, float y, float z) const;
84 static std::string getMapFileName(unsigned int mapId);
85
88
89 void InitializeThreadUnsafe(std::unordered_map<uint32, std::vector<uint32>> const& mapData);
90
91 LoadResult loadMap(char const* pBasePath, unsigned int mapId, int x, int y) override;
92
93 void unloadMap(unsigned int mapId, int x, int y) override;
94
95 void unloadMap(unsigned int mapId) override;
96
97 bool isInLineOfSight(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, ModelIgnoreFlags ignoreFlags) override ;
101 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;
102 float getHeight(unsigned int mapId, float x, float y, float z, float maxSearchDist) override;
103
104 bool processCommand(char* /*command*/) override { return false; } // for debug and extensions
105
106 bool getAreaAndLiquidData(uint32 mapId, float x, float y, float z, Optional<uint8> reqLiquidType, AreaAndLiquidData& data) const override;
107
108 WorldModel* acquireModelInstance(std::string const& basepath, std::string const& filename);
109 void releaseModelInstance(std::string const& filename);
110
111 // what's the use of this? o.O
112 virtual std::string getDirFileName(unsigned int mapId, int /*x*/, int /*y*/) const override
113 {
114 return getMapFileName(mapId);
115 }
116 virtual LoadResult existsMap(char const* basePath, unsigned int mapId, int x, int y) override;
117
118 void getInstanceMapTree(InstanceTreeMap &instanceMapTree);
119
120 int32 getParentMapId(uint32 mapId) const;
121
122 typedef uint32(*GetLiquidFlagsFn)(uint32 liquidType);
123 GetLiquidFlagsFn GetLiquidFlagsPtr;
124
125 typedef bool(*IsVMAPDisabledForFn)(uint32 entry, uint8 flags);
126 IsVMAPDisabledForFn IsVMAPDisabledForPtr;
127 };
128}
129
130#endif
uint8_t uint8
Definition: Define.h:144
#define TC_COMMON_API
Definition: Define.h:99
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
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:74
ModelFileMap iLoadedModelFiles
Definition: VMapManager2.h:69
std::unordered_map< uint32, uint32 > iParentMapData
Definition: VMapManager2.h:71
IsVMAPDisabledForFn IsVMAPDisabledForPtr
Definition: VMapManager2.h:126
static bool IsVMAPDisabledForDummy(uint32, uint8)
Definition: VMapManager2.h:77
bool thread_safe_environment
Definition: VMapManager2.h:72
bool processCommand(char *) override
Definition: VMapManager2.h:104
virtual std::string getDirFileName(unsigned int mapId, int, int) const override
Definition: VMapManager2.h:112
InstanceTreeMap iInstanceMapTrees
Definition: VMapManager2.h:70
GetLiquidFlagsFn GetLiquidFlagsPtr
Definition: VMapManager2.h:123
static uint32 GetLiquidFlagsDummy(uint32)
Definition: VMapManager2.h:76
std::unordered_map< uint32, StaticMapTree * > InstanceTreeMap
Definition: VMapManager2.h:54
LoadResult
Definition: IVMapManager.h:35
std::unordered_map< std::string, ManagedModel * > ModelFileMap
Definition: VMapManager2.h:55
DisableTypes
Definition: VMapManager2.h:58
@ VMAP_DISABLE_LIQUIDSTATUS
Definition: VMapManager2.h:62
@ VMAP_DISABLE_LOS
Definition: VMapManager2.h:61
@ VMAP_DISABLE_HEIGHT
Definition: VMapManager2.h:60
@ VMAP_DISABLE_AREAFLAG
Definition: VMapManager2.h:59