mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[12151] Init currency week limits on new currency recieved
Signed-off-by: Yaki Khadafi <elsoldollo@gmail.com>
This commit is contained in:
parent
8e5d609e1e
commit
f2cf0bcd19
3 changed files with 16 additions and 7 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "12150"
|
||||
#define REVISION_NR "12151"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue