mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 05:06:24 +00:00
feat(Core/Time): Implement saparated manager for game time (#8630)
This commit is contained in:
@@ -38,6 +38,7 @@ Copied events should probably have a new owner
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DisableMgr.h"
|
||||
#include "GameEventMgr.h"
|
||||
#include "GameTime.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "InstanceSaveMgr.h"
|
||||
#include "Log.h"
|
||||
@@ -46,14 +47,14 @@ Copied events should probably have a new owner
|
||||
#include "Player.h"
|
||||
#include "SocialMgr.h"
|
||||
#include "WorldSession.h"
|
||||
#include "utf8.h"
|
||||
#include <utf8.h>
|
||||
|
||||
void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/)
|
||||
{
|
||||
ObjectGuid guid = _player->GetGUID();
|
||||
LOG_DEBUG("network", "CMSG_CALENDAR_GET_CALENDAR [%s]", guid.ToString().c_str());
|
||||
|
||||
time_t currTime = time(nullptr);
|
||||
time_t currTime = GameTime::GetGameTime().count();
|
||||
|
||||
WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Average size if no instance
|
||||
|
||||
@@ -260,7 +261,7 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData)
|
||||
|
||||
// prevent events in the past
|
||||
// To Do: properly handle timezones and remove the "- time_t(86400L)" hack
|
||||
if (time_t(eventPackedTime) < (time(nullptr) - time_t(86400L)))
|
||||
if (time_t(eventPackedTime) < (GameTime::GetGameTime().count() - time_t(86400L)))
|
||||
{
|
||||
recvData.rfinish();
|
||||
sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_PASSED);
|
||||
@@ -298,13 +299,13 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData)
|
||||
}
|
||||
}
|
||||
|
||||
if (GetCalendarEventCreationCooldown() > time(nullptr))
|
||||
if (GetCalendarEventCreationCooldown() > GameTime::GetGameTime().count())
|
||||
{
|
||||
recvData.rfinish();
|
||||
sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_INTERNAL);
|
||||
return;
|
||||
}
|
||||
SetCalendarEventCreationCooldown(time(nullptr) + CALENDAR_CREATE_EVENT_COOLDOWN);
|
||||
SetCalendarEventCreationCooldown(GameTime::GetGameTime().count() + CALENDAR_CREATE_EVENT_COOLDOWN);
|
||||
|
||||
CalendarEvent* calendarEvent = new CalendarEvent(sCalendarMgr->GetFreeEventId(), guid, 0, CalendarEventType(type), dungeonId,
|
||||
time_t(eventPackedTime), flags, time_t(unkPackedTime), title, description);
|
||||
@@ -392,7 +393,7 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData)
|
||||
|
||||
// prevent events in the past
|
||||
// To Do: properly handle timezones and remove the "- time_t(86400L)" hack
|
||||
if (time_t(eventPackedTime) < (time(nullptr) - time_t(86400L)))
|
||||
if (time_t(eventPackedTime) < (GameTime::GetGameTime().count() - time_t(86400L)))
|
||||
{
|
||||
recvData.rfinish();
|
||||
return;
|
||||
@@ -449,7 +450,7 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData)
|
||||
|
||||
// prevent events in the past
|
||||
// To Do: properly handle timezones and remove the "- time_t(86400L)" hack
|
||||
if (time_t(eventTime) < (time(nullptr) - time_t(86400L)))
|
||||
if (time_t(eventTime) < (GameTime::GetGameTime().count() - time_t(86400L)))
|
||||
{
|
||||
recvData.rfinish();
|
||||
sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_PASSED);
|
||||
@@ -494,12 +495,12 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData)
|
||||
}
|
||||
}
|
||||
|
||||
if (GetCalendarEventCreationCooldown() > time(nullptr))
|
||||
if (GetCalendarEventCreationCooldown() > GameTime::GetGameTime().count())
|
||||
{
|
||||
sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_INTERNAL);
|
||||
return;
|
||||
}
|
||||
SetCalendarEventCreationCooldown(time(nullptr) + CALENDAR_CREATE_EVENT_COOLDOWN);
|
||||
SetCalendarEventCreationCooldown(GameTime::GetGameTime().count() + CALENDAR_CREATE_EVENT_COOLDOWN);
|
||||
|
||||
CalendarEvent* newEvent = new CalendarEvent(*oldEvent, sCalendarMgr->GetFreeEventId());
|
||||
newEvent->SetEventTime(time_t(eventTime));
|
||||
@@ -633,7 +634,7 @@ void WorldSession::HandleCalendarEventSignup(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
CalendarInviteStatus status = tentative ? CALENDAR_STATUS_TENTATIVE : CALENDAR_STATUS_SIGNED_UP;
|
||||
CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), eventId, guid, guid, time(nullptr), status, CALENDAR_RANK_PLAYER, "");
|
||||
CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), eventId, guid, guid, GameTime::GetGameTime().count(), status, CALENDAR_RANK_PLAYER, "");
|
||||
sCalendarMgr->AddInvite(calendarEvent, invite);
|
||||
sCalendarMgr->SendCalendarClearPendingAction(guid);
|
||||
}
|
||||
@@ -665,7 +666,7 @@ void WorldSession::HandleCalendarEventRsvp(WorldPacket& recvData)
|
||||
if (CalendarInvite* invite = sCalendarMgr->GetInvite(inviteId))
|
||||
{
|
||||
invite->SetStatus(CalendarInviteStatus(status));
|
||||
invite->SetStatusTime(time(nullptr));
|
||||
invite->SetStatusTime(GameTime::GetGameTime().count());
|
||||
|
||||
sCalendarMgr->UpdateInvite(invite);
|
||||
sCalendarMgr->SendCalendarEventStatus(*calendarEvent, *invite);
|
||||
@@ -725,7 +726,7 @@ void WorldSession::HandleCalendarEventStatus(WorldPacket& recvData)
|
||||
if (CalendarInvite* invite = sCalendarMgr->GetInvite(inviteId))
|
||||
{
|
||||
invite->SetStatus((CalendarInviteStatus)status);
|
||||
invite->SetStatusTime(time(nullptr));
|
||||
invite->SetStatusTime(GameTime::GetGameTime().count());
|
||||
|
||||
sCalendarMgr->UpdateInvite(invite);
|
||||
sCalendarMgr->SendCalendarEventStatus(*calendarEvent, *invite);
|
||||
@@ -824,7 +825,7 @@ void WorldSession::HandleSetSavedInstanceExtend(WorldPacket& recvData)
|
||||
void WorldSession::SendCalendarRaidLockout(InstanceSave const* save, bool add)
|
||||
{
|
||||
LOG_DEBUG("network", "%s", add ? "SMSG_CALENDAR_RAID_LOCKOUT_ADDED" : "SMSG_CALENDAR_RAID_LOCKOUT_REMOVED");
|
||||
time_t currTime = time(nullptr);
|
||||
time_t currTime = GameTime::GetGameTime().count();
|
||||
|
||||
WorldPacket data(SMSG_CALENDAR_RAID_LOCKOUT_REMOVED, (add ? 4 : 0) + 4 + 4 + 4 + 8);
|
||||
if (add)
|
||||
@@ -842,7 +843,7 @@ void WorldSession::SendCalendarRaidLockout(InstanceSave const* save, bool add)
|
||||
|
||||
void WorldSession::SendCalendarRaidLockoutUpdated(InstanceSave const* save, bool isExtended)
|
||||
{
|
||||
time_t currTime = time(nullptr);
|
||||
time_t currTime = GameTime::GetGameTime().count();
|
||||
time_t resetTime = isExtended ? save->GetExtendedResetTime() : save->GetResetTime();
|
||||
time_t resetTimeOp = isExtended ? save->GetResetTime() : save->GetExtendedResetTime();
|
||||
WorldPacket data(SMSG_CALENDAR_RAID_LOCKOUT_UPDATED, 4 + 4 + 4 + 4 + 8);
|
||||
|
||||
Reference in New Issue
Block a user