From f794b9ee52293cefd6ac73fdf0d2a01c5388f057 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 31 Jan 2008 18:22:44 +0000 Subject: modular system works now --- src/game/game.cc | 74 +++++++++++++++++++++++--------------------------------- 1 file changed, 30 insertions(+), 44 deletions(-) (limited to 'src/game/game.cc') 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 -namespace game { +namespace game +{ Ship ship; Star star; @@ -28,31 +29,16 @@ std::string author; // author of the game // sectors in space std::vector 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 -- cgit v1.2.3