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>2012-10-13 15:39:23 +0000
committerStijn Buys <ingar@osirion.org>2012-10-13 15:39:23 +0000
commit1883c2ea6cb3dd4ba5f26af31a0ad481d524dfef (patch)
tree277ba1ceb22cdf8615d1631c51abc2130a90ba87 /src/game
parent5dea1a263136c4cbe011de3325605dd3dc4523af (diff)
Corrected bugs in the respawn command, detect ship collisions with planets and stars.
Diffstat (limited to 'src/game')
-rw-r--r--src/game/base/game.cc30
-rw-r--r--src/game/base/ship.cc38
-rw-r--r--src/game/base/ship.h2
3 files changed, 55 insertions, 15 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index a79f5cc..b19ec52 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -835,30 +835,30 @@ void Game::func_launch(core::Player *player, std::string const &args)
// respawn
void Game::func_respawn(core::Player *player, std::string const &args)
{
- if (!player->control()) {
+ Ship *ship = static_cast<Ship *>(player->control());
+
+ if (!ship) {
func_join(player, args);
return;
}
- if (!(player->view() == player->control()))
- return;
-
- if (player->control()->state() != core::Entity::Destroyed)
+ if (ship->state() != core::Entity::Destroyed) {
return;
+ }
- Ship *ship = static_cast<Ship *>(player->control());
- core::Entity *dock = player->control()->zone()->default_view();
+ core::Entity *spawn = ship->spawn();
+ if (!spawn) {
+ spawn = player->control()->zone()->default_view();
+ }
- if (dock) {
- ship->get_location().assign(dock->location());
- ship->get_axis().assign(dock->axis());
- ship->set_state(core::Entity::Docked);
- player->set_view(dock);
- player->send("^BRespawning at " + dock->name());
+ if (spawn && spawn->has_flag(core::Entity::Dockable)) {
+ ship->set_dock(spawn);
+ player->set_view(spawn);
+ player->send("^BRespawning at " + spawn->name());
} else {
ship->get_location().clear();
ship->get_axis().clear();
- ship->set_state(core::Entity::Jump);
+ ship->set_state(core::Entity::Normal);
player->set_view(0);
player->send("^BRespawning");
}
@@ -1588,7 +1588,7 @@ bool Game::validate_zone(core::Zone *zone)
}
// initialize physics on planets and entities with a model
- if ((entity->entity_moduletypeid == planet_enttype) || (entity->model())) {
+ if ((entity->entity_moduletypeid == star_enttype) ||(entity->entity_moduletypeid == planet_enttype) || (entity->model())) {
entity->reset();
}
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 4efba27..9874337 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -419,6 +419,44 @@ void Ship::action (btScalar seconds)
}
}
+void Ship::collision(core::Entity *other)
+{
+ if (state() == core::Entity::Destroyed) {
+ return;
+ }
+
+ if (state() == core::Entity::Docked) {
+ return;
+ }
+
+ // do not fly into planets
+ if (other->moduletype() == planet_enttype) {
+ explode();
+
+ if (owner()) {
+ std::string message("^B");
+ message.append(owner()->name());
+ message.append(" ^Bran into ");
+ message.append(other->name());
+ message.append(".");
+ core::server()->broadcast(message);
+ } else {
+ die();
+ }
+ } else if (other->moduletype() == star_enttype) {
+ explode();
+
+ if (owner()) {
+ std::string message("^B");
+ message.append(owner()->name());
+ message.append(" ^Bcould not resist the light.");
+ core::server()->broadcast(message);
+ } else {
+ die();
+ }
+ }
+}
+
void Ship::frame(const unsigned long elapsed)
{
//const float direction_reaction = 2.0f; // directional control reaction time
diff --git a/src/game/base/ship.h b/src/game/base/ship.h
index 230d406..2670ee2 100644
--- a/src/game/base/ship.h
+++ b/src/game/base/ship.h
@@ -117,6 +117,8 @@ public:
/// reset physics state and ship controls
virtual void reset();
+
+ virtual void collision(Entity *other);
/// explode the ship
void explode();