EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TradeBound Class Reference
Inheritance diagram for TradeBound:
Collaboration diagram for TradeBound:

Public Member Functions

 PyCallable_Make_Dispatcher (TradeBound) TradeBound(PyServiceMgr *mgr)
 
virtual ~TradeBound ()
 
virtual void Release ()
 
void ExchangeItems (Client *pClient, Client *pOther, TradeSession *pTSes)
 
void CancelTrade (Client *pClient, Client *pOther, TradeSession *pTSes)
 
 PyCallable_DECL_CALL (List)
 
 PyCallable_DECL_CALL (IsCEOTrade)
 
 PyCallable_DECL_CALL (GetItemID)
 
 PyCallable_DECL_CALL (GetItem)
 
 PyCallable_DECL_CALL (Add)
 
 PyCallable_DECL_CALL (MultiAdd)
 
 PyCallable_DECL_CALL (ToggleAccept)
 
 PyCallable_DECL_CALL (OfferMoney)
 
 PyCallable_DECL_CALL (Abort)
 
- Public Member Functions inherited from PyBoundObject
 PyBoundObject (PyServiceMgr *mgr)
 
virtual ~PyBoundObject ()
 
uint32 nodeID () const
 
uint32 bindID () const
 
std::string GetBindStr () const
 
const char * GetName () const
 
virtual PyResult Call (const std::string &method, PyCallArgs &args)
 
- Public Member Functions inherited from PyCallable
 PyCallable ()
 
virtual ~PyCallable ()
 

Protected Attributes

Dispatcher *const m_dispatch
 
TradeServicem_TSvc
 
- Protected Attributes inherited from PyBoundObject
PyServiceMgr *const m_manager
 
std::string m_strBoundObjectName
 

Private Attributes

friend TradeService
 

Additional Inherited Members

- Protected Member Functions inherited from PyBoundObject
void _SetNodeBindID (uint32 nodeID, uint32 bindID)
 
- Protected Member Functions inherited from PyCallable
void _SetCallDispatcher (CallDispatcher *d)
 

Detailed Description

Definition at line 42 of file TradeService.cpp.

Constructor & Destructor Documentation

virtual TradeBound::~TradeBound ( )
inlinevirtual

Definition at line 69 of file TradeService.cpp.

References m_dispatch.

70  {
71  delete m_dispatch;
72  }
Dispatcher *const m_dispatch

Member Function Documentation

void TradeBound::CancelTrade ( Client pClient,
Client pOther,
TradeSession pTSes 
)

Definition at line 222 of file TradeService.cpp.

References _log, TradeSession::Session::containerID, flagHangar, RefPtr< X >::get(), Inv::Update::Location, TradeSession::m_tradelist, TradeSession::m_tradeSession, InventoryItem::Move(), PyDict::SetItem(), sItemFactory, and TradeSession::Session::stationID.

Referenced by TradeService::CancelTrade().

223 {
224  // trade canceled. send items back to owner. (monies not taken at this point)
225  PyDict* dict = new PyDict();
227 
228  uint32 stationID = pTSes->m_tradeSession.stationID;
229  for (auto cur : pTSes->m_tradelist) {
230  InventoryItemRef itemRef = sItemFactory.GetItem(cur.itemID);
231  if (itemRef.get() == nullptr) {
232  _log(PLAYER__ERROR, "TradeBound::CancelTrade() - Failed to get ItemRef.");
233  continue;
234  }
235 
236  itemRef->Move(stationID, flagHangar, true);
237  }
238 }
#define _log(type, fmt,...)
Definition: logsys.h:124
Python's dictionary.
Definition: PyRep.h:719
void Move(uint32 new_location=locTemp, EVEItemFlags flag=flagNone, bool notify=false)
Python integer.
Definition: PyRep.h:231
Session m_tradeSession
Definition: TradeService.h:105
X * get() const
Definition: RefPtr.h:213
unsigned __int32 uint32
Definition: eve-compat.h:50
#define sItemFactory
Definition: ItemFactory.h:165
std::list< TradeItems > m_tradelist
Definition: TradeService.h:107
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:

