OpenClonk
C4Network2Stats Class Reference

#include <C4Network2Stats.h>

Inheritance diagram for C4Network2Stats:
[legend]
Collaboration diagram for C4Network2Stats:
[legend]

Public Member Functions

 C4Network2Stats ()
 
 ~C4Network2Stats () override
 
void ExecuteFrame ()
 
void ExecuteSecond ()
 
void ExecuteControlFrame ()
 
void OnSec1Timer () override
 
C4GraphGetGraphByName (const StdStrBuf &rszName, bool &rfIsTemp)
 

Protected Attributes

C4GraphCollection statPings
 
C4GraphCollection statControls
 
C4GraphCollection statActions
 
int SecondCounter
 
int ControlCounter
 

Private Member Functions

bool Execute (int, pollfd *) override
 
void Set ()
 
void SetDelay (uint32_t inDelay)
 
bool CheckAndReset ()
 
C4TimeMilliseconds GetNextTick (C4TimeMilliseconds tNow) override
 
uint32_t TimerInterval () override
 
void Changed ()
 
bool ExecuteUntil (int iTimeout=-1)
 
virtual void GetFDs (std::vector< struct pollfd > &)
 
bool IsSignaled ()
 
virtual bool IsLowPriority ()
 
virtual bool IsNotify ()
 

Friends

class C4Player
 
class C4Network2Client
 

Detailed Description

Definition at line 163 of file C4Network2Stats.h.

Constructor & Destructor Documentation

◆ C4Network2Stats()

C4Network2Stats::C4Network2Stats ( )

Definition at line 300 of file C4Network2Stats.cpp.

References StdScheduler::Add(), Application, C4Network2::Clients, C4Network2Client::CreateGraphs(), C4PlayerList::First, C4Network2ClientList::GetNextClient(), LoadResStr(), Network, C4Player::Next, and Players.

301 {
302  // init callback timer
303  Application.Add(this);
304  SecondCounter = 0;
305  ControlCounter = 0;
306  // init graphs
307  statObjCount.SetTitle(LoadResStr("IDS_MSG_OBJCOUNT"));
308  statFPS.SetTitle(LoadResStr("IDS_MSG_FPS"));
309  statNetI.SetTitle(LoadResStr("IDS_NET_INPUT"));
310  statNetI.SetColorDw(0x00ff00);
311  statNetO.SetTitle(LoadResStr("IDS_NET_OUTPUT"));
312  statNetO.SetColorDw(0xff0000);
313  graphNetIO.AddGraph(&statNetI); graphNetIO.AddGraph(&statNetO);
314  statControls.SetTitle(LoadResStr("IDS_NET_CONTROL"));
316  statActions.SetTitle(LoadResStr("IDS_NET_APM"));
318  for (C4Player *pPlr = ::Players.First; pPlr; pPlr = pPlr->Next) pPlr->CreateGraphs();
319  C4Network2Client *pClient = nullptr;
320  while ((pClient = ::Network.Clients.GetNextClient(pClient))) pClient->CreateGraphs();
321 }
C4GraphCollection statControls
C4Network2Client * GetNextClient(C4Network2Client *pClient)
C4Player * First
Definition: C4PlayerList.h:31
void Add(StdSchedulerProc *pProc)
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4Network2 Network
Definition: C4Globals.cpp:53
C4GraphCollection statActions
C4PlayerList Players
C4Network2ClientList Clients
Definition: C4Network2.h:116
void SetAverageTime(int iToTime) override
C4Player * Next
Definition: C4Player.h:142
void SetTitle(const char *szNewTitle)
void AddGraph(C4Graph *pAdd)
C4Application Application
Definition: C4Globals.cpp:44
void SetColorDw(DWORD dwClr)
Here is the call graph for this function:

◆ ~C4Network2Stats()

C4Network2Stats::~C4Network2Stats ( )
override

Definition at line 323 of file C4Network2Stats.cpp.

References Application, C4Network2Client::ClearGraphs(), C4Network2::Clients, C4PlayerList::First, C4Network2ClientList::GetNextClient(), Network, C4Player::Next, Players, and StdScheduler::Remove().

324 {
325  for (C4Player *pPlr = ::Players.First; pPlr; pPlr = pPlr->Next) pPlr->ClearGraphs();
326  C4Network2Client *pClient = nullptr;
327  while ((pClient = ::Network.Clients.GetNextClient(pClient))) pClient->ClearGraphs();
328  Application.Remove(this);
329 }
C4Network2Client * GetNextClient(C4Network2Client *pClient)
C4Player * First
Definition: C4PlayerList.h:31
C4Network2 Network
Definition: C4Globals.cpp:53
C4PlayerList Players
void Remove(StdSchedulerProc *pProc)
C4Network2ClientList Clients
Definition: C4Network2.h:116
C4Player * Next
Definition: C4Player.h:142
C4Application Application
Definition: C4Globals.cpp:44
Here is the call graph for this function:

Member Function Documentation

◆ ExecuteControlFrame()

void C4Network2Stats::ExecuteControlFrame ( )

Definition at line 353 of file C4Network2Stats.cpp.

References Control, C4GameControl::ControlRate, C4PlayerList::First, C4Player::Next, and Players.

