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

#include "EffectsDataMgr.h"

Inheritance diagram for FxDataMgr:
Collaboration diagram for FxDataMgr:

Public Member Functions

float GetFxTime ()
 
uint16 GetFxSize ()
 
- Public Member Functions inherited from Singleton< FxDataMgr >
 Singleton ()
 Primary constructor. More...
 

Private Attributes

bool m_loaded
 
float m_time
 
effectMapType m_fxMap
 
effectMapType m_effectMap
 
std::map< uint16, Operandm_opMap
 
std::map< uint16, Expressionm_expMap
 
std::map< std::string, uint16m_effectName
 
std::unordered_multimap
< uint16, TypeEffects
m_typeFxMap
 

EffectsDataMgr.h

This file is for retrieving, manipulating and managing effect data Copyright 2017 EVEmu Team

: Allan

Date
: 29 January 2017
 FxDataMgr ()
 
 ~FxDataMgr ()
 
int Initialize ()
 
void Populate ()
 
bool isWarpSafe (uint16 eID)
 
bool isOffensive (uint16 eID)
 
bool isAssistance (uint16 eID)
 
uint16 GetEffectID (std::string effectName)
 
std::string GetEffectGuid (uint16 eID)
 
std::string GetEffectName (uint16 eID)
 
Effect GetEffect (uint16 eID)
 
Operand GetOperand (uint16 oID)
 
Expression GetExpression (uint16 eID)
 
void GetTypeEffect (uint16 typeID, std::vector< TypeEffects > &typeEffMap)
 
void GetOperands (DBQueryResult &res)
 
void GetDgmEffects (DBQueryResult &res)
 
void GetExpressions (DBQueryResult &res)
 
void GetDgmTypeEffects (DBQueryResult &res)
 

Additional Inherited Members

- Static Public Member Functions inherited from Singleton< FxDataMgr >
static FxDataMgrget ()
 
- Static Protected Attributes inherited from Singleton< FxDataMgr >
static std::shared_ptr< FxDataMgrmInstance
 

Detailed Description

Definition at line 17 of file EffectsDataMgr.h.

Constructor & Destructor Documentation

FxDataMgr::FxDataMgr ( )

Definition at line 16 of file EffectsDataMgr.cpp.

References m_effectMap, m_expMap, m_fxMap, m_loaded, m_opMap, and m_typeFxMap.

17 {
18  m_loaded = false;
19 
20  m_fxMap.clear();
21  m_opMap.clear();
22  m_expMap.clear();
23  m_effectMap.clear();
24  m_typeFxMap.clear();
25 }
std::map< uint16, Expression > m_expMap
effectMapType m_effectMap
std::map< uint16, Operand > m_opMap
std::unordered_multimap< uint16, TypeEffects > m_typeFxMap
effectMapType m_fxMap
FxDataMgr::~FxDataMgr ( )

Definition at line 27 of file EffectsDataMgr.cpp.

28 {
29 
30 }

Member Function Documentation

void FxDataMgr::GetDgmEffects ( DBQueryResult res)
protected

Definition at line 246 of file EffectsDataMgr.cpp.

References DBerror::c_str(), codelog, DBQueryResult::error, and sDatabase.

Referenced by Populate().

247 {
248  if( !sDatabase.RunQuery(res,
249  " SELECT"
250  " effectID,"
251  " effectName,"
252  " effectCategory,"
253  " preExpression,"
254  " postExpression,"
255  " isOffensive,"
256  " isAssistance,"
257  " disallowAutoRepeat,"
258  " isWarpSafe,"
259  " npcUsageChanceAttributeID,"
260  " npcActivationChanceAttributeID,"
261  " fittingUsageChanceAttributeID,"
262  " durationAttributeID,"
263  " trackingSpeedAttributeID,"
264  " dischargeAttributeID,"
265  " rangeAttributeID,"
266  " falloffAttributeID,"
267  " rangeChance," // dunno what this is ...bool?
268  " electronicChance," // dunno what this is...bool?
269  " propulsionChance," // not used (all 0)...bool?
270  " guid"
271  " FROM dgmEffects"))
272  {
273  codelog(DATABASE__ERROR, "Error in GetDgmEffects: %s", res.error.c_str());
274  }
275 }
#define sDatabase
Definition: dbcore.h:199
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

