diff options
Diffstat (limited to 'src/game/base/game.cc')
-rw-r--r-- | src/game/base/game.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc index da060b9..4128af8 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -195,17 +195,27 @@ void Game::func_dock(core::Player *player, core::Entity *entity) void Game::func_buy(core::Player *player, const std::string &args) { std::istringstream is(args); + std::string itemclass; std::string itemtype; - if (!(is >> itemtype)) { - player->send("usage: buy [string] [string] buy type of item, name of item"); + + if (!(is >> itemclass)) { + player->send("usage: buy [string] [string] buy an item of a specified class and type"); return; + } else { + aux::to_label(itemclass); + } + + if (!(is >> itemtype)) { + itemtype.clear(); + } else { + aux::to_label(itemtype); } - aux::to_label(itemtype); - if ((args.size() > 5 ) && (itemtype.compare("ship") == 0)) { - ShipDealer::func_buy(player, args.substr(5, args.size() - 5)); + + if (itemclass.compare("ship") == 0) { + ShipDealer::func_buy(player, itemtype); } else { - player->send("unkown item type '" + itemtype + "'"); + player->send("unkown item class '" + itemclass + "'"); } return; |