diff options
-rw-r--r-- | src/server/game/Time/UpdateTime.cpp | 60 | ||||
-rw-r--r-- | src/server/game/Time/UpdateTime.h | 18 |
2 files changed, 4 insertions, 74 deletions
diff --git a/src/server/game/Time/UpdateTime.cpp b/src/server/game/Time/UpdateTime.cpp index 8e72e2c6c75..f71095fae9f 100644 --- a/src/server/game/Time/UpdateTime.cpp +++ b/src/server/game/Time/UpdateTime.cpp @@ -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; } diff --git a/src/server/game/Time/UpdateTime.h b/src/server/game/Time/UpdateTime.h index ab51c08fdd9..19caf36a055 100644 --- a/src/server/game/Time/UpdateTime.h +++ b/src/server/game/Time/UpdateTime.h @@ -19,20 +19,10 @@ #define __UPDATETIME_H #include "Define.h" -#include <array> -#include <string> - -#define AVG_DIFF_COUNT 500 class TC_GAME_API UpdateTime { - using DiffTableArray = std::array<uint32, AVG_DIFF_COUNT>; - public: - uint32 GetAverageUpdateTime() const; - uint32 GetTimeWeightedAverageUpdateTime() const; - uint32 GetMaxUpdateTime() const; - uint32 GetMaxUpdateTimeOfCurrentTable() const; uint32 GetLastUpdateTime() const; void UpdateWithDiff(uint32 diff); @@ -41,13 +31,7 @@ class TC_GAME_API UpdateTime UpdateTime(); private: - DiffTableArray _updateTimeDataTable; - uint32 _averageUpdateTime; - uint32 _totalUpdateTime; - uint32 _updateTimeTableIndex; - uint32 _maxUpdateTime; - uint32 _maxUpdateTimeOfLastTable; - uint32 _maxUpdateTimeOfCurrentTable; + uint32 _lastUpdateTime; }; class TC_GAME_API WorldUpdateTime : public UpdateTime |