house.h

main 125 lines · 2.8 KB Raw
Alex Alex Commit Map Editor 18/10/2026 23:40
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_HOUSE_H_
19#define RME_HOUSE_H_
20
21#include "position.h"
22
23class Map;
24class Tile;
25class Door;
26
27class Houses;
28
29class House {
30public:
31 House(Map& map);
32 ~House();
33
34 uint32_t getID() const {
35 return id;
36 }
37 void setID(uint32_t newId) {
38 this->id = newId;
39 }
40
41 void clean();
42 void addTile(Tile* tile);
43 void removeTile(Tile* tile);
44 size_t size() const;
45 std::string getDescription();
46
47 int rent;
48 // HouseDoorList doorList;
49 std::string name;
50 uint32_t townid;
51 bool guildhall;
52
53 void setExit(const Position& pos);
54 void setExit(Map* map, const Position& pos);
55 Position getExit() const {
56 return exit;
57 }
58 uint8_t getEmptyDoorID() const;
59 Position getDoorPositionByID(uint8_t id) const;
60
61 // Added accessor to retrieve the list of tile positions for export functionality.
62 const PositionList& getTilePositions() const { return tiles; }
63
64private:
65 uint32_t id;
66
67protected:
68 Map* map;
69 PositionList tiles;
70 Position exit;
71
72 friend class Houses;
73};
74
75typedef std::map<uint32_t, House*> HouseMap;
76
77class Houses {
78public:
79 Houses(Map& map);
80 ~Houses();
81
82 uint32_t count() const {
83 return houses.size();
84 }
85
86 HouseMap::iterator begin() {
87 return houses.begin();
88 }
89 HouseMap::iterator end() {
90 return houses.end();
91 }
92 HouseMap::const_iterator begin() const {
93 return houses.begin();
94 }
95 HouseMap::const_iterator end() const {
96 return houses.end();
97 }
98#ifdef __VISUALC__ // C++0x compliance to some degree :)
99 HouseMap::iterator erase(HouseMap::iterator iter) {
100 return houses.erase(iter);
101 }
102#else
103 void erase(HouseMap::iterator iter) {
104 houses.erase(iter);
105 }
106#endif
107 HouseMap::iterator find(uint32_t val) {
108 return houses.find(val);
109 }
110
111 void removeHouse(House* house_to_remove);
112 void changeId(House* house, uint32_t newID);
113 void addHouse(House* new_house);
114 House* getHouse(uint32_t houseid);
115 const House* getHouse(uint32_t houseid) const;
116 uint32_t getEmptyID();
117
118protected:
119 Map& map;
120 uint32_t max_house_id;
121 HouseMap houses;
122};
123
124#endif
125
Top