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 "WorldPacket.h"
#include "WorldSession.h"
#include "Opcodes.h"
#include "GameTime.h"
#include "Log.h"
#include "World.h"
#include "ObjectMgr.h"
@@ -365,7 +366,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recvData)
Player* player = _player;
Mail* m = player->GetMail(mailId);
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > GameTime::GetGameTime())
{
player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR);
return;
@@ -430,7 +431,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recvData)
Player* player = _player;
Mail* m = player->GetMail(mailId);
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > GameTime::GetGameTime())
{
player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR);
return;
@@ -530,7 +531,7 @@ void WorldSession::HandleMailTakeMoney(WorldPacket& recvData)
Player* player = _player;
Mail* m = player->GetMail(mailId);
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > GameTime::GetGameTime())
{
player->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_ERR_INTERNAL_ERROR);
return;
@@ -579,7 +580,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recvData)
WorldPacket data(SMSG_MAIL_LIST_RESULT, (200)); // guess size
data << uint32(0); // real mail's count
data << uint8(0); // mail's count
time_t cur_time = time(NULL);
time_t cur_time = GameTime::GetGameTime();
for (PlayerMails::iterator itr = player->GetMailBegin(); itr != player->GetMailEnd(); ++itr)
{
@@ -626,7 +627,7 @@ void WorldSession::HandleGetMailList(WorldPacket & recvData)
data << uint32((*itr)->stationery); // stationery (Stationery.dbc)
data << uint32((*itr)->money); // Gold
data << uint32((*itr)->checked); // flags
data << float(float((*itr)->expire_time-time(NULL))/DAY); // Time
data << float(float((*itr)->expire_time-GameTime::GetGameTime())/DAY); // Time
data << uint32((*itr)->mailTemplateId); // mail template (MailTemplate.dbc)
data << (*itr)->subject; // Subject string - once 00, when mail type = 3, max 256
data << (*itr)->body; // message? max 8000
@@ -690,7 +691,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recvData)
Player* player = _player;
Mail* m = player->GetMail(mailId);
if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL) || (m->checked & MAIL_CHECK_MASK_COPIED))
if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > GameTime::GetGameTime() || (m->checked & MAIL_CHECK_MASK_COPIED))
{
player->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR);
return;
@@ -757,7 +758,7 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recvData*/)
data << uint32(0); // count
uint32 count = 0;
time_t now = time(NULL);
time_t now = GameTime::GetGameTime();
std::set<uint32> sentSenders;
for (PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr)
{