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

#include "ServiceDB.h"

Inheritance diagram for ServiceDB:

Public Member Functions

uint32 GetStationOwner (uint32 stationID)
 

Static Public Member Functions

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

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

static uint32 CreateNewAccount (const char *login, const char *pass, const char *passHash, int64 role)
 

Detailed Description

This object is the home for common DB operations which may be needed by many different service objects. It should be inherited by each serviceDB implementation.

it's also in need of an overhaul.

Definition at line 41 of file ServiceDB.h.

Member Function Documentation

uint32 ServiceDB::CreateNewAccount ( const char *  login,
const char *  pass,
const char *  passHash,
int64  role 
)
staticprotected

CreateNewAccount

This method is part of the "autoAccount" creation patch by firefoxpdm. This will insert a new account row into the database if the account name doesn't exist at login.

Parameters
loginis a const char string containing the name.
passis a const char string containing the password.
roleis the users role in the game.
Author
firefoxpdm, xanarox

Definition at line 151 of file ServiceDB.cpp.

References DBerror::c_str(), sDatabase, sEntityList, and sLog.

Referenced by GetAccountInformation().

152 {
153  uint32 accountID = 0;
154  uint32 clientID = sEntityList.GetClientSeed();
155 
156  DBerror err;
157  if ( !sDatabase.RunQueryLID( err, accountID,
158  "INSERT INTO account ( accountName, password, hash, role, clientID )"
159  " VALUES ( '%s', '%s', '%s', %li, %u )",
160  login, pass, passHash, role, clientID ) )
161  {
162  sLog.Error( "ServiceDB", "Failed to create a new account '%s':'%s': %s.", login, pass, err.c_str() );
163  return 0;
164  }
165 
166  sDatabase.RunQuery(err, "UPDATE srvStatus SET ClientSeed = ClientSeed + 1 WHERE AI = 1");
167  return accountID;
168 }
#define sDatabase
Definition: dbcore.h:199
#define sEntityList
Definition: EntityList.h:208
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
const char * c_str() const
Definition: dbcore.h:48
unsigned __int32 uint32
Definition: eve-compat.h:50
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

bool ServiceDB::GetAccountInformation ( CryptoChallengePacket &  ccp,
AccountData aData,
std::string &  failMsg 
)
static

Definition at line 70 of file ServiceDB.cpp.

References AccountData::banned, DBerror::c_str(), AccountData::clientID, CreateNewAccount(), DBQueryResult::error, DBResultRow::GetInt(), DBResultRow::GetInt64(), DBQueryResult::GetRow(), DBResultRow::GetText(), DBResultRow::GetUInt(), AccountData::hash, AccountData::id, DBResultRow::IsNull(), AccountData::last_login, AccountData::name, AccountData::online, AccountData::password, AccountData::role, sConfig, sDatabase, sLog, AccountData::type, and AccountData::visits.

Referenced by Client::_VerifyLogin().