Here is the caller graph for this function:

void FxDataMgr::GetDgmTypeEffects ( DBQueryResult res)
protected

Definition at line 297 of file EffectsDataMgr.cpp.

References DBerror::c_str(), codelog, DBQueryResult::error, and sDatabase.

Referenced by Populate().

298 {
299  if( !sDatabase.RunQuery(res,
300  " SELECT"
301  " typeID,"
302  " effectID,"
303  " isDefault"
304  " FROM dgmTypeEffects "
305  " WHERE effectID != 132")) // 132 maps skill level onto skill data. this screws up my skill level code
306  {
307  codelog(DATABASE__ERROR, "Error in GetDgmTypeEffects: %s", res.error.c_str());
308  }
309 }
#define sDatabase
Definition: dbcore.h:199
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

Here is the caller graph for this function:

Effect FxDataMgr::GetEffect ( uint16  eID)

Definition at line 149 of file EffectsDataMgr.cpp.

References m_effectMap.

150 {
151  effectMapType::const_iterator itr = m_effectMap.find(eID);
152  if (itr != m_effectMap.end())
153  return itr->second;
154  return m_effectMap.at(0);
155 }
effectMapType m_effectMap
std::string FxDataMgr::GetEffectGuid ( uint16  eID)

Definition at line 213 of file EffectsDataMgr.cpp.

References m_effectMap.

214 {
215  effectMapType::const_iterator itr = m_effectMap.find(eID);
216  if (itr != m_effectMap.end())
217  return itr->second.guid;
218  return ""; // default to 'nothing' if effectID not found
219 }
effectMapType m_effectMap
uint16 FxDataMgr::GetEffectID ( std::string  effectName)

Definition at line 205 of file EffectsDataMgr.cpp.

References m_effectName.

206 {
207  std::map<std::string, uint16>::const_iterator itr = m_effectName.find(effectName);
208  if (itr != m_effectName.end())
209  return itr->second;
210  return 0;
211 }
std::map< std::string, uint16 > m_effectName
std::string FxDataMgr::GetEffectName ( uint16  eID)

Definition at line 221 of file EffectsDataMgr.cpp.

References m_effectMap.

222 {
223  effectMapType::const_iterator itr = m_effectMap.find(eID);
224  if (itr != m_effectMap.end())
225  return itr->second.effectName;
226  return ""; // default to 'nothing' if effectID not found
227 }
effectMapType m_effectMap
Expression FxDataMgr::GetExpression ( uint16  eID)

Definition at line 164 of file EffectsDataMgr.cpp.

References m_expMap.

165 {
166  std::map<uint16, Expression>::const_iterator itr = m_expMap.find(eID);
167  if (itr != m_expMap.end())
168  return itr->second;
169  return m_expMap.at(0);
170 }
std::map< uint16, Expression > m_expMap
void FxDataMgr::GetExpressions ( DBQueryResult res)
protected

Definition at line 277 of file EffectsDataMgr.cpp.

References DBerror::c_str(), codelog, DBQueryResult::error, and sDatabase.

Referenced by Populate().

278 {
279  if( !sDatabase.RunQuery(res,
280  " SELECT"
281  " expressionID,"
282  " operandID,"
283  " arg1,"
284  " arg2,"
285  " expressionValue,"
286  " description,"
287  " expressionName,"
288  " expressionTypeID,"
289  " expressionGroupID,"
290  " expressionAttributeID"
291  " FROM dgmExpressions"))
292  {
293  codelog(DATABASE__ERROR, "Error in GetExpressions: %s", res.error.c_str());
294  }
295 }
#define sDatabase
Definition: dbcore.h:199
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

Here is the caller graph for this function:

uint16 FxDataMgr::GetFxSize ( )
inline

