关灯
开启左侧

T端的每周或则每天获得点数的上限

  [复制链接]
admin实名认证 发表于 2016-4-19 22:56:13 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
 
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;

 
VIP介绍
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 最佳新人

    注册账号后积极发帖的会员
  • 活跃会员

    经常参与各类话题的讨论,发帖内容较有主见
  • 热心会员

    经常帮助其他会员答疑
  • 推广达人

    积极宣传本站,为本站带来更多注册会员
  • 宣传达人

    积极宣传本站,为本站带来更多的用户访问量
  • 灌水之王

    经常在论坛发帖,且发帖量较大
  • 突出贡献

    长期对论坛的繁荣而不断努力,或多次提出建设性意见
  • 优秀版主

    活跃且尽责职守的版主
  • 荣誉管理

    曾经为论坛做出突出贡献目前已离职的版主
  • 论坛元老

    为论坛做出突出贡献的会员

0关注

5粉丝

3421帖子

排行榜
作者专栏

QQ交流群&&微信订阅号

QQ交流群

微信订阅号

吾爱尚玩资源基地永久域名:

Www.523Play.Com

在线管理员QQ:1589479632

邮箱:Email@523play.com

QQ交流群:558936238

Copyright   ©2015-2116  吾爱尚玩资源基地|523play.comPowered by©523Pplay.Com技术支持:吾爱尚玩资源基地