71 {
72  //added auto account -allan 18Jan14 -UD 16Jan18 -ud 15Dec18 -ud failMsgs 15Jun19 -ud type 4Nov20
73  std::string eLogin;
74  sDatabase.DoEscapeString(eLogin, ccp.user_name);
75 
76  DBQueryResult res;
77  if ( !sDatabase.RunQuery( res,
78  "SELECT accountID, clientID, password, hash, role, type, online, banned, logonCount, lastLogin"
79  " FROM account WHERE accountName = '%s'", eLogin.c_str() ) )
80  {
81  sLog.Error( "ServiceDB", "Error in query: %s.", res.error.c_str() );
82  failMsg = "Error in DB Query";
83  failMsg += ": Account not found for ";
84  failMsg += eLogin;
85  //failMsg += res.error.c_str(); // do we wanna sent the db error msg to client?
86  return false;
87  }
88 
89  DBResultRow row;
90  if (!res.GetRow( row )) {
91  // account not found, create new one if autoAccountRole is not zero (0)
92  if (sConfig.account.autoAccountRole > 0) {
93  std::string ePass, ePassHash;
94  sDatabase.DoEscapeString(ePass, ccp.user_password);
95  sDatabase.DoEscapeString(ePassHash, ccp.user_password_hash);
96  uint32 accountID = CreateNewAccount( eLogin.c_str(), ePass.c_str(), ePassHash.c_str(), sConfig.account.autoAccountRole);
97  if ( accountID > 0 ) {
98  // add new account successful, get account info
99  return GetAccountInformation(ccp, aData, failMsg);
100  } else {
101  failMsg = "Failed to create a new account.";
102  return false;
103  }
104  } else {
105  failMsg = "That account doesn't exist and AutoAccount is disabled.";
106  return false;
107  }
108  }
109 
110  aData.name = eLogin;
111  aData.id = row.GetInt(0);
112  aData.clientID = row.GetInt(1);
113  aData.password = (row.IsNull(2) ? "" : row.GetText(2));
114  aData.hash = (row.IsNull(3) ? "" : row.GetText(3));
115  aData.role = row.GetInt64(4);
116  aData.type = row.GetUInt(5);
117  aData.online = row.GetInt(6) ? true : false;
118  aData.banned = row.GetInt(7) ? true : false;
119  aData.visits = row.GetInt(8);
120  aData.last_login = (row.IsNull(9) ? "" : row.GetText(9));
121 
122  return true;
123 }
std::string name
#define sConfig
A macro for easier access to the singleton.
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
std::string hash
static uint32 CreateNewAccount(const char *login, const char *pass, const char *passHash, int64 role)
Definition: ServiceDB.cpp:151
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
uint32 clientID
const char * c_str() const
Definition: dbcore.h:48
std::string password
bool IsNull(uint32 index) const
Definition: dbcore.h:102
unsigned __int32 uint32
Definition: eve-compat.h:50
DBerror error
Definition: dbcore.h:69
static bool GetAccountInformation(CryptoChallengePacket &ccp, AccountData &aData, std::string &failMsg)
Definition: ServiceDB.cpp:70
std::string last_login
int64 GetInt64(uint32 index) const
Definition: dbcore.cpp:670

Here is the call graph for this function:

Here is the caller graph for this function:

bool ServiceDB::GetConstant ( const char *  name,
uint32 into 
)
static

Definition at line 242 of file ServiceDB.cpp.

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

