mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 02:11:30 +00:00
[C++20] Arithmetic on different enums is deprecated (#2752)
Just do some casts and add some constants to make life easier
This commit is contained in:
parent
a90c760186
commit
ee2079ec35
@ -34,7 +34,7 @@ const char *RuleManager::s_categoryNames[_CatCount + 1] = {
|
||||
"InvalidCategory"
|
||||
};
|
||||
|
||||
const RuleManager::RuleInfo RuleManager::s_RuleInfo[_IntRuleCount + _RealRuleCount + _BoolRuleCount + 1] = {
|
||||
const RuleManager::RuleInfo RuleManager::s_RuleInfo[IntRuleCount + RealRuleCount + BoolRuleCount + 1] = {
|
||||
/* this is done in three steps so we can reliably get to them by index*/
|
||||
#define RULE_INT(category_name, rule_name, default_value, notes) \
|
||||
{ #category_name ":" #rule_name, Category__##category_name, IntRule, Int__##rule_name, notes },
|
||||
@ -212,14 +212,14 @@ std::string RuleManager::_GetRuleName(RuleType type, uint16 index) {
|
||||
case IntRule:
|
||||
return s_RuleInfo[index].name;
|
||||
case RealRule:
|
||||
return s_RuleInfo[index + _IntRuleCount].name;
|
||||
return s_RuleInfo[index + IntRuleCount].name;
|
||||
case BoolRule:
|
||||
return s_RuleInfo[index + _IntRuleCount + _RealRuleCount].name;
|
||||
return s_RuleInfo[index + IntRuleCount + RealRuleCount].name;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return s_RuleInfo[_IntRuleCount + _RealRuleCount + _BoolRuleCount].name;
|
||||
return s_RuleInfo[IntRuleCount + RealRuleCount + BoolRuleCount].name;
|
||||
}
|
||||
|
||||
//assumes index is valid!
|
||||
@ -228,14 +228,14 @@ const std::string &RuleManager::_GetRuleNotes(RuleType type, uint16 index) {
|
||||
case IntRule:
|
||||
return s_RuleInfo[index].notes;
|
||||
case RealRule:
|
||||
return s_RuleInfo[index + _IntRuleCount].notes;
|
||||
return s_RuleInfo[index + IntRuleCount].notes;
|
||||
case BoolRule:
|
||||
return s_RuleInfo[index + _IntRuleCount + _RealRuleCount].notes;
|
||||
return s_RuleInfo[index + IntRuleCount + RealRuleCount].notes;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return s_RuleInfo[_IntRuleCount + _RealRuleCount + _BoolRuleCount].notes;
|
||||
return s_RuleInfo[IntRuleCount + RealRuleCount + BoolRuleCount].notes;
|
||||
}
|
||||
|
||||
bool RuleManager::LoadRules(Database *db, const std::string &rule_set_name, bool reload) {
|
||||
@ -325,15 +325,15 @@ void RuleManager::SaveRules(Database *db, const std::string &rule_set_name) {
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < _IntRuleCount; i++) {
|
||||
for (i = 0; i < IntRuleCount; i++) {
|
||||
_SaveRule(db, IntRule, i);
|
||||
}
|
||||
|
||||
for (i = 0; i < _RealRuleCount; i++) {
|
||||
for (i = 0; i < RealRuleCount; i++) {
|
||||
_SaveRule(db, RealRule, i);
|
||||
}
|
||||
|
||||
for (i = 0; i < _BoolRuleCount; i++) {
|
||||
for (i = 0; i < BoolRuleCount; i++) {
|
||||
_SaveRule(db, BoolRule, i);
|
||||
}
|
||||
}
|
||||
@ -536,7 +536,7 @@ bool RuleManager::RestoreRuleNotes(Database *db)
|
||||
}
|
||||
}
|
||||
|
||||
return s_RuleInfo[_IntRuleCount + _RealRuleCount + _BoolRuleCount];
|
||||
return s_RuleInfo[IntRuleCount + RealRuleCount + BoolRuleCount];
|
||||
}(e.rule_name);
|
||||
|
||||
if (Strings::Contains(rule.name, e.rule_name)) {
|
||||
|
||||
@ -57,6 +57,8 @@ public:
|
||||
_IntRuleCount
|
||||
} IntType;
|
||||
|
||||
static const int IntRuleCount = static_cast<int>(_IntRuleCount);
|
||||
|
||||
typedef enum {
|
||||
#define RULE_REAL(category_name, rule_name, default_value, notes) \
|
||||
Real__##rule_name,
|
||||
@ -66,6 +68,8 @@ public:
|
||||
_RealRuleCount
|
||||
} RealType;
|
||||
|
||||
static const int RealRuleCount = static_cast<int>(_RealRuleCount);
|
||||
|
||||
typedef enum {
|
||||
#define RULE_BOOL(category_name, rule_name, default_value, notes) \
|
||||
Bool__##rule_name,
|
||||
@ -75,6 +79,8 @@ public:
|
||||
_BoolRuleCount
|
||||
} BoolType;
|
||||
|
||||
static const int BoolRuleCount = static_cast<int>(_BoolRuleCount);
|
||||
|
||||
typedef enum {
|
||||
#define RULE_CATEGORY(category_name) \
|
||||
Category__##category_name,
|
||||
@ -95,7 +101,7 @@ public:
|
||||
static const BoolType InvalidBool = _BoolRuleCount;
|
||||
static const CategoryType InvalidCategory = _CatCount;
|
||||
|
||||
static const uint32 _RulesCount = _IntRuleCount + _RealRuleCount + _BoolRuleCount;
|
||||
static const uint32 RulesCount = IntRuleCount + RealRuleCount + BoolRuleCount;
|
||||
|
||||
//fetch routines, you should generally use the Rule* macros instead of this
|
||||
int GetIntRule(IntType t) const;
|
||||
@ -103,13 +109,13 @@ public:
|
||||
bool GetBoolRule(BoolType t) const;
|
||||
|
||||
//management routines
|
||||
static std::string GetRuleName(IntType t) { return s_RuleInfo[t].name; }
|
||||
static std::string GetRuleName(RealType t) { return s_RuleInfo[t + _IntRuleCount].name; }
|
||||
static std::string GetRuleName(BoolType t) { return s_RuleInfo[t + _IntRuleCount + _RealRuleCount].name; }
|
||||
static const std::string &GetRuleNotes(IntType t) { return s_RuleInfo[t].notes; }
|
||||
static const std::string &GetRuleNotes(RealType t) { return s_RuleInfo[t + _IntRuleCount].notes; }
|
||||
static const std::string &GetRuleNotes(BoolType t) { return s_RuleInfo[t + _IntRuleCount + _RealRuleCount].notes; }
|
||||
static uint32 CountRules() { return _RulesCount; }
|
||||
static std::string GetRuleName(IntType t) { return s_RuleInfo[static_cast<int>(t)].name; }
|
||||
static std::string GetRuleName(RealType t) { return s_RuleInfo[static_cast<int>(t) + IntRuleCount].name; }
|
||||
static std::string GetRuleName(BoolType t) { return s_RuleInfo[static_cast<int>(t) + IntRuleCount + RealRuleCount].name; }
|
||||
static const std::string &GetRuleNotes(IntType t) { return s_RuleInfo[static_cast<int>(t)].notes; }
|
||||
static const std::string &GetRuleNotes(RealType t) { return s_RuleInfo[static_cast<int>(t) + IntRuleCount].notes; }
|
||||
static const std::string &GetRuleNotes(BoolType t) { return s_RuleInfo[static_cast<int>(t) + IntRuleCount + RealRuleCount].notes; }
|
||||
static uint32 CountRules() { return RulesCount; }
|
||||
static CategoryType FindCategory(const std::string &category_name);
|
||||
bool ListRules(const std::string &category_name, std::vector <std::string> &l);
|
||||
bool ListCategories(std::vector <std::string> &l);
|
||||
@ -141,9 +147,9 @@ private:
|
||||
int m_activeRuleset;
|
||||
std::string m_activeName;
|
||||
|
||||
int m_RuleIntValues[_IntRuleCount];
|
||||
float m_RuleRealValues[_RealRuleCount];
|
||||
uint32 m_RuleBoolValues[_BoolRuleCount];
|
||||
int m_RuleIntValues[IntRuleCount];
|
||||
float m_RuleRealValues[RealRuleCount];
|
||||
uint32 m_RuleBoolValues[BoolRuleCount];
|
||||
|
||||
typedef enum {
|
||||
IntRule,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user