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

#include "PlanetDB.h"

Public Member Functions

PyRepGetPlanetsForChar (uint32 charID)
 
PyRepGetMyLaunchesDetails (uint32 charID)
 
void GetPlanetData (DBQueryResult &res)
 
void GetSchematicData (DBQueryResult &res)
 
void GetSchematicTimes (DBQueryResult &res)
 
void UpdatePins (uint32 pinID, PI_CCPin *ccPin)
 
void UpdateECUPin (uint32 pinID, PI_CCPin *ccPin)
 
void SavePins (PI_CCPin *ccPin)
 
void SaveHeads (uint32 ccPinID, uint32 ownerID, uint32 ecuID, std::map< uint16, PI_Heads > &heads)
 
void SaveLinks (PI_CCPin *ccPin)
 
void SaveRoutes (PI_CCPin *ccPin)
 
void SaveContents (PI_CCPin *ccPin)
 
void SavePinContents (uint32 ccPinID, uint32 pinID, std::map< uint16, uint32 > &contents)
 
void RemovePin (uint32 pinID)
 
void RemoveHead (uint32 ecuID, uint32 headID)
 
void RemoveLink (uint32 linkID)
 
void RemoveRoute (uint16 routeID)
 
void RemoveContents (uint32 pinID)
 
void DeleteColony (uint32 ccPinID, uint32 planetID, uint32 charID)
 
void LoadPins (uint32 ccPinID, std::map< uint32, PI_Pin > &pins)
 
void LoadHeads (uint32 ecuID, std::map< uint16, PI_Heads > &heads)
 
void LoadLinks (uint32 ccPinID, std::map< uint32, PI_Link > &links)
 
void LoadRoutes (uint32 ccPinID, std::map< uint16, PI_Route > &routes)
 
void LoadContents (uint32 pinID, std::map< uint16, uint32 > &contents)
 
void SaveCCLevel (uint32 pinID, uint8 level)
 
void SavePinLevel (uint32 pinID, uint8 level)
 
void SaveLinkLevel (uint32 linkID, uint8 level)
 
void SaveCommandCenter (uint32 pinID, uint32 charID, uint32 planetID, uint32 typeID, double latitude, double longitude)
 
void SaveLaunch (uint32 contID, uint32 charID, uint32 systemID, uint32 planetID, GPoint &pos)
 
void UpdatePinTimes (PI_CCPin *ccPin)
 
void AddPlanetForChar (uint32 solarSystemID, uint32 planetID, uint32 charID, uint32 ccPinID, uint16 typeID)
 
void UpdatePlanetPins (uint32 ccPinID, uint8 pins=1)
 
bool LoadColony (uint32 charID, uint32 planetID, PI_CCPin *ccPin)
 
uint16 SaveRoute (uint32 ccPinID, PI_Route &route)
 

Static Public Member Functions

static void GetLaunchDetails (Launch::Data &data)
 
static GPoint GetLaunchPos (uint32 launchID)
 
static uint32 GetLaunchItemID (uint32 launchID)
 
static uint32 GetLaunchPlanet (uint32 launchID)
 
static void UpdateLaunchStatus (uint32 itemID, uint8 status)
 
static void GetExtractorsForPlanet (uint32 planetID, DBQueryResult &res)
 
static void DeleteLaunch (uint32 contID)
 

Detailed Description

Definition at line 36 of file PlanetDB.h.

Member Function Documentation

void PlanetDB::AddPlanetForChar ( uint32  solarSystemID,
uint32  planetID,
uint32  charID,
uint32  ccPinID,
uint16  typeID 
)

Definition at line 90 of file PlanetDB.cpp.

References _log, DBerror::GetError(), and sDatabase.

Referenced by Colony::CreateCommandPin().

