Azerothcore-wotlk: [Config]Auto Distribute Points

Created on 29 Apr 2017  路  6Comments  路  Source: azerothcore/azerothcore-wotlk

Description: The timing of the distribution of the arena points does not work

Current behaviour: That's just the point, nothing happens!

Expected behaviour: Automatic charging at a specified time.

Steps to reproduce the problem:

  1. Set value Arena.AutoDistributePoints = 1
  2. Set value Arena.AutoDistributeInterval = 1

Branch(es): Master

Operating system: Debian 8


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Fix included Priority - High Waiting to be tested

Most helpful comment

Now need wait @ShinDarth and he will say " @HeartWell open PR plz" :D

All 6 comments

Test plz.
```diff
From d32c407c1c4d0fbb843935a5c59898829c173bee Mon Sep 17 00:00:00 2001
From: HeartWell heartwell@list.ru
Date: Sun, 30 Apr 2017 09:55:53 +0300
Subject: [PATCH] Core/Arena: Fix auto distribute points.


src/server/game/Battlegrounds/BattlegroundMgr.cpp | 29 ++++++++++++++++-------
src/server/game/Battlegrounds/BattlegroundMgr.h | 3 +++
2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
index b90a7fa..727bc26 100644
--- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
@@ -52,7 +52,7 @@
/*******************/

BattlegroundMgr::BattlegroundMgr() : m_ArenaTesting(false), m_Testing(false),
- m_lastClientVisibleInstanceId(0), m_NextAutoDistributionTime(0), m_NextPeriodicQueueUpdateTime(5IN_MILLISECONDS), randomBgDifficultyEntry(999, 0, 80, 80, 0)
+ m_lastClientVisibleInstanceId(0), m_NextAutoDistributionTime(0), m_AutoDistributionTimeChecker(0), m_NextPeriodicQueueUpdateTime(5
IN_MILLISECONDS), randomBgDifficultyEntry(999, 0, 80, 80, 0)
{
for (uint32 qtype = BATTLEGROUND_QUEUE_NONE; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype)
m_BattlegroundQueues[qtype].SetBgTypeIdAndArenaType(BGTemplateId(BattlegroundQueueTypeId(qtype)), BGArenaType(BattlegroundQueueTypeId(qtype)));
@@ -135,12 +135,18 @@ void BattlegroundMgr::Update(uint32 diff)
// arena points auto-distribution
if (sWorld->getBoolConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS))
{
- if (sWorld->GetGameTime() > m_NextAutoDistributionTime)
+ if (m_AutoDistributionTimeChecker < diff)
{
- sArenaTeamMgr->DistributeArenaPoints();
- m_NextAutoDistributionTime = sWorld->GetNextTimeWithDayAndHour(5, 18);
- sWorld->setWorldState(WS_ARENA_DISTRIBUTION_TIME, uint64(m_NextAutoDistributionTime));
+ if (time(NULL) > m_NextAutoDistributionTime)
+ {
+ sArenaTeamMgr->DistributeArenaPoints();
+ m_NextAutoDistributionTime = m_NextAutoDistributionTime + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld->getIntConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS);
+ sWorld->setWorldState(WS_ARENA_DISTRIBUTION_TIME, uint64(m_NextAutoDistributionTime));
+ }
+ m_AutoDistributionTimeChecker = 600000; // check 10 minutes
}
+ else
+ m_AutoDistributionTimeChecker -= diff;
}
}

@@ -696,9 +702,16 @@ void BattlegroundMgr::InitAutomaticArenaPointDistribution()
return;

 time_t wstime = time_t(sWorld->getWorldState(WS_ARENA_DISTRIBUTION_TIME));

  • m_NextAutoDistributionTime = wstime ? wstime : sWorld->GetNextTimeWithDayAndHour(5, 18);
  • if (!wstime)
  • sWorld->setWorldState(WS_ARENA_DISTRIBUTION_TIME, uint64(m_NextAutoDistributionTime));
  • time_t curtime = time(NULL);
  • sLog->outDebug(LOG_FILTER_BATTLEGROUND, "TSCR: bg.battleground", "Initializing Automatic Arena Point Distribution");
  • if (wstime < curtime)
  • {
  • m_NextAutoDistributionTime = curtime; // reset will be called in the next update
  • sLog->outDebug(LOG_FILTER_BATTLEGROUND, "TSCR: bg.battleground", "Battleground: Next arena point distribution time in the past, reseting it now.");
  • }
  • else
  • m_NextAutoDistributionTime = wstime;
  • sLog->outDebug(LOG_FILTER_BATTLEGROUND, "TSCR: bg.battleground", "Automatic Arena Point Distribution initialized.");
    }

void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* player, BattlegroundTypeId bgTypeId, uint8 fromWhere)
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h
index 9338ac4..2934e06 100644
--- a/src/server/game/Battlegrounds/BattlegroundMgr.h
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.h
@@ -29,6 +29,8 @@
typedef std::map BattlegroundContainer;
typedef std::unordered_map BattleMastersMap;

+#define BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY 86400 // seconds in a day
+
struct CreateBattlegroundData
{
BattlegroundTypeId bgTypeId;
@@ -157,6 +159,7 @@ class BattlegroundMgr
uint32 m_lastClientVisibleInstanceId;
uint32 m_NextPeriodicQueueUpdateTime;
time_t m_NextAutoDistributionTime;

  • uint32 m_AutoDistributionTimeChecker;
    bool m_ArenaTesting;
    bool m_Testing;

BattleMastersMap mBattleMastersMap;

2.11.0.windows.1

Now need wait @ShinDarth and he will say " @HeartWell open PR plz" :D

I was really tempted when I first saw it, but then I thought just let it be

Who test my patch?

This can be closed. The fix is included, working and merged #927

@poszer thank you friend!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FrancescoBorzi picture FrancescoBorzi  路  3Comments

Franklampardst picture Franklampardst  路  4Comments

fallen26 picture fallen26  路  3Comments

dev-master21 picture dev-master21  路  3Comments

wowissues picture wowissues  路  3Comments