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

#include "StationDB.h"

Inheritance diagram for StationDB:
Collaboration diagram for StationDB:

StationDB.cpp

database methods for station data

Author
Allan
Date
14 December 2017
void UpdateOfficeData (OfficeData &data)
 
static PyRepGetOffices (uint32 stationID)
 
static PyRepGetStationOfficeIDs (uint32 locationID, uint32 corpID, const char *key)
 
static uint32 CreateOffice (ItemData &idata, OfficeData &odata)
 
static bool GetOfficeData (uint32 officeID, OfficeData &odata)
 
static void GetStationData (DBQueryResult &res)
 
static void GetStationSystem (DBQueryResult &res)
 
static void GetStationRegion (DBQueryResult &res)
 
static void GetStationOfficeData (DBQueryResult &res)
 
static void GetOperationServiceIDs (DBQueryResult &res)
 
static void GetStationConstellation (DBQueryResult &res)
 
static int32 GetOfficeCount (uint32 corpID)
 
static void LoadOffices (OwnerData &od, std::vector< uint32 > &into)
 

Additional Inherited Members

- Public Member Functions inherited from ServiceDB
uint32 GetStationOwner (uint32 stationID)
 
- 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 18 of file StationDB.h.

Member Function Documentation

uint32 StationDB::CreateOffice ( ItemData idata,
OfficeData odata 
)
static

Definition at line 17 of file StationDB.cpp.

References DBerror::c_str(), codelog, OfficeData::corporationID, OfficeData::expiryTime, ItemData::flag, OfficeData::folderID, OfficeData::lockDown, OfficeData::name, OfficeData::officeID, OfficeData::rentalFee, sDatabase, OfficeData::stationID, stDataMgr, and OfficeData::typeID.

Referenced by StationOffice::Spawn().

18 {
19  uint32 uid = 0;
20  DBerror err;
21  if (!sDatabase.RunQueryLID(err, uid,
22  "INSERT INTO staOffices (name, corporationID, stationID, officeFolderID, flag, solarSystemID, typeID, stationTypeID, lockDown, rentalFee, expiryDateTime)"
23  " VALUES"
24  " ('%s',%u,%u,%u,%u,%u, 27, %u,%u,%u,%li)",
25  odata.name.c_str(), odata.corporationID, odata.stationID, odata.folderID, idata.flag, stDataMgr.GetStationSystemID(odata.stationID), odata.typeID, odata.lockDown, odata.rentalFee, odata.expiryTime)
26  )
27  codelog(DATABASE__ERROR, "Error in CreateOffice query: %s", err.c_str());
28 
29  return (odata.officeID = uid);
30 }
#define sDatabase
Definition: dbcore.h:199
#define stDataMgr
uint32 folderID
uint32 stationID
int64 expiryTime
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
uint32 officeID
std::string name
uint32 corporationID
unsigned __int32 uint32
Definition: eve-compat.h:50
EVEItemFlags flag
Definition: ItemType.h:187
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

int32 StationDB::GetOfficeCount ( uint32  corpID)
static

Definition at line 38 of file StationDB.cpp.

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

39 {
40  DBQueryResult res;
41  if (!sDatabase.RunQuery(res, "SELECT COUNT(itemID) FROM staOffices WHERE corporationID = %u ", corpID)) {
42  codelog(CORP__DB_ERROR, "Error in query: %s", res.error.c_str());
43  return 0;
44  }
45 
46  DBResultRow row;
47  if (!res.GetRow(row)) {
48  codelog(CORP__DB_WARNING, "Unable to find corporation's office data (%u)", corpID);
49  return 0;
50  }
51  return row.GetInt(0);
52 }
#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 StationDB::GetOfficeData ( uint32  officeID,
OfficeData odata 
)
static

Definition at line 68 of file StationDB.cpp.

References DBerror::c_str(), codelog, OfficeData::corporationID, DBQueryResult::error, OfficeData::expiryTime, OfficeData::folderID, DBResultRow::GetBool(), DBResultRow::GetInt(), DBResultRow::GetInt64(), DBQueryResult::GetRow(), OfficeData::lockDown, OfficeData::officeID, OfficeData::rentalFee, sDatabase, OfficeData::stationID, and OfficeData::typeID.

Referenced by StationOffice::_LoadItem().

