Network/ENet: Add peer-side lag simulation

This commit is contained in:
Lynix
2017-02-20 23:37:31 +01:00
parent cc57fed42e
commit b0d0a63fca
6 changed files with 104 additions and 14 deletions

View File

@@ -100,13 +100,20 @@ namespace Nz
static bool Initialize();
static void Uninitialize();
struct PendingPacket
struct PendingIncomingPacket
{
IpAddress from;
NetPacket data;
UInt32 deliveryTime;
};
struct PendingOutgoingPacket
{
IpAddress to;
NetPacket data;
UInt32 deliveryTime;
};
std::array<ENetProtocol, ENetConstants::ENetProtocol_MaximumPacketCommands> m_commands;
std::array<NetBuffer, ENetConstants::ENetProtocol_MaximumPacketCommands * 2 + 1> m_buffers;
std::array<UInt8, ENetConstants::ENetProtocol_MaximumMTU> m_packetData[2];
@@ -123,7 +130,8 @@ namespace Nz
std::size_t m_receivedDataLength;
std::uniform_int_distribution<UInt16> m_packetDelayDistribution;
std::vector<ENetPeer> m_peers;
std::vector<PendingPacket> m_pendingPackets;
std::vector<PendingIncomingPacket> m_pendingIncomingPackets;
std::vector<PendingOutgoingPacket> m_pendingOutgoingPackets;
UInt8* m_receivedData;
Bitset<UInt64> m_dispatchQueue;
MemoryPool m_packetPool;