client_version.h

main 277 lines · 7.1 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_CLIENT_VERSION_H_
19#define RME_CLIENT_VERSION_H_
20
21#include "main.h"
22#include "settings.h"
23
24typedef int ClientVersionID;
25
26// Client versions
27enum ClientVersions {
28 CLIENT_VERSION_NONE = -1,
29 CLIENT_VERSION_ALL = -2,
30 CLIENT_VERSION_750 = 1,
31 CLIENT_VERSION_755 = 2,
32 CLIENT_VERSION_760 = 3,
33 CLIENT_VERSION_770 = 3,
34 CLIENT_VERSION_780 = 4,
35 CLIENT_VERSION_790 = 5,
36 CLIENT_VERSION_792 = 6,
37 CLIENT_VERSION_800 = 7,
38 CLIENT_VERSION_810 = 8,
39 CLIENT_VERSION_811 = 9,
40 CLIENT_VERSION_820 = 10, // After this version, OTBM stores charges as an attribute
41 CLIENT_VERSION_830 = 11,
42 CLIENT_VERSION_840 = 12,
43 CLIENT_VERSION_841 = 13,
44 CLIENT_VERSION_842 = 14,
45 CLIENT_VERSION_850 = 15,
46 CLIENT_VERSION_854_BAD = 16,
47 CLIENT_VERSION_854 = 17,
48 CLIENT_VERSION_855 = 18,
49 CLIENT_VERSION_860_OLD = 19,
50 CLIENT_VERSION_860 = 20,
51 CLIENT_VERSION_861 = 21,
52 CLIENT_VERSION_862 = 22,
53 CLIENT_VERSION_870 = 23,
54 CLIENT_VERSION_871 = 24,
55 CLIENT_VERSION_872 = 25,
56 CLIENT_VERSION_873 = 26,
57 CLIENT_VERSION_900 = 27,
58 CLIENT_VERSION_910 = 28,
59 CLIENT_VERSION_920 = 29,
60 CLIENT_VERSION_940 = 30,
61 CLIENT_VERSION_944_V1 = 31,
62 CLIENT_VERSION_944_V2 = 32,
63 CLIENT_VERSION_944_V3 = 33,
64 CLIENT_VERSION_944_V4 = 34,
65 CLIENT_VERSION_946 = 35,
66 CLIENT_VERSION_950 = 36,
67 CLIENT_VERSION_952 = 37,
68 CLIENT_VERSION_953 = 38,
69 CLIENT_VERSION_954 = 39,
70 CLIENT_VERSION_960 = 40,
71 CLIENT_VERSION_961 = 41,
72 CLIENT_VERSION_963 = 42,
73 CLIENT_VERSION_970 = 43,
74 CLIENT_VERSION_980 = 44,
75 CLIENT_VERSION_981 = 45,
76 CLIENT_VERSION_982 = 46,
77 CLIENT_VERSION_983 = 47,
78 CLIENT_VERSION_985 = 48,
79 CLIENT_VERSION_986 = 49,
80 CLIENT_VERSION_1010 = 50,
81 CLIENT_VERSION_1020 = 51,
82 CLIENT_VERSION_1021 = 52
83};
84
85// OTBM versions
86enum MapVersionID {
87 MAP_OTBM_UNKNOWN = -1,
88 MAP_OTBM_1 = 0,
89 MAP_OTBM_2 = 1,
90 MAP_OTBM_3 = 2,
91 MAP_OTBM_4 = 3,
92};
93
94// The composed version of a otbm file (otbm version, client version)
95struct MapVersion {
96 MapVersion() :
97 otbm(MAP_OTBM_1), client(CLIENT_VERSION_NONE) { }
98 MapVersion(MapVersionID m, ClientVersionID c) :
99 otbm(m), client(c) { }
100 MapVersionID otbm;
101 ClientVersionID client;
102};
103
104enum OtbFormatVersion : uint32_t {
105 OTB_VERSION_1 = 1,
106 OTB_VERSION_2 = 2,
107 OTB_VERSION_3 = 3,
108};
109
110// Represents an OTB version
111struct OtbVersion {
112 // '8.60', '7.40' etc.
113 std::string name;
114 // What file format the OTB is in (version 1..3)
115 OtbFormatVersion format_version;
116 // The minor version ID of the OTB (maps to CLIENT_VERSION in OTServ)
117 ClientVersionID id;
118};
119
120// Formats for the metadata file
121enum DatFormat {
122 DAT_FORMAT_UNKNOWN,
123 DAT_FORMAT_74,
124 DAT_FORMAT_755,
125 DAT_FORMAT_78,
126 DAT_FORMAT_86,
127 DAT_FORMAT_96,
128 DAT_FORMAT_1010,
129 DAT_FORMAT_1050,
130 DAT_FORMAT_1057
131};
132
133enum DatFlags : uint8_t {
134 DatFlagGround = 0,
135 DatFlagGroundBorder = 1,
136 DatFlagOnBottom = 2,
137 DatFlagOnTop = 3,
138 DatFlagContainer = 4,
139 DatFlagStackable = 5,
140 DatFlagForceUse = 6,
141 DatFlagMultiUse = 7,
142 DatFlagWritable = 8,
143 DatFlagWritableOnce = 9,
144 DatFlagFluidContainer = 10,
145 DatFlagSplash = 11,
146 DatFlagNotWalkable = 12,
147 DatFlagNotMoveable = 13,
148 DatFlagBlockProjectile = 14,
149 DatFlagNotPathable = 15,
150 DatFlagPickupable = 16,
151 DatFlagHangable = 17,
152 DatFlagHookSouth = 18,
153 DatFlagHookEast = 19,
154 DatFlagRotateable = 20,
155 DatFlagLight = 21,
156 DatFlagDontHide = 22,
157 DatFlagTranslucent = 23,
158 DatFlagDisplacement = 24,
159 DatFlagElevation = 25,
160 DatFlagLyingCorpse = 26,
161 DatFlagAnimateAlways = 27,
162 DatFlagMinimapColor = 28,
163 DatFlagLensHelp = 29,
164 DatFlagFullGround = 30,
165 DatFlagLook = 31,
166 DatFlagCloth = 32,
167 DatFlagMarket = 33,
168 DatFlagUsable = 34,
169 DatFlagWrappable = 35,
170 DatFlagUnwrappable = 36,
171 DatFlagTopEffect = 37,
172
173 DatFlagFloorChange = 252,
174 DatFlagNoMoveAnimation = 253, // 10.10: real value is 16, but we need to do this for backwards compatibility
175 DatFlagChargeable = 254,
176 DatFlagLast = 255
177};
178
179// Represents a client file version
180struct ClientData {
181 DatFormat datFormat;
182 uint32_t datSignature;
183 uint32_t sprSignature;
184};
185
186// typedef the client version
187class ClientVersion;
188typedef std::vector<ClientVersion*> ClientVersionList;
189
190class ClientVersion : boost::noncopyable {
191public:
192 ClientVersion(OtbVersion otb, std::string versionName, wxString path);
193 ~ClientVersion() = default;
194
195 static void loadVersions();
196 static void unloadVersions();
197 static void saveVersions();
198
199 static ClientVersion* get(ClientVersionID id);
200 static ClientVersion* get(std::string name);
201 static ClientVersionList getVisible(std::string from, std::string to);
202 static ClientVersionList getAll();
203 static ClientVersionList getAllVisible();
204 static ClientVersionList getAllForOTBMVersion(MapVersionID map_version);
205 static ClientVersionList getAllVersionsSupportedForClientVersion(ClientVersion* v);
206 static ClientVersion* getLatestVersion();
207
208 bool operator==(const ClientVersion& o) const {
209 return otb.id == o.otb.id;
210 }
211
212 bool hasValidPaths();
213 bool loadValidPaths();
214 void setClientPath(const FileName& dir);
215
216 bool isVisible() const;
217 std::string getName() const;
218
219 ClientVersionID getID() const;
220 MapVersionID getPrefferedMapVersionID() const;
221 OtbVersion getOTBVersion() const;
222 DatFormat getDatFormatForSignature(uint32_t signature) const;
223 ClientVersionList getExtensionsSupported() const;
224
225 FileName getDataPath() const;
226 FileName getLocalDataPath() const;
227 FileName getClientPath() const {
228 return client_path;
229 }
230 wxFileName getMetadataPath() const {
231 return metadata_path;
232 }
233 wxFileName getSpritesPath() const {
234 return sprites_path;
235 }
236
237private:
238 OtbVersion otb;
239
240 std::string name;
241 bool visible;
242 bool usesFuckedUpCharges;
243
244 std::vector<MapVersionID> map_versions_supported;
245 MapVersionID preferred_map_version;
246 std::vector<ClientData> data_versions;
247 std::vector<ClientVersion*> extension_versions;
248
249 wxString data_path;
250 FileName client_path;
251 wxFileName metadata_path;
252 wxFileName sprites_path;
253
254private:
255 static void loadOTBInfo(pugi::xml_node otb_nodes);
256 static void loadVersion(pugi::xml_node client_node);
257 static void loadVersionExtensions(pugi::xml_node client_node);
258
259 // All versions
260 typedef std::map<ClientVersionID, ClientVersion*> VersionMap;
261 static VersionMap client_versions;
262 static ClientVersion* latest_version;
263
264 // All otbs
265 typedef std::map<std::string, OtbVersion> OtbMap;
266 static OtbMap otb_versions;
267};
268
269inline int VersionComparisonPredicate(ClientVersion* a, ClientVersion* b) {
270 if (a->getID() < b->getID()) {
271 return 1;
272 }
273 return 0;
274}
275
276#endif
277
Top