Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/base/game.cc41
-rw-r--r--src/game/base/planet.cc23
-rw-r--r--src/game/base/planet.h6
-rw-r--r--src/game/base/station.cc22
-rw-r--r--src/game/base/station.h3
5 files changed, 38 insertions, 57 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index c0ef4ce..a075574 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -37,6 +37,8 @@ core::Entity *Default::view = 0;
ShipModel *Default::shipmodel = 0;
long Default::credits = 0;
+const float planet_safe_distance = 150.0f;
+
void Default::clear()
{
zone = 0;
@@ -74,9 +76,11 @@ void Game::func_join(core::Player *player, std::string const &args)
ship->get_location().assign(dock->location() + (dock->axis().forward() *((ship->radius() + dock->radius())*2.0f)));
ship->get_axis().assign(dock->axis());
ship->set_state(core::Entity::Docked);
+ ship->reset();
player->set_view(dock);
}
-
+
+
std::string message("^B");
message.append(player->name());
message.append("^B joins the game.");
@@ -177,8 +181,34 @@ void Game::func_dock(core::Player *player, core::Entity *entity)
if (player->control()->state() != core::Entity::Normal)
return;
- if ((entity->flags() & core::Entity::Dockable) == core::Entity::Dockable) {
- entity->dock(player->control());
+ if (player->control()->moduletype() != ship_enttype)
+ return;
+
+ if (!(entity->flags() & core::Entity::Dockable)) {
+ return;
+ }
+
+ Ship * ship = static_cast<Ship *>(player->control());
+
+ float range = entity->radius() + ship->radius();
+ if (entity->moduletype() == planet_enttype) {
+ range = planet_safe_distance;
+ }
+
+ if (math::distance(entity->location(), ship->location()) > range) {
+ if (ship->owner()) {
+ ship->owner()->send("^W" + entity->name() + " out of range");
+ }
+ return;
+ }
+
+ ship->get_location().assign(entity->location());
+ ship->set_state(core::Entity::Docked);
+ ship->reset();
+
+ if (ship->owner() && ship->owner()->control() == ship) {
+ ship->owner()->set_view(entity);
+ ship->owner()->send("^BDocking at " + entity->name());
}
}
@@ -1170,6 +1200,11 @@ bool Game::validate_zone(core::Zone *zone)
generate_entity_menus(entity);
}
}
+
+ // initialize physics on planets and entities with a model
+ if ((entity->entity_moduletypeid == planet_enttype) || (entity->model())) {
+ entity->reset();
+ }
}
return true;
diff --git a/src/game/base/planet.cc b/src/game/base/planet.cc
index 7a648db..1e280c7 100644
--- a/src/game/base/planet.cc
+++ b/src/game/base/planet.cc
@@ -30,27 +30,4 @@ Planet::~Planet()
}
-void Planet::dock(core::Entity *entity)
-{
- if (entity->moduletype() != ship_enttype)
- return;
-
- Ship * ship = static_cast<Ship *>(entity);
-
- // fixed 5 km docking radius
- if (math::distance(location(), ship->location()) > radius() + ship->radius() + 50.0f) {
- if (ship->owner())
- ship->owner()->send("Planet out of range");
- return;
- }
-
- ship->get_location().assign(location());
- ship->set_state(core::Entity::Docked);
-
- if (ship->owner() && ship->owner()->control() == ship) {
- ship->owner()->set_view(this);
- ship->owner()->send("^BDocking at " + name());
- }
-}
-
} // namespace game
diff --git a/src/game/base/planet.h b/src/game/base/planet.h
index d2b18a8..19db012 100644
--- a/src/game/base/planet.h
+++ b/src/game/base/planet.h
@@ -21,14 +21,8 @@ class Planet : public core::EntityGlobe
public:
Planet();
virtual ~Planet();
-
- /// entity received a docking request
- virtual void dock(core::Entity *entity);
};
-/// FIXME
-const float planet_safe_distance = 5.0f;
-
} // namespace game
#endif // __INCLUDED_BASE_PLANET_H__
diff --git a/src/game/base/station.cc b/src/game/base/station.cc
index f5dc50a..0d992bd 100644
--- a/src/game/base/station.cc
+++ b/src/game/base/station.cc
@@ -22,26 +22,4 @@ Station::~Station()
{
}
-void Station::dock(core::Entity *entity)
-{
- if (entity->moduletype() != ship_enttype)
- return;
-
- Ship * ship = static_cast<Ship *>(entity);
-
- if (math::distance(location(), ship->location()) > radius() + ship->radius()) {
- if (ship->owner())
- ship->owner()->send("Target out of range");
- return;
- }
-
- ship->get_location().assign(location());
- ship->set_state(core::Entity::Docked);
-
- if (ship->owner() && ship->owner()->control() == ship) {
- ship->owner()->set_view(this);
- ship->owner()->send("^BDocking at " + name());
- }
-}
-
}
diff --git a/src/game/base/station.h b/src/game/base/station.h
index 3f8bea6..2aa8a95 100644
--- a/src/game/base/station.h
+++ b/src/game/base/station.h
@@ -15,9 +15,6 @@ class Station : public core::Entity
public:
Station();
virtual ~Station();
-
- /// entity received a docking request
- virtual void dock(core::Entity *entity);
};
}