29 #include <unordered_map>
119 if (!args.Decode(&tmp)) {
120 codelog(SERVICE__ERROR,
"%s: Failed to decode bind args.",
GetName());
124 _log(COLLECT__OTHER_DUMP,
"Trade bind request for:");
125 args.Dump(COLLECT__OTHER_DUMP,
" ");
130 std::map<uint32, ActiveSession>::iterator itr =
m_activeSessions.find(args.myID);
145 cAS.
myID = args.myID;
146 cAS.
herID = args.herID;
178 _log(CLIENT__ERROR,
"TradeBound::Handle_OfferMoney() : %s(%u) - clients are neither mine nor hers.", \
231 if (itemRef.
get() ==
nullptr) {
232 _log(PLAYER__ERROR,
"TradeBound::CancelTrade() - Failed to get ItemRef.");
259 _log(PLAYER__TRADE_MESSAGE,
"TradeBound::Handle_ToggleAccept() : %s(%u) - clients are neither mine nor hers.", \
264 bool forceTrade =
false;
265 if (call.
byname.find(
"forceTrade") != call.
byname.cend())
266 if (!call.
byname.find(
"forceTrade")->second->IsNone())
267 forceTrade = call.
byname.find(
"forceTrade")->second->AsBool()->value();
277 _log(PLAYER__TRADE_MESSAGE,
"TradeBound::Handle_ToggleAccept() is now %s/%s. forceTrade is %s.", \
278 (myAccept ?
"true" :
"false"), (herAccept ?
"true" :
"false"), (forceTrade ?
"true" :
"false"));
289 if (myAccept && herAccept) {
302 _log(CLIENT__CALL_DUMP,
"TradeBound::Handle_GetItemID()");
303 call.
Dump(CLIENT__CALL_DUMP);
311 Call_TwoIntegerArgs
args;
316 if (!args.Decode(&call.
tuple)) {
317 codelog(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
318 return Handle_Abort(call);
322 if (itemRef.
get() ==
nullptr) {
323 _log(PLAYER__TRADE_MESSAGE,
"TradeBound::Handle_Add() - Failed to get ItemRef.");
339 _log(PLAYER__TRADE_MESSAGE,
"TradeBound::Handle_Add() : %s(%u) & %s(%u) - clients are neither mine nor hers.", \
397 TradeMultiAddList
args;
402 if (!args.Decode(&call.
tuple)) {
403 codelog(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
404 return Handle_Abort(call);
423 _log(PLAYER__TRADE_MESSAGE,
"TradeBound::Handle_MultiAdd() : %s(%u) & %s(%u) - clients are neither mine nor hers.", \
432 std::vector<int32> list = args.ints;
433 for (
auto cur : list) {
435 if (itemRef.
get() ==
nullptr) {
436 _log(PLAYER__ERROR,
"TradeBound::Handle_Add() - Failed to get ItemRef.");
497 _log(CLIENT__CALL_DUMP,
"TradeBound::Handle_IsCEOTrade()");
498 call.
Dump(CLIENT__CALL_DUMP);
517 row->
SetField(
"quantity",
new PyInt(cur.singleton?-1:cur.quantity));
545 tlr.header = itemNames;
546 tlr.line = tld.Encode();
557 std::string reason =
"Player Trade between ";
573 _log(PLAYER__ERROR,
"TradeBound::Handle_Add() - Failed to get ItemRef.");
600 std::map<uint32, InventoryItemRef> InventoryMap;
601 InventoryMap.clear();
607 if (shipRef.get() ==
nullptr)
609 if (!shipRef->GetMyInventory()->IsEmpty())
610 shipRef->GetMyInventory()->GetInventoryMap(InventoryMap);
613 if (contRef.
get() ==
nullptr)
619 for (
auto cur : InventoryMap)
620 cur.second->ChangeOwner(newOwnerID,
true);
627 call.
client->
SendErrorMsg(
"You are currently trading with %s. You can only trade with one player at a time.", target->GetName());
631 Call_SingleIntegerArg
args;
633 if (!args.Decode(&call.
tuple)) {
634 codelog(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
638 target =
sEntityList.FindClientByCharID( args.arg );
639 if (target->GetTradeSession()) {
650 InitiateTradeRsp_NoCash rsp_nc;
652 rsp_nc.stationID = target->GetStationID();
654 rsp_nc.herID = target->GetCharacterID();
TradeService(PyServiceMgr *mgr)
Dispatcher *const m_dispatch
void ExchangeItems(Client *pClient, Client *pOther, TradeSession *pTSes)
void SendNotification(const PyAddress &dest, EVENotificationStream ¬i, bool seq=true)
std::map< uint32, ActiveSession > m_activeSessions
PyCallable_DECL_CALL(List)
void SendErrorMsg(const char *fmt,...)
#define _log(type, fmt,...)
PyRep * GetItem(size_t index) const
Returns Python object.
PyServiceMgr & services() const
std::map< std::string, PyRep * > byname
virtual PyRep * Clone() const =0
Clones object.
virtual PyBoundObject * CreateBoundObject(Client *pClient, const PyRep *bind_args)
PyRep * Clone() const
Clones object.
Python floating point number.
PyCallable_Make_Dispatcher(TradeBound) TradeBound(PyServiceMgr *mgr)
int32 GetCharacterID() const
static uint32 IntegerValueU32(PyRep *pRep)
std::string m_strBoundObjectName
const char * GetName() const
void TransferContainerContents(SystemManager *pSysMgr, InventoryItemRef itemRef, uint32 newOwnerID)
void Move(uint32 new_location=locTemp, EVEItemFlags flag=flagNone, bool notify=false)
void CancelTrade(Client *pClient)
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
void _SetCallDispatcher(CallDispatcher *d)
uint32 GetTradeSessionID()
ShipItemRef GetShipFromInventory(uint32 shipID)
Dispatcher *const m_dispatch
Python object "blue.DBRowDescriptor".
#define codelog(type, fmt,...)
CargoContainerRef GetContainerFromInventory(uint32 contID)
void SetItem(size_t index, PyRep *object)
Stores Python object.
SystemManager * SystemMgr() const
static void DeleteInsuranceByShipID(uint32 shipID)
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)
void SetItem(size_t index, PyRep *object)
Stores Python object.
TradeSession * GetTradeSession()
void InitiateTrade(Client *pClient, PyRep *resp)
PyServiceMgr *const m_manager
void SetTradeSession(TradeSession *ts)
const char * GetName() const
void ChangeOwner(uint32 new_owner, bool notify=false)
PyCallable_Make_InnerDispatcher(TradeService)
#define PyCallable_REG_CALL(c, m)
EVEItemFlags flag() const
std::string GetCharName()
void GetInventoryMap(std::map< uint32, InventoryItemRef > &invMap)
Python token (eg. class name).
void RemoveActiveSession(uint32 myID)
Dispatcher *const m_dispatch
bool SetField(uint32 index, PyRep *value)
void Dump(LogType type) const
int32 GetStationID() const
std::list< TradeItems > m_tradelist
static int64 IntegerValue(PyRep *pRep)
std::string GetSystemName() const
void CancelTrade(Client *pClient, Client *pOther, TradeSession *pTSes)
Inventory * GetMyInventory()
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
const char * GetName() const