diff --git a/src/game/Player.cpp b/src/game/Player.cpp index c0b78c0a8..65257fc79 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -709,7 +709,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c 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_CONQUEST_POINTS, sWorld.getConfig(CONFIG_UINT32_CURRENCY_START_CONQUEST_POINTS)); diff --git a/src/game/World.cpp b/src/game/World.cpp index 38f9d33a0..19487cc6e 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -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_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_WEEK_DAY, "Currency.ResetWeekDay", 3, 0, 6); @@ -2322,6 +2322,21 @@ void World::LoadDBVersion() 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) { 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) { 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) { setConfig(index, fieldname, defvalue); diff --git a/src/game/World.h b/src/game/World.h index b09d29107..da14741d6 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -82,6 +82,19 @@ enum WorldTimers }; /// 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 { CONFIG_UINT32_COMPRESSION = 0, @@ -107,7 +120,6 @@ enum eConfigUInt32Values CONFIG_UINT32_MAX_PLAYER_LEVEL, CONFIG_UINT32_START_PLAYER_LEVEL, CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL, - CONFIG_UINT32_START_PLAYER_MONEY, CONFIG_UINT32_CURRENCY_START_HONOR_POINTS, CONFIG_UINT32_CURRENCY_START_CONQUEST_POINTS, CONFIG_UINT32_CURRENCY_CONQUEST_POINTS_DEFAULT_WEEK_CAP, @@ -543,6 +555,16 @@ class World /// Get a server configuration element (see #eConfigFloatValues) 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) void setConfig(eConfigUInt32Values index, uint32 value) { m_configUint32Values[index] = value; } /// Get a server configuration element (see #eConfigUInt32Values) @@ -609,14 +631,20 @@ class World void ResetMonthlyQuests(); 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(eConfigInt32Values index, char const* fieldname, int32 defvalue); void setConfig(eConfigFloatValues index, char const* fieldname, float defvalue); void setConfig(eConfigBoolValues index, char const* fieldname, bool 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(eConfigInt32Values index, char const* fieldname, int32 defvalue, int32 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(eConfigInt32Values index, char const* fieldname, int32 defvalue, int32 minvalue, int32 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_maxQueuedSessionCount; + uint64 m_configUint64Values[CONFIG_UINT64_VALUE_COUNT]; + int64 m_configInt64Values[CONFIG_INT64_VALUE_COUNT]; uint32 m_configUint32Values[CONFIG_UINT32_VALUE_COUNT]; int32 m_configInt32Values[CONFIG_INT32_VALUE_COUNT]; float m_configFloatValues[CONFIG_FLOAT_VALUE_COUNT]; diff --git a/src/shared/Config/Config.cpp b/src/shared/Config/Config.cpp index fd2f0c950..a2637ef3b 100644 --- a/src/shared/Config/Config.cpp +++ b/src/shared/Config/Config.cpp @@ -105,6 +105,12 @@ int32 Config::GetIntDefault(const char* name, int32 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) { ACE_TString val; diff --git a/src/shared/Config/Config.h b/src/shared/Config/Config.h index f835cc6f4..558bb2a36 100644 --- a/src/shared/Config/Config.h +++ b/src/shared/Config/Config.h @@ -38,6 +38,7 @@ class MANGOS_DLL_SPEC Config std::string GetStringDefault(const char* name, const char* def); bool GetBoolDefault(const char* name, const bool def = false); int32 GetIntDefault(const char* name, const int32 def); + int64 GetInt64Default(const char* name, const int64 def); float GetFloatDefault(const char* name, const float def); std::string GetFilename() const { return mFilename; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index eaf5be887..f15a0cafb 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12712" + #define REVISION_NR "12713" #endif // __REVISION_NR_H__