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>2011-07-11 19:33:27 +0000
committerStijn Buys <ingar@osirion.org>2011-07-11 19:33:27 +0000
commit83c9d657773fa4f829b533791697ed07e0d9d962 (patch)
tree0c53d6a6d71c14894ac51124933ae31b66164217 /src/game/base/ship.cc
parent99bd770a6030805ecd2cb22671e8f29d32fd59db (diff)
Initial support for saving player data in multiplayer games,
have ships remember their docks and spawns.
Diffstat (limited to 'src/game/base/ship.cc')
-rw-r--r--src/game/base/ship.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index a18616e..0bc1b7c 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -38,6 +38,9 @@ Ship::Ship(core::Player *owner, const ShipModel *shipmodel) : core::EntityContro
ship_jumpdrive_timer = 0;
ship_jumpdepart = 0;
+ ship_dock = 0;
+ ship_spawn = 0;
+
current_impulse = false;
// apply ship type settings
@@ -289,6 +292,54 @@ void Ship::set_zone(core::Zone *zone)
owner()->set_zone(zone);
}
+void Ship::set_state(int state)
+{
+ EntityControlable::set_state(state);
+
+ if (state != core::Entity::Docked)
+ ship_dock = 0;
+}
+void Ship::set_dock(core::Entity *dock)
+{
+ if (!dock)
+ return;
+
+ ship_dock = dock;
+ get_location().assign(dock->location());
+ get_axis().assign(dock->axis());
+ set_state(core::Entity::Docked);
+
+ // if the dock is not owned by a player. set it as spawn
+ const core::Player *owner = (dock->type() == core::Entity::Controlable ? static_cast<core::EntityControlable *>(dock)->owner() : 0 );
+ if (!owner)
+ set_spawn(dock);
+ reset();
+}
+
+void Ship::launch()
+{
+ if (!ship_dock)
+ return;
+
+ get_axis().assign(ship_dock->axis());
+
+ if (ship_dock->type() == core::Entity::Globe)
+ get_location().assign(ship_dock->location() + (ship_dock->axis().forward() * (planet_safe_distance + this->radius() + ship_dock->radius())));
+ else
+ get_location().assign(ship_dock->location() + (ship_dock->axis().forward() * (this->radius() + ship_dock->radius())));
+
+ set_state(core::Entity::Normal);
+
+ ship_dock = 0;
+
+ reset();
+}
+
+void Ship::set_spawn(core::Entity *spawn)
+{
+ ship_spawn = spawn;
+}
+
void Ship::action (btScalar seconds)
{
//float maxspeed = 0;