EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MarketMgr.h
Go to the documentation of this file.
1 
12 #ifndef _EVE_SERVER_MARKET_MANAGER_H__
13 #define _EVE_SERVER_MARKET_MANAGER_H__
14 
15 
16 #include "../eve-server.h"
17 
18 #include "EntityList.h"
19 #include "market/MarketDB.h"
20 
21 class Client;
22 
23 class MarketMgr
24 : public Singleton< MarketMgr >
25 {
26 public:
27  MarketMgr();
28  ~MarketMgr();
29 
30  int Initialize(PyServiceMgr* pManager);
31 
32  void Close();
33  void GetInfo();
34  void Process();
35 
36  void SystemStartup(SystemData &data);
37  void SystemShutdown(SystemData &data);
38 
39  void UpdatePriceHistory();
40 
41  // fulfill market order placed by buyer to buy items (usually at reduced prices).
42  // updates qty in args based on order request. returns false if/when entire quantity is filled.
43  bool ExecuteBuyOrder(Client *seller, uint32 orderID, InventoryItemRef iRef, Call_PlaceCharOrder &args, uint16 accountKey = Account::KeyType::Cash);
44  // market order placed by seller to sell items (usually at higher prices)
45  void ExecuteSellOrder(Client *buyer, uint32 orderID, Call_PlaceCharOrder &args);
46  //forces a refresh of market data.
47  void SendOnOwnOrderChanged(Client* pClient, uint32 orderID, uint8 action, bool isCorp = false, PyRep* order = nullptr);
48 
49  void InvalidateOrdersCache(uint32 regionID, uint32 typeID);
50 
51  bool NeedsUpdate() { return m_timeStamp > GetFileTimeNow()?false:true; }
52 
54  // cached
55  PyRep* GetNewPriceHistory(uint32 regionID, uint32 typeID);
56  // cached
57  PyRep* GetOldPriceHistory(uint32 regionID, uint32 typeID);
58 
59 
60  // base price update method
61  void SetBasePrice(); // this uses current mineral values to estimate base price of item
62  void UpdateMineralPrice();
63  void GetCruPrices();
64 
65 
66 protected:
67  void Populate();
68 
69 private:
72 
73  PyRep* m_marketGroups; // static market group data
74 
76 
77  // markets are regional. there are 66 regions.
78  // market orders are stored as {regionID/typeID}
79  // load market data by region, sorted by system/station.
80  // station data will also store StationRef to owning/containing station for easier access later
81  // will be able to implement 'jumps' and other market conditionals
82  // ** this could take ~16m for average market data per region
83 };
84 
85 //Singleton
86 #define sMktMgr \
87 ( MarketMgr::get() )
88 
89 
90 #endif // _EVE_SERVER_MARKET_MANAGER_H__
91 
92 /*
93  * def GetStationDistance(self, stationID, getFastestRoute = True):
94  * if session.stationid == stationID:
95  * return -1
96  * station = sm.GetService('ui').GetStation(stationID)
97  * solarSystemID = station.solarSystemID
98  * regionID = sm.GetService('map').GetRegionForSolarSystem(solarSystemID)
99  * if regionID != session.regionid:
100  * return const.rangeRegion
101  * if getFastestRoute:
102  * jumps = sm.StartService('pathfinder').GetShortestJumpCountFromCurrent(solarSystemID)
103  * else:
104  * jumps = sm.StartService('pathfinder').GetJumpCountFromCurrent(solarSystemID)
105  * if jumps >= 1:
106  * return jumps
107  * return 0
108  */
109 
110 /*
111  * def GetSkillLimits(self):
112  * limits = {}
113  * currentOpen = 0
114  * myskills = sm.GetService('skills').MySkillLevelsByID()
115  * retailLevel = myskills.get(const.typeRetail, 0)
116  * tradeLevel = myskills.get(const.typeTrade, 0)
117  * wholeSaleLevel = myskills.get(const.typeWholesale, 0)
118  * accountingLevel = myskills.get(const.typeAccounting, 0)
119  * brokerLevel = myskills.get(const.typeBrokerRelations, 0)
120  * tycoonLevel = myskills.get(const.typeTycoon, 0)
121  * marginTradingLevel = myskills.get(const.typeMarginTrading, 0)
122  * marketingLevel = myskills.get(const.typeMarketing, 0)
123  * procurementLevel = myskills.get(const.typeProcurement, 0)
124  * visibilityLevel = myskills.get(const.typeVisibility, 0)
125  * daytradingLevel = myskills.get(const.typeDaytrading, 0)
126  * maxOrderCount = 5 + tradeLevel * 4 + retailLevel * 8 + wholeSaleLevel * 16 + tycoonLevel * 32
127  * limits['cnt'] = maxOrderCount
128  * commissionPercentage = const.marketCommissionPercentage / 100.0
129  * commissionPercentage *= 1 - brokerLevel * 0.05
130  * transactionTax = const.mktTransactionTax / 100.0
131  * transactionTax *= 1 - accountingLevel * 0.1
132  * limits['fee'] = commissionPercentage
133  * limits['acc'] = transactionTax
134  * limits['ask'] = jumpsPerSkillLevel[marketingLevel]
135  * limits['bid'] = jumpsPerSkillLevel[procurementLevel]
136  * limits['vis'] = jumpsPerSkillLevel[visibilityLevel]
137  * limits['mod'] = jumpsPerSkillLevel[daytradingLevel]
138  * limits['esc'] = 0.75 ** marginTradingLevel
139  * return limits
140  */
Base Python wire object.
Definition: PyRep.h:66
unsigned __int8 uint8
Definition: eve-compat.h:46
PyRep * m_marketGroups
Definition: MarketMgr.h:73
void SystemStartup(SystemData &data)
Definition: MarketMgr.cpp:91
void UpdatePriceHistory()
Definition: MarketMgr.cpp:101
PyRep * GetMarketGroups()
Definition: MarketMgr.h:53
PyRep * GetOldPriceHistory(uint32 regionID, uint32 typeID)
Definition: MarketMgr.cpp:190
void GetCruPrices()
Definition: MarketMgr.cpp:916
PyRep * GetNewPriceHistory(uint32 regionID, uint32 typeID)
Definition: MarketMgr.cpp:148
void InvalidateOrdersCache(uint32 regionID, uint32 typeID)
Definition: MarketMgr.cpp:264
* args
void SendOnOwnOrderChanged(Client *pClient, uint32 orderID, uint8 action, bool isCorp=false, PyRep *order=nullptr)
Definition: MarketMgr.cpp:231
MarketDB m_db
Definition: MarketMgr.h:70
void GetInfo()
Definition: MarketMgr.cpp:78
int Initialize(PyServiceMgr *pManager)
Definition: MarketMgr.cpp:53
void SetBasePrice()
Definition: MarketMgr.cpp:610
Definition: Client.h:66
unsigned __int32 uint32
Definition: eve-compat.h:50
#define PyIncRef(op)
Definition: PyRep.h:56
void ExecuteSellOrder(Client *buyer, uint32 orderID, Call_PlaceCharOrder &args)
Definition: MarketMgr.cpp:497
double GetFileTimeNow()
Definition: utils_time.cpp:84
signed __int64 int64
Definition: eve-compat.h:51
void Populate()
Definition: MarketMgr.cpp:64
Template used for singleton classes.
Definition: Singleton.h:43
void Process()
Definition: MarketMgr.cpp:83
int64 m_timeStamp
Definition: MarketMgr.h:75
void SystemShutdown(SystemData &data)
Definition: MarketMgr.cpp:96
void Close()
Definition: MarketMgr.cpp:46
unsigned __int16 uint16
Definition: eve-compat.h:48
bool ExecuteBuyOrder(Client *seller, uint32 orderID, InventoryItemRef iRef, Call_PlaceCharOrder &args, uint16 accountKey=Account::KeyType::Cash)
Definition: MarketMgr.cpp:303
bool NeedsUpdate()
Definition: MarketMgr.h:51
PyServiceMgr * m_manager
Definition: MarketMgr.h:71
void UpdateMineralPrice()
Definition: MarketMgr.cpp:903