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

@@ -8,6 +8,7 @@
#include "BattlefieldMgr.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "GameTime.h"
#include "Map.h"
#include "MapManager.h"
#include "Group.h"
@@ -77,7 +78,7 @@ void Battlefield::HandlePlayerEnterZone(Player* player, uint32 /*zone*/)
else // No more vacant places
{
// TODO: Send a packet to announce it to player
m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(NULL) + (player->IsGameMaster() ? 30*MINUTE : 10);
m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime() + (player->IsGameMaster() ? 30*MINUTE : 10);
InvitePlayerToQueue(player);
}
}
@@ -167,7 +168,7 @@ bool Battlefield::Update(uint32 diff)
// Kick players who chose not to accept invitation to the battle
if (m_uiKickDontAcceptTimer <= diff)
{
time_t now = time(NULL);
time_t now = GameTime::GetGameTime();
for (int team = 0; team < 2; team++)
for (PlayerTimerMap::iterator itr = m_InvitedPlayers[team].begin(); itr != m_InvitedPlayers[team].end(); ++itr)
if (itr->second <= now)
@@ -253,7 +254,7 @@ void Battlefield::InvitePlayersInZoneToWar()
if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer)
InvitePlayerToWar(player);
else if (m_PlayersWillBeKick[player->GetTeamId()].count(player->GetGUID()) == 0)// Battlefield is full of players
m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(NULL) + 10;
m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime() + 10;
}
}
}
@@ -277,7 +278,7 @@ void Battlefield::InvitePlayerToWar(Player* player)
if (player->getLevel() < m_MinLevel)
{
if (m_PlayersWillBeKick[player->GetTeamId()].count(player->GetGUID()) == 0)
m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(NULL) + 10;
m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime() + 10;
return;
}
@@ -286,7 +287,7 @@ void Battlefield::InvitePlayerToWar(Player* player)
return;
m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID());
m_InvitedPlayers[player->GetTeamId()][player->GetGUID()] = time(NULL) + m_TimeForAcceptInvite;
m_InvitedPlayers[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime() + m_TimeForAcceptInvite;
player->GetSession()->SendBfInvitePlayerToWar(m_BattleId, m_ZoneId, m_TimeForAcceptInvite);
}

View File

@@ -7,6 +7,7 @@
#include "Common.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "GameTime.h"
#include "WorldPacket.h"
#include "WorldSession.h"
@@ -25,7 +26,7 @@ void WorldSession::SendBfInvitePlayerToWar(uint32 BattleId, uint32 ZoneId, uint3
WorldPacket data(SMSG_BATTLEFIELD_MGR_ENTRY_INVITE, 12);
data << uint32(BattleId);
data << uint32(ZoneId);
data << uint32((time(NULL) + p_time));
data << uint32((GameTime::GetGameTime() + p_time));
//Sending the packet to player
SendPacket(&data);

View File

@@ -10,6 +10,7 @@
#include "BattlefieldWG.h"
#include "ObjectMgr.h"
#include "GameTime.h"
#include "Opcodes.h"
#include "Player.h"
#include "SpellAuras.h"
@@ -888,7 +889,7 @@ void BattlefieldWG::FillInitialWorldStates(WorldPacket& data)
data << uint32(BATTLEFIELD_WG_WORLD_STATE_SHOW_WORLDSTATE) << uint32(IsWarTime() ? 1 : 0);
for (uint32 i = 0; i < 2; ++i)
data << ClockWorldState[i] << uint32(time(NULL) + (m_Timer / 1000));
data << ClockWorldState[i] << uint32(GameTime::GetGameTime() + (m_Timer / 1000));
data << uint32(BATTLEFIELD_WG_WORLD_STATE_VEHICLE_H) << uint32(GetData(BATTLEFIELD_WG_DATA_VEHICLE_H));
data << uint32(BATTLEFIELD_WG_WORLD_STATE_MAX_VEHICLE_H) << GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_H);