示例#1
0
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
0
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() ) );
}
示例#3
0
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);
	}
}
示例#4
0
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
0
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);
}
示例#6
0
void 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::Charge )
		item->PutOffline();

	item->Move(m_pOperator->GetLocationID(), flag);  //TODO - check this

	m_ModuleManager->FitModule(item);
}
示例#7
0
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
0
void 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::Charge )
        item->PutOffline();

    // TODO: Somehow, if this returns FALSE, the item->Move() above has to be "undone"... can we do the move AFTER attempting to fit?
    // what if we pass the flag into FitModule().... then if it returns true, the item->Move() can be called
    if( m_ModuleManager->FitModule(item, flag) )
        item->Move(m_pOperator->GetLocationID(), flag);  //TODO - check this
}
示例#9
0
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;
}
示例#10
0
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() ) );
	}
	
}
示例#11
0
void RamProxyService::_VerifyInstallJob_Call(const Call_InstallJob &args, InventoryItemRef installedItem, const PathElement &bomLocation, Client *const c) {
    // ACTIVITY CHECK
    // ***************

    const ItemType *productType;
    switch(args.activityID) {
        /*
         * Manufacturing
         */
        case ramActivityManufacturing: {
            if(installedItem->categoryID() != EVEDB::invCategories::Blueprint)
                throw(PyException(MakeUserError("RamActivityRequiresABlueprint")));

            BlueprintRef bp = BlueprintRef::StaticCast( installedItem );

            if(!bp->infinite() && (bp->licensedProductionRunsRemaining() - args.runs) < 0)
                throw(PyException(MakeUserError("RamTooManyProductionRuns")));

            productType = &bp->productType();
            break;
        }
        /*
         * Time/Material Research
         */
        case ramActivityResearchingMaterialProductivity:
        case ramActivityResearchingTimeProductivity: {
            if(installedItem->categoryID() != EVEDB::invCategories::Blueprint)
                throw(PyException(MakeUserError("RamActivityRequiresABlueprint")));

            BlueprintRef bp = BlueprintRef::StaticCast( installedItem );

            if(bp->copy())
                throw(PyException(MakeUserError("RamCannotResearchABlueprintCopy")));

            productType = &bp->type();
            break;
        }
        /*
         * Copying
         */
        case ramActivityCopying: {
            if(installedItem->categoryID() != EVEDB::invCategories::Blueprint)
                throw(PyException(MakeUserError("RamActivityRequiresABlueprint")));

            BlueprintRef bp = BlueprintRef::StaticCast( installedItem );

            if(bp->copy())
                throw(PyException(MakeUserError("RamCannotCopyABlueprintCopy")));

            productType = &bp->type();
            break;
        }
        /*
         * The rest
         */
        case ramActivityResearchingTechnology:
        case ramActivityDuplicating:
        case ramActivityReverseEngineering:
        case ramActivityInvention: /* {
            if(installedItem->categoryID() != EVEDB::invCategories::Blueprint)
                throw(PyException(MakeUserError("RamActivityRequiresABlueprint")));

            Blueprint *bp = (Blueprint *)installedItem;

            if(!bp->copy())
                throw(PyException(MakeUserError("RamCannotInventABlueprintOriginal")));

            uint32 productTypeID = m_db.GetTech2Blueprint(installedItem->typeID());
            if(productTypeID == NULL)
                throw(PyException(MakeUserError("RamInventionNoOutput")));

            productType = m_manager->item_factory.type(productTypeID);
            break;
        } */
        default: {
            // not supported
            throw(PyException(MakeUserError("RamActivityInvalid")));
            //throw(PyException(MakeUserError("RamNoKnownOutputType")));
        }
    }

    if(!m_db.IsProducableBy(args.installationAssemblyLineID, productType->groupID()))
        throw(PyException(MakeUserError("RamBadEndProductForActivity")));

    // JOBS CHECK
    // ***********
    if(args.activityID == ramActivityManufacturing) {
        uint32 jobCount = m_db.CountManufacturingJobs(c->GetCharacterID());
        if(c->GetChar()->GetAttribute(AttrManufactureSlotLimit).get_int() <= jobCount) {
            std::map<std::string, PyRep *> exceptArgs;
            exceptArgs["current"] = new PyInt(jobCount);
            exceptArgs["max"] = c->GetChar()->GetAttribute(AttrManufactureSlotLimit).GetPyObject();
            throw(PyException(MakeUserError("MaxFactorySlotUsageReached", exceptArgs)));
        }
    } else {
        uint32 jobCount = m_db.CountResearchJobs(c->GetCharacterID());
        if(c->GetChar()->GetAttribute(AttrMaxLaborotorySlots).get_int() <= jobCount) {
            std::map<std::string, PyRep *> exceptArgs;
            exceptArgs["current"] = new PyInt(jobCount);
            exceptArgs["max"] = c->GetChar()->GetAttribute(AttrMaxLaborotorySlots).GetPyObject();
            throw(PyException(MakeUserError("MaxResearchFacilitySlotUsageReached", exceptArgs)));
        }
    }

    // INSTALLATION CHECK
    // *******************

    uint32 regionID = m_db.GetRegionOfContainer(args.installationContainerID);
    if(regionID == 0)
        throw(PyException(MakeUserError("RamIsNotAnInstallation")));

    if(c->GetRegionID() != regionID)
        throw(PyException(MakeUserError("RamRangeLimitationRegion")));

    // RamStructureNotInSpace
    // RamStructureNotIsSolarsystem
    // RamRangeLimitation
    // RamRangeLimitationJumps
    // RamRangeLimitationJumpsNoSkill

    // ASSEMBLY LINE CHECK
    // *********************

    uint32 ownerID;
    double minCharSec, maxCharSec;
    EVERamRestrictionMask restrictionMask;
    EVERamActivity activity;

    // get properties
    if(!m_db.GetAssemblyLineVerifyProperties(args.installationAssemblyLineID, ownerID, minCharSec, maxCharSec, restrictionMask, activity))
        throw(PyException(MakeUserError("RamInstallationHasNoDefaultContent")));

    // check validity of activity
    if(activity < ramActivityManufacturing || activity > ramActivityInvention)
        throw(PyException(MakeUserError("RamAssemblyLineHasNoActivity")));

    // check security rating if required
    if((restrictionMask & ramRestrictBySecurity) == ramRestrictBySecurity) {
        if(minCharSec > c->GetSecurityRating())
            throw(PyException(MakeUserError("RamAccessDeniedSecStatusTooLow")));

        if(maxCharSec < c->GetSecurityRating())
            throw(PyException(MakeUserError("RamAccessDeniedSecStatusTooHigh")));

        // RamAccessDeniedCorpSecStatusTooHigh
        // RamAccessDeniedCorpSecStatusTooLow
    }

    // check standing if required
    if((restrictionMask & ramRestrictByStanding) == ramRestrictByStanding) {
        // RamAccessDeniedCorpStandingTooLow
        // RamAccessDeniedStandingTooLow
    }

    if((restrictionMask & ramRestrictByAlliance) == ramRestrictByAlliance) {
//      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)));
                    } else
                        throw(PyException(MakeUserError("RamRemoteInstalledItemNotInOffice")));
                }
            } else {
                if(installedItem->flag() != flagHangar) {
                    if((uint32)args.installationInvLocationID == c->GetLocationID()) {
                        std::map<std::string, PyRep *> exceptArgs;
                        exceptArgs["location"] = new PyString(m_db.GetStationName(args.installationContainerID));

                        throw(PyException(MakeUserError("RamInstalledItemWrongLocation", exceptArgs)));
                    } else {
                        throw(PyException(MakeUserError("RamRemoteInstalledItemInStationNotHangar")));
                    }
                }
            }
        }
    } else if((uint32)args.installationContainerID == c->GetShipID()) {
        if(c->GetChar()->flag() != flagPilot)
            throw(PyException(MakeUserError("RamAccessDeniedNotPilot")));

        if(installedItem->locationID() != (uint32)args.installationContainerID)
            throw(PyException(MakeUserError("RamInstalledItemMustBeInShip")));
    } else {
        // here should be stuff around POS, but I dont certainly know how it should work, so ...
        // RamInstalledItemBadLocationStructure
        // RamInstalledItemInStructureNotInContainer
        // RamInstalledItemInStructureUnknownLocation
    }

    // BOM LOCATION CHECK
    // *******************

    // corp hangar permission
    if(    (bomLocation.flag == flagCorpSecurityAccessGroup2 && (c->GetCorpRole() & corpRoleHangarCanTake2) != corpRoleHangarCanTake2)
        || (bomLocation.flag == flagCorpSecurityAccessGroup3 && (c->GetCorpRole() & corpRoleHangarCanTake3) != corpRoleHangarCanTake3)
        || (bomLocation.flag == flagCorpSecurityAccessGroup4 && (c->GetCorpRole() & corpRoleHangarCanTake4) != corpRoleHangarCanTake4)
        || (bomLocation.flag == flagCorpSecurityAccessGroup5 && (c->GetCorpRole() & corpRoleHangarCanTake5) != corpRoleHangarCanTake5)
        || (bomLocation.flag == flagCorpSecurityAccessGroup6 && (c->GetCorpRole() & corpRoleHangarCanTake6) != corpRoleHangarCanTake6)
        || (bomLocation.flag == flagCorpSecurityAccessGroup7 && (c->GetCorpRole() & corpRoleHangarCanTake7) != corpRoleHangarCanTake7)
    )
            throw(PyException(MakeUserError("RamAccessDeniedToBOMHangar")));
}
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();
	end = items.end();

	for(; cur != end; cur++ )
	{
		PyPackedRow* data = new PyPackedRow( itemHeader );

		InventoryItemRef item = m_manager->item_factory.GetItem( cur->second->m_itemID );
		data->SetField( "contractID",							new PyInt(	contract->contractID() ) );
		data->SetField( "itemID",								new PyInt(	item->itemID() ) );
		data->SetField( "quantity",								new PyInt(	cur->second->m_quantity ) );
		data->SetField( "itemTypeID",							new PyInt(	item->typeID() ) );
		data->SetField( "inCrate",								new PyBool(	true ) );

		if( item->categoryID() == EVEDB::invCategories::Blueprint )
		{
			BlueprintRef bp = m_manager->item_factory.GetBlueprint( item->itemID() );
			data->SetField( "parentID",							new PyInt( bp->parentBlueprintTypeID() ) );
			data->SetField( "productivityLevel",				new PyInt( bp->productivityLevel() ) );
			data->SetField( "materialLevel",					new PyInt( bp->materialLevel() ) );
			data->SetField( "copy",								new PyInt( bp->copy() ) );
			data->SetField( "licensedProductionRunsRemaining",	new PyInt( bp->licensedProductionRunsRemaining() ) );

			if( bp->HasAttribute( 3 ) )
				data->SetField( "damage",						new PyFloat( bp->GetAttribute( 3 ).get_float() ) );
			else
				data->SetField( "damage",						new PyFloat( 0.0 ) );

			data->SetField( "flagID",							new PyInt( bp->flag() ) );
		}
		else
		{
			data->SetField( "parentID",							new PyInt( 0 ) );
			data->SetField( "productivityLevel",				new PyInt( 0 ) );
			data->SetField( "materialLevel",					new PyInt( 0 ) );
			data->SetField( "copy",								new PyInt( 0 ) );
			data->SetField( "licensedProductionRunsRemaining",	new PyInt( 0 ) );

			if( item->HasAttribute( 3 ) )
				data->SetField( "damage",						new PyFloat( item->GetAttribute( 3 ).get_float() ) );
			else
				data->SetField( "damage",						new PyFloat( 0.0 ) );

			data->SetField( "flagID",							new PyInt( item->flag() ) );
		}

		itemList->AddItem( data );
	}

	std::map<uint32, ContractRequestItemRef>::const_iterator c, e;
	std::map<uint32, ContractRequestItemRef> requestItems = contract->requestItems();

	c = requestItems.begin();
	e = requestItems.end();

	for(; c != e; c++ )
	{
		PyPackedRow* data = new PyPackedRow( itemHeader );
		data->SetField( "contractID",						new PyInt(	arg.arg ) );
		data->SetField(	"itemID",							new PyInt(	0 ) );
		data->SetField(	"quantity",							new PyInt(	c->second->m_quantity ) );
		data->SetField(	"itemTypeID",						new PyInt(	c->second->m_typeID ) );
		data->SetField( "inCrate",							new PyBool( false ) );
		data->SetField(	"parentID",							new PyInt(  0 ) );
		data->SetField( "productivityLevel",				new PyInt(  0 ) );
		data->SetField( "materialLevel",					new PyInt(  0 ) );
		data->SetField( "copy",								new PyInt(	0 ) );
		data->SetField( "licensedProductionRunsRemaining",	new PyInt(   0 ) );
		data->SetField( "damage",							new PyFloat( 0.0 ) );
		data->SetField( "flagID",							new PyInt(   0 ) );

		itemList->AddItem( data );
	}

	DBRowDescriptor *bidsHeader = new DBRowDescriptor();
	bidsHeader->AddColumn( "bidID",					DBTYPE_I4 );
	bidsHeader->AddColumn( "contractID",			DBTYPE_I4 );
	bidsHeader->AddColumn( "issuerID",				DBTYPE_I4 );
	bidsHeader->AddColumn( "quantity",				DBTYPE_I4 );
	bidsHeader->AddColumn( "issuerCorpID",			DBTYPE_I4 );
	bidsHeader->AddColumn( "issuerStationID",		DBTYPE_I4 );
	bidsHeader->AddColumn( "issuerSolarSystemID",	DBTYPE_I4 );
	bidsHeader->AddColumn( "issuerRegionID",		DBTYPE_I4 );
	CRowSet *bids_rowset = new CRowSet( &bidsHeader );

	_contract->SetItemString( "items",		itemList );
	_contract->SetItemString( "bids",		bids_rowset );
	_contract->SetItemString( "contract",	into);

	PyObject* res = new PyObject( new PyString( "util.KeyVal" ), _contract );

	return res;
}
示例#13
0
PyResult Command_spawn( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
    uint32 typeID = 0;
    uint32 actualTypeID = 0;
    std::string actualTypeName = "";
    uint32 actualGroupID = 0;
    uint32 actualCategoryID = 0;
    double actualRadius = 0.0;
    InventoryItemRef item;
    ShipRef ship;
    double radius;
    bool offsetLocationSet = false;
    
	if( args.argCount() < 2 ) {
		throw PyException( MakeCustomError("Correct Usage: /spawn [typeID(int)/typeName(string)]  with optional X Y Z coordinate as in /spawn [typeID(int/typeName(string)] [x(float)] [y(float)] [z(float)]") );
	}
	
	if( !(args.isNumber( 1 )) )
		throw PyException( MakeCustomError( "Argument 1 should be an item type ID" ) );

    typeID = atoi( args.arg( 1 ).c_str() );

	if( !who->IsInSpace() )
		throw PyException( MakeCustomError( "You must be in space to spawn things." ) );

    // Search for item type using typeID:
    if( !(db->ItemSearch(typeID, actualTypeID, actualTypeName, actualGroupID, actualCategoryID, actualRadius) ) )
    {
        return new PyString( "Unknown typeID or typeName returned no matches." );
    }

    // Check to see if the X Y Z optional coordinates were supplied with the command:
    GPoint offsetLocation;
    if( args.argCount() > 2 )
    {
        if( !(args.isNumber(2)) )
            throw PyException( MakeCustomError( "Argument 2 should be the X distance from your ship in meters you want the item spawned" ) );
        if( !(args.isNumber(3)) )
            throw PyException( MakeCustomError( "Argument 3 should be the Y distance from your ship in meters you want the item spawned" ) );
        if( !(args.isNumber(4)) )
            throw PyException( MakeCustomError( "Argument 4 should be the Z distance from your ship in meters you want the item spawned" ) );

        offsetLocation.x = atoi( args.arg( 2 ).c_str() );
        offsetLocation.y = atoi( args.arg( 3 ).c_str() );
        offsetLocation.z = atoi( args.arg( 4 ).c_str() );
        offsetLocationSet = true;
    }

	GPoint loc( who->GetPosition() );

    if( offsetLocationSet )
    {
        // An X, Y, Z coordinate offset was specified along with the command, so use this to calculate
        // the final cooridnate of the newly spawned item:
        loc.x += offsetLocation.x;
        loc.y += offsetLocation.y;
        loc.z += offsetLocation.z;
    }
    else
    {
        // Calculate a random coordinate on the sphere centered on the player's position with
        // a radius equal to the radius of the ship/celestial being spawned times 10 for really good measure of separation:
        radius = (actualRadius * 5.0) * (double)(MakeRandomInt( 1, 3));     // Scale the distance from player that the object will spawn to between 10x and 15x the object's radius
        loc.MakeRandomPointOnSphere( radius );
    }

    // Spawn the item:
	ItemData idata(
		actualTypeID,
		1, // owner is EVE System
		who->GetLocationID(),
		flagAutoFit,
        actualTypeName.c_str(),
		loc
	);

    item = services->item_factory.SpawnItem( idata );
	if( !item )
		throw PyException( MakeCustomError( "Unable to spawn item of type %u.", typeID ) );

    DBSystemDynamicEntity entity;

    entity.allianceID = 0;
    entity.categoryID = actualCategoryID;
    entity.corporationID = 0;
    entity.flag = 0;
    entity.groupID = actualGroupID;
    entity.itemID = item->itemID();
    entity.itemName = actualTypeName;
    entity.locationID = who->GetLocationID();
    entity.ownerID = 1;
    entity.typeID = actualTypeID;
    entity.x = loc.x;
    entity.y = loc.y;
    entity.z = loc.z;

    // Actually do the spawn using SystemManager's BuildEntity:
    if( !(who->System()->BuildDynamicEntity( who, entity )) )
        return new PyString( "Spawn Failed: typeID or typeName not supported." );

    // TEST FOR FUN:  If this is a drone, make its destiny manager orbit the ship that spawned it like a little lost puppy...
    if( item->categoryID() == EVEDB::invCategories::Drone )
    {
        ((DroneEntity *)(who->System()->get( entity.itemID )))->Destiny()->SetSpeedFraction( 1.0, true );
        ((DroneEntity *)(who->System()->get( entity.itemID )))->Destiny()->Orbit( who, 1000.0, true );
    }

    sLog.Log( "Command", "%s: Spawned %u.", who->GetName(), typeID );

	return new PyString( "Spawn successful." );
}
示例#14
0
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))
            {
                throw PyException(MakeCustomError("You do not have the required skills to fit this \n%s", item->itemName().c_str()));
            }
        }
        return true;
    }
    // Handle any other flag, legal or not by virtue of GetRemainingVolumeByFlag() and GetCapacity() that handle supported capacity types:
    // (unsupported or illegal flags report capacity of 0.0, so are automatically rejected)
    double capacityRemaining(0.0);
    capacityRemaining = GetRemainingVolumeByFlag(flag);

    // Check for sufficient capacity.
    if ((capacityRemaining < (item->getAttribute(AttrVolume).get_float() * (double) item->quantity())))
    {
        throw PyException(MakeCustomError("Not enough cargo space!<br><br>flag = %u", (uint32) flag));
        return false;
    }

	return true;
}