Author: fedr <fedr90@gmail.com> 2011-07-18 22:54:33
Committer: fedr <fedr90@gmail.com> 2011-07-18 22:54:33
Parent: dc9c7f3034c6f16d306643fd765ec5942d285a1b (Merge pull request #102 from fedr/master)
Child: c1cee8f868ebb563d036dab273f000298e48b38f (Currency: Remove Week Cap for Honor Points)
Branches: master, mgcore, remotes/origin/420, remotes/origin/AHBot_development(temp), remotes/origin/WinterGrasp_development, remotes/origin/anti-hack, remotes/origin/master, remotes/origin/opcode_db, remotes/origin/running_wild
Follows: 403
Precedes: Others_Fix-Start
Currency: Week Cap Reset
------------------ src/server/game/Entities/Player/Player.cpp ------------------
index 70a44aa..d1530de 100644
@@ -22088,9 +22088,14 @@ void Player::ResetWeeklyQuestStatus()
m_weeklyquests.clear();
// DB data deleted in caller
m_WeeklyQuestChanged = false;
+}
+void Player::ResetCurrencyWeekCap()
+{
for (PlayerCurrenciesMap::iterator itr = m_currencies.begin(); itr != m_currencies.end(); ++itr)
- itr->second.weekCount = 0; // no need to change state here as sWorld resets currencies in DB
+ itr->second.weekCount = 0;
+ SendCurrencies();
+
}
Battleground* Player::GetBattleground() const
------------------- src/server/game/Entities/Player/Player.h -------------------
index 14ef3b7..84a987a 100644
@@ -1435,6 +1435,8 @@ class Player : public Unit, public GridObject<Player>
void ResetDailyQuestStatus();
void ResetWeeklyQuestStatus();
+ void ResetCurrencyWeekCap();
+
uint16 FindQuestSlot(uint32 quest_id) const;
uint32 GetQuestSlotQuestId(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_ID_OFFSET); }
uint32 GetQuestSlotState(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET); }
----------------------- src/server/game/World/World.cpp -----------------------
index 703cb1e..2e991e2 100644
@@ -107,6 +107,7 @@ World::World()
m_MaxPlayerCount = 0;
m_NextDailyQuestReset = 0;
m_NextWeeklyQuestReset = 0;
+ m_NextCurrencyReset = 0;
m_scheduledScripts = 0;
debugOpcode = 0;
@@ -1758,6 +1759,9 @@ void World::SetInitialWorldSettings()
sLog->outString("Calculate random battleground reset time..." );
InitRandomBGResetTime();
+ sLog->outString("Calculate currency week cap reset time..." );
+ InitCurrencyResetTime();
+
// possibly enable db logging; avoid massive startup spam by doing it here.
if (sLog->GetLogDBLater())
{
@@ -1922,6 +1926,9 @@ void World::Update(uint32 diff)
if (m_gameTime > m_NextRandomBGReset)
ResetRandomBG();
+ if (m_gameTime > m_NextCurrencyReset)
+ ResetCurrencyWeekCap();
+
/// <ul><li> Handle auctions when the timer has passed
if (m_timers[WUPDATE_AUCTIONS].Passed())
{
@@ -2706,6 +2713,13 @@ void World::InitRandomBGResetTime()
sWorld->setWorldState(WS_BG_DAILY_RESET_TIME, uint64(m_NextRandomBGReset));
}
+void World::InitCurrencyResetTime()
+{
+ time_t wsTime = getWorldState(WS_CURRENCY_RESET_TIME);
+ time_t curTime = time(NULL);
+ m_NextCurrencyReset = wsTime < curTime ? curTime : wsTime;
+}
+
void World::ResetDailyQuests()
{
sLog->outDetail("Daily quests reset for all characters.");
@@ -2737,7 +2751,6 @@ void World::SetPlayerSecurityLimit(AccountTypes _sec)
void World::ResetWeeklyQuests()
{
CharacterDatabase.Execute("DELETE FROM character_queststatus_weekly");
- CharacterDatabase.Execute("UPDATE character_currency SET thisweek = 0");
for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
if (itr->second->GetPlayer())
itr->second->GetPlayer()->ResetWeeklyQuestStatus();
@@ -2761,6 +2774,18 @@ void World::ResetRandomBG()
sWorld->setWorldState(WS_BG_DAILY_RESET_TIME, uint64(m_NextRandomBGReset));
}
+void World::ResetCurrencyWeekCap()
+{
+ sLog->outDetail("Currencies week caps reset for all characters.");
+ CharacterDatabase.Execute("UPDATE character_currency SET thisweek = 0");
+ for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
+ if (itr->second->GetPlayer())
+ itr->second->GetPlayer()->ResetCurrencyWeekCap();
+
+ m_NextCurrencyReset = time_t(m_NextCurrencyReset + WEEK);
+ sWorld->setWorldState(WS_CURRENCY_RESET_TIME, uint64(m_NextCurrencyReset));
+}
+
void World::UpdateMaxSessionCounters()
{
m_maxActiveSessionCount = std::max(m_maxActiveSessionCount,uint32(m_sessions.size()-m_QueuedPlayer.size()));
------------------------ src/server/game/World/World.h ------------------------
index 96222ab..dc3f38e 100644
@@ -465,7 +465,8 @@ enum RealmZone
enum WorldStates
{
WS_WEEKLY_QUEST_RESET_TIME = 20002, // Next weekly reset time
- WS_BG_DAILY_RESET_TIME = 20003 // Next daily BG reset time
+ WS_BG_DAILY_RESET_TIME = 20003, // Next daily BG reset time
+ WS_CURRENCY_RESET_TIME = 20004 // Next currency week cap reset time
};
// DB scripting commands
@@ -620,6 +621,7 @@ class World
time_t GetNextDailyQuestsResetTime() const { return m_NextDailyQuestReset; }
time_t GetNextWeeklyQuestsResetTime() const { return m_NextWeeklyQuestReset; }
time_t GetNextRandomBGResetTime() const { return m_NextRandomBGReset; }
+ time_t GetNextCurrencyResetTime() const { return m_NextCurrencyReset; }
/// Get the maximum skill level a player can reach
uint16 GetConfigMaxSkillValue() const
@@ -763,9 +765,11 @@ class World
void InitDailyQuestResetTime();
void InitWeeklyQuestResetTime();
void InitRandomBGResetTime();
+ void InitCurrencyResetTime();
void ResetDailyQuests();
void ResetWeeklyQuests();
void ResetRandomBG();
+ void ResetCurrencyWeekCap();
private:
static volatile bool m_stopEvent;
static uint8 m_ExitCode;
@@ -830,6 +834,7 @@ class World
time_t m_NextDailyQuestReset;
time_t m_NextWeeklyQuestReset;
time_t m_NextRandomBGReset;
+ time_t m_NextCurrencyReset;
//Player Queue
Queue m_QueuedPlayer;
|