69 {
70  DBQueryResult res;
71  if (!sDatabase.RunQuery(res,
72  "SELECT"
73  " corporationID, stationID, typeID, lockDown, rentalFee, expiryDateTime, officeFolderID"
74  " FROM staOffices"
75  " WHERE itemID = %u", officeID)
76  ) {
77  codelog(DATABASE__ERROR, "Error in GetOfficeData query: %s", res.error.c_str());
78  return false;
79  }
80 
81  DBResultRow row;
82  if (!res.GetRow(row))
83  return false;
84 
85  odata.officeID = officeID;
86  odata.corporationID = row.GetInt(0);
87  odata.stationID = row.GetInt(1);
88  odata.typeID = row.GetInt(2);
89  odata.lockDown = row.GetBool(3);
90  odata.rentalFee = row.GetInt64(4);
91  odata.expiryTime = row.GetInt64(5);
92  odata.folderID = row.GetInt(6);
93  return true;
94 }
#define sDatabase
Definition: dbcore.h:199
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
uint32 folderID
uint32 stationID
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
bool GetBool(uint32 index) const
Definition: dbcore.cpp:647
int64 expiryTime
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
uint32 officeID
uint32 corporationID
DBerror error
Definition: dbcore.h:69
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:

PyRep * StationDB::GetOffices ( uint32  stationID)
static

Definition at line 54 of file StationDB.cpp.

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

Referenced by StationItem::_Load(), and StationItem::RentOffice().

55 {
56  DBQueryResult res;
57  if (!sDatabase.RunQuery(res,
58  "SELECT"
59  " corporationID, itemID, officeFolderID"
60  " FROM staOffices"
61  " WHERE stationID = %u", stationID)
62  )
63  codelog(DATABASE__ERROR, "Error in GetOffices query: %s", res.error.c_str());
64 
65  return DBResultToCRowset(res);
66 }
#define sDatabase
Definition: dbcore.h:199
PyObjectEx * DBResultToCRowset(DBQueryResult &result)
Definition: EVEDBUtils.cpp:402
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 StationDB::GetOperationServiceIDs ( DBQueryResult res)
static

Definition at line 175 of file StationDB.cpp.

References sDatabase.

Referenced by StationDataMgr::Populate().

176 {
177  sDatabase.RunQuery(res, "SELECT operationID, serviceID FROM staOperationServices");
178 }
#define sDatabase
Definition: dbcore.h:199

Here is the caller graph for this function:

void StationDB::GetStationConstellation ( DBQueryResult res)
static

Definition at line 169 of file StationDB.cpp.

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

Referenced by StaticDataMgr::Populate().

170 {
171  if (!sDatabase.RunQuery(res, "SELECT stationID, constellationID FROM staStations"))
172  codelog(DATABASE__ERROR, "Error in GetStationConstellation query: %s", res.error.c_str());
173 }
#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 StationDB::GetStationData ( DBQueryResult res)
static

Definition at line 138 of file StationDB.cpp.

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

Referenced by StationDataMgr::Populate().

139 {
140  if (!sDatabase.RunQuery(res,
141  "SELECT"
142  " s.stationID, s.x, s.y, s.z, st.dockOrientationX, st.dockOrientationY, st.dockOrientationZ,"
143  " s.dockingCostPerVolume, s.maxShipVolumeDockable, s.officeSlots, s.officeRentalCost,"
144  " s.operationID, s.stationTypeID, s.corporationID, s.stationName,"
145  " s.reprocessingStationsTake, s.reprocessingEfficiency, s.reprocessingHangarFlag, st.conquerable, st.hangarGraphicID,"
146  " m.orbitID, m.radius, m.security, o.description, o.descriptionID, t.graphicID, s.solarSystemID, s.constellationID, s.regionID,"
147  " st.dockEntryX, st.dockEntryY, st.dockEntryZ"
148  " FROM staStations AS s"
149  " LEFT JOIN staStationTypes AS st USING (stationTypeID)"
150  " LEFT JOIN invTypes AS t ON t.typeID = s.stationTypeID"
151  " LEFT JOIN staOperations AS o ON o.operationID = s.operationID"
152  " LEFT JOIN mapDenormalize AS m ON m.itemID = s.stationID")
153  )
154  codelog(DATABASE__ERROR, "Error in GetStationData query: %s", res.error.c_str());
155 }
#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 StationDB::GetStationOfficeData ( DBQueryResult res)
static

Definition at line 97 of file StationDB.cpp.

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

Referenced by StationDataMgr::Populate().

