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

#include "Colony.h"

Collaboration diagram for Colony:

Public Member Functions

 Colony (PyServiceMgr *mgr, Client *pClient, SystemEntity *pSE)
 
 ~Colony ()
 
void Init ()
 
void Load ()
 
void LoadPlants ()
 
void Save ()
 
void Update (bool updateTimes=false)
 
void Shutdown ()
 
void UpdatePlantPins (uint32 pinID=0)
 
void AbandonColony ()
 
void Process ()
 
void ProcessECUs (bool &save)
 
void ProcessPlants (bool &save)
 
void RemovePin (uint32 pinID)
 
void RemoveLink (uint32 src, uint32 dest)
 
void RemoveRoute (uint16 routeID)
 
void UpgradeLink (uint32 src, uint32 dest, uint8 level)
 
void UpgradeCommandCenter (uint32 pinID, int8 level)
 
void CreatePin (uint32 groupID, uint32 pinID, uint32 typeID, double latitude, double longitude)
 
void CreateLink (uint32 src, uint32 dest, uint16 level)
 
void CreateRoute (uint16 routeID, uint32 typeID, uint32 qty, PyList *path)
 
void CreateCommandPin (uint32 itemID, uint32 typeID, double latitude, double longitude)
 
void AddExtractorHead (uint32 ecuID, uint16 headID, double latitude, double longitude)
 
void MoveExtractorHead (uint32 ecuID, uint16 headID, double latitude, double longitude)
 
void KillExtractorHead (uint32 ecuID, uint16 headID)
 
void InstallProgram (uint32 ecuID, uint16 typeID, float headRadius, PlanetMgr *pPMgr)
 
void SetSchematic (uint32 pinID, uint8 schematicID=0)
 
void SetProgramResults (uint32 ecuID, uint16 typeID, uint16 numCycles, float headRadius, float cycleTime, uint32 qtyPerCycle)
 
PyRepLaunchCommodities (uint32 pinID, std::map< uint16, uint32 > &items)
 
void PlanetXfer (uint32 spaceportID, std::map< uint32, uint16 > importItems, std::map< uint32, uint16 > exportItems, double taxRate)
 
void PrioritizeRoute (uint16 routeID, uint8 priority)
 
uint32 GetOwner ()
 
PyRepGetColony ()
 
PyTupleGetPins ()
 
PyTupleGetLinks ()
 
PyTupleGetRoutes ()
 
PyDictTransferCommodities (uint32 srcID, uint32 destID, std::map< uint16, uint32 > items)
 
bool HasColony ()
 
int8 GetLevel ()
 
int64 GetSimTime ()
 

Private Attributes

PyServiceMgrm_svcMgr
 
PlanetSEm_pSE
 
PI_CCPinccPin
 
Clientm_client
 
Timer m_colonyTimer
 
PlanetDB m_db
 
bool m_active
 
bool m_loaded
 
bool m_newHead
 
bool m_toUpdate
 
uint8 m_pLevel
 
uint16 m_pg
 
uint16 m_cpu
 
uint32 m_colonyID
 
int64 m_procTime
 
std::vector< uint32tempECUs
 
std::map< uint8, uint32tempPinIDs
 
std::multimap< uint8, uint32m_plantMap
 
std::multimap< uint32, PI_Routem_srcRoutes
 
std::multimap< uint32, PI_Routem_destRoutes
 

Detailed Description

Definition at line 38 of file Colony.h.

Constructor & Destructor Documentation

Colony::Colony ( PyServiceMgr mgr,
Client pClient,
SystemEntity pSE 
)
Todo:
: items to work on... import/export tax cost of building timers (launch, run, current, logistics) planet items attribs/effects item->Move() logistics

