Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/game.cc93
-rw-r--r--src/game/sector.cc22
-rw-r--r--src/game/ship.h5
3 files changed, 111 insertions, 9 deletions
diff --git a/src/game/game.cc b/src/game/game.cc
index c6458d0..cbde6b0 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -5,27 +5,39 @@
*/
// project headers
+#include "sector.h"
#include "ship.h"
#include "star.h"
#include "common/console.h"
-#include "common/file.h"
+#include "common/inifile.h"
#include "osirion.h"
-namespace game {
+// C++ headers
+#include <vector>
-using common::File;
-using common::Vector3f;
+namespace game {
Ship ship;
Star star;
bool initialized = false;
+std::string name; // name of the game
+std::string label; // label of the game
+std::string author; // author of the game
+
+// sectors in space
+std::vector<Sector*> sectors;
+
// TODO datadir should by set by ./configure and read from config.h
-// FIXME win32
+// FIXME win32 directory names
void init()
{
+ using common::File;
+ using common::IniFile;
+ using common::Vector3f;
+
conmesg << "Project::OSiRiON " << OSIRION_VERSION << std::endl;
condebug << "Debug messages enabled" << std::endl;
@@ -37,14 +49,73 @@ void init()
File::moddir = "";
// read game.ini
- File f;
+ IniFile f;
f.open("ini/game.ini");
+ while (f) {
+ f.getline();
+ if (f.got_key()) {
+ if (f.section() == "game") {
+ // game::name
+ if (f.got_key_string("name", name)); else
+ // game::label
+ if (f.got_key_string("label", label)); else
+ // game::author
+ if (f.got_key_string("author", author)); else
+ // unknown value
+ conwarn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl;
+ }
+ } else if (f.got_section("game")) {
+
+ } else if (f.got_section()) {
+ conwarn << f.name() << " unknown section '" << f.section() << "' at line " << f.line() << std::endl;
+ }
+ }
f.close();
- // load the world
+ conmesg << "game.ini loaded " << name << " [" << label << "] by " << author << std::endl;
+
+ // read world.ini
+ std::string tmp;
+ Sector *sector =0;
+
f.open("ini/world.ini");
+ while (f) {
+ f.getline();
+ if (f.got_key()) {
+ if (f.section() == "world") {
+ // world::name
+ if (f.got_key_string("name", tmp)); else
+ // world:label
+ if (f.got_key_string("label", tmp)); else
+ // unknown value
+ conwarn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl;
+ } else if (f.section() == "sector") {
+ // sector::name
+ if (f.got_key_string("name", tmp)) {
+ sector->name = tmp;
+ } else
+ // sector:label
+ if (f.got_key_string("label", tmp)) {
+ sector->label = tmp;
+ } else
+ // unknown value
+ conwarn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl;
+ }
+ } else if (f.got_section("world")) {
+ condebug << "[world] section" << std::endl;
+ } else if (f.got_section("sector")) {
+ sector = new Sector();
+ sectors.push_back(sector);
+ } else if (f.got_section()) {
+ conwarn << f.name() << " unknown section '" << f.section() << "' at line " << f.line() << std::endl;
+ }
+ }
f.close();
+ conmesg << "Load sectors" << std::endl;
+ for (int i =0; i < sectors.size(); i++)
+ conmesg << sectors[i]->label << " " << sectors[i]->name << std::endl;
+
star.location = Vector3f(256.0f, 0.0f, 256.0f);
ship.location = Vector3f(0,0,0);
@@ -55,6 +126,14 @@ void init()
void shutdown()
{
initialized = false;
+
+ // delete every sector object in the sectors vector
+ for (int i =0; i< sectors.size(); i++) {
+ delete sectors[i];
+ sectors[i] = 0;
+ }
+ // clear the sectors vector
+ sectors.clear();
}
void update(float elapsed)
diff --git a/src/game/sector.cc b/src/game/sector.cc
new file mode 100644
index 0000000..68938c2
--- /dev/null
+++ b/src/game/sector.cc
@@ -0,0 +1,22 @@
+/*
+ game/sector.cc
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
+*/
+
+// project headers
+#include "sector.h"
+
+namespace game {
+
+Sector::Sector()
+{
+ label = "";
+ name = "";
+}
+
+Sector::~Sector()
+{
+}
+
+} // namespace game
diff --git a/src/game/ship.h b/src/game/ship.h
index ac38547..8c65264 100644
--- a/src/game/ship.h
+++ b/src/game/ship.h
@@ -45,10 +45,11 @@ public:
float yaw_speed;
private:
- /// current yaw, angle in the x/z plane
+ /// current yaw, angle in XZ plane, 0-360
float yaw_current;
- /// target yaw angle
+ /// target yaw angle, angle in XYplane, 0-360
float yaw_target;
+
/// current thruster power in % [0-1]
float thrust_current;
};