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-01-31 18:22:44 +0000
committerStijn Buys <ingar@osirion.org>2008-01-31 18:22:44 +0000
commitf794b9ee52293cefd6ac73fdf0d2a01c5388f057 (patch)
tree2838d7ee11ae49e2e519ad604ba41f7071fb8288 /src/game/game.cc
parent1ddff2045848da5136e9e8131e335ac7626b8f68 (diff)
modular system works now
Diffstat (limited to 'src/game/game.cc')
-rw-r--r--src/game/game.cc74
1 files changed, 30 insertions, 44 deletions
diff --git a/src/game/game.cc b/src/game/game.cc
index 9fe1133..b2b0822 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -1,21 +1,22 @@
/*
game/game.cc
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
*/
// project headers
+#include "game/game.h"
#include "game/sector.h"
#include "game/ship.h"
#include "game/star.h"
#include "filesystem/filesystem.h"
-#include "filesystem/inifile.h"
#include "common/common.h"
// C++ headers
#include <vector>
-namespace game {
+namespace game
+{
Ship ship;
Star star;
@@ -28,31 +29,16 @@ 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 directory names
-void init()
+void Game::init()
{
- using namespace filesystem;
using math::Vector3f;
+ using filesystem::IniFile;
con_print << "Project::OSiRiON " << VERSION << std::endl;
con_debug << "Debug messages enabled" << std::endl;
- // initialize game data locations
- datadir = "./data/";
- basedir = "base/";
- moddir = "";
-
- // FIXME win32
- homedir = getenv("HOME");
- homedir = homedir + "/.osirion/";
- Path::create(homedir);
- Path::create(homedir+basedir);
- if (moddir.size() && !Path::exists(homedir+moddir))
- Path::create(homedir+moddir);
-
// read game.ini
- filesystem::IniFile f;
+ IniFile f;
f.open("ini/game.ini");
while (f) {
f.getline();
@@ -60,15 +46,15 @@ void init()
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
- con_warn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl;
+ // game::label
+ if (f.got_key_string("label", label)); else
+ // game::author
+ if (f.got_key_string("author", author)); else
+ // unknown value
+ con_warn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl;
}
} else if (f.got_section("game")) {
-
+
} else if (f.got_section()) {
con_warn << f.name() << " unknown section '" << f.section() << "' at line " << f.line() << std::endl;
}
@@ -88,21 +74,21 @@ void init()
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
- con_warn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl;
+ // world:label
+ if (f.got_key_string("label", tmp)); else
+ // unknown value
+ con_warn << 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
- con_warn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl;
+ // sector:label
+ if (f.got_key_string("label", tmp)) {
+ sector->label = tmp;
+ } else
+ // unknown value
+ con_warn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl;
}
} else if (f.got_section("world")) {
con_debug << "[world] section" << std::endl;
@@ -123,13 +109,13 @@ void init()
ship.location = Vector3f(0,0,0);
// all done, ready to run
- initialized = true;
+ initialized = true;
}
-void shutdown()
+void Game::shutdown()
{
initialized = false;
-
+
// delete every sector object in the sectors vector
for (unsigned int n =0; n< sectors.size(); n++) {
delete sectors[n];
@@ -139,9 +125,9 @@ void shutdown()
sectors.clear();
}
-void update(float elapsed)
+void Game::frame(float elapsed)
{
ship.update(elapsed);
}
-
+
}; // namespace game