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
 

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.

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 }
C4Application Application
Definition: C4Globals.cpp:44
C4Network2 Network
Definition: C4Globals.cpp:53
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4PlayerList Players
void SetAverageTime(int iToTime) override
void AddGraph(C4Graph *pAdd)
void SetTitle(const char *szNewTitle)
void SetColorDw(DWORD dwClr)
C4Network2Client * GetNextClient(C4Network2Client *pClient)
C4Network2ClientList Clients
Definition: C4Network2.h:116
C4GraphCollection statControls
C4GraphCollection statActions
C4Player * Next
Definition: C4Player.h:142
C4Player * First
Definition: C4PlayerList.h:31
void Add(StdSchedulerProc *pProc)

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.

Here is the call graph for this function:

◆ ~C4Network2Stats()

C4Network2Stats::~C4Network2Stats ( )
override

Definition at line 323 of file C4Network2Stats.cpp.

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 }
void Remove(StdSchedulerProc *pProc)

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

Here is the call graph for this function:

Member Function Documentation

◆ ExecuteControlFrame()

void C4Network2Stats::ExecuteControlFrame ( )

Definition at line 353 of file C4Network2Stats.cpp.

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 }
C4GameControl Control
int32_t ControlRate
Definition: C4GameControl.h:88
void SetMultiplier(ValueType fToVal) override
float ValueType

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

Here is the call graph for this function:

◆ ExecuteFrame()

void C4Network2Stats::ExecuteFrame ( )

Definition at line 331 of file C4Network2Stats.cpp.

332 {
334 }
C4GameObjects Objects
Definition: C4Globals.cpp:48
int ObjectCount(C4ID id=C4ID::None) const
void RecordValue(ValueType iValue)

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

Here is the call graph for this function:

◆ ExecuteSecond()

void C4Network2Stats::ExecuteSecond ( )

Definition at line 336 of file C4Network2Stats.cpp.

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 }
C4Game Game
Definition: C4Globals.cpp:52
@ P_UDP
Definition: C4Network2IO.h:31
@ P_TCP
Definition: C4Network2IO.h:31
int32_t FPS
Definition: C4Game.h:111
class C4TableGraph * getStatPing() const
C4Network2IOConnection * getMsgConn() const
C4Network2IO NetIO
Definition: C4Network2.h:110
int getProtORate(C4Network2IOProtocol eProt) const
Definition: C4Network2IO.h:154
int getProtIRate(C4Network2IOProtocol eProt) const
Definition: C4Network2IO.h:153

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetGraphByName()

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

Definition at line 375 of file C4Network2Stats.cpp.

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

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

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

References ExecuteSecond().

Here is the call graph for this function:

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.

Referenced by C4Network2Stats(), and ExecuteControlFrame().

◆ SecondCounter

int C4Network2Stats::SecondCounter
protected

Definition at line 184 of file C4Network2Stats.h.

Referenced by C4Network2Stats(), and ExecuteSecond().

◆ statActions

C4GraphCollection C4Network2Stats::statActions
protected

Definition at line 182 of file C4Network2Stats.h.

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

◆ statControls

C4GraphCollection C4Network2Stats::statControls
protected

Definition at line 181 of file C4Network2Stats.h.

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

◆ statPings

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: