diff options
Diffstat (limited to 'src/game/base/shipdealer.cc')
-rw-r--r-- | src/game/base/shipdealer.cc | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/src/game/base/shipdealer.cc b/src/game/base/shipdealer.cc index fb6415c..c1d3b10 100644 --- a/src/game/base/shipdealer.cc +++ b/src/game/base/shipdealer.cc @@ -67,41 +67,33 @@ ShipModel *ShipDealer::find(ShipModel *shipmodel) const void ShipDealer::func_buy(core::Player *player, const std::string &args) { core::Entity *dock = player->view(); - ShipModel *shipmodel = 0; + ShipDealer *shipdealer = 0; // find the ship model - std::string shipname; - std::string helpstr; - std::istringstream is(args); - is >> shipname; - aux::to_label(shipname); - - if (shipname.size()) { - for (ShipModel::iterator smit = ShipModel::registry.begin(); smit != ShipModel::registry.end(); smit++) { - if (shipname == (*smit).first) { - shipmodel = (*smit).second; - break; - } - - if (helpstr.size()) - helpstr.append("^N|^B"); - helpstr.append((*smit).first); - } - } - + ShipModel *shipmodel = ShipModel::find(args); if (!shipmodel) { if (!Game::g_devel->value()) { player->send("Cheats disabled"); return; - } else { + shipmodel = ShipModel::search(args); + } + } + + if (!shipmodel) { + std::string helpstr; + for (ShipModel::iterator smit = ShipModel::registry.begin(); smit != ShipModel::registry.end(); smit++) { + if (helpstr.size()) + helpstr.append("^N|^B"); + helpstr.append((*smit).second->label()); + player->send("Usage: buy [^B" + helpstr + "^N]"); return; } } - /// find the ship dealer we're buying the ship from + // find the ship dealer we're buying the ship from if (player->view()) { if (player->view()->moduletype() == station_enttype) { shipdealer = static_cast<Station *>(player->view())->shipdealer(); |