-
Notifications
You must be signed in to change notification settings - Fork 224
/
map_region.h
135 lines (110 loc) · 3.82 KB
/
map_region.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//////////////////////////////////////////////////////////////////////
// This file is part of Remere's Map Editor
//////////////////////////////////////////////////////////////////////
// Remere's Map Editor is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Remere's Map Editor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////
#ifndef RME_MAP_REGION_H
#define RME_MAP_REGION_H
#include "const.h"
#include "position.h"
class Tile;
class Floor;
class BaseMap;
class TileLocation
{
TileLocation();
public:
~TileLocation();
TileLocation(const TileLocation&) = delete;
TileLocation& operator=(const TileLocation&) = delete;
protected:
Tile* tile;
Position position;
size_t spawn_count;
size_t waypoint_count;
HouseExitList* house_exits; // Any house exits pointing here
public:
// Access tile
// Can't set directly since that does not update tile count
Tile* get() noexcept { return tile; }
const Tile* get() const noexcept { return tile; }
int size() const;
bool empty() const;
const Position& getPosition() const noexcept { return position; }
int getX() const noexcept { return position.x; }
int getY() const noexcept { return position.y; }
int getZ() const noexcept { return position.z; }
size_t getSpawnCount() const noexcept { return spawn_count; }
void increaseSpawnCount() noexcept { spawn_count++; }
void decreaseSpawnCount() noexcept { spawn_count--; }
size_t getWaypointCount() const noexcept { return waypoint_count; }
void increaseWaypointCount() noexcept { waypoint_count++; }
void decreaseWaypointCount() noexcept { waypoint_count--; }
HouseExitList* createHouseExits();
HouseExitList* getHouseExits() noexcept { return house_exits; }
friend class Floor;
friend class QTreeNode;
friend class Waypoints;
};
class Floor
{
public:
Floor(int x, int y, int z);
TileLocation locs[rme::MapLayers];
};
// This is not a QuadTree, but a HexTree (16 child nodes to every node), so the name is abit misleading
class QTreeNode
{
public:
QTreeNode(BaseMap& map);
virtual ~QTreeNode();
QTreeNode(const QTreeNode&) = delete;
QTreeNode& operator=(const QTreeNode&) = delete;
QTreeNode* getLeaf(int x, int y); // Might return nullptr
QTreeNode* getLeafForce(int x, int y); // Will never return nullptr, it will create the node if it's not there
// Coordinates are NOT relative
TileLocation* createTile(int x, int y, int z);
TileLocation* getTile(int x, int y, int z);
Tile* setTile(int x, int y, int z, Tile* tile);
void clearTile(int x, int y, int z);
Floor* createFloor(int x, int y, int z);
Floor* getFloor(uint32_t z) {
ASSERT(isLeaf);
return array[z];
}
Floor** getFloors() {
return array;
}
void setVisible(bool overground, bool underground);
void setVisible(uint32_t client, bool underground, bool value);
bool isVisible(uint32_t client, bool underground);
void clearVisible(uint32_t client);
void setRequested(bool underground, bool r);
bool isVisible(bool underground);
bool isRequested(bool underground);
protected:
BaseMap& map;
uint32_t visible;
bool isLeaf;
union {
QTreeNode* child[rme::MapLayers];
Floor* array[rme::MapLayers];
//#if 16 != rme::MapLayers
//# error "You need to rewrite the QuadTree in order to handle more or less than 16 floors"
//#endif
};
friend class BaseMap;
friend class MapIterator;
};
#endif