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-12-21 18:03:58 +0000
committerStijn Buys <ingar@osirion.org>2008-12-21 18:03:58 +0000
commit164e3c5b1cd9e6d6f7ca26964df4c54394eb1c84 (patch)
treec34e7e7747d8f76a4161a045d406c05dcbb227a3 /src/game/intro/intro.cc
parentcf1f5b659873c7eb1557ce7cedc17eed6ca03185 (diff)
multiple introductions
Diffstat (limited to 'src/game/intro/intro.cc')
-rw-r--r--src/game/intro/intro.cc98
1 files changed, 64 insertions, 34 deletions
diff --git a/src/game/intro/intro.cc b/src/game/intro/intro.cc
index ed512ca..edb80d4 100644
--- a/src/game/intro/intro.cc
+++ b/src/game/intro/intro.cc
@@ -21,21 +21,15 @@ core::Module *factory()
Intro::Intro() : core::Module("Introduction", false)
{
- intro_zone = 0;
- intro_convoy = 0;
-
- /// 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);
-
- intro_convoy = new Convoy(intro_zone);
-
if (!load_world()) {
abort();
return;
}
+
+ core::Func *func = 0;
+
+ func = core::Func::add("intro", Intro::func_intro);
+ func->set_info("[int] view specified introduction");
}
bool Intro::load_world()
@@ -50,6 +44,9 @@ bool Intro::load_world()
return false;
}
+ core::Zone *zone = 0;
+ Convoy *convoy = 0;
+
std::string strval;
core::EntityGlobe *globe = 0;
math::Color color;
@@ -61,53 +58,69 @@ bool Intro::load_world()
if (ini.got_section()) {
if (ini.got_section("intro")) {
- continue;
+
+ zone = new core::Zone("intro");
+ zone->set_name("Introduction");
+ zone->set_sky("sky");
+ core::Zone::add(zone);
} else if (ini.got_section("convoy")) {
- continue;
+ if (zone) {
+ convoy = new Convoy(zone);
+ }
} else if (ini.got_section("globe")) {
- globe = new core::EntityGlobe();
- globe->set_zone(intro_zone);
+ if (zone) {
+ globe = new core::EntityGlobe();
+ globe->set_zone(zone);
+ }
} else {
ini.unknown_section();
}
- } else if (ini.got_key()) {
+ } else if (zone && ini.got_key()) {
if (ini.in_section("intro")) {
- if (ini.got_key_string("sky", strval)) {
- intro_zone->set_sky(strval);
- continue;
+
+ if (ini.got_key_string("label", strval)) {
+ zone->set_label(strval);
+
+ } else if (ini.got_key_string("sky", strval)) {
+ zone->set_sky(strval);
} else if (ini.got_key()) {
ini.unkown_key();
}
} else if (ini.in_section("convoy")) {
- if (ini.got_key_color("color", color)) {
- intro_convoy->set_color(color);
+
+ if (ini.got_key_string("label", strval)) {
+ convoy->set_label(strval);
+
+ } else if (ini.got_key_color("color", color)) {
+ convoy->set_color(color);
} else if (ini.got_key_color("colorsecond", color)) {
- intro_convoy->set_color_second(color);
+ convoy->set_color_second(color);
} else if (ini.got_key_vector3f("location", v)) {
- intro_convoy->set_location(v);
+ convoy->entity_location.assign(v);
} else if (ini.got_key_float("direction", f)) {
- intro_convoy->change_direction(f);
+ convoy->axis().change_direction(f);
} else if (ini.got_key_float("speed", f)) {
- intro_convoy->set_speed(f);
+ convoy->entity_speed = f;
} else if (ini.got_key_string("ship", strval)) {
- intro_convoy->add(strval);
+ convoy->add(strval);
} else if (ini.got_key()) {
ini.unkown_key();
}
} else if (ini.in_section("globe")) {
+
if (core::Parser::got_entity_key(ini, globe)) {
continue;
} else if (ini.got_key_string("texture", globe->entity_texture)) {
@@ -128,27 +141,44 @@ bool Intro::load_world()
void Intro::player_connect(core::Player *player)
{
- player->set_zone(intro_zone);
+ core::Zone::Registry::iterator it = core::Zone::registry().begin();
+ if (it != core::Zone::registry().end()) {
+ size_t m = math::randomi(core::Zone::registry().size());
+ for (size_t i = 0; i < m; i++) {
+ it++;
+ }
+ player->set_zone((*it).second);
+ }
}
void Intro::player_disconnect(core::Player *player)
{
+
}
void Intro::frame(float seconds)
{
- if (intro_convoy) {
- intro_convoy->frame(seconds);
- }
+
}
Intro::~Intro()
{
- intro_zone = 0;
+ core::Func::remove("intro");
+}
- if (intro_convoy) {
- delete intro_convoy;
- intro_convoy = 0;
+void Intro::func_intro(core::Player *player, std::string const &args)
+{
+ std::stringstream str(args);
+ size_t id;
+ if (str >> id) {
+ core::Zone *zone = core::Zone::find(id);
+ if (zone) {
+ player->set_zone(zone);
+ } else {
+ core::Zone::list();
+ }
+ } else {
+ core::Zone::list();
}
}