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

#include "CommandDB.h"

Inheritance diagram for CommandDB:
Collaboration diagram for CommandDB:

Public Member Functions

bool ItemSearch (const char *query, std::map< uint32, std::string > &into)
 
bool ItemSearch (uint32 typeID, uint32 &actualTypeID, std::string &actualTypeName, uint32 &actualGroupID, uint32 &actualCategoryID, double &actualRadius)
 
int GetAttributeID (const char *attributeName)
 
int GetAccountID (std::string name)
 
bool FullSkillList (std::vector< uint32 > &skillList)
 
uint32_t GetStation (const char *name)
 
uint32_t GetSolarSystem (const char *name)
 
- Public Member Functions inherited from ServiceDB
uint32 GetStationOwner (uint32 stationID)
 

Additional Inherited Members

- Static Public Member Functions inherited from ServiceDB
static bool GetAccountInformation (CryptoChallengePacket &ccp, AccountData &aData, std::string &failMsg)
 
static bool UpdateAccountHash (const char *username, std::string &hash)
 
static bool IncrementLoginCount (uint32 accountID)
 
static void UpdatePassword (uint32 accountID, const char *pass)
 
static void SaveKillOrLoss (CharKillData &data)
 
static bool GetConstant (const char *name, uint32 &into)
 
static void SetServerOnlineStatus (bool online=false)
 
static void SetCharacterOnlineStatus (uint32 char_id, bool online=false)
 
static void SetAccountOnlineStatus (uint32 accountID, bool online=false)
 
static void SetAccountBanStatus (uint32 accountID, bool banned=false)
 
static void SaveServerStats (double threads, float rss, float vm, float user, float kernel, uint32 items, uint32 bubbles)
 
static uint32 SetClientSeed ()
 
static PyRepLookupChars (const char *match, bool exact=false)
 
static PyRepLookupOwners (const char *match, bool exact=false)
 
static PyRepLookupCorporations (const std::string &)
 
static PyRepLookupFactions (const std::string &)
 
static PyRepLookupCorporationTickers (const std::string &)
 
static PyRepLookupStations (const std::string &)
 
static PyRepLookupKnownLocationsByGroup (const std::string &, uint32)
 
static PyRepPrimeOwners (std::vector< int32 > &itemIDs)
 
static bool ValidateAccountName (CryptoChallengePacket &ccp, std::string &failMsg)
 
static void GetCorpHangarNames (uint32 corpID, std::map< uint8, std::string > &hangarNames)
 
- Protected Member Functions inherited from ServiceDB
void ProcessStringChange (const char *key, const std::string &oldValue, std::string newValue, PyDict *notif, std::vector< std::string > &dbQ)
 
void ProcessRealChange (const char *key, double oldValue, double newValue, PyDict *notif, std::vector< std::string > &dbQ)
 
void ProcessIntChange (const char *key, uint32 oldValue, uint32 newValue, PyDict *notif, std::vector< std::string > &dbQ)
 
void ProcessLongChange (const char *key, int64 oldValue, int64 newValue, PyDict *notif, std::vector< std::string > &dbQ)
 
- Static Protected Member Functions inherited from ServiceDB
static uint32 CreateNewAccount (const char *login, const char *pass, const char *passHash, int64 role)
 

Detailed Description

Definition at line 30 of file CommandDB.h.

Member Function Documentation

bool CommandDB::FullSkillList ( std::vector< uint32 > &  skillList)

Definition at line 213 of file CommandDB.cpp.

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

Referenced by Command_giveallskills().

