mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[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:
parent
7f4338f0d6
commit
08913b2437
6 changed files with 106 additions and 4 deletions
|
|
@ -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));
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "12712"
|
||||
#define REVISION_NR "12713"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue