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