diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 089b0b508..78698b957 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -4724,9 +4724,9 @@ bool ChatHandler::HandleResetHonorCommand(char* args) if (!ExtractPlayerTarget(&args, &target)) return false; + target->SetHonorPoints(0); target->SetUInt32Value(PLAYER_FIELD_KILLS, 0); target->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS, 0); - target->SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, 0); target->SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, 0); target->SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0); target->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index bcf2d9ee1..83e8256d6 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -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()); diff --git a/src/game/Player.h b/src/game/Player.h index 09325beca..f4c73b6f5 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -2010,10 +2010,13 @@ class MANGOS_DLL_SPEC Player : public Unit void UpdateArenaFields(); void UpdateHonorFields(); bool RewardHonor(Unit *pVictim, uint32 groupsize, float honor = -1); - uint32 GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); } - uint32 GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); } - void ModifyHonorPoints( int32 value ); - void ModifyArenaPoints( int32 value ); + uint32 GetHonorPoints() const { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); } + uint32 GetArenaPoints() const { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); } + void SetHonorPoints(uint32 value); + void SetArenaPoints(uint32 value); + void ModifyHonorPoints(int32 value); + void ModifyArenaPoints(int32 value); + uint32 GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot); //End of PvP System diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 016b34307..0cd7549c9 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 "11186" + #define REVISION_NR "11187" #endif // __REVISION_NR_H__