243 {
244  DBQueryResult res;
245 
246  std::string escaped;
247  sDatabase.DoEscapeString(escaped, name);
248 
249  if (!sDatabase.RunQuery(res, "SELECT constantValue FROM eveConstants WHERE constantID='%s'", escaped.c_str() ))
250  {
251  codelog(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
252  return false;
253  }
254 
255  DBResultRow row;
256  if (!res.GetRow(row)) {
257  _log(DATABASE__MESSAGE, "Unable to find constant %s", name);
258  return false;
259  }
260 
261  into = row.GetUInt(0);
262 
263  return true;
264 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
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:

void ServiceDB::GetCorpHangarNames ( uint32  corpID,
std::map< uint8, std::string > &  hangarNames 
)
static

Definition at line 567 of file ServiceDB.cpp.

References _log, codelog, flagCorpHangar2, flagCorpHangar3, flagCorpHangar4, flagCorpHangar5, flagCorpHangar6, flagCorpHangar7, flagHangar, DBQueryResult::GetRow(), DBResultRow::GetText(), IsNPCCorp, and sDatabase.

Referenced by Command_cargo().

567  {
568 
569  std::string table = "crpWalletDivisons";
570  if (IsNPCCorp(corpID))
571  table = "crpNPCWalletDivisons";
572  DBQueryResult res;
573  if (!sDatabase.RunQuery(res,
574  " SELECT division1,division2,division3,division4,division5,division6,division7"
575  " FROM %s"
576  " WHERE corporationID = %u", table.c_str(), corpID))
577  {
578  codelog(CORP__DB_ERROR, "Error in retrieving corporation's data (%u)", corpID);
579  return;
580  }
581 
582  DBResultRow row;
583  if (res.GetRow(row)) {
584  hangarNames.emplace(flagHangar, row.GetText(0));
585  hangarNames.emplace(flagCorpHangar2, row.GetText(1));
586  hangarNames.emplace(flagCorpHangar3, row.GetText(2));
587  hangarNames.emplace(flagCorpHangar4, row.GetText(3));
588  hangarNames.emplace(flagCorpHangar5, row.GetText(4));
589  hangarNames.emplace(flagCorpHangar6, row.GetText(5));
590  hangarNames.emplace(flagCorpHangar7, row.GetText(6));
591  } else {
592  _log(CORP__DB_ERROR, "CorpID %u has no division data.", corpID);
593  }
594 }
#define IsNPCCorp(itemID)
Definition: EVE_Defines.h:238
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
#define _log(type, fmt,...)
Definition: logsys.h:124
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 ServiceDB::GetStationOwner ( uint32  stationID)

Definition at line 226 of file ServiceDB.cpp.

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

227 {
228  DBQueryResult res;
229  if (!sDatabase.RunQuery(res, "SELECT corporationID FROM staStations WHERE stationID = %u", stationID)) {
230  codelog(DATABASE__ERROR, "Failed to query info for station %u: %s.", stationID, res.error.c_str());
231  return false;
232  }
233 
234  DBResultRow row;
235  if (res.GetRow(row)) {
236  return row.GetInt(0);
237  } else {
238  return 1;
239  }
240 }
#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:

bool ServiceDB::IncrementLoginCount ( uint32  accountID)
static

Definition at line 140 of file ServiceDB.cpp.

References sDatabase, and sLog.

Referenced by Client::SelectCharacter().

141 {
142  DBerror err;
143  if (!sDatabase.RunQuery(err, "UPDATE account SET lastLogin=now(), logonCount=logonCount+1 WHERE accountID=%u", accountID)) {
144  sLog.Error( "AccountDB", "Unable to update account information for accountID %u.", accountID);
145  return false;
146  }
147 
148  return true;
149 }
#define sDatabase
Definition: dbcore.h:199
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
Definition: dbcore.h:39

Here is the caller graph for this function:

PyRep * ServiceDB::LookupChars ( const char *  match,
bool  exact = false 
)
static

Definition at line 358 of file ServiceDB.cpp.

References _log, DBerror::c_str(), DBResultToRowset(), DBQueryResult::error, maxNPCItem, and sDatabase.

358  {
359  DBQueryResult res;
360 
361  std::string matchEsc;
362  sDatabase.DoEscapeString(matchEsc, match);
363  if (matchEsc == "__ALL__") {
364  if(!sDatabase.RunQuery(res,
365  "SELECT "
366  " characterID AS ownerID"
367  " FROM chrCharacters"
368  " WHERE characterID > %u", maxNPCItem))
369  {
370  _log(DATABASE__ERROR, "Error in LookupChars query: %s", res.error.c_str());
371  return nullptr;
372  }
373  } else {
374  if(!sDatabase.RunQuery(res,
375  "SELECT "
376  " itemID AS ownerID"
377  " FROM entity"
378  " WHERE itemName %s '%s'",
379  exact?"=":"LIKE", matchEsc.c_str()
380  ))
381  {
382  _log(DATABASE__ERROR, "Error in LookupChars query: %s", res.error.c_str());
383  return nullptr;
384  }
385  }
386 
387  return DBResultToRowset(res);
388 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
#define maxNPCItem
Definition: EVE_Defines.h:139
const char * c_str() const
Definition: dbcore.h:48
PyObject * DBResultToRowset(DBQueryResult &result)
Definition: EVEDBUtils.cpp:81
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

PyRep * ServiceDB::LookupCorporations ( const std::string &  search)
static

Definition at line 445 of file ServiceDB.cpp.

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

445  {
446  DBQueryResult res;
447  std::string secure;
448  sDatabase.DoEscapeString(secure, search);
449 
450  if (!sDatabase.RunQuery(res,
451  "SELECT"
452  " corporationID, corporationName, corporationType "
453  " FROM crpCorporation "
454  " WHERE corporationName LIKE '%s'", secure.c_str()))
455  {
456  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
457  return 0;
458  }
459 
460  return DBResultToRowset(res);
461 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
PyObject * DBResultToRowset(DBQueryResult &result)
Definition: EVEDBUtils.cpp:81
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

PyRep * ServiceDB::LookupCorporationTickers ( const std::string &  search)
static

Definition at line 483 of file ServiceDB.cpp.

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

483  {
484  DBQueryResult res;
485  std::string secure;
486  sDatabase.DoEscapeString(secure, search);
487 
488  if (!sDatabase.RunQuery(res,
489  "SELECT"
490  " corporationID, corporationName, tickerName "
491  " FROM crpCorporation "
492  " WHERE tickerName LIKE '%s'", secure.c_str()))
493  {
494  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
495  return 0;
496  }
497 
498  return DBResultToRowset(res);
499 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
PyObject * DBResultToRowset(DBQueryResult &result)
Definition: EVEDBUtils.cpp:81
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

PyRep * ServiceDB::LookupFactions ( const std::string &  search)
static

Definition at line 464 of file ServiceDB.cpp.

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

464  {
465  DBQueryResult res;
466  std::string secure;
467  sDatabase.DoEscapeString(secure, search);
468 
469  if (!sDatabase.RunQuery(res,
470  "SELECT"
471  " factionID, factionName "
472  " FROM facFactions "
473  " WHERE factionName LIKE '%s'", secure.c_str()))
474  {
475  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
476  return 0;
477  }
478 
479  return DBResultToRowset(res);
480 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
PyObject * DBResultToRowset(DBQueryResult &result)
Definition: EVEDBUtils.cpp:81
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

PyRep * ServiceDB::LookupKnownLocationsByGroup ( const std::string &  search,
uint32  typeID 
)
static

Definition at line 521 of file ServiceDB.cpp.

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

521  {
522  DBQueryResult res;
523  std::string secure;
524  sDatabase.DoEscapeString(secure, search);
525 
526  if (!sDatabase.RunQuery(res,
527  "SELECT"
528  " itemID, itemName, typeID "
529  " FROM entity "
530  " WHERE itemName LIKE '%s' AND typeID = %u", secure.c_str(), typeID))
531  {
532  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
533  return 0;
534  }
535 
536  return DBResultToRowset(res);
537 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
PyObject * DBResultToRowset(DBQueryResult &result)
Definition: EVEDBUtils.cpp:81
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

PyRep * ServiceDB::LookupOwners ( const char *  match,
bool  exact = false 
)
static

Definition at line 391 of file ServiceDB.cpp.

References DBResultToRowset(), and sDatabase.

391  {
392  DBQueryResult res;
393 
394  std::string matchEsc;
395  sDatabase.DoEscapeString(matchEsc, match);
396 
397  // so each row needs "ownerID", "ownerName", and "groupID"
398  // ownerID = itemID
399  // ownerName = name
400  // groupID = 1 for character, 2 for corporation, 32 for alliance
401 
402  sDatabase.RunQuery(res,
403  "SELECT"
404  " characterID AS ownerID,"
405  " characterName AS ownerName,"
406  " 1 AS groupID"
407  " FROM chrCharacters"
408  " WHERE characterName %s '%s'", (exact?"=":"LIKE"), matchEsc.c_str());
409 
410  sDatabase.RunQuery(res,
411  "SELECT"
412  " corporationID AS ownerID,"
413  " corporationName AS ownerName,"
414  " 2 AS groupID"
415  " FROM crpCorporation"
416  " WHERE corporationName %s '%s'", (exact?"=":"LIKE"), matchEsc.c_str());
417 
418  sDatabase.RunQuery(res,
419  "SELECT"
420  " corporationID AS ownerID,"
421  " corporationName AS ownerName,"
422  " 2 AS groupID"
423  " FROM crpCorporation"
424  " WHERE tickerName %s '%s'", (exact?"=":"LIKE"), matchEsc.c_str());
425 
426  sDatabase.RunQuery(res,
427  "SELECT"
428  " allianceID AS ownerID,"
429  " allianceName AS ownerName,"
430  " 32 AS groupID"
431  " FROM alnAlliance"
432  " WHERE allianceName %s '%s'", (exact?"=":"LIKE"), matchEsc.c_str());
433 
434  sDatabase.RunQuery(res,
435  "SELECT"
436  " allianceID AS ownerID,"
437  " shortName AS ownerName,"
438  " 32 AS groupID"
439  " FROM alnAlliance"
440  " WHERE shortName %s '%s'", (exact?"=":"LIKE"), matchEsc.c_str());
441 
442  return DBResultToRowset(res);
443 }
#define sDatabase
Definition: dbcore.h:199
PyObject * DBResultToRowset(DBQueryResult &result)
Definition: EVEDBUtils.cpp:81

Here is the call graph for this function:

PyRep * ServiceDB::LookupStations ( const std::string &  search)
static

Definition at line 502 of file ServiceDB.cpp.

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

502  {
503  DBQueryResult res;
504  std::string secure;
505  sDatabase.DoEscapeString(secure, search);
506 
507  if (!sDatabase.RunQuery(res,
508  "SELECT"
509  " stationID, stationName, stationTypeID "
510  " FROM staStations "
511  " WHERE stationName LIKE '%s'", secure.c_str()))
512  {
513  _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
514  return 0;
515  }
516 
517  return DBResultToRowset(res);
518 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
PyObject * DBResultToRowset(DBQueryResult &result)
Definition: EVEDBUtils.cpp:81
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

PyRep * ServiceDB::PrimeOwners ( std::vector< int32 > &  itemIDs)
static
Todo:
look into this...may be wrong

Definition at line 540 of file ServiceDB.cpp.

References PyList::AddItem(), DBResultRow::GetInt(), DBQueryResult::GetRow(), DBResultRow::GetText(), IsAlliance, IsCharacterID, IsPlayerCorp, sDatabase, and PyDict::SetItem().

541 {
542  DBQueryResult res;
543  DBResultRow row;
544  PyDict* dict = new PyDict();
545  for (auto cur : itemIDs) {
546  if (IsCharacterID(cur)) {
547  sDatabase.RunQuery(res, "SELECT characterID, characterName, typeID FROM chrCharacters WHERE characterID = %u", cur);
548  } else if (IsPlayerCorp(cur)) {
549  sDatabase.RunQuery(res, "SELECT corporationID, corporationName, typeID FROM crpCorporation WHERE corporationID = %u", cur);
550  } else if (IsAlliance(cur)) {
551  sDatabase.RunQuery(res, "SELECT allianceID, allianceName, typeID FROM alnAlliance WHERE allianceID = %u", cur);
552  } else {
553  ; // make error
554  }
555  if (res.GetRow(row)) {
556  PyList* list = new PyList();
557  list->AddItem(new PyInt(row.GetInt(0)));
558  list->AddItem(new PyString(row.GetText(1)));
559  list->AddItem(new PyInt(row.GetInt(2)));
560  dict->SetItem(new PyInt(row.GetInt(0)), list);
561  }
562  }
563 
564  return dict;
565 }
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
Python string.
Definition: PyRep.h:430
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
Python's dictionary.
Definition: PyRep.h:719
void AddItem(PyRep *i)
Definition: PyRep.h:701
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
Python integer.
Definition: PyRep.h:231
#define IsPlayerCorp(itemID)
Definition: EVE_Defines.h:241
#define IsCharacterID(itemID)
Definition: EVE_Defines.h:206
#define IsAlliance(itemID)
Definition: EVE_Defines.h:244
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713
Python list.
Definition: PyRep.h:639

Here is the call graph for this function:

void ServiceDB::ProcessIntChange ( const char *  key,
uint32  oldValue,
uint32  newValue,
PyDict notif,
std::vector< std::string > &  dbQ 
)
protected

Definition at line 304 of file ServiceDB.cpp.

References PyTuple::items, and PyDict::SetItemString().

Referenced by CorporationDB::UpdateLogo().

305 {
306  if (oldValue == newValue)
307  return;
308  // add to notification
309  PyTuple* val = new PyTuple(2);
310  val->items[0] = new PyInt(oldValue);
311  val->items[1] = new PyInt(newValue);
312  notif->SetItemString(key, val);
313 
314  std::string qValue(key);
315  qValue += " = ";
316  qValue += std::to_string(newValue);
317  dbQ.push_back(qValue);
318 }
Python tuple.
Definition: PyRep.h:567
Python integer.
Definition: PyRep.h:231
storage_type items
Definition: PyRep.h:628
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 SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
Definition: PyRep.h:812

Here is the call graph for this function:

Here is the caller graph for this function:

void ServiceDB::ProcessLongChange ( const char *  key,
int64  oldValue,
int64  newValue,
PyDict notif,
std::vector< std::string > &  dbQ 
)
protected

Definition at line 320 of file ServiceDB.cpp.

References PyTuple::items, and PyDict::SetItemString().

Referenced by CorporationDB::UpdateTitle().

321 {
322  if (oldValue == newValue)
323  return;
324  // add to notification
325  PyTuple* val = new PyTuple(2);
326  val->items[0] = new PyLong(oldValue);
327  val->items[1] = new PyLong(newValue);
328  notif->SetItemString(key, val);
329 
330  std::string qValue(key);
331  qValue += " = ";
332  qValue += std::to_string(newValue);
333  dbQ.push_back(qValue);
334 }
Python tuple.
Definition: PyRep.h:567
storage_type items
Definition: PyRep.h:628
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 SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
Definition: PyRep.h:812
Python long integer.
Definition: PyRep.h:261

Here is the call graph for this function:

Here is the caller graph for this function:

void ServiceDB::ProcessRealChange ( const char *  key,
double  oldValue,
double  newValue,
PyDict notif,
std::vector< std::string > &  dbQ 
)
protected

Definition at line 287 of file ServiceDB.cpp.

References PyTuple::items, and PyDict::SetItemString().

Referenced by CorporationDB::UpdateCorporation().

288 {
289  if (oldValue == newValue)
290  return;
291  // add to notification
292  PyTuple* val = new PyTuple(2);
293  val->items[0] = new PyFloat(oldValue);
294  val->items[1] = new PyFloat(newValue);
295  notif->SetItemString(key, val);
296 
297  int* nullInt(nullptr);
298  std::string qValue(key);
299  qValue += " = ";
300  qValue += fcvt(newValue, 2, nullInt, nullInt);
301  dbQ.push_back(qValue);
302 }
Python floating point number.
Definition: PyRep.h:292
Python tuple.
Definition: PyRep.h:567
storage_type items
Definition: PyRep.h:628
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 SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
Definition: PyRep.h:812

Here is the call graph for this function:

Here is the caller graph for this function:

void ServiceDB::ProcessStringChange ( const char *  key,
const std::string &  oldValue,
std::string  newValue,
PyDict notif,
std::vector< std::string > &  dbQ 
)
protected

Definition at line 266 of file ServiceDB.cpp.

References PyTuple::items, key(), sDatabase, and PyDict::SetItemString().

Referenced by CorporationDB::UpdateCorporation(), CorporationDB::UpdateDivisionNames(), and CorporationDB::UpdateTitle().

267 {
268  if (oldValue.compare(newValue) == 0)
269  return;
270  // add to notification
271  PyTuple* val = new PyTuple(2);
272  val->items[0] = new PyString(oldValue);
273  val->items[1] = new PyString(newValue);
274  notif->SetItemString(key, val);
275 
276  std::string newEscValue;
277  sDatabase.DoEscapeString(newEscValue, newValue);
278 
279  std::string qValue = " ";
280  qValue += key;
281  qValue += " = '";
282  qValue += newEscValue.c_str();
283  qValue += "' ";
284  dbQ.push_back(qValue);
285 }
#define sDatabase
Definition: dbcore.h:199
Python string.
Definition: PyRep.h:430
Python tuple.
Definition: PyRep.h:567
storage_type items
Definition: PyRep.h:628
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 SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
Definition: PyRep.h:812

Here is the call graph for this function:

Here is the caller graph for this function:

void ServiceDB::SaveKillOrLoss ( CharKillData data)
static

Definition at line 212 of file ServiceDB.cpp.

References CharKillData::finalAllianceID, CharKillData::finalCharacterID, CharKillData::finalCorporationID, CharKillData::finalDamageDone, CharKillData::finalFactionID, CharKillData::finalSecurityStatus, CharKillData::finalShipTypeID, CharKillData::finalWeaponTypeID, CharKillData::killBlob, CharKillData::killTime, CharKillData::moonID, sDatabase, CharKillData::solarSystemID, CharKillData::victimAllianceID, CharKillData::victimCharacterID, CharKillData::victimCorporationID, CharKillData::victimDamageTaken, CharKillData::victimFactionID, and CharKillData::victimShipTypeID.

Referenced by CustomsSE::Killed(), StructureSE::Killed(), and Character::LogKill().

212  {
213  DBerror err;
214  sDatabase.RunQuery(err,
215  " INSERT INTO chrKillTable (solarSystemID, victimCharacterID, victimCorporationID, victimAllianceID, victimFactionID,"
216  "victimShipTypeID, victimDamageTaken, finalCharacterID, finalCorporationID, finalAllianceID, finalFactionID, finalShipTypeID,"
217  "finalWeaponTypeID, finalSecurityStatus, finalDamageDone, killBlob, killTime, moonID)"
218  " VALUES (%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%f,%u,'%s',%li,%u)",
223  data.killBlob.c_str(), data.killTime, data.moonID);
224 }
uint32 finalDamageDone
#define sDatabase
Definition: dbcore.h:199
uint32 finalCorporationID
uint32 victimDamageTaken
uint32 finalCharacterID
int32 victimFactionID
uint32 solarSystemID
uint32 victimCorporationID
uint16 finalShipTypeID
uint32 victimCharacterID
int32 finalFactionID
double finalSecurityStatus
uint16 finalWeaponTypeID
uint16 victimShipTypeID
int32 finalAllianceID
int32 victimAllianceID
std::string killBlob
Definition: dbcore.h:39

Here is the caller graph for this function:

void ServiceDB::SaveServerStats ( double  threads,
float  rss,
float  vm,
float  user,
float  kernel,
uint32  items,
uint32  bubbles 
)
static

Definition at line 336 of file ServiceDB.cpp.

References _log, sDatabase, and sEntityList.

Referenced by ConsoleCommand::UpdateStatus().

336  {
337  DBerror err;
338  sDatabase.RunQuery(err,
339  "UPDATE srvStatus"
340  " SET threads = %f,"
341  " rss = %f,"
342  " vm = %f,"
343  " user = %f,"
344  " kernel = %f,"
345  " items = %u,"
346  " bubbles = %u,"
347  " systems = %u,"
348  " npcs = %u,"
349  //" Connections = %u,"
350  " updateTime = UNIX_TIMESTAMP(CURRENT_TIMESTAMP)"
351  " WHERE AI = 1",
352  threads, rss, vm, user, kernel, items, bubbles, sEntityList.GetSystemCount(), sEntityList.GetNPCCount()/*, sEntityList.GetConnections()*/);
353 
354  _log(DATABASE__INFO, "Server Stats Saved");
355 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
#define sEntityList
Definition: EntityList.h:208
entityID heal the character with the entityID note giving you detailed ship status information gives a list of all dynamic entities and players and their destinyState in this bubble shows some current destiny variables save all items
Definition: dbcore.h:39

Here is the caller graph for this function:

void ServiceDB::SetAccountBanStatus ( uint32  accountID,
bool  banned = false 
)
static

Definition at line 205 of file ServiceDB.cpp.

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

Referenced by Client::BanClient(), and Command_unban().

205  {
206  DBerror err;
207  if (!sDatabase.RunQuery(err, "UPDATE account SET banned = %u WHERE accountID = %u", (banned?1:0), accountID)) {
208  codelog(DATABASE__ERROR, "Error in query: %s", err.c_str());
209  }
210 }
#define sDatabase
Definition: dbcore.h:199
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

void ServiceDB::SetAccountOnlineStatus ( uint32  accountID,
bool  online = false 
)
static

Definition at line 198 of file ServiceDB.cpp.

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

Referenced by Client::SelectCharacter(), and Client::~Client().

198  {
199  DBerror err;
200  if (!sDatabase.RunQuery(err, "UPDATE account SET online = %u WHERE accountID= %u ", (online?1:0), accountID)) {
201  codelog(DATABASE__ERROR, "Error in query: %s", err.c_str());
202  }
203 }
#define sDatabase
Definition: dbcore.h:199
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

void ServiceDB::SetCharacterOnlineStatus ( uint32  char_id,
bool  online = false 
)
static

Definition at line 177 of file ServiceDB.cpp.

References _log, and sDatabase.

Referenced by Client::SelectCharacter(), and Client::~Client().

177  {
178  _log(CLIENT__TRACE, "ServiceDB: Setting character %u %s.", char_id, online ? "Online" : "Offline");
179  DBerror err;
180  sDatabase.RunQuery(err, "UPDATE chrCharacters SET online = %u WHERE characterID = %u", (online?1:0), char_id);
181 
182  if ( online )
183  sDatabase.RunQuery(err, "UPDATE srvStatus SET Connections = Connections + 1");
184 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
Definition: dbcore.h:39

Here is the caller graph for this function:

uint32 ServiceDB::SetClientSeed ( )
static

Definition at line 34 of file ServiceDB.cpp.

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

Referenced by EntityList::Initialize().

35 {
36  DBQueryResult res;
37  sDatabase.RunQuery(res, "SELECT ClientSeed FROM srvStatus WHERE AI = 1");
38  DBResultRow row;
39  res.GetRow(row);
40  return row.GetInt(0);
41 }
#define sDatabase
Definition: dbcore.h:199
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552

Here is the call graph for this function:

Here is the caller graph for this function:

void ServiceDB::SetServerOnlineStatus ( bool  online = false)
static

Definition at line 186 of file ServiceDB.cpp.

References sDatabase.

Referenced by CleanUp(), and main().

186  {
187  DBerror err;
188  sDatabase.RunQuery(err,
189  "UPDATE srvStatus SET Online = %u, Connections = 0, startTime = %s WHERE AI = 1",
190  (online ? 1 : 0), (online ? "UNIX_TIMESTAMP(CURRENT_TIMESTAMP)" : "0"));
191 
192  //this is only called on startup/shutdown. reset all char online counts/status'
193  sDatabase.RunQuery(err, "UPDATE chrCharacters SET online = 0 WHERE 1");
194  sDatabase.RunQuery(err, "UPDATE account SET online = 0 WHERE 1");
195  sDatabase.RunQuery( err, "DELETE FROM chrPausedSkillQueue WHERE 1");
196 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39

Here is the caller graph for this function:

bool ServiceDB::UpdateAccountHash ( const char *  username,
std::string &  hash 
)
static

Definition at line 125 of file ServiceDB.cpp.

References DBerror::c_str(), sDatabase, and sLog.

126 {
127  std::string eLogin, eHash;
128  sDatabase.DoEscapeString(eLogin, username);
129  sDatabase.DoEscapeString(eHash, hash);
130 
131  DBerror err;
132  if (!sDatabase.RunQuery(err, "UPDATE account SET hash='%s' WHERE accountName='%s'", eHash.c_str(), eLogin.c_str())) {
133  sLog.Error( "AccountDB", "Unable to update account information for: %s.", username );
134  return false;
135  }
136 
137  return true;
138 }
#define sDatabase
Definition: dbcore.h:199
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
const char * c_str() const
Definition: dbcore.h:48
Definition: dbcore.h:39

Here is the call graph for this function:

void ServiceDB::UpdatePassword ( uint32  accountID,
const char *  pass 
)
static

Definition at line 170 of file ServiceDB.cpp.

References sDatabase.

Referenced by Client::_VerifyLogin().

171 {
172  DBerror err;
173  sDatabase.RunQuery(err, "UPDATE account SET password = '%s' WHERE accountID=%u", pass, accountID);
174 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39

Here is the caller graph for this function:

bool ServiceDB::ValidateAccountName ( CryptoChallengePacket &  ccp,
std::string &  failMsg 
)
static

Definition at line 43 of file ServiceDB.cpp.

References badChars, and EvE::icontains().

Referenced by Client::_VerifyLogin().

44 {
45 
46  if (ccp.user_name.empty()) {
47  failMsg = "Account Name is empty.";
48  return false;
49  }
50  if (ccp.user_name.length() < 3) {
51  failMsg = "Account Name is too short.";
52  return false;
53  }
54  //if (name.length() < 4)
55  // throw UserError ("CharNameInvalidMinLength");
56  if (ccp.user_name.length() > 20) { //client caps at 24
57  failMsg = "Account Name is too long.";
58  return false;
59  }
60 
61  for (const auto cur : badChars)
62  if (EvE::icontains(ccp.user_name, cur)) {
63  failMsg = "Account Name contains invalid characters.";
64  return false;
65  }
66 
67  return true;
68 }
static const std::array< std::string, 18 > badChars
Definition: EVE_Consts.h:87
bool icontains(std::string data, std::string toSearch, size_t pos=0)
Definition: misc.cpp:194

Here is the call graph for this function:

Here is the caller graph for this function:


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