EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
StatisticMgr Class Reference

#include "StatisticMgr.h"

Inheritance diagram for StatisticMgr:
Collaboration diagram for StatisticMgr:

Public Member Functions

 ~StatisticMgr ()
 
- Public Member Functions inherited from Singleton< StatisticMgr >
 Singleton ()
 Primary constructor. More...
 

Private Attributes

StatisticData m_data
 
int8 m_counter
 

StatisticMgr.cpp

server information system for managing and saving trivial ingame statistical data

: Allan

Date
: 8 March 2018
 StatisticMgr ()
 
int Initialize ()
 
void Close ()
 
void GetInfo ()
 
void Process ()
 
void PrintInfo ()
 
void ClearAll ()
 
void Add (uint8 key, double value)
 
void Increment (uint8 key)
 
void SaveData ()
 
void CompileData ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Singleton< StatisticMgr >
static StatisticMgrget ()
 
- Static Protected Attributes inherited from Singleton< StatisticMgr >
static std::shared_ptr
< StatisticMgr
mInstance
 

Detailed Description

Definition at line 37 of file StatisticMgr.h.

Constructor & Destructor Documentation

StatisticMgr::StatisticMgr ( )

Definition at line 16 of file StatisticMgr.cpp.

References m_data.

17 : m_counter(3) // do first update 15m after server starts
18 {
20 }
StatisticData m_data
Definition: StatisticMgr.h:61
StatisticMgr::~StatisticMgr ( )
inline

Definition at line 42 of file StatisticMgr.h.

42 { /* do nothing here */ }

Member Function Documentation

void StatisticMgr::Add ( uint8  key,
double  value 
)

Definition at line 73 of file StatisticMgr.cpp.

References Stat::iskMarket, StatisticData::iskMarket, m_data, Stat::npcBounties, StatisticData::npcBounties, Stat::oreMined, StatisticData::oreMined, Stat::pcBounties, StatisticData::pcBounties, sEntityList, sLog, and StatisticData::span.

74 {
75  m_data.span = sEntityList.GetMinutes();
76  switch(key) {
77  case Stat::pcBounties:
78  m_data.pcBounties += value;
79  break;
80  case Stat::npcBounties:
81  m_data.npcBounties += value;
82  break;
83  case Stat::oreMined:
84  m_data.oreMined += value;
85  break;
86  case Stat::iskMarket:
87  m_data.iskMarket += value;
88  break;
89  default:
90  sLog.Error("StatisticMgr::Add()", "Default reached for key %u.", key );
91  break;
92  }
93 }
StatisticData m_data
Definition: StatisticMgr.h:61
#define sEntityList
Definition: EntityList.h:208
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type() key(value)-Send an OnRemoteMessage" ) COMMAND( setbpattr
void StatisticMgr::ClearAll ( )

Definition at line 38 of file StatisticMgr.cpp.

References m_data.

39 {
41 }
StatisticData m_data
Definition: StatisticMgr.h:61
void StatisticMgr::Close ( )

Definition at line 22 of file StatisticMgr.cpp.

References SaveData(), and sLog.

23 {
24  // save current data to db before exit.
25  SaveData();
26  sLog.Warning(" StatisticMgr", "Statistics Manager has been closed." );
27 }
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250

Here is the call graph for this function:

void StatisticMgr::CompileData ( )
protected

Definition at line 139 of file StatisticMgr.cpp.

References DBResultRow::GetFloat(), DBResultRow::GetInt(), DBQueryResult::GetRow(), DBQueryResult::GetRowCount(), ManagerDB::GetStatisticData(), StatisticData::iskMarket, StatisticData::npcBounties, StatisticData::oreMined, StatisticData::pcBounties, StatisticData::pcMissiles, StatisticData::pcShots, StatisticData::probesLaunched, StatisticData::ramJobs, SafeDelete(), sEntityList, StatisticData::shipsSalvaged, StatisticData::sitesScanned, and ManagerDB::UpdateStatisticHistory().

Referenced by Process().