213  {
214  skillList.clear();
215 
216  DBQueryResult result;
217  if (!sDatabase.RunQuery(result,
218  " SELECT typeID FROM `invTypes` WHERE "
219  " ((`groupID` IN (SELECT groupID FROM invGroups WHERE categoryID = 16)) AND (published = 1)) "
220  ))
221  {
222  codelog(SERVICE__ERROR, "Error in query: %s", result.error.c_str());
223  return false;
224  }
225 
226  DBResultRow row;
227  while (result.GetRow(row)) {
228  skillList.push_back( (row.GetInt(0)) );
229  }
230 
231  // Because we searched skills with published = 1 and some GM skills are not published but still usable,
232  // we will add them manually here:
233  skillList.push_back( 3755 ); // Jove Frigate
234  skillList.push_back( 3758 ); // Jove Cruiser
235  skillList.push_back( 9955 ); // Polaris
236  skillList.push_back( 10264 ); // Concord
237  skillList.push_back( 11075 ); // Jove Industrial
238  skillList.push_back( 11078 ); // Jove Battleship
239  skillList.push_back( 19430 ); // Omnipotent
240  skillList.push_back( 28604 ); // Tournament Observation
241 
242  return true;
243 }
#define sDatabase
Definition: dbcore.h:199
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
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:

int CommandDB::GetAccountID ( std::string  name)

Definition at line 193 of file CommandDB.cpp.

References DBResultRow::GetInt(), DBQueryResult::GetRow(), sDatabase, and sLog.

Referenced by Command_unban().

193  {
194 
195  if (!sDatabase.IsSafeString(name))
196  return 0;
197 
198  DBQueryResult res;
199  if (!sDatabase.RunQuery(res, "SELECT accountID FROM chrCharacters WHERE name = '%s'", name.c_str())) {
200  sLog.Error("CommandDB", "Failed to retrieve accountID for %s", name.c_str());
201  return 0;
202  }
203 
204  DBResultRow row;
205  if (!res.GetRow(row)) {
206  sLog.Error("CommandDB", "Query Returned no results");
207  return 0;
208  }
209 
210  return row.GetInt(0);
211 }
#define sDatabase
Definition: dbcore.h:199
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250

Here is the call graph for this function:

Here is the caller graph for this function:

int CommandDB::GetAttributeID ( const char *  attributeName)

Definition at line 163 of file CommandDB.cpp.

References codelog, DBQueryResult::GetRow(), DBResultRow::GetUInt(), and sDatabase.

Referenced by Command_dogma().

163  {
164 
165  if (!sDatabase.IsSafeString(attributeName))
166  return 0;
167 
168  DBQueryResult res;
169  std::string escape;
170  sDatabase.DoEscapeString(escape, attributeName);
171 
172  if(!sDatabase.RunQuery(res,
173  " SELECT "
174  " attributeID "
175  " FROM dgmAttributeTypes "
176  " WHERE attributeName = '%s' ",
177  escape.c_str() ) )
178  {
179  codelog(DATABASE__ERROR, "Error retrieving attributeID for attributeName = '%s' ", escape.c_str() );
180  return 0;
181  }
182 
183  DBResultRow row;
184  if( !res.GetRow(row) ){
185  codelog(DATABASE__ERROR, "Null result finding attributeID for attributeName = '%s' ", escape.c_str() );
186  return 0;
187  }
188 
189  return row.GetUInt( 0 );
190 
191 }
#define sDatabase
Definition: dbcore.h:199
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
#define codelog(type, fmt,...)
Definition: logsys.h:128

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t CommandDB::GetSolarSystem ( const char *  name)
Todo:
update this...

Definition at line 32 of file CommandDB.cpp.

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

Referenced by Command_tr().

32  {
33  //sDatabase.ReplaceSlash(name);
34  if (!sDatabase.IsSafeString(name))
35  return 0;
36 
37  std::string escaped;
38  sDatabase.DoEscapeString(escaped, name);
39 
40  DBQueryResult result;
41  if (!sDatabase.RunQuery(result,
42  "SELECT solarSystemID "
43  "FROM mapSolarSystems "
44  "WHERE solarSystemName LIKE '%%%s%%';",
45  escaped.c_str()
46  )) {
47  codelog(DATABASE__ERROR, "Error in query: %s", result.error.c_str());
48  return 0;
49  }
50 
51  DBResultRow row;
52  if (!result.GetRow(row)) {
53  codelog(COMMAND__ERROR, "Solar System query returned nothing");
54  return 0;
55  }
56 
57  return row.GetUInt(0);
58 }
#define sDatabase
Definition: dbcore.h:199
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
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:

uint32_t CommandDB::GetStation ( const char *  name)

