[12713] Implemented uint64/int64 config values support, fixed compile warnings related to max player money (and damn you git_id)

This commit is contained in:
sanctum32 2013-10-24 18:49:38 +03:00 committed by Antz
parent 7f4338f0d6
commit 08913b2437
6 changed files with 106 additions and 4 deletions

View file

@ -709,7 +709,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
InitRunes(); InitRunes();
SetUInt32Value(PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_UINT32_START_PLAYER_MONEY)); SetUInt64Value(PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_UINT64_START_PLAYER_MONEY));
SetCurrencyCount(CURRENCY_HONOR_POINTS,sWorld.getConfig(CONFIG_UINT32_CURRENCY_START_HONOR_POINTS)); SetCurrencyCount(CURRENCY_HONOR_POINTS,sWorld.getConfig(CONFIG_UINT32_CURRENCY_START_HONOR_POINTS));
SetCurrencyCount(CURRENCY_CONQUEST_POINTS, sWorld.getConfig(CONFIG_UINT32_CURRENCY_START_CONQUEST_POINTS)); SetCurrencyCount(CURRENCY_CONQUEST_POINTS, sWorld.getConfig(CONFIG_UINT32_CURRENCY_START_CONQUEST_POINTS));

View file

@ -617,7 +617,7 @@ void World::LoadConfigSettings(bool reload)
setConfigMinMax(CONFIG_UINT32_START_PLAYER_LEVEL, "StartPlayerLevel", 1, 1, getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)); setConfigMinMax(CONFIG_UINT32_START_PLAYER_LEVEL, "StartPlayerLevel", 1, 1, getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL));
setConfigMinMax(CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL, "StartHeroicPlayerLevel", 55, 1, getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)); setConfigMinMax(CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL, "StartHeroicPlayerLevel", 55, 1, getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL));
setConfigMinMax(CONFIG_UINT32_START_PLAYER_MONEY, "StartPlayerMoney", 0, 0, MAX_MONEY_AMOUNT); setConfigMinMax(CONFIG_UINT64_START_PLAYER_MONEY, "StartPlayerMoney", 0, 0, MAX_MONEY_AMOUNT);
setConfigMinMax(CONFIG_UINT32_CURRENCY_RESET_TIME_HOUR, "Currency.ResetHour", 6, 0, 23); setConfigMinMax(CONFIG_UINT32_CURRENCY_RESET_TIME_HOUR, "Currency.ResetHour", 6, 0, 23);
setConfigMinMax(CONFIG_UINT32_CURRENCY_RESET_TIME_WEEK_DAY, "Currency.ResetWeekDay", 3, 0, 6); setConfigMinMax(CONFIG_UINT32_CURRENCY_RESET_TIME_WEEK_DAY, "Currency.ResetWeekDay", 3, 0, 6);
@ -2322,6 +2322,21 @@ void World::LoadDBVersion()
m_CreatureEventAIVersion = "Unknown creature EventAI."; m_CreatureEventAIVersion = "Unknown creature EventAI.";
} }
void World::setConfig(eConfigUInt64Values index, char const* fieldname, uint64 defvalue)
{
setConfig(index, sConfig.GetInt64Default(fieldname, defvalue));
if (int64(getConfig(index)) < 0)
{
sLog.outError("%s (%i) can't be negative. Using %u instead.", fieldname, int64(getConfig(index)), defvalue);
setConfig(index, defvalue);
}
}
void World::setConfig(eConfigInt64Values index, char const* fieldname, int64 defvalue)
{
setConfig(index, sConfig.GetIntDefault(fieldname, defvalue));
}
void World::setConfig(eConfigUInt32Values index, char const* fieldname, uint32 defvalue) void World::setConfig(eConfigUInt32Values index, char const* fieldname, uint32 defvalue)
{ {
setConfig(index, sConfig.GetIntDefault(fieldname, defvalue)); setConfig(index, sConfig.GetIntDefault(fieldname, defvalue));
@ -2357,6 +2372,26 @@ void World::setConfigPos(eConfigFloatValues index, char const* fieldname, float
} }
} }
void World::setConfigMin(eConfigUInt64Values index, char const* fieldname, uint64 defvalue, uint64 minvalue)
{
setConfig(index, fieldname, defvalue);
if (getConfig(index) < minvalue)
{
sLog.outError("%s (%u) must be >= %u. Using %u instead.", fieldname, getConfig(index), minvalue, minvalue);
setConfig(index, minvalue);
}
}
void World::setConfigMin(eConfigInt64Values index, char const* fieldname, int64 defvalue, int64 minvalue)
{
setConfig(index, fieldname, defvalue);
if (getConfig(index) < minvalue)
{
sLog.outError("%s (%i) must be >= %i. Using %i instead.", fieldname, getConfig(index), minvalue, minvalue);
setConfig(index, minvalue);
}
}
void World::setConfigMin(eConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 minvalue) void World::setConfigMin(eConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 minvalue)
{ {
setConfig(index, fieldname, defvalue); setConfig(index, fieldname, defvalue);
@ -2387,6 +2422,36 @@ void World::setConfigMin(eConfigFloatValues index, char const* fieldname, float
} }
} }
void World::setConfigMinMax(eConfigUInt64Values index, char const* fieldname, uint64 defvalue, uint64 minvalue, uint64 maxvalue)
{
setConfig(index, fieldname, defvalue);
if (getConfig(index) < minvalue)
{
sLog.outError("%s (%u) must be in range %u...%u. Using %u instead.", fieldname, getConfig(index), minvalue, maxvalue, minvalue);
setConfig(index, minvalue);
}
else if (getConfig(index) > maxvalue)
{
sLog.outError("%s (%u) must be in range %u...%u. Using %u instead.", fieldname, getConfig(index), minvalue, maxvalue, maxvalue);
setConfig(index, maxvalue);
}
}
void World::setConfigMinMax(eConfigInt64Values index, char const* fieldname, int64 defvalue, int64 minvalue, int64 maxvalue)
{
setConfig(index, fieldname, defvalue);
if (getConfig(index) < minvalue)
{
sLog.outError("%s (%i) must be in range %i...%i. Using %i instead.", fieldname, getConfig(index), minvalue, maxvalue, minvalue);
setConfig(index, minvalue);
}
else if (getConfig(index) > maxvalue)
{
sLog.outError("%s (%i) must be in range %i...%i. Using %i instead.", fieldname, getConfig(index), minvalue, maxvalue, maxvalue);
setConfig(index, maxvalue);
}
}
void World::setConfigMinMax(eConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 minvalue, uint32 maxvalue) void World::setConfigMinMax(eConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 minvalue, uint32 maxvalue)
{ {
setConfig(index, fieldname, defvalue); setConfig(index, fieldname, defvalue);

View file

@ -82,6 +82,19 @@ enum WorldTimers
}; };
/// Configuration elements /// Configuration elements
// just placeholder for int64 values
enum eConfigInt64Values
{
CONFIG_INT64_VALUE_COUNT = 1 // change this value after new constances added
};
enum eConfigUInt64Values
{
CONFIG_UINT64_START_PLAYER_MONEY = 0,
CONFIG_UINT64_VALUE_COUNT
};
enum eConfigUInt32Values enum eConfigUInt32Values
{ {
CONFIG_UINT32_COMPRESSION = 0, CONFIG_UINT32_COMPRESSION = 0,
@ -107,7 +120,6 @@ enum eConfigUInt32Values
CONFIG_UINT32_MAX_PLAYER_LEVEL, CONFIG_UINT32_MAX_PLAYER_LEVEL,
CONFIG_UINT32_START_PLAYER_LEVEL, CONFIG_UINT32_START_PLAYER_LEVEL,
CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL, CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL,
CONFIG_UINT32_START_PLAYER_MONEY,
CONFIG_UINT32_CURRENCY_START_HONOR_POINTS, CONFIG_UINT32_CURRENCY_START_HONOR_POINTS,
CONFIG_UINT32_CURRENCY_START_CONQUEST_POINTS, CONFIG_UINT32_CURRENCY_START_CONQUEST_POINTS,
CONFIG_UINT32_CURRENCY_CONQUEST_POINTS_DEFAULT_WEEK_CAP, CONFIG_UINT32_CURRENCY_CONQUEST_POINTS_DEFAULT_WEEK_CAP,
@ -543,6 +555,16 @@ class World
/// Get a server configuration element (see #eConfigFloatValues) /// Get a server configuration element (see #eConfigFloatValues)
float getConfig(eConfigFloatValues rate) const { return m_configFloatValues[rate]; } float getConfig(eConfigFloatValues rate) const { return m_configFloatValues[rate]; }
/// Set a server configuration element (see #eConfigUInt64Values)
void setConfig(eConfigUInt64Values index, uint64 value) { m_configUint64Values[index] = value; }
/// Get a server configuration element (see #eConfigUInt64Values)
uint32 getConfig(eConfigUInt64Values index) const { return m_configUint64Values[index]; }
/// Set a server configuration element (see #eConfigUInt64Values)
void setConfig(eConfigInt64Values index, int64 value) { m_configInt64Values[index] = value; }
/// Get a server configuration element (see #eConfigUInt64Values)
uint32 getConfig(eConfigInt64Values index) const { return m_configInt64Values[index]; }
/// Set a server configuration element (see #eConfigUInt32Values) /// Set a server configuration element (see #eConfigUInt32Values)
void setConfig(eConfigUInt32Values index, uint32 value) { m_configUint32Values[index] = value; } void setConfig(eConfigUInt32Values index, uint32 value) { m_configUint32Values[index] = value; }
/// Get a server configuration element (see #eConfigUInt32Values) /// Get a server configuration element (see #eConfigUInt32Values)
@ -609,14 +631,20 @@ class World
void ResetMonthlyQuests(); void ResetMonthlyQuests();
private: private:
void setConfig(eConfigUInt64Values index, char const* fieldname, uint64 defvalue);
void setConfig(eConfigInt64Values index, char const* fieldname, int64 defvalue);
void setConfig(eConfigUInt32Values index, char const* fieldname, uint32 defvalue); void setConfig(eConfigUInt32Values index, char const* fieldname, uint32 defvalue);
void setConfig(eConfigInt32Values index, char const* fieldname, int32 defvalue); void setConfig(eConfigInt32Values index, char const* fieldname, int32 defvalue);
void setConfig(eConfigFloatValues index, char const* fieldname, float defvalue); void setConfig(eConfigFloatValues index, char const* fieldname, float defvalue);
void setConfig(eConfigBoolValues index, char const* fieldname, bool defvalue); void setConfig(eConfigBoolValues index, char const* fieldname, bool defvalue);
void setConfigPos(eConfigFloatValues index, char const* fieldname, float defvalue); void setConfigPos(eConfigFloatValues index, char const* fieldname, float defvalue);
void setConfigMin(eConfigUInt64Values index, char const* fieldname, uint64 defvalue, uint64 minvalue);
void setConfigMin(eConfigInt64Values index, char const* fieldname, int64 defvalue, int64 minvalue);
void setConfigMin(eConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 minvalue); void setConfigMin(eConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 minvalue);
void setConfigMin(eConfigInt32Values index, char const* fieldname, int32 defvalue, int32 minvalue); void setConfigMin(eConfigInt32Values index, char const* fieldname, int32 defvalue, int32 minvalue);
void setConfigMin(eConfigFloatValues index, char const* fieldname, float defvalue, float minvalue); void setConfigMin(eConfigFloatValues index, char const* fieldname, float defvalue, float minvalue);
void setConfigMinMax(eConfigUInt64Values index, char const* fieldname, uint64 defvalue, uint64 minvalue, uint64 maxvalue);
void setConfigMinMax(eConfigInt64Values index, char const* fieldname, int64 defvalue, int64 minvalue, int64 maxvalue);
void setConfigMinMax(eConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 minvalue, uint32 maxvalue); void setConfigMinMax(eConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 minvalue, uint32 maxvalue);
void setConfigMinMax(eConfigInt32Values index, char const* fieldname, int32 defvalue, int32 minvalue, int32 maxvalue); void setConfigMinMax(eConfigInt32Values index, char const* fieldname, int32 defvalue, int32 minvalue, int32 maxvalue);
void setConfigMinMax(eConfigFloatValues index, char const* fieldname, float defvalue, float minvalue, float maxvalue); void setConfigMinMax(eConfigFloatValues index, char const* fieldname, float defvalue, float minvalue, float maxvalue);
@ -643,6 +671,8 @@ class World
uint32 m_maxActiveSessionCount; uint32 m_maxActiveSessionCount;
uint32 m_maxQueuedSessionCount; uint32 m_maxQueuedSessionCount;
uint64 m_configUint64Values[CONFIG_UINT64_VALUE_COUNT];
int64 m_configInt64Values[CONFIG_INT64_VALUE_COUNT];
uint32 m_configUint32Values[CONFIG_UINT32_VALUE_COUNT]; uint32 m_configUint32Values[CONFIG_UINT32_VALUE_COUNT];
int32 m_configInt32Values[CONFIG_INT32_VALUE_COUNT]; int32 m_configInt32Values[CONFIG_INT32_VALUE_COUNT];
float m_configFloatValues[CONFIG_FLOAT_VALUE_COUNT]; float m_configFloatValues[CONFIG_FLOAT_VALUE_COUNT];

View file

@ -105,6 +105,12 @@ int32 Config::GetIntDefault(const char* name, int32 def)
return GetValueHelper(mConf, name, val) ? atoi(val.c_str()) : def; return GetValueHelper(mConf, name, val) ? atoi(val.c_str()) : def;
} }
int64 Config::GetInt64Default(const char* name, int64 def)
{
ACE_TString val;
return GetValueHelper(mConf, name, val) ? atoi(val.c_str()) : def;
}
float Config::GetFloatDefault(const char* name, float def) float Config::GetFloatDefault(const char* name, float def)
{ {
ACE_TString val; ACE_TString val;

View file

@ -38,6 +38,7 @@ class MANGOS_DLL_SPEC Config
std::string GetStringDefault(const char* name, const char* def); std::string GetStringDefault(const char* name, const char* def);
bool GetBoolDefault(const char* name, const bool def = false); bool GetBoolDefault(const char* name, const bool def = false);
int32 GetIntDefault(const char* name, const int32 def); int32 GetIntDefault(const char* name, const int32 def);
int64 GetInt64Default(const char* name, const int64 def);
float GetFloatDefault(const char* name, const float def); float GetFloatDefault(const char* name, const float def);
std::string GetFilename() const { return mFilename; } std::string GetFilename() const { return mFilename; }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "12712" #define REVISION_NR "12713"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__