140 {
141  DBQueryResult* res = new DBQueryResult();
142  DBResultRow row;
143  ManagerDB::GetStatisticData(*res, sEntityList.GetStartTime());
144  if (res->GetRowCount() > 0) {
145  StatisticData data = StatisticData();
146  while (res->GetRow(row)) {
147  //SELECT pcShots, pcMissiles, ramJobs, shipsSalvaged, pcBounties, npcBounties, oreMined, iskMarket, sitesScanned, probesLaunched FROM srvStatisticData
148  data.pcShots += row.GetInt(0);
149  data.pcMissiles += row.GetInt(1);
150  data.ramJobs += row.GetInt(2);
151  data.shipsSalvaged += row.GetInt(3);
152  data.pcBounties += row.GetFloat(4);
153  data.npcBounties += row.GetFloat(5);
154  data.oreMined += row.GetFloat(6);
155  data.iskMarket += row.GetFloat(7);
156  data.sitesScanned += row.GetInt(8);
157  data.probesLaunched += row.GetInt(9);
158  }
159 
160  if (data.pcShots == 0)
161  if (data.pcMissiles == 0)
162  if (data.iskMarket == 0)
163  if (data.oreMined == 0)
164  if (data.shipsSalvaged == 0)
165  if (data.ramJobs == 0)
166  if (data.pcBounties == 0)
167  if (data.npcBounties == 0)
168  if (data.probesLaunched == 0)
169  if (data.sitesScanned == 0)
170  return;
171 
172  // data has been compiled for this running session. save to history.
174  }
175 
176  SafeDelete(res);
177 }
static void GetStatisticData(DBQueryResult &res, int64 starttime)
Definition: ManagerDB.cpp:714
float GetFloat(uint32 index) const
Definition: dbcore.cpp:682
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
#define sEntityList
Definition: EntityList.h:208
uint16 shipsSalvaged
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
uint16 probesLaunched
size_t GetRowCount()
Definition: dbcore.h:72
static void UpdateStatisticHistory(StatisticData &data)
Definition: ManagerDB.cpp:737

Here is the call graph for this function:

Here is the caller graph for this function:

void StatisticMgr::GetInfo ( )

Definition at line 43 of file StatisticMgr.cpp.

44 {
45  // return current data?
46 }
void StatisticMgr::Increment ( uint8  key)

Definition at line 95 of file StatisticMgr.cpp.

References m_data, Stat::pcMissiles, StatisticData::pcMissiles, Stat::pcShots, StatisticData::pcShots, Stat::probesLaunched, StatisticData::probesLaunched, Stat::ramJobs, StatisticData::ramJobs, sEntityList, Stat::shipsSalvaged, StatisticData::shipsSalvaged, Stat::sitesScanned, StatisticData::sitesScanned, sLog, and StatisticData::span.

96 {
97  m_data.span = sEntityList.GetMinutes();
98  switch(key) {
99  case Stat::pcShots:
100  ++m_data.pcShots;
101  break;
102  case Stat::ramJobs:
103  ++m_data.ramJobs;
104  break;
105  case Stat::pcMissiles:
106  ++m_data.pcMissiles;
107  break;
108  case Stat::shipsSalvaged:
110  break;
111  case Stat::sitesScanned:
113  break;
116  break;
117  default:
118  sLog.Error("StatisticMgr::Increment()", "Default reached for key %u.", key );
119  break;
120  }
121 }
StatisticData m_data
Definition: StatisticMgr.h:61
#define sEntityList
Definition: EntityList.h:208
uint16 shipsSalvaged
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
uint16 probesLaunched
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type() key(value)-Send an OnRemoteMessage" ) COMMAND( setbpattr
int StatisticMgr::Initialize ( )

Definition at line 29 of file StatisticMgr.cpp.

References m_data, sLog, and ManagerDB::UpdateStatisticHistory().

30 {
31  //ClearAll();
32  // reset current data for new session
34  sLog.Blue( " StatisticMgr", "Statistics Manager Initialized." );
35  return 1;
36 }
StatisticData m_data
Definition: StatisticMgr.h:61
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
static void UpdateStatisticHistory(StatisticData &data)
Definition: ManagerDB.cpp:737