notifyevents = [ 'OnPlanetCommandCenterDeployedOrRemoved', 'OnPlanetPinsChanged', 'OnColonyPinCountUpdated',

Definition at line 109 of file Colony.cpp.

References _log, ccPin, Client::GetCharacterID(), SystemEntity::GetID(), Client::GetName(), SystemEntity::GetName(), m_active, m_colonyID, m_cpu, m_loaded, m_newHead, m_pg, m_pLevel, m_procTime, m_toUpdate, and tempPinIDs.

110 :m_svcMgr(mgr),
111 m_client(pClient),
112 m_pSE(pSE->GetPlanetSE()),
113 m_colonyTimer(0)
114 {
115  ccPin = new PI_CCPin();
116 
117  m_active = false;
118  m_loaded = false;
119  m_newHead = false;
120  m_toUpdate = false;
121 
122  m_pg = 0;
123  m_cpu = 0;
124  m_pLevel = 5;
125  m_colonyID = 0;
126  m_procTime = 0; // process check. init to zero and stores last proc time, which is lastRunTime in command center
127  tempPinIDs.clear();
128  _log(COLONY__DEBUG, "Colony::Colony() c'tor called for %s(%u) by %s(%u)", pSE->GetName(), pSE->GetID(), pClient->GetName(), pClient->GetCharacterID());
129 }
bool m_loaded
Definition: Colony.h:105
#define _log(type, fmt,...)
Definition: logsys.h:124
virtual PlanetSE * GetPlanetSE()
Definition: SystemEntity.h:101
Client * m_client
Definition: Colony.h:98
int32 GetCharacterID() const
Definition: Client.h:113
bool m_newHead
Definition: Colony.h:106
int64 m_procTime
Definition: Colony.h:114
uint16 m_pg
Definition: Colony.h:110
std::map< uint8, uint32 > tempPinIDs
Definition: Colony.h:117
PlanetSE * m_pSE
Definition: Colony.h:96
uint32 GetID()
Definition: SystemEntity.h:207
bool m_toUpdate
Definition: Colony.h:107
uint16 m_cpu
Definition: Colony.h:111
const char * GetName() const
Definition: Client.h:94
Timer m_colonyTimer
Definition: Colony.h:100
const char * GetName() const
Definition: SystemEntity.h:210
PI_CCPin * ccPin
Definition: Colony.h:97
bool m_active
Definition: Colony.h:104
uint32 m_colonyID
Definition: Colony.h:112
PyServiceMgr * m_svcMgr
Definition: Colony.h:95
uint8 m_pLevel
Definition: Colony.h:109

Here is the call graph for this function:

Colony::~Colony ( )

Definition at line 131 of file Colony.cpp.

References ccPin, and SafeDelete().

132 {
133  SafeDelete(ccPin);
134 }
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
PI_CCPin * ccPin
Definition: Colony.h:97

Here is the call graph for this function:

Member Function Documentation

void Colony::AbandonColony ( )
Todo:
go thru entire pinMap and delete each itemRef to remove pin/link contents from db.

Definition at line 341 of file Colony.cpp.

References ccPin, InventoryItem::Delete(), PlanetDB::DeleteColony(), Timer::Disable(), Client::GetCharacterID(), SystemEntity::GetID(), PI_CCPin::links, m_client, m_colonyID, m_colonyTimer, m_db, m_pSE, PI_CCPin::pins, PlanetDB::RemoveContents(), PlanetDB::RemovePin(), SafeDelete(), and sItemFactory.

Referenced by PlanetSE::AbandonColony().

342 {
344  for (auto cur : ccPin->pins) {
345  m_db.RemovePin(cur.first);
346  m_db.RemoveContents(cur.first);
347  sItemFactory.RemoveItem(cur.first);
348  }
349  for (auto cur : ccPin->links) {
350  m_db.RemovePin(cur.first);
351  sItemFactory.RemoveItem(cur.first);
352  }
353  InventoryItemRef iRef = sItemFactory.GetItem(m_colonyID);
354  iRef->Delete();
356  SafeDelete(ccPin);
357  ccPin = new PI_CCPin();
358  m_colonyID = 0;
360 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
void Disable()
Definition: timer.h:39
Client * m_client
Definition: Colony.h:98
int32 GetCharacterID() const
Definition: Client.h:113
void RemoveContents(uint32 pinID)
Definition: PlanetDB.cpp:819
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
PlanetSE * m_pSE
Definition: Colony.h:96
uint32 GetID()
Definition: SystemEntity.h:207
PlanetDB m_db
Definition: Colony.h:102
Timer m_colonyTimer
Definition: Colony.h:100
std::map< uint32, PI_Link > links
Definition: EVE_Planet.h:237
PI_CCPin * ccPin
Definition: Colony.h:97
void RemovePin(uint32 pinID)
Definition: PlanetDB.cpp:793
void DeleteColony(uint32 ccPinID, uint32 planetID, uint32 charID)
Definition: PlanetDB.cpp:831
uint32 m_colonyID
Definition: Colony.h:112
virtual void Delete()
#define sItemFactory
Definition: ItemFactory.h:165

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::AddExtractorHead ( uint32  ecuID,
uint16  headID,
double  latitude,
double  longitude 
)

Definition at line 707 of file Colony.cpp.

References _log, ccPin, PI_Heads::ecuPinID, PI_Heads::latitude, PI_Heads::longitude, m_newHead, PI_CCPin::pins, tempECUs, and PI_Heads::typeID.

Referenced by PlanetMgr::AddExtractorHead().

708 {
709  std::map<uint32, PI_Pin>::iterator itr = ccPin->pins.find(ecuID);
710  if (itr != ccPin->pins.end()) {
711  m_newHead = true;
712  tempECUs.push_back(ecuID);
713  PI_Heads head = PI_Heads();
714  head.typeID = itr->second.schematicID;
715  head.ecuPinID = ecuID;
716  head.latitude = latitude;
717  head.longitude = longitude;
718  itr->second.heads[headID] = head;
719  } else {
720  _log(COLONY__ERROR, "Colony::AddExtractorHead() - ecuID %u not found in ccPin.pins map", ecuID);
721  }
722 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
#define _log(type, fmt,...)
Definition: logsys.h:124
uint16 typeID
Definition: EVE_Planet.h:136
bool m_newHead
Definition: Colony.h:106
uint32 ecuPinID
Definition: EVE_Planet.h:137
double latitude
Definition: EVE_Planet.h:138
double longitude
Definition: EVE_Planet.h:139
std::vector< uint32 > tempECUs
Definition: Colony.h:116
PI_CCPin * ccPin
Definition: Colony.h:97

Here is the caller graph for this function:

void Colony::CreateCommandPin ( uint32  itemID,
uint32  typeID,
double  latitude,
double  longitude 
)

Definition at line 362 of file Colony.cpp.

References PlanetDB::AddPlanetForChar(), ccPin, PI_CCPin::ccPinID, EVEDB::invGroups::Command_Centers, CreatePin(), Client::GetCharacterID(), GetFileTimeNow(), SystemManager::GetID(), SystemEntity::GetID(), SystemEntity::GetTypeID(), itemID(), PI_CCPin::level, PI::Pin::Level0, m_client, m_colonyID, m_db, m_procTime, m_pSE, PlanetDB::SaveCommandCenter(), PlanetDB::SavePins(), and SystemEntity::SystemMgr().

Referenced by PlanetMgr::CreatePin().

362  {
363  m_colonyID = itemID;
364  ccPin->ccPinID = itemID;
365  m_db.SaveCommandCenter(itemID, m_client->GetCharacterID(), m_pSE->GetID(), typeID, latitude, longitude);
369  CreatePin(EVEDB::invGroups::Command_Centers, itemID, typeID, latitude, longitude);
371 }
void SavePins(PI_CCPin *ccPin)
Definition: PlanetDB.cpp:442
void SaveCommandCenter(uint32 pinID, uint32 charID, uint32 planetID, uint32 typeID, double latitude, double longitude)
Definition: PlanetDB.cpp:420
uint8 level
Definition: EVE_Planet.h:231
Client * m_client
Definition: Colony.h:98
void CreatePin(uint32 groupID, uint32 pinID, uint32 typeID, double latitude, double longitude)
Definition: Colony.cpp:373
int32 GetCharacterID() const
Definition: Client.h:113
uint32 GetID() const
Definition: SystemManager.h:80
int64 m_procTime
Definition: Colony.h:114
SystemManager * SystemMgr()
Definition: SystemEntity.h:196
PlanetSE * m_pSE
Definition: Colony.h:96
uint32 GetID()
Definition: SystemEntity.h:207
PlanetDB m_db
Definition: Colony.h:102
uint32 ccPinID
Definition: EVE_Planet.h:232
PI_CCPin * ccPin
Definition: Colony.h:97
double GetFileTimeNow()
Definition: utils_time.cpp:84
void AddPlanetForChar(uint32 solarSystemID, uint32 planetID, uint32 charID, uint32 ccPinID, uint16 typeID)
Definition: PlanetDB.cpp:90
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
uint32 m_colonyID
Definition: Colony.h:112
uint16 GetTypeID()
Definition: SystemEntity.h:203

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::CreateLink ( uint32  src,
uint32  dest,
uint16  level 
)

Definition at line 477 of file Colony.cpp.

References _log, ccPin, PI_Link::endpoint1, PI_Link::endpoint2, flagNone, flagPlanetSurface, Client::GetCharacterID(), SystemEntity::GetID(), PI::Pin::State::Idle, IsTempPinID, PI_Link::level, PI_CCPin::links, locTemp, m_client, m_db, m_pSE, PlanetDB::SaveLinks(), sItemFactory, PI_Link::state, tempPinIDs, and PI_Link::typeID.

Referenced by PlanetMgr::CreateLink().

477  {
478  if (IsTempPinID(src) and (tempPinIDs.size() > 0)) {
479  std::map<uint8, uint32>::iterator itr = tempPinIDs.find(src);
480  if (itr != tempPinIDs.end())
481  src = itr->second;
482  }
483  if (IsTempPinID(dest) and (tempPinIDs.size() > 0)) {
484  std::map<uint8, uint32>::iterator itr = tempPinIDs.find(dest);
485  if (itr != tempPinIDs.end())
486  dest = itr->second;
487  }
488  ItemData data(2280, m_client->GetCharacterID(), locTemp, flagNone, 1);
489  InventoryItemRef iRef = sItemFactory.SpawnItem(data);
490  iRef->Move(m_pSE->GetID(), flagPlanetSurface, true);
491  iRef->SaveItem();
492 
493  PI_Link link = PI_Link();
495  link.level = level;
496  link.endpoint1 = src;
497  link.endpoint2 = dest;
498  link.typeID = 2280; // Only link type in the game.
499  ccPin->links[iRef->itemID()] = link;
500 
502  _log(COLONY__INFO, "Colony::CreateLink() - Created link - id:%u, src:%u, dest:%u, level:%u", iRef->itemID(), src, dest, level);
503 }
#define _log(type, fmt,...)
Definition: logsys.h:124
Client * m_client
Definition: Colony.h:98
#define IsTempPinID(pinID)
Definition: EVE_Defines.h:194
int32 GetCharacterID() const
Definition: Client.h:113
std::map< uint8, uint32 > tempPinIDs
Definition: Colony.h:117
PlanetSE * m_pSE
Definition: Colony.h:96
uint32 GetID()
Definition: SystemEntity.h:207
PlanetDB m_db
Definition: Colony.h:102
void SaveLinks(PI_CCPin *ccPin)
Definition: PlanetDB.cpp:626
std::map< uint32, PI_Link > links
Definition: EVE_Planet.h:237
PI_CCPin * ccPin
Definition: Colony.h:97
#define sItemFactory
Definition: ItemFactory.h:165

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::CreatePin ( uint32  groupID,
uint32  pinID,
uint32  typeID,
double  latitude,
double  longitude 
)
Todo:
will have to write code for effects and checks for pg/cpu/m3/etc for all of these.

Definition at line 373 of file Colony.cpp.

References _log, AttrPinExtractionQuantity, EVEDB::invGroups::Capsuleer_Bases, ccPin, InventoryItem::ChangeSingleton(), EVEDB::invGroups::Command_Centers, EVEDB::invGroups::Extractor_Control_Units, EVEDB::invGroups::Extractors, flagCargoHold, flagNone, flagPlanetSurface, EvilNumber::get_int(), InventoryItem::GetAttribute(), Client::GetCharacterID(), GetFileTimeNow(), SystemEntity::GetID(), Client::GetShip(), Client::GetShipID(), PI::Pin::State::Idle, PI_Pin::installTime, PI_Pin::isBase, PI_Pin::isCommandCenter, PI_Pin::isECU, PI_Pin::isLaunchable, PI_Pin::isProcess, PI_Pin::isStorage, InventoryItem::itemID(), PI_Pin::lastRunTime, PI_Pin::latitude, locTemp, PI_Pin::longitude, m_client, m_colonyID, m_pSE, EVEDB::invGroups::Mercenary_Bases, InventoryItem::Move(), InventoryItem::name(), PI_Pin::ownerID, PI_CCPin::pins, EVEDB::invGroups::Planetary_Links, PI_CCPin::plants, EVEDB::invGroups::Processors, PI_Pin::qtyPerCycle, InventoryItem::quantity(), ShipItem::RemoveItem(), InventoryItem::SetQuantity(), sItemFactory, EVEDB::invGroups::Spaceports, PI_Pin::state, EVEDB::invGroups::Storage_Facilities, tempPinIDs, and PI_Pin::typeID.

Referenced by CreateCommandPin(), and PlanetMgr::CreatePin().

373  {
375  // maybe not...client checks before sending command
376  using namespace EVEDB::invGroups;
377  PI_Pin pin = PI_Pin();
378  InventoryItemRef iRef(nullptr);
379  if (groupID == Command_Centers) {
380  iRef = sItemFactory.GetItem(m_colonyID);
381  if (iRef->quantity() > 1) {
382  // check for stack of CC items, and split as needed
383  ItemData data(typeID, m_client->GetCharacterID(), locTemp, flagNone, iRef->quantity() -1);
384  InventoryItemRef iRef2 = sItemFactory.SpawnItem(data);
385  iRef2->Move(m_client->GetShipID(), flagCargoHold);
386  iRef->SetQuantity(1);
387  }
388  m_client->GetShip()->RemoveItem(iRef);
389  } else {
390  // type, owner, location, flag, qty
391  ItemData data(typeID, m_client->GetCharacterID(), m_pSE->GetID(), flagNone, 1);
392  iRef = sItemFactory.SpawnItem(data);
393 
394  /* this shit doesnt work....changes arent sent to client. not sure why
395  m_pg = iRef->GetAttribute(AttrPowerLoad).get_int();
396  m_cpu = iRef->GetAttribute(AttrCpuLoad).get_int();
397  if (groupID != Planetary_Links) {
398  // reset pg/cpu needs based on char skills for all modules (ex links)
399  m_pg *= (1 - ( 0.05f * (m_client->GetChar()->GetSkillLevel(EvESkill::Engineering, true)))); // 5% decrease in need
400  m_pg *= (1 - ( 0.01f * (m_client->GetChar()->GetSkillLevel(EvESkill::EnergyManagement, true)))); // 1% decrease in need
401  m_pg *= (1 - ( 0.01f * (m_client->GetChar()->GetSkillLevel(EvESkill::CommandCenterUpgrades, true)))); // 1% decrease in need
402  m_pg *= (1 - ( 0.01f * (m_client->GetChar()->GetSkillLevel(EvESkill::EnergySystemsOperation, true)))); // 1% decrease in need
403 
404  m_cpu *= (1 - ( 0.05f * (m_client->GetChar()->GetSkillLevel(EvESkill::Electronics, true)))); // 5% decrease in need
405  m_cpu *= (1 - ( 0.01f * (m_client->GetChar()->GetSkillLevel(EvESkill::CommandCenterUpgrades, true)))); // 1% decrease in need
406  } */
407  }
408 
409  pin.typeID = typeID;
411  pin.latitude = latitude;
412  pin.longitude = longitude;
414 
415  switch(groupID) {
416  case Command_Centers: { // 1027
417  pin.isStorage = true;
418  pin.isLaunchable = true;
419  pin.isCommandCenter = true;
420  pin.lastRunTime = GetFileTimeNow();
421  pin.installTime = GetFileTimeNow(); // pin creation time here.
422  } break;
423  case Processors: { // 1028
424  pin.isStorage = true;
425  pin.isProcess = true;
426  pin.lastRunTime = 0;
427  PI_Plant plant = PI_Plant();
428  ccPin->plants[iRef->itemID()] = plant;
429  } break;
430  case Extractor_Control_Units: { // 1063
431  pin.isECU = true;
432  pin.lastRunTime = 0;
433  pin.qtyPerCycle = (uint16)iRef->GetAttribute(AttrPinExtractionQuantity).get_int();
434  } break;
435  case Spaceports:{ // 1030
436  pin.isStorage = true;
437  pin.isLaunchable = true;
438  pin.installTime = GetFileTimeNow(); // pin creation time here.
439  } break;
440  case Storage_Facilities: { // 1029
441  pin.isStorage = true;
442  pin.installTime = GetFileTimeNow(); // pin creation time here.
443  } break;
444  case Mercenary_Bases:
445  case Capsuleer_Bases: {
446  pin.isBase = true;
447  pin.installTime = GetFileTimeNow(); // pin creation time here.
448  /* nothing to do yet */
449  } break;
450  case Planetary_Links: // 1036
451  case Extractors: { // 1026
452  /* make error. should never get here. these are NOT pins */
453  /*
454  m_cpu = iRef->GetAttribute().get_int();
455  1633 powerLoadPerKm NULL 0.15
456  1634 cpuLoadPerKm NULL 0.2
457  1635 cpuLoadLevelModifier NULL 1.4
458  1636 powerLoadLevelModifier NULL 1.2
459  */
460  } break;
461  }
462 
463  iRef->Move(m_pSE->GetID(), flagPlanetSurface, true);
464  iRef->ChangeSingleton(true);
465  // cannot change attributes on PI items..... :(
466  //iRef->SetAttribute(AttrCpuLoad, m_cpu);
467  //iRef->SetAttribute(AttrPowerLoad, m_pg);
468 
469  ccPin->pins[iRef->itemID()] = pin;
470 
471  if (groupID != Command_Centers)
472  tempPinIDs.insert(std::pair<uint8, uint32>(pinID, iRef->itemID())); // save map of tempID to itemID - this handles the stacked-calls from client to use real itemIDs
473 
474  _log(COLONY__INFO, "Colony::CreatePin() - Created pin for %s(%u)", iRef->name(), iRef->itemID());
475 }
uint32 GetShipID() const
Definition: Client.h:150
float longitude
Definition: EVE_Planet.h:197
bool isBase
Definition: EVE_Planet.h:172
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
bool isLaunchable
Definition: EVE_Planet.h:176
#define _log(type, fmt,...)
Definition: logsys.h:124
bool isCommandCenter
Definition: EVE_Planet.h:177
Client * m_client
Definition: Colony.h:98
uint32 ownerID
Definition: EVE_Planet.h:189
uint32 qtyPerCycle
Definition: EVE_Planet.h:188
int32 GetCharacterID() const
Definition: Client.h:113
std::map< uint32, PI_Plant > plants
Definition: EVE_Planet.h:241
int64 lastRunTime
Definition: EVE_Planet.h:190
bool isECU
Definition: EVE_Planet.h:171
float latitude
Definition: EVE_Planet.h:196
std::map< uint8, uint32 > tempPinIDs
Definition: Colony.h:117
bool isStorage
Definition: EVE_Planet.h:173
uint16 typeID
Definition: EVE_Planet.h:185
PlanetSE * m_pSE
Definition: Colony.h:96
uint32 GetID()
Definition: SystemEntity.h:207
bool isProcess
Definition: EVE_Planet.h:174
ShipItemRef GetShip() const
Definition: Client.h:167
PI_CCPin * ccPin
Definition: Colony.h:97
double GetFileTimeNow()
Definition: utils_time.cpp:84
int64 installTime
Definition: EVE_Planet.h:193
virtual void RemoveItem(InventoryItemRef iRef)
Definition: Ship.cpp:532
int8 state
Definition: EVE_Planet.h:183
uint32 m_colonyID
Definition: Colony.h:112
#define sItemFactory
Definition: ItemFactory.h:165
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 Colony::CreateRoute ( uint16  routeID,
uint32  typeID,
uint32  qty,
PyList path 
)

Definition at line 505 of file Colony.cpp.

References _log, PyRep::AsTuple(), ccPin, PI_Route::commodityQuantity, PI_Route::commodityTypeID, PI_Route::destPinID, PyTuple::GetItem(), PyList::GetItem(), PI::Pin::State::Idle, PyRep::IntegerValue(), PyRep::IsInt(), IsTempPinID, PyRep::IsTuple(), m_colonyID, m_db, m_destRoutes, m_srcRoutes, m_toUpdate, PI_Route::path, PI_CCPin::pins, PI_CCPin::plants, PI_Route::priority, PI::Route::PriorityNorm, PI_CCPin::routes, PlanetDB::SaveRoute(), PyList::size(), PI_Route::srcPinID, PI_Route::state, tempPinIDs, and PyRep::TypeString().

Referenced by PlanetMgr::CreateRoute().

505  {
506  // routeID is sent as tempID like pins.
507  std::list<uint32> list1;
508  list1.clear();
509  for (size_t i = 0; i < path->size(); ++i) {
510  if (path->GetItem(i)->IsTuple()) {
511  list1.push_back(PyRep::IntegerValue(path->GetItem(i)->AsTuple()->GetItem(1)));
512  } else if (path->GetItem(i)->IsInt()) {
513  list1.push_back(PyRep::IntegerValue(path->GetItem(i)));
514  } else {
515  _log(COLONY__ERROR, "Colony::CreateRoute() - List item type unrecognized: %s", path->GetItem(1)->TypeString());
516  }
517  }
518 
519  if (tempPinIDs.size() > 0) {
520  std::list<uint32> list2;
521  list2.clear();
522  std::map<uint8, uint32>::iterator itr;
523  for (auto cur : list1) {
524  if (IsTempPinID(cur)) {
525  itr = tempPinIDs.find(cur);
526  if (itr != tempPinIDs.end())
527  list2.push_back(itr->second);
528  } else {
529  list2.push_back(cur);
530  }
531  }
532  list1.clear();
533  list1 = list2;
534  }
535 
536  PI_Route route = PI_Route();
537  route.state = PI::Pin::State::Idle;
539  route.commodityTypeID = typeID;
540  route.commodityQuantity = qty;
541  route.srcPinID = list1.front();
542  route.destPinID = list1.back();
543  route.path = list1;
544 
545  routeID = m_db.SaveRoute(m_colonyID, route);
546  ccPin->routes[routeID] = route;
547 
548  m_srcRoutes.emplace(route.srcPinID, route);
549  m_destRoutes.emplace(route.destPinID, route);
550 
551  _log(COLONY__INFO, "Colony::CreateRoute() - Created route id %u for %u of typeID %u, making %u hops.", routeID, qty, typeID, (uint32)path->size() -1);
552 
553  // route has been created and added to list. check for materials being moved, and if source has the mat, remove qty and send to dest.
554  std::map<uint32, PI_Pin>::iterator srcPin = ccPin->pins.find(route.srcPinID);
555  if (srcPin == ccPin->pins.end())
556  return; // source not found. make error here.
557  std::map<uint32, PI_Pin>::iterator destPin = ccPin->pins.find(route.destPinID);
558  if (destPin == ccPin->pins.end())
559  return; // destination not found. make error here.
560  std::map<uint16, uint32>::iterator itr = srcPin->second.contents.find(route.commodityTypeID);
561  if (itr == srcPin->second.contents.end())
562  return; // this material wasnt found in source container....cant move what we aint got..
563 
564  uint32 amount = route.commodityQuantity;
565  // remove contents from storage pin
566  if (itr->second > amount) {
567  itr->second -= amount;
568  } else {
569  amount = itr->second;
570  srcPin->second.contents.erase(itr);
571  }
572  srcPin->second.update = true;
573 
574  // add contents to dest pin if we have any
575  itr = destPin->second.contents.find(route.commodityTypeID);
576  if (itr != destPin->second.contents.end()) {
577  itr->second += amount;
578  } else {
579  destPin->second.contents[route.commodityTypeID] = amount;
580  }
581  destPin->second.update = true;
582  // we have received a material from this route. enable check for all required materials for this Schematic
583  if (destPin->second.isProcess) {
584  std::map<uint32, PI_Plant>::iterator plantPin = ccPin->plants.find(destPin->first);
585  if (plantPin != ccPin->plants.end())
586  plantPin->second.hasReceivedInputs = true;
587  }
588  m_toUpdate = true;
589 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
std::map< uint16, PI_Route > routes
Definition: EVE_Planet.h:239
PyTuple * AsTuple()
Definition: PyRep.h:138
std::list< uint32 > path
Definition: EVE_Planet.h:132
int8 priority
Definition: EVE_Planet.h:127
#define _log(type, fmt,...)
Definition: logsys.h:124
uint16 commodityQuantity
Definition: EVE_Planet.h:129
PyRep * GetItem(size_t index) const
Returns Python object.
Definition: PyRep.h:602
bool IsTuple() const
Definition: PyRep.h:108
#define IsTempPinID(pinID)
Definition: EVE_Defines.h:194
uint16 SaveRoute(uint32 ccPinID, PI_Route &route)
Definition: PlanetDB.cpp:667
PyRep * GetItem(size_t index) const
Returns Python object.
Definition: PyRep.h:674
std::map< uint32, PI_Plant > plants
Definition: EVE_Planet.h:241
uint16 commodityTypeID
Definition: EVE_Planet.h:128
uint32 srcPinID
Definition: EVE_Planet.h:130
int8 state
Definition: EVE_Planet.h:126
std::map< uint8, uint32 > tempPinIDs
Definition: Colony.h:117
std::multimap< uint32, PI_Route > m_destRoutes
Definition: Colony.h:123
bool m_toUpdate
Definition: Colony.h:107
PlanetDB m_db
Definition: Colony.h:102
unsigned __int32 uint32
Definition: eve-compat.h:50
PI_CCPin * ccPin
Definition: Colony.h:97
size_t size() const
Definition: PyRep.h:663
uint32 m_colonyID
Definition: Colony.h:112
bool IsInt() const
Definition: PyRep.h:100
std::multimap< uint32, PI_Route > m_srcRoutes
Definition: Colony.h:121
static int64 IntegerValue(PyRep *pRep)
Definition: PyRep.cpp:118
uint32 destPinID
Definition: EVE_Planet.h:131
const char * TypeString() const
Definition: PyRep.cpp:76

Here is the call graph for this function:

Here is the caller graph for this function:

PyRep * Colony::GetColony ( )

Definition at line 1313 of file Colony.cpp.

References _log, args, ccPin, PyRep::Dump(), Client::GetCharacterID(), GetLinks(), GetPins(), GetRoutes(), is_log_enabled, PI_CCPin::level, m_client, m_colonyID, m_db, m_newHead, m_procTime, PI_CCPin::pins, PlanetDB::SaveHeads(), PyDict::SetItem(), tempECUs, tempPinIDs, and Update().

Referenced by PlanetMgrBound::m_planet(), and PlanetMgr::UpdateNetwork().

1314 {
1315  if (m_newHead) {
1316  for (auto cur : tempECUs) {
1317  std::map<uint32, PI_Pin>::iterator itr = ccPin->pins.find(cur);
1318  if (itr != ccPin->pins.end()) {
1319  m_db.SaveHeads(m_colonyID, m_client->GetCharacterID(), cur, itr->second.heads);
1320  } else {
1321  _log(COLONY__ERROR, "Colony::GetColony()::SaveHeads() - headID %u not found in ccPin.pins map", cur);
1322  }
1323  }
1324  tempECUs.clear();
1325  m_newHead = false;
1326  }
1327 
1328  Update(); // update colony before sending data.
1329 
1330  PyDict* args = new PyDict();
1331  args->SetItem("pins", GetPins());
1332  args->SetItem("level", new PyInt(ccPin->level));
1333  args->SetItem("links", GetLinks());
1334  args->SetItem("routes", GetRoutes());
1335  args->SetItem("currentSimTime", new PyLong(m_procTime));
1336  PyObject* res = new PyObject("util.KeyVal", args);
1337 
1338  if (is_log_enabled(COLONY__GC_DUMP)) {
1339  _log(COLONY__GC_DUMP, "Colony::GetColony() Dump");
1340  res->Dump(COLONY__GC_DUMP, " ");
1341  }
1342 
1343  // reset tempPinID-to-newPinID map after command loop is completed and all new pins have been created.
1344  tempPinIDs.clear();
1345 
1346  return res;
1347 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
#define _log(type, fmt,...)
Definition: logsys.h:124
Python's dictionary.
Definition: PyRep.h:719
uint8 level
Definition: EVE_Planet.h:231
void SaveHeads(uint32 ccPinID, uint32 ownerID, uint32 ecuID, std::map< uint16, PI_Heads > &heads)
Definition: PlanetDB.cpp:595
Client * m_client
Definition: Colony.h:98
int32 GetCharacterID() const
Definition: Client.h:113
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
bool m_newHead
Definition: Colony.h:106
PyTuple * GetLinks()
Definition: Colony.cpp:1277
* args
void Update(bool updateTimes=false)
Definition: Colony.cpp:1349
#define is_log_enabled(type)
Definition: logsys.h:78
int64 m_procTime
Definition: Colony.h:114
PyTuple * GetRoutes()
Definition: Colony.cpp:1293
Python object.
Definition: PyRep.h:826
std::map< uint8, uint32 > tempPinIDs
Definition: Colony.h:117
Python integer.
Definition: PyRep.h:231
PlanetDB m_db
Definition: Colony.h:102
std::vector< uint32 > tempECUs
Definition: Colony.h:116
PI_CCPin * ccPin
Definition: Colony.h:97
PyTuple * GetPins()
Definition: Colony.cpp:1206
uint32 m_colonyID
Definition: Colony.h:112
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713
Python long integer.
Definition: PyRep.h:261

Here is the call graph for this function:

Here is the caller graph for this function:

int8 Colony::GetLevel ( )
inline

Definition at line 91 of file Colony.h.

References ccPin, and PI_CCPin::level.

Referenced by PlanetSE::GetPlanetInfo(), and PlanetMgr::UpgradeCommandCenter().

91 { return ccPin->level; }
uint8 level
Definition: EVE_Planet.h:231
PI_CCPin * ccPin
Definition: Colony.h:97

Here is the caller graph for this function:

PyTuple * Colony::GetLinks ( )

Definition at line 1277 of file Colony.cpp.

References ccPin, PI_CCPin::links, PyTuple::SetItem(), and PyDict::SetItem().

Referenced by GetColony(), and PlanetSE::GetPlanetInfo().

1278 {
1279  uint8 index = 0;
1280  PyTuple* links = new PyTuple(ccPin->links.size());
1281  for (auto cur : ccPin->links) {
1282  PyDict* dict = new PyDict();
1283  dict->SetItem("linkID", new PyInt(cur.first)); // this is link itemID
1284  dict->SetItem("endpoint1", new PyInt(cur.second.endpoint1));
1285  dict->SetItem("endpoint2", new PyInt(cur.second.endpoint2));
1286  dict->SetItem("level", new PyInt(cur.second.level));
1287  dict->SetItem("typeID", new PyInt(cur.second.typeID)); // typeID 2280
1288  links->SetItem(index++, new PyObject("util.KeyVal", dict));
1289  }
1290  return links;
1291 }
unsigned __int8 uint8
Definition: eve-compat.h:46
Python's dictionary.
Definition: PyRep.h:719
Python tuple.
Definition: PyRep.h:567
Python object.
Definition: PyRep.h:826
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:610
Python integer.
Definition: PyRep.h:231
std::map< uint32, PI_Link > links
Definition: EVE_Planet.h:237
PI_CCPin * ccPin
Definition: Colony.h:97
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713

Here is the call graph for this function:

Here is the caller graph for this function:

uint32 Colony::GetOwner ( )

Definition at line 249 of file Colony.cpp.

References Client::GetCharacterID(), and m_client.

Referenced by PlanetSE::AbandonColony().

250 {
251  return m_client->GetCharacterID();
252 }
Client * m_client
Definition: Colony.h:98
int32 GetCharacterID() const
Definition: Client.h:113

Here is the call graph for this function:

Here is the caller graph for this function:

PyTuple * Colony::GetPins ( )

Definition at line 1206 of file Colony.cpp.

References PyList::AddItem(), ccPin, PyList::clear(), PyDict::clear(), EvE::Time::Hour, PI_CCPin::pins, PI_CCPin::plants, PyStatic, PyTuple::SetItem(), and PyDict::SetItem().

Referenced by GetColony(), and PlanetSE::GetPlanetInfo().

1207 {
1208  uint8 index = 0;
1209  PyTuple* pins = new PyTuple(ccPin->pins.size());
1210 
1211  for (auto cur : ccPin->pins) {
1212  PyDict* dict = new PyDict();
1213  dict->SetItem("id", new PyInt(cur.first));
1214  dict->SetItem("typeID", new PyInt(cur.second.typeID));
1215  dict->SetItem("ownerID", new PyInt(cur.second.ownerID));
1216  dict->SetItem("latitude", new PyFloat(cur.second.latitude));
1217  dict->SetItem("longitude", new PyFloat(cur.second.longitude));
1218  dict->SetItem("lastRunTime", (cur.second.lastRunTime > 0 ? new PyLong(cur.second.lastRunTime) : PyStatic.NewNone()));
1219  dict->SetItem("state", new PyInt(cur.second.state));
1220  dict->SetItem("level", new PyInt(cur.second.level));
1221 
1222  PyDict* contents = new PyDict();
1223  contents->clear();
1224  if (cur.second.isStorage)
1225  for (auto cur2 : cur.second.contents)
1226  contents->SetItem(new PyInt(cur2.first), new PyInt(cur2.second));
1227  dict->SetItem("contents", contents);
1228 
1229  if (cur.second.isLaunchable)
1230  dict->SetItem("lastLaunchTime", (cur.second.lastLaunchTime > 0 ? new PyLong(cur.second.lastLaunchTime) : PyStatic.NewNone()));
1231 
1232  if (cur.second.isProcess)
1233  if (cur.second.schematicID) {
1234  dict->SetItem("schematicID", new PyInt(cur.second.schematicID));
1235  std::map<uint32, PI_Plant>::iterator plantPin = ccPin->plants.find(cur.first);
1236  if (plantPin != ccPin->plants.end()) {
1237  dict->SetItem("cycleTime", new PyLong(plantPin->second.cycleTime));
1238  dict->SetItem("hasReceivedInputs", new PyBool(plantPin->second.hasReceivedInputs));
1239  dict->SetItem("receivedInputsLastCycle", new PyBool(plantPin->second.receivedInputsLastCycle));
1240  } else {
1241  dict->SetItem("cycleTime", PyStatic.NewZero());
1242  dict->SetItem("hasReceivedInputs", PyStatic.NewFalse());
1243  dict->SetItem("receivedInputsLastCycle", PyStatic.NewFalse());
1244  }
1245  } else {
1246  dict->SetItem("cycleTime", PyStatic.NewZero());
1247  dict->SetItem("hasReceivedInputs", PyStatic.NewFalse());
1248  dict->SetItem("receivedInputsLastCycle", PyStatic.NewFalse());
1249  }
1250 
1251  if (cur.second.isECU) {
1252  if (cur.second.installTime > 0) {
1253  dict->SetItem("cycleTime", new PyFloat(cur.second.cycleTime / EvE::Time::Hour));
1254  dict->SetItem("expiryTime", new PyLong(cur.second.expiryTime));
1255  dict->SetItem("headRadius", new PyFloat(cur.second.headRadius));
1256  dict->SetItem("installTime", new PyLong(cur.second.installTime));
1257  dict->SetItem("programType", new PyInt(cur.second.programType));
1258  dict->SetItem("qtyPerCycle", new PyInt(cur.second.qtyPerCycle));
1259  }
1260  PyList* list = new PyList();
1261  list->clear();
1262  for (auto head : cur.second.heads) {
1263  PyTuple* tuple = new PyTuple(3);
1264  tuple->SetItem(0, new PyInt(head.first));
1265  tuple->SetItem(1, new PyFloat(head.second.latitude));
1266  tuple->SetItem(2, new PyFloat(head.second.longitude));
1267  list->AddItem(tuple);
1268  }
1269  dict->SetItem("heads", list);
1270  }
1271 
1272  pins->SetItem(index++, new PyObject("util.KeyVal", dict));
1273  }
1274  return pins;
1275 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
unsigned __int8 uint8
Definition: eve-compat.h:46
void clear()
Definition: PyRep.cpp:680
Python's dictionary.
Definition: PyRep.h:719
Python floating point number.
Definition: PyRep.h:292
Python tuple.
Definition: PyRep.h:567
void AddItem(PyRep *i)
Definition: PyRep.h:701
std::map< uint32, PI_Plant > plants
Definition: EVE_Planet.h:241
Python boolean.
Definition: PyRep.h:323
Python object.
Definition: PyRep.h:826
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:610
Python integer.
Definition: PyRep.h:231
#define PyStatic
Definition: PyRep.h:1209
void clear()
Definition: PyRep.cpp:627
PI_CCPin * ccPin
Definition: Colony.h:97
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713
Python list.
Definition: PyRep.h:639
Python long integer.
Definition: PyRep.h:261

Here is the call graph for this function:

Here is the caller graph for this function:

PyTuple * Colony::GetRoutes ( )

Definition at line 1293 of file Colony.cpp.

References PyList::AddItem(), ccPin, PI_CCPin::routes, PyTuple::SetItem(), and PyDict::SetItem().

Referenced by GetColony(), and PlanetSE::GetPlanetInfo().

1294 {
1295  uint8 index = 0;
1296  PyTuple* routes = new PyTuple(ccPin->routes.size());
1297 
1298  for (auto cur : ccPin->routes) {
1299  PyDict* dict = new PyDict();
1300  dict->SetItem("routeID", new PyInt(cur.first)); // this is routeID (low number - assigned by client)
1301  dict->SetItem("commodityTypeID", new PyInt(cur.second.commodityTypeID));
1302  dict->SetItem("commodityQuantity", new PyInt(cur.second.commodityQuantity));
1303 
1304  PyList* list = new PyList();
1305  for (auto cur2 : cur.second.path) // path of pinIDs this route will follow
1306  list->AddItem(new PyInt(cur2));
1307  dict->SetItem("path", list); // list of paths on this route
1308  routes->SetItem(index++, new PyObject("util.KeyVal", dict));
1309  }
1310  return routes;
1311 }
std::map< uint16, PI_Route > routes
Definition: EVE_Planet.h:239
unsigned __int8 uint8
Definition: eve-compat.h:46
Python's dictionary.
Definition: PyRep.h:719
Python tuple.
Definition: PyRep.h:567
void AddItem(PyRep *i)
Definition: PyRep.h:701
Python object.
Definition: PyRep.h:826
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:610
Python integer.
Definition: PyRep.h:231
PI_CCPin * ccPin
Definition: Colony.h:97
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:

Here is the caller graph for this function:

int64 Colony::GetSimTime ( )
inline

Definition at line 92 of file Colony.h.

References m_procTime.

Referenced by PlanetSE::GetPlanetInfo().

92 { return m_procTime; }
int64 m_procTime
Definition: Colony.h:114

Here is the caller graph for this function:

bool Colony::HasColony ( )
inline

Definition at line 89 of file Colony.h.

References ccPin, and PI_CCPin::ccPinID.

Referenced by PlanetSE::GetPlanetInfo().

89 { return (ccPin->ccPinID ? true : false); }
uint32 ccPinID
Definition: EVE_Planet.h:232
PI_CCPin * ccPin
Definition: Colony.h:97

Here is the caller graph for this function:

void Colony::Init ( )

Definition at line 142 of file Colony.cpp.

References ccPin, PI_CCPin::ccPinID, Client::GetCharacterID(), SystemEntity::GetID(), Load(), PlanetDB::LoadColony(), m_client, m_colonyID, m_db, m_loaded, m_pSE, and Update().

Referenced by PlanetMgrBound::m_planet().

143 {
144  if (m_loaded)
145  return;
146 
147  // check for and load colony if the char has one on this planet
150  Load();
151  }
152 
153  if (m_loaded)
154  Update();
155 }
bool m_loaded
Definition: Colony.h:105
Client * m_client
Definition: Colony.h:98
int32 GetCharacterID() const
Definition: Client.h:113
bool LoadColony(uint32 charID, uint32 planetID, PI_CCPin *ccPin)
Definition: PlanetDB.cpp:212
void Update(bool updateTimes=false)
Definition: Colony.cpp:1349
PlanetSE * m_pSE
Definition: Colony.h:96
uint32 GetID()
Definition: SystemEntity.h:207
PlanetDB m_db
Definition: Colony.h:102
uint32 ccPinID
Definition: EVE_Planet.h:232
PI_CCPin * ccPin
Definition: Colony.h:97
void Load()
Definition: Colony.cpp:164
uint32 m_colonyID
Definition: Colony.h:112

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::InstallProgram ( uint32  ecuID,
uint16  typeID,
float  headRadius,
PlanetMgr pPMgr 
)

Definition at line 794 of file Colony.cpp.

References _log, PI::Pin::State::Active, PyList::AddItem(), AttrPinExtractionQuantity, ccPin, GetFileTimeNow(), PI_CCPin::pins, sItemFactory, and sPIDataMgr.

Referenced by PlanetMgr::InstallProgram().

795 {
796  /*
797  * 09:54:54 [PlanetCallDump] [ 0] [10] [ 1] Tuple: 3 elements
798  * 09:54:54 [PlanetCallDump] [ 0] [10] [ 1] [ 0] Integer: 140000565 ecuID
799  * 09:54:54 [PlanetCallDump] [ 0] [10] [ 1] [ 1] Integer: 2272 typeID
800  * 09:54:54 [PlanetCallDump] [ 0] [10] [ 1] [ 2] Real: 0.011281 headRadius
801  */
802  std::map<uint32, PI_Pin>::iterator itr = ccPin->pins.find(ecuID);
803  if (itr == ccPin->pins.end()) {
804  _log(COLONY__ERROR, "Colony::InstallProgram() - ecuPinID %u not found in ccPin.pins map", ecuID);
805  return;
806  }
807  if (typeID < 1) {
808  // uninstall program
809  itr->second = PI_Pin();
810  // reset extraction quantity in ecu attrib. this doesnt check for invalid item
811  sItemFactory.GetItem(ecuID)->ResetAttribute(AttrPinExtractionQuantity);
812  return;
813  }
814  if (itr->second.programType != typeID) {
815  // is this installing a new program?
816  _log(COLONY__ERROR, "Colony::InstallProgram() - typeID %u does not match previously saved program. *edit* not sure wtf that means now.", typeID);
817  return;
818  }
819 
820  itr->second.state = PI::Pin::State::Active;
821  itr->second.headRadius = headRadius;
822  itr->second.installTime = GetFileTimeNow();
823  itr->second.lastRunTime = GetFileTimeNow();
824 
825  PyList* list = new PyList();
826  for (auto cur : itr->second.heads)
827  list->AddItem(new PyInt(cur.second.ecuPinID));
828  // set up extractor program data
829  sPIDataMgr.GetProgramResultInfo(this, ecuID, typeID, list, headRadius);
830 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
#define _log(type, fmt,...)
Definition: logsys.h:124
#define sPIDataMgr
Definition: PlanetDataMgr.h:79
void AddItem(PyRep *i)
Definition: PyRep.h:701
Python integer.
Definition: PyRep.h:231
PI_CCPin * ccPin
Definition: Colony.h:97
double GetFileTimeNow()
Definition: utils_time.cpp:84
#define sItemFactory
Definition: ItemFactory.h:165
Python list.
Definition: PyRep.h:639

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::KillExtractorHead ( uint32  ecuID,
uint16  headID 
)

Definition at line 743 of file Colony.cpp.

References _log, ccPin, and PI_CCPin::pins.

Referenced by PlanetMgr::KillExtractorHead().

744 {
745  std::map<uint32, PI_Pin>::iterator itr = ccPin->pins.find(ecuID);
746  if (itr != ccPin->pins.end()) {
747  itr->second.heads.erase(headID);
748  } else {
749  _log(COLONY__ERROR, "Colony::KillExtractorHead() - ecuID %u not found in ccPin.pins map", ecuID);
750  }
751 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
#define _log(type, fmt,...)
Definition: logsys.h:124
PI_CCPin * ccPin
Definition: Colony.h:97

Here is the caller graph for this function:

PyRep * Colony::LaunchCommodities ( uint32  pinID,
std::map< uint16, uint32 > &  items 
)
Todo:
check capacities before adding items

Definition at line 927 of file Colony.cpp.

References _log, FactionData::allianceID, Client::CanThrow(), Account::KeyType::Cash, ccPin, corpCONCORD, FactionData::corporationID, FactionData::factionID, flagNone, Client::GetAllianceID(), Client::GetCharacterID(), Client::GetCorporationID(), GetFileTimeNow(), SystemEntity::GetID(), Client::GetName(), SystemEntity::GetName(), SystemEntity::GetRadius(), Client::GetWarFactionID(), is_log_enabled, locTemp, m_client, m_colonyID, m_db, m_pSE, m_svcMgr, GPoint::MakeRandomPointOnSphere(), FactionData::ownerID, PI_CCPin::pins, Journal::EntryType::PlanetaryExportTax, EVEDB::invTypes::PlanetaryLaunchContainer, PlanetDB::SaveContents(), PlanetDB::SaveLaunch(), Client::SendErrorMsg(), sItemFactory, sPIDataMgr, SystemEntity::SystemMgr(), AccountService::TranserFunds(), Update(), and PlanetDB::UpdatePins().

928 {
929  // this will export items from CC to jetcan in space.
930  // launchpad (Spaceport) xfers items to/from customs office
931  std::map<uint32, PI_Pin>::iterator pin = ccPin->pins.find(pinID);
932  if (pin == ccPin->pins.end()) {
933  _log(COLONY__ERROR, "Colony::LaunchCommodities() - pinID %u not found in ccPin.pins map", pinID);
934  return nullptr;
935  }
936 
937  // first - create jetcan, add to system, and put in orbit around planet
938  // NOTE: PI launches have 5d timers
940  SystemManager* pSysMgr(m_pSE->SystemMgr());
941  GPoint location(pSysMgr->GetSE(m_pSE->GetID())->GetPosition());
942  location.MakeRandomPointOnSphere(m_pSE->GetRadius() + 2000000); //2000km orbit for launch can
944  m_client->GetCharacterID(), // owner is Character
945  pSysMgr->GetID(),
946  flagNone,
947  "PI Commodities Container",
948  location);
949 
950  CargoContainerRef contRef = sItemFactory.SpawnCargoContainer(canData);
951  if (contRef.get() == nullptr) {
952  contRef->Delete();
953  if (m_client->CanThrow())
954  throw CustomError ("Unable to spawn item of type %u.", EVEDB::invTypes::PlanetaryLaunchContainer);
955  }
956 
957  FactionData data = FactionData();
961  data.ownerID = m_client->GetCharacterID();
962  // create new container SE
963  ContainerSE* cSE = new ContainerSE(contRef, *m_svcMgr, pSysMgr, data);
964  contRef->SetMySE(cSE); // item-to-entity internal interface
965  //cSE->AnchorContainer(); // avoid GC checks on this container -no. has 5d timer set
966  pSysMgr->AddEntity(cSE);
967 
968  /* second - reduce qtys in source container (CC pin.contents in this case)
969  * create actual item (previously only virtual)
970  * add to container
971  * calculate taxes on items
972  * charge char taxes upon launch
973  */
974  uint8 count = 0;
975  double cost = 0;
976  for (auto cur : items) {
977  std::map<uint16, uint32>::iterator cont = pin->second.contents.find(cur.first);
978  if (cont != pin->second.contents.end()) {
979  if (cont->second > cur.second) {
980  cont->second -= cur.second;
981  } else {
982  pin->second.contents.erase(cont);
983  }
984  } else {
985  _log(COLONY__WARNING, "Colony::LaunchCommodities() - item %u not found in command center", cur.first);
986  }
987 
988  // if item not found in src contents, assume client is right and procede with xfer
989  switch (sPIDataMgr.GetProductLevel(cur.first)) {
990  case 0: cost += ( 0.15 * cur.second); break;
991  case 1: cost += ( 1.14 * cur.second); break;
992  case 2: cost += ( 13.50 * cur.second); break;
993  case 3: cost += ( 900.00 * cur.second); break;
994  case 4: cost += (75000.00 * cur.second); break;
995  }
996  ItemData iData(cur.first, m_client->GetCharacterID(), locTemp, flagNone, cur.second);
997  InventoryItemRef iRef = sItemFactory.SpawnItem(iData);
998  if (iRef.get() == nullptr)
999  continue;
1000  // verify we're not overloading container capy
1001  if (contRef->GetMyInventory()->HasAvailableSpace(flagNone, iRef)) {
1002  iRef->Move(cSE->GetID());
1003  iRef->SaveItem();
1004  ++count;
1005  } else {
1006  _log(COLONY__WARNING, "%s: PI Commodity Container %u is full.", m_client->GetName(), contRef->itemID());
1007  m_client->SendErrorMsg("Your Commodity Container is full. Some items were not transferred.");
1008  break;
1009  }
1010  }
1011 
1012  if (count)
1013  if (is_log_enabled(COLONY__TRACE))
1014  _log(COLONY__TRACE, "Colony::LaunchCommodities() - Launched %u items from command center %u to %s (%u)", \
1015  count, m_colonyID, contRef->name(), contRef->itemID() );
1016 
1017  contRef->SaveItem();
1018  pin->second.lastLaunchTime = GetFileTimeNow();
1019 
1020  // third - create db entry for launch
1021  m_db.SaveLaunch(contRef->itemID(), m_client->GetCharacterID(), pSysMgr->GetID(), m_pSE->GetID(), location);
1022 
1023  // update colony
1024  Update(true); // must update and save CC's lastLaunchTime here
1025  //do we do a full save here, or just update contents and times?
1026  //Save();
1027  m_db.UpdatePins(0, ccPin);
1029 
1030  // fourth - take taxes and record entry in journal
1031  if (cost) {
1032  //take the money, send wallet blink event record the transaction in their journal.
1033  std::string reason = "DESC: Launching PI items from ";
1034  reason += m_pSE->GetName();
1037  corpCONCORD, // pSysMgr->GetSovHolder(),
1038  cost,
1039  reason.c_str(),
1041  m_pSE->GetID(),
1043  }
1044 
1045  return new PyLong(pin->second.lastLaunchTime);
1046 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
unsigned __int8 uint8
Definition: eve-compat.h:46
void UpdatePins(uint32 pinID, PI_CCPin *ccPin)
Definition: PlanetDB.cpp:485
void SendErrorMsg(const char *fmt,...)
Definition: Client.cpp:2719
#define _log(type, fmt,...)
Definition: logsys.h:124
double GetRadius()
Definition: SystemEntity.h:208
void SaveLaunch(uint32 contID, uint32 charID, uint32 systemID, uint32 planetID, GPoint &pos)
Definition: PlanetDB.cpp:408
Client * m_client
Definition: Colony.h:98
#define sPIDataMgr
Definition: PlanetDataMgr.h:79
int32 GetCharacterID() const
Definition: Client.h:113
int32 GetWarFactionID() const
Definition: Client.h:126
int32 GetCorporationID() const
Definition: Client.h:123
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
int32 GetAllianceID() const
Definition: Client.h:125
void Update(bool updateTimes=false)
Definition: Colony.cpp:1349
#define is_log_enabled(type)
Definition: logsys.h:78
Definition: gpoint.h:33
SystemManager * SystemMgr()
Definition: SystemEntity.h:196
static void TranserFunds(uint32 fromID, uint32 toID, double amount, std::string reason="", uint8 entryTypeID=Journal::EntryType::Undefined, uint32 referenceID=0, uint16 fromKey=Account::KeyType::Cash, uint16 toKey=Account::KeyType::Cash, Client *pClient=nullptr)
bool CanThrow()
Definition: Client.h:431
PlanetSE * m_pSE
Definition: Colony.h:96
uint32 GetID()
Definition: SystemEntity.h:207
PlanetDB m_db
Definition: Colony.h:102
const char * GetName() const
Definition: Client.h:94
const char * GetName() const
Definition: SystemEntity.h:210
void SaveContents(PI_CCPin *ccPin)
Definition: PlanetDB.cpp:733
PI_CCPin * ccPin
Definition: Colony.h:97
uint32 corporationID
double GetFileTimeNow()
Definition: utils_time.cpp:84
uint32 m_colonyID
Definition: Colony.h:112
#define sItemFactory
Definition: ItemFactory.h:165
PyServiceMgr * m_svcMgr
Definition: Colony.h:95
void MakeRandomPointOnSphere(double radius)
Definition: gpoint.h:46
Python long integer.
Definition: PyRep.h:261

Here is the call graph for this function:

void Colony::Load ( )

Definition at line 164 of file Colony.cpp.

References ccPin, GetFileTimeNow(), PI_CCPin::links, PlanetDB::LoadLinks(), PlanetDB::LoadPins(), LoadPlants(), PlanetDB::LoadRoutes(), m_colonyID, m_db, m_destRoutes, m_loaded, m_procTime, m_srcRoutes, PI_CCPin::pins, PI_CCPin::routes, and Update().

Referenced by Init().

165 {
166  // redundant check
167  if (m_loaded) {
168  Update();
169  return;
170  }
171 
175 
176  LoadPlants();
177 
178  for (auto cur : ccPin->routes) {
179  m_srcRoutes.emplace(cur.second.srcPinID, cur.second);
180  m_destRoutes.emplace(cur.second.destPinID, cur.second);
181  }
182 
183  if (m_procTime < 1)
185 
186  if (!ccPin->pins.empty())
187  m_loaded = true;
188 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
std::map< uint16, PI_Route > routes
Definition: EVE_Planet.h:239
bool m_loaded
Definition: Colony.h:105
void LoadRoutes(uint32 ccPinID, std::map< uint16, PI_Route > &routes)
Definition: PlanetDB.cpp:316
void Update(bool updateTimes=false)
Definition: Colony.cpp:1349
int64 m_procTime
Definition: Colony.h:114
std::multimap< uint32, PI_Route > m_destRoutes
Definition: Colony.h:123
void LoadPins(uint32 ccPinID, std::map< uint32, PI_Pin > &pins)
Definition: PlanetDB.cpp:234
PlanetDB m_db
Definition: Colony.h:102
std::map< uint32, PI_Link > links
Definition: EVE_Planet.h:237
PI_CCPin * ccPin
Definition: Colony.h:97
double GetFileTimeNow()
Definition: utils_time.cpp:84
uint32 m_colonyID
Definition: Colony.h:112
std::multimap< uint32, PI_Route > m_srcRoutes
Definition: Colony.h:121
void LoadLinks(uint32 ccPinID, std::map< uint32, PI_Link > &links)
Definition: PlanetDB.cpp:290
void LoadPlants()
Definition: Colony.cpp:254

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::LoadPlants ( )

Definition at line 254 of file Colony.cpp.

References ccPin, PI_Schematic::cycleTime, PI_Plant::cycleTime, PI_Plant::data, Timer::Enabled(), GetFileTimeNow(), PI_Plant::hasReceivedInputs, EvE::Time::Hour, PI_Plant::installTime, PI_Plant::lastRunTime, m_colonyTimer, m_plantMap, m_pLevel, m_procTime, EvE::min(), PI_Schematic::outputQty, PI_Schematic::outputType, PI_CCPin::pins, PI_CCPin::plants, PI_Plant::pLevel, PI_Plant::qtyPerCycle, PI_Plant::receivedInputsLastCycle, PI_Plant::schematicID, EvE::Time::Second, sPIDataMgr, Timer::Start(), PI_Plant::state, and UpdatePlantPins().

Referenced by Load().

255 {
256  bool update = false;
257  for (auto cur: ccPin->pins) {
258  // set proc time on load
259  if (cur.second.isCommandCenter) {
260  m_procTime = cur.second.lastRunTime;
263  }
264 
265  // load plants in mem objects
266  if (cur.second.isProcess) {
267  PI_Plant plant = PI_Plant();
268  plant.data = PI_Schematic();
269  plant.state = cur.second.state;
270  plant.cycleTime = cur.second.cycleTime;
271  plant.installTime = cur.second.installTime;
272  plant.lastRunTime = cur.second.lastRunTime;
273  plant.schematicID = cur.second.schematicID;
274  plant.hasReceivedInputs = cur.second.hasReceivedInputs;
275  plant.receivedInputsLastCycle = cur.second.receivedInputsLastCycle;
276 
277  if (plant.schematicID) {
278  sPIDataMgr.GetSchematicData(plant.schematicID, plant.data);
279  plant.cycleTime = plant.data.cycleTime * EvE::Time::Second; // data.cycleTime is in seconds
280  plant.pLevel = sPIDataMgr.GetProductLevel(plant.data.outputType); // i am ordering plant processing by output's Plevel
281  plant.qtyPerCycle = plant.data.outputQty; // this is not saved
282 
283  if (cur.second.lastRunTime == 0) {
284  update = true;
285  cur.second.lastRunTime = GetFileTimeNow() - plant.cycleTime;
286  }
287  }
288 
290  ccPin->plants[cur.first] = plant;
291  m_plantMap.emplace(plant.pLevel, cur.first);
292  }
293 
294  }
295 
296  // set process timer to 30m
297  if (!m_colonyTimer.Enabled())
298  m_colonyTimer.Start(30*60*1000);
299 
300  if (update)
301  UpdatePlantPins();
302 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
uint16 outputQty
Definition: EVE_Planet.h:143
unsigned __int8 uint8
Definition: eve-compat.h:46
double min(double x, double y)
Definition: misc.h:95
#define sPIDataMgr
Definition: PlanetDataMgr.h:79
uint16 outputType
Definition: EVE_Planet.h:144
int64 installTime
Definition: EVE_Planet.h:162
int64 lastRunTime
Definition: EVE_Planet.h:163
int64 cycleTime
Definition: EVE_Planet.h:160
std::map< uint32, PI_Plant > plants
Definition: EVE_Planet.h:241
void UpdatePlantPins(uint32 pinID=0)
Definition: Colony.cpp:304
int64 m_procTime
Definition: Colony.h:114
bool Enabled() const
Definition: timer.h:41
uint16 qtyPerCycle
Definition: EVE_Planet.h:159
Timer m_colonyTimer
Definition: Colony.h:100
PI_CCPin * ccPin
Definition: Colony.h:97
int8 state
Definition: EVE_Planet.h:156
uint8 pLevel
Definition: EVE_Planet.h:157
double GetFileTimeNow()
Definition: utils_time.cpp:84
uint16 cycleTime
Definition: EVE_Planet.h:145
bool receivedInputsLastCycle
Definition: EVE_Planet.h:154
uint8 schematicID
Definition: EVE_Planet.h:158
std::multimap< uint8, uint32 > m_plantMap
Definition: Colony.h:119
bool hasReceivedInputs
Definition: EVE_Planet.h:153
PI_Schematic data
Definition: EVE_Planet.h:165
void Start(uint32 setTimerTime=0, bool changeResetTimer=true)
Definition: timer.cpp:81
uint8 m_pLevel
Definition: Colony.h:109

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::MoveExtractorHead ( uint32  ecuID,
uint16  headID,
double  latitude,
double  longitude 
)

Definition at line 724 of file Colony.cpp.

References _log, ccPin, m_newHead, PI_CCPin::pins, and tempECUs.

Referenced by PlanetMgr::MoveExtractorHead().

725 {
726  std::map<uint32, PI_Pin>::iterator itr = ccPin->pins.find(ecuID);
727  if (itr != ccPin->pins.end()) {
728  std::map<uint16, PI_Heads>::iterator head = itr->second.heads.find(headID);
729  if (head != itr->second.heads.end()) {
730  m_newHead = true;
731  tempECUs.push_back(ecuID);
732  // find head and update....
733  head->second.latitude = latitude;
734  head->second.longitude = longitude;
735  } else {
736  _log(COLONY__ERROR, "Colony::MoveExtractorHead() - headID %u not found in pin.heads map", headID);
737  }
738  } else {
739  _log(COLONY__ERROR, "Colony::MoveExtractorHead() - ecuID %u not found in ccPin.pins map", ecuID);
740  }
741 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
#define _log(type, fmt,...)
Definition: logsys.h:124
bool m_newHead
Definition: Colony.h:106
std::vector< uint32 > tempECUs
Definition: Colony.h:116
PI_CCPin * ccPin
Definition: Colony.h:97

Here is the caller graph for this function:

void Colony::PlanetXfer ( uint32  spaceportID,
std::map< uint32, uint16 importItems,
std::map< uint32, uint16 exportItems,
double  taxRate 
)
Todo:
check for available capy and adjust qty accordingly. if spaceport cant hold entire xfer qty, xfer to full, and return rest back to CO.

Definition at line 1048 of file Colony.cpp.

References _log, Client::CanThrow(), Account::KeyType::Cash, ccPin, flagHangar, flagNone, RefPtr< X >::get(), Client::GetCharacterID(), PlanetSE::GetCustomsOffice(), GetFileTimeNow(), SystemEntity::GetID(), SystemEntity::GetName(), SystemEntity::GetOwnerID(), is_log_enabled, locTemp, m_client, m_db, m_pSE, PI_CCPin::pins, Journal::EntryType::PlanetaryExportTax, Journal::EntryType::PlanetaryImportTax, PlanetDB::SaveContents(), EvE::Time::Second, sItemFactory, sPIDataMgr, InventoryItem::ToVirtual(), AccountService::TranserFunds(), InventoryItem::typeID(), Update(), and PlanetDB::UpdatePins().

1049 {
1050  // import is from CO to planet. export is from planet to CO
1051  // this method will make the transfer of items from real to virtual and back as necessary
1052 
1053  std::map<uint32, PI_Pin>::iterator pin = ccPin->pins.find(spaceportID);
1054  if (pin == ccPin->pins.end()) {
1055  _log(COLONY__ERROR, "Colony::PlanetXfer() - pinID %u not found in ccPin.pins map", spaceportID);
1056  if (m_client->CanThrow())
1057  throw CustomError ("Your SpacePort on %s was not found. Ref: ServerError xxxxx.", m_pSE->GetName());
1058 
1059  return;
1060  }
1061 
1062  if (pin->second.lastLaunchTime > GetFileTimeNow() + 30 * EvE::Time::Second) { // launch cycle time is 60s
1063  if (m_client->CanThrow())
1064  throw CustomError ("Your Launch crew on %s is still recovering from the last launch.", m_pSE->GetName());
1065 
1066  return;
1067  }
1068 
1069  uint8 toColony = 0, fromColony = 0;
1070  double cost = 0;
1071  InventoryItemRef iRef(nullptr);
1072  std::map<uint16, uint32>::iterator itr;
1073  // import
1074  for (auto cur : importItems) {
1075  // xfer real item to virtual
1076  iRef = sItemFactory.GetItem(cur.first);
1077  if (iRef.get() == nullptr) {
1078  _log(COLONY__ERROR, "Colony::PlanetXfer():import - itemRef for id %u not found in ItemFactory", cur.first);
1079  continue; // should never happen
1080  }
1081 
1082  itr = pin->second.contents.find(iRef->typeID());
1086  if (itr != pin->second.contents.end()) {
1087  itr->second += cur.second;
1088  } else {
1089  pin->second.contents[iRef->typeID()] = cur.second;
1090  }
1091 
1092  switch (sPIDataMgr.GetProductLevel(iRef->typeID())) {
1093  case 0: cost += ( 0.05 * cur.second); break;
1094  case 1: cost += ( 0.38 * cur.second); break;
1095  case 2: cost += ( 4.50 * cur.second); break;
1096  case 3: cost += ( 300.00 * cur.second); break;
1097  case 4: cost += (25000.00 * cur.second); break;
1098  }
1099  iRef->ToVirtual(spaceportID);
1100  ++toColony;
1101  }
1102 
1103  if (toColony)
1104  if (is_log_enabled(COLONY__TRACE))
1105  _log(COLONY__TRACE, "Colony::PlanetXfer() - Imported %u items from customs office %u to spaceport %u", \
1106  toColony, m_pSE->GetCustomsOffice()->GetID(), spaceportID);
1107 
1108  if (cost) {
1109  //take the money, send wallet blink event record the transaction in their journal.
1110  std::string reason = "DESC: Importing items to ";
1111  reason += m_pSE->GetName();
1115  cost,
1116  reason.c_str(),
1118  m_pSE->GetID(),
1120  }
1121 
1122  // reset cost for possible export taxes
1123  cost = 0;
1124  // export
1125  for (auto cur : exportItems) {
1126  std::map<uint16, uint32>::iterator cont = pin->second.contents.find(cur.first);
1127  if (cont != pin->second.contents.end()) {
1128  if (cont->second > cur.second) {
1129  cont->second -= cur.second;
1130  } else {
1131  // set qty to amount contained in pin.
1132  cur.second = cont->second;
1133  pin->second.contents.erase(cont); // remove item from pin.contents if exporting entire qty.
1134  }
1135  } else {
1136  _log(COLONY__WARNING, "Colony::PlanetXfer():export - item %u not found in spaceport", cur.first);
1137  }
1138 
1139  // if item not found in src contents, assume client is right and procede with xfer
1140  switch (sPIDataMgr.GetProductLevel(cur.first)) {
1141  case 0: cost += ( 0.10 * cur.second); break;
1142  case 1: cost += ( 0.76 * cur.second); break;
1143  case 2: cost += ( 9.00 * cur.second); break;
1144  case 3: cost += ( 600.00 * cur.second); break;
1145  case 4: cost += (50000.00 * cur.second); break;
1146  }
1147  // xfer virtual item to real
1148  ItemData iData(cur.first, m_client->GetCharacterID(), locTemp, flagNone, cur.second);
1149  InventoryItemRef iRef = sItemFactory.SpawnItem(iData);
1150  iRef->Move(m_pSE->GetCustomsOffice()->GetID(), flagHangar, true);
1151  ++fromColony;
1152  }
1153 
1154  if (fromColony)
1155  if (is_log_enabled(COLONY__TRACE))
1156  _log(COLONY__TRACE, "Colony::PlanetXfer() - Exported %u items from spaceport %u to customs office %u", \
1157  fromColony, spaceportID, m_pSE->GetCustomsOffice()->GetID());
1158 
1159  if (cost) {
1160  //take the money, send wallet blink event record the transaction in their journal.
1161  std::string reason = "DESC: Exporting items from ";
1162  reason += m_pSE->GetName();
1166  cost,
1167  reason.c_str(),
1169  m_pSE->GetID(),
1171  }
1172 
1173  pin->second.lastLaunchTime = GetFileTimeNow(); // launch cycle time is 60s
1174  pin->second.lastRunTime = GetFileTimeNow();
1175 
1176  // update colony
1177  Update(true); // must update and save SP's lastLaunchTime here
1178  //do we do a full save here, or just update contents and times?
1179  //Save();
1180  m_db.UpdatePins(0, ccPin);
1182 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
unsigned __int8 uint8
Definition: eve-compat.h:46
void UpdatePins(uint32 pinID, PI_CCPin *ccPin)
Definition: PlanetDB.cpp:485
#define _log(type, fmt,...)
Definition: logsys.h:124
Client * m_client
Definition: Colony.h:98
#define sPIDataMgr
Definition: PlanetDataMgr.h:79
CustomsSE * GetCustomsOffice()
Definition: Planet.h:68
uint32 GetOwnerID()
Definition: SystemEntity.h:219
int32 GetCharacterID() const
Definition: Client.h:113
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
void Update(bool updateTimes=false)
Definition: Colony.cpp:1349
#define is_log_enabled(type)
Definition: logsys.h:78
static void TranserFunds(uint32 fromID, uint32 toID, double amount, std::string reason="", uint8 entryTypeID=Journal::EntryType::Undefined, uint32 referenceID=0, uint16 fromKey=Account::KeyType::Cash, uint16 toKey=Account::KeyType::Cash, Client *pClient=nullptr)
bool CanThrow()
Definition: Client.h:431
PlanetSE * m_pSE
Definition: Colony.h:96
uint32 GetID()
Definition: SystemEntity.h:207
PlanetDB m_db
Definition: Colony.h:102
const char * GetName() const
Definition: SystemEntity.h:210
void SaveContents(PI_CCPin *ccPin)
Definition: PlanetDB.cpp:733
PI_CCPin * ccPin
Definition: Colony.h:97
double GetFileTimeNow()
Definition: utils_time.cpp:84
#define sItemFactory
Definition: ItemFactory.h:165

Here is the call graph for this function:

void Colony::PrioritizeRoute ( uint16  routeID,
uint8  priority 
)

Definition at line 1195 of file Colony.cpp.

References ccPin, m_db, PI_CCPin::routes, and PlanetDB::SaveRoutes().

Referenced by PlanetMgr::PrioritizeRoute().

1196 {
1197  // set priority level for route...still not sure how to use it
1198  std::map<uint16, PI_Route>::iterator itr = ccPin->routes.find(routeID);
1199  if (itr != ccPin->routes.end()) {
1200  itr->second.priority = priority;
1202  }
1203 }
std::map< uint16, PI_Route > routes
Definition: EVE_Planet.h:239
void SaveRoutes(PI_CCPin *ccPin)
Definition: PlanetDB.cpp:689
PlanetDB m_db
Definition: Colony.h:102
PI_CCPin * ccPin
Definition: Colony.h:97

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::Process ( )

Definition at line 203 of file Colony.cpp.

References ccPin, Timer::Check(), Profile::colony, Timer::Disable(), GetTimeUSeconds(), m_colonyID, m_colonyTimer, m_db, m_toUpdate, PI_CCPin::pins, PlanetDB::RemoveContents(), PlanetDB::SavePinContents(), sConfig, sProfiler, Update(), and PlanetDB::UpdatePins().

204 {
205  if (m_colonyTimer.Check()) { // this will process colony data every 30 mins. (typical cycle time)
206  if (ccPin->pins.empty()) {
208  return;
209  }
210 
211  double profileStartTime = GetTimeUSeconds();
212  Update();
213 
214  // profile timer for the colony updates
215  if (sConfig.debug.UseProfiling)
216  sProfiler.AddTime(Profile::colony, GetTimeUSeconds() - profileStartTime);
217  }
218 
219  if (m_toUpdate) {
220  // this is part of clever code to avoid db hits on every update.
221  // this method will check for updated contents and save to db as needed.
222  std::map<uint32, PI_Pin>::iterator itr;
223  for (auto cur : ccPin->pins)
224  if (cur.second.update) {
225  m_db.RemoveContents(cur.first);
226  m_db.SavePinContents(m_colonyID, cur.first, cur.second.contents);
227  cur.second.update = false;
228  if (cur.second.isProcess) {
229  itr = ccPin->pins.find(cur.first);
230  if (itr != ccPin->pins.end()) {
231  itr->second.state = cur.second.state;
232  itr->second.cycleTime = cur.second.cycleTime;
233  itr->second.installTime = cur.second.installTime;
234  itr->second.lastRunTime = cur.second.lastRunTime;
235  itr->second.schematicID = cur.second.schematicID;
236  itr->second.qtyPerCycle = cur.second.qtyPerCycle;
237  itr->second.hasReceivedInputs = cur.second.hasReceivedInputs;
238  itr->second.receivedInputsLastCycle = cur.second.receivedInputsLastCycle;
239  }
240  }
241  }
242 
243  m_db.UpdatePins(0, ccPin);
244  m_toUpdate = false;
245  }
246 
247 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
#define sConfig
A macro for easier access to the singleton.
void UpdatePins(uint32 pinID, PI_CCPin *ccPin)
Definition: PlanetDB.cpp:485
void Disable()
Definition: timer.h:39
#define sProfiler
Definition: dbcore.cpp:39
void RemoveContents(uint32 pinID)
Definition: PlanetDB.cpp:819
void Update(bool updateTimes=false)
Definition: Colony.cpp:1349
double GetTimeUSeconds()
Definition: utils_time.cpp:116
bool m_toUpdate
Definition: Colony.h:107
PlanetDB m_db
Definition: Colony.h:102
bool Check(bool reset=true)
Definition: timer.cpp:62
Timer m_colonyTimer
Definition: Colony.h:100
PI_CCPin * ccPin
Definition: Colony.h:97
void SavePinContents(uint32 ccPinID, uint32 pinID, std::map< uint16, uint32 > &contents)
Definition: PlanetDB.cpp:767
uint32 m_colonyID
Definition: Colony.h:112

Here is the call graph for this function:

void Colony::ProcessECUs ( bool &  save)
Todo:
as i dont have data on planet resources, and am not tracking depletion, extraction qtys used here are sent from the client during 'survey program' installation, and do not simulate the diminishing returns as shown in the survey program. (testing diminishing returns @ 95%) because of this, the values used here (and all subsquent processes) will be more than shown in client.
Note
this is a simple process, as it only provides raw mats, simulating extraction from planet and shipped to storage or directly to plant for processing. however, in the case of shipping directly to plant, we will have to store the mats in the plant queue and wait for the ProcessPlants() call to use them, as this will avoid overcomplicating things, but it could get messy later....
Todo:
verify cycles isnt over program cycle count
Todo:
set/implement storage capy for pin - PI_Pin.capacity, PI_Pin.quantity

Definition at line 1385 of file Colony.cpp.

References _log, ccPin, GetFileTimeNow(), EvE::Time::Hour, is_log_enabled, m_destRoutes, m_procTime, PI_CCPin::pins, PI_CCPin::plants, EvE::Time::Second, and sPIDataMgr.

Referenced by Update().

1386 {
1387  double delta = 0;
1388  uint16 cycles = 0, quantity = 0, amount = 0, count = 0;
1389  std::map<uint16, uint32>::iterator itemItr;
1390  std::map<uint32, PI_Pin>::iterator destPin;
1391  std::map<uint32, PI_Plant>::iterator plant;
1392  for (auto ecu : ccPin->pins) {
1393  if (!ecu.second.isECU)
1394  continue;
1395 
1396  if ((ecu.second.expiryTime < EvE::Time::Second ) or (ecu.second.expiryTime > m_procTime)) {
1397  if (is_log_enabled(COLONY__DEBUG))
1398  _log(COLONY__DEBUG, "Colony::ProcessECUs() - expiryTime (%li) > m_procTime (%li).", \
1399  ecu.second.expiryTime, m_procTime);
1400  continue;
1401  }
1402  if (ecu.second.cycleTime < 0.0f) {
1403  if (is_log_enabled(COLONY__DEBUG))
1404  _log(COLONY__DEBUG, "Colony::ProcessECUs() - cycleTime < 0.");
1405  continue;
1406  }
1407 
1408  if (ecu.second.lastRunTime < EvE::Time::Hour)
1409  ecu.second.lastRunTime = ecu.second.expiryTime - ecu.second.cycleTime;
1410 
1423  // dont loop...get #cycles to 'run' and set amounts accordingly
1424  delta = (m_procTime - ecu.second.expiryTime) / EvE::Time::Hour;
1425  cycles = delta / (ecu.second.cycleTime / EvE::Time::Hour);
1426 
1429  // first - see if this ecu has a route and move contents per route. this will simulate aquisition of raw matls from heads to storage
1430  if (is_log_enabled(COLONY__DEBUG))
1431  _log(COLONY__DEBUG, "Colony::ProcessECUs() - ECU pin %u - begin processing with %u cycles (%0.2f / %0.2f)", \
1432  ecu.first, cycles, delta, (ecu.second.cycleTime / EvE::Time::Hour));
1433  auto destRouteItr = m_destRoutes.equal_range(plant->first);
1434  for (auto it = destRouteItr.first; it != destRouteItr.second; ++it) {
1435  // verify this route begins at this pin.
1436  //if (it->second.srcPinID != ecu.first)
1437  // continue;
1438 
1439  // second - update current contents per route movement as noted above (there are no stored contents to update in the ECU)
1440  // get route destination pin and update qty
1441  destPin = ccPin->pins.find(it->first);
1442  if (destPin == ccPin->pins.end()) {
1443  _log(COLONY__ERROR, "Colony::ProcessECUs() - Dest pinID %u not found in ccPin.pins map", it->first);
1444  continue;
1445  }
1446  // loop thru cycles to apply diminishing returns
1447  count = cycles;
1448  quantity = it->second.commodityQuantity;
1449  while (count) {
1450  quantity *= 0.95;
1451  amount += quantity;
1452  --count;
1453  }
1454  // contents are stored in each pin. PI_Pin.contents(std::map<uint16, uint32>(typeID, qty))
1455  itemItr = destPin->second.contents.find(it->second.commodityTypeID);
1457  // if dest cant hold entire xfer qty, drop remainder in current pin contents (as opposed to loss)
1458  // will need a way to set/test for this 'extra' material and xfer on next run
1459  if (itemItr != destPin->second.contents.end()) {
1460  itemItr->second += amount;
1461  } else {
1462  destPin->second.contents[it->second.commodityTypeID] = amount;
1463  }
1464  if (is_log_enabled(COLONY__DEBUG))
1465  _log(COLONY__DEBUG, "Colony::ProcessECUs() - Dest pinID %u updated with %u %s (%u).", \
1466  it->second.destPinID, amount, sPIDataMgr.GetProductName(it->second.commodityTypeID), it->second.commodityTypeID);
1467 
1468  // 'update' is part of clever code to avoid db hits.
1469  // this will delete existing contents and insert current contents upon completion of processing
1470  destPin->second.update = true;
1471  // if destination pin is plant, put materials in its' storage
1472  // client verifies mat'l is required before routing
1473  if (destPin->second.isProcess) {
1474  // find dest's plant data
1475  plant = ccPin->plants.find(destPin->first);
1476  if (plant == ccPin->plants.end()) {
1477  _log(COLONY__ERROR, "Colony::ProcessECUs() - Plant pinID %u not found in ccPin.plants map", destPin->first);
1478  continue;
1479  }
1480  //and set hasReceivedInputs to true for subsequent processing
1481  plant->second.hasReceivedInputs = true;
1482  if (is_log_enabled(COLONY__DEBUG))
1483  _log(COLONY__DEBUG, "Colony::ProcessECUs() - Dest pinID %u isPlant.", it->second.destPinID);
1484  }
1485  }
1486 
1487  // third - reset cycle times.
1488  // set expiryTime to previous runtime plus cycleTime to simulate end of cycle
1489  ecu.second.expiryTime = ecu.second.lastRunTime + ecu.second.cycleTime * cycles;
1490  // set lastRunTime to last-processed cycle's expire time.
1491  ecu.second.lastRunTime = ecu.second.expiryTime;
1492  updateTimes = true;
1493 
1494  if (is_log_enabled(COLONY__DEBUG))
1495  _log(COLONY__DEBUG, "Colony::ProcessECUs() - Processing complete. timeNow %li, expiryTime %li, lastRunTime %li", \
1496  GetFileTimeNow(), ecu.second.expiryTime, ecu.second.lastRunTime);
1497  }
1498 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
#define _log(type, fmt,...)
Definition: logsys.h:124
#define sPIDataMgr
Definition: PlanetDataMgr.h:79
std::map< uint32, PI_Plant > plants
Definition: EVE_Planet.h:241
#define is_log_enabled(type)
Definition: logsys.h:78
int64 m_procTime
Definition: Colony.h:114
std::multimap< uint32, PI_Route > m_destRoutes
Definition: Colony.h:123
PI_CCPin * ccPin
Definition: Colony.h:97
double GetFileTimeNow()
Definition: utils_time.cpp:84
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 Colony::ProcessPlants ( bool &  save)
Note
generally-accepted PI design has plant input and output to/from silo(spaceport or storage) for input buffers and follows this guideline... silo->plant->silo->plant->silo however, there may be rare cases where colony is restricted or other design constraints limit routing and plants must be linked together, where the output of one provides the direct input of the next, as follows... silo->plant->plant->plant->silo with plants as needed for production requirements of the colony.

this will need to check for and be able to process both cases, and could be somewhat complicated.

plants will have to be processed in order from p1 to p4 products, to provide input for downstream plants this WILL have to loop for each cycle to correctly set inputs and outputs for each plant, and provide positive material control (and be more realistic) per run.

Note
plants are stored separate from other pins, to avoid the cycles and checks for plants in this call. this will also avoid the unnecessary plant-specific data to be stored in std pins for all items
           if schematicID is valid, input and cycletime *should* be valid also.
          comment these until proven needed  (gotta get proc times faster)

check if plant has valid input map if (plant->second.data.inputs.empty()) { _log(COLONY__WARNING, "Colony::ProcessPlants() - Empty input map"); plant->second.hasReceivedInputs = false; plant->second.receivedInputsLastCycle = false; continue; } if (plant->second.cycleTime == 0) { if (is_log_enabled(COLONY__DEBUG)) _log(COLONY__DEBUG, "Colony::ProcessPlants() - cycleTime = 0."); continue; }

    overkill...client verifies plant routing before sending to server
if (plant->second.data.inputs.find(it->second.commodityTypeID) == plant->second.data.inputs.end()) {
    _log(COLONY__ERROR, "Colony::ProcessPlants() - Routed Commodity %s (%u) not found in input map",\
            sPIDataMgr.GetProductName(it->second.commodityTypeID), it->second.commodityTypeID);
    plant->second.lastRunTime = m_procTime;
    plant->second.hasReceivedInputs = false;
    plant->second.receivedInputsLastCycle = false;
    updateTimes = true;

remove route here continue; }

Todo:
set/implement storage capy for pin - PI_Pin.capacity, PI_Pin.quantity

Definition at line 1500 of file Colony.cpp.

References _log, PI::Pin::State::Active, ccPin, GetFileTimeNow(), EvE::Time::Hour, PI::Pin::State::Idle, is_log_enabled, m_destRoutes, m_plantMap, m_pLevel, m_procTime, m_srcRoutes, PI_CCPin::pins, PI_CCPin::plants, EvE::Time::Second, and sPIDataMgr.

Referenced by Update().

1501 {
1502  if (ccPin->plants.empty() or (m_pLevel < 1))
1503  return; // nothing to do...
1504 
1522  // m_pLevel is set to lowest 'P' level of produced items, and used to properly order plant processing streams
1523  uint8 curCycle = m_pLevel;
1524  int32 cycles = 0, cycles2 = 0, amount = 0, divisor = 0, delta = 0;
1525  std::map<uint32, PI_Pin>::iterator srcPin;
1526  std::map<uint32, PI_Pin>::iterator destPin;
1527  std::map<uint16, uint32>::iterator itemItr;
1528  std::map<uint32, PI_Plant>::iterator destPlant;
1529  _log(COLONY__INFO, "Colony::ProcessPlants() - Begin Plant Processing. m_procTime: %li", m_procTime);
1530  while (curCycle < 5) {
1531  if (is_log_enabled(COLONY__DEBUG))
1532  _log(COLONY__DEBUG, "Colony::ProcessPlants() - Begin Process loop for pLevel %u.", curCycle);
1533 
1534  // plants must be processed in order to correctly make products and send to downstream recipients.
1535  // this allows for both silo->plant->silo->plant and silo->plant->plant->plant->silo routing (or any combination of plant and silo routing)
1536  auto cycleItr = m_plantMap.equal_range(curCycle);
1537  for (auto it = cycleItr.first; it != cycleItr.second; ++it) {
1538  _log(COLONY__INFO, "Colony::ProcessPlants() - Begin Processing for Plant %u", it->second);
1539 
1540  // first, find plant pin in plant map
1541  std::map<uint32, PI_Plant>::iterator plant = ccPin->plants.find(it->second);
1542  if (plant == ccPin->plants.end()) {
1543  _log(COLONY__ERROR, "Colony::ProcessPlants() - Plant %u not found in ccPin.pins map", it->second);
1544  it = m_plantMap.erase(it);
1545  continue;
1546  }
1547  // plant pin found. begin basic data integrity checks
1548 
1549  // check if plant has schematic installed
1550  if (plant->second.schematicID == 0) {
1551  _log(COLONY__WARNING, "Colony::ProcessPlants() - No schematic installed in plant %u.", it->second);
1552  plant->second.hasReceivedInputs = false;
1553  plant->second.receivedInputsLastCycle = false;
1554  continue;
1555  }
1571  if (plant->second.lastRunTime < EvE::Time::Hour)
1572  plant->second.lastRunTime = m_procTime + EvE::Time::Second;
1573 
1574  if (plant->second.lastRunTime >= m_procTime) {
1575  if (is_log_enabled(COLONY__DEBUG))
1576  _log(COLONY__DEBUG, "Colony::ProcessPlants() - lastRunTime (%li) >= m_procTime (%li).", \
1577  plant->second.lastRunTime, m_procTime);
1578  continue;
1579  }
1580 
1581  if (is_log_enabled(COLONY__DEBUG))
1582  _log(COLONY__DEBUG, "Colony::ProcessPlants() - last run time %li.", plant->second.lastRunTime);
1583 
1584  // second, check processing times for active plants
1585  delta = (m_procTime - plant->second.lastRunTime) / EvE::Time::Second;
1586  divisor = (plant->second.cycleTime / EvE::Time::Second);
1587  if (divisor > 0) {
1588  if (delta < divisor) {
1589  if (plant->second.state < PI::Pin::State::Active) {
1590  delta = divisor;
1591  plant->second.lastRunTime -= plant->second.cycleTime;
1592  } else {
1593  if (is_log_enabled(COLONY__DEBUG))
1594  _log(COLONY__DEBUG, "Colony::ProcessPlants() - cycle incomplete (%i < %i).", delta, divisor);
1595  continue;
1596  }
1597  }
1598  } else {
1599  if (is_log_enabled(COLONY__DEBUG))
1600  _log(COLONY__DEBUG, "Colony::ProcessPlants() - divisor < 0 (%i).", divisor);
1601  continue;
1602  }
1603  // we are doing 'batch' cycles here. get #cycles completed based on proc times
1604  cycles = delta / divisor;
1605  if (is_log_enabled(COLONY__DEBUG))
1606  _log(COLONY__DEBUG, "Colony::ProcessPlants() - current cycle count is %i (%i / %i).", \
1607  cycles, delta, divisor);
1608 
1609  if (cycles < 1) {
1610  _log(COLONY__WARNING, "Colony::ProcessPlants() - Cycle count < 1");
1611  continue;
1612  }
1613  // basic data checks done.
1614 
1615  // third, check supply routes for available matls and xfer to this plant
1616  _log(COLONY__INFO, "Colony::ProcessPlants() - Begin Input Route loop for Plant %u.", plant->first);
1617  auto destRouteItr = m_destRoutes.equal_range(plant->first);
1618  for (auto it = destRouteItr.first; it != destRouteItr.second; ++it) {
1619  // we are ONLY checking routes TO this plant.
1620  //if (it->second.destPinID != plant->first)
1621  // continue;
1622 
1623  // verify plant needs this input....this may be overkill...
1635  // this route supplies this plant with input matls.
1636  srcPin = ccPin->pins.find(it->second.srcPinID);
1637  if (srcPin == ccPin->pins.end()) {
1638  _log(COLONY__ERROR, "Colony::ProcessPlants() - Source %u not found in ccPin.pins map", it->second.srcPinID);
1639  plant->second.lastRunTime = m_procTime;
1640  plant->second.hasReceivedInputs = false;
1641  plant->second.receivedInputsLastCycle = false;
1642  updateTimes = true;
1643  continue;
1644  }
1645  // verify supplier is NOT a plant or ECU here, as this was done in previous cycle checks.
1646  if (!srcPin->second.isStorage)
1647  continue;
1648  // source is storage. continue with processing
1649  itemItr = srcPin->second.contents.find(it->second.commodityTypeID);
1650  if (itemItr == srcPin->second.contents.end()) {
1651  if (is_log_enabled(COLONY__DEBUG))
1652  _log(COLONY__DEBUG, "Colony::ProcessPlants() - Routed Commodity %s (%u) not found in Source Inventory.", \
1653  sPIDataMgr.GetProductName(it->second.commodityTypeID), it->second.commodityTypeID);
1654  continue;// this material wasnt found in source container....cant move what we aint got..
1655  }
1656 
1657  // remove contents from storage pin
1658  amount = it->second.commodityQuantity * cycles;
1659  if (itemItr->second > amount) {
1660  itemItr->second -= amount;
1661  } else {
1662  amount = itemItr->second;
1663  srcPin->second.contents.erase(itemItr);
1664  }
1665  if (is_log_enabled(COLONY__DEBUG))
1666  _log(COLONY__DEBUG, "Colony::ProcessPlants() - Removed %i %s (%u) from src %u.", \
1667  amount, sPIDataMgr.GetProductName(it->second.commodityTypeID), it->second.commodityTypeID, srcPin->first);
1668 
1669  // update contents of storage pin
1670  srcPin->second.update = true;
1671 
1672  // add contents to this plant's pin
1673  destPin = ccPin->pins.find(plant->first);
1674  if (destPin == ccPin->pins.end()) {
1675  _log(COLONY__ERROR, "Colony::ProcessPlants() - Pin %u not found in ccPin.pins map for this plant.", plant->first);
1676  plant->second.lastRunTime = m_procTime;
1677  plant->second.hasReceivedInputs = false;
1678  plant->second.receivedInputsLastCycle = false;
1679  updateTimes = true;
1680  continue;
1681  }
1682  itemItr = destPin->second.contents.find(it->second.commodityTypeID);
1683  if (itemItr != destPin->second.contents.end()) {
1684  itemItr->second += amount;
1685  } else {
1686  destPin->second.contents[it->second.commodityTypeID] = amount;
1687  }
1688  destPin->second.update = true;
1689 
1690  // we have received a material from this route. enable check for all required materials in this Schematic for this plant
1691  plant->second.hasReceivedInputs = true;
1692 
1693  if (is_log_enabled(COLONY__DEBUG))
1694  _log(COLONY__DEBUG, "Colony::ProcessPlants() - Added %i %s (%u) to Plant Inventory.", \
1695  amount, sPIDataMgr.GetProductName(it->second.commodityTypeID), it->second.commodityTypeID);
1696  }
1697  // current plant has received product as defined by routing info
1698 
1699  // fourth, process input material requirements
1700  cycles2 = 0;
1701  _log(COLONY__INFO, "Colony::ProcessPlants() - %s Input Check loop for Plant %u.", plant->second.hasReceivedInputs ? "Begin" : "Skipping", plant->first);
1702  if (is_log_enabled(COLONY__DEBUG))
1703  _log(COLONY__DEBUG, "Colony::ProcessPlants() - Plant %u processing inputs.", plant->first);
1704 
1705  destPin = ccPin->pins.find(plant->first);
1706  if (destPin == ccPin->pins.end()) {
1707  _log(COLONY__ERROR, "Colony::ProcessPlants() - Dest %u not found in ccPin.pins map", plant->first);
1708  continue;
1709  }
1710 
1711  plant->second.receivedInputsLastCycle = false;
1712 
1713  if (plant->second.hasReceivedInputs) {
1714  /* if plant has received mats from routing (above), then check here for required qtys per Schematic.
1715  * input data is found in plant->second.data.inputs map (std::map<uint16, uint16> {typeID, qty})
1716  *
1717  * if required mats are not present, set receivedInputsLastCycle=false, which will deny processing
1718  * and subsquent routing for this plant.
1719  *
1720  * if all required qtys have been received, procede with the following:
1721  * - remove mats from pin.contents
1722  * - set receivedInputsLastCycle=true
1723  */
1724  if (plant->second.data.inputs.empty()) {
1725  _log(COLONY__WARNING, "Colony::ProcessPlants() - Empty input map");
1726  plant->second.hasReceivedInputs = false;
1727  plant->second.lastRunTime = m_procTime;
1728  updateTimes = true;
1729  continue;
1730  }
1731  uint16 tempCycles = cycles;
1732  for (auto mats : plant->second.data.inputs) {
1733  // loop thru Schematic inputs to verify all required mats are present
1734  itemItr = destPin->second.contents.find(mats.first);
1735  if (itemItr == destPin->second.contents.end()) {
1736  if (is_log_enabled(COLONY__DEBUG))
1737  _log(COLONY__DEBUG, "Colony::ProcessPlants() - %s (%u) not found in Plant Inventory.", \
1738  sPIDataMgr.GetProductName(mats.first), mats.first);
1739  // this required material was not found in plant inventory. skip further processing
1740  plant->second.state = PI::Pin::State::Idle;
1741  plant->second.lastRunTime = m_procTime;
1742  updateTimes = true;
1743  continue;
1744  }
1745  if (itemItr->second >= mats.second * cycles) {
1746  itemItr->second -= mats.second * cycles;
1747  plant->second.receivedInputsLastCycle = true;
1748  } else {
1749  // this required material was not sufficient quantity for (num cycles) runs.
1750  // determine how many cycles we can run with current material quantity
1751  if (is_log_enabled(COLONY__DEBUG))
1752  _log(COLONY__DEBUG, "Colony::ProcessPlants() - Not enough %s (%u) for %i cycles. Need %u, Have %u", \
1753  sPIDataMgr.GetProductName(mats.first), mats.first, cycles, mats.second * cycles, itemItr->second);
1754  cycles2 = itemItr->second / mats.second;
1755  if (cycles2 > 0) {
1756  itemItr->second -= mats.second * cycles2;
1757  plant->second.receivedInputsLastCycle = true;
1758  if (is_log_enabled(COLONY__DEBUG))
1759  _log(COLONY__DEBUG, "Colony::ProcessPlants() - Have enough material for %i cycles.", cycles2);
1760  } else {
1761  plant->second.lastRunTime = m_procTime;
1762  plant->second.state = PI::Pin::State::Idle;
1763  updateTimes = true;
1764  continue;
1765  }
1766  }
1767  // set temp variable with mininmum cycle count
1768  if (tempCycles > cycles2)
1769  tempCycles = cycles2;
1770  cycles2 = 0;
1771  }
1772  // we have enough mat'l for at least on process. set cycles based on material in inventory.
1773  if (cycles > tempCycles)
1774  cycles = tempCycles; // temp variable not longer needed at this point.
1775  } else {
1776  plant->second.lastRunTime = m_procTime;
1777  updateTimes = true;
1778  }
1779 
1780  // at this point, we have looped thru all required mats and set plant variables accordingly.
1781 
1782  // fifth, process manufacturing cycle
1783  _log(COLONY__INFO, "Colony::ProcessPlants() - %s manufacturing loop for Plant %u.", plant->second.receivedInputsLastCycle ? "Begin" : "Skipping", plant->first);
1784  if (plant->second.receivedInputsLastCycle and (cycles > 0)) {
1785  /* plant has received all required mats for production.
1786  * set timers for runtimes and state to active
1787  * this will allow routing (and subsquent process checks) on next loop, as defined in beginning of this loop
1788  */
1789  if (is_log_enabled(COLONY__DEBUG))
1790  _log(COLONY__DEBUG, "Colony::ProcessPlants() - Updating timers for %i cycles using current inventory.", cycles);
1791 
1792  plant->second.state = PI::Pin::State::Active;
1793  updateTimes = true;
1794 
1795  if (is_log_enabled(COLONY__DEBUG))
1796  _log(COLONY__DEBUG, "Colony::ProcessPlants() - Received Inputs. timeNow %li, lastRunTime %li", \
1797  GetFileTimeNow(), plant->second.lastRunTime);
1798  } else {
1799  cycles = 0;
1800  }
1801 
1802  // sixth, manufacturing complete. move finished product per route
1803  _log(COLONY__INFO, "Colony::ProcessPlants() - %s Output Routing loop for Plant %u.", cycles > 0 ? "Begin" : "Skipping", plant->first);
1804  if (cycles) {
1805  // at this point, *SOMETHING* has changed in this plant, so send it to update
1806  destPin->second.update = true;
1807  auto srcRouteItr = m_srcRoutes.equal_range(plant->first);
1808  for (auto it = srcRouteItr.first; it != srcRouteItr.second; ++it) {
1809  // verify this route begins at this plant. should be only ONE route here for this output
1810  //if (route.second.srcPinID != plant->first)
1811  // continue;
1812  // get destination pin and update qty there for this round
1813  destPin= ccPin->pins.find(it->second.destPinID);
1814  if (destPin == ccPin->pins.end()) {
1815  _log(COLONY__ERROR, "Colony::ProcessPlants() - Dest %u not found in ccPin.pins map", it->second.destPinID);
1816  continue;
1817  }
1818  // contents are stored in each pin. PI_Pin.contents(std::map<uint16, uint32> typeID, qty)
1819  // we have plant cycles for this loop, so multiply output by cycles to get a total to simulate the "active" plant
1820  amount = it->second.commodityQuantity * cycles;
1821  itemItr = destPin->second.contents.find(it->second.commodityTypeID);
1822  if (itemItr != destPin->second.contents.end()) {
1823  itemItr->second += amount;
1824  } else {
1825  destPin->second.contents[it->second.commodityTypeID] = amount;
1826  }
1827  if (is_log_enabled(COLONY__DEBUG))
1828  _log(COLONY__DEBUG, "Colony::ProcessPlants() - Added %u %s (%u) to Dest %u.", \
1829  amount, sPIDataMgr.GetProductName(it->second.commodityTypeID), it->second.commodityTypeID, it->second.destPinID);
1830 
1831  if (destPin->second.isStorage) {
1833  // if dest cant hold entire xfer qty, drop remainder in current pin contents (as opposed to loss)
1834  } else if (destPin->second.isProcess) {
1835  // find dest's plant data
1836  // the destination plant will have a P level of curCycle+1, and will process on next iteration
1837  destPlant = ccPin->plants.find(destPin->first);
1838  if (destPlant == ccPin->plants.end()) {
1839  _log(COLONY__ERROR, "Colony::ProcessPlants() - Dest %u not found in ccPin.plants map", destPin->first);
1840  continue;
1841  }
1842  //and set hasReceivedInputs to true for subsquent processing
1843  destPlant->second.hasReceivedInputs = true;
1844  }
1845 
1846  destPin->second.update = true;
1847  plant->second.hasReceivedInputs = false;
1848  }
1849  // update last run time based on current process cycles
1850  plant->second.lastRunTime += plant->second.cycleTime * cycles;
1851  } else {
1852  plant->second.state = PI::Pin::State::Idle;
1853  plant->second.lastRunTime = m_procTime;
1854  plant->second.hasReceivedInputs = false;
1855  plant->second.receivedInputsLastCycle = false;
1856  }
1857  }
1858  if (is_log_enabled(COLONY__DEBUG))
1859  _log(COLONY__DEBUG, "Colony::ProcessPlants() - Process loop complete for pLevel %u.", curCycle);
1860  ++curCycle;
1861  }
1862 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
unsigned __int8 uint8
Definition: eve-compat.h:46
#define _log(type, fmt,...)
Definition: logsys.h:124
#define sPIDataMgr
Definition: PlanetDataMgr.h:79
signed __int32 int32
Definition: eve-compat.h:49
std::map< uint32, PI_Plant > plants
Definition: EVE_Planet.h:241
#define is_log_enabled(type)
Definition: logsys.h:78
int64 m_procTime
Definition: Colony.h:114
std::multimap< uint32, PI_Route > m_destRoutes
Definition: Colony.h:123
PI_CCPin * ccPin
Definition: Colony.h:97
double GetFileTimeNow()
Definition: utils_time.cpp:84
std::multimap< uint32, PI_Route > m_srcRoutes
Definition: Colony.h:121
std::multimap< uint8, uint32 > m_plantMap
Definition: Colony.h:119
unsigned __int16 uint16
Definition: eve-compat.h:48
uint8 m_pLevel
Definition: Colony.h:109

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::RemoveLink ( uint32  src,
uint32  dest 
)

Definition at line 684 of file Colony.cpp.

References _log, ccPin, PI_CCPin::links, m_db, and PlanetDB::RemoveLink().

Referenced by PlanetMgr::RemoveLink().

685 {
686  std::map<uint32, PI_Link>::iterator itr = ccPin->links.begin();
687  for (; itr != ccPin->links.end(); ++itr)
688  if (itr->second.endpoint1 == src)
689  if (itr->second.endpoint2 == dest) {
690  _log(COLONY__INFO, "Colony::RemoveLink() - Removing linkID %u - src: %u, dest: %u", itr->first, src, dest);
691  m_db.RemoveLink(itr->first);
692  ccPin->links.erase(itr);
693  return;
694  }
695 }
#define _log(type, fmt,...)
Definition: logsys.h:124
PlanetDB m_db
Definition: Colony.h:102
std::map< uint32, PI_Link > links
Definition: EVE_Planet.h:237
PI_CCPin * ccPin
Definition: Colony.h:97
void RemoveLink(uint32 linkID)
Definition: PlanetDB.cpp:807

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::RemovePin ( uint32  pinID)

Definition at line 615 of file Colony.cpp.

References _log, ccPin, PI_CCPin::links, m_colonyID, m_db, m_destRoutes, m_srcRoutes, PI_CCPin::pins, PI_CCPin::plants, PlanetDB::RemoveLink(), PlanetDB::RemovePin(), PlanetDB::RemoveRoute(), PI_CCPin::routes, PlanetDB::SaveLinks(), PlanetDB::SaveRoutes(), and PlanetDB::UpdatePlanetPins().

Referenced by PlanetMgr::RemovePin().

616 {
617  uint8 linkCount = 0, routeCount = 0, pathCount = 0;
618  // check for and remove links to this pinID
619  std::map<uint32, PI_Link>::iterator itr = ccPin->links.begin();
620  while (itr != ccPin->links.end()) {
621  if (itr->second.endpoint1 == pinID) {
622  m_db.RemoveLink(itr->first);
623  itr = ccPin->links.erase(itr);
624  ++linkCount;
625  continue;
626  }
627  if (itr->second.endpoint2 == pinID) {
628  m_db.RemoveLink(itr->first);
629  itr = ccPin->links.erase(itr);
630  ++linkCount;
631  continue;
632  }
633  ++itr;
634  }
635 
636  // check for routes to, from, or thru this pin
637  std::map<uint16, PI_Route>::iterator rItr = ccPin->routes.begin();
638  while (rItr != ccPin->routes.end()) {
639  /*
640  uint32 srcPinID;
641  uint32 destPinID;
642  std::list<uint32> path;
643  */
644  if (rItr->second.srcPinID == pinID) {
645  m_db.RemoveRoute(rItr->first);
646  rItr = ccPin->routes.erase(rItr);
647  ++routeCount;
648  continue;
649  }
650  if (rItr->second.destPinID == pinID) {
651  m_db.RemoveRoute(rItr->first);
652  rItr = ccPin->routes.erase(rItr);
653  ++routeCount;
654  continue;
655  }
656  // at this point, the pin being removed isnt src or dest, so check for intermediate routing.
657  std::list<uint32>::iterator pItr = rItr->second.path.begin();
658  while (pItr != rItr->second.path.end()) {
659  // we may have to reroute from this pin removal...
660  if (*pItr == pinID) {
661  //reroute = true;
662  pItr = rItr->second.path.erase(pItr);
663  ++pathCount;
664  continue;
665  }
666  ++pItr;
667  }
668  ++rItr;
669  }
670 
671  m_srcRoutes.erase(pinID);
672  m_destRoutes.erase(pinID);
673 
674  ccPin->pins.erase(pinID);
675  ccPin->plants.erase(pinID); // may or may not be here.
676  m_db.RemovePin(pinID);
680  _log(COLONY__INFO, "Colony::RemovePin() - Removed pin %u with %u routes and %u links. Upset %u routes by removing this pin", \
681  pinID, routeCount, linkCount, pathCount);
682 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
std::map< uint16, PI_Route > routes
Definition: EVE_Planet.h:239
void UpdatePlanetPins(uint32 ccPinID, uint8 pins=1)
Definition: PlanetDB.cpp:101
unsigned __int8 uint8
Definition: eve-compat.h:46
#define _log(type, fmt,...)
Definition: logsys.h:124
std::map< uint32, PI_Plant > plants
Definition: EVE_Planet.h:241
void SaveRoutes(PI_CCPin *ccPin)
Definition: PlanetDB.cpp:689
std::multimap< uint32, PI_Route > m_destRoutes
Definition: Colony.h:123
PlanetDB m_db
Definition: Colony.h:102
void SaveLinks(PI_CCPin *ccPin)
Definition: PlanetDB.cpp:626
std::map< uint32, PI_Link > links
Definition: EVE_Planet.h:237
PI_CCPin * ccPin
Definition: Colony.h:97
void RemovePin(uint32 pinID)
Definition: PlanetDB.cpp:793
void RemoveRoute(uint16 routeID)
Definition: PlanetDB.cpp:813
void RemoveLink(uint32 linkID)
Definition: PlanetDB.cpp:807
uint32 m_colonyID
Definition: Colony.h:112
std::multimap< uint32, PI_Route > m_srcRoutes
Definition: Colony.h:121

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::RemoveRoute ( uint16  routeID)

Definition at line 697 of file Colony.cpp.

References _log, ccPin, m_db, m_destRoutes, m_srcRoutes, PlanetDB::RemoveRoute(), and PI_CCPin::routes.

Referenced by PlanetMgr::RemoveRoute().

698 {
699  std::map<uint16, PI_Route>::iterator routeItr = ccPin->routes.find(routeID);
700  m_srcRoutes.erase(routeItr->second.srcPinID);
701  m_destRoutes.erase(routeItr->second.destPinID);
702  ccPin->routes.erase(routeID);
703  m_db.RemoveRoute(routeID);
704  _log(COLONY__INFO, "Colony::RemoveRoute() - Removed route: %u", routeID);
705 }
std::map< uint16, PI_Route > routes
Definition: EVE_Planet.h:239
#define _log(type, fmt,...)
Definition: logsys.h:124
std::multimap< uint32, PI_Route > m_destRoutes
Definition: Colony.h:123
PlanetDB m_db
Definition: Colony.h:102
PI_CCPin * ccPin
Definition: Colony.h:97
void RemoveRoute(uint16 routeID)
Definition: PlanetDB.cpp:813
std::multimap< uint32, PI_Route > m_srcRoutes
Definition: Colony.h:121

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::Save ( )
Todo:
maybe separate these saves

Definition at line 190 of file Colony.cpp.

References ccPin, m_colonyID, m_db, PI_CCPin::pins, PlanetDB::SaveContents(), PlanetDB::SaveLinks(), PlanetDB::SavePins(), PlanetDB::SaveRoutes(), PlanetDB::UpdatePlanetPins(), and UpdatePlantPins().

Referenced by PlanetMgr::UpdateNetwork().

191 {
193  UpdatePlantPins(); // this MUST be called before Save() and GetColony() to update plant pins with current data
199 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
void UpdatePlanetPins(uint32 ccPinID, uint8 pins=1)
Definition: PlanetDB.cpp:101
void SavePins(PI_CCPin *ccPin)
Definition: PlanetDB.cpp:442
void UpdatePlantPins(uint32 pinID=0)
Definition: Colony.cpp:304
void SaveRoutes(PI_CCPin *ccPin)
Definition: PlanetDB.cpp:689
PlanetDB m_db
Definition: Colony.h:102
void SaveContents(PI_CCPin *ccPin)
Definition: PlanetDB.cpp:733
void SaveLinks(PI_CCPin *ccPin)
Definition: PlanetDB.cpp:626
PI_CCPin * ccPin
Definition: Colony.h:97
uint32 m_colonyID
Definition: Colony.h:112

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::SetProgramResults ( uint32  ecuID,
uint16  typeID,
uint16  numCycles,
float  headRadius,
float  cycleTime,
uint32  qtyPerCycle 
)

Definition at line 832 of file Colony.cpp.

References _log, AttrPinExtractionQuantity, ccPin, Timer::Enabled(), GetFileTimeNow(), EvE::Time::Hour, m_colonyTimer, m_db, PI_CCPin::pins, sItemFactory, sPIDataMgr, Timer::Start(), and PlanetDB::UpdateECUPin().

Referenced by PIDataMgr::GetProgramResultInfo().

833 {
834  std::map<uint32, PI_Pin>::iterator itr = ccPin->pins.find(ecuID);
835  if (itr == ccPin->pins.end()) {
836  _log(COLONY__ERROR, "Colony::SetProgramResults() - ecuPinID %u not found in ccPin.pins map", ecuID);
837  return;
838  }
839 
840  itr->second.cycleTime = cycleTime * EvE::Time::Hour ;
841  itr->second.programType = typeID;
842  itr->second.expiryTime = (cycleTime * numCycles) * EvE::Time::Hour + GetFileTimeNow();
843  itr->second.headRadius = headRadius;
844  itr->second.qtyPerCycle = qtyPerCycle;
845  itr->second.schematicID = sPIDataMgr.GetHeadType(sItemFactory.GetItem(ecuID)->typeID(), typeID);
846 
847  m_db.UpdateECUPin(ecuID, ccPin);
848 
849  // save extraction quantity in ecu attrib this doesnt check for invalid item
850  sItemFactory.GetItem(ecuID)->SetAttribute(AttrPinExtractionQuantity, qtyPerCycle, false);
851 
852  // set process timer to 30m
853  if (!m_colonyTimer.Enabled())
854  m_colonyTimer.Start(30*60*1000);
855 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
#define _log(type, fmt,...)
Definition: logsys.h:124
#define sPIDataMgr
Definition: PlanetDataMgr.h:79
void UpdateECUPin(uint32 pinID, PI_CCPin *ccPin)
Definition: PlanetDB.cpp:536
bool Enabled() const
Definition: timer.h:41
PlanetDB m_db
Definition: Colony.h:102
Timer m_colonyTimer
Definition: Colony.h:100
PI_CCPin * ccPin
Definition: Colony.h:97
double GetFileTimeNow()
Definition: utils_time.cpp:84
#define sItemFactory
Definition: ItemFactory.h:165
void Start(uint32 setTimerTime=0, bool changeResetTimer=true)
Definition: timer.cpp:81

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::SetSchematic ( uint32  pinID,
uint8  schematicID = 0 
)

Definition at line 753 of file Colony.cpp.

References _log, ccPin, Timer::Enabled(), GetFileTimeNow(), PI::Pin::State::Idle, IsTempPinID, m_colonyTimer, m_pLevel, EvE::min(), PI_CCPin::plants, EvE::Time::Second, sPIDataMgr, Timer::Start(), tempPinIDs, and UpdatePlantPins().

Referenced by PlanetMgr::SetSchematic().

754 {
755  if (IsTempPinID(pinID) and (tempPinIDs.size() > 0)) {
756  std::map<uint8, uint32>::iterator itr = tempPinIDs.find(pinID);
757  if (itr != tempPinIDs.end())
758  pinID = itr->second;
759  }
760 
761  std::map<uint32, PI_Plant>::iterator itr = ccPin->plants.find(pinID);
762  if (itr == ccPin->plants.end())
763  _log(COLONY__ERROR, "Colony::SetSchematic() - plantID %u not found in ccPin.plants map", pinID);
764 
765  if (schematicID) {
766  // install new schematic. set lastRunTime to 0
767  sPIDataMgr.GetSchematicData(schematicID, itr->second.data);
768  itr->second.state = PI::Pin::State::Idle;
769  itr->second.pLevel = sPIDataMgr.GetProductLevel(itr->second.data.outputType);
770  itr->second.cycleTime = itr->second.data.cycleTime * EvE::Time::Second;
771  itr->second.installTime = GetFileTimeNow();
772  itr->second.qtyPerCycle = itr->second.data.outputQty;
773  itr->second.schematicID = schematicID;
774  itr->second.lastRunTime = 0;
775  itr->second.hasReceivedInputs = false;
776  itr->second.receivedInputsLastCycle = false;
777 
778  m_pLevel = (uint8)EvE::min(m_pLevel, itr->second.pLevel);
779 
780  // set process timer to 30m
781  if (!m_colonyTimer.Enabled())
782  m_colonyTimer.Start(30*60*1000);
783  _log(COLONY__INFO, "Colony::SetSchematic() - Set Schematic %u in plantID %u", schematicID, pinID);
784  } else {
785  itr->second = PI_Plant();
786  itr->second.data = PI_Schematic();
787  itr->second.state = PI::Pin::State::Idle;
788  _log(COLONY__INFO, "Colony::SetSchematic() - Cleared Schematic from plantID %u", pinID);
789  }
790  // save schematic update
791  UpdatePlantPins(pinID); // this MUST be called before Save() and GetColony() to update plant pin with current data
792 }
unsigned __int8 uint8
Definition: eve-compat.h:46
#define _log(type, fmt,...)
Definition: logsys.h:124
double min(double x, double y)
Definition: misc.h:95
#define IsTempPinID(pinID)
Definition: EVE_Defines.h:194
#define sPIDataMgr
Definition: PlanetDataMgr.h:79
std::map< uint32, PI_Plant > plants
Definition: EVE_Planet.h:241
void UpdatePlantPins(uint32 pinID=0)
Definition: Colony.cpp:304
bool Enabled() const
Definition: timer.h:41
std::map< uint8, uint32 > tempPinIDs
Definition: Colony.h:117
Timer m_colonyTimer
Definition: Colony.h:100
PI_CCPin * ccPin
Definition: Colony.h:97
double GetFileTimeNow()
Definition: utils_time.cpp:84
void Start(uint32 setTimerTime=0, bool changeResetTimer=true)
Definition: timer.cpp:81
uint8 m_pLevel
Definition: Colony.h:109

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::Shutdown ( )

Definition at line 157 of file Colony.cpp.

References ccPin, m_db, PlanetDB::SaveContents(), Update(), and UpdatePlantPins().

158 {
159  Update();
160  UpdatePlantPins();
162 }
void Update(bool updateTimes=false)
Definition: Colony.cpp:1349
void UpdatePlantPins(uint32 pinID=0)
Definition: Colony.cpp:304
PlanetDB m_db
Definition: Colony.h:102
void SaveContents(PI_CCPin *ccPin)
Definition: PlanetDB.cpp:733
PI_CCPin * ccPin
Definition: Colony.h:97

Here is the call graph for this function:

PyDict * Colony::TransferCommodities ( uint32  srcID,
uint32  destID,
std::map< uint16, uint32 items 
)
Todo:
this needs to be updated to use process times (for next cycle end)

Definition at line 864 of file Colony.cpp.

References _log, args, Client::CanThrow(), ccPin, GetFileTimeNow(), m_client, m_db, m_procTime, EvE::Time::Minute, PI_CCPin::pins, PlanetDB::SaveContents(), PyDict::SetItemString(), Update(), and PlanetDB::UpdatePins().

865 {
866  std::map<uint32, PI_Pin>::iterator src = ccPin->pins.find(srcID);
867  if (src == ccPin->pins.end()) {
868  _log(COLONY__ERROR, "Colony::TransferCommodities() - srcPin %u not found in ccPin.pins map", srcID);
869  if (m_client->CanThrow())
870  throw CustomError ("Source not found.");
871  return nullptr; // make error and exit.
872  }
873  std::map<uint32, PI_Pin>::iterator dest = ccPin->pins.find(destID);
874  if (dest == ccPin->pins.end()) {
875  _log(COLONY__ERROR, "Colony::TransferCommodities() - destPin %u not found in ccPin.pins map", destID);
876  if (m_client->CanThrow())
877  throw CustomError ("Destination not found.");
878  return nullptr; // make error and exit.
879  }
880  /*{'FullPath': u'UI/Messages', 'messageID': 256630, 'label': u'ExpeditedTransferNotEnoughSpaceBody'}(u'There is not enough space at the transfer destination for the selected commodities.', None, None)
881  * {'FullPath': u'UI/Messages', 'messageID': 256775, 'label': u'CannotPutMissionItemInCargolinkBody'}(u'You cannot store the {typeName} in a planetary customs facility, as it an agent has issued a special embargo for this particular item.', None, {u'{typeName}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'typeName'}})
882  * {'FullPath': u'UI/Messages', 'messageID': 256776, 'label': u'CannotExportCommodityNotEnoughBody'}(u'Your request to export {desired} units of {typeName} cannot be fulfilled, as the spaceport only has {contained} in stock.', None, {u'{contained}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'contained'}, u'{desired}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'desired'}, u'{typeName}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'typeName'}})
883  * {'FullPath': u'UI/Messages', 'messageID': 256777, 'label': u'CannotExportCommodityNotFoundBody'}(u"You cannot export {typeName}, as your spaceport's storehouse does not appear to contain any.", None, {u'{typeName}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'typeName'}})
884  * {'FullPath': u'UI/Messages', 'messageID': 256778, 'label': u'RouteFailedValidationExpeditedSourceLacksCommodityQtyBody'}(u"You cannot perform this expedited transfer as the facility from which you're sourcing your commodities currently lacks the requested {qty} units of {typeName}.", None, {u'{typeName}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'typeName'}, u'{qty}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'qty'}})
885  * {'FullPath': u'UI/Messages', 'messageID': 256779, 'label': u'RouteFailedValidationExpeditedSourceLacksCommodityBody'}(u'You cannot perform this expedited transfer, as the facility from which you are sourcing your commodities appears to lack the {typeName} which you wish to transfer.', None, {u'{typeName}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'typeName'}})
886  */
887 
888  // capacities are checked in client. procede with xfer
889  for (auto cur : items) {
890  std::map<uint16, uint32>::iterator srcItr = src->second.contents.find(cur.first), destItr = dest->second.contents.find(cur.first);
891  if (srcItr != src->second.contents.end()) {
892  if (srcItr->second > cur.second) {
893  srcItr->second -= cur.second;
894  } else {
895  src->second.contents.erase(srcItr);
896  }
897  } // if src contents not found, assume client is right and procede with xfer
898  if (destItr != dest->second.contents.end()) {
899  destItr->second += cur.second;
900  } else {
901  dest->second.contents[cur.first] = cur.second;
902  }
903  }
904 
905  // update colony
906  Update(true); // must update and save CC's lastLaunchTime here
907  //do we do a full save here, or just update contents and times?
908  //Save();
909  m_db.UpdatePins(0, ccPin);
911 
912  // simTime = time to stop (currentSimTime), sourceRunTime = lastRunTime
913  PyDict* args = new PyDict();
915  args->SetItemString("simTime", new PyLong(GetFileTimeNow() + (EvE::Time::Minute * 15))); // arbitrary 15 minute run time
916  src->second.lastRunTime = 0; //m_procTime;
917  args->SetItemString("sourceRunTime", new PyLong(m_procTime));
918 
919  /*
920  * def GetExpeditedTransferTime(linkBandwidth, commodities):
921  * commodityVolume = GetCommodityTotalVolume(commodities)
922  * return long(math.ceil(max(5 * MIN, float(commodityVolume) / linkBandwidth * HOUR)))
923  */
924  return args;
925 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
void UpdatePins(uint32 pinID, PI_CCPin *ccPin)
Definition: PlanetDB.cpp:485
#define _log(type, fmt,...)
Definition: logsys.h:124
Python's dictionary.
Definition: PyRep.h:719
Client * m_client
Definition: Colony.h:98
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
* args
void Update(bool updateTimes=false)
Definition: Colony.cpp:1349
int64 m_procTime
Definition: Colony.h:114
bool CanThrow()
Definition: Client.h:431
PlanetDB m_db
Definition: Colony.h:102
void SaveContents(PI_CCPin *ccPin)
Definition: PlanetDB.cpp:733
PI_CCPin * ccPin
Definition: Colony.h:97
double GetFileTimeNow()
Definition: utils_time.cpp:84
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:

void Colony::Update ( bool  updateTimes = false)

Definition at line 1349 of file Colony.cpp.

References _log, ccPin, GetFileTimeNow(), SystemEntity::GetName(), GetTimeUSeconds(), is_log_enabled, PI_CCPin::links, m_colonyID, m_destRoutes, m_procTime, m_pSE, m_srcRoutes, m_toUpdate, PI_CCPin::pins, PI_CCPin::plants, ProcessECUs(), ProcessPlants(), and PI_CCPin::routes.

Referenced by GetColony(), Init(), LaunchCommodities(), Load(), PlanetXfer(), Process(), Shutdown(), and TransferCommodities().

1350 {
1351  double profileStartTime = GetTimeUSeconds();
1352 
1353  /* loop thru process calls to update each pin to simulate production and logistics
1354  * this will have to be fast, as there may/will be large time deltas between updates
1355  * can loop each item to process for each time step (like i do for skill training)
1356  */
1357 
1358  if (is_log_enabled(COLONY__DEBUG))
1359  _log(COLONY__DEBUG, "Colony::Update() - Starting Update for colony %u on %s.", m_colonyID, m_pSE->GetName());
1360 
1361  // first, process ecus for raw matls.
1362  ProcessECUs(updateTimes);
1363  // second, process plants for production.
1364  ProcessPlants(updateTimes);
1365  // third, update plants for matl's received
1366 
1367  // update colony time to current time (based on this update, prior to sending out current colony status)
1369 
1370  // update CommandCenter pin times
1371  if (updateTimes) {
1372  std::map<uint32, PI_Pin>::iterator itr = ccPin->pins.find(m_colonyID);
1373  if (itr != ccPin->pins.end())
1374  itr->second.lastRunTime = m_procTime;
1375 
1376  m_toUpdate = true;
1377  }
1378 
1379  // empty colony runs in 47 - 80 us
1380  _log(COLONY__INFO, "Colony::Update() - Update completed in %.3fus with %u links, %u pins, %u plants, and %u routes (s:%u, d:%u) ", \
1381  GetTimeUSeconds() - profileStartTime, ccPin->links.size(), ccPin->pins.size(), ccPin->plants.size(), ccPin->routes.size(), \
1382  m_srcRoutes.size(), m_destRoutes.size());
1383 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
std::map< uint16, PI_Route > routes
Definition: EVE_Planet.h:239
#define _log(type, fmt,...)
Definition: logsys.h:124
void ProcessPlants(bool &save)
Definition: Colony.cpp:1500
std::map< uint32, PI_Plant > plants
Definition: EVE_Planet.h:241
#define is_log_enabled(type)
Definition: logsys.h:78
int64 m_procTime
Definition: Colony.h:114
double GetTimeUSeconds()
Definition: utils_time.cpp:116
std::multimap< uint32, PI_Route > m_destRoutes
Definition: Colony.h:123
PlanetSE * m_pSE
Definition: Colony.h:96
bool m_toUpdate
Definition: Colony.h:107
const char * GetName() const
Definition: SystemEntity.h:210
std::map< uint32, PI_Link > links
Definition: EVE_Planet.h:237
PI_CCPin * ccPin
Definition: Colony.h:97
double GetFileTimeNow()
Definition: utils_time.cpp:84
void ProcessECUs(bool &save)
Definition: Colony.cpp:1385
uint32 m_colonyID
Definition: Colony.h:112
std::multimap< uint32, PI_Route > m_srcRoutes
Definition: Colony.h:121

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::UpdatePlantPins ( uint32  pinID = 0)

Definition at line 304 of file Colony.cpp.

References ccPin, m_db, PI_CCPin::pins, PI_CCPin::plants, and PlanetDB::UpdatePins().

Referenced by LoadPlants(), Save(), SetSchematic(), and Shutdown().

305 {
306  std::map<uint32, PI_Pin>::iterator itr;
307  std::map<uint32, PI_Plant>::iterator itr2;
308  if (pinID) {
309  itr = ccPin->pins.find(pinID);
310  if (itr != ccPin->pins.end()) {
311  itr2 = ccPin->plants.find(pinID);
312  if (itr2 != ccPin->plants.end()) {
313  itr->second.state = itr2->second.state;
314  itr->second.cycleTime = itr2->second.cycleTime;
315  itr->second.installTime = itr2->second.installTime;
316  itr->second.lastRunTime = itr2->second.lastRunTime;
317  itr->second.schematicID = itr2->second.schematicID;
318  itr->second.qtyPerCycle = itr2->second.qtyPerCycle;
319  itr->second.hasReceivedInputs = itr2->second.hasReceivedInputs;
320  itr->second.receivedInputsLastCycle = itr2->second.receivedInputsLastCycle;
321  }
322  }
323  } else {
324  for (auto cur : ccPin->plants) {
325  itr = ccPin->pins.find(cur.first);
326  if (itr != ccPin->pins.end()) {
327  itr->second.state = cur.second.state;
328  itr->second.cycleTime = cur.second.cycleTime;
329  itr->second.installTime = cur.second.installTime;
330  itr->second.lastRunTime = cur.second.lastRunTime;
331  itr->second.schematicID = cur.second.schematicID;
332  itr->second.qtyPerCycle = cur.second.qtyPerCycle;
333  itr->second.hasReceivedInputs = cur.second.hasReceivedInputs;
334  itr->second.receivedInputsLastCycle = cur.second.receivedInputsLastCycle;
335  }
336  }
337  }
338  m_db.UpdatePins(pinID, ccPin);
339 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
void UpdatePins(uint32 pinID, PI_CCPin *ccPin)
Definition: PlanetDB.cpp:485
std::map< uint32, PI_Plant > plants
Definition: EVE_Planet.h:241
PlanetDB m_db
Definition: Colony.h:102
PI_CCPin * ccPin
Definition: Colony.h:97

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::UpgradeCommandCenter ( uint32  pinID,
int8  level 
)

Definition at line 591 of file Colony.cpp.

References _log, ccPin, PI_CCPin::level, m_db, PI_CCPin::pins, and PlanetDB::SaveCCLevel().

Referenced by PlanetMgr::UpgradeCommandCenter().

591  {
592  ccPin->level = level;
593  std::map<uint32, PI_Pin>::iterator itr = ccPin->pins.find(pinID);
594  if (itr != ccPin->pins.end()) {
595  itr->second.level = level;
596  m_db.SaveCCLevel(pinID, level);
597  _log(COLONY__INFO, "Colony::UpgradeCommandCenter() - Upgraded Command Center %u to level:%u", pinID, level);
598  } else {
599  _log(COLONY__ERROR, "Colony::UpgradeCommandCenter() - pinID %u not found in ccPin.pins map", pinID);
600  }
601 }
std::map< uint32, PI_Pin > pins
Definition: EVE_Planet.h:235
#define _log(type, fmt,...)
Definition: logsys.h:124
uint8 level
Definition: EVE_Planet.h:231
PlanetDB m_db
Definition: Colony.h:102
PI_CCPin * ccPin
Definition: Colony.h:97
void SaveCCLevel(uint32 pinID, uint8 level)
Definition: PlanetDB.cpp:432

Here is the call graph for this function:

Here is the caller graph for this function:

void Colony::UpgradeLink ( uint32  src,
uint32  dest,
uint8  level 
)

Definition at line 603 of file Colony.cpp.

References ccPin, PI_CCPin::links, m_db, and PlanetDB::SaveLinks().

Referenced by PlanetMgr::SetLinkLevel().

604 {
605  std::map<uint32, PI_Link>::iterator itr = ccPin->links.begin();
606  for (; itr != ccPin->links.end(); ++itr)
607  if (itr->second.endpoint1 == src)
608  if (itr->second.endpoint2 == dest) {
609  itr->second.level = level;
611  return;
612  }
613 }
PlanetDB m_db
Definition: Colony.h:102
void SaveLinks(PI_CCPin *ccPin)
Definition: PlanetDB.cpp:626
std::map< uint32, PI_Link > links
Definition: EVE_Planet.h:237
PI_CCPin * ccPin
Definition: Colony.h:97

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

bool Colony::m_active
private

Definition at line 104 of file Colony.h.

Referenced by Colony().

Timer Colony::m_colonyTimer
private

Definition at line 100 of file Colony.h.

Referenced by AbandonColony(), LoadPlants(), Process(), SetProgramResults(), and SetSchematic().

uint16 Colony::m_cpu
private

Definition at line 111 of file Colony.h.

Referenced by Colony().

std::multimap<uint32, PI_Route> Colony::m_destRoutes
private

Definition at line 123 of file Colony.h.

Referenced by CreateRoute(), Load(), ProcessECUs(), ProcessPlants(), RemovePin(), RemoveRoute(), and Update().

bool Colony::m_loaded
private

Definition at line 105 of file Colony.h.

Referenced by Colony(), Init(), and Load().

bool Colony::m_newHead
private

Definition at line 106 of file Colony.h.

Referenced by AddExtractorHead(), Colony(), GetColony(), and MoveExtractorHead().

uint16 Colony::m_pg
private

Definition at line 110 of file Colony.h.

Referenced by Colony().

std::multimap<uint8, uint32> Colony::m_plantMap
private

Definition at line 119 of file Colony.h.

Referenced by LoadPlants(), and ProcessPlants().

uint8 Colony::m_pLevel
private

Definition at line 109 of file Colony.h.

Referenced by Colony(), LoadPlants(), ProcessPlants(), and SetSchematic().

int64 Colony::m_procTime
private
PlanetSE* Colony::m_pSE
private
std::multimap<uint32, PI_Route> Colony::m_srcRoutes
private

Definition at line 121 of file Colony.h.

Referenced by CreateRoute(), Load(), ProcessPlants(), RemovePin(), RemoveRoute(), and Update().

PyServiceMgr* Colony::m_svcMgr
private

Definition at line 95 of file Colony.h.

Referenced by LaunchCommodities().

bool Colony::m_toUpdate
private

Definition at line 107 of file Colony.h.

Referenced by Colony(), CreateRoute(), Process(), and Update().

std::vector<uint32> Colony::tempECUs
private

Definition at line 116 of file Colony.h.

Referenced by AddExtractorHead(), GetColony(), and MoveExtractorHead().

std::map<uint8, uint32> Colony::tempPinIDs
private

Definition at line 117 of file Colony.h.

Referenced by Colony(), CreateLink(), CreatePin(), CreateRoute(), GetColony(), and SetSchematic().


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