Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-12-25 12:13:56 +0000
committerStijn Buys <ingar@osirion.org>2008-12-25 12:13:56 +0000
commitbfa10f9990a8a045b03474d11af75984c12a856a (patch)
tree87ff30329be78b8012d545b097b669b746ab0fc0 /src/game/base/shipdealer.cc
parent164e3c5b1cd9e6d6f7ca26964df4c54394eb1c84 (diff)
Improved list_zone, list_ships
Ship price and cargo size
Diffstat (limited to 'src/game/base/shipdealer.cc')
-rw-r--r--src/game/base/shipdealer.cc36
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();