-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathstructs.h
More file actions
403 lines (393 loc) · 7.81 KB
/
structs.h
File metadata and controls
403 lines (393 loc) · 7.81 KB
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
//
// structs.h
// Project Spitfire
//
// Copyright (c) 2013 Daizee (rensiadz at gmail dot com)
//
// This file is part of Spitfire.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#pragma once
#include "amf3.h"
#include <stdint.h>
extern char * GetBuildingName(int id);
class Hero;
class City;
class PlayerCity;
class NpcCity;
class Client;
class Alliance;
#pragma region structs and stuff
struct stResources
{
double gold;
double food;
double wood;
double stone;
double iron;
stResources& operator -=(const stResources& b)
{
this->gold -= b.gold;
this->food -= b.food;
this->wood -= b.wood;
this->stone -= b.stone;
this->iron -= b.iron;
return *this;
}
stResources& operator +=(const stResources& b)
{
this->gold += b.gold;
this->food += b.food;
this->wood += b.wood;
this->stone += b.stone;
this->iron += b.iron;
return *this;
}
amf3object ToObject()
{
amf3object obj = amf3object();
obj["wood"] = wood;
obj["food"] = food;
obj["stone"] = stone;
obj["gold"] = gold;
obj["iron"] = iron;
return obj;
}
}; // 40 bytes
struct stForts
{
int32_t traps;
int32_t abatis;
int32_t towers;
int32_t logs;
int32_t trebs;
}; // 20 bytes
struct stBuilding
{
int16_t id;
int16_t level;
//short appearance; //age2
int16_t type;
int16_t status;
double endtime;
double starttime;
//short help; //age2
//string name;
amf3object ToObject()
{
amf3object obj;
obj["startTime"] = starttime;
obj["endTime"] = endtime;//(endtime > 0)?(endtime-1000):(0);// HACK: Attempt to correct "lag" issues.
obj["level"] = level;
obj["status"] = status;
obj["typeId"] = type;
obj["positionId"] = id;
obj["name"] = GetBuildingName(type);
return obj;
};
}; // 21 bytes
struct stPrereq
{
int32_t id;
int32_t level;
};
struct stItemConfig
{
string name;
int32_t cost;
int32_t saleprice;
int32_t daylimit;
int32_t type;
bool cangamble;
bool buyable;
int32_t rarity;
};
struct stRarityGamble
{
vector<stItemConfig*> common;
vector<stItemConfig*> special;
vector<stItemConfig*> rare;
vector<stItemConfig*> superrare;
vector<stItemConfig*> ultrarare;
};
struct stBuildingConfig
{
int32_t food;
int32_t wood;
int32_t iron;
int32_t stone;
int32_t gold;
int32_t population;
double time;
double destructtime;
stPrereq buildings[3];
stPrereq techs[3];
stPrereq items[3];
int32_t limit;
int32_t inside;
int32_t prestige;
};
struct stMarketEntry
{
double amount;
double price;
uint32_t clientid;
uint32_t cityid;
};
struct stTroops
{
int64_t worker;
int64_t warrior;
int64_t scout;
int64_t pike;
int64_t sword;
int64_t archer;
int64_t cavalry;
int64_t cataphract;
int64_t transporter;
int64_t ballista;
int64_t ram;
int64_t catapult;
stTroops& operator -=(const stTroops& b)
{
this->worker -= b.worker;
this->warrior -= b.warrior;
this->scout -= b.scout;
this->pike -= b.pike;
this->sword -= b.sword;
this->archer -= b.archer;
this->cavalry -= b.cavalry;
this->cataphract -= b.cataphract;
this->transporter -= b.transporter;
this->ballista -= b.ballista;
this->ram -= b.ram;
this->catapult -= b.catapult;
return *this;
}
stTroops& operator +=(const stTroops& b)
{
this->worker += b.worker;
this->warrior += b.warrior;
this->scout += b.scout;
this->pike += b.pike;
this->sword += b.sword;
this->archer += b.archer;
this->cavalry += b.cavalry;
this->cataphract += b.cataphract;
this->transporter += b.transporter;
this->ballista += b.ballista;
this->ram += b.ram;
this->catapult += b.catapult;
return *this;
}
amf3object ToObject()
{
amf3object obj = amf3object();
obj["peasants"] = worker;
obj["catapult"] = catapult;
obj["archer"] = archer;
obj["ballista"] = ballista;
obj["scouter"] = scout;
obj["carriage"] = transporter;
obj["heavyCavalry"] = cataphract;
obj["militia"] = warrior;
obj["lightCavalry"] = cavalry;
obj["swordsmen"] = sword;
obj["pikemen"] = pike;
obj["batteringRam"] = ram;
return obj;
}
};
struct stAlliance
{
int32_t id;
union
{
int32_t members;
double honor;
double prestige;
};
uint32_t rank;
Alliance * ref;
};
struct stArmyMovement
{
stArmyMovement() { memset(&resources, 0, sizeof(stResources)); memset(&troops, 0, sizeof(stTroops)); }
Hero * hero;
string heroname;
int16_t direction;
stResources resources;
string startposname;
string king;
stTroops troops;
uint64_t starttime;
uint64_t armyid;
uint64_t reachtime;
uint32_t herolevel;
uint64_t resttime;
uint32_t missiontype;
uint32_t startfieldid;
uint32_t targetfieldid;
string targetposname;
City * city;
Client * client;
amf3object ToObject()
{
amf3object obj = amf3object();
obj["hero"] = heroname;
obj["direction"] = direction;
obj["resource"] = resources.ToObject();
obj["startPosName"] = startposname;
obj["king"] = king;
obj["troop"] = troops.ToObject();
obj["startTime"] = starttime;
obj["armyId"] = armyid;
obj["reachTime"] = reachtime;
obj["heroLevel"] = herolevel;
obj["restTime"] = resttime;
obj["missionType"] = missiontype;
obj["startFieldId"] = startfieldid;
obj["targetFieldId"] = targetfieldid;
obj["targetPosName"] = targetposname;
return obj;
}
};
struct stTrainingAction
{
int32_t troopcount;
int8_t trooptype;
int8_t buildingid;
Client * client;
};
struct stBuildingAction
{
PlayerCity * city;
Client * client;
int16_t positionid;
};
struct stResearchAction
{
PlayerCity * city;
Client * client;
int16_t researchid;
};
struct stTimedEvent
{
int8_t type;
void * data;
};
struct stIntRank
{
uint32_t value;
uint32_t id;
};
struct stClientRank
{
Client * client;
int32_t rank;
};
struct stHeroRank
{
int16_t stratagem;
int16_t power;
int16_t management;
int16_t grade;
string name;
string kind;
int32_t rank;
};
struct stCastleRank
{
int16_t level;
int32_t population;
string name;
string grade;
string alliance;
string kind;
int32_t rank;
};
struct stSearchClientRank
{
list<stClientRank> ranklist;
list<stClientRank> * rlist;
string key;
uint64_t lastaccess;
};
struct stSearchHeroRank
{
list<stHeroRank> ranklist;
list<stHeroRank> * rlist;
string key;
uint64_t lastaccess;
};
struct stSearchCastleRank
{
list<stCastleRank> ranklist;
list<stCastleRank> * rlist;
string key;
uint64_t lastaccess;
};
struct stSearchAllianceRank
{
list<stAlliance> ranklist;
list<stAlliance> * rlist;
string key;
uint64_t lastaccess;
};
struct stPacketOut
{
int32_t client;
amf3object obj;
};
struct stTroopTrain
{
int16_t troopid;
int32_t count;
int32_t queueid;
double starttime;
double endtime;
double costtime;
};
struct stTroopQueue
{
int8_t status;
int16_t positionid;
int32_t nextqueueid;
list<stTroopTrain> queue;
};
struct stBuff
{
string id;
string desc;
double endtime;
};
struct stItem
{
string id;
int16_t count;
int16_t mincount;
int16_t maxcount;
};
struct stResearch
{
int16_t level;
uint32_t castleid;
double endtime;
double starttime;
};
#pragma endregion