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

#include "ReprocessingService.h"

Inheritance diagram for ReprocessingServiceBound:
Collaboration diagram for ReprocessingServiceBound:

Public Member Functions

 ReprocessingServiceBound (PyServiceMgr *mgr, ReprocessingDB &db, uint32 stationID)
 
virtual ~ReprocessingServiceBound ()
 
 PyCallable_DECL_CALL (GetOptionsForItemTypes)
 
 PyCallable_DECL_CALL (GetReprocessingInfo)
 
 PyCallable_DECL_CALL (GetQuote)
 
 PyCallable_DECL_CALL (GetQuotes)
 
 PyCallable_DECL_CALL (Reprocess)
 
virtual void Release ()
 
- 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 Member Functions

float CalcReprocessingEfficiency (const Client *pClient, InventoryItemRef item=InventoryItemRef(nullptr)) const
 
float CalcTax (float standing) const
 
PyRepGetQuote (uint32 itemID, Client *pClient)
 
float GetStanding (const Client *pClient) const
 
- Protected Member Functions inherited from PyBoundObject
void _SetNodeBindID (uint32 nodeID, uint32 bindID)
 
- Protected Member Functions inherited from PyCallable
void _SetCallDispatcher (CallDispatcher *d)
 

Protected Attributes

Dispatcher *const m_dispatch
 
ReprocessingDBm_db
 
StationItemRef m_stationRef
 
uint32 m_stationCorpID
 
float m_staEfficiency
 
float m_tax
 
- Protected Attributes inherited from PyBoundObject
PyServiceMgr *const m_manager
 
std::string m_strBoundObjectName
 

Detailed Description

Definition at line 49 of file ReprocessingService.h.

Constructor & Destructor Documentation

ReprocessingServiceBound::ReprocessingServiceBound ( PyServiceMgr mgr,
ReprocessingDB db,
uint32  stationID 
)

Definition at line 79 of file ReprocessingService.cpp.

References PyCallable::_SetCallDispatcher(), RefPtr< X >::get(), GetQuote(), StationItem::GetRefineData(), m_dispatch, m_staEfficiency, m_stationCorpID, m_stationRef, PyBoundObject::m_strBoundObjectName, m_tax, PyCallable_REG_CALL, and sItemFactory.

80 : PyBoundObject(mgr),
81 m_dispatch(new Dispatcher(this)),
82 m_db(db),
84 m_staEfficiency(0.0f),
85 m_tax(0.0f)
86 {
88 
89  m_strBoundObjectName = "ReprocessingServiceBound";
90 
91  PyCallable_REG_CALL(ReprocessingServiceBound, GetOptionsForItemTypes);
92  PyCallable_REG_CALL(ReprocessingServiceBound, GetReprocessingInfo);
96 
97  m_stationRef = sItemFactory.GetStationItem(stationID);
98  if (m_stationRef.get() != nullptr)
100 }
void GetRefineData(uint32 &stationCorpID, float &staEfficiency, float &tax)
Definition: Station.cpp:235
std::string m_strBoundObjectName
Definition: PyBoundObject.h:54
PyRep * GetQuote(uint32 itemID, Client *pClient)
void _SetCallDispatcher(CallDispatcher *d)
Definition: PyCallable.h:87
X * get() const
Definition: RefPtr.h:213
PyBoundObject(PyServiceMgr *mgr)
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
Dispatcher *const m_dispatch
#define sItemFactory
Definition: ItemFactory.h:165

Here is the call graph for this function:

ReprocessingServiceBound::~ReprocessingServiceBound ( )
virtual

Definition at line 102 of file ReprocessingService.cpp.

References m_dispatch.

102  {
103  delete m_dispatch;
104 }
Dispatcher *const m_dispatch

Member Function Documentation

float ReprocessingServiceBound::CalcReprocessingEfficiency ( const Client pClient,
InventoryItemRef  item = InventoryItemRef(nullptr) 
) const
protected
Todo:
check for implants here ... once they're working

Definition at line 258 of file ReprocessingService.cpp.

References AttrReprocessingSkillType, RefPtr< X >::get(), EvilNumber::get_int(), InventoryItem::GetAttribute(), Client::GetChar(), Character::GetSkillLevel(), m_staEfficiency, EvESkill::RefineryEfficiency, EvESkill::Refining, and EvESkill::ScrapmetalProcessing.

Referenced by GetQuote().

258  {
259  /* formula is:
260  reprocessingEfficiency = 0.375
261  *(1 + 0.02 * RefiningSkill)
262  *(1 + 0.04 * RefineryEfficiencySkill)
263  *(1 + 0.05 * OreProcessingSkill)
264  */
266  CharacterRef cRef = pClient->GetChar();
267  double efficiency = (0.375f
268  * (1 + (0.02f * cRef->GetSkillLevel(EvESkill::Refining))) // 2% lvl
269  * (1 + (0.04f * cRef->GetSkillLevel(EvESkill::RefineryEfficiency)))); // 4% lvl
270 
271  if (item.get() != nullptr) {
272  uint32 specificSkill = item->GetAttribute(AttrReprocessingSkillType).get_int();
273  if (specificSkill) {
274  efficiency *= (1 + 0.05f * cRef->GetSkillLevel(specificSkill));
275  } else {
276  efficiency *= (1 + 0.04f * cRef->GetSkillLevel(EvESkill::ScrapmetalProcessing)); // use Scrapmetal Processing as default
277  }
278  }
279 
280  efficiency += m_staEfficiency;
281 
282  if (efficiency > 1.0f)
283  efficiency = 1.05f; // should be 1.0 max
284 
285  return efficiency;
286 }
CharacterRef GetChar() const
Definition: Client.h:164
int64 get_int()
Definition: EvilNumber.cpp:166
X * get() const
Definition: RefPtr.h:213
unsigned __int32 uint32
Definition: eve-compat.h:50
EvilNumber GetAttribute(const uint16 attrID) const
int8 GetSkillLevel(uint16 skillTypeID, bool zeroForNotInjected=true) const
Definition: Character.cpp:575

Here is the call graph for this function:

Here is the caller graph for this function:

float ReprocessingServiceBound::CalcTax ( float  standing) const
protected

Definition at line 362 of file ReprocessingService.cpp.

References m_tax.

Referenced by GetQuote().

362  {
363  //EvEMath::Refine::StationTaxesForReprocessing(standing);
364  float tax = m_tax - 0.75f / 100.0f * standing;
365  if (tax < 0.0f)
366  tax = 0.0f;
367  return tax;
368 }

Here is the caller graph for this function:

PyRep * ReprocessingServiceBound::GetQuote ( uint32  itemID,
Client pClient 
)
protected
Todo:
update this for item location - need to verify corp roles are being set correctly

Definition at line 288 of file ReprocessingService.cpp.

References _log, UserError::AddTypeName(), CalcReprocessingEfficiency(), CalcTax(), Corp::Role::FactoryManager, InventoryItem::flag(), RefPtr< X >::get(), Client::GetCharacterID(), Client::GetCorporationID(), Client::GetCorpRole(), Client::GetName(), ReprocessingDB::GetRecoverables(), Client::GetRolesAtAll(), GetStanding(), InventoryItem::itemID(), m_db, InventoryItem::ownerID(), ItemType::portionSize(), InventoryItem::quantity(), Client::SendErrorMsg(), sItemFactory, sRamMthd, InventoryItem::type(), and InventoryItem::typeID().

Referenced by ReprocessingServiceBound().

