Add net stat

This commit is contained in:
Magnus Norddahl 2020-06-05 02:27:49 +02:00
parent 377f4c50ba
commit 81ecf88902
10 changed files with 47 additions and 0 deletions

View file

@ -84,6 +84,14 @@ CUSTOM_CVAR(Int, net_extratic, 0, CVAR_SERVERINFO | CVAR_NOSAVE)
}
}
ADD_STAT(net)
{
if (network)
return network->GetStats();
else
return "Network object is null!";
}
#if 0
CVAR(Int, net_fakelatency, 0, 0);

View file

@ -62,6 +62,7 @@ public:
// Statistics
virtual int GetPing(int player) const = 0;
int GetHighPingThreshold() const { return ((BACKUPTICS / 2 - 1)) * (1000 / TICRATE); }
virtual FString GetStats() = 0;
// CCMDs
virtual void ListPingTimes() = 0;

View file

@ -230,6 +230,13 @@ int NetClient::GetPing(int player) const
return 0;
}
FString NetClient::GetStats()
{
FString out;
out.Format("Tic ping = %d, unacked outbound data (%s)", mSendTic - mReceiveTic, mOutput.GetStats().GetChars());
return out;
}
void NetClient::ListPingTimes()
{
}

View file

@ -47,6 +47,7 @@ public:
void WriteBotInput(int player, const ticcmd_t &cmd) override;
int GetPing(int player) const override;
FString GetStats() override;
void ListPingTimes() override;
void Network_Controller(int playernum, bool add) override;

View file

@ -81,6 +81,20 @@ void NetNodeOutput::AckPacket(uint8_t headerFlags, uint16_t serial, uint16_t ack
}
}
FString NetNodeOutput::GetStats()
{
int total = 0;
int count = 0;
for (auto& msg : mMessages)
{
total += msg->size;
count++;
}
FString out;
out.Format("messages = %d, bytes = %d", count, total);
return out;
}
/////////////////////////////////////////////////////////////////////////////
bool NetNodeInput::IsMessageAvailable()

View file

@ -15,6 +15,8 @@ public:
void WriteMessage(const void *data, size_t size, bool unreliable);
void Send(doomcom_t* comm, int nodeIndex);
void AckPacket(uint8_t headerFlags, uint16_t serial, uint16_t ack);
FString GetStats();
private:
struct Message

View file

@ -203,6 +203,13 @@ int NetServer::GetPing(int player) const
return 0;
}
FString NetServer::GetStats()
{
FString out;
out = "NetServer";
return out;
}
void NetServer::ListPingTimes()
{
#if 0

View file

@ -68,6 +68,7 @@ public:
void WriteBotInput(int player, const ticcmd_t &cmd) override;
int GetPing(int player) const override;
FString GetStats() override;
void ListPingTimes() override;
void Network_Controller(int playernum, bool add) override;

View file

@ -123,3 +123,8 @@ void NetSinglePlayer::ListPingTimes()
void NetSinglePlayer::Network_Controller(int playernum, bool add)
{
}
FString NetSinglePlayer::GetStats()
{
return "Not in a multiplayer game";
}

View file

@ -43,6 +43,7 @@ public:
void WriteBotInput(int player, const ticcmd_t &cmd) override;
int GetPing(int player) const override;
FString GetStats() override;
void ListPingTimes() override;
void Network_Controller(int playernum, bool add) override;