From f2cf0bcd19c63c98f3bf50458595283131c5db3e Mon Sep 17 00:00:00 2001 From: Yaki Khadafi Date: Thu, 30 Aug 2012 12:54:41 +0300 Subject: [PATCH] [12151] Init currency week limits on new currency recieved Signed-off-by: Yaki Khadafi --- src/game/Player.cpp | 20 ++++++++++++++------ src/game/Player.h | 1 + src/shared/revision_nr.h | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index f1ffdb412..50f4f1135 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -23199,14 +23199,15 @@ uint32 Player::GetCurrencyWeekCap(CurrencyTypesEntry const * currency) const void Player::SendCurrencyWeekCap(uint32 id) const { - if (!IsInWorld() || GetSession()->PlayerLoading()) + SendCurrencyWeekCap(sCurrencyTypesStore.LookupEntry(id)); +} + +void Player::SendCurrencyWeekCap(CurrencyTypesEntry const * currency) const +{ + if (!currency || !IsInWorld() || GetSession()->PlayerLoading()) return; - CurrencyTypesEntry const * currency = sCurrencyTypesStore.LookupEntry(id); - if (!currency) - return; - - uint32 cap = GetCurrencyTotalCap(currency); + uint32 cap = GetCurrencyWeekCap(currency); if (!cap) return; @@ -23252,6 +23253,7 @@ void Player::ModifyCurrencyCount(uint32 id, int32 count, bool modifyWeek, bool m int32 oldWeekCount = 0; PlayerCurrenciesMap::iterator itr = m_currencies.find(id); + bool initWeek = false; if (itr == m_currencies.end()) { currency = sCurrencyTypesStore.LookupEntry(id); @@ -23265,6 +23267,7 @@ void Player::ModifyCurrencyCount(uint32 id, int32 count, bool modifyWeek, bool m cur.flags = 0; cur.currencyEntry = currency; m_currencies[id] = cur; + initWeek = true; itr = m_currencies.find(id); } else @@ -23297,6 +23300,7 @@ void Player::ModifyCurrencyCount(uint32 id, int32 count, bool modifyWeek, bool m newWeekCount = weekCap; newTotalCount -= delta; } + initWeek &= weekCap != currency->WeekCap; if (newTotalCount != oldTotalCount) { @@ -23331,6 +23335,10 @@ void Player::ModifyCurrencyCount(uint32 id, int32 count, bool modifyWeek, bool m if (bit0) packet << uint32(floor(newWeekCount / currency->GetPrecision())); GetSession()->SendPacket(&packet); + + // init currency week limit for new currencies + if (initWeek) + SendCurrencyWeekCap(currency); } if (itr->first == CURRENCY_CONQUEST_ARENA_META || itr->first == CURRENCY_CONQUEST_BG_META) diff --git a/src/game/Player.h b/src/game/Player.h index ef9e2a138..806cde679 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1983,6 +1983,7 @@ class MANGOS_DLL_SPEC Player : public Unit bool HasCurrencySeasonCount(uint32 id, uint32 count) const { return GetCurrencySeasonCount(id) >= count; } void SetCurrencyCount(uint32 id, uint32 count); void SendCurrencyWeekCap(uint32 id) const; + void SendCurrencyWeekCap(CurrencyTypesEntry const * currency) const; void SetCurrencyFlags(uint32 currencyId, uint8 flags); void ResetCurrencyWeekCounts(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index b1b2551f3..f5394a3e6 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 "12150" + #define REVISION_NR "12151" #endif // __REVISION_NR_H__