本文整理汇总了C++中InventoryItemRef::flag方法的典型用法代码示例。如果您正苦于以下问题:C++ InventoryItemRef::flag方法的具体用法?C++ InventoryItemRef::flag怎么用?C++ InventoryItemRef::flag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InventoryItemRef
的用法示例。
在下文中一共展示了InventoryItemRef::flag方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddItem
void Character::AddItem(InventoryItemRef item)
{
Inventory::AddItem( item );
if( item->flag() == flagSkill
|| item->flag() == flagSkillInTraining )
{
// Skill has been added ...
if( item->categoryID() != EVEDB::invCategories::Skill ) {
_log( ITEM__WARNING, "%s (%u): %s has been added with flag %d.", itemName().c_str(), itemID(), item->category().name().c_str(), (int)item->flag() );
} else
{
SkillRef skill = SkillRef::StaticCast( item );
if( !skill->singleton() )
{
_log( ITEM__TRACE, "%s (%u): Injecting %s.", itemName().c_str(), itemID(), item->itemName().c_str() );
// Make it singleton and set initial skill values.
skill->ChangeSingleton( true );
skill->SetAttribute(AttrSkillLevel, 0);
skill->SetAttribute(AttrSkillPoints, 0);
if( skill->flag() != flagSkillInTraining )
skill->SetAttribute(AttrExpiryTime, 0);
}
}
}
}
示例2: 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;
}
示例3: GetItemRow
void Contract::GetItemRow( InventoryItemRef item, PyPackedRow* into ) const
{
into->SetField( "contractID", new PyInt( contractID() ) );
into->SetField( "itemID", new PyInt( item->itemID() ) );
into->SetField( "quantity", new PyInt( item->quantity() ) );
into->SetField( "itemTypeID", new PyInt( item->typeID() ) );
into->SetField( "inCrate", new PyBool( true ) );
if( item->categoryID() == EVEDB::invCategories::Blueprint )
{
BlueprintRef bp = m_itemFactory.GetBlueprint( item->itemID() );
into->SetField( "parentID", new PyInt( bp->parentBlueprintTypeID() ) );
into->SetField( "productivityLevel", new PyInt( bp->productivityLevel() ) );
into->SetField( "materialLevel", new PyInt( bp->materialLevel() ) );
into->SetField( "copy", new PyInt( bp->copy() ) );
into->SetField( "licensedProductionRunsRemaining", new PyInt( bp->licensedProductionRunsRemaining() ) );
}
else
{
into->SetField( "parentID", new PyInt( 0 ) );
into->SetField( "productivityLevel", new PyInt( 0 ) );
into->SetField( "materialLevel", new PyInt( 0 ) );
into->SetField( "copy", new PyInt( 0 ) );
into->SetField( "licensedProductionRunsRemaining", new PyInt( 0 ) );
}
if( item->HasAttribute( AttrDamage ) )
into->SetField( "damage", new PyInt( item->GetAttribute( AttrDamage ).get_int() ) );
else
into->SetField( "damage", new PyInt( 0 ) );
into->SetField( "flagID", new PyInt( item->flag() ) );
}
示例4: AddItem
void Ship::AddItem(InventoryItemRef item)
{
InventoryEx::AddItem( item );
if( item->flag() >= flagSlotFirst &&
item->flag() <= flagSlotLast &&
item->categoryID() != EVEDB::invCategories::Charge)
{
// make singleton
item->ChangeSingleton( true );
}
}
示例5: 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;
}
示例6: List
void Inventory::List( CRowSet* into, EVEItemFlags _flag, uint32 forOwner ) const
{
//there has to be a better way to build this...
std::map<uint32, InventoryItemRef>::const_iterator cur, end;
cur = mContents.begin();
end = mContents.end();
for(; cur != end; cur++)
{
InventoryItemRef i = cur->second;
if( ( i->flag() == _flag || _flag == flagAnywhere )
&& ( i->ownerID() == forOwner || forOwner == 0 ) )
{
PyPackedRow* row = into->NewRow();
i->GetItemRow( row );
}
}
}
示例7: 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;
}
示例8: 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() );
}
示例9: _VerifyInstallJob_Call
//.........这里部分代码省略.........
// if(...)
throw(PyException(MakeUserError("RamAccessDeniedWrongAlliance")));
} else if((restrictionMask & ramRestrictByCorp) == ramRestrictByCorp) {
if(ownerID != c->GetCorporationID())
throw(PyException(MakeUserError("RamAccessDeniedWrongCorp")));
}
if(args.isCorpJob) {
if((c->GetCorpRole() & corpRoleFactoryManager) != corpRoleFactoryManager)
throw(PyException(MakeUserError("RamCannotInstallForCorpByRoleFactoryManager")));
if(args.activityID == ramActivityManufacturing) {
if((c->GetCorpRole() & corpRoleCanRentFactorySlot) != corpRoleCanRentFactorySlot)
throw(PyException(MakeUserError("RamCannotInstallForCorpByRole")));
} else {
if((c->GetCorpRole() & corpRoleCanRentResearchSlot) != corpRoleCanRentResearchSlot)
throw(PyException(MakeUserError("RamCannotInstallForCorpByRole")));
}
}
// INSTALLED ITEM CHECK
// *********************
// ownership
if(args.isCorpJob) {
if(installedItem->ownerID() != c->GetCorporationID())
throw(PyException(MakeUserError("RamCannotInstallItemForAnotherCorp")));
} else {
if(installedItem->ownerID() != c->GetCharacterID())
throw(PyException(MakeUserError("RamCannotInstallItemForAnother")));
}
// corp hangar permission
if( (installedItem->flag() == flagCorpSecurityAccessGroup2 && (c->GetCorpRole() & corpRoleHangarCanTake2) != corpRoleHangarCanTake2)
|| (installedItem->flag() == flagCorpSecurityAccessGroup3 && (c->GetCorpRole() & corpRoleHangarCanTake3) != corpRoleHangarCanTake3)
|| (installedItem->flag() == flagCorpSecurityAccessGroup4 && (c->GetCorpRole() & corpRoleHangarCanTake4) != corpRoleHangarCanTake4)
|| (installedItem->flag() == flagCorpSecurityAccessGroup5 && (c->GetCorpRole() & corpRoleHangarCanTake5) != corpRoleHangarCanTake5)
|| (installedItem->flag() == flagCorpSecurityAccessGroup6 && (c->GetCorpRole() & corpRoleHangarCanTake6) != corpRoleHangarCanTake6)
|| (installedItem->flag() == flagCorpSecurityAccessGroup7 && (c->GetCorpRole() & corpRoleHangarCanTake7) != corpRoleHangarCanTake7)
)
throw(PyException(MakeUserError("RamAccessDeniedToBOMHangar")));
// large location check
if(IsStation(args.installationContainerID)) {
if(/*args.isCorpJob && */installedItem->flag() == flagCargoHold)
throw(PyException(MakeUserError("RamCorpInstalledItemNotInCargo")));
if(installedItem->locationID() != (uint32)args.installationContainerID) {
if((uint32)args.installationContainerID == c->GetLocationID()) {
std::map<std::string, PyRep *> exceptArgs;
exceptArgs["location"] = new PyString(m_db.GetStationName(args.installationContainerID));
if(args.isCorpJob)
throw(PyException(MakeUserError("RamCorpInstalledItemWrongLocation", exceptArgs)));
else
throw(PyException(MakeUserError("RamInstalledItemWrongLocation", exceptArgs)));
} else
throw(PyException(MakeUserError("RamRemoteInstalledItemNotInStation")));
} else {
if(args.isCorpJob) {
if(installedItem->flag() < flagCorpSecurityAccessGroup2 || installedItem->flag() > flagCorpSecurityAccessGroup7) {
if((uint32)args.installationContainerID == c->GetLocationID()) {
std::map<std::string, PyRep *> exceptArgs;
exceptArgs["location"] = new PyString(m_db.GetStationName(args.installationContainerID));
throw(PyException(MakeUserError("RamCorpInstalledItemWrongLocation", exceptArgs)));
示例10: 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)
//.........这里部分代码省略.........
示例11: Handle_GetContract
PyResult ContractMgrService::Handle_GetContract( PyCallArgs& call )
{
Call_SingleIntegerArg arg;
PyDict* _contract = new PyDict;
if( !arg.Decode( &call.tuple ) )
{
codelog(SERVICE__ERROR, "%s: Bad arguments to GetContract in contractMgr", call.client->GetCharacterName() );
return NULL;
}
// Manual creation of PyPackedRow
DBRowDescriptor *header = new DBRowDescriptor();
header->AddColumn( "contractID", DBTYPE_I4 );
header->AddColumn( "issuerID", DBTYPE_I4 );
header->AddColumn( "issuerCorpID", DBTYPE_I4 );
header->AddColumn( "type", DBTYPE_UI1 );
header->AddColumn( "availability", DBTYPE_I4 );
header->AddColumn( "assigneeID", DBTYPE_I4 );
header->AddColumn( "numDays", DBTYPE_I4 );
header->AddColumn( "startStationID", DBTYPE_I4 );
header->AddColumn( "endStationID", DBTYPE_I4 );
header->AddColumn( "startSolarSystemID", DBTYPE_I4 );
header->AddColumn( "endSolarSystemID", DBTYPE_I4 );
header->AddColumn( "startRegionID", DBTYPE_I4 );
header->AddColumn( "endRegionID", DBTYPE_I4 );
header->AddColumn( "price", DBTYPE_CY );
header->AddColumn( "reward", DBTYPE_CY );
header->AddColumn( "collateral", DBTYPE_CY );
header->AddColumn( "title", DBTYPE_WSTR );
header->AddColumn( "description", DBTYPE_WSTR );
header->AddColumn( "forCorp", DBTYPE_BOOL );
header->AddColumn( "status", DBTYPE_UI1 );
header->AddColumn( "acceptorID", DBTYPE_I4 );
header->AddColumn( "dateIssued", DBTYPE_FILETIME );
header->AddColumn( "dateExpired", DBTYPE_FILETIME );
header->AddColumn( "dateAccepted", DBTYPE_FILETIME );
header->AddColumn( "dateCompleted", DBTYPE_FILETIME );
header->AddColumn( "volume", DBTYPE_R8 );
header->AddColumn( "issuerAllianceID", DBTYPE_I4 );
header->AddColumn( "issuerWalletKey", DBTYPE_I4 );
header->AddColumn( "acceptorWalletKey", DBTYPE_I4 );
header->AddColumn( "crateID", DBTYPE_I4 );
ContractRef contract = m_contractManager->GetContract( arg.arg );
uint32 n = 0;
PyPackedRow* into = new PyPackedRow( header );
into->SetField( "contractID", new PyInt( contract->contractID() ) );
into->SetField( "issuerID", new PyInt( contract->issuerID() ) );
into->SetField( "issuerCorpID", new PyInt( contract->issuerCorpID() ) );
into->SetField( "type", new PyInt( contract->type() ) );
into->SetField( "availability", new PyInt( contract->avail() ) );
into->SetField( "assigneeID", new PyInt( contract->assigneeID() ) );
into->SetField( "numDays", new PyInt( 0 ) );
into->SetField( "startStationID", new PyInt( contract->startStationID() ) );
into->SetField( "endStationID", new PyInt( contract->endStationID() ) );
into->SetField( "startSolarSystemID", new PyInt( contract->startSolarSystemID() ) );
into->SetField( "endSolarSystemID", new PyInt( contract->endSolarSystemID() ) );
into->SetField( "startRegionID", new PyInt( contract->startRegionID() ) );
into->SetField( "endRegionID", new PyInt( contract->endRegionID() ) );
into->SetField( "price", new PyFloat( contract->price() ) );
into->SetField( "reward", new PyFloat( contract->reward() ) );
into->SetField( "collateral", new PyFloat( contract->collateral() ) );
into->SetField( "title", new PyString( "title" ) );
into->SetField( "description", new PyString( "description" ) );
into->SetField( "forCorp", new PyBool( contract->forCorp() ) );
into->SetField( "status", new PyInt( contract->status() ) );
into->SetField( "acceptorID", new PyInt( contract->acceptorID() ) );
into->SetField( "dateIssued", new PyLong( contract->dateIssued() ) );
into->SetField( "dateExpired", new PyLong( contract->dateExpired() ) );
into->SetField( "dateAccepted", new PyLong( contract->dateAccepted() ) );
into->SetField( "dateCompleted", new PyLong( contract->dateCompleted() ) );
into->SetField( "volume", new PyFloat( contract->volume() ) );
into->SetField( "issuerAllianceID", new PyInt( contract->issuerAllianceID() ) );
into->SetField( "issuerWalletKey", new PyInt( contract->issuerWalletKey() ) );
into->SetField( "acceptorWalletKey", new PyInt( 0 ) );
into->SetField( "crateID", new PyInt( 0 ) );
PyList* itemList = new PyList;
DBRowDescriptor *itemHeader = new DBRowDescriptor();
itemHeader->AddColumn( "contractID", DBTYPE_I4 );
itemHeader->AddColumn( "itemID", DBTYPE_I4 );
itemHeader->AddColumn( "quantity", DBTYPE_I4 );
itemHeader->AddColumn( "itemTypeID", DBTYPE_I4 );
itemHeader->AddColumn( "inCrate", DBTYPE_BOOL );
itemHeader->AddColumn( "parentID", DBTYPE_I4 );
itemHeader->AddColumn( "productivityLevel", DBTYPE_I4 );
itemHeader->AddColumn( "materialLevel", DBTYPE_I4 );
itemHeader->AddColumn( "copy", DBTYPE_I4 );
itemHeader->AddColumn( "licensedProductionRunsRemaining", DBTYPE_I4 );
itemHeader->AddColumn( "damage", DBTYPE_R8 );
itemHeader->AddColumn( "flagID", DBTYPE_I2 );
std::map<uint32, ContractGetItemsRef>::const_iterator cur, end;
std::map<uint32, ContractGetItemsRef> items = contract->items();
cur = items.begin();
//.........这里部分代码省略.........
示例12: 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);
}
}