Definition at line 40 of file EffectsDataMgr.h.

References m_fxMap.

40 { return m_fxMap.size(); }
effectMapType m_fxMap
float FxDataMgr::GetFxTime ( )
inline

Definition at line 39 of file EffectsDataMgr.h.

References m_time.

39 { return m_time; }
float m_time
Operand FxDataMgr::GetOperand ( uint16  oID)

Definition at line 172 of file EffectsDataMgr.cpp.

References m_opMap.

173 {
174  std::map<uint16, Operand>::const_iterator itr = m_opMap.find(oID);
175  if (itr != m_opMap.end())
176  return itr->second;
177  return m_opMap.at(0);
178 
179 }
std::map< uint16, Operand > m_opMap
void FxDataMgr::GetOperands ( DBQueryResult res)
protected

Definition at line 230 of file EffectsDataMgr.cpp.

References DBerror::c_str(), codelog, DBQueryResult::error, and sDatabase.

Referenced by Populate().

231 {
232  if( !sDatabase.RunQuery(res,
233  " SELECT"
234  " operandID,"
235  " operandKey,"
236  " format,"
237  " arg1categoryID,"
238  " arg2categoryID,"
239  " resultCategoryID"
240  " FROM dgmOperands"))
241  {
242  codelog(DATABASE__ERROR, "Error in GetOperands: %s", res.error.c_str());
243  }
244 }
#define sDatabase
Definition: dbcore.h:199
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

Here is the caller graph for this function:

void FxDataMgr::GetTypeEffect ( uint16  typeID,
std::vector< TypeEffects > &  typeEffMap 
)

Definition at line 157 of file EffectsDataMgr.cpp.

References m_typeFxMap.

158 {
159  auto itr = m_typeFxMap.equal_range(typeID);
160  for (auto it = itr.first; it != itr.second; ++it)
161  typeEffMap.push_back(it->second);
162 }
std::unordered_multimap< uint16, TypeEffects > m_typeFxMap
int FxDataMgr::Initialize ( )

Definition at line 32 of file EffectsDataMgr.cpp.

References Populate(), and sLog.

33 {
34  Populate();
35  sLog.Blue(" FxDataMgr", "Effects Data Manager Initialized.");
36  return 1;
37 }
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
void Populate()

Here is the call graph for this function:

bool FxDataMgr::isAssistance ( uint16  eID)

Definition at line 197 of file EffectsDataMgr.cpp.

References m_effectMap.

198 {
199  effectMapType::const_iterator itr = m_effectMap.find(eID);
200  if (itr != m_effectMap.end())
201  return itr->second.isAssistance;
202  return false; // default to false if effectID not found
203 }
effectMapType m_effectMap
bool FxDataMgr::isOffensive ( uint16  eID)

Definition at line 189 of file EffectsDataMgr.cpp.

References m_effectMap.

190 {
191  effectMapType::const_iterator itr = m_effectMap.find(eID);
192  if (itr != m_effectMap.end())
193  return itr->second.isOffensive;
194  return false; // default to false if effectID not found
195 }
effectMapType m_effectMap
bool FxDataMgr::isWarpSafe ( uint16  eID)

Definition at line 181 of file EffectsDataMgr.cpp.

References m_effectMap.

182 {
183  effectMapType::const_iterator itr = m_effectMap.find(eID);
184  if (itr != m_effectMap.end())
185  return itr->second.isWarpSafe;
186  return false; // default to false if effectID not found
187 }
effectMapType m_effectMap
void FxDataMgr::Populate ( )

Definition at line 39 of file EffectsDataMgr.cpp.

