1/**
2 * The Forgotten Server - a free and open-source MMORPG server emulator
3 * Copyright (C) 2019 Mark Samman <mark.samman@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#ifndef FS_OUTFIT_H_C56E7A707E3F422C8C93D9BE09916AA3
21#define FS_OUTFIT_H_C56E7A707E3F422C8C93D9BE09916AA3
22
23#include <string>
24#include <vector>
25
26#include "enums.h"
27
28static constexpr int OUTFIT_DIRECTIONS = 4;
29
30struct Outfit {
31 Outfit(std::string name, uint16_t lookType, uint16_t attackMeleeType,
32 uint16_t attackRangeType, uint8_t attackRange, bool premium,
33 bool unlocked)
34 : name(std::move(name)), lookType(lookType),
35 attackMeleeType(attackMeleeType), attackRangeType(attackRangeType),
36 attackRange(attackRange), premium(premium), unlocked(unlocked) {
37 for (int i = 0; i < OUTFIT_DIRECTIONS; ++i) {
38 offsets[i] = OutfitOffset{};
39 }
40 }
41
42 std::string name;
43 uint16_t lookType;
44 uint16_t attackMeleeType;
45 uint16_t attackRangeType;
46 uint8_t attackRange;
47 bool premium;
48 bool unlocked;
49 OutfitOffset offsets[OUTFIT_DIRECTIONS];
50};
51
52struct ProtocolOutfit {
53 ProtocolOutfit(const std::string &name, uint16_t lookType, uint8_t addons)
54 : name(name), lookType(lookType), addons(addons) {}
55
56 const std::string &name;
57 uint16_t lookType;
58 uint8_t addons;
59};
60
61class Outfits {
62public:
63 static Outfits &getInstance() {
64 static Outfits instance;
65 return instance;
66 }
67
68 bool loadFromXml();
69
70 bool reload() {
71 for (int i = 0; i <= PLAYERSEX_LAST; ++i) {
72 outfits[i].clear();
73 }
74 return loadFromXml();
75 }
76
77 const Outfit *getOutfitByLookType(PlayerSex_t sex, uint16_t lookType) const;
78 const std::vector<Outfit> &getOutfits(PlayerSex_t sex) const {
79 return outfits[sex];
80 }
81
82private:
83 std::vector<Outfit> outfits[PLAYERSEX_LAST + 1];
84};
85
86#endif
87