diff options
author | Stijn Buys <ingar@osirion.org> | 2010-11-25 19:29:30 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2010-11-25 19:29:30 +0000 |
commit | aae321e655a3590f81173b615cc1f227fdf996a7 (patch) | |
tree | 37453eb0dc000ae38b7640785f93b15f3b43ee15 /src/game/base | |
parent | 02b285bf20603bab6fc75d106acbaccead645eb9 (diff) |
Have the spec command report individual specifications if no value is provided.
Diffstat (limited to 'src/game/base')
-rw-r--r-- | src/game/base/game.cc | 64 |
1 files changed, 44 insertions, 20 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc index 108c13f..8c39c5c 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -82,7 +82,6 @@ void Game::func_join(core::Player *player, std::string const &args) player->set_view(dock); } - std::string message("^B"); message.append(player->name()); message.append("^B joins the game."); @@ -168,7 +167,7 @@ void Game::func_target_dock(core::Player *player, core::Entity *entity) range += planet_safe_distance; } - core::Player *owner = (entity->type() == core::Entity::Controlable ? static_cast<core::EntityControlable *>(entity)->owner() : 0 ); + core::Player *owner = (entity->type() == core::Entity::Controlable ? static_cast<core::EntityControlable *>(entity)->owner() : 0 ); if (math::distance(entity->location(), ship->location()) > range) { if (owner) { player->send("^B" + owner->name() + "^B's " + entity->name() + " is out of range"); @@ -477,40 +476,65 @@ void Game::func_specs(core::Player *player, const std::string &args) } } else { + std::stringstream msgstr; float value; - if (!(is >> value)) - return; + // specs label aux::to_label(str); - std::stringstream msgstr; if (str.compare("thrust") == 0) { - ship->set_thrust_force(value); - msgstr << "Ship thrust force set to " << value; + if (is >> value) { + ship->set_thrust_force(value); + msgstr << "Ship thrust force set to " << value; + } else { + msgstr << "Ship thrust at " << ship->thrust_force(); + } } else if (str.compare("impulse") == 0) { - ship->set_impulse_force(value); - msgstr << "Ship impulse force set to " << value; + if (is >> value) { + ship->set_impulse_force(value); + msgstr << "Ship impulse force set to " << value; + } else { + msgstr << "Ship impulse force at " << ship->impulse_force(); + } } else if (str.compare("strafe") == 0) { - ship->set_strafe_force(value) ; - msgstr << "Ship strafe force set to " << value; + if (is >> value) { + ship->set_strafe_force(value) ; + msgstr << "Ship strafe force set to " << value; + } else { + msgstr << "Ship impulse force at " << ship->strafe_force(); + } } else if (str.compare("turn") == 0) { - ship->set_turn_force(value); - msgstr << "Ship turn force set to " << value; + if (is >> value) { + ship->set_turn_force(value); + msgstr << "Ship turn force set to " << value; + } else { + msgstr << "Ship turn force at " << ship->turn_force(); + } } else if (str.compare("roll") == 0) { - ship->set_roll_force(value); - msgstr << "Ship roll force set to " << value; + if (is >> value) { + ship->set_roll_force(value); + msgstr << "Ship roll force set to " << value; + } else { + msgstr << "Ship roll force at " << ship->roll_force(); + } } else if (str.compare("damping") == 0) { - float a; - if (!(is >> a)) { - a = value; + if (is >> value) { + float a; + if (!(is >> a)) { + a = value; + } + ship->body()->setDamping(value, a); + msgstr << "Ship damping set to " << value << " " << a; + } else { + msgstr << "Ship damping at " << ship->body()->getLinearDamping() << " " << ship->body()->getAngularDamping(); } - ship->body()->setDamping(value, a); - + } else if (str.compare("mass") == 0) { + msgstr << "Ship mass at " << ship->mass(); } else { msgstr << "^WUnknown ship engine specification '" << str << "'"; } |