Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-09-28 21:34:53 +0000
committerStijn Buys <ingar@osirion.org>2008-09-28 21:34:53 +0000
commit9252bfb61fabea1f45afacb19d805eb5fdd01599 (patch)
tree13fdfb005ab0b690766d35572f0eeecca28f6009 /src/game/intro/intro.cc
parent6774f2b5d14c1957d163ef4b7914c2660b59fdfd (diff)
intro module
Diffstat (limited to 'src/game/intro/intro.cc')
-rw-r--r--src/game/intro/intro.cc98
1 files changed, 88 insertions, 10 deletions
diff --git a/src/game/intro/intro.cc b/src/game/intro/intro.cc
index c0ae6da..f5b4e2f 100644
--- a/src/game/intro/intro.cc
+++ b/src/game/intro/intro.cc
@@ -5,6 +5,11 @@
*/
#include "intro/intro.h"
+#include "core/core.h"
+#include "core/parser.h"
+#include "filesystem/filesystem.h"
+#include "filesystem/inifile.h"
+#include "math/color.h"
#include "sys/sys.h"
namespace intro {
@@ -12,6 +17,7 @@ namespace intro {
Intro::Intro() : core::Module("Introduction")
{
intro_zone = 0;
+ intro_convoy = 0;
}
Intro::~Intro()
@@ -23,21 +29,84 @@ void Intro::init()
/// intialize a single zone for the introduction
intro_zone = new core::Zone("intro");
intro_zone->set_name("Introduction");
+ intro_zone->set_sky("sky");
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;
+
+ intro_convoy = new Convoy(intro_zone);
+
+ if (!load_world()) {
+ abort();
+ return;
+ }
module_running = true;
}
+bool Intro::load_world()
+{
+ std::string filename("intro");
+
+ filesystem::IniFile ini;
+ ini.open(filename);
+
+ if (!ini.is_open()) {
+ con_error << "Could not open " << ini.name() << std::endl;
+ return false;
+ }
+
+ std::string strval;
+ core::EntityGlobe *globe = 0;
+ math::Color color;
+ bool b;
+
+ while (ini.getline()) {
+ if (ini.got_key()) {
+
+ if (ini.section().compare("intro") == 0) {
+ if (ini.got_key_string("sky", strval)) {
+ intro_zone->set_sky(strval);
+ continue;
+ }
+ } else if (ini.section().compare("convoy") == 0) {
+ if (ini.got_key_color("color", color)) {
+ intro_convoy->set_color(color);
+
+ } else if (ini.got_key_color("colorsecond", color)) {
+ intro_convoy->set_color_second(color);
+
+ } else if (ini.got_key_string("ship", strval)) {
+ intro_convoy->add(strval);
+ }
+
+ } else if (ini.section().compare("globe") == 0) {
+ if (core::Parser::got_entity_key(ini, globe)) {
+ continue;
+ } else if (ini.got_key_string("texture", globe->entity_texture)) {
+ continue;
+ } else if (ini.got_key_float("rotationspeed", globe->entity_rotationspeed)) {
+ continue;
+ } else if (ini.got_key_bool("bright", b)) {
+ if (b) { globe->entity_flags |= core::Entity::Bright; }
+ } else {
+ con_warn << ini.name() << " unknown key '" << ini.key() << "' at line " << ini.line() << std::endl;
+ }
+ }
+
+ } else if (ini.got_section("intro")) {
+ continue;
+
+ } else if (ini.got_section("globe")) {
+ globe = new core::EntityGlobe();
+ globe->set_zone(intro_zone);
+
+ } else if (ini.got_section()) {
+ con_warn << ini.name() << " unknown section '" << ini.section() << "' at line " << ini.line() << std::endl;
+ }
+ }
+
+ return true;
+}
+
void Intro::player_connect(core::Player *player)
{
player->set_zone(intro_zone);
@@ -49,10 +118,19 @@ void Intro::player_disconnect(core::Player *player)
void Intro::frame(float seconds)
{
+ if (intro_convoy) {
+ intro_convoy->frame(seconds);
+ }
}
void Intro::shutdown()
{
+ intro_zone = 0;
+
+ if (intro_convoy) {
+ delete intro_convoy;
+ intro_convoy = 0;
+ }
}
}