Пример #1
0
void ModuleManager::UnfitModule(uint32 itemID)
{
    GenericModule * mod = m_Modules->GetModule(itemID);
    if( mod != NULL )
    {
		if( mod->isLoaded() )
		{
			InventoryItemRef loadedChargeRef = mod->getLoadedChargeRef();
			if( IsStation(m_Ship->locationID()) )
				loadedChargeRef->Move(m_Ship->locationID(), flagHangar);		// used to be (m_pOperator->GetLocationID(), flag)
			else
			{
				m_Ship->ValidateAddItem(flagCargoHold,loadedChargeRef);
				//if( m_Ship->ValidateAddItem(flagCargoHold,loadedChargeRef) )
				//{
					loadedChargeRef->Move(m_Ship->itemID(), flagCargoHold);		// used to be (m_pOperator->GetLocationID(), flag)
					mod->unload();
				//}
				//else
				//	throw PyException( MakeCustomError( "Not enough cargo space!") );
			}
		}

		mod->offline();
		m_Modules->RemoveModule(itemID);
    }
}
Пример #2
0
int32 ModuleManager::Activate(uint32 itemID, std::string effectName, uint32 targetID, uint32 repeat)
{
    SysLog::Debug("Activate","Needs to be implemented");
    //return 1;

    GenericModule * mod = m_Modules->GetModule(itemID);
    if( mod != NULL )
    {
		if(effectName == "online")
		{
			//ModuleCommand cmd = _translateEffectName(effectName);		// GET RID of this function, effectName should be passed into the module's calls
			mod->online();

			// We should check for "online" here or something else, then either call the mod->Online() or mod->Activate()
			//if(cmd == ONLINE)
		    //    mod->Online();     // this currently fails since m_selectedEffect and m_defaultEffect in the ModuleEffect class are undefined
			//there needs to be more cases here i just don't know what they're called yet
		}
		else
		{
			SystemEntity * targetEntity = this->m_Ship->GetOperator()->GetDestiny()->GetCurrentBubble()->GetEntity(targetID);
			mod->activate(targetEntity);
			m_pLog->Log("ModuleManager::Activate()", "Module '%s' Activating...", mod->getItem()->itemName().c_str());
		}
    }

    return 1;
}
Пример #3
0
void ModuleManager::DeOverload(uint32 itemID)
{
    GenericModule * mod = m_Modules->GetModule(itemID);
    if( mod != NULL )
    {
        mod->deOverload();
    }
}
Пример #4
0
void ModuleManager::DamageModule(uint32 itemID, EvilNumber val)
{
    GenericModule * mod = m_Modules->GetModule(itemID);
    if( mod != NULL)
    {
        mod->setAttribute(AttrHp, val);
    }
}
Пример #5
0
void ModuleManager::RepairModule(uint32 itemID)
{
    GenericModule * mod = m_Modules->GetModule(itemID);
    if( mod != NULL )
    {
        mod->repair();
    }
}
Пример #6
0
void ModuleManager::Offline(uint32 itemID)
{
    GenericModule * mod = m_Modules->GetModule(itemID);
    if( mod != NULL )
	{
        mod->offline();
		m_pLog->Log("ModuleManager::Offline()", "Module '%s' going Offline", mod->getItem()->itemName().c_str());
	}
}
Пример #7
0
void ModuleManager::UnfitModule(uint32 itemID)
{
    GenericModule * mod = m_Modules->GetModule(itemID);
    if( mod != NULL )
    {
        mod->Offline();
        m_Modules->RemoveModule(itemID);
    }
}
Пример #8
0
void ModuleContainer::RemoveModule(EVEItemFlags flag)
{
    GenericModule * mod = GetModule(flag);

    _removeModule(mod->flag(), mod);

    //delete the module
    delete mod;
    mod = NULL;
}
Пример #9
0
void ModuleContainer::RemoveModule(uint32 itemID)
{
    GenericModule * mod = GetModule(itemID);

    _removeModule(mod->flag(), mod);

    //delete the module
    delete mod;
    mod = NULL;
}
Пример #10
0
void ModuleManager::Deactivate(uint32 itemID, std::string effectName)
{
    GenericModule * mod = m_Modules->GetModule(itemID);
    if( mod != NULL )
    {
        ModuleCommand cmd = _translateEffectName(effectName);
        mod->getItem()->PutOffline();
        //if(cmd == OFFLINE)
        //    mod->Offline();     // this currently fails since m_selectedEffect and m_defaultEffect in the ModuleEffect class are undefined
        //there needs to be more cases here i just don't know what they're called yet
    }
}
Пример #11
0
bool ModuleManager::_fitModule(InventoryItemRef item, EVEItemFlags flag)
{
    bool verifyFailed = false;
    GenericModule * mod = ModuleFactory(item, ShipRef(m_Ship));

    // 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(mod->flag(), mod);
        m_Modules->AddModule(flag, mod);
    }

    if( verifyFailed )
    {
        delete mod;
        return false;
    }
    else
        return true;
}
Пример #12
0
bool ModuleContainer::RemoveModule(uint32 itemID)
{
    GenericModule * mod = GetModule(itemID);

	if( mod == NULL )
		return false;	// NO module pointer found at this slot flag, DO NOT attempt to dereference

    _removeModule(mod->flag(), mod);

    //delete the module
    delete mod;
    mod = NULL;

	return true;
}
Пример #13
0
int32 ModuleManager::Activate(uint32 itemID, std::string effectName, uint32 targetID, uint32 repeat)
{
    //sLog.Debug("Activate","Needs to be implemented");
    //return 1;

    GenericModule * mod = m_Modules->GetModule(itemID);
    if( mod != NULL )
    {
        ModuleCommand cmd = _translateEffectName(effectName);
        mod->getItem()->PutOnline();
        //if(cmd == ONLINE)
        //    mod->Online();     // this currently fails since m_selectedEffect and m_defaultEffect in the ModuleEffect class are undefined
        //there needs to be more cases here i just don't know what they're called yet
    }

    return 1;
}
Пример #14
0
InventoryItemRef ModuleManager::GetLoadedChargeOnModule(EVEItemFlags flag)
{
    GenericModule * mod = m_Modules->GetModule(flag);
	if( mod->isLoaded() )
	{
		if( mod != NULL )
		{
			if( mod->isLoaded() )
				return mod->getLoadedChargeRef();
			else
				return InventoryItemRef();
		}
	}
	else
		GetLogger()->Warning( "ModuleManager::UnloadCharge()", "WARNING! Called UnloadCharge() on a module that is NOT loaded or not a charged module!" );

	return InventoryItemRef();
}
Пример #15
0
void ModuleManager::_processExternalEffect(SubEffect * s)
{
    //50-50 it's targeting a specific module ( i'm assuming here )
    GenericModule * mod = m_Modules->GetModule(s->TargetItemID());
    if( mod != NULL )
    {
        //calculate new attribute
        mod->setAttribute(s->AttributeID(),
                          CalculateNewAttributeValue(mod->getAttribute(s->AttributeID()),
                                                                       s->AppliedValue(), s->CalculationType()));
    }
    else if( s->TargetItemID() == m_Ship->itemID() ) //guess it's not, but that means it should be targeting our ship itself
    {
        //calculate new attribute
        m_Ship->SetAttribute(s->AttributeID(),
                             CalculateNewAttributeValue(m_Ship->GetAttribute(s->AttributeID()),
                                                                             s->AppliedValue(), s->CalculationType()));
    }
    else //i have no idea what their targeting X_X
        SysLog::Error("ModuleManager", "Process external effect inconsistency.  This shouldn't happen");

}
Пример #16
0
void ModuleManager::Deactivate(uint32 itemID, std::string effectName)
{
    GenericModule * mod = m_Modules->GetModule(itemID);
    if( mod != NULL )
    {
		if(effectName == "online")
		{
			//ModuleCommand cmd = _translateEffectName(effectName);		// GET RID of this function, effectName should be passed into the module's calls
			mod->offline();

			// We should check for "online" here or something else, then either call the mod->Offline() or mod->Deactivate()
			//if(cmd == OFFLINE)
			//    mod->Offline();     // this currently fails since m_selectedEffect and m_defaultEffect in the ModuleEffect class are undefined
			//there needs to be more cases here i just don't know what they're called yet
		}
		else
		{
			mod->deactivate();
			m_pLog->Log("ModuleManager::Deactivate()", "Module '%s' Deactivating...", mod->getItem()->itemName().c_str());
		}
    }
}
Пример #17
0
bool ModuleContainer::isSubSystem(uint32 itemID)
{
    GenericModule * mod = GetModule(itemID);

    return mod->isSubSystem();
}
Пример #18
0
bool ModuleContainer::isLowPower(uint32 itemID)
{
    GenericModule * mod = GetModule(itemID);

    return mod->isLowPower();
}
Пример #19
0
std::vector<GenericModule *> ModuleManager::GetStackedItems(uint32 typeID, ModulePowerLevel level)
{
    std::vector<GenericModule *> mods;
    GenericModule * tmp;

    switch(level)
    {
    case MODULE_BANK_HIGH_POWER:
        for(int i = flagHiSlot0; i < flagHiSlot7 + 1; i++)
        {
            tmp = m_Modules->GetModule((EVEItemFlags)i);
            if( tmp->typeID() == typeID && tmp->isOnline() )
                mods.push_back(tmp);
        }
        break;
    case MODULE_BANK_MEDIUM_POWER:
        for(int i = flagMedSlot0; i < flagMedSlot7 + 1; i++)
        {
            tmp = m_Modules->GetModule((EVEItemFlags)i);
            if( tmp->typeID() == typeID && tmp->isOnline() )
                mods.push_back(tmp);
        }
        break;
    case MODULE_BANK_LOW_POWER:
        for(int i = flagLowSlot0; i < flagLowSlot7 + 1; i++)
        {
            tmp = m_Modules->GetModule((EVEItemFlags)i);
            if( tmp->typeID() == typeID && tmp->isOnline() )
                mods.push_back(tmp);
        }
        break;
    case MODULE_BANK_RIG:
        for(int i = flagRigSlot0; i < flagRigSlot7 + 1; i++)
        {
            tmp = m_Modules->GetModule((EVEItemFlags)i);
            if( tmp->typeID() == typeID && tmp->isOnline() )
                mods.push_back(tmp);
        }
        break;
    case MODULE_BANK_SUBSYSTEM:
        for(int i = flagSubSystem0; i < flagSubSystem7 + 1; i++)
        {
            tmp = m_Modules->GetModule((EVEItemFlags)i);
            if( tmp->typeID() == typeID && tmp->isOnline() )
                mods.push_back(tmp);
        }
        break;
    }

    return mods;
}
Пример #20
0
void ModuleManager::UninstallRig(uint32 itemID)
{
    GenericModule * mod = m_Modules->GetModule(itemID);
    if( mod != NULL )
        mod->DestroyRig();
}
Пример #21
0
void ModuleManager::Offline(uint32 itemID)
{
    GenericModule * mod = m_Modules->GetModule(itemID);
    if( mod != NULL )
        mod->Offline();
}
Пример #22
0
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;
}