-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathDataDefinitions.hpp
More file actions
602 lines (511 loc) · 14.4 KB
/
Copy pathDataDefinitions.hpp
File metadata and controls
602 lines (511 loc) · 14.4 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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
/**
* Alicia Server - dedicated server software
* Copyright (C) 2024 Story Of Alicia
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#ifndef DATADEFINITIONS_HPP
#define DATADEFINITIONS_HPP
#include <array>
#include <atomic>
#include <chrono>
#include <cstdint>
#include <string>
#include <vector>
#include <optional>
#include <unordered_set>
#include <set>
#include <map>
namespace server
{
namespace dao
{
template <typename T>
struct Field
{
//! Constructs a field with an initialized value.
//! @param value Value.
Field(T value) noexcept
: _value(std::move(value))
{
}
//! Constructs field with an initialized value.
Field()
: _value()
{
}
//! Deleted copy constructor.
Field(const Field& field) = delete;
//! Deleted copy assignment operator.
Field& operator=(const Field& field) = delete;
Field(Field&& field) noexcept
: _modified(field.IsModified())
, _value(field._value)
{
}
Field& operator=(Field&& field) noexcept
{
_modified = field.IsModified();
_value = std::move(field._value);
return *this;
}
[[nodiscard]] bool IsModified() const noexcept
{
return _modified;
}
T& operator()(const T& value) noexcept
{
_modified = true;
_value = value;
return value;
}
T& operator()(T&& value) noexcept
{
_modified = true;
_value = std::move(value);
return value;
}
const T& operator()() const noexcept
{
return _value;
}
T& operator()() noexcept
{
return _value;
}
private:
std::atomic_bool _modified{false};
T _value;
};
} // namespace dao
namespace data
{
//! Unique identifier.
using Uid = uint32_t;
//! Type identifier.
using Tid = uint32_t;
//! Value of an invalid unique identifier.
constexpr Uid InvalidUid = 0;
//! Value of an invalid type identifier.
constexpr Tid InvalidTid = 0;
using Clock = std::chrono::system_clock;
//! User
struct User
{
//! A name of the user.
dao::Field<std::string> name{};
//! An authorization token of the user.
dao::Field<std::string> token{};
//! Infractions.
dao::Field<std::vector<Uid>> infractions{};
//! A character UID of the user.
dao::Field<Uid> characterUid{InvalidUid};
//! The last time the user was seen online. 1 means currently online.
dao::Field<Clock::time_point> lastSeenOnline{};
};
//! Infraction
struct Infraction
{
enum class Punishment
{
None, Mute, Ban
};
dao::Field<Uid> uid{InvalidUid};
dao::Field<std::string> description;
dao::Field<Punishment> punishment{Punishment::None};
dao::Field<std::chrono::seconds> duration;
dao::Field<Clock::time_point> createdAt;
};
//! Item
struct Item
{
//! A unique identifier.
dao::Field<Uid> uid{InvalidUid};
//! A type identifier.
dao::Field<Tid> tid{InvalidTid};
//! An amount of an item.
dao::Field<uint32_t> count{};
//! A duration of an item.
dao::Field<std::chrono::seconds> duration{};
//! A time point of when the item was created.
dao::Field<Clock::time_point> createdAt{};
};
//! Pet
struct Pet
{
//! A unique identifier.
dao::Field<Uid> uid{InvalidUid};
//! A Item tied to the pet.
dao::Field<Uid> itemUid{InvalidUid};
//! A pet identifier.
dao::Field<Uid> petId{0};
//! A name of the pet.
dao::Field<std::string> name{};
//! A birth date of the pet.
dao::Field<Clock::time_point> birthDate{};
};
//! Stored item
struct StorageItem
{
struct Item
{
Tid tid{InvalidTid};
uint32_t count{};
std::chrono::seconds duration{};
};
//! A unique identifier.
dao::Field<Uid> uid{InvalidUid};
dao::Field<std::string> sender{};
dao::Field<std::string> message{};
dao::Field<int32_t> carrots{};
dao::Field<std::vector<Item>> items{};
dao::Field<bool> checked{false};
dao::Field<Clock::time_point> createdAt{};
dao::Field<std::chrono::seconds> duration{};
dao::Field<uint32_t> goodsSq{};
dao::Field<uint32_t> priceId{};
};
//! Guild
struct Guild
{
dao::Field<Uid> uid{InvalidUid};
dao::Field<std::string> name{};
dao::Field<std::string> description{};
dao::Field<Uid> owner{};
dao::Field<std::vector<Uid>> officers{};
dao::Field<std::vector<Uid>> members{};
dao::Field<uint32_t> rank{};
dao::Field<uint32_t> totalWins{};
dao::Field<uint32_t> totalLosses{};
dao::Field<uint32_t> seasonalWins{};
dao::Field<uint32_t> seasonalLosses{};
};
//! Settings
struct Settings
{
dao::Field<Uid> uid{InvalidUid};
struct Option
{
uint32_t primaryKey{0};
uint32_t type{0};
uint32_t secondaryKey{0};
};
dao::Field<std::optional<std::vector<Option>>> keyboardBindings{std::nullopt};
dao::Field<std::optional<std::array<std::string, 8>>> macros{std::nullopt};
dao::Field<std::optional<std::vector<Option>>> gamepadBindings{std::nullopt};
dao::Field<uint32_t> age{};
dao::Field<bool> hideAge{true};
};
//! User
struct Character
{
//! An UID of the character.
dao::Field<Uid> uid{InvalidUid};
//! A name of the character.
dao::Field<std::string> name{};
dao::Field<std::string> introduction{};
dao::Field<uint32_t> level{};
dao::Field<uint32_t> experience{};
dao::Field<int32_t> carrots{};
dao::Field<int32_t> cash{};
enum class Role
{
User,
Op,
GameMaster
};
dao::Field<Role> role{};
struct Parts
{
//! An ID of the character model.
dao::Field<uint32_t> modelId{0u};
//! An ID of the mouth part.
dao::Field<uint32_t> mouthId{0u};
//! An ID of the face part.
dao::Field<uint32_t> faceId{0u};
} parts{};
struct Appearance
{
//! An ID of the Voice model.
dao::Field<uint32_t> voiceId{0u};
dao::Field<uint32_t> headSize{0u};
dao::Field<uint32_t> height{0u};
dao::Field<uint32_t> thighVolume{0u};
dao::Field<uint32_t> legVolume{0u};
//! An ID of the emblem.
dao::Field<uint32_t> emblemId{0u};
} appearance{};
dao::Field<Uid> guildUid{InvalidUid};
struct Contacts
{
struct Group
{
Uid uid{};
std::string name{};
std::set<Uid> members{};
Clock::time_point createdAt{};
};
dao::Field<std::set<Uid>> pending{};
dao::Field<std::map<Uid, Group>> groups{};
} contacts{};
dao::Field<std::vector<Uid>> gifts{};
dao::Field<std::vector<Uid>> purchases{};
dao::Field<std::vector<Uid>> inventory{};
dao::Field<std::vector<Uid>> characterEquipment{};
dao::Field<std::vector<Uid>> expiredEquipment{};
dao::Field<std::vector<Uid>> horses{};
dao::Field<uint32_t> horseSlotCount{0u};
dao::Field<std::vector<Uid>> pets{};
dao::Field<Uid> mountUid{InvalidUid};
dao::Field<Uid> petUid{InvalidUid};
dao::Field<std::vector<Uid>> eggs{};
dao::Field<std::vector<Uid>> housing{};
dao::Field<bool> isRanchLocked{};
dao::Field<Uid> settingsUid{InvalidUid};
struct Skills
{
// TODO: confirm this
//! Max 2 skill sets per gamemode
struct Sets
{
//! Max 2 skills per skill set
struct Set
{
uint32_t slot1{};
uint32_t slot2{};
};
Set set1{};
Set set2{};
uint32_t activeSetId{0};
};
dao::Field<Sets> speed{};
dao::Field<Sets> magic{};
} skills{};
dao::Field<Uid> dailyQuestGroupUid{InvalidUid};
struct Mailbox
{
dao::Field<bool> hasNewMail{false};
dao::Field<std::vector<Uid>> inbox{};
dao::Field<std::vector<Uid>> sent{};
} mailbox{};
dao::Field<std::vector<Uid>> quests{};
};
struct Horse
{
//! A horse type.
enum class Type
{
//! An adult horse.
Adult,
//! A horse foal.
Foal,
//! An adult horse which is registered in the breeding market.
Stallion,
//! An adult horse which is rented.
Rent
};
dao::Field<Uid> uid{InvalidUid};
dao::Field<Tid> tid{InvalidTid};
dao::Field<std::string> name{};
struct Parts
{
dao::Field<Tid> skinTid{0u};
dao::Field<Tid> faceTid{0u};
dao::Field<Tid> maneTid{0u};
dao::Field<Tid> tailTid{0u};
} parts{};
struct Appearance
{
dao::Field<uint32_t> scale{0u};
dao::Field<uint32_t> legLength{0u};
dao::Field<uint32_t> legVolume{0u};
dao::Field<uint32_t> bodyLength{0u};
dao::Field<uint32_t> bodyVolume{0u};
} appearance{};
struct Stats
{
dao::Field<uint32_t> agility{0u};
dao::Field<uint32_t> courage{0u};
dao::Field<uint32_t> rush{0u};
dao::Field<uint32_t> endurance{0u};
dao::Field<uint32_t> ambition{0u};
} stats{};
struct Mastery
{
dao::Field<uint32_t> spurMagicCount{0u};
dao::Field<uint32_t> jumpCount{0u};
dao::Field<uint32_t> slidingTime{0u};
dao::Field<uint32_t> glidingDistance{0u};
} mastery{};
dao::Field<uint32_t> rating{0u};
dao::Field<uint32_t> clazz{0u};
dao::Field<uint32_t> clazzProgress{0u};
dao::Field<uint32_t> grade{0u};
dao::Field<uint32_t> growthPoints{0u};
//! A count of how many times the horse was bred.
dao::Field<uint32_t> breedingCount{0u};
//! A count of successful consecutive breeds.
dao::Field<uint32_t> breedingCombo{0u};
dao::Field<Type> type{Type::Adult};
dao::Field<Clock::time_point> dateOfBirth{};
dao::Field<uint32_t> tendency{0u};
dao::Field<uint32_t> spirit{0u};
struct Potential
{
dao::Field<uint32_t> type{0u};
dao::Field<uint32_t> level{0u};
dao::Field<uint32_t> value{0u};
} potential{};
dao::Field<uint32_t> luckState{0u};
dao::Field<uint32_t> fatigue{0u};
dao::Field<uint32_t> emblemUid{0u};
struct MountCondition
{
dao::Field<uint32_t> stamina{};
dao::Field<uint32_t> charm{};
dao::Field<uint32_t> friendliness{};
dao::Field<uint32_t> injury{};
dao::Field<uint32_t> plenitude{};
dao::Field<uint32_t> bodyDirtiness{};
dao::Field<uint32_t> maneDirtiness{};
dao::Field<uint32_t> tailDirtiness{};
dao::Field<uint32_t> bodyPolish{};
dao::Field<uint32_t> manePolish{};
dao::Field<uint32_t> tailPolish{};
dao::Field<uint32_t> attachment{};
dao::Field<uint32_t> boredom{};
dao::Field<uint32_t> stopAmendsPoint{};
} mountCondition{};
struct MountInfo
{
dao::Field<uint32_t> boostsInARow{};
dao::Field<uint32_t> winsSpeedSingle{};
dao::Field<uint32_t> winsSpeedTeam{};
dao::Field<uint32_t> winsMagicSingle{};
dao::Field<uint32_t> winsMagicTeam{};
// Store in metres, displayed in kilometres
dao::Field<uint32_t> totalDistance{};
// Whole number, divided by 10 for the floating point.
dao::Field<uint32_t> topSpeed{};
// Whole number, divided by 10 for the floating point.
dao::Field<uint32_t> longestGlideDistance{};
// refers to carnival participation
dao::Field<uint32_t> participated{};
dao::Field<uint32_t> cumulativePrize{};
dao::Field<uint32_t> biggestPrize{};
} mountInfo{};
struct Ancestors
{
Uid father{InvalidUid};
Uid mother{InvalidUid};
} ancestors{};
//! A value in an interval of <1, 9>.
//! Basically a weighted score of number of ancestors that share the same coat as the horse.
//! Ancestors of the first generation add two points to the lineage,
//! ancestors of the second generation add one point to the lineage
//! while the horse itself adds 1.
dao::Field<uint32_t> lineage{1u};
};
struct Housing
{
dao::Field<Uid> uid{InvalidUid};
dao::Field<uint32_t> housingId{};
dao::Field<Clock::time_point> expiresAt{};
dao::Field<uint32_t> durability{};
};
struct Egg
{
dao::Field<Uid> uid{InvalidUid};
dao::Field<Uid> itemUid{InvalidUid};
dao::Field<Tid> itemTid{InvalidTid};
dao::Field<Clock::time_point> incubatedAt{};
dao::Field<uint32_t> incubatorSlot{};
dao::Field<uint32_t> boostsUsed;
};
struct DailyQuestEntry
{
//! Template ID of the quest.
uint16_t questId{};
//! Current progress toward the quest's successValue.
uint32_t progress{};
};
struct DailyQuestGroup
{
dao::Field<Uid> uid{InvalidUid};
//! Reward entry ID shared by all 3 quests, references quests.rewards in quests.yaml.
dao::Field<uint8_t> rewardId{};
//! Reward type shared by all 3 quests: 1 = carrots, 2 = exp.
dao::Field<uint8_t> rewardType{};
//! Accumulated quest reward points. References QuestRewardPoint thresholds in quests.yaml.
dao::Field<uint32_t> rewardPoints{};
//! Whether the daily quest carrot reward has been claimed today.
dao::Field<bool> carrotsClaimed{false};
//! The 3 daily quest slots.
dao::Field<std::array<DailyQuestEntry, 3>> quests{};
};
struct Quest
{
enum class Status : uint32_t
{
InProgress = 0,
ReadyToClaim = 1,
Completed = 3
};
dao::Field<Uid> uid{InvalidUid};
dao::Field<uint32_t> questId{};
dao::Field<Status> isCompleted{Status::InProgress};
dao::Field<uint32_t> progress{};
};
struct Mail
{
//! Mail type.
//! Dictates whether or not the inbox mail can be replied to, including system mails, or contains rewards.
enum class MailType : uint32_t
{
CanReply = 0,
NoReply = 1,
CarnivalReward = 2, //! Requests AcCmdCLRequestFestivalResult
BreedingReward = 3, //! Requests AcCmdCRBreedingTakeMoney
};
//! Flags whether the mail is a system or a character mail.
//! The game client uses this to filter for system mails only.
enum class MailOrigin : uint32_t
{
Character = 0,
System = 1
};
dao::Field<Uid> uid{InvalidUid};
dao::Field<Uid> from{InvalidUid};
dao::Field<Uid> to{InvalidUid};
dao::Field<bool> isRead{false};
dao::Field<bool> isDeleted{false};
dao::Field<MailType> type{};
dao::Field<MailOrigin> origin{};
dao::Field<Clock::time_point> createdAt{};
dao::Field<std::string> body{};
};
struct Stallion
{
dao::Field<Uid> uid{InvalidUid};
dao::Field<Uid> horseUid{InvalidUid}; // The horse being registered as stallion
dao::Field<Uid> ownerUid{InvalidUid}; // Owner of the stallion
dao::Field<uint32_t> breedingCharge{}; // Price in carrots to breed with this stallion
dao::Field<uint32_t> timesMated{0u}; // Times bred during current registration
dao::Field<Clock::time_point> registeredAt{};
dao::Field<Clock::time_point> expiresAt{};
};
} // namespace data
} // namespace server
#endif // DATADEFINITIONS_HPP