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

@@ -21,6 +21,7 @@
#include "Chat.h"
#include "DisableMgr.h"
#include "DynamicTree.h"
#include "GameTime.h"
#include "Geometry.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
@@ -2946,7 +2947,7 @@ bool InstanceMap::AddPlayerToMap(Player* player)
// increase current instances (hourly limit)
// xinef: specific instances are still limited
if (!group || !group->isLFGGroup() || !group->IsLfgRandomInstance())
player->AddInstanceEnterTime(GetInstanceId(), time(nullptr));
player->AddInstanceEnterTime(GetInstanceId(), GameTime::GetGameTime().count());
if (!playerBind->perm && !mapSave->CanReset() && group && !group->isLFGGroup() && !group->IsLfgRandomInstance())
{
@@ -3297,7 +3298,7 @@ void Map::SaveCreatureRespawnTime(ObjectGuid::LowType spawnId, time_t& respawnTi
return;
}
time_t now = time(nullptr);
time_t now = GameTime::GetGameTime().count();
if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod())
respawnTime = now + YEAR;
@@ -3331,7 +3332,7 @@ void Map::SaveGORespawnTime(ObjectGuid::LowType spawnId, time_t& respawnTime)
return;
}
time_t now = time(nullptr);
time_t now = GameTime::GetGameTime().count();
if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod())
respawnTime = now + YEAR;
@@ -3622,7 +3623,7 @@ Corpse* Map::ConvertCorpseToBones(ObjectGuid const ownerGuid, bool insignia /*=
void Map::RemoveOldCorpses()
{
time_t now = time(nullptr);
time_t now = GameTime::GetGameTime().count();
std::vector<ObjectGuid> corpses;
corpses.reserve(_corpsesByPlayer.size());

View File

@@ -16,7 +16,6 @@
*/
#include "MapMgr.h"
#include "AvgDiffTracker.h"
#include "Chat.h"
#include "DatabaseEnv.h"
#include "GridDefines.h"
@@ -252,13 +251,12 @@ void MapMgr::Update(uint32 diff)
//if (mapUpdateStep == 0)
{
if (m_updater.activated())
{
m_updater.schedule_lfg_update(diff);
}
else
{
uint32 startTime = getMSTime();
sLFGMgr->Update(diff, 1);
uint32 totalTime = getMSTimeDiff(startTime, getMSTime());
lfgDiffTracker.Update(10000 + totalTime); // +10k to mark it was NOT multithreaded
}
}

View File

@@ -16,7 +16,6 @@
*/
#include "MapUpdater.h"
#include "AvgDiffTracker.h"
#include "LFGMgr.h"
#include "Map.h"
#include "Metric.h"
@@ -59,10 +58,7 @@ public:
void call() override
{
uint32 startTime = getMSTime();
sLFGMgr->Update(m_diff, 1);
uint32 totalTime = getMSTimeDiff(startTime, getMSTime());
lfgDiffTracker.Update(totalTime);
m_updater.update_finished();
}
private: