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 ()
 
virtual ~C4Network2Stats ()
 
void ExecuteFrame ()
 
void ExecuteSecond ()
 
void ExecuteControlFrame ()
 
virtual void OnSec1Timer ()
 
C4GraphGetGraphByName (const StdStrBuf &rszName, bool &rfIsTemp)
 

Protected Attributes

C4GraphCollection statPings
 
C4GraphCollection statControls
 
C4GraphCollection statActions
 
int SecondCounter
 
int ControlCounter
 

Private Member Functions

virtual bool Execute (int, pollfd *)
 
void Set ()
 
void SetDelay (uint32_t inDelay)
 
bool CheckAndReset ()
 
virtual C4TimeMilliseconds GetNextTick (C4TimeMilliseconds tNow)
 
virtual uint32_t TimerInterval ()
 
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 166 of file C4Network2Stats.h.

Constructor & Destructor Documentation

C4Network2Stats::C4Network2Stats ( )

Definition at line 302 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.

303 {
304  // init callback timer
305  Application.Add(this);
306  SecondCounter = 0;
307  ControlCounter = 0;
308  // init graphs
309  statObjCount.SetTitle(LoadResStr("IDS_MSG_OBJCOUNT"));
310  statFPS.SetTitle(LoadResStr("IDS_MSG_FPS"));
311  statNetI.SetTitle(LoadResStr("IDS_NET_INPUT"));
312  statNetI.SetColorDw(0x00ff00);
313  statNetO.SetTitle(LoadResStr("IDS_NET_OUTPUT"));
314  statNetO.SetColorDw(0xff0000);
315  graphNetIO.AddGraph(&statNetI); graphNetIO.AddGraph(&statNetO);
316  statControls.SetTitle(LoadResStr("IDS_NET_CONTROL"));
318  statActions.SetTitle(LoadResStr("IDS_NET_APM"));
320  for (C4Player *pPlr = ::Players.First; pPlr; pPlr = pPlr->Next) pPlr->CreateGraphs();
321  C4Network2Client *pClient = nullptr;
322  while ((pClient = ::Network.Clients.GetNextClient(pClient))) pClient->CreateGraphs();
323 }
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
virtual void SetAverageTime(int iToTime)
C4Player * Next
Definition: C4Player.h:144
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 ( )
virtual

Definition at line 325 of file C4Network2Stats.cpp.

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

326 {
327  for (C4Player *pPlr = ::Players.First; pPlr; pPlr = pPlr->Next) pPlr->ClearGraphs();
328  C4Network2Client *pClient = nullptr;
329  while ((pClient = ::Network.Clients.GetNextClient(pClient))) pClient->ClearGraphs();
330  Application.Remove(this);
331 }
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:144
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Member Function Documentation

void C4Network2Stats::ExecuteControlFrame ( )

Definition at line 355 of file C4Network2Stats.cpp.

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

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

Here is the call graph for this function:

void C4Network2Stats::ExecuteFrame ( )

Definition at line 333 of file C4Network2Stats.cpp.

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

334 {
336 }
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 338 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().

339 {
343  // pings for all clients
344  C4Network2Client *pClient = nullptr;
345  while ((pClient = ::Network.Clients.GetNextClient(pClient))) if (pClient->getStatPing())
346  {
347  int iPing=0;
348  C4Network2IOConnection *pConn = pClient->getMsgConn();
349  if (pConn) iPing = pConn->getLag();
350  pClient->getStatPing()->RecordValue(C4Graph::ValueType(iPing));
351  }
352  ++SecondCounter;
353 }
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:113
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 377 of file C4Network2Stats.cpp.

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

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

Here is the call graph for this function:

virtual void C4Network2Stats::OnSec1Timer ( )
inlinevirtual

Implements C4ApplicationSec1Timer.

Definition at line 202 of file C4Network2Stats.h.

References ExecuteSecond().

202 { ExecuteSecond(); }

Here is the call graph for this function:

Friends And Related Function Documentation

friend class C4Network2Client
friend

Definition at line 191 of file C4Network2Stats.h.

friend class C4Player
friend

Definition at line 190 of file C4Network2Stats.h.

Member Data Documentation

int C4Network2Stats::ControlCounter
protected

Definition at line 188 of file C4Network2Stats.h.

Referenced by C4Network2Stats(), and ExecuteControlFrame().

int C4Network2Stats::SecondCounter
protected

Definition at line 187 of file C4Network2Stats.h.

Referenced by C4Network2Stats(), and ExecuteSecond().

C4GraphCollection C4Network2Stats::statActions
protected

Definition at line 185 of file C4Network2Stats.h.

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

C4GraphCollection C4Network2Stats::statControls
protected

Definition at line 184 of file C4Network2Stats.h.

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

C4GraphCollection C4Network2Stats::statPings
protected

Definition at line 181 of file C4Network2Stats.h.

Referenced by GetGraphByName().


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