Beispiel #1
0
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;

    // Load modules, rigs and subsystems from Ship's inventory into ModuleContainer:
    uint32 flagIndex;
    for(flagIndex=flagLowSlot0; flagIndex<=flagLowSlot7; flagIndex++)
    {
        InventoryItemRef itemRef;
        m_Ship->FindSingleByFlag( (EVEItemFlags)flagIndex, itemRef );
        if( !(itemRef == NULL) )
            _fitModule( itemRef, (EVEItemFlags)flagIndex );
    }

    for(flagIndex=flagMedSlot0; flagIndex<=flagMedSlot7; flagIndex++)
    {
        InventoryItemRef itemRef;
        m_Ship->FindSingleByFlag( (EVEItemFlags)flagIndex, itemRef );
        if( !(itemRef == NULL) )
            _fitModule( itemRef, (EVEItemFlags)flagIndex );
    }

    for(flagIndex=flagHiSlot0; flagIndex<=flagHiSlot7; flagIndex++)
    {
        InventoryItemRef itemRef;
        m_Ship->FindSingleByFlag( (EVEItemFlags)flagIndex, itemRef );
        if( !(itemRef == NULL) )
            _fitModule( itemRef, (EVEItemFlags)flagIndex );
    }

    for(flagIndex=flagRigSlot0; flagIndex<=flagRigSlot7; flagIndex++)
    {
        InventoryItemRef itemRef;
        m_Ship->FindSingleByFlag( (EVEItemFlags)flagIndex, itemRef );
        if( !(itemRef == NULL) )
            _fitModule( itemRef, (EVEItemFlags)flagIndex );
    }

    for(flagIndex=flagSubSystem0; flagIndex<=flagSubSystem7; flagIndex++)
    {
        InventoryItemRef itemRef;
        m_Ship->FindSingleByFlag( (EVEItemFlags)flagIndex, itemRef );
        if( !(itemRef == NULL) )
            _fitModule( itemRef, (EVEItemFlags)flagIndex );
    }
}
Beispiel #2
0
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;
}
Beispiel #3
0
bool ModuleManager::InstallRig(InventoryItemRef item, EVEItemFlags flag)
{
    if(item->groupID() >= 773 && item->groupID() <= 786 && item->groupID() != 783)
    {
        _fitModule(item,flag);
        return true;
    }
    else
        SysLog::Debug("ModuleManager","%s tried to fit item %u, which is not a rig", m_Ship->GetOperator()->GetName(), item->itemID());

    return false;
}
Beispiel #4
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;
}
Beispiel #5
0
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() );
					throw PyException( MakeCustomError( "ERROR! Cannot fit Med Slot module '%s'", moduleRef->itemName().c_str() ) );
				}
			}
		}
    }

    for(flagIndex=flagHiSlot0; flagIndex<=flagHiSlot7; 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 ) )
				{
					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 High Slot module '%s' (id %u)", moduleRef->itemName().c_str(), moduleRef->itemID() );
					throw PyException( MakeCustomError( "ERROR! Cannot fit High Slot module '%s'", moduleRef->itemName().c_str() ) );
				}
			}
		}
    }

    for(flagIndex=flagRigSlot0; flagIndex<=flagRigSlot7; flagIndex++)
    {
        InventoryItemRef itemRef;
		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->get()->categoryID() != EVEDB::invCategories::Module) && (cur != end) ) {
				cur++;
			}
			if( cur->get()->categoryID() == EVEDB::invCategories::Module )
				itemRef = (*cur);
			if( itemRef )
			{
				_fitModule( itemRef, (EVEItemFlags)flagIndex );
				// We don't think Rigs need the Online attribute set, but keep this code here in case we do:
				//if( itemRef->GetAttribute(AttrIsOnline).get_int() == 1 )
				//	Online(itemRef->itemID());
				//else
				//	Offline(itemRef->itemID());
			}
		}
    }

    for(flagIndex=flagSubSystem0; flagIndex<=flagSubSystem7; flagIndex++)
    {
        InventoryItemRef itemRef;
		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->get()->categoryID() != EVEDB::invCategories::Module) && (cur != end) ) {
				cur++;
			}
			if( cur->get()->categoryID() == EVEDB::invCategories::Module )
				itemRef = (*cur);
			if( itemRef )
			{
				_fitModule( itemRef, (EVEItemFlags)flagIndex );
				// We don't think Subsystems need the Online attribute set, but keep this code here in case we do:
				//if( itemRef->GetAttribute(AttrIsOnline).get_int() == 1 )
				//	Online(itemRef->itemID());
				//else
				//	Offline(itemRef->itemID());
			}
		}
    }

	m_pLog->Log("ModuleManager", "Module loading complete!");

}