feat(core): Ensure that all actions are compared to fixed point in time (#1236) (#1458)

i.e. world update start
This commit is contained in:
Viste(Кирилл)
2019-02-14 21:22:17 +03:00
committed by Francesco Borzì
parent 1b7522ff0e
commit 51b8773528
108 changed files with 933 additions and 509 deletions

View File

@@ -9,6 +9,7 @@
#include "ArenaTeamMgr.h"
#include "World.h"
#include "WorldPacket.h"
#include "GameTime.h"
#include "ArenaTeam.h"
#include "BattlegroundMgr.h"
@@ -129,7 +130,7 @@ void BattlegroundMgr::Update(uint32 diff)
{
if (m_AutoDistributionTimeChecker < diff)
{
if (time(NULL) > m_NextAutoDistributionTime)
if (GameTime::GetGameTime() > m_NextAutoDistributionTime)
{
sArenaTeamMgr->DistributeArenaPoints();
m_NextAutoDistributionTime = m_NextAutoDistributionTime + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld->getIntConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS);
@@ -694,7 +695,7 @@ void BattlegroundMgr::InitAutomaticArenaPointDistribution()
return;
time_t wstime = time_t(sWorld->getWorldState(WS_ARENA_DISTRIBUTION_TIME));
time_t curtime = time(NULL);
time_t curtime = GameTime::GetGameTime();
sLog->outString("AzerothCore Battleground: Initializing Automatic Arena Point Distribution");
if (wstime < curtime)
{
@@ -1051,7 +1052,7 @@ void BattlegroundMgr::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, T
if (bg->isArena() && bg->isRated())
bg->SetArenaTeamIdForTeam(ginfo->teamId, ginfo->ArenaTeamId);
ginfo->RemoveInviteTime = World::GetGameTimeMS() + INVITE_ACCEPT_WAIT_TIME;
ginfo->RemoveInviteTime = GameTime::GetGameTimeMS() + INVITE_ACCEPT_WAIT_TIME;
// loop through the players
for (std::set<uint64>::iterator itr = ginfo->Players.begin(); itr != ginfo->Players.end(); ++itr)

View File

@@ -8,6 +8,7 @@
#include "ArenaTeamMgr.h"
#include "BattlegroundMgr.h"
#include "BattlegroundQueue.h"
#include "GameTime.h"
#include "Chat.h"
#include "Group.h"
#include "Log.h"
@@ -124,7 +125,7 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, PvPDiffi
ginfo->ArenaTeamId = arenateamid;
ginfo->IsRated = isRated;
ginfo->IsInvitedToBGInstanceGUID = 0;
ginfo->JoinTime = World::GetGameTimeMS();
ginfo->JoinTime = GameTime::GetGameTimeMS();
ginfo->RemoveInviteTime = 0;
ginfo->teamId = leader->GetTeamId();
ginfo->ArenaTeamRating = ArenaRating;
@@ -210,7 +211,7 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, PvPDiffi
void BattlegroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo)
{
uint32 timeInQueue = std::max<uint32>(1, getMSTimeDiff(ginfo->JoinTime, World::GetGameTimeMS()));
uint32 timeInQueue = std::max<uint32>(1, getMSTimeDiff(ginfo->JoinTime, GameTime::GetGameTimeMS()));
// team_index: bg alliance - TEAM_ALLIANCE, bg horde - TEAM_HORDE, arena skirmish - TEAM_ALLIANCE, arena rated - TEAM_HORDE
uint8 team_index;
@@ -538,7 +539,7 @@ bool BattlegroundQueue::CheckPremadeMatch(BattlegroundBracketId bracket_id, uint
// this happens if timer has expired or group size lowered
uint32 premade_time = sWorld->getIntConfig(CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH);
uint32 time_before = World::GetGameTimeMS() >= premade_time ? World::GetGameTimeMS() - premade_time : 0;
uint32 time_before = GameTime::GetGameTimeMS() >= premade_time ? GameTime::GetGameTimeMS() - premade_time : 0;
for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
if (!m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE + i].empty())
@@ -789,7 +790,7 @@ void BattlegroundQueue::BattlegroundQueueUpdate(BattlegroundBracketId bracket_id
{
// pussywizard: everything inside this section is mine, do NOT destroy!
const uint32 currMSTime = World::GetGameTimeMS();
const uint32 currMSTime = GameTime::GetGameTimeMS();
const uint32 discardTime = sBattlegroundMgr->GetRatingDiscardTimer();
const uint32 maxDefaultRatingDifference = (MaxPlayersPerTeam > 2 ? 300 : 200);
const uint32 maxCountedMMR = 2500;

View File

@@ -10,6 +10,7 @@
#include "Creature.h"
#include "Language.h"
#include "Object.h"
#include "GameTime.h"
#include "Player.h"
#include "Util.h"
#include "WorldSession.h"
@@ -56,7 +57,7 @@ void BattlegroundEY::PostUpdateImpl(uint32 diff)
AddPoints(TEAM_ALLIANCE, BG_EY_TickPoints[_ownedPointsCount[TEAM_ALLIANCE] - 1]);
if (_ownedPointsCount[TEAM_HORDE] > 0)
AddPoints(TEAM_HORDE, BG_EY_TickPoints[_ownedPointsCount[TEAM_HORDE] - 1]);
_bgEvents.ScheduleEvent(BG_EY_EVENT_ADD_POINTS, BG_EY_FPOINTS_TICK_TIME - (World::GetGameTimeMS() % BG_EY_FPOINTS_TICK_TIME));
_bgEvents.ScheduleEvent(BG_EY_EVENT_ADD_POINTS, BG_EY_FPOINTS_TICK_TIME - (GameTime::GetGameTimeMS() % BG_EY_FPOINTS_TICK_TIME));
break;
case BG_EY_EVENT_FLAG_ON_GROUND:
RespawnFlagAfterDrop();
@@ -66,7 +67,7 @@ void BattlegroundEY::PostUpdateImpl(uint32 diff)
break;
case BG_EY_EVENT_CHECK_CPOINTS:
UpdatePointsState();
_bgEvents.ScheduleEvent(BG_EY_EVENT_CHECK_CPOINTS, BG_EY_FPOINTS_CHECK_TIME - (World::GetGameTimeMS() % BG_EY_FPOINTS_CHECK_TIME));
_bgEvents.ScheduleEvent(BG_EY_EVENT_CHECK_CPOINTS, BG_EY_FPOINTS_CHECK_TIME - (GameTime::GetGameTimeMS() % BG_EY_FPOINTS_CHECK_TIME));
break;
}
}

View File

@@ -11,6 +11,7 @@
#include "WorldPacket.h"
#include "GameObject.h"
#include "ObjectMgr.h"
#include "GameTime.h"
#include "Vehicle.h"
#include "Transport.h"
#include "WorldSession.h"
@@ -127,7 +128,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff)
{
// Check if creature respawn time is properly saved
RespawnMap::iterator itr = respawnMap.find(catapult->GetGUIDLow());
if (itr == respawnMap.end() || time(NULL) < itr->second)
if (itr == respawnMap.end() || GameTime::GetGameTime() < itr->second)
continue;
catapult->Relocate(BG_IC_DocksVehiclesCatapults[j].GetPositionX(), BG_IC_DocksVehiclesCatapults[j].GetPositionY(), BG_IC_DocksVehiclesCatapults[j].GetPositionZ(), BG_IC_DocksVehiclesCatapults[j].GetOrientation());
@@ -145,7 +146,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff)
{
// Check if creature respawn time is properly saved
RespawnMap::iterator itr = respawnMap.find(glaiveThrower->GetGUIDLow());
if (itr == respawnMap.end() || time(NULL) < itr->second)
if (itr == respawnMap.end() || GameTime::GetGameTime() < itr->second)
continue;
glaiveThrower->Relocate(BG_IC_DocksVehiclesGlaives[j].GetPositionX(), BG_IC_DocksVehiclesGlaives[j].GetPositionY(), BG_IC_DocksVehiclesGlaives[j].GetPositionZ(), BG_IC_DocksVehiclesGlaives[j].GetOrientation());
@@ -174,7 +175,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff)
{
// Check if creature respawn time is properly saved
RespawnMap::iterator itr = respawnMap.find(siege->GetGUIDLow());
if (itr == respawnMap.end() || time(NULL) < itr->second)
if (itr == respawnMap.end() || GameTime::GetGameTime() < itr->second)
continue;
siege->Relocate(BG_IC_WorkshopVehicles[4].GetPositionX(), BG_IC_WorkshopVehicles[4].GetPositionY(), BG_IC_WorkshopVehicles[4].GetPositionZ(), BG_IC_WorkshopVehicles[4].GetOrientation());
@@ -192,7 +193,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff)
{
// Check if creature respawn time is properly saved
RespawnMap::iterator itr = respawnMap.find(demolisher->GetGUIDLow());
if (itr == respawnMap.end() || time(NULL) < itr->second)
if (itr == respawnMap.end() || GameTime::GetGameTime() < itr->second)
continue;
demolisher->Relocate(BG_IC_WorkshopVehicles[u].GetPositionX(), BG_IC_WorkshopVehicles[u].GetPositionY(), BG_IC_WorkshopVehicles[u].GetPositionZ(), BG_IC_WorkshopVehicles[u].GetOrientation());
@@ -520,7 +521,7 @@ void BattlegroundIC::HandleKillUnit(Creature* unit, Player* killer)
// Xinef: Add to respawn list
if (entry == NPC_DEMOLISHER || entry == NPC_SIEGE_ENGINE_H || entry == NPC_SIEGE_ENGINE_A ||
entry == NPC_GLAIVE_THROWER_A || entry == NPC_GLAIVE_THROWER_H || entry == NPC_CATAPULT)
respawnMap[unit->GetGUIDLow()] = time(NULL) + VEHICLE_RESPAWN_TIME;
respawnMap[unit->GetGUIDLow()] = GameTime::GetGameTime() + VEHICLE_RESPAWN_TIME;
}
}
@@ -867,7 +868,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* nodePoint, bool recapture)
if (!siegeVehicle->IsVehicleInUse())
Unit::Kill(siegeEngine, siegeEngine);
respawnMap[siegeEngine->GetGUIDLow()] = time(NULL) + VEHICLE_RESPAWN_TIME;
respawnMap[siegeEngine->GetGUIDLow()] = GameTime::GetGameTime() + VEHICLE_RESPAWN_TIME;
}
}

View File

@@ -9,6 +9,7 @@
#include "Player.h"
#include "GameObject.h"
#include "ObjectMgr.h"
#include "GameTime.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "GameGraveyard.h"
@@ -1059,11 +1060,11 @@ void BattlegroundSA::UpdateDemolisherSpawns()
// Demolisher is not in list
if (DemoliserRespawnList.find(i) == DemoliserRespawnList.end())
{
DemoliserRespawnList[i] = World::GetGameTimeMS()+30000;
DemoliserRespawnList[i] = GameTime::GetGameTimeMS()+30000;
}
else
{
if (DemoliserRespawnList[i] < World::GetGameTimeMS())
if (DemoliserRespawnList[i] < GameTime::GetGameTimeMS())
{
Demolisher->Relocate(BG_SA_NpcSpawnlocs[i][0], BG_SA_NpcSpawnlocs[i][1],
BG_SA_NpcSpawnlocs[i][2], BG_SA_NpcSpawnlocs[i][3]);