void TradeBound::ExchangeItems ( Client pClient,
Client pOther,
TradeSession pTSes 
)

Definition at line 550 of file TradeService.cpp.

References _log, EVEDB::invGroups::Audit_Log_Secure_Container, EVEDB::invGroups::Cargo_Container, InventoryItem::categoryID(), InventoryItem::ChangeOwner(), TradeSession::Session::containerID, flagHangar, EVEDB::invGroups::Freight_Container, Client::GetCharacterID(), Client::GetCharName(), Client::GetStationID(), Client::GetSystemName(), InventoryItem::groupID(), TradeSession::Session::herID, TradeSession::Session::herMoney, Inv::Update::Location, TradeSession::m_tradelist, TradeSession::m_tradeSession, m_TSvc, InventoryItem::Move(), TradeSession::Session::myID, TradeSession::Session::myMoney, Journal::EntryType::PlayerTrading, PyIncRef, EVEDB::invGroups::Secure_Cargo_Container, Client::SendNotification(), sEntityList, PyTuple::SetItem(), EVEDB::invCategories::Ship, sItemFactory, TradeSession::Session::stationID, Client::SystemMgr(), AccountService::TranserFunds(), and TradeService::TransferContainerContents().

550  {
551  // trade completed. perform item and money exchange
552  if (pClient->GetCharacterID() == pTSes->m_tradeSession.herID) {
553  pOther = sEntityList.FindClientByCharID(pTSes->m_tradeSession.herID);
554  pClient = sEntityList.FindClientByCharID(pTSes->m_tradeSession.myID);
555  }
556  // transfer funds and add journal entries for both sides
557  std::string reason = "Player Trade between ";
558  reason += pClient->GetCharName();
559  reason += " and ";
560  reason += pOther->GetCharName();
561  reason += " in ";
562  reason += pClient->GetSystemName(); // use system name or station name here?
565 
566  PyDict* dict = new PyDict();
567  dict->SetItem(new PyInt(Inv::Update::Location), new PyInt(pTSes->m_tradeSession.containerID));
568 
569  uint32 stationID = pTSes->m_tradeSession.stationID;
570  for (auto cur : pTSes->m_tradelist) {
571  InventoryItemRef itemRef = sItemFactory.GetItem(cur.itemID);
572  if (!itemRef) {
573  _log(PLAYER__ERROR, "TradeBound::Handle_Add() - Failed to get ItemRef.");
574  continue;
575  }
576 
577  uint32 newOwnerID = (cur.ownerID == pTSes->m_tradeSession.myID ? pTSes->m_tradeSession.herID : pTSes->m_tradeSession.myID);
578  itemRef->ChangeOwner(newOwnerID, true);
579  itemRef->Move(stationID, flagHangar, true);
580 
581  if ((itemRef->categoryID() == EVEDB::invCategories::Ship)
583  || (itemRef->groupID() == EVEDB::invGroups::Cargo_Container)
586  m_TSvc->TransferContainerContents(pClient->SystemMgr(), itemRef, newOwnerID);
587  }
588 
589  PyTuple* tuple = new PyTuple(2);
590  tuple->SetItem(0, new PyString("TradeComplete"));
591  tuple->SetItem(1, new PyInt(pTSes->m_tradeSession.containerID));
592  PyIncRef(tuple);
593  // now send it, bypassing the extra shit and wrong dest name added in Client::SendNotification
594  pClient->SendNotification("OnTrade", "charid", &tuple);
595  pOther->SendNotification("OnTrade", "charid", &tuple);
596 }
void SendNotification(const PyAddress &dest, EVENotificationStream &noti, bool seq=true)
Definition: Client.cpp:2245
#define _log(type, fmt,...)
Definition: logsys.h:124
Python string.
Definition: PyRep.h:430
Python's dictionary.
Definition: PyRep.h:719
int32 GetCharacterID() const
Definition: Client.h:113
#define sEntityList
Definition: EntityList.h:208
Python tuple.
Definition: PyRep.h:567
void TransferContainerContents(SystemManager *pSysMgr, InventoryItemRef itemRef, uint32 newOwnerID)
void Move(uint32 new_location=locTemp, EVEItemFlags flag=flagNone, bool notify=false)
uint16 groupID() const
TradeService * m_TSvc
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:610
SystemManager * SystemMgr() const
Definition: Client.h:92
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)
Python integer.
Definition: PyRep.h:231
Session m_tradeSession
Definition: TradeService.h:105
void ChangeOwner(uint32 new_owner, bool notify=false)
unsigned __int32 uint32
Definition: eve-compat.h:50
#define PyIncRef(op)
Definition: PyRep.h:56
std::string GetCharName()
Definition: Client.h:165
#define sItemFactory
Definition: ItemFactory.h:165
int32 GetStationID() const
Definition: Client.h:114
std::list< TradeItems > m_tradelist
Definition: TradeService.h:107
std::string GetSystemName() const
Definition: Client.h:155
uint8 categoryID() const

