[Core/Currency] not allow add more then week limit.

This commit is contained in:
cyberbrest
2012-09-03 22:55:02 +03:00
parent 9025a86536
commit e9a3d38769
+13 -4
View File
@@ -7366,6 +7366,11 @@ void Player::ModifyCurrency(uint32 id, int32 count, bool printLog/* = true*/)
oldWeekCount = itr->second.weekCount;
}
// count can't be more then weekCap.
uint32 weekCap = _GetCurrencyWeekCap(currency);
if (count > int32(weekCap))
count = weekCap;
int32 newTotalCount = int32(oldTotalCount) + count;
if (newTotalCount < 0)
newTotalCount = 0;
@@ -7374,12 +7379,16 @@ void Player::ModifyCurrency(uint32 id, int32 count, bool printLog/* = true*/)
if (newWeekCount < 0)
newWeekCount = 0;
// TODO: fix conquest points
ASSERT(weekCap >= oldWeekCount);
// if we get more then weekCap just set to limit.
uint32 weekCap = _GetCurrencyWeekCap(currency);
if (weekCap && int32(weekCap) < newTotalCount)
// TODO: fix conquest points
// if we get more then weekCap just set to limit
if (weekCap && int32(weekCap) < newWeekCount)
{
newWeekCount = int32(weekCap);
// weekCap - oldWeekCount alwayt >= 0 as we set limit before!
newTotalCount = oldTotalCount + (weekCap - oldWeekCount);
}
// if we get more then totalCap set to maximum;
if (currency->TotalCap && int32(currency->TotalCap) < newTotalCount)