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')
-rw-r--r--src/game/base/collision.cc16
-rw-r--r--src/game/base/collision.h12
-rw-r--r--src/game/base/game.cc86
-rw-r--r--src/game/base/game.h14
-rw-r--r--src/game/base/jumppoint.cc14
-rw-r--r--src/game/base/jumppoint.h25
-rw-r--r--src/game/base/navpoint.cc4
-rw-r--r--src/game/base/navpoint.h10
-rw-r--r--src/game/base/physics.cc45
-rw-r--r--src/game/base/physics.h55
-rw-r--r--src/game/base/planet.cc7
-rw-r--r--src/game/base/planet.h14
-rw-r--r--src/game/base/racetrack.cc19
-rw-r--r--src/game/base/racetrack.h21
-rw-r--r--src/game/base/ship.cc75
-rw-r--r--src/game/base/ship.h13
-rw-r--r--src/game/base/shipdealer.cc19
-rw-r--r--src/game/base/shipdealer.h15
-rw-r--r--src/game/base/shipmodel.cc43
-rw-r--r--src/game/base/shipmodel.h63
-rw-r--r--src/game/base/star.cc3
-rw-r--r--src/game/base/star.h10
-rw-r--r--src/game/base/station.cc9
-rw-r--r--src/game/base/station.h11
24 files changed, 347 insertions, 256 deletions
diff --git a/src/game/base/collision.cc b/src/game/base/collision.cc
index 4e6f4bb..952bba2 100644
--- a/src/game/base/collision.cc
+++ b/src/game/base/collision.cc
@@ -18,18 +18,18 @@ void Collision::distance_test(core::EntityControlable *first, core::Entity *seco
{
if (!first->owner())
return;
-
+
if (first->state() == core::Entity::Docked)
return;
-
+
// FIXME - use distancesquared
const float d = math::distance(first->location(), second->location());
const float r = first->radius() + second->radius();
-
+
if (second->type() == core::Entity::Globe) {
// collision with a star or a planet
-
- if ((d-r) < 0.0f) {
+
+ if ((d - r) < 0.0f) {
// crash zone
if ((first->moduletype() == ship_enttype) && (first->state() != core::Entity::Destroyed)) {
first->owner()->send_warning("^RBOOM!^N");
@@ -38,9 +38,9 @@ void Collision::distance_test(core::EntityControlable *first, core::Entity *seco
}
} else if (first->owner()->last_warning() + 5.0f < core::application()->time()) {
// warning zone: star corona or planet atmosphere
- if ((second->moduletype() == star_enttype) && (d-r < 50.0f)) {
+ 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 < Planet::safe_distance)) {
+ } else if ((second->moduletype() == planet_enttype) && (d - r < Planet::safe_distance)) {
first->owner()->send_warning("^3Warning: entering planet gravity well!^N");
}
}
@@ -51,7 +51,7 @@ void Collision::frame_zone(core::Zone *zone)
{
core::Zone::Content::iterator first;
core::Zone::Content::iterator second;
-
+
for (first = zone->content().begin(); first != zone->content().end(); first ++) {
second = first;
for (second++; second != zone->content().end(); second++) {
diff --git a/src/game/base/collision.h b/src/game/base/collision.h
index 8203669..d74e6d6 100644
--- a/src/game/base/collision.h
+++ b/src/game/base/collision.h
@@ -1,7 +1,7 @@
/*
base/collision.h
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#ifndef __INCLUDED_BASE_COLLISION_H__
@@ -9,10 +9,12 @@
#include "core/zone.h"
-namespace game {
+namespace game
+{
/// collision detection functions
-class Collision {
+class Collision
+{
public:
/// do collision detection
static void frame(const float elapsed);
@@ -20,7 +22,7 @@ public:
private:
/// do collision detection for a single zone
static void frame_zone(core::Zone *zone);
-
+
/// do a distance test between two entities
static void distance_test(core::EntityControlable *first, core::Entity *second);
};
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index bcb3567..7ec54b3 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -82,12 +82,12 @@ void Game::func_join(core::Player *player, std::string const &args)
core::Entity *dock = ship->zone()->default_view();
if (dock) {
- ship->get_location().assign(dock->location() + (dock->axis().forward() * ((ship->radius()+ dock->radius())*2.0f)));
+ 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);
player->set_view(dock);
}
-
+
std::string message("^B");
message.append(player->name());
message.append("^B joins the game.");
@@ -233,15 +233,15 @@ void Game::func_launch(core::Player *player, std::string const &args)
return;
assert(player->view()->zone() == player->control()->zone());
-
+
Ship *ship = static_cast<Ship *>(player->control());
ship->shutdown_physics();
core::Entity *dock = player->view();
if (dock->type() == core::Entity::Globe)
- ship->get_location().assign(dock->location() + (dock->axis().forward() * (Planet::safe_distance + ship->radius() + dock->radius())));
+ 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_location().assign(dock->location() + (dock->axis().forward() *(ship->radius() + dock->radius())));
ship->get_axis().assign(dock->axis());
ship->set_state(core::Entity::Normal);
@@ -309,9 +309,9 @@ void Game::func_goto(core::Player *player, const std::string &args)
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())));
+ 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_location().assign(dock->location() + (dock->axis().forward() *(ship->radius() + dock->radius())));
ship->get_axis().assign(dock->axis());
ship->get_axis().change_direction(180.0f);
@@ -319,7 +319,7 @@ void Game::func_goto(core::Player *player, const std::string &args)
ship->init_physics(ship->radius());
ship->set_state(core::Entity::Jump);
-
+
player->set_view(0);
player->send("Going to " + dock->name());
} else {
@@ -333,7 +333,7 @@ Game::Game() : core::Module("Project::OSiRiON", true)
{
Default::clear();
ShipModel::clear();
-
+
Physics::init();
if (!load_ships()) {
@@ -350,13 +350,13 @@ Game::Game() : core::Module("Project::OSiRiON", true)
abort();
return;
}
-
+
// add engine functions
core::Func *func = 0;
func = core::Func::add("list_ship", Game::func_list_ship);
func->set_info("[string] list ship statistics");
-
+
func = core::Func::add("join", Game::func_join);
func->set_info("join the game");
@@ -445,7 +445,7 @@ bool Game::load_world()
}
} else if (worldini.got_key()) {
-
+
if (worldini.in_section("world")) {
if (worldini.got_key_string("zone", label)) {
@@ -521,20 +521,20 @@ bool Game::load_zone(core::Zone *zone)
while (zoneini.getline()) {
- if (zoneini.got_section()) {
+ if (zoneini.got_section()) {
if (zoneini.got_section("zone")) {
continue;
-
+
} else if (zoneini.got_section("star")) {
star = new Star();
star->set_zone(zone);
count ++;
-
+
} else if (zoneini.got_section("navpoint")) {
navpoint = new NavPoint();
navpoint->set_zone(zone);
count ++;
-
+
} else if (zoneini.got_section("jumpgate")) {
jumppoint = new JumpGate();
jumppoint->set_zone(zone);
@@ -544,17 +544,17 @@ bool Game::load_zone(core::Zone *zone)
jumppoint = new JumpPoint();
jumppoint->set_zone(zone);
count ++;
-
- } else if(zoneini.got_section("racetrack")) {
+
+ } else if (zoneini.got_section("racetrack")) {
racetrack = new RaceTrack();
racetrack->set_zone(zone);
-
- } else if(zoneini.got_section("checkpoint")) {
+
+ } else if (zoneini.got_section("checkpoint")) {
checkpoint = new CheckPoint(racetrack);
if (!racetrack) {
con_warn << zoneini.name() << " checkpoint without racetrack at line " << zoneini.line() << std::endl;
}
-
+
} else if (zoneini.got_section("planet")) {
planet = new Planet();
planet->set_zone(zone);
@@ -564,13 +564,13 @@ bool Game::load_zone(core::Zone *zone)
station = new Station();
station->set_zone(zone);
count ++;
-
+
} else if (zoneini.got_section("entity")) {
entity = new core::Entity();
entity->set_flag(core::Entity::Static);
entity->set_zone(zone);
count ++;
-
+
} else {
zoneini.unknown_section();
}
@@ -593,7 +593,7 @@ bool Game::load_zone(core::Zone *zone)
if (core::Parser::got_entity_key(zoneini, star)) {
continue;
} else if (zoneini.got_key_string("texture", star->entity_texture)) {
- continue;
+ continue;
} else {
zoneini.unkown_key();
}
@@ -619,12 +619,12 @@ bool Game::load_zone(core::Zone *zone)
if (core::Parser::got_entity_key(zoneini, planet)) {
continue;
} else if (zoneini.got_key_string("texture", planet->entity_texture)) {
- continue;
+ continue;
} else if (zoneini.got_key_float("rotationspeed", planet->entity_rotationspeed)) {
continue;
} else if (zoneini.got_key_bool("dock", b)) {
if (b) {
- planet->set_flag(core::Entity::Dockable);
+ planet->set_flag(core::Entity::Dockable);
} else {
planet->unset_flag(core::Entity::Dockable);
}
@@ -636,7 +636,7 @@ bool Game::load_zone(core::Zone *zone)
} else {
zoneini.unkown_key();
}
-
+
} else if (zoneini.in_section("station")) {
if (core::Parser::got_entity_key(zoneini, station)) {
continue;
@@ -673,7 +673,7 @@ bool Game::load_zone(core::Zone *zone)
zoneini.unkown_key();
}
}
-
+
}
}
zoneini.close();
@@ -707,7 +707,7 @@ bool Game::validate_zone(core::Zone *zone)
if ((entity->flags() & core::Entity::Dockable) == core::Entity::Dockable)
load_menus(entity, "zones/" + zone->label() + "/" + entity->label());
- }
+ }
}
return true;
@@ -733,7 +733,7 @@ bool Game::load_menus(core::Entity *entity, const std::string &menufilename)
if (inifile.is_open()) {
while (inifile.getline()) {
-
+
if (inifile.got_section()) {
if (inifile.got_section("dealer")) {
// dealer menu
@@ -741,22 +741,22 @@ bool Game::load_menus(core::Entity *entity, const std::string &menufilename)
menu_dealer = new MenuDescription();
menu_dealer->set_label("dealer");
menu_dealer->set_text("Ship dealer");
-
+
shipdealer = new ShipDealer();
if (entity->moduletype() == planet_enttype) {
static_cast<Planet *>(entity)->set_shipdealer(shipdealer);
} else if (entity->moduletype() == station_enttype) {
static_cast<Station *>(entity)->set_shipdealer(shipdealer);
}
- }
+ }
} else {
inifile.unknown_section();
}
-
+
} else if (inifile.got_key()) {
-
+
if (inifile.in_section("dealer")) {
-
+
if (inifile.got_key_string("ship", strval)) {
aux::to_label(strval);
ShipModel *model = shipdealer->add(strval);
@@ -771,7 +771,7 @@ bool Game::load_menus(core::Entity *entity, const std::string &menufilename)
} else {
inifile.unkown_key();
}
-
+
}
}
}
@@ -805,12 +805,12 @@ bool Game::load_menus(core::Entity *entity, const std::string &menufilename)
menu_main->add_button(button);
}
- if (inifile.is_open()) {
+ if (inifile.is_open()) {
size_t n = entity->menus().size();
con_debug << " " << inifile.name() << " " << n << " " << aux::plural("menu", n) << std::endl;
inifile.close();
}
-
+
return true;
}
@@ -841,8 +841,8 @@ bool Game::load_ships()
shipmodel->shipmodel_label.assign(label);
ShipModel::add(shipmodel);
continue;
- } else if (shipsini.got_key_string("name",shipmodel->shipmodel_name)) {
- continue;
+ } else if (shipsini.got_key_string("name", shipmodel->shipmodel_name)) {
+ continue;
} else if (shipsini.got_key_string("info", infostr)) {
shipmodel->shipmodel_infotext.push_back(infostr);
continue;
@@ -856,7 +856,7 @@ bool Game::load_ships()
continue;
} else if (shipsini.got_key_bool("jumpdrive", shipmodel->shipmodel_jumpdrive)) {
continue;
- } else if (shipsini.got_key_float("acceleration",f)) {
+ } else if (shipsini.got_key_float("acceleration", f)) {
shipmodel->set_acceleration(f);
continue;
} else if (shipsini.got_key_float("maxspeed", f)) {
@@ -874,7 +874,7 @@ bool Game::load_ships()
if (shipmodel && !ShipModel::find(shipmodel)) delete shipmodel;
shipmodel = new ShipModel();
if (!Default::shipmodel)
- Default::shipmodel = shipmodel;
+ Default::shipmodel = shipmodel;
} else if (shipsini.got_section()) {
shipsini.unknown_section();
@@ -934,7 +934,7 @@ bool Game::load_player()
aux::to_label(str);
Default::shipmodel = ShipModel::find(str);
}
- }
+ }
}
}
diff --git a/src/game/base/game.h b/src/game/base/game.h
index 9b2d377..65084d3 100644
--- a/src/game/base/game.h
+++ b/src/game/base/game.h
@@ -1,7 +1,7 @@
/*
base/game.h
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
*/
#ifndef __INCLUDED_BASE_H__
@@ -35,7 +35,8 @@ const unsigned int jumpgate_enttype = 261;
const unsigned int station_enttype = 262;
/// default player settings
-class Default {
+class Default
+{
public:
static core::Zone *zone;
static core::Entity *view;
@@ -46,7 +47,8 @@ public:
};
/// the base Project::OSiRiON game model
-class Game : public core::Module {
+class Game : public core::Module
+{
public:
Game();
virtual ~Game();
@@ -84,7 +86,7 @@ private:
bool load_menus(core::Entity *entity, const std::string &menufilename);
bool load_ships();
-
+
bool load_player();
/* ---- engine functions ----------------------------------- */
@@ -95,7 +97,7 @@ private:
static void func_hail(core::Player *player, std::string const &args);
static void func_jump(core::Player *player, std::string const &args);
static void func_impulse(core::Player *player, std::string const &args);
- static void func_dock(core::Player *player,core::Entity *entity);
+ static void func_dock(core::Player *player, core::Entity *entity);
static void func_launch(core::Player *player, std::string const &args);
static void func_respawn(core::Player *player, std::string const &args);
static void func_goto(core::Player *player, const std::string &args);
diff --git a/src/game/base/jumppoint.cc b/src/game/base/jumppoint.cc
index 9017f1c..5b4e689 100644
--- a/src/game/base/jumppoint.cc
+++ b/src/game/base/jumppoint.cc
@@ -1,7 +1,7 @@
/*
base/jumppoint.cc
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#include "base/game.h"
@@ -28,7 +28,7 @@ JumpPoint::~JumpPoint()
{
}
-void JumpPoint::set_targetlabel(const std::string &label)
+void JumpPoint::set_targetlabel(const std::string &label)
{
jumppoint_targetlabel.assign(label);
}
@@ -42,13 +42,13 @@ void JumpPoint::validate()
return;
}
size_t pos = targetlabel().find(':');
- if ((pos < 1 ) || (pos >= (targetlabel().size()-1))) {
+ if ((pos < 1) || (pos >= (targetlabel().size() - 1))) {
con_warn << " Jumppoint with invalid target label '" << targetlabel() << "'\n";
return;
}
std::string zonelabel(targetlabel().substr(0, pos));
- std::string entitylabel(targetlabel().substr(pos+1, targetlabel().size()-pos));
+ std::string entitylabel(targetlabel().substr(pos + 1, targetlabel().size() - pos));
core::Zone *targetzone = core::Zone::find(zonelabel);
if (!targetzone) {
@@ -68,7 +68,7 @@ void JumpPoint::validate()
}
jumppoint_target = static_cast<JumpPoint *>(targetentity);
-
+
//con_debug << " Jumppoint " << zone->label() << ":" << label() << " with target " << targetlabel() << std::endl;
}
@@ -132,7 +132,7 @@ void JumpGate::dock(core::Entity *entity)
if (ship->owner())
ship->owner()->send("Jumpgate inactive");
return;
- }
+ }
}
void JumpGate::activate()
diff --git a/src/game/base/jumppoint.h b/src/game/base/jumppoint.h
index 900f1f3..fe29727 100644
--- a/src/game/base/jumppoint.h
+++ b/src/game/base/jumppoint.h
@@ -1,7 +1,7 @@
/*
base/jumppoint.h
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#ifndef __INCLUDED_BASE_JUMPPOINT_H__
@@ -12,7 +12,8 @@
#include <string>
-namespace game {
+namespace game
+{
/// a jumppoint
/**
@@ -21,14 +22,19 @@ namespace game {
* between the current system and the target of the nearest jumppoint.
*
*/
-class JumpPoint : public core::EntityDynamic {
+class JumpPoint : public core::EntityDynamic
+{
public:
JumpPoint();
virtual ~JumpPoint();
- inline std::string const & targetlabel() { return jumppoint_targetlabel; }
+ inline std::string const & targetlabel() {
+ return jumppoint_targetlabel;
+ }
- inline JumpPoint *target() { return jumppoint_target; }
+ inline JumpPoint *target() {
+ return jumppoint_target;
+ }
/// set trget label
void set_targetlabel(const std::string &label);
@@ -42,7 +48,8 @@ private:
};
/// a jumpgate
-class JumpGate : public JumpPoint {
+class JumpGate : public JumpPoint
+{
public:
JumpGate();
virtual ~JumpGate();
@@ -53,7 +60,9 @@ public:
/// entity received a docking request
virtual void dock(core::Entity *entity);
- inline bool activated() const { return (jumpgate_timer > 0); }
+ inline bool activated() const {
+ return (jumpgate_timer > 0);
+ }
void activate();
diff --git a/src/game/base/navpoint.cc b/src/game/base/navpoint.cc
index 7b48ee7..78f1ae0 100644
--- a/src/game/base/navpoint.cc
+++ b/src/game/base/navpoint.cc
@@ -1,7 +1,7 @@
/*
base/navpoint.cc
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#include "base/navpoint.h"
diff --git a/src/game/base/navpoint.h b/src/game/base/navpoint.h
index c2fb1d6..bb2420e 100644
--- a/src/game/base/navpoint.h
+++ b/src/game/base/navpoint.h
@@ -1,7 +1,7 @@
/*
base/navpoint.h
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#ifndef __INCLUDED_BASE_NAVPOINT_H__
@@ -12,10 +12,12 @@
#include <string>
-namespace game {
+namespace game
+{
/// a navigation point
-class NavPoint : public core::Entity {
+class NavPoint : public core::Entity
+{
public:
NavPoint();
~NavPoint();
diff --git a/src/game/base/physics.cc b/src/game/base/physics.cc
index b76e0c1..3cc7427 100644
--- a/src/game/base/physics.cc
+++ b/src/game/base/physics.cc
@@ -49,12 +49,12 @@ CollisionShape::CollisionShape(model::Model *model, const bool moving)
if (group->type() == model::FragmentGroup::None) {
// for each fragment
- for (model::FragmentGroup::iterator fit = group->begin(); fit != group->end(); fit++) {
+ for (model::FragmentGroup::iterator fit = group->begin(); fit != group->end(); fit++) {
model::Fragment *fragment = (*fit);
- const size_t index = fragment->index();
- const size_t triangle_count = (fragment->structural_size() + fragment->detail_size()) / 3;
-
+ const size_t index = fragment->index();
+ const size_t triangle_count = (fragment->structural_size() + fragment->detail_size()) / 3;
+
// load vertices from the global VertexArray into the bullet shape
for (size_t i = 0; i < triangle_count; i++) {
float *f = vertexarray->vertex() + index + (i * 9);
@@ -81,8 +81,8 @@ CollisionShape::CollisionShape(model::Model *model, const bool moving)
static_shape = new btBvhTriangleMeshShape(shape_mesh, true, false);
shape_bulletshape = static_shape;
}
-
-
+
+
con_debug << " collision data for " << model->name() << ": " << count << " tris " << std::endl;
#endif
}
@@ -136,10 +136,10 @@ void Physics::init()
{
con_print << "^BInitializing bullet physics..." << std::endl;
- configuration = new btDefaultCollisionConfiguration();
+ configuration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(configuration);
solver = new btSequentialImpulseConstraintSolver;
-
+
}
void Physics::frame(const float seconds)
@@ -183,12 +183,12 @@ void Physics::shutdown()
PhysicsZone::PhysicsZone(const std::string &label) : core::Zone(label)
{
#ifdef HAVE_BULLET
- btVector3 worldAabbMin(-10000,-10000,-10000);
- btVector3 worldAabbMax(10000,10000,10000);
+ btVector3 worldAabbMin(-10000, -10000, -10000);
+ btVector3 worldAabbMax(10000, 10000, 10000);
const int maxProxies = 1024;
-
- zone_cache = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
- zone_dynamics_world = new btDiscreteDynamicsWorld(Physics::dispatcher, zone_cache, Physics::solver,Physics::configuration);
+
+ zone_cache = new btAxisSweep3(worldAabbMin, worldAabbMax, maxProxies);
+ zone_dynamics_world = new btDiscreteDynamicsWorld(Physics::dispatcher, zone_cache, Physics::solver, Physics::configuration);
// disable gravity
zone_dynamics_world->setGravity(btVector3(0.0f, 0.0f, 0.0f));
@@ -222,7 +222,7 @@ PhysicsBody::PhysicsBody(core::Entity *entity)
#endif
}
-PhysicsBody::~PhysicsBody()
+PhysicsBody::~PhysicsBody()
{
#ifdef HAVE_BULLET
if (collider_body) {
@@ -251,22 +251,22 @@ void PhysicsBody::init_physics(const float mass)
}
if (!collider_body) {
- btVector3 inertia(0,0,0);
+ btVector3 inertia(0, 0, 0);
btTransform t;
t.setIdentity();
t.setOrigin(to_btVector3(entity()->location()));
t.setBasis(to_btMatrix3x3(entity()->axis()));
-
-
+
+
if (moving) {
- collider_shape->bullet_shape()->calculateLocalInertia(mass,inertia);
+ collider_shape->bullet_shape()->calculateLocalInertia(mass, inertia);
btMotionState *motionstate = new btDefaultMotionState(t);
btRigidBody::btRigidBodyConstructionInfo body_info(mass, motionstate, collider_shape->bullet_shape(), inertia);
- collider_body = new btRigidBody(body_info);
+ collider_body = new btRigidBody(body_info);
collider_body->setUserPointer((void *)entity());
- collider_body->setLinearFactor(btVector3(1,1,1));
+ collider_body->setLinearFactor(btVector3(1, 1, 1));
collider_body->setCcdMotionThreshold(0.0001f);
} else {
collider_body = new btRigidBody(mass, 0, collider_shape->bullet_shape(), inertia);
@@ -276,7 +276,7 @@ void PhysicsBody::init_physics(const float mass)
if (entity()->zone()) {
PhysicsZone *zone = static_cast<PhysicsZone *>(entity()->zone());
- zone->dynamics_world()->addRigidBody(collider_body);
+ zone->dynamics_world()->addRigidBody(collider_body);
if (moving) {
//collider_body->setActivationState(ISLAND_SLEEPING);
//collider_body->setActivationState(ACTIVE_TAG);
@@ -292,8 +292,7 @@ void PhysicsBody::shutdown_physics()
if (collider_body && entity()->zone()) {
PhysicsZone *zone = static_cast<PhysicsZone *>(entity()->zone());
- if(collider_body->getMotionState())
- {
+ if (collider_body->getMotionState()) {
delete collider_body->getMotionState();
}
zone->dynamics_world()->removeCollisionObject(collider_body);
diff --git a/src/game/base/physics.h b/src/game/base/physics.h
index 37ed1cf..3bbd749 100644
--- a/src/game/base/physics.h
+++ b/src/game/base/physics.h
@@ -1,7 +1,7 @@
/*
base/physics.h
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#ifndef __INCLUDED_BASE_PHYSICS_H__
@@ -23,7 +23,8 @@
*/
-namespace game {
+namespace game
+{
#ifdef HAVE_BULLET
/// helper function to convert math:Vector3f to btVector3
@@ -36,29 +37,36 @@ inline btVector3 to_btVector3(const math::Vector3f & v)
inline btMatrix3x3 to_btMatrix3x3(const math::Axis &a)
{
return btMatrix3x3(a[0][0], a[0][1], a[0][2],
- a[1][0], a[1][1], a[1][2],
- a[2][0], a[2][1], a[2][2]);
+ a[1][0], a[1][1], a[1][2],
+ a[2][0], a[2][1], a[2][2]);
};
#endif
/* ---- class CollisionShape --------------------------------------- */
/// a bullet collision shape
-class CollisionShape {
+class CollisionShape
+{
public:
CollisionShape(model::Model *model, const bool moving);
~CollisionShape();
- inline const std::string &label() const { return shape_label; }
+ inline const std::string &label() const {
+ return shape_label;
+ }
- inline const bool moving() const { return shape_moving; }
+ inline const bool moving() const {
+ return shape_moving;
+ }
#ifdef HAVE_BULLET
- inline btCollisionShape *bullet_shape() { return shape_bulletshape; }
+ inline btCollisionShape *bullet_shape() {
+ return shape_bulletshape;
+ }
#endif
-/* ----- static functions for the shape registry ------------------- */
+ /* ----- static functions for the shape registry ------------------- */
/// tpye definition for the collision shape registry
typedef std::vector<CollisionShape *> Registry;
@@ -85,7 +93,8 @@ private:
/* ---- class Physics ---------------------------------------------- */
/// main physics functions
-class Physics {
+class Physics
+{
public:
/// intialize world physics
static void init();
@@ -108,13 +117,16 @@ public:
/* ---- class PhysicsZone ------------------------------------------ */
/// a zone containing collision objects
-class PhysicsZone : public core::Zone {
+class PhysicsZone : public core::Zone
+{
public:
PhysicsZone(const std::string &label);
virtual ~PhysicsZone();
#ifdef HAVE_BULLET
- inline btDiscreteDynamicsWorld *dynamics_world() { return zone_dynamics_world; }
+ inline btDiscreteDynamicsWorld *dynamics_world() {
+ return zone_dynamics_world;
+ }
private:
btAxisSweep3 *zone_cache;
@@ -125,10 +137,11 @@ private:
/* ---- class PhysicsBody ------------------------------------------ */
/// an object that is capable of colliding with other objects
-class PhysicsBody {
+class PhysicsBody
+{
public:
/// initialize a collider attached to an entity
- /**
+ /**
* a PhysicsBody with zero mass is considered non-moving
*/
PhysicsBody(core::Entity *entity);
@@ -141,14 +154,20 @@ public:
void shutdown_physics();
/// collider mass
- inline const float mass() const { return collider_mass; }
+ inline const float mass() const {
+ return collider_mass;
+ }
/// the entity the collider is attached to
- inline core::Entity *entity() { return collider_entity; }
+ inline core::Entity *entity() {
+ return collider_entity;
+ }
#ifdef HAVE_BULLET
/// the bullet rigid body associated with this collider
- inline btRigidBody *body() { return collider_body; }
+ inline btRigidBody *body() {
+ return collider_body;
+ }
#endif
private:
diff --git a/src/game/base/planet.cc b/src/game/base/planet.cc
index b1ac976..f9535ba 100644
--- a/src/game/base/planet.cc
+++ b/src/game/base/planet.cc
@@ -8,7 +8,8 @@
#include "base/planet.h"
-namespace game {
+namespace game
+{
Planet::Planet() : core::EntityGlobe(core::Entity::Static | core::Entity::Solid)
{
@@ -46,7 +47,7 @@ void Planet::dock(core::Entity *entity)
Ship * ship = static_cast<Ship *>(entity);
- if (math::distance(location(), ship->location()) > radius() + ship->radius() + 50.0f ) {
+ if (math::distance(location(), ship->location()) > radius() + ship->radius() + 50.0f) {
if (ship->owner())
ship->owner()->send("Planet out of range");
return;
@@ -55,7 +56,7 @@ void Planet::dock(core::Entity *entity)
ship->get_location().assign(entity->location());
ship->set_state(core::Entity::Docked);
- if (ship->owner() && ship->owner()->control() == ship) {
+ if (ship->owner() && ship->owner()->control() == ship) {
ship->owner()->set_view(this);
ship->owner()->send("^BDocking at " + name());
}
diff --git a/src/game/base/planet.h b/src/game/base/planet.h
index c9bb214..f0bf75f 100644
--- a/src/game/base/planet.h
+++ b/src/game/base/planet.h
@@ -1,7 +1,7 @@
/*
base/planet.h
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#ifndef __INCLUDED_BASE_PLANET_H__
@@ -13,15 +13,19 @@
#include <string>
-namespace game {
+namespace game
+{
/// a planet
-class Planet : public core::EntityGlobe {
+class Planet : public core::EntityGlobe
+{
public:
Planet();
virtual ~Planet();
- inline ShipDealer *shipdealer() { return planet_shipdealer; }
+ inline ShipDealer *shipdealer() {
+ return planet_shipdealer;
+ }
void set_shipdealer(ShipDealer *shipdealer);
diff --git a/src/game/base/racetrack.cc b/src/game/base/racetrack.cc
index 3d1cb69..51526ea 100644
--- a/src/game/base/racetrack.cc
+++ b/src/game/base/racetrack.cc
@@ -1,7 +1,7 @@
/*
base/racetrack.cc
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#include <string>
@@ -11,7 +11,8 @@
#include "base/racetrack.h"
#include "core/gameserver.h"
-namespace game {
+namespace game
+{
/* ---- class CheckPoint ------------------------------------------- */
@@ -31,7 +32,7 @@ CheckPoint::CheckPoint(RaceTrack *parent)
CheckPoint::~CheckPoint()
{
-
+
}
/* ---- class RaceTrack -------------------------------------------- */
@@ -64,7 +65,7 @@ void RaceTrack::reset()
track_player = 0;
track_racestart = 0;
track_checkpointtime = 0;
-
+
for (CheckPoints::iterator cpit = track_checkpoints.begin(); cpit != track_checkpoints.end(); ++cpit) {
(*cpit)->set_state(core::Entity::NoPower);
}
@@ -74,7 +75,7 @@ void RaceTrack::reset()
void RaceTrack::dock(core::Entity *entity)
{
-
+
if (entity->moduletype() != ship_enttype)
return;
Ship * ship = static_cast<Ship *>(entity);
@@ -96,7 +97,7 @@ void RaceTrack::dock(core::Entity *entity)
for (CheckPoints::iterator cpit = track_checkpoints.begin(); cpit != track_checkpoints.end(); ++cpit) {
set_state(core::Entity::Normal);
}
-
+
entity_timer = 5.0f;
std::string message("^B" + track_player->name() + " ^Bactivated the race! Race starts in 5...");
core::server()->broadcast(message);
@@ -163,7 +164,7 @@ void RaceTrack::frame(float seconds)
track_player->set_mission_target((*track_checkpoint));
}
}
-
+
} else {
@@ -192,7 +193,7 @@ void RaceTrack::frame(float seconds)
} else {
std::stringstream msgstr;
- msgstr << "^BRace completed in " << core::server()->time() - track_racestart << " seconds!";
+ msgstr << "^BRace completed in " << core::server()->time() - track_racestart << " seconds!";
core::server()->broadcast(msgstr.str());
// prize money
diff --git a/src/game/base/racetrack.h b/src/game/base/racetrack.h
index 80a5766..ef7375a 100644
--- a/src/game/base/racetrack.h
+++ b/src/game/base/racetrack.h
@@ -1,7 +1,7 @@
/*
base/racetrack.h
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#ifndef __INCLUDED_BASE_RACETRACK_H__
@@ -13,14 +13,16 @@
#include <string>
-namespace game {
+namespace game
+{
class CheckPoint;
/* ---- class RaceTrack -------------------------------------------- */
/// a race track entity
-class RaceTrack : public core::EntityDynamic {
+class RaceTrack : public core::EntityDynamic
+{
public:
/// default constructor
@@ -33,7 +35,9 @@ public:
typedef std::list<CheckPoint *> CheckPoints ;
/// the player who activated the race
- inline core::Player *player() { return track_player; }
+ inline core::Player *player() {
+ return track_player;
+ }
/// add a checkpoint to the racetrack
void add_checkpoint(CheckPoint *checkpoint);
@@ -46,20 +50,21 @@ public:
/// run one time frame
virtual void frame(float elapsed);
-
+
private:
CheckPoints track_checkpoints;
core::Player *track_player;
float track_racestart;
float track_checkpointtime;
CheckPoints::iterator track_checkpoint;
-
+
};
/* ---- class CheckPoint ------------------------------------------- */
/// a checkpoint for the race track
-class CheckPoint : public core::EntityDynamic {
+class CheckPoint : public core::EntityDynamic
+{
public:
CheckPoint(RaceTrack *parent);
~CheckPoint();
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 8bc7799..2c42ca8 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -1,7 +1,7 @@
/*
base/ship.cc
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#include <cmath>
@@ -19,13 +19,14 @@
using math::degrees360f;
using math::degrees180f;
-namespace game {
+namespace game
+{
const float MIN_DELTA = 0.000001f;
Ship::Ship(core::Player *owner, ShipModel *shipmodel) :
- core::EntityControlable(owner, ship_enttype),
- PhysicsBody(this)
+ core::EntityControlable(owner, ship_enttype),
+ PhysicsBody(this)
{
set_modelname(shipmodel->modelname());
set_name(shipmodel->name());
@@ -41,7 +42,7 @@ Ship::Ship(core::Player *owner, ShipModel *shipmodel) :
ship_shipmodel = shipmodel;
ship_jumpdrive = shipmodel->shipmodel_jumpdrive;
-
+
ship_impulsedrive_timer = 0;
ship_jumpdrive_timer = 0;
ship_jumpdepart = 0;
@@ -49,7 +50,7 @@ Ship::Ship(core::Player *owner, ShipModel *shipmodel) :
reset();
}
-Ship::~Ship()
+Ship::~Ship()
{
shutdown_physics();
}
@@ -71,16 +72,16 @@ void Ship::func_impulse()
} else if (entity_state == core::Entity::ImpulseInitiate) {
entity_state = core::Entity::Normal;
-
+
} else if (entity_state != core::Entity::Normal) {
return;
-
- } else {
+
+ } else {
if (entity_state == core::Entity::JumpInitiate) {
ship_jumpdrive_timer = 0;
entity_timer = 0;
}
-
+
entity_state = core::Entity::ImpulseInitiate;
if (Game::g_devel->value()) {
entity_timer = 0;
@@ -137,12 +138,12 @@ void Ship::func_jump(std::string const &args)
owner()->send("Usage: jump [^B" + helpstr + "^N]");
return;
}
-
+
if (jumptargetzone == zone()) {
owner()->send("Already in the " + jumptargetzone->name());
return;
}
-
+
owner()->send("Jumping to the " + jumptargetzone->name());
set_zone(jumptargetzone);
@@ -188,7 +189,7 @@ JumpPoint * Ship::find_closest_jumppoint()
}
}
}
-
+
if (jumppoint && jumppoint->target()) {
if (Game::g_jumppointrange->value() < d) {
owner()->send("Jumppoint out of range!");
@@ -201,14 +202,14 @@ JumpPoint * Ship::find_closest_jumppoint()
owner()->send("No jumppoints found!");
return 0;
}
-
+
return 0;
}
void Ship::explode()
{
set_state(core::Entity::Destroyed);
-
+
target_thrust = 0;
target_pitch = 0;
target_roll = 0;
@@ -235,7 +236,7 @@ void Ship::set_zone(core::Zone *zone)
init_physics(radius());
}
-void Ship::frame(float seconds)
+void Ship::frame(float seconds)
{
float actual_maxspeed = ship_shipmodel->maxspeed();
float actual_turnspeed = ship_shipmodel->turnspeed();
@@ -247,10 +248,10 @@ void Ship::frame(float seconds)
const float thrust_reaction = 0.5f; // thrust control reaction time factor
const float strafe_reaction = 1.5f;
const float afterburner_reaction = 1.0f; // a fterburner control reaction time
-
+
float cosangle; // cosine of an angle
- float angle; // angle in radians
+ float angle; // angle in radians
math::Vector3f n; // normal of a plane
math::Axis target_axis(axis()); // target axis
#endif
@@ -270,7 +271,7 @@ void Ship::frame(float seconds)
target_direction = 0;
target_afterburner = 0.0f;
target_thrust = 0;
-
+
entity_speed = 0;
entity_thrust = 0;
@@ -289,7 +290,7 @@ void Ship::frame(float seconds)
//entity_location += entity_axis.forward() * radius();
} else {
get_location().assign(ship_jumpdepart->target()->location() + location() - ship_jumpdepart->location());
- }
+ }
set_zone(ship_jumpdepart->target()->zone());
owner()->send("^BJumping to the " + ship_jumpdepart->target()->zone()->name());
} else {
@@ -297,7 +298,7 @@ void Ship::frame(float seconds)
}
ship_jumpdrive_timer = 0;
entity_timer = 0;
-
+
set_dirty();
return;
} else {
@@ -340,12 +341,12 @@ void Ship::frame(float seconds)
if (target_afterburner < 0.0f) {
set_state(core::Entity::Normal);
set_dirty();
- entity_timer = 0;
+ entity_timer = 0;
} else {
if (ship_impulsedrive_timer + 1.0f <= core::server()->time()) {
entity_timer -= 1.0f;
-
+
if (entity_timer <= 0) {
actual_maxspeed = Game::g_impulsespeed->value();
actual_acceleration = Game::g_impulseacceleration->value();
@@ -357,25 +358,23 @@ void Ship::frame(float seconds)
set_dirty();
}
}
-
+
// clamp input values
target_thrust = 0.0f;
math::clamp(target_pitch, -1.0f, 1.0f);
math::clamp(target_roll, -1.0f, 1.0f);
math::clamp(target_direction, -1.0f, 1.0f);
math::clamp(target_afterburner, -1.0f, 1.0f);
-
+
actual_turnspeed *= 0.5;
}
} else if (entity_state == core::Entity::Impulse) {
// clamp input values
- target_thrust = 0.0f;
math::clamp(target_pitch, -1.0f, 1.0f);
math::clamp(target_roll, -1.0f, 1.0f);
math::clamp(target_direction, -1.0f, 1.0f);
- target_afterburner = 0.0f;
// cancel impulse drive if afterburner goes reverse
if (target_afterburner < 0.0f) {
@@ -383,11 +382,13 @@ void Ship::frame(float seconds)
set_dirty();
entity_timer = 0;
target_thrust = 1.0f;
- target_thrust = 1.0f;
- } else {
+ entity_thrust = 1.0f;
+ } else {
actual_maxspeed = Game::g_impulsespeed->value();
actual_acceleration = Game::g_impulseacceleration->value();
actual_turnspeed *= 0.5;
+ target_afterburner = 0.0f;
+ target_thrust = 0.0f;
}
} else if (entity_state == core::Entity::Normal) {
@@ -412,7 +413,7 @@ void Ship::frame(float seconds)
target_direction = 0;
target_afterburner = 0.0f;
target_thrust = 0;
-
+
entity_thrust = 0;
}
@@ -448,7 +449,7 @@ void Ship::frame(float seconds)
if ((entity_state == core::Entity::ImpulseInitiate) || (entity_state == core::Entity::Impulse)) {
actual_thrust = 1.0f;
}
-
+
// update strafe control target
if (current_target_strafe < target_strafe) {
@@ -476,7 +477,7 @@ void Ship::frame(float seconds)
}
math::clamp(current_target_roll, -1.0f, 1.0f);
- if (fabs(current_target_roll) > MIN_DELTA) {
+ if (fabs(current_target_roll) > MIN_DELTA) {
float roll_offset = seconds * current_target_roll;
get_axis().change_roll(actual_turnspeed * roll_offset);
} else {
@@ -496,7 +497,7 @@ void Ship::frame(float seconds)
}
}
- if (fabs(current_target_direction) > MIN_DELTA ) {
+ if (fabs(current_target_direction) > MIN_DELTA) {
math::clamp(current_target_direction, -1.0f, 1.0f);
target_axis.change_direction(actual_turnspeed * current_target_direction);
} else {
@@ -513,7 +514,7 @@ void Ship::frame(float seconds)
if (current_target_pitch < target_pitch)
current_target_pitch = target_pitch;
}
-
+
if (fabs(current_target_pitch) > MIN_DELTA) {
math::clamp(current_target_pitch, -1.0f, 1.0f);
target_axis.change_pitch(actual_turnspeed * current_target_pitch);
@@ -538,7 +539,7 @@ void Ship::frame(float seconds)
if (entity_speed > max) {
entity_speed = max;
}
- } else if(entity_speed > max) {
+ } else if (entity_speed > max) {
entity_speed -= actual_acceleration * seconds;
if (entity_speed < max) {
entity_speed = max;
@@ -584,7 +585,7 @@ void Ship::frame(float seconds)
entity_movement = math::max(entity_movement, fabs(current_target_afterburner));
entity_movement = math::max(entity_movement, fabs(current_target_strafe));
- if ((entity_movement > 0)|| (entity_speed > 0)) {
+ if ((entity_movement > 0) || (entity_speed > 0)) {
set_dirty();
}
}
diff --git a/src/game/base/ship.h b/src/game/base/ship.h
index 21987e7..e1b8b1d 100644
--- a/src/game/base/ship.h
+++ b/src/game/base/ship.h
@@ -1,7 +1,7 @@
/*
base/ship.h
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#ifndef __INCLUDED_BASE_SHIP_H__
@@ -14,7 +14,8 @@
#include "base/jumppoint.h"
#include "math/vector3f.h"
-namespace game {
+namespace game
+{
/// A ship in the game, controled by a player
class Ship : public core::EntityControlable, public PhysicsBody
@@ -30,7 +31,9 @@ public:
virtual void set_zone(core::Zone *zone);
/// true if the ship is equiped with a jumpdrive
- inline bool jumpdrive() const { return ship_jumpdrive; }
+ inline bool jumpdrive() const {
+ return ship_jumpdrive;
+ }
/// Initiate jump, departing from a jump point
/** Initiates a jump even if the ship has no jumpdrive
@@ -65,7 +68,7 @@ private:
float ship_impulsedrive_timer;
-
+
JumpPoint *ship_jumpdepart;
};
diff --git a/src/game/base/shipdealer.cc b/src/game/base/shipdealer.cc
index 408ae43..54d3e90 100644
--- a/src/game/base/shipdealer.cc
+++ b/src/game/base/shipdealer.cc
@@ -1,7 +1,7 @@
/*
base/shipdealer.cc
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#include "auxiliary/functions.h"
@@ -11,7 +11,8 @@
#include "base/station.h"
#include "sys/sys.h"
-namespace game {
+namespace game
+{
ShipDealer::ShipDealer()
{
@@ -67,7 +68,7 @@ ShipModel *ShipDealer::find(ShipModel *shipmodel) const
void ShipDealer::func_buy(core::Player *player, const std::string &args)
{
core::Entity *dock = player->view();
-
+
ShipDealer *shipdealer = 0;
// find the ship model
@@ -102,7 +103,7 @@ void ShipDealer::func_buy(core::Player *player, const std::string &args)
}
if (!Game::g_devel->value()) {
-
+
if (!shipdealer) {
player->send("No ship dealer available");
return;
@@ -116,7 +117,7 @@ void ShipDealer::func_buy(core::Player *player, const std::string &args)
// check price
if (shipmodel->price() > player->credits()) {
std::stringstream msgstr;
- msgstr << "You require " << (shipmodel->price() - player->credits()) << " additional credits to buy the " << shipmodel->name();
+ msgstr << "You require " << (shipmodel->price() - player->credits()) << " additional credits to buy the " << shipmodel->name();
player->send(msgstr.str());
return;
}
@@ -135,7 +136,7 @@ void ShipDealer::func_buy(core::Player *player, const std::string &args)
ship->get_location().assign(dock->location());
ship->set_state(core::Entity::Docked);
ship->get_axis().assign(dock->axis());
- ship->get_axis().change_direction(180.0f);
+ ship->get_axis().change_direction(180.0f);
player->set_control(ship);
player->set_view(dock);
} else {
@@ -148,9 +149,9 @@ void ShipDealer::func_buy(core::Player *player, const std::string &args)
msgstr << "^BPurchased " << aux::article(shipmodel->name());
if (!Game::g_devel->value()) {
msgstr << " for " << shipmodel->price() << " credits";
- }
+ }
player->send(msgstr.str());
- player->sound("game/buy-ship");
+ player->sound("game/buy-ship");
}
diff --git a/src/game/base/shipdealer.h b/src/game/base/shipdealer.h
index 48f9835..1d93f03 100644
--- a/src/game/base/shipdealer.h
+++ b/src/game/base/shipdealer.h
@@ -1,7 +1,7 @@
/*
base/shipdealer.h
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#ifndef __INCLUDED_BASE_SHIPDEALER_H__
@@ -12,29 +12,30 @@
#include "base/shipmodel.h"
#include "core/entity.h"
-namespace game {
+namespace game
+{
class ShipDealer
{
public:
typedef std::list<ShipModel *> Models;
-
+
ShipDealer();
~ShipDealer();
/// add a ship model to the dealer list
ShipModel *add(const std::string &modelname);
-
+
/// find a ship model in the dealer list
ShipModel *find(const std::string &modelname) const;
-
+
/// find a ship model in the dealer list
ShipModel *find(ShipModel *shipmodel) const;
static void func_buy(core::Player *player, const std::string &args);
private:
- Models dealer_models;
+ Models dealer_models;
};
}
diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc
index 9d905d6..6233120 100644
--- a/src/game/base/shipmodel.cc
+++ b/src/game/base/shipmodel.cc
@@ -1,7 +1,7 @@
/*
base/shipmodel.cc
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#include <iomanip>
@@ -10,7 +10,8 @@
#include "base/shipmodel.h"
#include "sys/sys.h"
-namespace game {
+namespace game
+{
// the ship model registry
std::map<std::string, ShipModel *> ShipModel::registry;
@@ -35,7 +36,7 @@ ShipModel::~ShipModel()
void ShipModel::clear()
{
for (iterator smit = registry.begin(); smit != registry.end(); smit++) {
- delete (*smit).second;
+ delete(*smit).second;
}
registry.clear();
}
@@ -43,7 +44,7 @@ void ShipModel::clear()
void ShipModel::print()
{
con_print << "label: ^B" << label() << " ^Nname: ^B" << name() << std::endl;
- con_print << " price: ^B" << price() << std::endl;
+ con_print << " price: ^B" << price() << std::endl;
con_print << " acceleration: ^B" << acceleration() << std::endl;
con_print << " turnspeed: ^B" << turnspeed() << std::endl;
con_print << " max speed: ^B" << maxspeed() << std::endl;
@@ -64,33 +65,39 @@ void ShipModel::generate_info(core::Info *info)
info->add_text("");
info->add_text("^BSpecifications:^N");
- std::stringstream str;
+ std::stringstream str;
str << "price: ^B" << price() << " ^Ncredits";
- info->add_text(str.str()); str.str("");
+ info->add_text(str.str());
+ str.str("");
str << "cargo hold: ^B" << 0.1f * maxcargo() << " ^Nmetric tonnes";
- info->add_text(str.str()); str.str("");
+ info->add_text(str.str());
+ str.str("");
str << "top speed: ^B" << 100.0f * maxspeed() << " ^Nmps";
- info->add_text(str.str()); str.str("");
+ info->add_text(str.str());
+ str.str("");
str << "response: ^B" << turnspeed() << " ^Ndps";
- info->add_text(str.str()); str.str("");
+ info->add_text(str.str());
+ str.str("");
str << "acceleration: ^B" << acceleration() << " ^Nstandard";
- info->add_text(str.str()); str.str("");
+ info->add_text(str.str());
+ str.str("");
- if(shipmodel_jumpdrive) {
+ if (shipmodel_jumpdrive) {
str << "hyperspace jump drive capable";
- info->add_text(str.str()); str.str("");
+ info->add_text(str.str());
+ str.str("");
}
}
void ShipModel::list()
{
for (iterator smit = registry.begin(); smit != registry.end(); smit++) {
- con_print << std::setw(24) << (*smit).second->label()
- << " ^B" << (*smit).second->name() << "\n";
+ con_print << std::setw(24) << (*smit).second->label()
+ << " ^B" << (*smit).second->name() << "\n";
}
con_print << registry.size() << " registered ship models\n";
}
@@ -132,12 +139,12 @@ ShipModel *ShipModel::search(const std::string searchname)
for (iterator smit = registry.begin(); smit != registry.end(); smit++) {
ShipModel *shipmodel = (*smit).second;
-
+
label.assign(shipmodel->label());
if (label.size() && (label.find(strsearchkey) != std::string::npos)) {
return shipmodel;
}
-
+
name.assign(aux::lowercase(shipmodel->name()));
if (name.size() && (name.find(strsearchkey) != std::string::npos)) {
return shipmodel;
@@ -155,7 +162,7 @@ void ShipModel::add(ShipModel *shipmodel)
con_warn << "Duplicate ship model " << shipmodel->label() << "!\n";
delete m;
}
-
+
registry[shipmodel->label()] = shipmodel;
}
diff --git a/src/game/base/shipmodel.h b/src/game/base/shipmodel.h
index 9bdf4f5..0cfe87e 100644
--- a/src/game/base/shipmodel.h
+++ b/src/game/base/shipmodel.h
@@ -1,7 +1,7 @@
/*
base/shipmodel.h
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#ifndef __INCLUDED_BASE_SHIPMODEL_H__
@@ -12,7 +12,8 @@
#include "core/info.h"
-namespace game {
+namespace game
+{
/// ship model specifications
class ShipModel
@@ -24,43 +25,69 @@ public:
void print();
/// acceleration
- inline const float acceleration() const { return shipmodel_acceleration; }
+ inline const float acceleration() const {
+ return shipmodel_acceleration;
+ }
/// maximum speed
- inline const float maxspeed() const { return shipmodel_maxspeed; }
-
+ inline const float maxspeed() const {
+ return shipmodel_maxspeed;
+ }
+
/// turn speed in rotations per second
- inline const float turnspeed() const { return shipmodel_turnspeed; }
+ inline const float turnspeed() const {
+ return shipmodel_turnspeed;
+ }
/// label of the ship model
- inline const std::string &label() const { return shipmodel_label; }
+ inline const std::string &label() const {
+ return shipmodel_label;
+ }
/// name of the ship model
- inline const std::string & name() const { return shipmodel_name; }
+ inline const std::string & name() const {
+ return shipmodel_name;
+ }
/// name of the model of the ship
- inline const std::string & modelname() const { return shipmodel_modelname; }
+ inline const std::string & modelname() const {
+ return shipmodel_modelname;
+ }
/// price of the ship
- inline const long price() const { return shipmodel_price; }
+ inline const long price() const {
+ return shipmodel_price;
+ }
/// size of the cargo hold
- inline const float maxcargo() const { return shipmodel_maxcargo; }
+ inline const float maxcargo() const {
+ return shipmodel_maxcargo;
+ }
/// set acceleration
- inline void set_acceleration(const float acceleration) { shipmodel_acceleration = acceleration; }
+ inline void set_acceleration(const float acceleration) {
+ shipmodel_acceleration = acceleration;
+ }
/// set maximum speed
- inline void set_maxspeed(const float maxspeed) { shipmodel_maxspeed = maxspeed; }
+ inline void set_maxspeed(const float maxspeed) {
+ shipmodel_maxspeed = maxspeed;
+ }
/// set turn speed
- inline void set_turnspeed(const float turnspeed) { shipmodel_turnspeed = turnspeed; }
+ inline void set_turnspeed(const float turnspeed) {
+ shipmodel_turnspeed = turnspeed;
+ }
/// set price
- inline void set_price(const long price) { shipmodel_price = price; }
+ inline void set_price(const long price) {
+ shipmodel_price = price;
+ }
/// set size of the cargo hold
- inline void set_maxcargo(const float maxcargo) { shipmodel_maxcargo = maxcargo; }
+ inline void set_maxcargo(const float maxcargo) {
+ shipmodel_maxcargo = maxcargo;
+ }
/// generate an info object for this shipmodel
void generate_info(core::Info *info);
@@ -108,7 +135,7 @@ private:
float shipmodel_maxcargo;
long shipmodel_price;
-
+
};
}
diff --git a/src/game/base/star.cc b/src/game/base/star.cc
index ba3ccba..43efd0c 100644
--- a/src/game/base/star.cc
+++ b/src/game/base/star.cc
@@ -8,7 +8,8 @@
#include "base/star.h"
-namespace game {
+namespace game
+{
Star::Star() : core::EntityGlobe(core::Entity::Static | core::Entity::Solid | core::Entity::Bright)
{
diff --git a/src/game/base/star.h b/src/game/base/star.h
index 5283894..12bec07 100644
--- a/src/game/base/star.h
+++ b/src/game/base/star.h
@@ -1,7 +1,7 @@
/*
base/star.h
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#ifndef __INCLUDED_BASE_STAR_H__
@@ -14,10 +14,12 @@
// C++ headers
#include <string>
-namespace game {
+namespace game
+{
/// a star, that shines so bright
-class Star : public core::EntityGlobe {
+class Star : public core::EntityGlobe
+{
public:
Star();
~Star();
diff --git a/src/game/base/station.cc b/src/game/base/station.cc
index 0552269..fb548bb 100644
--- a/src/game/base/station.cc
+++ b/src/game/base/station.cc
@@ -1,14 +1,15 @@
/*
base/station.cc
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#include "base/game.h"
#include "base/station.h"
#include "sys/sys.h"
-namespace game {
+namespace game
+{
Station::Station() : Entity(), PhysicsBody(this)
{
@@ -51,7 +52,7 @@ void Station::dock(core::Entity *entity)
ship->get_location().assign(entity->location());
ship->set_state(core::Entity::Docked);
- if (ship->owner() && ship->owner()->control() == ship) {
+ 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 ae4d0f4..ad627dd 100644
--- a/src/game/base/station.h
+++ b/src/game/base/station.h
@@ -1,7 +1,7 @@
/*
base/station.h
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#ifndef __INCLUDED_BASE_STATION_H__
@@ -10,7 +10,8 @@
#include "base/shipdealer.h"
#include "base/physics.h"
-namespace game {
+namespace game
+{
class Station : public core::Entity, public PhysicsBody
{
@@ -18,7 +19,9 @@ public:
Station();
virtual ~Station();
- inline ShipDealer *shipdealer() { return station_shipdealer; }
+ inline ShipDealer *shipdealer() {
+ return station_shipdealer;
+ }
void set_shipdealer(ShipDealer *shipdealer);