本文整理汇总了C++中InventoryItemRef::itemID方法的典型用法代码示例。如果您正苦于以下问题:C++ InventoryItemRef::itemID方法的具体用法?C++ InventoryItemRef::itemID怎么用?C++ InventoryItemRef::itemID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InventoryItemRef
的用法示例。
在下文中一共展示了InventoryItemRef::itemID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveRig
void Ship::RemoveRig( InventoryItemRef item, uint32 inventoryID )
{
m_ModuleManager->UninstallRig(item->itemID());
//move the item to the void or w/e
m_pOperator->MoveItem(item->itemID(), inventoryID, flagAutoFit);
//delete the item
item->Delete();
}
示例2: AddItem
void Inventory::AddItem(InventoryItemRef item)
{
std::map<uint32, InventoryItemRef>::iterator res = mContents.find( item->itemID() );
if( res == mContents.end() )
{
mContents.insert( std::make_pair( item->itemID(), item ) );
sLog.Debug("Inventory", "Updated location %u to contain item %u with flag %d.", inventoryID(), item->itemID(), (int)item->flag() );
}
//else already here
sLog.Debug("Inventory", "unable to updated location %u to contain item %u with flag %d, because it already happend.", inventoryID(), item->itemID(), (int)item->flag() );
}
示例3: RemoveItem
void Ship::RemoveItem(InventoryItemRef item, uint32 inventoryID, EVEItemFlags flag)
{
//coming from ship, we need to deactivate it and remove mass if it isn't a charge
if( item->categoryID() != EVEDB::invCategories::Charge ) {
m_pOperator->GetShip()->Deactivate( item->itemID(), "online" );
// m_pOperator->GetShip()->Set_mass( m_pOperator->GetShip()->mass() - item->massAddition() );
//m_pOperator->GetShip()->SetAttribute(AttrMass, m_pOperator->GetShip()->GetAttribute(AttrMass) - item->GetAttribute(AttrMassAddition) );
m_pOperator->GetShip()->UnloadModule( item->itemID() );
}
//Move New item to its new location
m_pOperator->MoveItem(item->itemID(), inventoryID, flag);
}
示例4: RemoveItem
void Inventory::RemoveItem(InventoryItemRef item)
{
std::map<uint32, InventoryItemRef>::iterator res = mContents.find( item->itemID() );
if( res != mContents.end() )
{
mContents.erase( res );
sLog.Debug("Inventory", "Updated location %u to no longer contain item %u.", inventoryID(), item->itemID() );
}
else
{
sLog.Debug("Inventory", "unable to remove %u from %u.", item->itemID(), inventoryID() );
}
}
示例5: RemoveRig
void Ship::RemoveRig( InventoryItemRef item, uint32 inventoryID )
{
m_ModuleManager->UnfitModule(item->itemID());
//delete the item
item->Delete();
}
示例6: RemoveItem
void Ship::RemoveItem(InventoryItemRef item, uint32 inventoryID, EVEItemFlags flag)
{
// If item IS a module and it's being removed from a slot:
if( (item->categoryID() == EVEDB::invCategories::Module) && ((item->flag() >= flagLowSlot0) && (item->flag() <= flagHiSlot7)) )
{
m_pOperator->GetShip()->Deactivate( item->itemID(), "online" );
// m_pOperator->GetShip()->Set_mass( m_pOperator->GetShip()->mass() - item->massAddition() );
//m_pOperator->GetShip()->SetAttribute(AttrMass, m_pOperator->GetShip()->GetAttribute(AttrMass) - item->GetAttribute(AttrMassAddition) );
m_pOperator->GetShip()->UnloadModule( item->itemID() );
}
// If item IS a rig and it's being removed from a slot:
if( (item->categoryID() == EVEDB::invCategories::Module) && ((item->flag() >= flagRigSlot0) && (item->flag() <= flagRigSlot7)) )
{
// Don't know what to do when removing a Rig... yet ;)
}
// If item IS a rig and it's being removed from a slot:
if( (item->categoryID() == EVEDB::invCategories::Subsystem) && ((item->flag() >= flagSubSystem0) && (item->flag() <= flagSubSystem7)) )
{
// Don't know what to do when removing a Subsystem... yet ;)
}
// if item being removed IS a charge, it needs to be removed via Module Manager so modules know charge is removed,
// BUT, only if it is loaded into a module in one of the 3 slot banks, so we also check its flag value:
if( (item->categoryID() == EVEDB::invCategories::Charge) && ((item->flag() >= flagLowSlot0) && (item->flag() <= flagHiSlot7)) )
{
m_ModuleManager->UnloadCharge(item->flag());
}
if( item->flag() == flag )
// Item's already been moved, let's return
return;
// Move New item to its new location:
if( !( ((item->flag() >= flagLowSlot0) && (item->flag() <= flagHiSlot7)) || ((item->flag() >= flagRigSlot0) && (item->flag() <= flagRigSlot7))
|| ((item->flag() >= flagSubSystem0) && (item->flag() <= flagSubSystem7)) ) )
{
_DecreaseCargoHoldsUsedVolume(item->flag(), (item->getAttribute(AttrVolume).get_float() * item->quantity()));
m_pOperator->MoveItem(item->itemID(), inventoryID, flag);
}
else
{
m_pOperator->MoveItem(item->itemID(), inventoryID, flag);
}
}
示例7: SpawnItem
InventoryItemRef ItemFactory::SpawnItem(ItemData &data) {
InventoryItemRef i = InventoryItem::Spawn(*this, data);
if( !i )
return InventoryItemRef();
// spawn successful; store the ref
m_items.insert( std::make_pair( i->itemID(), i ) );
return i;
}
示例8: FitModule
bool ModuleManager::FitModule(InventoryItemRef item, EVEItemFlags flag)
{
if(item->categoryID() == EVEDB::invCategories::Module)
{
// Attempt to fit the module
if( _fitModule(item, flag) )
{
// Now that module is successfully fitted, attempt to put it Online:
Online(item->itemID());
return true;
}
}
else
SysLog::Debug("ModuleManager","%s tried to fit item %u, which is not a module", m_Ship->GetOperator()->GetName(), item->itemID());
return false;
}
示例9: AlterCargoQty
bool Ship::AlterCargoQty(InventoryItemRef item, int qtyChange)
{
// Make sure we actually contain this item!
if (!Contains(item->itemID()))
{
// We don't contain it, sorry!
return false;
}
// Calculate total volume needed.
double volumeNeed = item->getAttribute(AttrVolume).get_float() * qtyChange;
// Get remaining volume.
double remain = GetRemainingCapacity(item->flag());
if (remain >= volumeNeed)
{
// We have enough space remaining, add the items.
item->AlterQuantity(qtyChange);
// Adjust the remaining volume.
_IncreaseCargoHoldsUsedVolume(item->flag(), volumeNeed);
return true;
}
return false;
}
示例10: AddItem
uint32 Ship::AddItem(EVEItemFlags flag, InventoryItemRef item)
{
ValidateAddItem( flag, item );
//it's a new module, make sure it's state starts at offline so that it is added correctly
if( item->categoryID() == EVEDB::invCategories::Module )
item->PutOffline();
switch( item->categoryID() )
{
case EVEDB::invCategories::Charge:
{
m_ModuleManager->LoadCharge(item, flag);
InventoryItemRef loadedChargeOnModule = m_ModuleManager->GetLoadedChargeOnModule(flag);
if( loadedChargeOnModule )
{
return loadedChargeOnModule->itemID();
}
else
return 0;
}
break;
case EVEDB::invCategories::Module:
if( m_ModuleManager->FitModule(item, flag) )
item->Move(itemID(), flag);
break;
// The default case handles ANY other items added to ship and assumes they go into one of the valid cargo holds on this ship:
default:
//Log::Error( "Ship::AddItem(flag,item)", "ERROR! Function called with item '%s' (id: %u) of category neither Charge nor Module!", item->itemName().c_str(), item->itemID() );
_IncreaseCargoHoldsUsedVolume(item->flag(), (item->getAttribute(AttrVolume).get_float() * item->quantity()));
item->Move(itemID(), flag);
break;
}
return 0;
}
示例11: Merge
bool InventoryItem::Merge(InventoryItemRef to_merge, int32 qty, bool notify) {
if(typeID() != to_merge->typeID()) {
_log(ITEM__ERROR, "%s (%u): Asked to merge with %s (%u).", itemName().c_str(), itemID(), to_merge->itemName().c_str(), to_merge->itemID());
return false;
}
if(locationID() != to_merge->locationID() || flag() != to_merge->flag()) {
_log(ITEM__ERROR, "%s (%u) in location %u, flag %u: Asked to merge with item %u in location %u, flag %u.", itemName().c_str(), itemID(), locationID(), flag(), to_merge->itemID(), to_merge->locationID(), to_merge->flag());
return false;
}
if(qty == 0)
qty = to_merge->quantity();
if(qty <= 0) {
_log(ITEM__ERROR, "%s (%u): Asked to merge with %d units of item %u.", itemName().c_str(), itemID(), qty, to_merge->itemID());
return false;
}
if(!AlterQuantity(qty, notify)) {
_log(ITEM__ERROR, "%s (%u): Failed to add quantity %d.", itemName().c_str(), itemID(), qty);
return false;
}
if(qty == to_merge->quantity()) {
to_merge->Delete();
} else if(!to_merge->AlterQuantity(-qty, notify)) {
_log(ITEM__ERROR, "%s (%u): Failed to remove quantity %d.", to_merge->itemName().c_str(), to_merge->itemID(), qty);
return false;
}
return true;
}
示例12: PyException
ModuleManager::ModuleManager(Ship *const ship)
{
// Create ModuleContainer object and initialize with sizes for all slot banks for this ship:
m_Modules = new ModuleContainer((uint32)ship->GetAttribute(AttrLowSlots).get_int(),
(uint32)ship->GetAttribute(AttrMedSlots).get_int(),
(uint32)ship->GetAttribute(AttrHiSlots).get_int(),
(uint32)ship->GetAttribute(AttrRigSlots).get_int(),
(uint32)ship->GetAttribute(AttrSubSystemSlot).get_int(),
(uint32)ship->GetAttribute(AttrTurretSlotsLeft).get_int(),
(uint32)ship->GetAttribute(AttrLauncherSlotsLeft).get_int(),
this);
// Store reference to the Ship object to which the ModuleManager belongs:
m_Ship = ship;
// Initialize the log file for this Module Manager instance
std::string logsubdirectory = "ModuleManagers";
//std::string logfilename = "On_Ship_" + m_Ship->itemName(); // This method using ship's name string may NOT be path friendly as players naming ships may use path-unfriendly characters - need function to convert to path-friendly ship name string
std::string logfilename = "On_Ship_" + m_Ship->itemName() + "_(" + std::string(itoa(m_Ship->itemID())) + ")";
m_pLog = new Task_Log( EVEServerConfig::files.logDir, logsubdirectory, logfilename );
m_pLog->InitializeLogging( EVEServerConfig::files.logDir, logsubdirectory, logfilename );
// Load modules, rigs and subsystems from Ship's inventory into ModuleContainer:
m_pLog->Log("ModuleManager", "Loading modules...");
uint32 flagIndex;
for(flagIndex=flagLowSlot0; flagIndex<=flagLowSlot7; flagIndex++)
{
InventoryItemRef moduleRef;
InventoryItemRef chargeRef;
std::vector<InventoryItemRef>::iterator cur, end;
std::vector<InventoryItemRef> items;
m_Ship->FindByFlag( (EVEItemFlags)flagIndex, items ); // Operator assumed to be Client *
cur = items.begin();
end = items.end();
if( items.size() > 0 )
{
while( (cur != end) ) {
if( cur->get()->categoryID() == EVEDB::invCategories::Charge )
chargeRef = (*cur);
if( cur->get()->categoryID() == EVEDB::invCategories::Module )
moduleRef = (*cur);
cur++;
}
if( moduleRef )
{
if( _fitModule( moduleRef, (EVEItemFlags)flagIndex ) )
{
//_fitModule( moduleRef, (EVEItemFlags)flagIndex );
if( moduleRef->GetAttribute(AttrIsOnline).get_int() == 1 )
Online(moduleRef->itemID());
else
Offline(moduleRef->itemID());
if( chargeRef )
((ActiveModule *)GetModule((EVEItemFlags)flagIndex))->load(chargeRef);
}
else
{
SysLog::Error( "ModuleManager::ModuleManager()", "ERROR: Cannot fit Low Slot module '%s' (id %u)", moduleRef->itemName().c_str(), moduleRef->itemID() );
throw PyException( MakeCustomError( "ERROR! Cannot fit Low Slot module '%s'", moduleRef->itemName().c_str() ) );
}
}
}
}
for(flagIndex=flagMedSlot0; flagIndex<=flagMedSlot7; flagIndex++)
{
InventoryItemRef moduleRef;
InventoryItemRef chargeRef;
std::vector<InventoryItemRef>::iterator cur, end;
std::vector<InventoryItemRef> items;
m_Ship->FindByFlag( (EVEItemFlags)flagIndex, items ); // Operator assumed to be Client *
cur = items.begin();
end = items.end();
if( items.size() > 0 )
{
while( (cur != end) ) {
if( cur->get()->categoryID() == EVEDB::invCategories::Charge )
chargeRef = (*cur);
if( cur->get()->categoryID() == EVEDB::invCategories::Module )
moduleRef = (*cur);
cur++;
}
if( moduleRef )
{
if( _fitModule( moduleRef, (EVEItemFlags)flagIndex ) )
{
//_fitModule( moduleRef, (EVEItemFlags)flagIndex );
if( moduleRef->GetAttribute(AttrIsOnline).get_int() == 1 )
Online(moduleRef->itemID());
else
Offline(moduleRef->itemID());
if( chargeRef )
((ActiveModule *)GetModule((EVEItemFlags)flagIndex))->load(chargeRef);
}
else
{
SysLog::Error( "ModuleManager::ModuleManager()", "ERROR: Cannot fit Med Slot module '%s' (id %u)", moduleRef->itemName().c_str(), moduleRef->itemID() );
//.........这里部分代码省略.........
示例13: _fitModule
bool ModuleManager::_fitModule(InventoryItemRef item, EVEItemFlags flag)
{
bool verifyFailed = false;
GenericModule * mod;
// First, check to see if this module item is already fitted, and if so, let's instruct ModuleContainer to move the module
GenericModule * existingMod = m_Modules->GetModule(item->itemID());
if( existingMod != NULL )
{
if( m_Modules->isSlotOccupied(flag) )
{
throw PyException( MakeUserError( "SlotAlreadyOccupied" ) );
verifyFailed = true;
}
m_Modules->RemoveModule( existingMod->flag() ); // Remove this module from existing slot
existingMod->getItem()->SetFlag( flag ); // Change item's flag to the NEW slot flag
m_Modules->AddModule( flag, existingMod ); // Add this module back to the container at the NEW slot location
}
else
{
mod = ModuleFactory(item, ShipRef(m_Ship));
// Set module's pointer to its owner ModuleManager's log object:
mod->setLog(m_pLog);
// Check for max turret modules allowed:
if( mod->isTurretFitted() && (m_Modules->GetFittedTurretCount() == m_Ship->GetMaxTurrentHardpoints().get_int()) )
{
//std::map<std::string, PyRep *> args;
//args["typename"] = new PyString(item->itemName().c_str());
//args["portion"] = new PyInt(item->type().portionSize());
throw PyException( MakeUserError( "NotEnoughTurretSlots" ) );
verifyFailed = true;
}
// Check for max launcher modules allowed:
if( mod->isLauncherFitted() && (m_Modules->GetFittedLauncherCount() == m_Ship->GetMaxLauncherHardpoints().get_int()) )
{
//std::map<std::string, PyRep *> args;
//args["typename"] = new PyString(item->itemName().c_str());
//args["portion"] = new PyInt(item->type().portionSize());
throw PyException( MakeUserError( "NotEnoughLauncherSlots" ) );
verifyFailed = true;
}
// Check for max modules of group allowed:
else if( mod->isMaxGroupFitLimited() && (m_Modules->GetFittedModuleCountByGroup(item->groupID()) == mod->getItem()->GetAttribute(AttrMaxGroupFitted).get_int()) )
{
//std::map<std::string, PyRep *> args;
//args["typename"] = new PyString(item->itemName().c_str());
//args["portion"] = new PyInt(item->type().portionSize());
throw PyException( MakeUserError( "CantFitTooManyByGroup" ) );
verifyFailed = true;
}
else
{
// Fit Module now that all checks have passed:
m_Modules->AddModule(flag, mod);
}
}
if( verifyFailed )
{
if( mod != NULL )
delete mod;
return false;
}
else
return true;
}
示例14: SwapSubSystem
bool ModuleManager::SwapSubSystem(InventoryItemRef item, EVEItemFlags flag)
{
if(item->groupID() >= 954 && item->groupID() <= 958)
{
_fitModule(item,flag);
return true;
}
else
SysLog::Debug("ModuleManager","%s tried to fit item %u, which is not a subsystem", m_Ship->GetOperator()->GetName(), item->itemID());
return false;
}
示例15: Handle_InstallJob
PyResult RamProxyService::Handle_InstallJob(PyCallArgs &call) {
Call_InstallJob args;
if(!args.Decode(&call.tuple)) {
_log(SERVICE__ERROR, "Failed to decode args.");
return NULL;
}
// load installed item
InventoryItemRef installedItem = m_manager->item_factory.GetItem( args.installedItemID );
if( !installedItem )
return NULL;
// if output flag not set, put it where it was
if(args.flagOutput == flagAutoFit)
args.flagOutput = installedItem->flag();
// decode path to BOM location
PathElement pathBomLocation;
if( !pathBomLocation.Decode( args.bomPath->GetItem(0) ) ) {
_log(SERVICE__ERROR, "Failed to decode BOM location.");
return NULL;
}
// verify call
_VerifyInstallJob_Call( args, (InventoryItemRef)installedItem, pathBomLocation, call.client );
// this calculates some useful multipliers ... Rsp_InstallJob is used as container ...
Rsp_InstallJob rsp;
if(!_Calculate(args, (InventoryItemRef)installedItem, call.client, rsp))
return NULL;
// I understand sent maxJobStartTime as a limit, so this checks whether it's in limit
if(rsp.maxJobStartTime > call.byname["maxJobStartTime"]->AsInt()->value())
throw(PyException(MakeUserError("RamCannotGuaranteeStartTime")));
// query required items for activity
std::vector<RequiredItem> reqItems;
if(!m_db.GetRequiredItems(installedItem->typeID(), (EVERamActivity)args.activityID, reqItems))
return NULL;
// if 'quoteOnly' is 1 -> send quote, if 0 -> install job
if(call.byname["quoteOnly"]->AsInt()->value())
{
_EncodeBillOfMaterials(reqItems, rsp.materialMultiplier, rsp.charMaterialMultiplier, args.runs, rsp.bom);
_EncodeMissingMaterials(reqItems, pathBomLocation, call.client, rsp.materialMultiplier, rsp.charMaterialMultiplier, args.runs, rsp.missingMaterials);
return rsp.Encode();
}
else
{
// verify install
_VerifyInstallJob_Install(rsp, pathBomLocation, reqItems, args.runs, call.client);
// now we are sure everything from the client side is right, we can start it ...
// calculate proper start time
uint64 beginProductionTime = Win32TimeNow();
if(beginProductionTime < (uint32)rsp.maxJobStartTime)
beginProductionTime = rsp.maxJobStartTime;
// register our job
if( !m_db.InstallJob(
args.isCorpJob ? call.client->GetCorporationID() : call.client->GetCharacterID(),
call.client->GetCharacterID(),
args.installationAssemblyLineID,
installedItem->itemID(),
beginProductionTime,
beginProductionTime + uint64(rsp.productionTime) * Win32Time_Second,
args.description.c_str(),
args.runs,
(EVEItemFlags)args.flagOutput,
pathBomLocation.locationID,
args.licensedProductionRuns ) )
{
return NULL;
}
// do some activity-specific actions
switch(args.activityID) {
case ramActivityManufacturing: {
// decrease licensed production runs
BlueprintRef bp = BlueprintRef::StaticCast( installedItem );
if(!bp->infinite())
bp->AlterLicensedProductionRunsRemaining(-1);
}
}
// pay for assembly lines, move the item away
call.client->AddBalance(-rsp.cost);
installedItem->Move( installedItem->locationID(), flagFactoryBlueprint );
// query all items contained in "Bill of Materials" location
std::vector<InventoryItemRef> items;
_GetBOMItems( pathBomLocation, items );
std::vector<RequiredItem>::iterator cur, end;
cur = reqItems.begin();
end = reqItems.end();
for(; cur != end; cur++) {
if(cur->isSkill)
//.........这里部分代码省略.........