mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-24 21:11:52 +00:00
Add net stat
This commit is contained in:
parent
377f4c50ba
commit
81ecf88902
10 changed files with 47 additions and 0 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -123,3 +123,8 @@ void NetSinglePlayer::ListPingTimes()
|
|||
void NetSinglePlayer::Network_Controller(int playernum, bool add)
|
||||
{
|
||||
}
|
||||
|
||||
FString NetSinglePlayer::GetStats()
|
||||
{
|
||||
return "Not in a multiplayer game";
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue