当前位置: 首页>>代码示例>>C++>>正文


C++ InventoryItemRef::itemName方法代码示例

本文整理汇总了C++中InventoryItemRef::itemName方法的典型用法代码示例。如果您正苦于以下问题:C++ InventoryItemRef::itemName方法的具体用法?C++ InventoryItemRef::itemName怎么用?C++ InventoryItemRef::itemName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InventoryItemRef的用法示例。


在下文中一共展示了InventoryItemRef::itemName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:careysky,项目名称:evemu_server,代码行数:29,代码来源:InventoryItem.cpp

示例2: 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);
            }
        }
    }
}
开发者ID:Logomorph,项目名称:evemu_crucible,代码行数:30,代码来源:Character.cpp

示例3: ValidateAddItem

void Ship::ValidateAddItem(EVEItemFlags flag, InventoryItemRef item)
{
    CharacterRef character = m_pOperator->GetChar();        // Operator assumed to be Client *
	
	if( flag == flagDroneBay )
    {
        if( item->categoryID() != EVEDB::invCategories::Drone )
            //Can only put drones in drone bay
            throw PyException( MakeUserError( "ItemCannotBeInDroneBay" ) );
    }
    else if( flag == flagShipHangar )
    {
		if( m_pOperator->GetShip()->GetAttribute(AttrHasShipMaintenanceBay ) != 0)      // Operator assumed to be Client *
            // We have no ship maintenance bay
			throw PyException( MakeCustomError( "%s has no ship maintenance bay.", item->itemName().c_str() ) );
        if( item->categoryID() != EVEDB::invCategories::Ship )
            // Only ships may be put here
            throw PyException( MakeCustomError( "Only ships may be placed into ship maintenance bay." ) );
    }
    else if( flag == flagHangar )
    {
		if( m_pOperator->GetShip()->GetAttribute(AttrHasCorporateHangars ) != 0)        // Operator assumed to be Client *
            // We have no corporate hangars
            throw PyException( MakeCustomError( "%s has no corporate hangars.", item->itemName().c_str() ) );
    }
    else if( flag == flagCargoHold )
	{
		//get all items in cargohold
		EvilNumber capacityUsed(0);
		std::vector<InventoryItemRef> items;
		m_pOperator->GetShip()->FindByFlag(flag, items);        // Operator assumed to be Client *
		for(uint32 i = 0; i < items.size(); i++){
			capacityUsed += items[i]->GetAttribute(AttrVolume);
		}
		if( capacityUsed + item->GetAttribute(AttrVolume) > m_pOperator->GetShip()->GetAttribute(AttrCapacity) )    // Operator assumed to be Client *
			throw PyException( MakeCustomError( "Not enough cargo space!") );
	}
	else if( flag > flagLowSlot0  &&  flag < flagHiSlot7 )
	{
        if( m_pOperator->IsClient() )
		    if(!Skill::FitModuleSkillCheck(item, character))        // SKIP THIS SKILL CHECK if Operator is NOT Client *
			    throw PyException( MakeCustomError( "You do not have the required skills to fit this \n%s", item->itemName().c_str() ) );
		if(!ValidateItemSpecifics(item))
			throw PyException( MakeCustomError( "Your ship cannot equip this module" ) );
		if(item->categoryID() == EVEDB::invCategories::Charge) {
			InventoryItemRef module;
			m_pOperator->GetShip()->FindSingleByFlag(flag, module);     // Operator assumed to be Client *
			if(module->GetAttribute(AttrChargeSize) != item->GetAttribute(AttrChargeSize) )
				throw PyException( MakeCustomError( "The charge is not the correct size for this module." ) );
			if(module->GetAttribute(AttrChargeGroup1) != item->groupID())
				throw PyException( MakeCustomError( "Incorrect charge type for this module.") );
		}
	}
	else if( flag > flagRigSlot0  &&  flag < flagRigSlot7 )
	{
        if( m_pOperator->IsClient() )
    		if(!Skill::FitModuleSkillCheck(item, character))        // SKIP THIS SKILL CHECK if Operator is NOT Client *
			    throw PyException( MakeCustomError( "You do not have the required skills to fit this \n%s", item->itemName().c_str() ) );
		if(m_pOperator->GetShip()->GetAttribute(AttrRigSize) != item->GetAttribute(AttrRigSize))        // Operator assumed to be Client *
			throw PyException( MakeCustomError( "Your ship cannot fit this size module" ) );
		if( m_pOperator->GetShip()->GetAttribute(AttrUpgradeLoad) + item->GetAttribute(AttrUpgradeCost) > m_pOperator->GetShip()->GetAttribute(AttrUpgradeCapacity) )   // Operator assumed to be Client *
			throw PyException( MakeCustomError( "Your ship cannot handle the extra calibration" ) );
	}
	else if( flag > flagSubSystem0  &&  flag < flagSubSystem7 )
	{
        if( m_pOperator->IsClient() )
		    if(!Skill::FitModuleSkillCheck(item, character))        // SKIP THIS SKILL CHECK if Operator is NOT Client *
			    throw PyException( MakeCustomError( "You do not have the required skills to fit this \n%s", item->itemName().c_str() ) );
	}
	
}
开发者ID:Logomorph,项目名称:evemu_crucible,代码行数:71,代码来源:Ship.cpp

示例4: 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() );
//.........这里部分代码省略.........
开发者ID:comet0,项目名称:evemu_server,代码行数:101,代码来源:ModuleManager.cpp

示例5: ValidateAddItem

bool Ship::ValidateAddItem(EVEItemFlags flag, InventoryItemRef item) const
{
    CharacterRef character = m_pOperator->GetChar();

    if( flag == flagDroneBay )
    {
        if (item->categoryID() != EVEDB::invCategories::Drone)
        {
            //Can only put drones in drone bay
            throw PyException(MakeUserError("ItemCannotBeInDroneBay"));
        }
    }
    else if( flag == flagShipHangar )
    {
        if (m_pOperator->GetShip()->getAttribute(AttrHasShipMaintenanceBay) != 0)
        {
            // We have no ship maintenance bay
            throw PyException(MakeCustomError("%s has no ship maintenance bay.", item->itemName().c_str()));
        }
        if (item->categoryID() != EVEDB::invCategories::Ship)
        {
            // Only ships may be put here
            throw PyException(MakeCustomError("Only ships may be placed into ship maintenance bay."));
        }
    }
    else if( flag == flagHangar )
    {
        if (m_pOperator->GetShip()->getAttribute(AttrHasCorporateHangars) != 0)
        {
            // We have no corporate hangars
            throw PyException(MakeCustomError("%s has no corporate hangars.", item->itemName().c_str()));
        }
    }
    else if( (flag >= flagLowSlot0)  &&  (flag <= flagHiSlot7) )
    {
        if (m_pOperator->IsClient())
        {
            // SKIP THIS SKILL CHECK if Operator is NOT Client *
            if (!character->canUse(item))
            {
                throw PyException(MakeCustomError("You do not have the required skills to fit this \n%s", item->itemName().c_str()));
            }
        }
        if (!ValidateItemSpecifics(item))
        {
            throw PyException(MakeCustomError("Your ship cannot equip this module"));
        }
        if(item->categoryID() == EVEDB::invCategories::Charge)
		{
			if( m_ModuleManager->GetModule(flag) != NULL )
			{
				InventoryItemRef module;
				module = m_ModuleManager->GetModule(flag)->getItem();
                if (module->getAttribute(AttrChargeSize) != item->getAttribute(AttrChargeSize))
					throw PyException( MakeCustomError( "The charge is not the correct size for this module." ) );
                if (module->getAttribute(AttrChargeGroup1) != item->groupID())
					throw PyException( MakeCustomError( "Incorrect charge type for this module.") );

				// NOTE: Module Manager will check for actual room to load charges and make stack splits, or reject loading altogether
            }
            else
            {
                throw PyException(MakeCustomError("Module at flag '%u' does not exist!", flag));
            }
        }
		else
        {
            if (m_ModuleManager->IsSlotOccupied(flag))
            {
                throw PyException(MakeUserError("SlotAlreadyOccupied"));
            }
        }
        return true;
    }
    else if( (flag >= flagRigSlot0)  &&  (flag <= flagRigSlot7) )
    {
        if (m_pOperator->IsClient())
        {
            // SKIP THIS SKILL CHECK if Operator is NOT Client *
            if (!character->canUse(item))
            {
                throw PyException(MakeCustomError("You do not have the required skills to fit this \n%s", item->itemName().c_str()));
            }
        }
        if (m_pOperator->GetShip()->getAttribute(AttrRigSize) != item->getAttribute(AttrRigSize))
        {
            throw PyException(MakeCustomError("Your ship cannot fit this size module"));
        }
        if (m_pOperator->GetShip()->getAttribute(AttrUpgradeLoad) + item->getAttribute(AttrUpgradeCost) > m_pOperator->GetShip()->getAttribute(AttrUpgradeCapacity))
        {
            throw PyException(MakeCustomError("Your ship cannot handle the extra calibration"));
        }
        return true;
    }
    else if( (flag >= flagSubSystem0)  &&  (flag <= flagSubSystem7) )
    {
        if (m_pOperator->IsClient())
        {
            // SKIP THIS SKILL CHECK if Operator is NOT Client *
            if (!character->canUse(item))
//.........这里部分代码省略.........
开发者ID:eve-moo,项目名称:evemu_server,代码行数:101,代码来源:Ship.cpp


注:本文中的InventoryItemRef::itemName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。