Esempio n. 1
0
bool SystemManager::_LoadSystemCelestials() {
	std::vector<DBSystemEntity> entities;
	if(!m_db.LoadSystemEntities(m_systemID, entities)) {
		_log(SERVICE__ERROR, "Unable to load celestial entities during boot of system %u.", m_systemID);
		return false;
    }

	//uint32 next_hack_entity_ID = m_systemID + 900000000;
	
	std::vector<DBSystemEntity>::iterator cur, end;
	cur = entities.begin();
	end = entities.end();
	for(; cur != end; ++cur) {
		SimpleSystemEntity *se = SimpleSystemEntity::MakeEntity(this, *cur);
		if(se == NULL) {
			codelog(SERVICE__ERROR, "Failed to create entity for item %u (type %u)", cur->itemID, cur->typeID);
			continue;
		}
		if(!se->LoadExtras(&m_db)) {
			_log(SERVICE__ERROR, "Failed to load additional data for entity %u. Skipping.", se->GetID());
			delete se;
			continue;
		}
		m_entities[se->GetID()] = se;
		bubbles.Add(se, false);
		m_entityChanged = true;
	}
	
	return true;
}
Esempio n. 2
0
bool SystemManager::_LoadSystemCelestials() {
    std::vector<DBSystemEntity> entities;
    if(!m_db.LoadSystemEntities(m_systemID, entities)) {
        _log(SERVICE__ERROR, "Unable to load celestial entities during boot of system %u.", m_systemID);
        return false;
    }

    //uint32 next_hack_entity_ID = m_systemID + 900000000;

    std::vector<DBSystemEntity>::iterator cur, end;
    cur = entities.begin();
    end = entities.end();
    for(; cur != end; ++cur) {
        if( itemFactory().GetItem( cur->itemID ) )
        {
            if( itemFactory().GetItem( cur->itemID )->categoryID() == EVEDB::invCategories::Station )
            {
                StationRef station = Station::Load( itemFactory(), cur->itemID );
                StationEntity *stationEntity = new StationEntity( station, this, *(GetServiceMgr()), cur->position );
                if(stationEntity == NULL) {
                    codelog(SERVICE__ERROR, "Failed to create entity for item %u (type %u)", cur->itemID, cur->typeID);
                    continue;
                }

                // Create default dynamic attributes in the AttributeMap:
                StationRef stationRef = stationEntity->GetStationObject();
                stationRef->SetAttribute(AttrIsOnline,      1);                                        // Is Online
                stationRef->SetAttribute(AttrDamage,        0.0);                                        // Structure Damage
                stationRef->SetAttribute(AttrShieldCapacity,20000000.0);                         // Shield Capacity
                stationRef->SetAttribute(AttrShieldCharge,  stationRef->GetAttribute(AttrShieldCapacity));     // Shield Charge
                stationRef->SetAttribute(AttrArmorHP,       stationRef->type().attributes.armorHP());   // Armor HP
                stationRef->SetAttribute(AttrArmorDamage,   0.0);                                   // Armor Damage
                stationRef->SetAttribute(AttrMass,          stationRef->type().attributes.mass());         // Mass
                stationRef->SetAttribute(AttrRadius,        stationRef->type().attributes.radius());     // Radius
                stationRef->SetAttribute(AttrVolume,        stationRef->type().attributes.volume());     // Volume

                m_entities[stationEntity->GetStationObject()->itemID()] = stationEntity;
                bubbles.Add(stationEntity, true);
                m_entityChanged = true;
            }
            else if(( itemFactory().GetItem( cur->itemID )->groupID() == EVEDB::invGroups::Stargate ) ||
               ( itemFactory().GetItem( cur->itemID )->groupID() == EVEDB::invGroups::Asteroid_Belt ))
            {
                SimpleSystemEntity *se = SimpleSystemEntity::MakeEntity(this, *cur);
                if(se == NULL) {
                    codelog(SERVICE__ERROR, "Failed to create entity for item %u (type %u)", cur->itemID, cur->typeID);
                    continue;
                }
                if(!se->LoadExtras(&m_db)) {
                    _log(SERVICE__ERROR, "Failed to load additional data for entity %u. Skipping.", se->GetID());
                    delete se;
                    continue;
                }
                m_entities[se->GetID()] = se;
                bubbles.Add(se, false);
                m_entityChanged = true;
            }
            else
            {
                SimpleSystemEntity *se = SimpleSystemEntity::MakeEntity(this, *cur);
                if(se == NULL) {
                    codelog(SERVICE__ERROR, "Failed to create entity for item %u (type %u)", cur->itemID, cur->typeID);
                    continue;
                }
                if(!se->LoadExtras(&m_db)) {
                    _log(SERVICE__ERROR, "Failed to load additional data for entity %u. Skipping.", se->GetID());
                    delete se;
                    continue;
                }
                m_entities[se->GetID()] = se;
                //bubbles.Add(se, false);
                m_entityChanged = true;
            }
        }
    }

    return true;
}