From bac8343bbc9f1e4cf97a561c732054539f21f03d Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 30 Jan 2008 17:35:04 +0000 Subject: accomodate the new modules --- src/game/Makefile.am | 12 +++++---- src/game/game.cc | 70 +++++++++++++++++++++++++--------------------------- src/game/game.h | 11 +++++---- src/game/player.h | 9 ++++--- src/game/sector.cc | 2 +- src/game/ship.cc | 8 +++--- src/game/ship.h | 11 +++++---- src/game/star.h | 18 +++++++------- src/game/world.h | 4 +-- 9 files changed, 73 insertions(+), 72 deletions(-) (limited to 'src/game') diff --git a/src/game/Makefile.am b/src/game/Makefile.am index fc1b23e..4268c84 100644 --- a/src/game/Makefile.am +++ b/src/game/Makefile.am @@ -1,9 +1,11 @@ - +INCLUDES = -I$(top_srcdir)/src METASOURCES = AUTO -libgame_la_LDFLAGS = -avoid-version -no-undefined -noinst_LTLIBRARIES = libgame.la +libgame_la_LDFLAGS = -avoid-version -no-undefined libgame_la_SOURCES = game.cc sector.cc ship.cc shipspecs.cc star.cc -INCLUDES = -I$(top_srcdir)/src -libgame_la_LIBADD = $(top_builddir)/src/common/libcommon.la +libgame_la_LIBADD = $(top_builddir)/src/common/libcommon.la \ + $(top_builddir)/src/math/libmath.la \ + $(top_builddir)/src/filesystem/libfilesystem.la + +noinst_LTLIBRARIES = libgame.la noinst_HEADERS = game.h player.h sector.h ship.h shipspecs.h star.h world.h diff --git a/src/game/game.cc b/src/game/game.cc index cd80889..9fe1133 100644 --- a/src/game/game.cc +++ b/src/game/game.cc @@ -5,15 +5,12 @@ */ // project headers -#include "sector.h" -#include "ship.h" -#include "star.h" - -#include "common/console.h" -#include "common/inifile.h" -#include "common/path.h" - -#include "osirion.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 @@ -35,28 +32,27 @@ std::vector sectors; // FIXME win32 directory names void init() { - using common::File; - using common::Path; - using common::IniFile; - using common::Vector3f; + using namespace filesystem; + using math::Vector3f; - conmesg << "Project::OSiRiON " << OSIRION_VERSION << std::endl; - condebug << "Debug messages enabled" << std::endl; + con_print << "Project::OSiRiON " << VERSION << std::endl; + con_debug << "Debug messages enabled" << std::endl; // initialize game data locations - File::datadir = "./data/"; - File::basedir = "base/"; - File::moddir = ""; + datadir = "./data/"; + basedir = "base/"; + moddir = ""; // FIXME win32 - File::homedir = getenv("HOME"); - File::homedir = File::homedir + "/.osirion/"; - Path::create(File::homedir); - Path::create(File::homedir+File::basedir); - if (File::moddir.size()) Path::create(File::homedir+File::moddir); + 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 - IniFile f; + filesystem::IniFile f; f.open("ini/game.ini"); while (f) { f.getline(); @@ -69,17 +65,17 @@ void init() // 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; + 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()) { - conwarn << f.name() << " unknown section '" << f.section() << "' at line " << f.line() << std::endl; + con_warn << f.name() << " unknown section '" << f.section() << "' at line " << f.line() << std::endl; } } f.close(); - conmesg << "game.ini loaded " << name << " [" << label << "] by " << author << std::endl; + con_print << "game.ini loaded " << name << " [" << label << "] by " << author << std::endl; // read world.ini std::string tmp; @@ -95,7 +91,7 @@ void init() // 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; + 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)) { @@ -106,22 +102,22 @@ void init() sector->label = tmp; } else // unknown value - conwarn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl; + con_warn << f.name() << " unknown key '" << f.key() << "' at line " << f.line() << std::endl; } } else if (f.got_section("world")) { - condebug << "[world] section" << std::endl; + con_debug << "[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; + con_warn << 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; + con_print << "Load sectors" << std::endl; + for (unsigned n =0; n < sectors.size(); n++) + con_print << sectors[n]->label << " " << sectors[n]->name << std::endl; star.location = Vector3f(256.0f, 0.0f, 256.0f); ship.location = Vector3f(0,0,0); @@ -135,9 +131,9 @@ 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; + for (unsigned int n =0; n< sectors.size(); n++) { + delete sectors[n]; + sectors[n] = 0; } // clear the sectors vector sectors.clear(); diff --git a/src/game/game.h b/src/game/game.h index b86e773..f2a0eab 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -7,12 +7,13 @@ #ifndef __INCLUDED_GAME_H__ #define __INCLUDED_GAME_H__ -#include "ship.h" -#include "star.h" -#include "common/console.h" +#include "game/ship.h" +#include "game/star.h" -/// The game engine -/*! +#include "common/common.h" + +/// the game engine +/** * The main game functions. The console should be initialized before calling these. */ namespace game diff --git a/src/game/player.h b/src/game/player.h index d2f2316..0fdec76 100644 --- a/src/game/player.h +++ b/src/game/player.h @@ -4,14 +4,14 @@ the terms and conditions of the GNU General Public License version 2 */ -#ifndef __INCLUDED_PLAYER_H__ -#define __INCLUDED_PLAYER_H__ +#ifndef __INCLUDED_GAME_PLAYER_H__ +#define __INCLUDED_GAME_PLAYER_H__ #include namespace game { -/// A player in the game +/// a player in the game class Player { public: Player(); @@ -23,4 +23,5 @@ public: } // namespace game -#endif // __INCLUDED_PLAYER_H__ +#endif // __INCLUDED_GAME_PLAYER_H__ + diff --git a/src/game/sector.cc b/src/game/sector.cc index 68938c2..a7a97b8 100644 --- a/src/game/sector.cc +++ b/src/game/sector.cc @@ -5,7 +5,7 @@ */ // project headers -#include "sector.h" +#include "game/sector.h" namespace game { diff --git a/src/game/ship.cc b/src/game/ship.cc index 049283f..fc18375 100644 --- a/src/game/ship.cc +++ b/src/game/ship.cc @@ -5,14 +5,14 @@ */ // project headers -#include "ship.h" -#include "common/functions.h" +#include "game/ship.h" +#include "math/mathlib.h" // C++ headers #include -using common::degrees360f; -using common::degrees180f; +using math::degrees360f; +using math::degrees180f; namespace game { diff --git a/src/game/ship.h b/src/game/ship.h index 8c65264..d420f67 100644 --- a/src/game/ship.h +++ b/src/game/ship.h @@ -4,11 +4,11 @@ the terms and conditions of the GNU General Public License version 2 */ -#ifndef __INCLUDED_SHIP_H__ -#define __INCLUDED_SHIP_H__ +#ifndef __INCLUDED_GAME_SHIP_H__ +#define __INCLUDED_GAME_SHIP_H__ // project headers -#include "common/vector3f.h" +#include "math/vector3f.h" namespace game { @@ -22,7 +22,7 @@ public: void update(float elapsed); /// location of the ship in space - common::Vector3f location; + math::Vector3f location; /// speed vector in units/second float speed; @@ -56,4 +56,5 @@ private: } // namespace game -#endif // __INCLUDED_SHIP_H__ +#endif // __INCLUDED_GAME_SHIP_H__ + diff --git a/src/game/star.h b/src/game/star.h index e65a9fb..70ce2aa 100644 --- a/src/game/star.h +++ b/src/game/star.h @@ -4,31 +4,31 @@ the terms and conditions of the GNU General Public License version 2 */ -#ifndef __INCLUDED_STAR_H__ -#define __INCLUDED_STAR_H__ +#ifndef __INCLUDED_GAME_STAR_H__ +#define __INCLUDED_GAME_STAR_H__ // project headers -#include "common/vector3f.h" -#include "common/color.h" +#include "math/mathlib.h" // C++ headers #include namespace game { -/// A star, that shines so bright +/// a star, that shines so bright class Star { public: Star(); ~Star(); - common::Vector3f location; - common::Color color; + math::Vector3f location; + math::Color color; float radius; std::string name; }; -} // namespace game +} + +#endif // __INCLUDED_GAME_STAR_H__ -#endif // __INCLUDED_STAR_H__ diff --git a/src/game/world.h b/src/game/world.h index 27909fc..11a80fc 100644 --- a/src/game/world.h +++ b/src/game/world.h @@ -9,10 +9,10 @@ #include -namespace game +namespace Game { -/// The game world +/// the game world class World { /// load the intial game world into memory static void init(); -- cgit v1.2.3