OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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 ( )

Definition at line 300 of file C4Network2Stats.cpp.

References StdScheduler::Add(), C4GraphCollection::AddGraph(), Application, C4Network2::Clients, ControlCounter, C4Network2Client::CreateGraphs(), C4PlayerList::First, C4Network2ClientList::GetNextClient(), LoadResStr(), Network, C4Player::Next, Players, SecondCounter, C4GraphCollection::SetAverageTime(), C4Graph::SetColorDw(), C4Graph::SetTitle(), statActions, and statControls.

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 ( )
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

void C4Network2Stats::ExecuteControlFrame ( )

Definition at line 353 of file C4Network2Stats.cpp.

References Control, ControlCounter, C4GameControl::ControlRate, C4PlayerList::First, C4Player::Next, Players, C4GraphCollection::SetMultiplier(), statActions, and statControls.

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

Here is the call graph for this function:

void C4Network2Stats::ExecuteFrame ( )

Definition at line 331 of file C4Network2Stats.cpp.

References C4ObjectList::ObjectCount(), Objects, and C4TableGraph::RecordValue().

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:

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, C4TableGraph::RecordValue(), and SecondCounter.

Referenced by OnSec1Timer().

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 }
C4Network2Client * GetNextClient(C4Network2Client *pClient)
C4Network2IO NetIO
Definition: C4Network2.h:110
C4Game Game
Definition: C4Globals.cpp:52
C4Network2IOConnection * getMsgConn() const
C4Network2 Network
Definition: C4Globals.cpp:53
int32_t FPS
Definition: C4Game.h:111
class C4TableGraph * getStatPing() const
int getProtORate(C4Network2IOProtocol eProt) const
Definition: C4Network2IO.h:153
C4Network2ClientList Clients
Definition: C4Network2.h:116
void RecordValue(ValueType iValue)
int getProtIRate(C4Network2IOProtocol eProt) const
Definition: C4Network2IO.h:152
float ValueType

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 375 of file C4Network2Stats.cpp.

References StdStrBuf::getData(), SEqualNoCase(), statActions, statControls, and statPings.

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 }
const char * getData() const
Definition: StdBuf.h:442
C4GraphCollection statControls
bool SEqualNoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:207
C4GraphCollection statPings
C4GraphCollection statActions

Here is the call graph for this function:

void C4Network2Stats::OnSec1Timer ( )
inlineoverridevirtual

Implements C4ApplicationSec1Timer.

Definition at line 199 of file C4Network2Stats.h.

References ExecuteSecond().

199 { ExecuteSecond(); }

Here is the call graph for this function:

Friends And Related Function Documentation

friend class C4Network2Client
friend

Definition at line 188 of file C4Network2Stats.h.

friend class C4Player
friend

Definition at line 187 of file C4Network2Stats.h.

Member Data Documentation

int C4Network2Stats::ControlCounter
protected

Definition at line 185 of file C4Network2Stats.h.

Referenced by C4Network2Stats(), and ExecuteControlFrame().

int C4Network2Stats::SecondCounter
protected

Definition at line 184 of file C4Network2Stats.h.

Referenced by C4Network2Stats(), and ExecuteSecond().

C4GraphCollection C4Network2Stats::statActions
protected

Definition at line 182 of file C4Network2Stats.h.

Referenced by C4Network2Stats(), ExecuteControlFrame(), and GetGraphByName().

C4GraphCollection C4Network2Stats::statControls
protected

Definition at line 181 of file C4Network2Stats.h.

Referenced by C4Network2Stats(), ExecuteControlFrame(), and GetGraphByName().

C4GraphCollection C4Network2Stats::statPings
protected

Definition at line 178 of file C4Network2Stats.h.

Referenced by GetGraphByName().


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