diff options
author | Stijn Buys <ingar@osirion.org> | 2008-09-28 18:02:06 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-09-28 18:02:06 +0000 |
commit | f46be446304dcb2d609fcd2648fd36d3f2fda054 (patch) | |
tree | 36e194d6e2d9d8fc48d03c4b8bb56d63e12276cf /src/game | |
parent | fd778219e40c5fbb4d0af1839cbc313caaf10d9d (diff) |
intro module groundworks
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/Makefile.am | 3 | ||||
-rw-r--r-- | src/game/base/base.cc | 74 | ||||
-rw-r--r-- | src/game/base/base.h | 2 | ||||
-rw-r--r-- | src/game/game.cc | 1 | ||||
-rw-r--r-- | src/game/intro/Makefile.am | 6 | ||||
-rw-r--r-- | src/game/intro/intro.cc | 59 | ||||
-rw-r--r-- | src/game/intro/intro.h | 47 |
7 files changed, 123 insertions, 69 deletions
diff --git a/src/game/Makefile.am b/src/game/Makefile.am index 91838e6..a6a5290 100644 --- a/src/game/Makefile.am +++ b/src/game/Makefile.am @@ -7,4 +7,5 @@ libgame_la_SOURCES = game.cc noinst_LTLIBRARIES = libgame.la noinst_HEADERS = game.h SUBDIRS = base intro -libgame_la_LIBADD = $(top_builddir)/src/game/base/libbase.la +libgame_la_LIBADD = $(top_builddir)/src/game/base/libbase.la \ + $(top_builddir)/src/game/intro/libintro.la diff --git a/src/game/base/base.cc b/src/game/base/base.cc index 70d9335..d337391 100644 --- a/src/game/base/base.cc +++ b/src/game/base/base.cc @@ -9,6 +9,7 @@ #include "auxiliary/functions.h" #include "core/gameserver.h" +#include "core/parser.h" #include "filesystem/filesystem.h" #include "filesystem/inifile.h" #include "base/base.h" @@ -308,65 +309,6 @@ bool Base::load_world() return true; } -bool Base::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity) -{ - std::string shapename; - std::string strval; - float direction; - float pitch; - float roll; - - if (inifile.got_key_string("shape", shapename)) { - - if (shapename.compare("axis") == 0) { - entity->entity_shape = core::Entity::Axis; - return true; - } else if (shapename.compare("cube") == 0) { - entity->entity_shape = core::Entity::Cube; - return true; - } else if (shapename.compare("diamond") == 0) { - entity->entity_shape = core::Entity::Diamond; - return true; - } else if (shapename.compare("sphere") == 0) { - entity->entity_shape = core::Entity::Sphere; - return true; - } else { - con_warn << inifile.name() << " unknown shape '" << shapename << "' at line " << inifile.line() << std::endl; - return false; - } - - } else if (inifile.got_key_string("label", strval)) { - aux::to_label(strval); - entity->entity_label.assign(strval); - return true; - } else if (inifile.got_key_string("name", strval)) { - aux::strip_quotes(strval); - entity->entity_name.assign(strval); - return true; - } else if (inifile.got_key_string("model", entity->entity_modelname)) { - return true; - } else if (inifile.got_key_angle("direction", direction)) { - entity->axis().change_direction(direction); - return true; - } else if (inifile.got_key_angle("pitch", pitch)) { - entity->axis().change_pitch(pitch); - return true; - } else if (inifile.got_key_angle("roll", roll)) { - entity->axis().change_roll(roll); - return true; - } else if (inifile.got_key_angle("radius", entity->entity_radius)) { - return true; - } else if (inifile.got_key_vector3f("location", entity->entity_location)) { - return true; - } else if (inifile.got_key_color("color", entity->entity_color)) { - return true; - } else if (inifile.got_key_color("colorsecond", entity->entity_color_second)) { - return true; - } - - return false; -} - bool Base::load_zone(core::Zone *zone) { using math::Vector3f; @@ -417,7 +359,7 @@ bool Base::load_zone(core::Zone *zone) con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl; } } else if (zoneini.section().compare("star") == 0) { - if (got_entity_key(zoneini, star)) { + if (core::Parser::got_entity_key(zoneini, star)) { continue; } else if (zoneini.got_key_string("texture", star->entity_texture)) { continue; @@ -425,13 +367,13 @@ bool Base::load_zone(core::Zone *zone) con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl; } } else if (zoneini.section().compare("navpoint") == 0) { - if (got_entity_key(zoneini, navpoint)) { + if (core::Parser::got_entity_key(zoneini, navpoint)) { continue; } else { con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl; } } else if (zoneini.section().compare("jumppoint") == 0) { - if (got_entity_key(zoneini, jumppoint)) { + if (core::Parser::got_entity_key(zoneini, jumppoint)) { continue; } else if (zoneini.got_key_string("target", jumppoint->jumppoint_targetlabel)) { continue; @@ -439,7 +381,7 @@ bool Base::load_zone(core::Zone *zone) con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl; } } else if (zoneini.section().compare("planet") == 0) { - if (got_entity_key(zoneini, planet)) { + if (core::Parser::got_entity_key(zoneini, planet)) { continue; } else if (zoneini.got_key_string("texture", planet->entity_texture)) { continue; @@ -450,21 +392,21 @@ bool Base::load_zone(core::Zone *zone) } } else if (zoneini.section().compare("racetrack") == 0) { - if (got_entity_key(zoneini, racetrack)) { + if (core::Parser::got_entity_key(zoneini, racetrack)) { continue; } else { con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl; } } else if (zoneini.section().compare("checkpoint") == 0) { - if (got_entity_key(zoneini, checkpoint)) { + if (core::Parser::got_entity_key(zoneini, checkpoint)) { continue; } else { con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl; } } else if (zoneini.section().compare("entity") == 0) { - if (got_entity_key(zoneini, entity)) { + if (core::Parser::got_entity_key(zoneini, entity)) { continue; } else { con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl; diff --git a/src/game/base/base.h b/src/game/base/base.h index fea1919..db3e7d9 100644 --- a/src/game/base/base.h +++ b/src/game/base/base.h @@ -1,5 +1,5 @@ /* - game/game.h + base/base.h This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2 */ diff --git a/src/game/game.cc b/src/game/game.cc index 0b7e0f2..26214cf 100644 --- a/src/game/game.cc +++ b/src/game/game.cc @@ -12,6 +12,7 @@ namespace game { +/// register game modules void register_modules(bool register_client_modules) { con_print << "^BRegistering game modules..." << std::endl; diff --git a/src/game/intro/Makefile.am b/src/game/intro/Makefile.am index 66ea90d..fc5b019 100644 --- a/src/game/intro/Makefile.am +++ b/src/game/intro/Makefile.am @@ -1,2 +1,6 @@ -INCLUDES = -I$(top_srcdir)/src +INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/game METASOURCES = AUTO +libintro_la_LDFLAGS = -avoid-version +noinst_LTLIBRARIES = libintro.la +libintro_la_SOURCES = intro.cc +noinst_HEADERS = intro.h diff --git a/src/game/intro/intro.cc b/src/game/intro/intro.cc new file mode 100644 index 0000000..c0ae6da --- /dev/null +++ b/src/game/intro/intro.cc @@ -0,0 +1,59 @@ +/* + intro/intro.cc + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#include "intro/intro.h" +#include "sys/sys.h" + +namespace intro { + +Intro::Intro() : core::Module("Introduction") +{ + intro_zone = 0; +} + +Intro::~Intro() +{ +} + +void Intro::init() +{ + /// intialize a single zone for the introduction + intro_zone = new core::Zone("intro"); + intro_zone->set_name("Introduction"); + core::Zone::add(intro_zone); + + /// add a planet + core::EntityGlobe *planet = new core::EntityGlobe(); + planet->set_zone(intro_zone); + planet->set_name("Planet"); + planet->set_label("planet"); + planet->entity_texture.assign("planets/seymour"); + planet->entity_location.assign(0, -32.0f, 0.0f); + planet->entity_radius = 64.0f; + planet->entity_rotationspeed = 1.0f; + + module_running = true; +} + +void Intro::player_connect(core::Player *player) +{ + player->set_zone(intro_zone); +} + +void Intro::player_disconnect(core::Player *player) +{ +} + +void Intro::frame(float seconds) +{ +} + +void Intro::shutdown() +{ +} + +} + diff --git a/src/game/intro/intro.h b/src/game/intro/intro.h new file mode 100644 index 0000000..21dc604 --- /dev/null +++ b/src/game/intro/intro.h @@ -0,0 +1,47 @@ +/* + intro/intro.h + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#ifndef __INCLUDED_INTRO_H__ +#define __INCLUDED_INTRO_H__ + +#include "core/core.h" + +/// introduction game module +namespace intro +{ + +/// introduction game module +class Intro : public core::Module +{ +public: + /// create an introduction game module + Intro(); + /// delete an introduction game module + ~Intro(); + + /// run the introduction + void init(); + + /// shutdown the introduction + void shutdown(); + + /// run one frame + void frame(float seconds); + + /// is called when a player connects + void player_connect(core::Player *player); + + /// is called when a player disconnects + void player_disconnect(core::Player *player); + +private: + core::Zone *intro_zone; +}; + +} + +#endif // __INCLUDED_INTRO_H__ + |