town.h

main 109 lines · 2.4 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_TOWN_H_
19#define RME_TOWN_H_
20
21#include "position.h"
22
23class Town {
24public:
25 Town(uint32_t _id) :
26 id(_id), name("") { }
27 Town(const Town& copy) :
28 id(copy.id), name(copy.name), templepos(copy.templepos) { }
29 ~Town() { }
30
31 const std::string& getName() const {
32 return name;
33 }
34 void setName(const std::string& newName) {
35 name = newName;
36 }
37
38 const Position& getTemplePosition() const {
39 return templepos;
40 }
41 void setTemplePosition(const Position& _pos);
42
43 uint32_t getID() const {
44 return id;
45 }
46 void setID(uint32_t _id) {
47 id = _id;
48 }
49
50private:
51 uint32_t id;
52 std::string name;
53 Position templepos;
54};
55
56typedef std::map<uint32_t, Town*> TownMap;
57
58class Towns {
59public:
60 Towns();
61 ~Towns();
62
63 // Clears the townmap
64 void clear();
65
66 uint32_t count() const {
67 return towns.size();
68 }
69
70 bool addTown(Town* town);
71 uint32_t getEmptyID();
72
73 Town* getTown(std::string& townname);
74 Town* getTown(uint32_t _townid);
75
76 TownMap::const_iterator begin() const {
77 return towns.begin();
78 }
79 TownMap::const_iterator end() const {
80 return towns.end();
81 }
82 TownMap::const_iterator find(uint32_t id) const {
83 return towns.find(id);
84 }
85 TownMap::iterator begin() {
86 return towns.begin();
87 }
88 TownMap::iterator end() {
89 return towns.end();
90 }
91 TownMap::iterator find(uint32_t id) {
92 return towns.find(id);
93 }
94#ifdef __VISUALC__ // C++0x compliance to some degree :)
95 TownMap::iterator erase(TownMap::iterator iter) {
96 return towns.erase(iter);
97 }
98#else
99 void erase(TownMap::iterator iter) {
100 towns.erase(iter);
101 }
102#endif
103
104private:
105 TownMap towns;
106};
107
108#endif
109
Top