Here is the call graph for this function:

TradeBound::PyCallable_DECL_CALL ( List  )
TradeBound::PyCallable_DECL_CALL ( IsCEOTrade  )
TradeBound::PyCallable_DECL_CALL ( GetItemID  )
TradeBound::PyCallable_DECL_CALL ( GetItem  )
TradeBound::PyCallable_DECL_CALL ( Add  )
TradeBound::PyCallable_DECL_CALL ( MultiAdd  )
TradeBound::PyCallable_DECL_CALL ( ToggleAccept  )
TradeBound::PyCallable_DECL_CALL ( OfferMoney  )
TradeBound::PyCallable_DECL_CALL ( Abort  )
TradeBound::PyCallable_Make_Dispatcher ( TradeBound  )
inline

Definition at line 48 of file TradeService.cpp.

References PyCallable::_SetCallDispatcher(), EvERam::Status::Abort, Corp::Actions::Add, m_dispatch, PyBoundObject::m_strBoundObjectName, m_TSvc, and PyCallable_REG_CALL.

51  : PyBoundObject(mgr),
52  m_dispatch(new Dispatcher(this))
53  {
55 
56  m_strBoundObjectName = "TradeBound";
57  m_TSvc = (TradeService*)(mgr->LookupService("trademgr"));
58 
60  PyCallable_REG_CALL(TradeBound, IsCEOTrade);
61  PyCallable_REG_CALL(TradeBound, GetItemID);
65  PyCallable_REG_CALL(TradeBound, ToggleAccept);
66  PyCallable_REG_CALL(TradeBound, OfferMoney);
68  }
std::string m_strBoundObjectName
Definition: PyBoundObject.h:54
void _SetCallDispatcher(CallDispatcher *d)
Definition: PyCallable.h:87
TradeService * m_TSvc
Dispatcher *const m_dispatch
PyBoundObject(PyServiceMgr *mgr)
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78

Here is the call graph for this function:

virtual void TradeBound::Release ( )
inlinevirtual

Implements PyBoundObject.

Definition at line 74 of file TradeService.cpp.

74  {
75  //this needs to die
76  delete this;
77  }

Member Data Documentation

Dispatcher* const TradeBound::m_dispatch
protected

Definition at line 93 of file TradeService.cpp.

Referenced by PyCallable_Make_Dispatcher(), and ~TradeBound().

TradeService* TradeBound::m_TSvc
protected

Definition at line 94 of file TradeService.cpp.

Referenced by ExchangeItems(), and PyCallable_Make_Dispatcher().

friend TradeBound::TradeService
private

Definition at line 45 of file TradeService.cpp.


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