-
Notifications
You must be signed in to change notification settings - Fork 1
/
group.h
112 lines (95 loc) · 3.84 KB
/
group.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
////////////////////////////////////////////////////////////////////////
// OpenTibia - an opensource roleplaying game
////////////////////////////////////////////////////////////////////////
// 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 3 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, see <http://www.gnu.org/licenses/>.
////////////////////////////////////////////////////////////////////////
#ifndef __GROUP__
#define __GROUP__
#include "otsystem.h"
class Group
{
public:
virtual ~Group() {}
Group()
{
m_name = m_fullName = "";
m_access = m_ghostAccess = m_outfit = m_depotLimit = m_maxVips = m_flags = m_customFlags = 0;
m_violationReasons = m_nameViolationFlags = m_statementViolationFlags = 0;
}
Group(uint32_t id): m_id(id)
{
m_name = m_fullName = "";
m_access = m_ghostAccess = m_outfit = m_depotLimit = m_maxVips = m_flags = m_customFlags = 0;
m_violationReasons = m_nameViolationFlags = m_statementViolationFlags = 0;
}
std::string getName() const {return m_name;}
void setName(const std::string& v) {m_name = v;}
std::string getFullName() const {return m_fullName;}
void setFullName(const std::string& v) {m_fullName = v;}
uint16_t getAccess() const {return m_access;}
void setAccess(uint16_t v) {m_access = v;}
uint16_t getGhostAccess() const {return m_ghostAccess;}
void setGhostAccess(uint16_t v) {m_ghostAccess = v;}
uint8_t getViolationReasons() const {return m_violationReasons;}
void setViolationReasons(uint8_t v) {m_violationReasons = v;}
int16_t getStatementViolationFlags() const {return m_statementViolationFlags;}
void setStatementViolationFlags(uint8_t v) {m_statementViolationFlags = v;}
int16_t getNameViolationFlags() const {return m_nameViolationFlags;}
void setNameViolationFlags(uint8_t v) {m_nameViolationFlags = v;}
uint16_t getOutfit() const {return m_outfit;}
void setOutfit(uint16_t v) {m_outfit = v;}
uint32_t getId() const {return m_id;}
void setId(uint32_t v) {m_id = v;}
uint32_t getDepotLimit(bool premium = false) const;
void setDepotLimit(uint32_t v) {m_depotLimit = v;}
uint32_t getMaxVips(bool premium = false) const;
void setMaxVips(uint32_t v) {m_maxVips = v;}
uint64_t getFlags() const {return m_flags;}
void setFlags(uint64_t v) {m_flags = v;}
uint64_t getCustomFlags() const {return m_customFlags;}
void setCustomFlags(uint64_t v) {m_customFlags = v;}
bool hasFlag(uint64_t value) const {return (m_flags & ((uint64_t)1 << value));}
bool hasCustomFlag(uint64_t value) const {return (m_customFlags & ((uint64_t)1 << value));}
private:
std::string m_name, m_fullName;
uint8_t m_violationReasons;
int16_t m_nameViolationFlags, m_statementViolationFlags;
uint16_t m_access, m_ghostAccess, m_outfit;
uint32_t m_id, m_depotLimit, m_maxVips;
uint64_t m_flags, m_customFlags;
};
typedef std::map<uint32_t, Group*> GroupsMap;
class Groups
{
public:
virtual ~Groups() {clear();}
static Groups* getInstance()
{
static Groups instance;
return &instance;
}
bool loadFromXml();
bool parseGroupNode(xmlNodePtr p);
void clear();
bool reload();
Group* getGroup(uint32_t groupId);
int32_t getGroupId(const std::string& name);
GroupsMap::iterator getFirstGroup() {return groupsMap.begin();}
GroupsMap::iterator getLastGroup() {return groupsMap.end();}
private:
Groups() {}
GroupsMap groupsMap;
static Group defGroup;
};
#endif