Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/base/game.cc')
-rw-r--r--src/game/base/game.cc53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index 4128af8..441e080 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -52,7 +52,6 @@ core::Cvar *Game::g_impulsespeed = 0;
core::Cvar *Game::g_impulseacceleration = 0;
core::Cvar *Game::g_jumppointrange = 0;
core::Cvar *Game::g_devel = 0;
-core::Cvar *Game::g_collision = 0;
core::Module *factory()
{
@@ -235,10 +234,13 @@ void Game::func_launch(core::Player *player, std::string const &args)
assert(player->view()->zone() == player->control()->zone());
+ Ship *ship = static_cast<Ship *>(player->control());
+ ship->shutdown_physics();
core::Entity *dock = player->view();
- player->control()->entity_location.assign(dock->location() + (dock->axis().forward() * (player->control()->radius()+ dock->radius())*2.0f));
- player->control()->entity_axis.assign(dock->axis());
- player->control()->set_state(core::Entity::Normal);
+ ship->entity_location.assign(dock->location() + (dock->axis().forward() * (player->control()->radius()+ dock->radius())));
+ ship->entity_axis.assign(dock->axis());
+ ship->set_state(core::Entity::Normal);
+ ship->init_physics(ship->radius());
player->set_view(0);
player->send("^BLaunching from " + dock->name());
@@ -259,7 +261,7 @@ void Game::func_respawn(core::Player *player, std::string const &args)
player->control()->set_zone(Default::zone);
core::Entity *dock = player->control()->zone()->default_view();
if (dock) {
- player->control()->entity_location.assign(dock->location() + (dock->axis().forward() * ((player->control()->radius()+ dock->radius())*2.0f)));
+ player->control()->entity_location.assign(dock->location() + (dock->axis().forward() * ((player->control()->radius()+ dock->radius()))));
player->control()->entity_axis.assign(dock->axis());
player->control()->set_state(core::Entity::Docked);
player->set_view(dock);
@@ -289,11 +291,18 @@ void Game::func_goto(core::Player *player, const std::string &args)
return;
core::Entity *dock = player->control()->zone()->search_entity(args);
+ Ship *ship = static_cast<Ship *>(player->control());
+
if (dock) {
- player->control()->entity_location.assign(dock->location() + (dock->axis().forward() * (player->control()->radius()+dock->radius())*2.0f));
- player->control()->entity_axis.assign(dock->axis());
- player->control()->entity_axis.change_direction(180.0f);
- player->control()->set_state(core::Entity::Normal);
+ ship->shutdown_physics();
+
+ ship->entity_location.assign(dock->location() + (dock->axis().forward() * (ship->radius()+dock->radius())));
+ ship->entity_axis.assign(dock->axis());
+ ship->entity_axis.change_direction(180.0f);
+ ship->set_state(core::Entity::Normal);
+
+ ship->init_physics(ship->radius());
+
player->set_view(0);
player->send("Going to " + dock->name());
} else {
@@ -307,6 +316,8 @@ Game::Game() : core::Module("Project::OSiRiON", true)
{
Default::clear();
ShipModel::clear();
+
+ Physics::init();
if (!load_ships()) {
abort();
@@ -371,9 +382,6 @@ Game::Game() : core::Module("Project::OSiRiON", true)
g_devel = core::Cvar::get("g_devel", "0", core::Cvar::Archive);
g_devel->set_info("[bool] enable or disable developer mode");
-
- g_collision = core::Cvar::get("g_collision", "0", core::Cvar::Archive);
- g_collision->set_info("[bool] enable or disable collision detection");
}
Game::~Game()
@@ -384,7 +392,12 @@ Game::~Game()
// remove engine core functions
core::Func::remove("list_ship");
+ // we explicity clear game data to prevent bullet from beeing confused
+ core::game()->clear();
+
ShipModel::clear();
+
+ Physics::shutdown();
}
bool Game::load_world()
@@ -401,7 +414,7 @@ bool Game::load_world()
con_print << "^BLoading world..." << std::endl;
- core::Zone *zone = 0;
+ PhysicsZone *zone = 0;
std::string label;
while (worldini.getline()) {
@@ -420,7 +433,7 @@ bool Game::load_world()
if (worldini.got_key_string("zone", label)) {
aux::to_label(label);
- zone = new core::Zone(label);
+ zone = new PhysicsZone(label);
core::Zone::add(zone);
} else {
worldini.unkown_key();
@@ -668,7 +681,13 @@ bool Game::validate_zone(core::Zone *zone)
// validate jump gate
JumpGate *jumpgate = static_cast<JumpGate *>(entity);
jumpgate->validate();
+
} else {
+ if (entity->entity_moduletypeid == station_enttype) {
+ Station *station = static_cast<Station *>(entity);
+ station->init_physics(0.0f);
+ }
+
if ((entity->flags() & core::Entity::Dockable) == core::Entity::Dockable)
load_menus(entity, "zones/" + zone->label() + "/" + entity->label());
}
@@ -929,11 +948,7 @@ void Game::frame(float seconds)
if (!running())
return;
- // TODO check Module::frame() is execute before are Entity::frame()
-
- // collision
- if (g_collision->value())
- Collision::frame(seconds);
+ Physics::frame(seconds);
}
void Game::player_connect(core::Player *player)