From 0ecdd8bc98ba583bbee801b838d785c6f881d7df Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 9 Oct 2010 20:23:01 +0000 Subject: removed physics references, transfer inventory on ship aquisition --- src/game/base/game.cc | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'src/game/base/game.cc') diff --git a/src/game/base/game.cc b/src/game/base/game.cc index 7fc3eb5..19b3968 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -16,7 +16,6 @@ #include "filesystem/inifile.h" #include "base/game.h" #include "base/cargo.h" -#include "base/collision.h" #include "base/navpoint.h" #include "base/jumppoint.h" #include "base/planet.h" @@ -227,12 +226,25 @@ void Game::func_give(core::Player *player, const std::string &args) return; } + // check if there's enough space available to transfer inventory + if (shipmodel->maxcargo() < player->control()->inventory()->capacity_used()) { + player->send("^WNot enough cargo space to transfer inventory!"); + return; + } + Ship * ship = new Ship(player, shipmodel); core::Entity *view = player->view(); if (view && (view == player->control())) { view = ship; } + // transfer inventory + for (core::Inventory::Items::iterator it = player->control()->inventory()->items().begin(); + it != player->control()->inventory()->items().end(); it++) { + ship->inventory()->add(new core::Item(*(*it))); + } + ship->inventory()->set_dirty(); + // FIME move this into a method in the Ship class ship->set_zone(player->control()->zone()); ship->get_location().assign(player->control()->location()); @@ -465,7 +477,6 @@ void Game::func_launch(core::Player *player, std::string const &args) assert(player->control()->moduletype() == ship_enttype); Ship *ship = static_cast(player->control()); - ship->shutdown_physics(); if (dock->type() == core::Entity::Globe) ship->get_location().assign(dock->location() + (dock->axis().forward() *(planet_safe_distance + ship->radius() + dock->radius()))); @@ -474,7 +485,6 @@ void Game::func_launch(core::Player *player, std::string const &args) ship->get_axis().assign(dock->axis()); ship->set_state(core::Entity::Normal); - ship->init_physics(ship->radius()); ship->set_state(core::Entity::Jump); player->set_view(0); @@ -496,8 +506,6 @@ void Game::func_respawn(core::Player *player, std::string const &args) Ship *ship = static_cast(player->control()); core::Entity *dock = player->control()->zone()->default_view(); - ship->shutdown_physics(); - if (dock) { ship->get_location().assign(dock->location()); ship->get_axis().assign(dock->axis()); @@ -513,7 +521,6 @@ void Game::func_respawn(core::Player *player, std::string const &args) } ship->set_zone(Default::zone); - ship->init_physics(ship->radius()); } @@ -535,8 +542,6 @@ void Game::func_goto(core::Player *player, const std::string &args) Ship *ship = static_cast(player->control()); if (dock) { - ship->shutdown_physics(); - if (dock->type() == core::Entity::Globe) ship->get_location().assign(dock->location() + (dock->axis().forward() *(planet_safe_distance + ship->radius() + dock->radius()))); else @@ -546,7 +551,6 @@ void Game::func_goto(core::Player *player, const std::string &args) ship->get_axis().change_direction(180.0f); ship->set_state(core::Entity::Normal); - ship->init_physics(ship->radius()); ship->set_state(core::Entity::Jump); player->set_view(0); @@ -563,8 +567,6 @@ Game::Game() : core::Module("Project::OSiRiON", true) // reset default player values Default::clear(); - Physics::init(); - // read cargo.ini if (!Cargo::init()) { abort(); @@ -647,8 +649,6 @@ Game::~Game() // we explicity clear game data to prevent bullet from beeing confused core::game()->clear(); - - Physics::shutdown(); } bool Game::load_world() @@ -665,7 +665,7 @@ bool Game::load_world() con_print << "^BLoading world..." << std::endl; - PhysicsZone *zone = 0; + core::Zone *zone = 0; std::string label; while (worldini.getline()) { @@ -684,7 +684,7 @@ bool Game::load_world() if (worldini.got_key_string("zone", label)) { aux::to_label(label); - zone = new PhysicsZone(label); + zone = new core::Zone(label); core::Zone::add(zone); } else { worldini.unkown_key(); @@ -1040,11 +1040,6 @@ bool Game::validate_zone(core::Zone *zone) jumpgate->validate(); } else { - if (entity->entity_moduletypeid == station_enttype) { - Station *station = static_cast(entity); - station->init_physics(0.0f); - } - if ((entity->flags() & core::Entity::Dockable) == core::Entity::Dockable) { generate_entity_menus(entity); } @@ -1211,13 +1206,8 @@ bool Game::load_player() void Game::frame(float seconds) { -#ifdef HAVE_BULLET if (!running()) return; - - Physics::frame(seconds); -#endif - } void Game::player_connect(core::Player *player) -- cgit v1.2.3