Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/entity.h7
-rw-r--r--src/core/gameserver.cc20
-rw-r--r--src/core/gameserver.h6
-rw-r--r--src/core/player.cc2
-rw-r--r--src/game/Makefile.am6
-rw-r--r--src/game/game.cc57
-rw-r--r--src/render/draw.cc19
7 files changed, 99 insertions, 18 deletions
diff --git a/src/core/entity.h b/src/core/entity.h
index 2b2ed00..30e3356 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -47,7 +47,7 @@ public:
enum Shape {Diamond=0, Sphere=1, Cube=2, Axis=3};
/// EntityDynamic event state classes
- enum Event {Normal=0, ImpulseInitiate=2, Impulse=3, JumpInitiate=4, Jump=5};
+ enum Event {Normal=0, NoPower=1, ImpulseInitiate=2, Impulse=3, JumpInitiate=4, Jump=5};
/// create a new entity and add it to the registry
Entity(unsigned int flags = 0);
@@ -137,7 +137,7 @@ public:
virtual void receive_server_update(std::istream &is);
/// mark the entity as destroyed
- void die();
+ virtual void die();
/// runs one game frame for the entity
/**
@@ -276,8 +276,9 @@ public:
/// speed of the entity
float entity_speed;
-protected:
unsigned int entity_eventstate;
+
+protected:
float entity_timer;
};
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 81df14b..fce758e 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -170,6 +170,8 @@ GameServer::GameServer() : GameInterface()
func = Func::add("who", func_who, Func::Shared);
func->set_info("get a list of connected players");
+ server_players.clear();
+
if (!Cvar::sv_dedicated->value()) {
player_connect(localplayer());
}
@@ -211,7 +213,7 @@ GameServer::~GameServer()
server_instance = 0;
- players.clear();
+ server_players.clear();
}
void GameServer::abort()
@@ -225,7 +227,7 @@ void GameServer::list_players()
stringstream msgstr;
int count = 0;
- for (std::list<Player *>:: iterator it = players.begin(); it != players.end(); it++) {
+ for (Players::iterator it = server_players.begin(); it != server_players.end(); it++) {
msgstr.str("");
con_print << setw(3) << (*it)->id() << aux::pad_left((*it)->name(), 24) << std::endl;
count++;
@@ -257,7 +259,7 @@ Player *GameServer::find_player(std::string const search)
std::istringstream searchstr(search);
int id = 0;
if (searchstr >> id) {
- for (std::list<Player *>:: iterator it = players.begin(); it != players.end(); it++) {
+ for (std::list<Player *>:: iterator it = server_players.begin(); it != server_players.end(); it++) {
if ((*it)->id() == id) {
return (*it);
}
@@ -267,7 +269,7 @@ Player *GameServer::find_player(std::string const search)
if (search.size() <3)
return 0;
- for (std::list<Player *>:: iterator it = players.begin(); it != players.end(); it++) {
+ for (std::list<Player *>:: iterator it = server_players.begin(); it != server_players.end(); it++) {
if (aux::text_strip_lowercase((*it)->name()).find(lowercase(search)) != std::string::npos)
return (*it);
}
@@ -470,7 +472,7 @@ void GameServer::player_connect(Player *player)
server_module->player_connect(player);
// manage player list
- players.push_back(player);
+ server_players.push_back(player);
}
void GameServer::player_disconnect(Player *player)
@@ -487,12 +489,12 @@ void GameServer::player_disconnect(Player *player)
server_module->player_disconnect(player);
// manage player list
- std::list<Player *>:: iterator it = players.begin();
- while (((*it)->id() != player->id()) && (it != players.end())) {
+ std::list<Player *>:: iterator it = server_players.begin();
+ while (((*it)->id() != player->id()) && (it != server_players.end())) {
it++;
}
- if (it != players.end()) {
- players.erase(it);
+ if (it != server_players.end()) {
+ server_players.erase(it);
}
}
diff --git a/src/core/gameserver.h b/src/core/gameserver.h
index f05e6c6..98938fa 100644
--- a/src/core/gameserver.h
+++ b/src/core/gameserver.h
@@ -21,6 +21,8 @@ namespace core
class GameServer : public GameInterface
{
public:
+ typedef std::list<Player *> Players;
+
GameServer();
~GameServer();
@@ -79,7 +81,7 @@ public:
/// find the first player who's id or name matches the search string
Player *find_player(std::string const search);
- std::list<Player *> players;
+ inline Players & players() { return server_players; }
/*----- static ---------------------------------------------------- */
@@ -100,6 +102,8 @@ private:
float server_frametime;
float server_time;
float server_previoustime;
+
+ Players server_players;
};
inline GameServer *server() { return GameServer::instance(); }
diff --git a/src/core/player.cc b/src/core/player.cc
index fafb052..1a610ca 100644
--- a/src/core/player.cc
+++ b/src/core/player.cc
@@ -15,6 +15,7 @@ namespace core
Player::Player()
{
+ player_control = 0;
clear();
}
@@ -34,6 +35,7 @@ void Player::clear()
player_mute = false;
clear_assets();
+ player_control = 0;
}
void Player::set_control(EntityControlable *entitycontrolable)
diff --git a/src/game/Makefile.am b/src/game/Makefile.am
index 17bd6d3..efa051f 100644
--- a/src/game/Makefile.am
+++ b/src/game/Makefile.am
@@ -2,7 +2,9 @@ INCLUDES = -I$(top_srcdir)/src
METASOURCES = AUTO
libgame_la_LDFLAGS = -avoid-version
-libgame_la_SOURCES = game.cc navpoint.cc planet.cc ship.cc shipmodel.cc star.cc
+libgame_la_SOURCES = game.cc navpoint.cc planet.cc racetrack.cc ship.cc \
+ shipmodel.cc star.cc
noinst_LTLIBRARIES = libgame.la
-noinst_HEADERS = game.h navpoint.h planet.h ship.h shipmodel.h star.h
+noinst_HEADERS = game.h navpoint.h planet.h racetrack.h ship.h shipmodel.h \
+ star.h
diff --git a/src/game/game.cc b/src/game/game.cc
index f35670a..ca06c81 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -13,6 +13,7 @@
#include "game/game.h"
#include "game/navpoint.h"
#include "game/planet.h"
+#include "game/racetrack.h"
#include "game/ship.h"
#include "game/star.h"
#include "math/mathlib.h"
@@ -313,6 +314,8 @@ bool Game::load_zone(core::Zone *zone)
Planet *planet = 0;
Star *star = 0;
NavPoint *navpoint = 0;
+ RaceTrack *racetrack = 0;
+ CheckPoint *checkpoint = 0;
core::Entity *entity = 0;
float direction;
@@ -404,6 +407,50 @@ bool Game::load_zone(core::Zone *zone)
con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl;
}
+ } else if (zoneini.section().compare("racetrack") == 0) {
+ if (zoneini.got_key_string("label", strval)) {
+ aux::to_label(strval);
+ racetrack->entity_label.assign(strval);
+ continue;
+ } else if (zoneini.got_key_string("name", racetrack->entity_name)) {
+ continue;
+ } else if (zoneini.got_key_vector3f("location", racetrack->entity_location )) {
+ continue;
+ } else if (zoneini.got_key_color("color", racetrack->entity_color)) {
+ continue;
+ } else if (zoneini.got_key_angle("direction", direction)) {
+ racetrack->axis().change_direction(direction);
+ continue;
+ } else if (zoneini.got_key_angle("pitch", pitch)) {
+ racetrack->axis().change_pitch(pitch);
+ continue;
+ } else if (zoneini.got_key_string("model", racetrack->entity_modelname)) {
+ continue;
+ } else {
+ con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl;
+ }
+
+ } else if (zoneini.section().compare("checkpoint") == 0) {
+ if (zoneini.got_key_string("label", strval)) {
+ aux::to_label(strval);
+ checkpoint->entity_label.assign(strval);
+ continue;
+ } else if (zoneini.got_key_string("name", checkpoint->entity_name)) {
+ continue;
+ } else if (zoneini.got_key_vector3f("location", checkpoint->entity_location )) {
+ continue;
+ } else if (zoneini.got_key_angle("direction", direction)) {
+ checkpoint->axis().change_direction(direction);
+ continue;
+ } else if (zoneini.got_key_angle("pitch", pitch)) {
+ checkpoint->axis().change_pitch(pitch);
+ continue;
+ } else if (zoneini.got_key_string("model", checkpoint->entity_modelname)) {
+ continue;
+ } else {
+ con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl;
+ }
+
} else if (zoneini.section().compare("entity") == 0) {
std::string shapename;
if (zoneini.got_key_string("shape", shapename)) {
@@ -460,6 +507,16 @@ bool Game::load_zone(core::Zone *zone)
navpoint = new NavPoint();
navpoint->set_zone(zone);
count ++;
+
+ } else if(zoneini.got_section("racetrack")) {
+ racetrack = new RaceTrack();
+ racetrack->set_zone(zone);
+
+ } 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();
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 26b1109..2104981 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -578,6 +578,13 @@ void draw_model_fragments(core::Entity *entity)
thrust = static_cast<core::EntityControlable *>(entity)->thrust();
}
+ bool power = true;
+ if ((entity->type() == core::Entity::Dynamic) || (entity->type() == core::Entity::Controlable)) {
+ if ((static_cast<core::EntityDynamic *>(entity)->eventstate() & core::Entity::NoPower) == core::Entity::NoPower) {
+ power = false;
+ }
+ }
+
for (Model::Fragments::iterator fit = model->fragments().begin(); fit != model->fragments().end(); fit++) {
Fragment *fragment = (*fit);
@@ -625,12 +632,12 @@ void draw_model_fragments(core::Entity *entity)
}
}
- if (material & Material::Light) {
+ if (power && material & Material::Light) {
if (use_light) {
gl::disable(GL_LIGHTING);
use_light = false;
}
- } else if (material & Material::Engine) {
+ } else if ( power && material & Material::Engine) {
if (use_light) {
gl::disable(GL_LIGHTING);
use_light = false;
@@ -741,8 +748,14 @@ void draw_pass_model_fx(float elapsed)
for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) {
core::Entity *entity = (*it);
- if (entity->model() && entity->state() && entity->state()->detailvisible()) {
+ bool power = true;
+ if ((entity->type() == core::Entity::Dynamic) || (entity->type() == core::Entity::Controlable)) {
+ if ((static_cast<core::EntityDynamic *>(entity)->eventstate() & core::Entity::NoPower) == core::Entity::NoPower) {
+ power = false;
+ }
+ }
+ if (entity->model() && entity->state() && entity->state()->detailvisible() && power) {
// draw model lights
for (model::Model::Lights::iterator lit = entity->model()->lights().begin(); lit != entity->model()->lights().end(); lit++) {
light = (*lit);