From 818566a1806f7b51ed8a8ecf1fb9abe0757f610e Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 15 Aug 2009 14:06:30 +0000 Subject: planet safe distance for launch and goto --- src/game/base/collision.cc | 3 ++- src/game/base/game.cc | 21 +++++++++++++++++---- src/game/base/game.h | 4 ---- src/game/base/planet.h | 2 ++ 4 files changed, 21 insertions(+), 9 deletions(-) (limited to 'src/game') diff --git a/src/game/base/collision.cc b/src/game/base/collision.cc index 215764c..4e6f4bb 100644 --- a/src/game/base/collision.cc +++ b/src/game/base/collision.cc @@ -6,6 +6,7 @@ #include "base/collision.h" #include "base/game.h" +#include "base/planet.h" #include "core/zone.h" #include "math/functions.h" #include "math/vector3f.h" @@ -39,7 +40,7 @@ void Collision::distance_test(core::EntityControlable *first, core::Entity *seco // warning zone: star corona or planet atmosphere if ((second->moduletype() == star_enttype) && (d-r < 50.0f)) { first->owner()->send_warning("^3Warning: entering star corona!^N"); - } else if ((second->moduletype() == planet_enttype) && (d-r < 15.0f)) { + } else if ((second->moduletype() == planet_enttype) && (d-r < Planet::safe_distance)) { first->owner()->send_warning("^3Warning: entering planet gravity well!^N"); } } diff --git a/src/game/base/game.cc b/src/game/base/game.cc index 35dfc5f..bcb3567 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -237,7 +237,12 @@ void Game::func_launch(core::Player *player, std::string const &args) Ship *ship = static_cast(player->control()); ship->shutdown_physics(); core::Entity *dock = player->view(); - ship->get_location().assign(dock->location() + (dock->axis().forward() * (ship->radius()+ dock->radius()))); + + if (dock->type() == core::Entity::Globe) + ship->get_location().assign(dock->location() + (dock->axis().forward() * (Planet::safe_distance + ship->radius() + dock->radius()))); + else + ship->get_location().assign(dock->location() + (dock->axis().forward() * (ship->radius() + dock->radius()))); + ship->get_axis().assign(dock->axis()); ship->set_state(core::Entity::Normal); ship->init_physics(ship->radius()); @@ -265,7 +270,7 @@ void Game::func_respawn(core::Player *player, std::string const &args) ship->shutdown_physics(); if (dock) { - ship->get_location().assign(dock->location() + (dock->axis().forward() * ((ship->radius()+ dock->radius())))); + ship->get_location().assign(dock->location()); ship->get_axis().assign(dock->axis()); ship->set_state(core::Entity::Docked); player->set_view(dock); @@ -303,7 +308,11 @@ void Game::func_goto(core::Player *player, const std::string &args) if (dock) { ship->shutdown_physics(); - ship->get_location().assign(dock->location() + (dock->axis().forward() * (ship->radius()+dock->radius()))); + if (dock->type() == core::Entity::Globe) + ship->get_location().assign(dock->location() + (dock->axis().forward() * (Planet::safe_distance + ship->radius() + dock->radius()))); + else + ship->get_location().assign(dock->location() + (dock->axis().forward() * (ship->radius() + dock->radius()))); + ship->get_axis().assign(dock->axis()); ship->get_axis().change_direction(180.0f); ship->set_state(core::Entity::Normal); @@ -953,10 +962,14 @@ bool Game::load_player() void Game::frame(float seconds) { - Physics::frame(seconds); +#ifdef HAVE_BULLET if (!running()) return; + + Physics::frame(seconds); +#endif + } void Game::player_connect(core::Player *player) diff --git a/src/game/base/game.h b/src/game/base/game.h index 7519970..9b2d377 100644 --- a/src/game/base/game.h +++ b/src/game/base/game.h @@ -73,10 +73,6 @@ public: /// game variable: enable or disable development mode static core::Cvar *g_devel; - - /// game variable: enable or disable collision - static core::Cvar *g_collision; - private: bool load_world(); diff --git a/src/game/base/planet.h b/src/game/base/planet.h index efc5332..c9bb214 100644 --- a/src/game/base/planet.h +++ b/src/game/base/planet.h @@ -28,6 +28,8 @@ public: /// entity received a docking request virtual void dock(core::Entity *entity); + static const float safe_distance = 5.0f; + private: ShipDealer *planet_shipdealer; -- cgit v1.2.3