98 {
99  if (!sDatabase.RunQuery(res,
100  "SELECT"
101  " itemID, corporationID, stationID, typeID, lockDown, rentalFee, expiryDateTime, officeFolderID"
102  " FROM staOffices")
103  )
104  codelog(DATABASE__ERROR, "Error in GetStationOfficeData query: %s", res.error.c_str());
105 }
#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:

PyRep * StationDB::GetStationOfficeIDs ( uint32  locationID,
uint32  corpID,
const char *  key 
)
static

Definition at line 107 of file StationDB.cpp.

References _log, DBRowToRow(), DBQueryResult::GetRow(), IsOfficeFolder, IsOfficeID, sDatabase, sDataMgr, and STATION_OFFICE_OFFSET.

108 {
109  DBQueryResult res;
110  if (sDataMgr.IsStation(locationID)) {
111  sDatabase.RunQuery(res, "SELECT itemID AS officeID, stationID, officeFolderID"
112  " FROM staOffices WHERE stationID = %u", locationID);
113  } else if (IsOfficeFolder(locationID)) {
114  sDatabase.RunQuery(res, "SELECT itemID AS officeID, stationID, officeFolderID"
115  " FROM staOffices WHERE officeFolderID = %u",
116  locationID - STATION_OFFICE_OFFSET);
117  } else if (IsOfficeID(locationID)) {
118  sDatabase.RunQuery(res, "SELECT itemID AS officeID, stationID, officeFolderID"
119  " FROM staOffices WHERE itemID = %u", locationID);
120  } else {
121  _log(CORP__DB_ERROR, "StationDB::GetStationOfficeIDs got invalid locationID %u", locationID);
122  }
123 
124  DBResultRow row;
125  if (res.GetRow(row))
126  return DBRowToRow(row);
127 
128  return nullptr;
129 
130  //return DBResultToCIndexedRowset(res, key);
131  //return DBResultToIndexRowset(res, key);
132  //return DBResultToCRowset(res);
133  //return DBResultToRowList(res);
134  //return DBResultToRowset(res);
135  //return DBResultToPackedRowDict(res, key);
136 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
#define IsOfficeFolder(itemID)
Definition: EVE_Defines.h:309
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
PyObject * DBRowToRow(DBResultRow &row, const char *type)
Definition: EVEDBUtils.cpp:208
#define IsOfficeID(itemID)
Definition: EVE_Defines.h:253
#define STATION_OFFICE_OFFSET
Definition: EVE_Defines.h:177
#define sDataMgr

Here is the call graph for this function:

void StationDB::GetStationRegion ( DBQueryResult res)
static

Definition at line 163 of file StationDB.cpp.

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

Referenced by StaticDataMgr::Populate().

164 {
165  if (!sDatabase.RunQuery(res, "SELECT stationID, regionID FROM staStations"))
166  codelog(DATABASE__ERROR, "Error in GetStationRegion query: %s", res.error.c_str());
167 }
#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 StationDB::GetStationSystem ( DBQueryResult res)
static

Definition at line 157 of file StationDB.cpp.

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

Referenced by StaticDataMgr::Populate().

158 {
159  if (!sDatabase.RunQuery(res, "SELECT stationID, solarSystemID FROM staStations"))
160  codelog(DATABASE__ERROR, "Error in GetStationSystem query: %s", res.error.c_str());
161 }
#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 StationDB::LoadOffices ( OwnerData od,
std::vector< uint32 > &  into 
)
static

Definition at line 180 of file StationDB.cpp.

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

Referenced by Inventory::LoadContents().

181 {
182  DBQueryResult res;
183  if (!sDatabase.RunQuery(res, "SELECT itemID FROM staOffices WHERE stationID = %u", od.locID)) {
184  codelog(DATABASE__ERROR, "Error in LoadOffices query: %s", res.error.c_str());
185  return;
186  }
187 
188  DBResultRow row;
189  while (res.GetRow(row))
190  into.push_back(row.GetInt(0));
191 }
uint32 locID
#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:

void StationDB::UpdateOfficeData ( OfficeData data)

Definition at line 32 of file StationDB.cpp.

References OfficeData::expiryTime, OfficeData::lockDown, OfficeData::rentalFee, and sDatabase.

33 {
34  DBerror err;
35  sDatabase.RunQuery(err, "UPDATE staOffices SET lockDown = %u, rentalFee = %u, expiryDateTime = %li)", data.lockDown, data.rentalFee, data.expiryTime);
36 }
#define sDatabase
Definition: dbcore.h:199
int64 expiryTime
Definition: dbcore.h:39

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