288  {
289  InventoryItemRef iRef = sItemFactory.GetItem( itemID );
290  if (iRef.get() == nullptr)
291  return nullptr; // No action as GetQuote is also called for reprocessed items (probably for check)
292 
293  // update this for corp items
294  if (iRef->ownerID() == pClient->GetCorporationID()) {
296  int64 roles = pClient->GetRolesAtAll();
297  //roles = pClient->GetRolesAtBase() | pClient->GetRolesAtAll();
298  //roles = pClient->GetRolesAtHQ() | pClient->GetRolesAtAll();
299  //roles = pClient->GetRolesAtOther() | pClient->GetRolesAtAll();
301  _log(MANUF__WARNING, "%s(%u) doesnt have FactoryManager role to access materials for reprocessing.", \
302  pClient->GetName(), pClient->GetCharacterID());
303  pClient->SendErrorMsg("You do not have the role \'Factory Manager\' which is required to access factory services on behalf of a corporation.");
304  //throw error here...dunno the format yet.
305  return nullptr;
306  }
307 
308  // this throw "access denied to bom hangar" on error. probably wrong for this application
309  sRamMthd.HangarRolesCheck(pClient, iRef->flag());
310  } else if (iRef->ownerID() != pClient->GetCharacterID()) {
311  _log(SERVICE__ERROR, "Character %u tried to reprocess item %u of character %u.", pClient->GetCharacterID(), iRef->itemID(), iRef->ownerID());
312  pClient->SendErrorMsg("The requested item is not yours.");
313  return nullptr;
314  }
315 
316  if (iRef->quantity() < iRef->type().portionSize()) {
317  throw UserError ("QuantityLessThanMinimumPortion")
318  .AddTypeName ("typename", iRef->typeID ())
319  .AddAmount ("portion", iRef->type ().portionSize ());
320  }
321 
322  std::vector<Recoverable> recoverables;
323  if (!m_db.GetRecoverables( iRef->typeID(), recoverables))
324  return nullptr;
325 
326  Rsp_GetQuote quote;
327  quote.lines = new PyList();
328  quote.leftOvers = iRef->quantity() % iRef->type().portionSize();
329  quote.quantityToProcess = iRef->quantity() - quote.leftOvers;
330  quote.playerStanding = GetStanding(pClient);
331 
332  double tax = CalcTax( quote.playerStanding );
333  double efficiency = CalcReprocessingEfficiency(pClient, iRef);
334 
335  for (auto cur :recoverables) {
336  uint32 ratio = cur.amountPerBatch * quote.quantityToProcess / iRef->type().portionSize();
337  Rsp_GetQuote_Recoverables_Line line;
338  line.typeID = cur.typeID;
339  line.client = uint32(efficiency * (1.0f - tax) * ratio);
340  line.station = uint32(efficiency * tax * ratio);
341  line.unrecoverable = ratio - line.client - line.station;
342  quote.lines->AddItem( line.Encode() );
343  }
344 
345  return quote.Encode();
346 }
float CalcReprocessingEfficiency(const Client *pClient, InventoryItemRef item=InventoryItemRef(nullptr)) const
void SendErrorMsg(const char *fmt,...)
Definition: Client.cpp:2719
#define _log(type, fmt,...)
Definition: logsys.h:124
int64 GetCorpRole() const
Definition: Client.h:129
uint32 ownerID() const
Definition: InventoryItem.h:99
UserError & AddTypeName(const char *name, uint32 typeID)
Shorthand method for adding a type's name.
int32 GetCharacterID() const
Definition: Client.h:113
int32 GetCorporationID() const
Definition: Client.h:123
const ItemType & type() const
uint16 portionSize() const
Definition: ItemType.h:77
X * get() const
Definition: RefPtr.h:213
const char * GetName() const
Definition: Client.h:94
Python object "ccp_exceptions.UserError".
Definition: PyExceptions.h:121
int64 GetRolesAtAll() const
Definition: Client.h:131
unsigned __int32 uint32
Definition: eve-compat.h:50
EVEItemFlags flag() const
bool GetRecoverables(const uint32 typeID, std::vector< Recoverable > &into)
signed __int64 int64
Definition: eve-compat.h:51
float GetStanding(const Client *pClient) const
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
float CalcTax(float standing) const
#define sItemFactory
Definition: ItemFactory.h:165
#define sRamMthd
Definition: RamMethods.h:55
uint16 typeID() const
Python list.
Definition: PyRep.h:639
uint32 itemID() const
Definition: InventoryItem.h:98
int32 quantity() const
Definition: InventoryItem.h:97

