80 return sMktMgr.GetMarketGroups();
113 Call_SingleIntegerArg
args;
114 if (!args.Decode(&call.
tuple)) {
115 _log(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
123 Call_SingleIntegerArg
args;
124 if (!args.Decode(&call.
tuple)) {
125 _log(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
134 Call_GetNewCharTransactions
args;
135 if (!args.Decode(&call.
tuple)) {
136 _log(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
142 data.
isBuy = args.sellBuy;
143 data.
price = args.minPrice;
145 data.
typeID = args.typeID;
146 data.
time = args.fromDate;
153 Call_GetNewCorpTransactions
args;
154 if (!args.Decode(&call.
tuple)) {
155 _log(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
161 data.
isBuy = args.sellBuy;
162 data.
price = args.minPrice;
164 data.
typeID = args.typeID;
165 data.
time = args.fromDate;
172 Call_SingleIntegerArg
args;
173 if (!args.Decode(&call.
tuple)) {
174 _log(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
178 PyRep* result(
nullptr);
179 std::string method_name (
"GetOrders_");
182 method_name += std::to_string(args.arg);
189 if (result ==
nullptr) {
190 _log(MARKET__DB_ERROR,
"Failed to load cache, generating empty contents.");
230 Call_PlaceCharOrder
args;
231 if (!args.Decode(&call.
tuple)) {
232 _log(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
239 _log(MARKET__DUMP,
"Mkt::PlaceCharOrder()");
240 args.Dump(MARKET__DUMP,
" ");
246 call.
client->
SendErrorMsg(
"Corporation Market transactions are not available at this time.");
259 if (args.bid and (args.itemID == 0)) {
261 float fStanding(0), cStanding(0);
281 if (args.duration == 0) {
287 _log(MARKET__TRACE,
"PlaceCharOrder - Found sell order #%u in %s for %s. (type %i, price %.2f, qty %i, range %i)", \
288 orderID,
stDataMgr.GetStationName(args.stationID).c_str(), call.
client->
GetName(), args.typeID, args.price, args.quantity, args.orderRange);
294 _log(MARKET__TRACE,
"PlaceCharOrder - Failed to satisfy buy order for %i of type %i at %.2f ISK.", \
295 args.quantity, args.typeID, args.price);
301 float money(args.price * args.quantity);
310 data.
isCorp = args.useCorp;
311 data.
typeID = args.typeID;
317 data.
price = args.price;
331 _log(MARKET__ERROR,
"PlaceCharOrder - Failed to record buy order in the DB.");
336 std::string reason =
"DESC: Setting up buy order in ";
337 reason +=
stDataMgr.GetStationName(args.stationID).c_str();
343 float factionStanding = 0.0f;
349 _log(MARKET__DEBUG,
"PlaceCharOrder(buy) - %s: Escrow: %.2f, Fee: %.2f", args.useCorp?
"Corp":
"Player", money, fee);
368 if (!args.located->IsNone()) {
378 if (iRef.
get() ==
nullptr) {
379 _log(ITEM__ERROR,
"PlaceCharOrder - Failed to find item %i for sell order.", args.itemID);
384 if (iRef->
typeID() != args.typeID) {
385 _log(MARKET__MESSAGE,
"PlaceCharOrder - Denying Sell of typeID %u using typeID %i.", call.
client->
GetName(), iRef->
itemID(), iRef->
typeID(), args.typeID);
390 if (iRef->
quantity() < args.quantity) {
392 _log(MARKET__MESSAGE,
"PlaceCharOrder - Denying inflated qty for %s", call.
client->
GetName());
393 call.
client->
SendErrorMsg(
"You cannot sell %i %s when you only have %i. If applicable, merge stacks and try again.", \
411 _log(MARKET__WARNING,
"%s(%u) Tried to sell %i %s owned by %u in %s.", \
413 iRef->name(), iRef->
ownerID(),
stDataMgr.GetStationName(args.stationID).c_str());
430 itemLoc =
"an Invalid Location";
432 _log(MARKET__ERROR,
"%s Trying to sell %s(%u) in %s through %s while in %s", \
435 call.
client->
SendErrorMsg(
"You cannot sell %s from %s while you are in %s. Locations mismatch", \
445 if (args.duration == 0) {
448 uint32 orderID(0), origQty(args.quantity);
449 while (args.quantity and search) {
452 _log(MARKET__TRACE,
"PlaceCharOrder - Found buy order #%u in %s for %s.", \
454 search =
sMktMgr.ExecuteBuyOrder(call.
client, orderID, iRef, args);
459 if (args.quantity == 0) {
462 }
else if (args.quantity == origQty) {
465 _log(MARKET__TRACE,
"PlaceCharOrder - Failed to find any buy order for type %i at %.2f ISK.", \
466 args.typeID, args.price);
471 _log(MARKET__TRACE,
"PlaceCharOrder - Failed to find buy orders for remaining %i of type %i at %.2f ISK.", \
472 args.quantity, args.typeID, args.price);
473 call.
client->
SendErrorMsg(
"There were only buyers for %u of the %i items you wanted to sell.", args.quantity, origQty);
477 _log(MARKET__ERROR,
"PlaceCharOrder - immediate order qty hit end of conditional.");\
490 data.
isCorp = args.useCorp;
491 data.
typeID = args.typeID;
497 data.
price = args.price;
525 float total = args.price * args.quantity;
526 std::string reason =
"DESC: Setting up sell order in ";
527 reason +=
stDataMgr.GetStationName(args.stationID).c_str();
533 float factionStanding = 0.0f;
539 _log(MARKET__DEBUG,
"PlaceCharOrder(sell) - %s: Total: %.2f, Fee: %.2f", args.useCorp?
"Corp":
"Player", total, fee);
553 _log(MARKET__ERROR,
"PlaceCharOrder - Failed to record sell order in the DB.");
558 if (iRef->
quantity() == args.quantity) {
565 _log(MARKET__ERROR,
"PlaceCharOrder - Failed to consume %i units from %s", args.quantity, iRef->
name());
580 Call_ModifyCharOrder
args;
581 if (!args.Decode(&call.
tuple)) {
582 _log(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
590 _log(MARKET__ERROR,
"ModifyCharOrder - Failed to get info about order #%u.", args.orderID);
597 float money = (args.price - args.newPrice) * args.volRemaining;
598 std::string reason =
"DESC: Altering Market Order #";
599 reason += std::to_string(args.orderID);
605 _log(MARKET__ERROR,
"ModifyCharOrder - Failed to modify price for order #%u.", call.
client->
GetName(), args.orderID);
616 Call_CancelCharOrder
args;
617 if (!args.Decode(&call.
tuple)) {
618 _log(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
624 _log(MARKET__ERROR,
"CancelCharOrder - Failed to get info about order #%u.", args.orderID);
632 std::string reason =
"DESC: Canceling Market Order #";
633 reason += std::to_string(args.orderID);
640 if (iRef.
get() !=
nullptr)
646 _log(MARKET__ERROR,
"CancelCharOrder - Failed to delete order #%u.", args.orderID);
static float GetStanding(uint32 fromID, uint32 toID)
PyRep * GetRegionBest(uint32 regionID)
Dispatcher *const m_dispatch
#define IsNPCCorp(itemID)
void Donate(uint32 new_owner=ownerSystem, uint32 new_location=locTemp, EVEItemFlags new_flag=flagNone, bool notify=true)
bool GetOrderInfo(uint32 orderID, Market::OrderInfo &oInfo)
void SendErrorMsg(const char *fmt,...)
uint32 GetSystemID() const
#define _log(type, fmt,...)
int64 GetCorpRole() const
PyRep * GetOrdersForOwner(uint32 ownerID)
PyRep * GetStationAsks(uint32 stationID)
PyRep * GetTransactions(uint32 ownerID, Market::TxData &data)
PyRep * GetOrders(uint32 regionID, uint16 typeID)
uint32 GetRegionID() const
Dispatcher *const m_dispatch
int32 GetCharacterID() const
int32 GetCorporationID() const
UserError & AddFormatValue(const char *name, PyRep *value)
Fluent version of the protected AddKeyword, allows for adding a keyword to the exception.
bool AlterOrderPrice(uint32 orderID, double new_price)
CharacterRef GetChar() const
const char * GetName() const
bool ContainsItem(uint32 itemID) const
PyRep * GetOrderRow(uint32 orderID)
SystemManager * SystemMgr() const
PyCallable_Make_InnerDispatcher(MarketProxyService) MarketProxyService
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)
uint32 locationID() const
bool AlterQuantity(int32 qty, bool notify=false)
void RemoveItemFromInventory(InventoryItemRef item)
PyServiceMgr *const m_manager
ShipItemRef GetShip() const
const char * GetName() const
#define IsPlayerCorp(itemID)
uint32 FindBuyOrder(Call_PlaceCharOrder &call)
Python object "ccp_exceptions.UserError".
#define PyCallable_REG_CALL(c, m)
void GiveCache(const PyRep *objectID, PyRep **contents)
virtual ~MarketProxyService()
float BrokerFee(uint8 brSkillLvl, float fStanding, float cStanding, float total)
int32 GetCorpAccountKey() const
ObjCacheService * cache_service
int8 GetSkillLevel(uint16 skillTypeID, bool zeroForNotInjected=true) const
int32 GetStationID() const
bool DeleteOrder(uint32 orderID)
uint32 StoreOrder(Market::SaveData &data)
Inventory * GetMyInventory()
PyObject * MakeObjectCachedMethodCallResult(const PyRep *objectID, const char *versionCheck="run")
PyRep * GetSystemAsks(uint32 solarSystemID)
bool IsCacheLoaded(const PyRep *objectID) const
uint32 FindSellOrder(Call_PlaceCharOrder &call)