References Expression::arg1, Operand::arg1categoryID, Expression::arg2, Operand::arg2categoryID, Expression::description, Effect::disallowAutoRepeat, Effect::dischargeAttributeID, Effect::durationAttributeID, Effect::effectID, TypeEffects::effectID, Effect::effectName, Effect::effectState, Effect::electronicChance, Expression::expressionAttributeID, Expression::expressionGroupID, Expression::expressionName, Expression::expressionTypeID, Expression::expressionValue, Effect::falloffAttributeID, Effect::fittingUsageChanceAttributeID, Operand::format, DBResultRow::GetBool(), GetDgmEffects(), GetDgmTypeEffects(), GetExpressions(), DBResultRow::GetFloat(), DBResultRow::GetInt(), GetOperands(), DBQueryResult::GetRow(), DBResultRow::GetText(), GetTimeMSeconds(), Effect::guid, Expression::id, Effect::isAssistance, TypeEffects::isDefault, DBResultRow::IsNull(), Effect::isOffensive, Effect::isWarpSafe, m_effectMap, m_effectName, m_expMap, m_loaded, m_opMap, m_typeFxMap, Effect::npcActivationChanceAttributeID, Effect::npcUsageChanceAttributeID, Expression::operandID, Operand::operandKey, Effect::postExpression, Effect::preExpression, Effect::propulsionChance, Effect::rangeAttributeID, Effect::rangeChance, Operand::resultCategoryID, SafeDelete(), sLog, and Effect::trackingSpeedAttributeID.

Referenced by Initialize().

