mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 10:26:28 +01:00
Core/Misc: Code cleanup
Remove more unused code in UpdateTime class
(cherry picked from commit 6c4f71c84b)
This commit is contained in:
@@ -25,69 +25,15 @@ WorldUpdateTime sWorldUpdateTime;
|
||||
|
||||
UpdateTime::UpdateTime()
|
||||
{
|
||||
_averageUpdateTime = 0;
|
||||
_totalUpdateTime = 0;
|
||||
_updateTimeTableIndex = 0;
|
||||
_maxUpdateTime = 0;
|
||||
_maxUpdateTimeOfLastTable = 0;
|
||||
_maxUpdateTimeOfCurrentTable = 0;
|
||||
|
||||
_updateTimeDataTable = { };
|
||||
}
|
||||
|
||||
uint32 UpdateTime::GetAverageUpdateTime() const
|
||||
{
|
||||
return _averageUpdateTime;
|
||||
}
|
||||
|
||||
uint32 UpdateTime::GetTimeWeightedAverageUpdateTime() const
|
||||
{
|
||||
uint32 sum = 0, weightsum = 0;
|
||||
for (uint32 diff : _updateTimeDataTable)
|
||||
{
|
||||
sum += diff * diff;
|
||||
weightsum += diff;
|
||||
}
|
||||
if (weightsum == 0)
|
||||
return 0;
|
||||
return sum / weightsum;
|
||||
}
|
||||
|
||||
uint32 UpdateTime::GetMaxUpdateTime() const
|
||||
{
|
||||
return _maxUpdateTime;
|
||||
}
|
||||
|
||||
uint32 UpdateTime::GetMaxUpdateTimeOfCurrentTable() const
|
||||
{
|
||||
return std::max(_maxUpdateTimeOfCurrentTable, _maxUpdateTimeOfLastTable);
|
||||
_lastUpdateTime = 0;
|
||||
}
|
||||
|
||||
uint32 UpdateTime::GetLastUpdateTime() const
|
||||
{
|
||||
return _updateTimeDataTable[_updateTimeTableIndex != 0 ? _updateTimeTableIndex - 1 : _updateTimeDataTable.size() - 1];
|
||||
return _lastUpdateTime;
|
||||
}
|
||||
|
||||
void UpdateTime::UpdateWithDiff(uint32 diff)
|
||||
{
|
||||
_totalUpdateTime = _totalUpdateTime - _updateTimeDataTable[_updateTimeTableIndex] + diff;
|
||||
_updateTimeDataTable[_updateTimeTableIndex] = diff;
|
||||
|
||||
if (diff > _maxUpdateTime)
|
||||
_maxUpdateTime = diff;
|
||||
|
||||
if (diff > _maxUpdateTimeOfCurrentTable)
|
||||
_maxUpdateTimeOfCurrentTable = diff;
|
||||
|
||||
if (++_updateTimeTableIndex >= _updateTimeDataTable.size())
|
||||
{
|
||||
_updateTimeTableIndex = 0;
|
||||
_maxUpdateTimeOfLastTable = _maxUpdateTimeOfCurrentTable;
|
||||
_maxUpdateTimeOfCurrentTable = 0;
|
||||
}
|
||||
|
||||
if (_updateTimeDataTable[_updateTimeDataTable.size() - 1])
|
||||
_averageUpdateTime = _totalUpdateTime / _updateTimeDataTable.size();
|
||||
else if (_updateTimeTableIndex)
|
||||
_averageUpdateTime = _totalUpdateTime / _updateTimeTableIndex;
|
||||
_lastUpdateTime = diff;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user