354 {
355  // control rate may have updated: always convert values to actions per minute
358  // register and reset control counts for all players
359  for (C4Player *pPlr = ::Players.First; pPlr; pPlr = pPlr->Next)
360  {
361  if (pPlr->pstatControls)
362  {
363  pPlr->pstatControls->RecordValue(C4Graph::ValueType(pPlr->ControlCount));
364  pPlr->ControlCount = 0;
365  }
366  if (pPlr->pstatActions)
367  {
368  pPlr->pstatActions->RecordValue(C4Graph::ValueType(pPlr->ActionCount));
369  pPlr->ActionCount = 0;
370  }
371  }
372  ++ControlCounter;
373 }
C4GraphCollection statControls
C4Player * First
Definition: C4PlayerList.h:31
C4GameControl Control
C4GraphCollection statActions
C4PlayerList Players
float ValueType
C4Player * Next
Definition: C4Player.h:142
void SetMultiplier(ValueType fToVal) override
int32_t ControlRate
Definition: C4GameControl.h:88

◆ ExecuteFrame()

void C4Network2Stats::ExecuteFrame ( )

Definition at line 331 of file C4Network2Stats.cpp.

References C4ObjectList::ObjectCount(), and Objects.

332 {
334 }
int ObjectCount(C4ID id=C4ID::None) const
void RecordValue(ValueType iValue)
float ValueType
C4GameObjects Objects
Definition: C4Globals.cpp:48
Here is the call graph for this function:

◆ ExecuteSecond()

void C4Network2Stats::ExecuteSecond ( )

Definition at line 336 of file C4Network2Stats.cpp.

References C4Network2::Clients, C4Game::FPS, Game, C4Network2IOConnection::getLag(), C4Network2Client::getMsgConn(), C4Network2ClientList::GetNextClient(), C4Network2IO::getProtIRate(), C4Network2IO::getProtORate(), C4Network2Client::getStatPing(), C4Network2::NetIO, Network, P_TCP, P_UDP, and C4TableGraph::RecordValue().

337 {
341  // pings for all clients
342  C4Network2Client *pClient = nullptr;
343  while ((pClient = ::Network.Clients.GetNextClient(pClient))) if (pClient->getStatPing())
344  {
345  int iPing=0;
346  C4Network2IOConnection *pConn = pClient->getMsgConn();
347  if (pConn) iPing = pConn->getLag();
348  pClient->getStatPing()->RecordValue(C4Graph::ValueType(iPing));
349  }
350  ++SecondCounter;
351 }
class C4TableGraph * getStatPing() const
C4Network2Client * GetNextClient(C4Network2Client *pClient)
C4Network2IO NetIO
Definition: C4Network2.h:110
C4Game Game
Definition: C4Globals.cpp:52
int getProtIRate(C4Network2IOProtocol eProt) const
Definition: C4Network2IO.h:153
C4Network2IOConnection * getMsgConn() const
C4Network2 Network
Definition: C4Globals.cpp:53
int32_t FPS
Definition: C4Game.h:111
C4Network2ClientList Clients
Definition: C4Network2.h:116
void RecordValue(ValueType iValue)
float ValueType
int getProtORate(C4Network2IOProtocol eProt) const
Definition: C4Network2IO.h:154
Here is the call graph for this function:

◆ GetGraphByName()

C4Graph * C4Network2Stats::GetGraphByName ( const StdStrBuf rszName,
bool &  rfIsTemp 
)

Definition at line 375 of file C4Network2Stats.cpp.

References StdStrBuf::getData(), and SEqualNoCase().

376 {
377  // compare against default graph names
378  rfIsTemp = false;
379  if (SEqualNoCase(rszName.getData(), "oc")) return &statObjCount;
380  if (SEqualNoCase(rszName.getData(), "fps")) return &statFPS;
381  if (SEqualNoCase(rszName.getData(), "netio")) return &graphNetIO;
382  if (SEqualNoCase(rszName.getData(), "pings")) return &statPings;
383  if (SEqualNoCase(rszName.getData(), "control")) return &statControls;
384  if (SEqualNoCase(rszName.getData(), "apm")) return &statActions;
385  // no match
386  return nullptr;
387 }
C4GraphCollection statControls
bool SEqualNoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:207
C4GraphCollection statPings
C4GraphCollection statActions
const char * getData() const
Definition: StdBuf.h:442
Here is the call graph for this function:

◆ OnSec1Timer()

void C4Network2Stats::OnSec1Timer ( )
inlineoverridevirtual

Implements C4ApplicationSec1Timer.

Definition at line 199 of file C4Network2Stats.h.

199 { ExecuteSecond(); }

Friends And Related Function Documentation

◆ C4Network2Client

friend class C4Network2Client
friend

Definition at line 188 of file C4Network2Stats.h.

◆ C4Player

friend class C4Player
friend

Definition at line 187 of file C4Network2Stats.h.

Member Data Documentation

◆ ControlCounter

int C4Network2Stats::ControlCounter
protected

Definition at line 185 of file C4Network2Stats.h.

◆ SecondCounter

int C4Network2Stats::SecondCounter
protected

Definition at line 184 of file C4Network2Stats.h.

◆ statActions

C4GraphCollection C4Network2Stats::statActions
protected

Definition at line 182 of file C4Network2Stats.h.

◆ statControls

C4GraphCollection C4Network2Stats::statControls
protected

Definition at line 181 of file C4Network2Stats.h.

◆ statPings

C4GraphCollection C4Network2Stats::statPings
protected

Definition at line 178 of file C4Network2Stats.h.


The documentation for this class was generated from the following files: