From f33257521bf80dcef8575c4fc3ddaf4a40ff588a Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 7 Jun 2009 18:13:15 +0000 Subject: fixed a few widget order problems, changed map targetting behaviour --- src/game/base/game.cc | 22 ++++++++++++++++------ src/game/base/shipdealer.cc | 2 +- src/game/base/shipmodel.cc | 6 ++++++ 3 files changed, 23 insertions(+), 7 deletions(-) (limited to 'src/game') 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; diff --git a/src/game/base/shipdealer.cc b/src/game/base/shipdealer.cc index e28b922..feef432 100644 --- a/src/game/base/shipdealer.cc +++ b/src/game/base/shipdealer.cc @@ -88,7 +88,7 @@ void ShipDealer::func_buy(core::Player *player, const std::string &args) helpstr.append("^N|^B"); helpstr.append((*smit).second->label()); } - player->send("Usage: buy [^B" + helpstr + "^N]"); + player->send("Usage: buy ship [^B" + helpstr + "^N]"); return; } diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc index b3802f7..9d905d6 100644 --- a/src/game/base/shipmodel.cc +++ b/src/game/base/shipmodel.cc @@ -107,6 +107,9 @@ ShipModel *ShipModel::find(ShipModel *shipmodel) ShipModel *ShipModel::find(const std::string label) { + if (!label.size()) + return 0; + std::map::iterator it = registry.find(label); if (it == registry.end()) return 0; @@ -116,6 +119,9 @@ ShipModel *ShipModel::find(const std::string label) ShipModel *ShipModel::search(const std::string searchname) { + if (!searchname.size()) + return 0; + std::string strsearchkey(aux::lowercase(searchname)); if (strsearchkey.size() < 3) { return 0; -- cgit v1.2.3