mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[11187] Minimize direct access to honor and arena points fields
This commit is contained in:
parent
49ef8edb6a
commit
972c08a878
4 changed files with 43 additions and 37 deletions
|
|
@ -737,8 +737,8 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
|
|||
InitRunes();
|
||||
|
||||
SetUInt32Value (PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_UINT32_START_PLAYER_MONEY));
|
||||
SetUInt32Value (PLAYER_FIELD_HONOR_CURRENCY, sWorld.getConfig(CONFIG_UINT32_START_HONOR_POINTS));
|
||||
SetUInt32Value (PLAYER_FIELD_ARENA_CURRENCY, sWorld.getConfig(CONFIG_UINT32_START_ARENA_POINTS));
|
||||
SetHonorPoints(sWorld.getConfig(CONFIG_UINT32_START_HONOR_POINTS));
|
||||
SetArenaPoints(sWorld.getConfig(CONFIG_UINT32_START_ARENA_POINTS));
|
||||
|
||||
// Played time
|
||||
m_Last_tick = time(NULL);
|
||||
|
|
@ -6646,30 +6646,40 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor)
|
|||
return true;
|
||||
}
|
||||
|
||||
void Player::ModifyHonorPoints( int32 value )
|
||||
void Player::SetHonorPoints(uint32 value)
|
||||
{
|
||||
if(value < 0)
|
||||
{
|
||||
if (GetHonorPoints() > sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS))
|
||||
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS) + value);
|
||||
else
|
||||
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, GetHonorPoints() > uint32(-value) ? GetHonorPoints() + value : 0);
|
||||
}
|
||||
else
|
||||
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, GetHonorPoints() < sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS) - value ? GetHonorPoints() + value : sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS));
|
||||
if (value > sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS))
|
||||
value = sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS);
|
||||
|
||||
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, value);
|
||||
}
|
||||
|
||||
void Player::ModifyArenaPoints( int32 value )
|
||||
void Player::SetArenaPoints(uint32 value)
|
||||
{
|
||||
if(value < 0)
|
||||
{
|
||||
if (GetArenaPoints() > sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS))
|
||||
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS) + value);
|
||||
else
|
||||
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, GetArenaPoints() > uint32(-value) ? GetArenaPoints() + value : 0);
|
||||
}
|
||||
else
|
||||
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, GetArenaPoints() < sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS) - value ? GetArenaPoints() + value : sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS));
|
||||
if (value > sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS))
|
||||
value = sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS);
|
||||
|
||||
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, value);
|
||||
}
|
||||
|
||||
void Player::ModifyHonorPoints(int32 value)
|
||||
{
|
||||
int32 newValue = (int32)GetHonorPoints() + value;
|
||||
|
||||
if (newValue < 0)
|
||||
newValue = 0;
|
||||
|
||||
SetHonorPoints(newValue);
|
||||
}
|
||||
|
||||
void Player::ModifyArenaPoints(int32 value)
|
||||
{
|
||||
int32 newValue = (int32)GetArenaPoints() + value;
|
||||
|
||||
if (newValue < 0)
|
||||
newValue = 0;
|
||||
|
||||
SetArenaPoints(newValue);
|
||||
}
|
||||
|
||||
uint32 Player::GetGuildIdFromDB(ObjectGuid guid)
|
||||
|
|
@ -15313,11 +15323,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder )
|
|||
|
||||
_LoadArenaTeamInfo(holder->GetResult(PLAYER_LOGIN_QUERY_LOADARENAINFO));
|
||||
|
||||
uint32 arena_currency = fields[39].GetUInt32();
|
||||
if (arena_currency > sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS))
|
||||
arena_currency = sWorld.getConfig(CONFIG_UINT32_MAX_ARENA_POINTS);
|
||||
|
||||
SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, arena_currency);
|
||||
SetArenaPoints(fields[39].GetUInt32());
|
||||
|
||||
// check arena teams integrity
|
||||
for(uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot)
|
||||
|
|
@ -15335,10 +15341,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder )
|
|||
SetArenaTeamInfoField(arena_slot, ArenaTeamInfoType(j), 0);
|
||||
}
|
||||
|
||||
uint32 honor_currency = fields[40].GetUInt32();
|
||||
if (honor_currency > sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS))
|
||||
honor_currency = sWorld.getConfig(CONFIG_UINT32_MAX_HONOR_POINTS);
|
||||
SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, honor_currency);
|
||||
SetHonorPoints(fields[40].GetUInt32());
|
||||
|
||||
SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, fields[41].GetUInt32());
|
||||
SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, fields[42].GetUInt32());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue