Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-11-13 21:44:04 +0000
committerStijn Buys <ingar@osirion.org>2010-11-13 21:44:04 +0000
commitc86b4142ff8adc8fc14f58d603b116dfd8ea6515 (patch)
tree21076e7db33a4532949337f153e9c38c85c2c62a /src/game
parentb68389e450d537eed51683515d1c4d6f7450caf2 (diff)
added jumppoint and jumpgate templates, corrected a number of potentional
radius related bugs
Diffstat (limited to 'src/game')
-rw-r--r--src/game/base/game.cc10
-rw-r--r--src/game/base/jumppoint.cc28
-rw-r--r--src/game/base/jumppoint.h20
-rw-r--r--src/game/base/navpoint.cc8
-rw-r--r--src/game/base/template.cc13
5 files changed, 59 insertions, 20 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index c8f3cc6..d97d23b 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -1106,21 +1106,18 @@ bool Game::load_zone(core::Zone *zone)
navpoint = new NavPoint();
entity = navpoint;
navpoint->set_zone(zone);
- navpoint->set_radius(0);
count ++;
} else if (zoneini.got_section("jumpgate")) {
jumppoint = new JumpGate();
entity = jumppoint;
jumppoint->set_zone(zone);
- jumppoint->set_radius(0);
count ++;
} else if (zoneini.got_section("jumppoint")) {
jumppoint = new JumpPoint();
entity = jumppoint;
jumppoint->set_zone(zone);
- jumppoint->set_radius(0);
count ++;
} else if (zoneini.got_section("racetrack")) {
@@ -1220,6 +1217,13 @@ bool Game::load_zone(core::Zone *zone)
} else if (zoneini.in_section("navpoint")) {
if (core::Parser::got_entity_key(zoneini, navpoint)) {
continue;
+ } else if (zoneini.got_key_label("faction", strval)) {
+ Faction *faction = Faction::find(strval);
+ if (!faction) {
+ zoneini.unknown_error("unkown faction '" + strval + "'");
+ } else {
+ faction->apply(navpoint);
+ }
} else {
zoneini.unkown_key();
}
diff --git a/src/game/base/jumppoint.cc b/src/game/base/jumppoint.cc
index e52873e..1f2c0a9 100644
--- a/src/game/base/jumppoint.cc
+++ b/src/game/base/jumppoint.cc
@@ -12,16 +12,24 @@ namespace game
/* ---- class JumpPoint -------------------------------------------- */
+const Template *JumpPoint::jumppoint_template = 0;
+
JumpPoint::JumpPoint() : core::EntityDynamic()
{
set_shape(core::Entity::Diamond);
+
+ // FIXME jumppoints should be harder to find
+ set_flag(core::Entity::ShowOnMap);
+
get_color().assign(0.0f, 0.8f, 0.8f, 1.0f);
get_color_second().assign(0.6f, 1.0f);
set_radius(0.25f);
+
set_flag(core::Entity::Bright);
- // FIXME jumppoints should be harder to find
- set_flag(core::Entity::ShowOnMap);
-
+
+ if (jumppoint_template)
+ jumppoint_template->apply(this);
+
entity_moduletypeid = jumppoint_enttype;
jumppoint_target = 0;
set_serverside(false);
@@ -94,15 +102,19 @@ void JumpPoint::validate()
/* ---- class JumpGate --------------------------------------------- */
+const Template *JumpGate::jumpgate_template = 0;
+
JumpGate::JumpGate() : JumpPoint()
{
+ entity_moduletypeid = jumpgate_enttype;
unset_flag(core::Entity::Bright);
set_flag(core::Entity::ShowOnMap);
- set_radius(1.0f);
-
- entity_moduletypeid = jumpgate_enttype;
- entity_state = core::Entity::NoPower;
-
+ set_radius(0.0f);
+ set_state(core::Entity::NoPower);
+
+ if (jumpgate_template)
+ jumpgate_template->apply(this);
+
jumpgate_timer = 0;
}
diff --git a/src/game/base/jumppoint.h b/src/game/base/jumppoint.h
index cb3ee28..40f9e5d 100644
--- a/src/game/base/jumppoint.h
+++ b/src/game/base/jumppoint.h
@@ -7,11 +7,12 @@
#ifndef __INCLUDED_BASE_JUMPPOINT_H__
#define __INCLUDED_BASE_JUMPPOINT_H__
-#include "core/entity.h"
-#include "math/mathlib.h"
-
#include <string>
+#include "math/mathlib.h"
+#include "core/entity.h"
+#include "base/template.h"
+
namespace game
{
@@ -43,10 +44,16 @@ public:
/// validate the targetlabel and set target()
virtual void validate();
+
+ static inline void set_template (const Template *entitytemplate) {
+ jumppoint_template = entitytemplate;
+ }
private:
std::string jumppoint_targetlabel;
JumpPoint *jumppoint_target;
+
+ static const Template *jumppoint_template;
};
/// a jumpgate
@@ -69,8 +76,15 @@ public:
void activate();
virtual void frame(float elapsed);
+
+ static inline void set_template (const Template *entitytemplate) {
+ jumpgate_template = entitytemplate;
+ }
+
private:
float jumpgate_timer;
+
+ static const Template *jumpgate_template;
};
}
diff --git a/src/game/base/navpoint.cc b/src/game/base/navpoint.cc
index f7d6046..ccfb3d8 100644
--- a/src/game/base/navpoint.cc
+++ b/src/game/base/navpoint.cc
@@ -14,18 +14,14 @@ const Template *NavPoint::navpoint_template = 0;
NavPoint::NavPoint() : core::Entity()
{
- set_shape(core::Entity::Diamond);
- get_color().assign(1.0f, 1.0f);
- get_color_second().assign(0.6f, 1.0f);
- set_radius(0.25f);
-
entity_moduletypeid = navpoint_enttype;
+ set_shape(core::Entity::Diamond);
+ set_radius(0.25);
// use template settings if available
if (navpoint_template) {
navpoint_template->apply(this);
}
-
}
NavPoint::~NavPoint()
diff --git a/src/game/base/template.cc b/src/game/base/template.cc
index 7327c31..04c8058 100644
--- a/src/game/base/template.cc
+++ b/src/game/base/template.cc
@@ -9,6 +9,7 @@
#include "base/template.h"
#include "base/cargopod.h"
#include "base/navpoint.h"
+#include "base/jumppoint.h"
namespace game {
@@ -139,6 +140,18 @@ bool Template::init()
if (!entitytemplate) {
con_warn << "Template 'navpoint' not found!" << std::endl;
}
+
+ entitytemplate = Template::find(std::string("jumppoint"));
+ JumpPoint::set_template(entitytemplate);
+ if (!entitytemplate) {
+ con_warn << "Template 'jumppoint' not found!" << std::endl;
+ }
+
+ entitytemplate = Template::find(std::string("jumpgate"));
+ JumpGate::set_template(entitytemplate);
+ if (!entitytemplate) {
+ con_warn << "Template 'jumpgate' not found!" << std::endl;
+ }
con_debug << " " << inifile.name() << " " << count << " entity templates" << std::endl;