Definition at line 60 of file CommandDB.cpp.

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

Referenced by Command_tr().

61 {
62  if (!sDatabase.IsSafeString(name))
63  return 0;
64 
65  std::string escaped;
66  sDatabase.DoEscapeString(escaped, name);
67 
68  DBQueryResult result;
69  if (!sDatabase.RunQuery(result,
70  "SELECT `stationID`"
71  " FROM `staStations`"
72  " WHERE `stationName` LIKE '%%%s%%';",
73  escaped.c_str()
74  )) {
75  codelog(DATABASE__ERROR, "Error in query: %s", result.error.c_str());
76  return 0;
77  }
78 
79  DBResultRow row;
80  if (!result.GetRow(row)) {
81  codelog(COMMAND__ERROR, "Station query returned nothing");
82  return 0;
83  }
84 
85  return row.GetUInt(0);
86 }
#define sDatabase
Definition: dbcore.h:199
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
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:

bool CommandDB::ItemSearch ( const char *  query,
std::map< uint32, std::string > &  into 
)

Definition at line 89 of file CommandDB.cpp.

References DBerror::c_str(), codelog, DBQueryResult::error, DBQueryResult::GetRow(), DBResultRow::GetText(), DBResultRow::GetUInt(), and sDatabase.

Referenced by Command_search(), Command_spawn(), Command_spawnn(), and generic_createitem().

89  {
90 
91  into.clear();
92 
93  //sDatabase.ReplaceSlash(query);
94  if (!sDatabase.IsSafeString(query))
95  return 0;
96 
97  std::string escaped;
98  sDatabase.DoEscapeString(escaped, query);
99 
100 
101  //we need to query out the primary message here... not sure how to properly
102  //grab the "main message" though... the text/plain clause is pretty hackish.
103  DBQueryResult result;
104  if (!sDatabase.RunQuery(result,
105  " SELECT typeID,typeName"
106  " FROM invTypes"
107  " WHERE"
108  " typeName rlike '%s'",
109  escaped.c_str()
110  ))
111  {
112  codelog(SERVICE__ERROR, "Error in query: %s", result.error.c_str());
113  return (false);
114  }
115 
116  DBResultRow row;
117  while(result.GetRow(row)) {
118  into[row.GetUInt(0)] = row.GetText(1);
119  }
120  return true;
121 }
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
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:

bool CommandDB::ItemSearch ( uint32  typeID,
uint32 actualTypeID,
std::string &  actualTypeName,
uint32 actualGroupID,
uint32 actualCategoryID,
double &  actualRadius 
)

Definition at line 123 of file CommandDB.cpp.

References DBerror::c_str(), DBQueryResult::error, DBResultRow::GetDouble(), DBQueryResult::GetRow(), DBResultRow::GetText(), DBResultRow::GetUInt(), sDatabase, and sLog.

125 {
126  DBQueryResult result;
127  DBResultRow row;
128 
129  if (!sDatabase.RunQuery(result,
130  "SELECT "
131  " invTypes.typeID,"
132  " invTypes.typeName,"
133  " invTypes.groupID,"
134  " invTypes.radius,"
135  " invGroups.categoryID"
136  " FROM invTypes"
137  " LEFT JOIN invGroups"
138  " ON invGroups.groupID = invTypes.groupID"
139  " WHERE typeID = %u",
140  typeID
141  ))
142  {
143  sLog.Error( "CommandDB::ItemSearch()", "Error in query: %s", result.error.c_str() );
144  return (false);
145  }
146 
147  if( !result.GetRow(row) )
148  {
149  sLog.Error( "CommandDB::ItemSearch()", "Query returned NO results: %s", result.error.c_str() );
150  return (false);
151  }
152 
153  // Extract values from the first row:
154  actualTypeID = row.GetUInt( 0 );
155  actualTypeName = row.GetText( 1 );
156  actualGroupID = row.GetUInt( 2 );
157  actualCategoryID = row.GetUInt( 4 );
158  actualRadius = row.GetDouble( 3 );
159 
160  return true;
161 }
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
double GetDouble(uint32 index) const
Definition: dbcore.cpp:693
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:


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