From babef2ec1d88b6057b0e17bf1c04dfa3c9d0d5a0 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 27 Oct 2007 13:17:31 +0000 Subject: conditional -DDEBUG messages --- src/client/client.cc | 10 ++++++---- src/client/console.cc | 6 +++--- src/common/console.h | 5 +++++ src/common/file.cc | 1 - src/game/game.cc | 19 ++++++++++++++----- src/game/game.h | 3 +++ src/server/main.cc | 1 - 7 files changed, 31 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/client/client.cc b/src/client/client.cc index 14e6bb5..f146a8f 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -17,11 +17,16 @@ namespace client { +// public instances Camera camera; View view; Video video; Input input; +// private instance of the client console object +Console clientconsole; + + void quit(int status) { SDL_Quit(); @@ -30,12 +35,9 @@ void quit(int status) void init() { - // initialize console - Console clientconsole; + // set clientconsole as the common console object common::Console::instance = &clientconsole; - conmesg << "Project::OSiRiON " << OSIRION_VERSION << std::endl; - // Initialize the video subsystem video.init(); if (!video.initialized) { diff --git a/src/client/console.cc b/src/client/console.cc index 21dde67..f270108 100644 --- a/src/client/console.cc +++ b/src/client/console.cc @@ -11,17 +11,17 @@ namespace client { std::ostream & Console::message() { - return std::cout; + return (std::cout << ". "); } std::ostream & Console::warning() { - return std::cerr; + return (std::cout << "! "); } std::ostream & Console::debug() { - return std::cout; + return (std::cout << "? "); } } // namespace client diff --git a/src/common/console.h b/src/common/console.h index 609c99a..5f80e73 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -14,8 +14,13 @@ #define conmesg common::Console::instance->message() /// global define to send a warning message to the system console #define conwarn common::Console::instance->warning() + +#ifdef DEBUG /// global define to send a debug message to the system console #define condebug common::Console::instance->debug() +#else +#define condebug if (0) *(std::ostream*)(0) +#endif // DEBUG namespace common { diff --git a/src/common/file.cc b/src/common/file.cc index d7603c3..822c678 100644 --- a/src/common/file.cc +++ b/src/common/file.cc @@ -57,7 +57,6 @@ void File::open(const char * filename, ios_base::openmode mode) fn.append(filename); std::ifstream::open(fn.c_str(), mode); - // FIXME console if (!this->is_open()) { condebug << "File could not open " << filename << std::endl; } else { diff --git a/src/game/game.cc b/src/game/game.cc index 0ac9acc..c6458d0 100644 --- a/src/game/game.cc +++ b/src/game/game.cc @@ -8,8 +8,11 @@ #include "ship.h" #include "star.h" +#include "common/console.h" #include "common/file.h" +#include "osirion.h" + namespace game { using common::File; @@ -23,10 +26,9 @@ bool initialized = false; // FIXME win32 void init() { - // load the world - star.location = Vector3f(256.0f, 0.0f, 256.0f); - ship.location = Vector3f(0,0,0); - + conmesg << "Project::OSiRiON " << OSIRION_VERSION << std::endl; + condebug << "Debug messages enabled" << std::endl; + // initialize game data locations // TODO create game::homedir if it doesn't exist File::datadir = "./data/"; @@ -36,9 +38,16 @@ void init() // read game.ini File f; - f.open("game.ini"); + f.open("ini/game.ini"); f.close(); + // load the world + f.open("ini/world.ini"); + f.close(); + + star.location = Vector3f(256.0f, 0.0f, 256.0f); + ship.location = Vector3f(0,0,0); + // all done, ready to run initialized = true; } diff --git a/src/game/game.h b/src/game/game.h index ed49135..b86e773 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -12,6 +12,9 @@ #include "common/console.h" /// The game engine +/*! + * The main game functions. The console should be initialized before calling these. + */ namespace game { /// initialize the game diff --git a/src/server/main.cc b/src/server/main.cc index 92b2dce..f49dbc2 100644 --- a/src/server/main.cc +++ b/src/server/main.cc @@ -23,7 +23,6 @@ int main( int argc, char *argv[] ) common::Console::instance = &serverconsole; const float server_framerate = 1.0f / 20.0f; - conmesg << "The Osirion project " << OSIRION_VERSION << std::endl; server::Timer timer; // initialize game -- cgit v1.2.3