feat(Core/Time): Implement saparated manager for game time (#8630)

This commit is contained in:
Kargatum
2022-01-24 17:55:00 +07:00
committed by GitHub
parent 12da792a90
commit 8b7df23f06
129 changed files with 1147 additions and 817 deletions

View File

@@ -20,6 +20,7 @@
#include "Chat.h"
#include "Common.h"
#include "DatabaseEnv.h"
#include "GameTime.h"
#include "Language.h"
#include "Log.h"
#include "Opcodes.h"
@@ -28,14 +29,14 @@
#include "WorldPacket.h"
#include "WorldSession.h"
inline float GetAge(uint64 t) { return float(time(nullptr) - t) / DAY; }
inline float GetAge(uint64 t) { return float(GameTime::GetGameTime().count() - t) / DAY; }
///////////////////////////////////////////////////////////////////////////////////////////////////
// GM ticket
GmTicket::GmTicket() : _id(0), _type(TICKET_TYPE_OPEN), _posX(0), _posY(0), _posZ(0), _mapId(0), _createTime(0), _lastModifiedTime(0),
_completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false), _needResponse(false), _needMoreHelp(false) { }
GmTicket::GmTicket(Player* player) : _type(TICKET_TYPE_OPEN), _createTime(time(nullptr)), _lastModifiedTime(time(nullptr)),
GmTicket::GmTicket(Player* player) : _type(TICKET_TYPE_OPEN), _createTime(GameTime::GetGameTime().count()), _lastModifiedTime(GameTime::GetGameTime().count()),
_completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false), _needMoreHelp(false)
{
_id = sTicketMgr->GenerateTicketId();
@@ -159,7 +160,7 @@ void GmTicket::SendResponse(WorldSession* session) const
std::string GmTicket::FormatMessageString(ChatHandler& handler, bool detailed) const
{
time_t curTime = time(nullptr);
time_t curTime = GameTime::GetGameTime().count();
std::stringstream ss;
ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTGUID, _id);
@@ -252,9 +253,15 @@ void GmTicket::SetChatLog(std::list<uint32> time, std::string const& log)
_chatLog = newss.str();
}
void GmTicket::SetMessage(std::string const& message)
{
_message = message;
_lastModifiedTime = uint64(GameTime::GetGameTime().count());
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Ticket manager
TicketMgr::TicketMgr() : _status(true), _lastTicketId(0), _lastSurveyId(0), _openTicketCount(0), _lastChange(time(nullptr)) { }
TicketMgr::TicketMgr() : _status(true), _lastTicketId(0), _lastSurveyId(0), _openTicketCount(0), _lastChange(GameTime::GetGameTime().count()) { }
TicketMgr::~TicketMgr()
{
@@ -430,3 +437,8 @@ void TicketMgr::SendTicket(WorldSession* session, GmTicket* ticket) const
session->SendPacket(&data);
}
void TicketMgr::UpdateLastChange()
{
_lastChange = GameTime::GetGameTime().count();
}