mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Misc: Use boost/circular_buffer forward declaration headers in our headers
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include <boost/accumulators/statistics/variance.hpp>
|
||||
#include <boost/accumulators/accumulators.hpp>
|
||||
#include <boost/accumulators/statistics.hpp>
|
||||
#include <boost/circular_buffer.hpp>
|
||||
|
||||
void WorldSession::HandleMoveWorldportAckOpcode(WorldPackets::Movement::WorldPortResponse& /*packet*/)
|
||||
{
|
||||
@@ -757,7 +758,7 @@ void WorldSession::HandleTimeSyncResponse(WorldPackets::Misc::TimeSyncResponse&
|
||||
serverTime = clockDelta + clientTime
|
||||
*/
|
||||
int64 clockDelta = (int64)serverTimeAtSent + (int64)lagDelay - (int64)timeSyncResponse.ClientTime;
|
||||
_timeSyncClockDeltaQueue.push_back(std::pair<int64, uint32>(clockDelta, roundTripDuration));
|
||||
_timeSyncClockDeltaQueue->push_back(std::pair<int64, uint32>(clockDelta, roundTripDuration));
|
||||
ComputeNewClockDelta();
|
||||
}
|
||||
|
||||
@@ -770,18 +771,18 @@ void WorldSession::ComputeNewClockDelta()
|
||||
|
||||
accumulator_set<uint32, features<tag::mean, tag::median, tag::variance(lazy)> > latencyAccumulator;
|
||||
|
||||
for (auto pair : _timeSyncClockDeltaQueue)
|
||||
latencyAccumulator(pair.second);
|
||||
for (auto [_, roundTripDuration] : *_timeSyncClockDeltaQueue)
|
||||
latencyAccumulator(roundTripDuration);
|
||||
|
||||
uint32 latencyMedian = static_cast<uint32>(std::round(median(latencyAccumulator)));
|
||||
uint32 latencyStandardDeviation = static_cast<uint32>(std::round(sqrt(variance(latencyAccumulator))));
|
||||
|
||||
accumulator_set<int64, features<tag::mean> > clockDeltasAfterFiltering;
|
||||
uint32 sampleSizeAfterFiltering = 0;
|
||||
for (auto pair : _timeSyncClockDeltaQueue)
|
||||
for (auto [clockDelta, roundTripDuration] : *_timeSyncClockDeltaQueue)
|
||||
{
|
||||
if (pair.second < latencyStandardDeviation + latencyMedian) {
|
||||
clockDeltasAfterFiltering(pair.first);
|
||||
if (roundTripDuration < latencyStandardDeviation + latencyMedian) {
|
||||
clockDeltasAfterFiltering(clockDelta);
|
||||
sampleSizeAfterFiltering++;
|
||||
}
|
||||
}
|
||||
@@ -793,10 +794,7 @@ void WorldSession::ComputeNewClockDelta()
|
||||
_timeSyncClockDelta = meanClockDelta;
|
||||
}
|
||||
else if (_timeSyncClockDelta == 0)
|
||||
{
|
||||
std::pair<int64, uint32> back = _timeSyncClockDeltaQueue.back();
|
||||
_timeSyncClockDelta = back.first;
|
||||
}
|
||||
_timeSyncClockDelta = _timeSyncClockDeltaQueue->back().first;
|
||||
}
|
||||
|
||||
void WorldSession::HandleMoveInitActiveMoverComplete(WorldPackets::Movement::MoveInitActiveMoverComplete& moveInitActiveMoverComplete)
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include "WardenWin.h"
|
||||
#include "World.h"
|
||||
#include "WorldSocket.h"
|
||||
#include <boost/circular_buffer.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -134,7 +135,7 @@ WorldSession::WorldSession(uint32 id, std::string&& name, uint32 battlenetAccoun
|
||||
_RBACData(nullptr),
|
||||
expireTime(60000), // 1 min after socket loss, session is deleted
|
||||
forceExit(false),
|
||||
_timeSyncClockDeltaQueue(6),
|
||||
_timeSyncClockDeltaQueue(std::make_unique<boost::circular_buffer<std::pair<int64, uint32>>>(6)),
|
||||
_timeSyncClockDelta(0),
|
||||
_pendingTimeSyncRequests(),
|
||||
_timeSyncNextCounter(0),
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "Optional.h"
|
||||
#include "RaceMask.h"
|
||||
#include "SharedDefines.h"
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <boost/circular_buffer_fwd.hpp>
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -1936,7 +1936,7 @@ class TC_GAME_API WorldSession
|
||||
uint32 expireTime;
|
||||
bool forceExit;
|
||||
|
||||
boost::circular_buffer<std::pair<int64, uint32>> _timeSyncClockDeltaQueue; // first member: clockDelta. Second member: latency of the packet exchange that was used to compute that clockDelta.
|
||||
std::unique_ptr<boost::circular_buffer<std::pair<int64, uint32>>> _timeSyncClockDeltaQueue; // first member: clockDelta. Second member: latency of the packet exchange that was used to compute that clockDelta.
|
||||
int64 _timeSyncClockDelta;
|
||||
void ComputeNewClockDelta();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user