Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-09-17 18:58:46 +0000
committerStijn Buys <ingar@osirion.org>2010-09-17 18:58:46 +0000
commit66ce015e5927c30801110acd289310fdff181792 (patch)
tree7beaa6b533eefdd26f0705bd65dfb5c3c9b5996a /src/game
parentc62fe609a69058e2e30f757e9a06f72a98464232 (diff)
Initial support for players docking other players' ships.
Diffstat (limited to 'src/game')
-rw-r--r--src/game/base/game.cc8
-rw-r--r--src/game/base/ship.cc22
-rw-r--r--src/game/base/shipmodel.cc9
-rw-r--r--src/game/base/shipmodel.h11
4 files changed, 47 insertions, 3 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index 1d4536a..128ae7c 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -168,6 +168,9 @@ void Game::func_dock(core::Player *player, core::Entity *entity)
if (player->control()->zone() != entity->zone())
return;
+
+ if (player->control() == entity)
+ return;
if ((entity->flags() & core::Entity::Dockable) == 0)
return;
@@ -202,6 +205,8 @@ void Game::func_buy(core::Player *player, const std::string &args)
if (typestr.compare("ship") == 0) {
ShipDealer::func_buy(player, labelstr);
+ } else if (typestr.compare("cargo") == 0) {
+ player->send("Buying cargo is not supported");
} else {
player->send("unkown item type '" + typestr + "'");
}
@@ -915,6 +920,9 @@ bool Game::load_ships()
} else if (shipsini.got_key_bool("jumpdrive", b)) {
shipmodel->set_jumpdrive(b);
continue;
+ } else if (shipsini.got_key_bool("dock", b)) {
+ shipmodel->set_dock(b);
+ continue;
} else if (shipsini.got_key_float("acceleration", f)) {
shipmodel->set_acceleration(f);
continue;
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 6aaba40..7edc183 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -49,6 +49,23 @@ Ship::Ship(core::Player *owner, ShipModel *shipmodel) : core::EntityControlable(
set_label(shipmodel->label());
}
+ if (shipmodel->dock()) {
+ using core::MenuDescription;
+ using core::ButtonDescription;
+
+ MenuDescription *menu_main = new MenuDescription();
+ menu_main->set_label("main");
+ menu_main->set_text("Launch area");
+ add_menu(menu_main);
+
+ ButtonDescription *button = new ButtonDescription();
+ button->set_text("Launch");
+ button->set_command("launch", ButtonDescription::CommandGame);
+ button->set_alignment(ButtonDescription::Center);
+ menu_main->add_button(button);
+
+ set_flag(core::Entity::Dockable);
+ }
reset();
}
@@ -293,7 +310,12 @@ void Ship::frame(float seconds)
} else {
get_location().assign(ship_jumpdepart->target()->location() + location() - ship_jumpdepart->location());
}
+
set_zone(ship_jumpdepart->target()->zone());
+
+ if (owner() && owner()->view()->zone() != ship_jumpdepart->target()->zone())
+ owner()->set_view(0);
+
owner()->send("^BJumping to the " + ship_jumpdepart->target()->zone()->name());
} else {
set_state(core::Entity::Normal);
diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc
index ed8f09d..ee2e647 100644
--- a/src/game/base/shipmodel.cc
+++ b/src/game/base/shipmodel.cc
@@ -25,6 +25,7 @@ ShipModel::ShipModel() : core::Info(shipmodel_infotype)
shipmodel_maxcargo = 0;
shipmodel_jumpdrive = false; // no jumpdrive capability
+ shipmodel_dock = false; // not dockable
}
ShipModel::~ShipModel()
@@ -59,9 +60,11 @@ void ShipModel::generate_info()
str.str("");
if (jumpdrive()) {
- str << "hyperspace jump drive capable";
- add_text(str.str());
- str.str("");
+ add_text("hyperspace jump drive capable");
+ }
+
+ if (dock()) {
+ add_text("docking capable");
}
}
diff --git a/src/game/base/shipmodel.h b/src/game/base/shipmodel.h
index 9b428df..38e9d5d 100644
--- a/src/game/base/shipmodel.h
+++ b/src/game/base/shipmodel.h
@@ -31,6 +31,11 @@ public:
return shipmodel_jumpdrive;
}
+ /// indicates if players can dock this ship model
+ inline const bool dock() const {
+ return shipmodel_dock;
+ }
+
/// acceleration
inline const float acceleration() const {
return shipmodel_acceleration;
@@ -77,6 +82,11 @@ public:
inline void set_jumpdrive(const bool jumpdrive) {
shipmodel_jumpdrive = jumpdrive;
}
+
+ /// set dock capability
+ inline void set_dock(const bool dock) {
+ shipmodel_dock = dock;
+ }
void generate_info();
@@ -92,6 +102,7 @@ public:
private:
bool shipmodel_jumpdrive;
+ bool shipmodel_dock;
float shipmodel_acceleration;
float shipmodel_maxspeed;