Here is the call graph for this function:

void StatisticMgr::PrintInfo ( )

Definition at line 123 of file StatisticMgr.cpp.

References StatisticData::iskMarket, m_data, StatisticData::npcBounties, StatisticData::oreMined, StatisticData::pcBounties, StatisticData::pcMissiles, StatisticData::pcShots, StatisticData::probesLaunched, StatisticData::ramJobs, sEntityList, StatisticData::shipsSalvaged, StatisticData::sitesScanned, sLog, and StatisticData::span.

124 {
125  m_data.span = sEntityList.GetMinutes();
126  sLog.Cyan(" StatisticMgr", " Time Span: %u minutes", m_data.span);
127  sLog.Cyan(" StatisticMgr", " PC Shots Fired: %u", m_data.pcShots);
128  sLog.Cyan(" StatisticMgr", " PC Missiles Fired: %u", m_data.pcMissiles);
129  sLog.Cyan(" StatisticMgr", " Scan Probes Launched: %u", m_data.probesLaunched);
130  sLog.Cyan(" StatisticMgr", " Cosmic Signals Scanned: %u", m_data.sitesScanned);
131  sLog.Cyan(" StatisticMgr", " PC Bounties Paid: %.2f isk", m_data.pcBounties);
132  sLog.Cyan(" StatisticMgr", " NPC Bounties Paid: %.2f isk", m_data.npcBounties);
133  sLog.Cyan(" StatisticMgr", " Ore Mined: %.2f m3", m_data.oreMined);
134  sLog.Cyan(" StatisticMgr", " ISK Spent in Market: %.2f isk", m_data.iskMarket);
135  sLog.Cyan(" StatisticMgr", " Ships Salvaged: %u", m_data.shipsSalvaged);
136  sLog.Cyan(" StatisticMgr", " R.A.M. Jobs: %u", m_data.ramJobs);
137 }
StatisticData m_data
Definition: StatisticMgr.h:61
#define sEntityList
Definition: EntityList.h:208
uint16 shipsSalvaged
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
uint16 probesLaunched
void StatisticMgr::Process ( )

Definition at line 49 of file StatisticMgr.cpp.

References CompileData(), m_counter, and SaveData().

50 {
51  SaveData();
52 
53  // check timers and manipulate data accordingly...
54  // this system is currently inaccurate. priority level: low
55  if (++m_counter > 4) { // every hour? provided proc call is 15m
56  m_counter = 0;
57  // every [increment][time] save stat history data
58  CompileData();
59  //sEntityList.ResetStartTime();
60  }
61  /*
62  * SELECT timeStamp, timeSpan, pcShots, pcMissiles, ramJobs, shipsSalvaged, pcBounties, npcBounties, oreMined, iskMarket FROM srvStatisticData
63  * SELECT month, pcShots, pcMissiles, ramJobs, shipsSalvaged, pcBounties, npcBounties, oreMined, iskMarket FROM srvStatisticHistory
64  */
65 }
void CompileData()

Here is the call graph for this function:

void StatisticMgr::SaveData ( )
protected

Definition at line 67 of file StatisticMgr.cpp.

References m_data, ManagerDB::SaveStatisticData(), sEntityList, and StatisticData::span.

Referenced by Close(), and Process().

68 {
69  m_data.span = sEntityList.GetMinutes();
71 }
StatisticData m_data
Definition: StatisticMgr.h:61
#define sEntityList
Definition: EntityList.h:208
static void SaveStatisticData(StatisticData &data)
Definition: ManagerDB.cpp:723

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

int8 StatisticMgr::m_counter
private

Definition at line 63 of file StatisticMgr.h.

Referenced by Process().

StatisticData StatisticMgr::m_data
private

Definition at line 61 of file StatisticMgr.h.

Referenced by Add(), ClearAll(), Increment(), Initialize(), PrintInfo(), SaveData(), and StatisticMgr().


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