40 {
41  if (m_loaded)
42  return;
43 
44  double begin = GetTimeMSeconds();
45  double start = GetTimeMSeconds();
46  DBResultRow row;
47  DBQueryResult* res = new DBQueryResult();
48 
49  GetDgmTypeEffects(*res);
50  while (res->GetRow(row)) {
51  //SELECT typeID, effectID, isDefault
52  TypeEffects mTfx = TypeEffects();
53  mTfx.effectID = row.GetInt(1);
54  mTfx.isDefault = row.GetBool(2);
55  m_typeFxMap.insert(std::pair<uint16, TypeEffects>(row.GetInt(0), mTfx));
56  }
57  sLog.Cyan(" FxDataMgr", "%u Type Effects loaded in %.3fms.", m_typeFxMap.size(), (GetTimeMSeconds() - start));
58 
59  //res->Reset();
60  start = GetTimeMSeconds();
61  GetOperands(*res);
62  while (res->GetRow(row)) {
63  //SELECT operandID, operandKey, format, arg1categoryID, arg2categoryID, resultCategoryID
64  Operand mOpr = Operand();
65  mOpr.arg1categoryID = row.GetInt(3);
66  mOpr.arg2categoryID = row.GetInt(4);
67  mOpr.format = row.GetText(2);
68  mOpr.operandKey = row.GetText(1);
69  mOpr.resultCategoryID = row.GetInt(5);
70  m_opMap.insert(std::pair<uint16, Operand>(row.GetInt(0), mOpr));
71  }
72  // insert a zero-value data set
73  Operand mOpr = Operand();
74  mOpr.format = "None";
75  mOpr.operandKey = "NULL";
76  m_opMap[0] = mOpr;
77  sLog.Cyan(" FxDataMgr", "%u Operands loaded in %.3fms.", m_opMap.size(), (GetTimeMSeconds() - start));
78 
79  //res->Reset();
80  start = GetTimeMSeconds();
81  GetExpressions(*res);
82  while (res->GetRow(row)) {
83  //SELECT expressionID, operandID, arg1, arg2, expressionValue, description, expressionName, expressionTypeID, expressionGroupID, expressionAttributeID
84  Expression mExp = Expression();
85  mExp.id = row.GetInt(0);
86  mExp.arg1 = (row.IsNull(2) ? 0 : row.GetInt(2));
87  mExp.arg2 = (row.IsNull(3) ? 0 : row.GetInt(3));
88  mExp.expressionAttributeID = (row.IsNull(9) ? 0 : row.GetInt(9));
89  mExp.description = row.GetText(5);
90  mExp.expressionGroupID = (row.IsNull(8) ? 0 : row.GetInt(8));
91  mExp.expressionName = row.GetText(6);
92  mExp.operandID = row.GetInt(1);
93  mExp.expressionTypeID = (row.IsNull(7) ? 0 : row.GetInt(7));
94  mExp.expressionValue = row.GetText(4);
95  m_expMap.insert(std::pair<uint16, Expression>(row.GetInt(0), mExp));
96  }
97  // insert a zero-value data set
98  Expression mExp = Expression();
99  mExp.description = "NULL";
100  mExp.expressionName = "NULL";
101  m_expMap[0] = mExp;
102  sLog.Cyan(" FxDataMgr", "%u Expressions loaded in %.3fms.", m_expMap.size(), (GetTimeMSeconds() - start));
103 
104  //res->Reset();
105  start = GetTimeMSeconds();
106  GetDgmEffects(*res);
107  while (res->GetRow(row)) {
108  //SELECT effectID, effectName, effectState, preExpression, postExpression, isOffensive, isAssistance, disallowAutoRepeat, isWarpSafe \
109  // npcUsageChanceAttributeID, npcActivationChanceAttributeID, fittingUsageChanceAttributeID,\
110  // durationAttributeID, trackingSpeedAttributeID, dischargeAttributeID, rangeAttributeID, falloffAttributeID, rangeChance, electronicChance, propulsionChance, guid
111  Effect mEffect = Effect();
112  mEffect.effectID = row.GetInt(0);
113  mEffect.effectName = row.GetText(1);
114  mEffect.effectState = row.GetInt(2);
115  mEffect.preExpression = row.GetInt(3);
116  mEffect.postExpression = row.GetInt(4);
117  mEffect.isOffensive = row.GetInt(5) ? true : false;
118  mEffect.isAssistance = row.GetInt(6) ? true : false;
119  mEffect.disallowAutoRepeat = row.GetInt(7) ? true : false;
120  mEffect.isWarpSafe = row.GetInt(8) ? true : false;
121  mEffect.npcUsageChanceAttributeID = row.GetInt(9);
122  mEffect.npcActivationChanceAttributeID = row.GetInt(10);
123  mEffect.fittingUsageChanceAttributeID = row.GetInt(11);
124  mEffect.durationAttributeID = (row.IsNull(12) ? 0 : row.GetInt(12));
125  mEffect.trackingSpeedAttributeID = (row.IsNull(13) ? 0 : row.GetInt(13));
126  mEffect.dischargeAttributeID = (row.IsNull(14) ? 0 : row.GetInt(14));
127  mEffect.rangeAttributeID = (row.IsNull(15) ? 0 : row.GetInt(15));
128  mEffect.falloffAttributeID = (row.IsNull(16) ? 0 : row.GetInt(16));
129  mEffect.rangeChance = row.GetFloat(17);
130  mEffect.electronicChance = row.GetFloat(18);
131  mEffect.propulsionChance = row.GetFloat(19);
132  mEffect.guid = row.GetText(20);
133  m_effectMap.insert(std::pair<uint16, Effect>(row.GetInt(0), mEffect));
134  m_effectName.insert(std::pair<std::string, uint16>(mEffect.effectName, row.GetInt(0)));
135  }
136  // insert a zero-value data set
137  Effect mEffect = Effect();
138  mEffect.effectName = "NULL";
139  m_effectMap[0] = mEffect;
140  sLog.Cyan(" FxDataMgr", "%u Effect Types loaded in %.3fms.", m_effectMap.size(), (GetTimeMSeconds() - start));
141 
142  //cleanup
143  SafeDelete(res);
144 
145  m_loaded = true;
146  sLog.Cyan(" FxDataMgr", "Effects Data loaded in %.3fms.", (GetTimeMSeconds() - begin));
147 }
uint16 preExpression
Definition: EffectsData.h:26
bool isDefault
Definition: EffectsData.h:65
uint16 effectID
Definition: EffectsData.h:66
const char * GetText(uint32 index) const
Definition: dbcore.h:104
std::map< std::string, uint16 > m_effectName
float GetFloat(uint32 index) const
Definition: dbcore.cpp:682
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
uint16 fittingUsageChanceAttributeID
Definition: EffectsData.h:30
uint16 durationAttributeID
Definition: EffectsData.h:31
std::string format
Definition: EffectsData.h:61
uint16 id
Definition: EffectsData.h:45
int8 operandID
Definition: EffectsData.h:44
std::map< uint16, Expression > m_expMap
uint16 postExpression
Definition: EffectsData.h:27
float propulsionChance
Definition: EffectsData.h:38
std::string effectName
Definition: EffectsData.h:39
uint16 falloffAttributeID
Definition: EffectsData.h:35
uint16 expressionTypeID
Definition: EffectsData.h:48
float rangeChance
Definition: EffectsData.h:36
bool isOffensive
Definition: EffectsData.h:20
uint16 arg1categoryID
Definition: EffectsData.h:58
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
std::string operandKey
Definition: EffectsData.h:60
std::string expressionName
Definition: EffectsData.h:53
effectMapType m_effectMap
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
bool GetBool(uint32 index) const
Definition: dbcore.cpp:647
uint8 effectState
Definition: EffectsData.h:25
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
uint16 arg2categoryID
Definition: EffectsData.h:59
double GetTimeMSeconds()
Definition: utils_time.cpp:104
bool isWarpSafe
Definition: EffectsData.h:23
uint16 arg2
Definition: EffectsData.h:47
void GetDgmEffects(DBQueryResult &res)
uint16 dischargeAttributeID
Definition: EffectsData.h:33
bool IsNull(uint32 index) const
Definition: dbcore.h:102
float electronicChance
Definition: EffectsData.h:37
uint16 npcUsageChanceAttributeID
Definition: EffectsData.h:28
uint16 arg1
Definition: EffectsData.h:46
bool isAssistance
Definition: EffectsData.h:21
uint16 expressionAttributeID
Definition: EffectsData.h:50
bool disallowAutoRepeat
Definition: EffectsData.h:22
uint16 expressionGroupID
Definition: EffectsData.h:49
std::map< uint16, Operand > m_opMap
uint16 effectID
Definition: EffectsData.h:24
void GetExpressions(DBQueryResult &res)
std::unordered_multimap< uint16, TypeEffects > m_typeFxMap
std::string expressionValue
Definition: EffectsData.h:51
uint8 resultCategoryID
Definition: EffectsData.h:57
uint16 trackingSpeedAttributeID
Definition: EffectsData.h:32
void GetDgmTypeEffects(DBQueryResult &res)
std::string guid
Definition: EffectsData.h:40
uint16 npcActivationChanceAttributeID
Definition: EffectsData.h:29
std::string description
Definition: EffectsData.h:52
void GetOperands(DBQueryResult &res)
uint16 rangeAttributeID
Definition: EffectsData.h:34

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

