aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorTuxity <kevin.darcel@gmail.com>2013-01-10 14:18:14 +0100
committerTuxity <kevin.darcel@gmail.com>2013-01-10 14:18:14 +0100
commit2f48fe7cf1b2a9ac00bff2e9694b52764f2c62c4 (patch)
tree913affc4858fe13fafa57b9f0d05d2a6f1f64926 /src/server/game
parent3c8a9576923d226386578f6e7eba07b9e7bbc2e5 (diff)
Core/Currency:
- Fix a typo in conquest points formulas - Correctly fix max justice and honor points - Remove a previous fix when refunding an item, my mistake ref #8892
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/Entities/Player/Player.cpp47
-rw-r--r--src/server/game/Entities/Player/Player.h8
-rw-r--r--src/server/game/Miscellaneous/Formulas.h5
-rw-r--r--src/server/game/World/World.cpp14
4 files changed, 49 insertions, 25 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 117b461e6b6..c688bfd95f9 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -7437,6 +7437,11 @@ void Player::ModifyCurrency(uint32 id, int32 count, bool printLog/* = true*/, bo
if (weekCap && count > int32(weekCap))
count = weekCap;
+ // count can't be more then totalCap if used (totalCap > 0)
+ uint32 totalCap = _GetCurrencyTotalCap(currency);
+ if (totalCap && count > int32(totalCap))
+ count = totalCap;
+
int32 newTotalCount = int32(oldTotalCount) + count;
if (newTotalCount < 0)
newTotalCount = 0;
@@ -7445,20 +7450,18 @@ void Player::ModifyCurrency(uint32 id, int32 count, bool printLog/* = true*/, bo
if (newWeekCount < 0)
newWeekCount = 0;
- ASSERT(weekCap >= oldWeekCount);
-
// 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!
+ // weekCap - oldWeekCount always >= 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)
+ if (totalCap && int32(totalCap) < newTotalCount)
{
- newTotalCount = int32(currency->TotalCap);
+ newTotalCount = int32(totalCap);
newWeekCount = weekCap;
}
@@ -7571,10 +7574,29 @@ uint32 Player::_GetCurrencyWeekCap(const CurrencyTypesEntry* currency) const
return _ConquestCurrencyTotalWeekCap;
case CURRENCY_TYPE_CONQUEST_META_ARENA:
// should add precision mod = 100
- return Trinity::Currency::ConquestRatingCalculator(_maxPersonalArenaRate) * 100;
+ return Trinity::Currency::ConquestRatingCalculator(_maxPersonalArenaRate) * CURRENCY_PRECISION;
case CURRENCY_TYPE_CONQUEST_META_BG:
// should add precision mod = 100
- return Trinity::Currency::BgConquestRatingCalculator(GetRBGPersonalRating()) * 100;
+ return Trinity::Currency::BgConquestRatingCalculator(GetRBGPersonalRating()) * CURRENCY_PRECISION;
+ }
+
+ if (cap != currency->WeekCap && IsInWorld() && !GetSession()->PlayerLoading())
+ {
+ WorldPacket packet(SMSG_UPDATE_CURRENCY_WEEK_LIMIT, 8);
+ packet << uint32(cap / ((currency->Flags & CURRENCY_FLAG_HIGH_PRECISION) ? 100 : 1));
+ packet << uint32(currency->ID);
+ GetSession()->SendPacket(&packet);
+ }
+
+ return cap;
+}
+
+uint32 Player::_GetCurrencyTotalCap(const CurrencyTypesEntry* currency) const
+{
+ uint32 cap = currency->TotalCap;
+
+ switch (currency->ID)
+ {
case CURRENCY_TYPE_HONOR_POINTS:
{
uint32 honorcap = sWorld->getIntConfig(CONFIG_CURRENCY_MAX_HONOR_POINTS);
@@ -7591,16 +7613,7 @@ uint32 Player::_GetCurrencyWeekCap(const CurrencyTypesEntry* currency) const
}
}
- if (cap != currency->WeekCap && IsInWorld() && !GetSession()->PlayerLoading())
- {
- WorldPacket packet(SMSG_UPDATE_CURRENCY_WEEK_LIMIT, 8);
- packet << uint32(cap / ((currency->Flags & CURRENCY_FLAG_HIGH_PRECISION) ? 100 : 1));
- packet << uint32(currency->ID);
- GetSession()->SendPacket(&packet);
- }
-
return cap;
-
}
void Player::SetInGuild(uint32 guildId)
@@ -26152,7 +26165,7 @@ void Player::RefundItem(Item* item)
uint32 count = iece->RequiredCurrencyCount[i];
uint32 currencyid = iece->RequiredCurrency[i];
if (count && currencyid)
- ModifyCurrency(currencyid, count / CURRENCY_PRECISION);
+ ModifyCurrency(currencyid, count);
}
// Grant back money
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index ddff890bb6f..b6fc1599ce0 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -2935,6 +2935,14 @@ class Player : public Unit, public GridObject<Player>
*/
uint32 _GetCurrencyWeekCap(const CurrencyTypesEntry* currency) const;
+ /*
+ * @name _GetCurrencyTotalCap
+ * @brief return total cap for selected currency
+
+ * @param currency CurrencyTypesEntry witch should get week cap
+ */
+ uint32 _GetCurrencyTotalCap(const CurrencyTypesEntry* currency) const;
+
VoidStorageItem* _voidStorageItems[VOID_STORAGE_MAX_SLOT];
std::vector<Item*> m_itemUpdateQueue;
diff --git a/src/server/game/Miscellaneous/Formulas.h b/src/server/game/Miscellaneous/Formulas.h
index 3675e633bad..8ae333f2651 100644
--- a/src/server/game/Miscellaneous/Formulas.h
+++ b/src/server/game/Miscellaneous/Formulas.h
@@ -235,13 +235,14 @@ namespace Trinity
rate = 3000;
// http://www.arenajunkies.com/topic/179536-conquest-point-cap-vs-personal-rating-chart/page__st__60#entry3085246
- return 1.4326 * ((1511.26 / (1 + 1639.28 / exp(0.00412 * rate))) + 850.15);
+ return uint32(1.4326 * ((1511.26 / (1 + 1639.28 / exp(0.00412 * rate))) + 850.15));
}
inline uint32 BgConquestRatingCalculator(uint32 rate)
{
// WowWiki: Battleground ratings receive a bonus of 22.2% to the cap they generate
- return ConquestRatingCalculator(rate)*1.222f;
+ printf("%u",uint32(round(ConquestRatingCalculator(rate) * 1.222f)));
+ return uint32(round(ConquestRatingCalculator(rate) * 1.222f));
}
} // namespace Trinity::Currency
} // namespace Trinity
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index b4d2e7933d2..215e9bb629b 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -808,12 +808,13 @@ void World::LoadConfigSettings(bool reload)
sLog->outError(LOG_FILTER_SERVER_LOADING, "Currency.StartHonorPoints (%i) must be >= 0, set to default 0.", m_int_configs[CONFIG_CURRENCY_START_HONOR_POINTS]);
m_int_configs[CONFIG_CURRENCY_START_HONOR_POINTS] = 0;
}
- m_int_configs[CONFIG_CURRENCY_MAX_HONOR_POINTS] = ConfigMgr::GetIntDefault("Currency.MaxHonorPoints", 400000);
+ m_int_configs[CONFIG_CURRENCY_MAX_HONOR_POINTS] = ConfigMgr::GetIntDefault("Currency.MaxHonorPoints", 4000);
if (int32(m_int_configs[CONFIG_CURRENCY_MAX_HONOR_POINTS]) < 0)
{
- sLog->outError(LOG_FILTER_SERVER_LOADING, "Currency.MaxHonorPoints (%i) can't be negative. Set to default 400000 (with precision).", m_int_configs[CONFIG_CURRENCY_MAX_HONOR_POINTS]);
- m_int_configs[CONFIG_CURRENCY_MAX_HONOR_POINTS] = 400000;
+ sLog->outError(LOG_FILTER_SERVER_LOADING, "Currency.MaxHonorPoints (%i) can't be negative. Set to default 4000.", m_int_configs[CONFIG_CURRENCY_MAX_HONOR_POINTS]);
+ m_int_configs[CONFIG_CURRENCY_MAX_HONOR_POINTS] = 4000;
}
+ m_int_configs[CONFIG_CURRENCY_MAX_HONOR_POINTS] *= 100; //precision mod
m_int_configs[CONFIG_CURRENCY_START_JUSTICE_POINTS] = ConfigMgr::GetIntDefault("Currency.StartJusticePoints", 0);
if (int32(m_int_configs[CONFIG_CURRENCY_START_JUSTICE_POINTS]) < 0)
@@ -821,12 +822,13 @@ void World::LoadConfigSettings(bool reload)
sLog->outError(LOG_FILTER_SERVER_LOADING, "Currency.StartJusticePoints (%i) must be >= 0, set to default 0.", m_int_configs[CONFIG_CURRENCY_START_JUSTICE_POINTS]);
m_int_configs[CONFIG_CURRENCY_START_JUSTICE_POINTS] = 0;
}
- m_int_configs[CONFIG_CURRENCY_MAX_JUSTICE_POINTS] = ConfigMgr::GetIntDefault("Currency.MaxJusticePoints", 400000);
+ m_int_configs[CONFIG_CURRENCY_MAX_JUSTICE_POINTS] = ConfigMgr::GetIntDefault("Currency.MaxJusticePoints", 4000);
if (int32(m_int_configs[CONFIG_CURRENCY_MAX_JUSTICE_POINTS]) < 0)
{
- sLog->outError(LOG_FILTER_SERVER_LOADING, "Currency.MaxJusticePoints (%i) can't be negative. Set to default 400000 (with precision).", m_int_configs[CONFIG_CURRENCY_MAX_JUSTICE_POINTS]);
- m_int_configs[CONFIG_CURRENCY_MAX_JUSTICE_POINTS] = 400000;
+ sLog->outError(LOG_FILTER_SERVER_LOADING, "Currency.MaxJusticePoints (%i) can't be negative. Set to default 4000.", m_int_configs[CONFIG_CURRENCY_MAX_JUSTICE_POINTS]);
+ m_int_configs[CONFIG_CURRENCY_MAX_JUSTICE_POINTS] = 4000;
}
+ m_int_configs[CONFIG_CURRENCY_MAX_JUSTICE_POINTS] *= 100; //precision mod
m_int_configs[CONFIG_CURRENCY_START_CONQUEST_POINTS] = ConfigMgr::GetIntDefault("Currency.StartConquestPoints", 0);
if (int32(m_int_configs[CONFIG_CURRENCY_START_CONQUEST_POINTS]) < 0)