From 9c56ebfdba5fe33476f8d382da6d72e5b81ab4b8 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 10 Aug 2008 18:48:23 +0000 Subject: added racetrack to the game module, added Odin's new structures to the assets documentation --- doc/assets.html | 14 +++++++++++++ src/core/entity.h | 7 ++++--- src/core/gameserver.cc | 20 ++++++++++-------- src/core/gameserver.h | 6 +++++- src/core/player.cc | 2 ++ src/game/Makefile.am | 6 ++++-- src/game/game.cc | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/render/draw.cc | 19 ++++++++++++++--- 8 files changed, 113 insertions(+), 18 deletions(-) diff --git a/doc/assets.html b/doc/assets.html index 3aca42d..6238dbc 100644 --- a/doc/assets.html +++ b/doc/assets.html @@ -71,6 +71,20 @@ supertanker
+ + /base/maps/stations + tsukhan_central.map + + Odin
+ + + + /base/maps/stations + civilian_housing.map + + supertanker
+ + /base/sounds/engines loop00.wav 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:: 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:: iterator it = players.begin(); it != players.end(); it++) { + for (std::list:: 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:: iterator it = players.begin(); it != players.end(); it++) { + for (std::list:: 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:: iterator it = players.begin(); - while (((*it)->id() != player->id()) && (it != players.end())) { + std::list:: 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 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 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(entity)->thrust(); } + bool power = true; + if ((entity->type() == core::Entity::Dynamic) || (entity->type() == core::Entity::Controlable)) { + if ((static_cast(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(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); -- cgit v1.2.3