91 {
92  DBerror err;
93  if(!sDatabase.RunQuery(err,
94  "INSERT INTO piPlanets (solarSystemID, planetID, charID, typeID, ccPinID)"
95  " VALUES (%u, %u, %u, %u, %u)", solarSystemID, planetID, charID, typeID, ccPinID))
96  {
97  _log(DATABASE__ERROR, "AddPlanetForChar - Unable to add planet %u for char %u: %s", planetID, charID, err.GetError());
98  }
99 
100 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * GetError() const
Definition: dbcore.h:46
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::DeleteColony ( uint32  ccPinID,
uint32  planetID,
uint32  charID 
)
Todo:
remove items from entity* table...

Definition at line 831 of file PlanetDB.cpp.

References sDatabase.

Referenced by Colony::AbandonColony().

832 {
834  DBerror err;
835  sDatabase.RunQuery(err, "DELETE FROM entity WHERE locationID = %u AND ownerID = %u", planetID, charID);
836  sDatabase.RunQuery(err, "DELETE FROM piCCPin WHERE pinID = %u", ccPinID);
837  sDatabase.RunQuery(err, "DELETE FROM piPins WHERE ccPinID = %u", ccPinID);
838  sDatabase.RunQuery(err, "DELETE FROM piLinks WHERE ccPinID = %u", ccPinID);
839  sDatabase.RunQuery(err, "DELETE FROM piRoutes WHERE ccPinID = %u", ccPinID);
840  sDatabase.RunQuery(err, "DELETE FROM piPlanets WHERE ccPinID = %u", ccPinID);
841  sDatabase.RunQuery(err, "DELETE FROM piECUHeads WHERE ccPinID = %u", ccPinID);
842  sDatabase.RunQuery(err, "DELETE FROM piPinContents WHERE ccPinID = %u", ccPinID);
843 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39

Here is the caller graph for this function:

void PlanetDB::DeleteLaunch ( uint32  contID)
static

Definition at line 825 of file PlanetDB.cpp.

References sDatabase.

Referenced by CargoContainer::Delete().

826 {
827  DBerror err;
828  sDatabase.RunQuery(err, "DELETE FROM piLaunches WHERE itemID = %u", contID);
829 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39

Here is the caller graph for this function:

void PlanetDB::GetExtractorsForPlanet ( uint32  planetID,
DBQueryResult res 
)
static

Definition at line 194 of file PlanetDB.cpp.

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

Referenced by PlanetSE::GetExtractorsForPlanet().

195 {
196  //SELECT ccPinID, ownerID, ecuID, headID, typeID, latitude, longitude FROM piECUHeads WHERE 1
197  if (!sDatabase.RunQuery(res,
198  "SELECT headID, typeID, ownerID, latitude, longitude"
199  " FROM piECUHeads"
200  " WHERE ccPinID IN"
201  " (SELECT pinID FROM piCCPin"
202  " WHERE planetID = %u)",
203  planetID))
204  {
205  _log(DATABASE__ERROR, "Error in LoadPins Query: %s", res.error.c_str());
206  return;
207  }
208 
209  _log(DATABASE__RESULTS, "GetExtractorsForPlanet returned %u items", res.GetRowCount());
210 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69
size_t GetRowCount()
Definition: dbcore.h:72

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::GetLaunchDetails ( Launch::Data data)
static

Definition at line 151 of file PlanetDB.cpp.

References _log, DBerror::c_str(), DBQueryResult::error, DBResultRow::GetDouble(), DBResultRow::GetInt(), DBResultRow::GetInt64(), DBQueryResult::GetRow(), Launch::Data::itemID, Launch::Data::launchID, Launch::Data::launchTime, Launch::Data::planetID, sDatabase, Launch::Data::solarSystemID, Launch::Data::status, Launch::Data::x, Launch::Data::y, and Launch::Data::z.

152 {
153  DBQueryResult res;
154  if(!sDatabase.RunQuery(res, "SELECT itemID, status, solarSystemID, planetID, launchTime, x, y, z FROM piLaunches WHERE launchID = %u", data.launchID)) {
155  _log(DATABASE__ERROR, "Error in GetLaunchDetails query: %s", res.error.c_str());
156  }
157  DBResultRow row;
158  if (!res.GetRow(row)) {
159  _log(DATABASE__ERROR, "Error in GetLaunchDetails query: %s", res.error.c_str());
160  return;
161  }
162 
163  data.itemID = row.GetInt(0);
164  data.status = row.GetInt(1);
165  data.solarSystemID = row.GetInt(2);
166  data.planetID = row.GetInt(3);
167  data.launchTime = row.GetInt64(4);
168  data.x = row.GetDouble(5);
169  data.y = row.GetDouble(6);
170  data.z = row.GetDouble(7);
171 }
double z
Definition: EVE_Planet.h:93
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
uint32 itemID
Definition: EVE_Planet.h:87
int64 launchTime
Definition: EVE_Planet.h:90
double GetDouble(uint32 index) const
Definition: dbcore.cpp:693
uint8 status
Definition: EVE_Planet.h:85
uint32 solarSystemID
Definition: EVE_Planet.h:88
double x
Definition: EVE_Planet.h:91
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
uint32 planetID
Definition: EVE_Planet.h:89
uint32 launchID
Definition: EVE_Planet.h:86
const char * c_str() const
Definition: dbcore.h:48
double y
Definition: EVE_Planet.h:92
DBerror error
Definition: dbcore.h:69
int64 GetInt64(uint32 index) const
Definition: dbcore.cpp:670

Here is the call graph for this function:

uint32 PlanetDB::GetLaunchItemID ( uint32  launchID)
static

Definition at line 172 of file PlanetDB.cpp.

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

173 {
174  DBQueryResult res;
175  if(!sDatabase.RunQuery(res, "SELECT itemID FROM piLaunches WHERE launchID = %u", launchID)) {
176  _log(DATABASE__ERROR, "Error in GetLaunchItemID query: %s", res.error.c_str());
177  }
178  DBResultRow row;
179  if (!res.GetRow(row)) {
180  _log(DATABASE__ERROR, "Error in GetLaunchItemID query: %s", res.error.c_str());
181  return 0;
182  }
183 
184  return row.GetInt(0);
185 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
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
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

uint32 PlanetDB::GetLaunchPlanet ( uint32  launchID)
static

Definition at line 136 of file PlanetDB.cpp.

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

137 {
138  DBQueryResult res;
139  if(!sDatabase.RunQuery(res, "SELECT planetID FROM piLaunches WHERE launchID = %u", launchID)) {
140  _log(DATABASE__ERROR, "Error in GetLaunchPlanet query: %s", res.error.c_str());
141  }
142  DBResultRow row;
143  if (!res.GetRow(row)) {
144  _log(DATABASE__ERROR, "Error in GetLaunchPlanet query: %s", res.error.c_str());
145  return 0;
146  }
147 
148  return row.GetInt(0);
149 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
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
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

GPoint PlanetDB::GetLaunchPos ( uint32  launchID)
static

Definition at line 121 of file PlanetDB.cpp.

References _log, DBerror::c_str(), DBQueryResult::error, DBResultRow::GetDouble(), DBQueryResult::GetRow(), NULL_ORIGIN(), and sDatabase.

122 {
123  DBQueryResult res;
124  if(!sDatabase.RunQuery(res, "SELECT x,y,z FROM piLaunches WHERE launchID = %u", launchID)) {
125  _log(DATABASE__ERROR, "Error in GetLaunchPos query: %s", res.error.c_str());
126  }
127  DBResultRow row;
128  if (!res.GetRow(row)) {
129  _log(DATABASE__ERROR, "Error in GetLaunchPos query: %s", res.error.c_str());
130  return NULL_ORIGIN;
131  }
132  GPoint pos(row.GetDouble(0), row.GetDouble(1), row.GetDouble(2));
133  return pos;
134 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
double GetDouble(uint32 index) const
Definition: dbcore.cpp:693
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
Definition: gpoint.h:33
const char * c_str() const
Definition: dbcore.h:48
static const GPoint NULL_ORIGIN(0, 0, 0)
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

PyRep * PlanetDB::GetMyLaunchesDetails ( uint32  charID)

Definition at line 111 of file PlanetDB.cpp.

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

111  {
112  DBQueryResult res;
113  if(!sDatabase.RunQuery(res, "SELECT itemID AS launchID, status, itemID, solarSystemID, planetID, launchTime, x, y, z"
114  " FROM piLaunches WHERE charID = %u", charID)) {
115  _log(DATABASE__ERROR, "Error in GetMyLaunchesDetails Query: %s", res.error.c_str());
116  return nullptr;
117  }
118  return DBResultToRowset(res);
119 }
#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:

void PlanetDB::GetPlanetData ( DBQueryResult res)

Definition at line 61 of file PlanetDB.cpp.

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

Referenced by PlanetDataMgr::_Populate().

62 {
63  // load info into PlanetDataMgr
64  if(!sDatabase.RunQuery(res,
65  "SELECT planet.typeID AS planetTypeID,"
66  " resource.typeID AS resourceID"
67  " FROM invTypes planet, invTypes resource, dgmTypeAttributes dgm1, dgmTypeAttributes dgm2 "
68  " WHERE dgm1.typeID = dgm2.typeID AND dgm1.attributeID = 1632 AND dgm1.valueFloat = planet.typeID AND dgm2.attributeID = 709"
69  " AND dgm2.valueFloat = resource.typeID ORDER BY planet.typeID ")) {
70  _log(DATABASE__ERROR, "Error in GetPlanetData Query: %s", res.error.c_str());
71  }
72 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

Here is the caller graph for this function:

PyRep * PlanetDB::GetPlanetsForChar ( uint32  charID)

self.colonizationData = sm.RemoteSvc('planetMgr').GetPlanetsForChar() returns (solarSystemID, planetID, typeID, numberOfPins)

Definition at line 75 of file PlanetDB.cpp.

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

75  {
79  DBQueryResult res;
80  if(!sDatabase.RunQuery(res,
81  "SELECT solarSystemID, planetID, typeID, numberOfPins"
82  " FROM piPlanets WHERE charID = %u", charID)) {
83  _log(DATABASE__ERROR, "Error in GetPlanetsForChar query: %s", res.error.c_str());
84  return nullptr;
85  }
86  _log(DATABASE__RESULTS, "GetPlanetsForChar returned %u items", res.GetRowCount());
87  return DBResultToCRowset(res);
88 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
PyObjectEx * DBResultToCRowset(DBQueryResult &result)
Definition: EVEDBUtils.cpp:402
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69
size_t GetRowCount()
Definition: dbcore.h:72

Here is the call graph for this function:

void PlanetDB::GetSchematicData ( DBQueryResult res)

Definition at line 47 of file PlanetDB.cpp.

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

Referenced by PIDataMgr::_Populate().

48 {
49  // load info into PIDataMgr
50  if(!sDatabase.RunQuery(res, "SELECT schematicID, typeID, quantity, isInput FROM piTypeMap" ))
51  _log(DATABASE__ERROR, "Error in GetSchematicData Query: %s", res.error.c_str());
52 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::GetSchematicTimes ( DBQueryResult res)

Definition at line 54 of file PlanetDB.cpp.

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

Referenced by PIDataMgr::_Populate().

55 {
56  // load info into PIDataMgr
57  if(!sDatabase.RunQuery(res, "SELECT schematicID, cycleTime FROM piSchematics"))
58  _log(DATABASE__ERROR, "Error in GetSchematicTimes Query: %s", res.error.c_str());
59 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

Here is the caller graph for this function:

bool PlanetDB::LoadColony ( uint32  charID,
uint32  planetID,
PI_CCPin ccPin 
)

Definition at line 212 of file PlanetDB.cpp.

References _log, DBerror::c_str(), PI_CCPin::ccPinID, DBQueryResult::error, DBResultRow::GetInt(), DBQueryResult::GetRow(), PI_CCPin::level, and sDatabase.

Referenced by Colony::Init().

213 {
214  DBQueryResult res;
215  if (!sDatabase.RunQuery(res,
216  "SELECT pinID,level"
217  " FROM piCCPin"
218  " WHERE charID = %u"
219  " AND planetID = %u",
220  charID, planetID ))
221  {
222  _log(DATABASE__ERROR, "Error in LoadPins Query: %s", res.error.c_str());
223  return false;
224  }
225  DBResultRow row;
226  if (res.GetRow(row)) {
227  ccPin->level = row.GetInt(1);
228  ccPin->ccPinID = row.GetInt(0);
229  return true;
230  }
231  return false;
232 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
uint8 level
Definition: EVE_Planet.h:231
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
uint32 ccPinID
Definition: EVE_Planet.h:232
DBerror error
Definition: dbcore.h:69

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::LoadContents ( uint32  pinID,
std::map< uint16, uint32 > &  contents 
)

Definition at line 361 of file PlanetDB.cpp.

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

Referenced by LoadPins().

362 {
363  //SELECT ccPinID, pinID, typeID, itemQty FROM piPinContents
364  DBQueryResult res;
365  if (!sDatabase.RunQuery(res,
366  "SELECT typeID, itemQty"
367  " FROM piPinContents WHERE pinID = %u",
368  pinID ))
369  {
370  _log(DATABASE__ERROR, "Error in LoadContents Query: %s", res.error.c_str());
371  return;
372  }
373 
374  _log(DATABASE__RESULTS, "LoadContents returned %u items", res.GetRowCount());
375 
376  DBResultRow row;
377  while (res.GetRow(row)) {
378  contents[row.GetInt(0)] = row.GetInt(1);
379  }
380 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69
size_t GetRowCount()
Definition: dbcore.h:72

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::LoadHeads ( uint32  ecuID,
std::map< uint16, PI_Heads > &  heads 
)

Definition at line 382 of file PlanetDB.cpp.

References _log, DBerror::c_str(), PI_Heads::ecuPinID, DBQueryResult::error, DBQueryResult::GetRow(), DBQueryResult::GetRowCount(), PI_Heads::latitude, PI_Heads::longitude, sDatabase, and PI_Heads::typeID.

Referenced by LoadPins().

383 {
384  //SELECT ecuID, headID, typeID, latitude, longitude FROM piECUHeads
385  DBQueryResult res;
386  if (!sDatabase.RunQuery(res,
387  "SELECT headID, typeID, latitude, longitude"
388  " FROM piECUHeads WHERE ecuID = %u",
389  ecuID ))
390  {
391  _log(DATABASE__ERROR, "Error in LoadHeads Query: %s", res.error.c_str());
392  return;
393  }
394 
395  _log(DATABASE__RESULTS, "LoadHeads returned %u items", res.GetRowCount());
396 
397  DBResultRow row;
398  while (res.GetRow(row)) {
399  PI_Heads head = PI_Heads();
400  head.typeID = row.GetInt(1);
401  head.ecuPinID = ecuID;
402  head.latitude = row.GetDouble(2);
403  head.longitude = row.GetDouble(3);
404  heads[(uint16)row.GetInt(0)] = head;
405  }
406 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
uint16 typeID
Definition: EVE_Planet.h:136
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
uint32 ecuPinID
Definition: EVE_Planet.h:137
const char * c_str() const
Definition: dbcore.h:48
double latitude
Definition: EVE_Planet.h:138
double longitude
Definition: EVE_Planet.h:139
DBerror error
Definition: dbcore.h:69
size_t GetRowCount()
Definition: dbcore.h:72
unsigned __int16 uint16
Definition: eve-compat.h:48

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::LoadLinks ( uint32  ccPinID,
std::map< uint32, PI_Link > &  links 
)

Definition at line 290 of file PlanetDB.cpp.

References _log, DBerror::c_str(), PI_Link::endpoint1, PI_Link::endpoint2, DBQueryResult::error, DBQueryResult::GetRow(), DBQueryResult::GetRowCount(), PI_Link::level, sDatabase, PI_Link::state, and PI_Link::typeID.

Referenced by Colony::Load().

291 {
292  DBQueryResult res;
293  if (!sDatabase.RunQuery(res,
294  "SELECT linkID, level, state, endpoint1, endpoint2"
295  " FROM piLinks WHERE ccPinID = %u",
296  ccPinID ))
297  {
298  _log(DATABASE__ERROR, "Error in LoadPins Query: %s", res.error.c_str());
299  return;
300  }
301 
302  _log(DATABASE__RESULTS, "LoadLinks returned %u items", res.GetRowCount());
303 
304  DBResultRow row;
305  while (res.GetRow(row)) {
306  PI_Link link = PI_Link();
307  link.level = row.GetInt(1);
308  link.state = row.GetInt(2);
309  link.typeID = 2280; // only link type in game
310  link.endpoint1 = row.GetInt(3);
311  link.endpoint2 = row.GetInt(4);
312  links[row.GetInt(0)] = link;
313  }
314 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69
size_t GetRowCount()
Definition: dbcore.h:72

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::LoadPins ( uint32  ccPinID,
std::map< uint32, PI_Pin > &  pins 
)

Definition at line 234 of file PlanetDB.cpp.

References _log, DBerror::c_str(), PI_Pin::contents, PI_Pin::cycleTime, DBQueryResult::error, PI_Pin::expiryTime, DBQueryResult::GetRow(), DBQueryResult::GetRowCount(), PI_Pin::hasReceivedInputs, PI_Pin::headRadius, PI_Pin::heads, EvE::Time::Hour, PI_Pin::installTime, PI_Pin::isCommandCenter, PI_Pin::isECU, PI_Pin::isLaunchable, PI_Pin::isProcess, PI_Pin::isStorage, PI_Pin::lastLaunchTime, PI_Pin::lastRunTime, PI_Pin::latitude, PI_Pin::level, LoadContents(), LoadHeads(), PI_Pin::longitude, PI_Pin::ownerID, PI_Pin::programType, PI_Pin::qtyPerCycle, PI_Pin::receivedInputsLastCycle, PI_Pin::schematicID, sDatabase, PI_Pin::state, and PI_Pin::typeID.

Referenced by Colony::Load().

235 {
236  DBQueryResult res;
237  if (!sDatabase.RunQuery(res,
238  "SELECT pinID, typeID, ownerID, state, level, latitude, longitude, "
239  " isCommandCenter, isLaunchable, isProcess, isStorage, isECU,"
240  " schematicID, programType, headRadius,"
241  " launchTime, cycleTime, expiryTime, installTime, lastRunTime,"
242  " hasReceivedInputs, receivedInputsLastCycle, qtyPerCycle"
243  " FROM piPins"
244  " WHERE ccPinID = %u", ccPinID))
245  {
246  _log(DATABASE__ERROR, "Error in LoadPins Query: %s", res.error.c_str());
247  return;
248  }
249 
250  _log(DATABASE__RESULTS, "LoadPins returned %u items", res.GetRowCount());
251 
252  DBResultRow row;
253  while (res.GetRow(row)) {
254  PI_Pin pin = PI_Pin();
255  pin.typeID = row.GetInt(1);
256  pin.ownerID = row.GetInt(2);
257  pin.state = row.GetInt(3);
258  pin.level = row.GetInt(4);
259  pin.latitude = row.GetFloat(5);
260  pin.longitude = row.GetFloat(6);
261  pin.isCommandCenter = row.GetBool(7);
262  pin.isLaunchable = row.GetBool(8);
263  pin.isProcess = row.GetBool(9);
264  pin.isStorage = row.GetBool(10);
265  pin.isECU = row.GetBool(11);
266  pin.schematicID = row.GetInt(12);
267  pin.programType = row.GetInt(13);
268  pin.headRadius = row.GetFloat(14);
269  pin.lastLaunchTime = row.GetInt64(15);
270  pin.cycleTime = row.GetInt64(16);
271  if (pin.isECU) // ecu time is stored as filetime, but used as hours
272  pin.cycleTime /= EvE::Time::Hour;
273  pin.expiryTime = row.GetInt64(17);
274  pin.installTime = row.GetInt64(18);
275  pin.lastRunTime = row.GetInt64(19);
276  pin.hasReceivedInputs = row.GetBool(20);
277  pin.receivedInputsLastCycle = row.GetBool(21);
278  pin.qtyPerCycle = row.GetInt(22);
279 
280  if (pin.isStorage or pin.isProcess)
281  LoadContents(row.GetInt(0), pin.contents);
282 
283  if (pin.isECU)
284  LoadHeads(row.GetInt(0), pin.heads);
285 
286  pins[row.GetInt(0)] = pin;
287  }
288 }
float longitude
Definition: EVE_Planet.h:197
std::map< uint16, uint32 > contents
Definition: EVE_Planet.h:204
#define sDatabase
Definition: dbcore.h:199
bool isLaunchable
Definition: EVE_Planet.h:176
#define _log(type, fmt,...)
Definition: logsys.h:124
uint16 programType
Definition: EVE_Planet.h:187
bool isCommandCenter
Definition: EVE_Planet.h:177
void LoadHeads(uint32 ecuID, std::map< uint16, PI_Heads > &heads)
Definition: PlanetDB.cpp:382
uint32 ownerID
Definition: EVE_Planet.h:189
uint32 qtyPerCycle
Definition: EVE_Planet.h:188
uint16 level
Definition: EVE_Planet.h:184
void LoadContents(uint32 pinID, std::map< uint16, uint32 > &contents)
Definition: PlanetDB.cpp:361
std::map< uint16, PI_Heads > heads
Definition: EVE_Planet.h:203
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
int64 lastRunTime
Definition: EVE_Planet.h:190
bool isECU
Definition: EVE_Planet.h:171
float latitude
Definition: EVE_Planet.h:196
const char * c_str() const
Definition: dbcore.h:48
bool isStorage
Definition: EVE_Planet.h:173
uint16 typeID
Definition: EVE_Planet.h:185
bool hasReceivedInputs
Definition: EVE_Planet.h:180
float headRadius
Definition: EVE_Planet.h:201
int64 lastLaunchTime
Definition: EVE_Planet.h:194
bool isProcess
Definition: EVE_Planet.h:174
bool receivedInputsLastCycle
Definition: EVE_Planet.h:181
int64 installTime
Definition: EVE_Planet.h:193
DBerror error
Definition: dbcore.h:69
int64 cycleTime
Definition: EVE_Planet.h:191
int8 state
Definition: EVE_Planet.h:183
size_t GetRowCount()
Definition: dbcore.h:72
uint16 schematicID
Definition: EVE_Planet.h:186
int64 expiryTime
Definition: EVE_Planet.h:192

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::LoadRoutes ( uint32  ccPinID,
std::map< uint16, PI_Route > &  routes 
)

Definition at line 316 of file PlanetDB.cpp.

References _log, DBerror::c_str(), PI_Route::commodityQuantity, PI_Route::commodityTypeID, PI_Route::destPinID, DBQueryResult::error, DBQueryResult::GetRow(), DBQueryResult::GetRowCount(), PI_Route::path, PI_Route::priority, sDatabase, PI_Route::srcPinID, and PI_Route::state.

Referenced by Colony::Load().

317 {
318  DBQueryResult res;
319  if (!sDatabase.RunQuery(res,
320  "SELECT routeID, srcPinID, destPinID, state, priority, path, typeID, itemQty"
321  " FROM piRoutes WHERE ccPinID = %u",
322  ccPinID ))
323  {
324  _log(DATABASE__ERROR, "Error in LoadPins Query: %s", res.error.c_str());
325  return;
326  }
327 
328  _log(DATABASE__RESULTS, "LoadRoutes returned %u items", res.GetRowCount());
329 
330  DBResultRow row;
331  std::string tempPath;
332  while (res.GetRow(row)) {
333  tempPath.clear();
334  PI_Route route = PI_Route();
335  route.srcPinID = row.GetInt(1);
336  route.destPinID = row.GetInt(2);
337  route.state = row.GetInt(3);
338  route.priority = row.GetInt(4);
339  route.commodityTypeID = row.GetInt(6);
340  route.commodityQuantity = row.GetInt(7);
341 
342  tempPath = row.GetText(5);
343  if (!tempPath.empty()) {
344  // route string is not empty, so extract one number at a time until it is
345  int pos = 0;
346  std::string tempString = "";
347 
348  while ((pos = tempPath.find_first_of(':')) > 0 ) {
349  tempString = tempPath.substr(0,pos);
350  tempPath = tempPath.substr(pos+1,tempPath.length()-1);
351  route.path.insert(route.path.end(), (atoi(tempString.c_str())));
352  }
353  // insert last pinID
354  route.path.insert(route.path.end(), (atoi(tempPath.c_str())));
355  }
356 
357  routes[row.GetInt(0)] = route;
358  }
359 }
std::list< uint32 > path
Definition: EVE_Planet.h:132
int8 priority
Definition: EVE_Planet.h:127
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
uint16 commodityQuantity
Definition: EVE_Planet.h:129
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
uint16 commodityTypeID
Definition: EVE_Planet.h:128
uint32 srcPinID
Definition: EVE_Planet.h:130
int8 state
Definition: EVE_Planet.h:126
const char * c_str() const
Definition: dbcore.h:48
DBerror error
Definition: dbcore.h:69
size_t GetRowCount()
Definition: dbcore.h:72
uint32 destPinID
Definition: EVE_Planet.h:131

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::RemoveContents ( uint32  pinID)

Definition at line 819 of file PlanetDB.cpp.

References sDatabase.

Referenced by Colony::AbandonColony(), and Colony::Process().

820 {
821  DBerror err;
822  sDatabase.RunQuery(err, "DELETE FROM piPinContents WHERE pinID = %u", pinID);
823 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39

Here is the caller graph for this function:

void PlanetDB::RemoveHead ( uint32  ecuID,
uint32  headID 
)

Definition at line 801 of file PlanetDB.cpp.

References sDatabase.

802 {
803  DBerror err;
804  sDatabase.RunQuery(err, "DELETE FROM piECUHeads WHERE ecuID = %u AND headID = %u", ecuID, headID);
805 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39
void PlanetDB::RemoveLink ( uint32  linkID)

Definition at line 807 of file PlanetDB.cpp.

References sDatabase.

Referenced by Colony::RemoveLink(), and Colony::RemovePin().

808 {
809  DBerror err;
810  sDatabase.RunQuery(err, "DELETE FROM piLinks WHERE linkID = %u", linkID);
811 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39

Here is the caller graph for this function:

void PlanetDB::RemovePin ( uint32  pinID)

Definition at line 793 of file PlanetDB.cpp.

References sDatabase.

Referenced by Colony::AbandonColony(), and Colony::RemovePin().

794 {
795  DBerror err;
796  sDatabase.RunQuery(err, "DELETE FROM piPins WHERE pinID = %u", pinID);
797  sDatabase.RunQuery(err, "DELETE FROM entity WHERE itemID = %u", pinID);
798  sDatabase.RunQuery(err, "DELETE FROM entity_attributes WHERE itemID = %u", pinID);
799 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39

Here is the caller graph for this function:

void PlanetDB::RemoveRoute ( uint16  routeID)

Definition at line 813 of file PlanetDB.cpp.

References sDatabase.

Referenced by Colony::RemovePin(), and Colony::RemoveRoute().

814 {
815  DBerror err;
816  sDatabase.RunQuery(err, "DELETE FROM piRoutes WHERE routeID = %u", routeID);
817 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39

Here is the caller graph for this function:

void PlanetDB::SaveCCLevel ( uint32  pinID,
uint8  level 
)

Definition at line 432 of file PlanetDB.cpp.

References _log, DBerror::GetError(), and sDatabase.

Referenced by Colony::UpgradeCommandCenter().

433 {
434  DBerror err;
435  if(!sDatabase.RunQuery(err, "UPDATE piCCPin SET level = %u WHERE pinID = %u", level, pinID))
436  _log(DATABASE__ERROR, "SaveCCLevel - Unable to save CCLevel: %s", err.GetError());
437  if(!sDatabase.RunQuery(err, "UPDATE piPins SET level = %u WHERE pinID = %u", level, pinID))
438  _log(DATABASE__ERROR, "SaveCCLevel - Unable to save CCLevel: %s", err.GetError());
439 
440 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * GetError() const
Definition: dbcore.h:46
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::SaveCommandCenter ( uint32  pinID,
uint32  charID,
uint32  planetID,
uint32  typeID,
double  latitude,
double  longitude 
)

Definition at line 420 of file PlanetDB.cpp.

References _log, DBerror::GetError(), and sDatabase.

Referenced by Colony::CreateCommandPin().

421 {
422  DBerror err;
423  if(!sDatabase.RunQuery(err,
424  "INSERT INTO piCCPin (pinID, charID, planetID, typeID, latitude, longitude) "
425  " VALUES (%u, %u, %u, %u, %f, %f)",
426  pinID, charID, planetID, typeID, latitude, longitude))
427  {
428  _log(DATABASE__ERROR, "SaveCommandCenter - Unable to save CommandCenter: %s", err.GetError());
429  }
430 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * GetError() const
Definition: dbcore.h:46
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::SaveContents ( PI_CCPin ccPin)

Definition at line 733 of file PlanetDB.cpp.

References _log, DBerror::c_str(), PI_CCPin::ccPinID, PI_CCPin::pins, and sDatabase.

Referenced by Colony::LaunchCommodities(), Colony::PlanetXfer(), Colony::Save(), Colony::Shutdown(), and Colony::TransferCommodities().

734 {
735  std::ostringstream Inserts;
736  // start the insert into command.
737  Inserts << "INSERT INTO piPinContents";
738  Inserts << " (ccPinID, pinID, typeID, itemQty)";
739 
740  bool first = true;
741  uint32 ccPinID = ccPin->ccPinID;
742  std::map<uint16, uint32>::iterator itr;
743  for (auto cur : ccPin->pins) {
744  if (cur.second.isStorage) {
745  for (itr = cur.second.contents.begin(); itr != cur.second.contents.end(); ++itr) {
746  if (first) {
747  Inserts << " VALUES ";
748  first = false;
749  } else {
750  Inserts << ", ";
751  }
752  Inserts << "(" << ccPinID << ", " << cur.first << ", " << itr->first << ", " << itr->second << ")";
753  }
754  }
755  }
756  if (!first) {
757  // finish creating the command.
758  Inserts << " ON DUPLICATE KEY UPDATE";
759  Inserts << " itemQty=VALUES(itemQty);";
760  // execute the command.
761  DBerror err;
762  if (!sDatabase.RunQuery(err, Inserts.str().c_str()))
763  _log(DATABASE__ERROR, "SaveContents - unable to save contents - %s", err.c_str());
764  }
765 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
uint32 ccPinID
Definition: EVE_Planet.h:232
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:

void PlanetDB::SaveHeads ( uint32  ccPinID,
uint32  ownerID,
uint32  ecuID,
std::map< uint16, PI_Heads > &  heads 
)

Definition at line 595 of file PlanetDB.cpp.

References _log, DBerror::GetError(), and sDatabase.

Referenced by Colony::GetColony().

596 {
597  if (heads.empty())
598  return;
599 
600  DBerror err;
601  for (auto cur : heads) {
602  // save the head data separately
603  if (!sDatabase.RunQuery(err,
604  "INSERT INTO piECUHeads (ccPinID, ownerID, ecuID, headID, typeID, latitude, longitude)"
605  " VALUES (%u, %u, %u, %u, %u, %f, %f)"
606  " ON DUPLICATE KEY UPDATE "
607  " typeID=VALUES(typeID),"
608  " latitude=VALUES(latitude),"
609  " longitude=VALUES(longitude)",
610  ccPinID, ownerID, ecuID, cur.first, cur.second.typeID, cur.second.latitude, cur.second.longitude))
611  {
612  _log(DATABASE__ERROR, "SaveHeads - Unable to save heads: %s", err.GetError());
613  }
614  }
615 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * GetError() const
Definition: dbcore.h:46
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::SaveLaunch ( uint32  contID,
uint32  charID,
uint32  systemID,
uint32  planetID,
GPoint pos 
)

Definition at line 408 of file PlanetDB.cpp.

References _log, DBerror::GetError(), GetFileTimeNow(), sDatabase, Ga::GaVec3::x, Ga::GaVec3::y, and Ga::GaVec3::z.

Referenced by Colony::LaunchCommodities().

409 {
410  DBerror err;
411  if(!sDatabase.RunQuery(err,
412  "INSERT INTO piLaunches (itemID, status, charID, solarSystemID, planetID, launchTime, x, y, z) "
413  " VALUES (%u, 0, %u, %u, %u, %f, %f, %f, %f)",
414  contID, charID, systemID, planetID, GetFileTimeNow(), pos.x, pos.y, pos.z))
415  {
416  _log(DATABASE__ERROR, "SaveLaunch - Unable to save Launch: %s", err.GetError());
417  }
418 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * GetError() const
Definition: dbcore.h:46
GaFloat x
Definition: GaTypes.h:207
GaFloat y
Definition: GaTypes.h:207
double GetFileTimeNow()
Definition: utils_time.cpp:84
Definition: dbcore.h:39
GaFloat z
Definition: GaTypes.h:207

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::SaveLinkLevel ( uint32  linkID,
uint8  level 
)

Definition at line 658 of file PlanetDB.cpp.

References _log, DBerror::GetError(), and sDatabase.

659 {
660  DBerror err;
661  if(!sDatabase.RunQuery(err, "UPDATE piLinks SET level = %u WHERE linkID = %u", level, linkID))
662  {
663  _log(DATABASE__ERROR, "SaveLinkLevel - Unable to save LinkLevel: %s", err.GetError());
664  }
665 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * GetError() const
Definition: dbcore.h:46
Definition: dbcore.h:39

Here is the call graph for this function:

void PlanetDB::SaveLinks ( PI_CCPin ccPin)

Definition at line 626 of file PlanetDB.cpp.

References _log, DBerror::c_str(), PI_CCPin::ccPinID, PI_CCPin::links, and sDatabase.

Referenced by Colony::CreateLink(), Colony::RemovePin(), Colony::Save(), and Colony::UpgradeLink().

627 {
628  std::ostringstream Inserts;
629  // start the insert into command.
630  Inserts << "INSERT INTO piLinks";
631  Inserts << " (ccPinID, linkID, level, endpoint1, endpoint2)";
632 
633  bool first = true;
634  uint32 ccPinID = ccPin->ccPinID;
635  for (auto cur : ccPin->links) {
636  if (first) {
637  Inserts << " VALUES ";
638  first = false;
639  } else {
640  Inserts << ", ";
641  }
642  Inserts << "(" << ccPinID << ", " << cur.first << ", " << cur.second.level << ", " << cur.second.endpoint1 << ", " << cur.second.endpoint2 << ")";
643  }
644 
645  if (!first) {
646  // finish creating the command.
647  Inserts << " ON DUPLICATE KEY UPDATE";
648  Inserts << " level=VALUES(level), ";
649  Inserts << " endpoint1=VALUES(endpoint1), ";
650  Inserts << " endpoint2=VALUES(endpoint2)";
651  // execute the command.
652  DBerror err;
653  if (!sDatabase.RunQuery(err, Inserts.str().c_str()))
654  _log(DATABASE__ERROR, "SaveLinks - unable to save links - %s", err.c_str());
655  }
656 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
uint32 ccPinID
Definition: EVE_Planet.h:232
std::map< uint32, PI_Link > links
Definition: EVE_Planet.h:237
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:

void PlanetDB::SavePinContents ( uint32  ccPinID,
uint32  pinID,
std::map< uint16, uint32 > &  contents 
)

Definition at line 767 of file PlanetDB.cpp.

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

Referenced by Colony::Process().

768 {
769  std::ostringstream Inserts;
770  // start the insert into command.
771  Inserts << "INSERT INTO piPinContents";
772  Inserts << " (ccPinID, pinID, typeID, itemQty)";
773 
774  bool first = true;
775  std::map<uint16, uint32>::iterator itr;
776  for (itr = contents.begin(); itr != contents.end(); ++itr) {
777  if (first) {
778  Inserts << " VALUES ";
779  first = false;
780  } else {
781  Inserts << ", ";
782  }
783  Inserts << "(" << ccPinID << ", " << pinID << ", " << itr->first << ", " << itr->second << ")";
784  }
785  if (!first) {
786  // execute the command.
787  DBerror err;
788  if (!sDatabase.RunQuery(err, Inserts.str().c_str()))
789  _log(DATABASE__ERROR, "SavePinContents - unable to save contents - %s", err.c_str());
790  }
791 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::SavePinLevel ( uint32  pinID,
uint8  level 
)

Definition at line 617 of file PlanetDB.cpp.

References _log, DBerror::GetError(), and sDatabase.

618 {
619  DBerror err;
620  if(!sDatabase.RunQuery(err, "UPDATE piPins SET level = %u WHERE pinID = %u", level, pinID))
621  {
622  _log(DATABASE__ERROR, "SavePinLevel - Unable to save PinLevel: %s", err.GetError());
623  }
624 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * GetError() const
Definition: dbcore.h:46
Definition: dbcore.h:39

Here is the call graph for this function:

void PlanetDB::SavePins ( PI_CCPin ccPin)

Definition at line 442 of file PlanetDB.cpp.

References _log, DBerror::c_str(), PI_CCPin::ccPinID, PI_CCPin::pins, and sDatabase.

Referenced by Colony::CreateCommandPin(), and Colony::Save().

443 {
444  std::ostringstream Inserts;
445  // start the insert into command.
446  Inserts << "INSERT INTO piPins";
447  Inserts << " (ccPinID, pinID, typeID, ownerID, level, latitude, longitude,";
448  Inserts << " isCommandCenter, isLaunchable, isProcess, isStorage, isECU,";
449  Inserts << " schematicID, programType, headRadius, launchTime,";
450  Inserts << " cycleTime, expiryTime, installTime, lastRunTime)";
451 
452  bool first = true;
453  uint32 ccPinID = ccPin->ccPinID;
454  for (auto cur : ccPin->pins) {
455  if (first) {
456  Inserts << " VALUES ";
457  first = false;
458  } else {
459  Inserts << ", ";
460  }
461  Inserts << "(" << ccPinID << ", " << cur.first << ", " << cur.second.typeID << ", " << cur.second.ownerID << ", " << cur.second.level << ", " << cur.second.latitude << ", " << cur.second.longitude << ", ";
462  Inserts << cur.second.isCommandCenter << ", " << cur.second.isLaunchable << ", " << cur.second.isProcess << ", " << cur.second.isStorage <<", " << cur.second.isECU << ", ";
463  Inserts << cur.second.schematicID << ", " << cur.second.programType << ", " << cur.second.headRadius << ", " << cur.second.lastLaunchTime;
464  Inserts << ", " << cur.second.cycleTime << ", " << cur.second.expiryTime << ", " << cur.second.installTime << ", " << cur.second.lastRunTime << ")";
465  }
466 
467  if (!first) {
468  // finish creating the command.
469  Inserts << " ON DUPLICATE KEY UPDATE ";
470  Inserts << " schematicID=VALUES(schematicID), ";
471  Inserts << " programType=VALUES(programType), ";
472  Inserts << " headRadius=VALUES(headRadius),";
473  Inserts << " launchTime=VALUES(launchTime), ";
474  Inserts << " cycleTime=VALUES(cycleTime),";
475  Inserts << " expiryTime=VALUES(expiryTime), ";
476  Inserts << " installTime=VALUES(installTime),";
477  Inserts << " lastRunTime=VALUES(lastRunTime);";
478  // execute the command.
479  DBerror err;
480  if (!sDatabase.RunQuery(err, Inserts.str().c_str()))
481  _log(DATABASE__ERROR, "SavePins - unable to save pins: %s", err.c_str());
482  }
483 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
uint32 ccPinID
Definition: EVE_Planet.h:232
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:

uint16 PlanetDB::SaveRoute ( uint32  ccPinID,
PI_Route route 
)

Definition at line 667 of file PlanetDB.cpp.

References _log, PI_Route::commodityQuantity, PI_Route::commodityTypeID, PI_Route::destPinID, DBerror::GetError(), PI_Route::path, PI_Route::priority, sDatabase, PI_Route::srcPinID, and PI_Route::state.

Referenced by Colony::CreateRoute().

668 {
669  DBerror err;
670  uint32 routeID = 0;
671  std::string path;
672  path.clear();
673  std::list<uint32>::iterator itr = route.path.begin();
674  while (itr != route.path.end()) {
675  path += std::to_string(*itr);
676  if (++itr != route.path.end())
677  path += ":";
678  }
679  if (!sDatabase.RunQueryLID(err, routeID,
680  "INSERT INTO `piRoutes`(`ccPinID`, `srcPinID`, `destPinID`, `state`, `priority`, `path`, `typeID`, `itemQty`) "
681  " VALUES (%u, %u, %u, %u, %u, '%s', %u, %u)",
682  ccPinID, route.srcPinID, route.destPinID, route.state, route.priority, path.c_str(), route.commodityTypeID, route.commodityQuantity))
683  {
684  _log(DATABASE__ERROR, "SaveHeads - Unable to save heads: %s", err.GetError());
685  }
686  return (uint16)routeID;
687 }
std::list< uint32 > path
Definition: EVE_Planet.h:132
int8 priority
Definition: EVE_Planet.h:127
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
uint16 commodityQuantity
Definition: EVE_Planet.h:129
const char * GetError() const
Definition: dbcore.h:46
uint16 commodityTypeID
Definition: EVE_Planet.h:128
uint32 srcPinID
Definition: EVE_Planet.h:130
int8 state
Definition: EVE_Planet.h:126
unsigned __int32 uint32
Definition: eve-compat.h:50
uint32 destPinID
Definition: EVE_Planet.h:131
unsigned __int16 uint16
Definition: eve-compat.h:48
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::SaveRoutes ( PI_CCPin ccPin)

Definition at line 689 of file PlanetDB.cpp.

References _log, DBerror::c_str(), PI_CCPin::ccPinID, PI_CCPin::routes, and sDatabase.

Referenced by Colony::PrioritizeRoute(), Colony::RemovePin(), and Colony::Save().

690 {
691  std::ostringstream Inserts;
692  // start the insert into command.
693  Inserts << "INSERT INTO piRoutes";
694  Inserts << " (ccPinID, routeID, srcPinID, destPinID, path, typeID, itemQty)";
695 
696  bool first = true;
697  std::string path;
698  std::list<uint32>::iterator itr;
699  uint32 ccPinID = ccPin->ccPinID;
700  for (auto cur : ccPin->routes) {
701  path.clear();
702  if (first) {
703  Inserts << " VALUES ";
704  first = false;
705  } else {
706  Inserts << ", ";
707  }
708  itr = cur.second.path.begin();
709  while (itr != cur.second.path.end()) {
710  path += std::to_string(*itr);
711  if (++itr != cur.second.path.end())
712  path += ":";
713  }
714  Inserts << "(" << ccPinID << ", " << cur.first << ", " << cur.second.srcPinID << ", " << cur.second.destPinID << ", '" << path << "', ";
715  Inserts << cur.second.commodityTypeID << ", " << cur.second.commodityQuantity << ")";
716  }
717 
718  if (!first) {
719  // finish creating the command.
720  Inserts << " ON DUPLICATE KEY UPDATE";
721  Inserts << " path=VALUES(path),";
722  Inserts << " srcPinID=VALUES(srcPinID),";
723  Inserts << " destPinID=VALUES(destPinID),";
724  Inserts << " typeID=VALUES(typeID),";
725  Inserts << " itemQty=VALUES(itemQty);";
726  // execute the command.
727  DBerror err;
728  if (!sDatabase.RunQuery(err, Inserts.str().c_str()))
729  _log(DATABASE__ERROR, "SaveRoutes - unable to save route - %s", err.c_str());
730  }
731 }
std::map< uint16, PI_Route > routes
Definition: EVE_Planet.h:239
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
uint32 ccPinID
Definition: EVE_Planet.h:232
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:

void PlanetDB::UpdateECUPin ( uint32  pinID,
PI_CCPin ccPin 
)

Definition at line 536 of file PlanetDB.cpp.

References _log, DBerror::GetError(), PI_CCPin::pins, and sDatabase.

Referenced by Colony::SetProgramResults().

537 {
538  std::map<uint32, PI_Pin>::iterator itr = ccPin->pins.find(pinID);
539  if (itr == ccPin->pins.end()) {
540  _log(PLANET__ERROR, "PlanetDB::UpdateECUPin() - pinID %u not found in ccPin.pins map", pinID);
541  return;
542  }
543 
544  DBerror err;
545  if(!sDatabase.RunQuery(err,
546  "UPDATE piPins SET"
547  " programType = %u,"
548  " headRadius = %f,"
549  " qtyPerCycle = %u,"
550  " schematicID = %u,"
551  " expiryTime = %li,"
552  " cycleTime = %li,"
553  " installTime = %li,"
554  " lastRunTime = %li"
555  " WHERE pinID = %u",
556  itr->second.programType, itr->second.headRadius, itr->second.qtyPerCycle, itr->second.schematicID, itr->second.expiryTime,
557  itr->second.cycleTime, itr->second.installTime, itr->second.lastRunTime, pinID))
558  {
559  _log(DATABASE__ERROR, "UpdateECUPin - Unable to update pin: %s", err.GetError());
560  }
561 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * GetError() const
Definition: dbcore.h:46
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::UpdateLaunchStatus ( uint32  itemID,
uint8  status 
)
static

Definition at line 187 of file PlanetDB.cpp.

References sDatabase.

Referenced by CargoContainer::RemoveItem().

188 {
189  DBerror err;
190  sDatabase.RunQuery(err, "UPDATE piLaunches SET status=%u WHERE itemID = %u", status, itemID);
191 }
#define sDatabase
Definition: dbcore.h:199
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type()() itemID() copy() materialLevel()() itemID(attributeID)-Retrieves attribute value." ) COMMAND( setattr
Definition: dbcore.h:39

Here is the caller graph for this function:

void PlanetDB::UpdatePins ( uint32  pinID,
PI_CCPin ccPin 
)

Definition at line 485 of file PlanetDB.cpp.

References _log, DBerror::c_str(), PI_CCPin::ccPinID, PI_CCPin::pins, and sDatabase.

Referenced by Colony::LaunchCommodities(), Colony::PlanetXfer(), Colony::Process(), Colony::TransferCommodities(), and Colony::UpdatePlantPins().

486 {
487  std::ostringstream Inserts;
488  // start the insert into command.
489  Inserts << "INSERT INTO piPins";
490  Inserts << " (ccPinID, pinID, schematicID, programType, launchTime,";
491  Inserts << " cycleTime, installTime, lastRunTime, receivedInputsLastCycle, hasReceivedInputs)";
492 
493  bool first = true;
494  if (pinID) {
495  std::map<uint32, PI_Pin>::iterator itr;
496  itr = ccPin->pins.find(pinID);
497  if (itr != ccPin->pins.end()) {
498  first = false;
499  Inserts << " VALUES ";
500  Inserts << "(" << ccPin->ccPinID << ", " << itr->first << ", "<< itr->second.schematicID << ", " << itr->second.programType;
501  Inserts << ", " << itr->second.lastLaunchTime << ", " << itr->second.cycleTime << ", " << itr->second.installTime;
502  Inserts << ", " << itr->second.lastRunTime << ", " << itr->second.receivedInputsLastCycle << ", " << itr->second.hasReceivedInputs << ")";
503  }
504  } else {
505  for (auto cur : ccPin->pins) {
506  if (first) {
507  Inserts << " VALUES ";
508  first = false;
509  } else {
510  Inserts << ", ";
511  }
512  Inserts << "(" << ccPin->ccPinID << ", " << cur.first << ", "<< cur.second.schematicID << ", " << cur.second.programType;
513  Inserts << ", " << cur.second.lastLaunchTime << ", " << cur.second.cycleTime << ", " << cur.second.installTime;
514  Inserts << ", " << cur.second.lastRunTime << ", " << cur.second.receivedInputsLastCycle << ", " << cur.second.hasReceivedInputs << ")";
515  }
516  }
517 
518  if (!first) {
519  // finish creating the command.
520  Inserts << " ON DUPLICATE KEY UPDATE ";
521  Inserts << " schematicID=VALUES(schematicID), ";
522  Inserts << " programType=VALUES(programType), ";
523  Inserts << " launchTime=VALUES(launchTime), ";
524  Inserts << " cycleTime=VALUES(cycleTime),";
525  Inserts << " installTime=VALUES(installTime),";
526  Inserts << " lastRunTime=VALUES(lastRunTime),";
527  Inserts << " hasReceivedInputs=VALUES(hasReceivedInputs),";
528  Inserts << " receivedInputsLastCycle=VALUES(receivedInputsLastCycle);";
529  // execute the command.
530  DBerror err;
531  if (!sDatabase.RunQuery(err, Inserts.str().c_str()))
532  _log(DATABASE__ERROR, "SavePins - unable to save pins: %s", err.c_str());
533  }
534 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
uint32 ccPinID
Definition: EVE_Planet.h:232
Definition: dbcore.h:39

Here is the call graph for this function:

Here is the caller graph for this function:

void PlanetDB::UpdatePinTimes ( PI_CCPin ccPin)

Definition at line 563 of file PlanetDB.cpp.

References _log, DBerror::c_str(), PI_CCPin::pins, and sDatabase.

564 {
565  std::ostringstream Inserts;
566  // start the insert into command.
567  Inserts << "INSERT INTO piPins";
568  Inserts << " (pinID, launchTime, installTime, lastRunTime)";
569 
570  bool first = true;
571  for (auto cur : ccPin->pins) {
572  if (first) {
573  Inserts << " VALUES ";
574  first = false;
575  } else {
576  Inserts << ", ";
577  }
578  Inserts << "(" << cur.first << ", " << cur.second.lastLaunchTime << ", ";
579  Inserts << cur.second.installTime << ", " << cur.second.lastRunTime << ")";
580  }
581 
582  if (!first) {
583  // finish creating the command.
584  Inserts << " ON DUPLICATE KEY UPDATE ";
585  Inserts << " launchTime=VALUES(launchTime),";
586  Inserts << " installTime=VALUES(installTime),";
587  Inserts << " lastRunTime=VALUES(lastRunTime);";
588  // execute the command.
589  DBerror err;
590  if (!sDatabase.RunQuery(err, Inserts.str().c_str()))
591  _log(DATABASE__ERROR, "SavePins - unable to save pins: %s", err.c_str());
592  }
593 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * c_str() const
Definition: dbcore.h:48
Definition: dbcore.h:39

Here is the call graph for this function:

void PlanetDB::UpdatePlanetPins ( uint32  ccPinID,
uint8  pins = 1 
)

Definition at line 101 of file PlanetDB.cpp.

References _log, DBerror::GetError(), and sDatabase.

Referenced by Colony::RemovePin(), and Colony::Save().

102 {
103  DBerror err;
104  if(!sDatabase.RunQuery(err, "UPDATE piPlanets SET numberOfPins = %u WHERE ccPinID = %u ", pins, ccPinID))
105  {
106  _log(DATABASE__ERROR, "UpdatePlanetPins - Unable to update ccPinID %u : %s", ccPinID, err.GetError());
107  }
108 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * GetError() const
Definition: dbcore.h:46
Definition: dbcore.h:39

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: