ShipRef ItemFactory::SpawnShip(ItemData &data) { ShipRef s = Ship::Spawn(*this, data); if( !s ) return ShipRef(); m_items.insert( std::make_pair( s->itemID(), s ) ); return s; }
void Client::Killed(Damage &fatal_blow) { DynamicSystemEntity::Killed(fatal_blow); if(GetShip()->typeID() == itemTypeCapsule) { //we have been pod killed... off we go. //TODO: destroy all implants //TODO: send them back to their clone. m_system->RemoveClient(this); } else { //our ship has been destroyed. Off to our capsule. //We are currently not keeping our real capsule around in the DB, so we need to make a new one. //m_system->bubbles.Remove(this, true); std::string capsule_name = GetName(); capsule_name += "'s Capsule"; ItemData idata( itemTypeCapsule, GetCharacterID(), GetLocationID(), flagAutoFit, capsule_name.c_str() ); ShipRef capsule = m_services.item_factory.SpawnShip(idata); if( !capsule ) { codelog(CLIENT__ERROR, "Failed to create capsule for character '%s'", GetName()); //what to do? return; } ShipRef dead_ship = GetShip(); //grab a ship ref to ensure that nobody else nukes it first. //ok, nothing can fail now, we need have our capsule, make the transition. //put the capsule where the ship was capsule->Relocate(dead_ship->position()); //move it out of the way dead_ship->Move(this->GetLocationID(), (EVEItemFlags)flagNone, true ); //this updates m_self and manages destiny updates as needed. BoardShip((ShipRef)capsule); mSession.SetInt("shipid", capsule->itemID() ); //This sends the RemoveBall for the old ship. //kill off the old ship. //TODO: figure out anybody else which may be referencing this ship... dead_ship->Delete(); //remove from the DB. } }