effectMapType FxDataMgr::m_effectMap
private
std::map<std::string, uint16> FxDataMgr::m_effectName
private

Definition at line 58 of file EffectsDataMgr.h.

Referenced by GetEffectID(), and Populate().

std::map<uint16, Expression> FxDataMgr::m_expMap
private

Definition at line 57 of file EffectsDataMgr.h.

Referenced by FxDataMgr(), GetExpression(), and Populate().

effectMapType FxDataMgr::m_fxMap
private

Definition at line 53 of file EffectsDataMgr.h.

Referenced by FxDataMgr(), and GetFxSize().

bool FxDataMgr::m_loaded
private

Definition at line 49 of file EffectsDataMgr.h.

Referenced by FxDataMgr(), and Populate().

std::map<uint16, Operand> FxDataMgr::m_opMap
private

Definition at line 56 of file EffectsDataMgr.h.

Referenced by FxDataMgr(), GetOperand(), and Populate().

float FxDataMgr::m_time
private

Definition at line 50 of file EffectsDataMgr.h.

Referenced by GetFxTime().

std::unordered_multimap<uint16, TypeEffects> FxDataMgr::m_typeFxMap
private

Definition at line 59 of file EffectsDataMgr.h.

Referenced by FxDataMgr(), GetTypeEffect(), and Populate().


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