1//////////////////////////////////////////////////////////////////////
2// This file is part of Remere's Map Editor
3//////////////////////////////////////////////////////////////////////
4// Remere's Map Editor is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Remere's Map Editor is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//////////////////////////////////////////////////////////////////////
17
18#ifndef RME_MAP_ALLOCATOR_H
19#define RME_MAP_ALLOCATOR_H
20
21#include "tile.h"
22#include "map_region.h"
23
24class BaseMap;
25
26class MapAllocator {
27
28public:
29 MapAllocator() { }
30 ~MapAllocator() { }
31
32 // shorthands for tiles
33 Tile* operator()(TileLocation* location) {
34 return allocateTile(location);
35 }
36 // free
37 void operator()(Tile* t) {
38 freeTile(t);
39 }
40
41 //
42 Tile* allocateTile(TileLocation* location) {
43 return newd Tile(*location);
44 }
45 void freeTile(Tile* t) {
46 delete t;
47 }
48
49 //
50 Floor* allocateFloor(int x, int y, int z) {
51 return newd Floor(x, y, z);
52 }
53 void freeFloor(Floor* f) {
54 delete f;
55 }
56
57 //
58 QTreeNode* allocateNode(BaseMap& map) {
59 return newd QTreeNode(map);
60 }
61 void freeNode(QTreeNode* qt) {
62 delete qt;
63 }
64};
65
66#endif
67