Skip to content

Commit

Permalink
Add MaxLatencyLevel key for ProtocolZero
Browse files Browse the repository at this point in the history
spawn.ini->[Settings]->MaxLatencyLevel
  • Loading branch information
Belonit committed Aug 22, 2023
1 parent 768b7e4 commit 05022ca
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/Spawner/ProtocolZero.LatencyLevel.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "ProtocolZero.h"
#include "ProtocolZero.LatencyLevel.h"

#include <HouseClass.h>
#include <MessageListClass.h>
#include <Utilities/Debug.h>

LatencyLevelEnum LatencyLevel::MaxLatencyLevel = LatencyLevelEnum::LATENCY_LEVEL_MAX;
LatencyLevelEnum LatencyLevel::CurentLatencyLevel = LatencyLevelEnum::LATENCY_LEVEL_INITIAL;
unsigned char LatencyLevel::NewFrameSendRate = 3;

Expand All @@ -13,8 +13,9 @@ void LatencyLevel::Apply(LatencyLevelEnum newLatencyLevel)
if (newLatencyLevel > LatencyLevelEnum::LATENCY_LEVEL_MAX)
newLatencyLevel = LatencyLevelEnum::LATENCY_LEVEL_MAX;

if (newLatencyLevel > MaxLatencyLevel)
newLatencyLevel = MaxLatencyLevel;
auto maxLatencyLevel = static_cast<LatencyLevelEnum>(ProtocolZero::MaxLatencyLevel);
if (newLatencyLevel > maxLatencyLevel)
newLatencyLevel = maxLatencyLevel;

if (newLatencyLevel <= CurentLatencyLevel)
return;
Expand Down
1 change: 0 additions & 1 deletion src/Spawner/ProtocolZero.LatencyLevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ enum class LatencyLevelEnum : uint8_t
class LatencyLevel
{
public:
static LatencyLevelEnum MaxLatencyLevel;
static LatencyLevelEnum CurentLatencyLevel;
static uint8_t NewFrameSendRate;

Expand Down
1 change: 1 addition & 0 deletions src/Spawner/ProtocolZero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

bool ProtocolZero::Enable = false;
int ProtocolZero::WorstMaxAhead = 24;
unsigned char ProtocolZero::MaxLatencyLevel = 0xff;

void ProtocolZero::SendResponseTime2()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Spawner/ProtocolZero.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class ProtocolZero

public:
static bool Enable;
static int WorstMaxAhead; // = 24
static unsigned char MaxLatencyLevel;
static int WorstMaxAhead;

static void SendResponseTime2();
static void HandleResponseTime2(EventExt* event);
Expand Down
1 change: 1 addition & 0 deletions src/Spawner/Spawner.Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void SpawnerConfig::LoadFromINIFile(CCINIClass* pINI)
ConnTimeout = pINI->ReadInteger(pSettingsSection, "ConnTimeout", ConnTimeout);
MaxAhead = pINI->ReadInteger(pSettingsSection, "MaxAhead", MaxAhead);
PreCalcMaxAhead = pINI->ReadInteger(pSettingsSection, "PreCalcMaxAhead", PreCalcMaxAhead);
MaxLatencyLevel = (byte)pINI->ReadInteger(pSettingsSection, "MaxLatencyLevel", (int)MaxLatencyLevel);
}

{ // Tunnel Options
Expand Down
2 changes: 2 additions & 0 deletions src/Spawner/Spawner.Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class SpawnerConfig
int ConnTimeout;
int MaxAhead;
int PreCalcMaxAhead;
byte MaxLatencyLevel;

// Tunnel Options
int TunnelId;
Expand Down Expand Up @@ -178,6 +179,7 @@ class SpawnerConfig
, ConnTimeout { 3600 }
, MaxAhead { -1 }
, PreCalcMaxAhead { 0 }
, MaxLatencyLevel { 0xFF }

// Tunnel Options
, TunnelId { 0 }
Expand Down
1 change: 1 addition & 0 deletions src/Spawner/Spawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ void Spawner::InitNetwork()
if (Spawner::Config->Protocol == 0)
{
ProtocolZero::Enable = true;
ProtocolZero::MaxLatencyLevel = Spawner::Config->MaxLatencyLevel;
Game::Network::FrameSendRate = 2;
Game::Network::PreCalcMaxAhead = Spawner::Config->PreCalcMaxAhead;
}
Expand Down

0 comments on commit 05022ca

Please sign in to comment.