$player->update(); // assign the new ship $ship->ship_type_id = $var["ship_id"]; // delete cargo $ship->remove_all_cargo(); // update $ship->update(); // get new ship object $ship = new SMR_SHIP(SmrSession::$old_account_id, SmrSession::$game_id); // adapt hardware $db->query("SELECT * FROM hardware_type"); while ($db->next_record()) { $hardware_type_id = $db->f("hardware_type_id"); // take hardware we don't support if ($ship->hardware[$hardware_type_id] > $ship->max_hardware[$hardware_type_id]) { $ship->hardware[$hardware_type_id] = $ship->max_hardware[$hardware_type_id]; } } // take weapons that we can't carry $ship->weapon = array_slice($ship->weapon, 0, $ship->hardpoint); // disable hardware $db->query("DELETE FROM ship_is_cloaked WHERE account_id = {$player->account_id} AND " . "game_id = {$player->game_id}"); $db->query("DELETE FROM ship_has_illusion WHERE account_id = {$player->account_id} AND " . "game_id = {$player->game_id}"); // if we changed max hardware we need to compensate this. $ship->mark_seen(); // update again $ship->update_hardware(); $ship->update_weapon(); $ship->mark_seen(); $account->log(10, "Buys a {$ship->ship_name} for {$cost} credits", $player->sector_id); forward(create_container("skeleton.php", "current_sector.php"));