Here is the call graph for this function:

Here is the caller graph for this function:

float ReprocessingServiceBound::GetStanding ( const Client pClient) const
protected
Todo:
should this be moved to standings code? yes!!

Definition at line 349 of file ReprocessingService.cpp.

References EvESkill::Connections, EvESkill::Diplomacy, Client::GetChar(), Client::GetCharacterID(), Client::GetCorporationID(), Character::GetSkillLevel(), StandingDB::GetStanding(), m_stationCorpID, and EvE::max().

Referenced by GetQuote().

350 {
351  float standing = StandingDB::GetStanding(m_stationCorpID, pClient->GetCharacterID());
352  if (standing < 0.0f) {
353  standing += ((10.0f + standing) * 0.04f * pClient->GetChar()->GetSkillLevel(EvESkill::Diplomacy));
354  } else {
355  standing += ((10.0f - standing) * 0.04f * pClient->GetChar()->GetSkillLevel(EvESkill::Connections));
356  }
357 
358  return EvE::max(standing, StandingDB::GetStanding(m_stationCorpID, pClient->GetCorporationID()));
359 }
static float GetStanding(uint32 fromID, uint32 toID)
Definition: StandingDB.cpp:142
int32 GetCharacterID() const
Definition: Client.h:113
int32 GetCorporationID() const
Definition: Client.h:123
CharacterRef GetChar() const
Definition: Client.h:164
int64 max(int64 x, int64 y=0)
Definition: misc.h:103
int8 GetSkillLevel(uint16 skillTypeID, bool zeroForNotInjected=true) const
Definition: Character.cpp:575

Here is the call graph for this function:

Here is the caller graph for this function:

ReprocessingServiceBound::PyCallable_DECL_CALL ( GetOptionsForItemTypes  )
ReprocessingServiceBound::PyCallable_DECL_CALL ( GetReprocessingInfo  )
ReprocessingServiceBound::PyCallable_DECL_CALL ( GetQuote  )
ReprocessingServiceBound::PyCallable_DECL_CALL ( GetQuotes  )
ReprocessingServiceBound::PyCallable_DECL_CALL ( Reprocess  )
void ReprocessingServiceBound::Release ( )
virtual

Implements PyBoundObject.

Definition at line 106 of file ReprocessingService.cpp.

106  {
107  //I hate this statement
108  delete this;
109 }

Member Data Documentation

ReprocessingDB& ReprocessingServiceBound::m_db
protected

Definition at line 68 of file ReprocessingService.h.

Referenced by GetQuote().

Dispatcher* const ReprocessingServiceBound::m_dispatch
protected

Definition at line 65 of file ReprocessingService.h.

Referenced by ReprocessingServiceBound(), and ~ReprocessingServiceBound().

float ReprocessingServiceBound::m_staEfficiency
protected

Definition at line 72 of file ReprocessingService.h.

Referenced by CalcReprocessingEfficiency(), and ReprocessingServiceBound().

uint32 ReprocessingServiceBound::m_stationCorpID
protected

Definition at line 71 of file ReprocessingService.h.

Referenced by GetStanding(), and ReprocessingServiceBound().

StationItemRef ReprocessingServiceBound::m_stationRef
protected

Definition at line 70 of file ReprocessingService.h.

Referenced by ReprocessingServiceBound().

float ReprocessingServiceBound::m_tax
protected

Definition at line 73 of file ReprocessingService.h.

Referenced by CalcTax(), and ReprocessingServiceBound().


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