Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--INSTALL15
-rw-r--r--README15
-rw-r--r--configure.in6
-rw-r--r--osirion.kdevelop22
-rw-r--r--osirion.kdevelop.pcsbin217050 -> 235690 bytes
-rw-r--r--osirion.kdevses31
-rw-r--r--src/Makefile.am13
-rw-r--r--src/client/Makefile.am22
-rw-r--r--src/client/console.h4
-rw-r--r--src/client/main.cc14
-rw-r--r--src/client/video.cc2
-rw-r--r--src/client/view.cc4
-rw-r--r--src/core/Makefile.am5
-rw-r--r--src/core/applicationinterface.cc28
-rw-r--r--src/core/applicationinterface.h3
-rw-r--r--src/filesystem/Makefile.am3
-rw-r--r--src/filesystem/file.cc2
-rw-r--r--src/filesystem/filesystem.cc2
-rw-r--r--src/filesystem/path.cc18
-rw-r--r--src/game/Makefile.am6
-rw-r--r--src/game/game.cc2
-rw-r--r--src/game/game.h2
-rw-r--r--src/gl/Makefile.am1
-rw-r--r--src/gl/gllib.cc2
-rw-r--r--src/server/Makefile.am13
-rw-r--r--src/server/application.cc14
-rw-r--r--src/server/application.h3
-rw-r--r--src/server/console.h4
-rw-r--r--src/server/main.cc14
-rw-r--r--src/server/server.cc2
-rw-r--r--src/server/server.h2
-rw-r--r--src/sys/Makefile.am4
-rw-r--r--src/sys/consoleinterface.cc35
-rw-r--r--src/sys/consoleinterface.h59
-rw-r--r--src/sys/sys.cc19
-rw-r--r--src/sys/sys.h10
36 files changed, 263 insertions, 138 deletions
diff --git a/INSTALL b/INSTALL
index 25bbf54..1ee3364 100644
--- a/INSTALL
+++ b/INSTALL
@@ -11,16 +11,17 @@ I have succesfully compiled it on the following platforms:
Compile the source by executing the following commands:
-autoreconf -fi
-./configure
-make
+ autoreconf -fi
+ ./configure
+ make
-To run the program execute:
+To run the client program, execute:
-src/client/osirion
+ src/osirion
-To run the dedicated server:
-src/server/osiriond
+To run the dedicated server, execute:
+
+ src/osiriond
The game data files should be located in the subdirectory
data/base of the main distribution.
diff --git a/README b/README
index 6f75ff3..0b6a919 100644
--- a/README
+++ b/README
@@ -17,18 +17,23 @@ Organization of the distribution
src/ C++ source code
- client\ osirion client
- common\ General utility classes
- game\ Game engine, used by client and server
- gl\ OpenGL library, used by client
+ math\ mathematical classes
+ sys\ low-level system functions
+ filesystem\ virtual filesystem
+ core\ game-independent core classes
+ game\ game-specific functions
server\ osiriond dedicated server
+ gl\ OpenGL wrapper library
+ client\ osirion client
data/ Data files
base\ main data files
License
+
The program is distributed under the terms and conditions of the
GNU General Public License version 2.
+ Copyright 2007-2008
+ Ingar <ingar@telenet.be>
-Ingar <ingar@telenet.be>
diff --git a/configure.in b/configure.in
index c7b243a..e4854e4 100644
--- a/configure.in
+++ b/configure.in
@@ -136,9 +136,9 @@ AC_SUBST(LIBSDL_RPATH)
CXXFLAGS="-pipe $DEBUG_CFLAGS $WARN_CFLAGS $CXXFLAGS"
AC_SUBST(CXXFLAGS)
-AC_OUTPUT(Makefile src/Makefile src/client/Makefile src/common/Makefile \
- src/core/Makefile src/filesystem/Makefile src/game/Makefile src/gl/Makefile src/math/Makefile \
- src/server/Makefile src/sys/Makefile)
+AC_OUTPUT(Makefile src/Makefile src/client/Makefile src/core/Makefile \
+ src/filesystem/Makefile src/game/Makefile src/gl/Makefile src/math/Makefile src/server/Makefile \
+ src/sys/Makefile)
AC_MSG_RESULT([
The Osirion Project $VERSION
diff --git a/osirion.kdevelop b/osirion.kdevelop
index 35ce71d..7032509 100644
--- a/osirion.kdevelop
+++ b/osirion.kdevelop
@@ -16,12 +16,12 @@
<projectdirectory>./</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description>The OSiRiON Project is an SDL+OpenGL space game.</description>
- <defaultencoding></defaultencoding>
+ <defaultencoding/>
<versioncontrol>kdevsubversion</versioncontrol>
</general>
<kdevautoproject>
<general>
- <activetarget>src/server/osiriond</activetarget>
+ <activetarget>src/sys/libsys.la</activetarget>
<useconfiguration>debug</useconfiguration>
</general>
<run>
@@ -37,8 +37,8 @@
<osirion></osirion>
</debugarguments>
<cwd>
- <osiriond>/home/ingar/projects/osirion/debug/./src/game</osiriond>
- <osirion>/home/ingar/projects/osirion/debug/./src/client</osirion>
+ <osiriond>/home/ingar/projects/osirion/osirion-work/debug/src/</osiriond>
+ <osirion>/home/ingar/projects/osirion/osirion-work/debug/src/</osirion>
</cwd>
<programargs/>
<globaldebugarguments/>
@@ -81,7 +81,7 @@
<runmultiplejobs>false</runmultiplejobs>
<numberofjobs>2</numberofjobs>
<dontact>false</dontact>
- <makebin></makebin>
+ <makebin/>
<prio>0</prio>
</make>
</kdevautoproject>
@@ -196,7 +196,7 @@
<designerpluginpaths/>
</qt>
<creategettersetter>
- <prefixGet></prefixGet>
+ <prefixGet/>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>
@@ -228,11 +228,11 @@
</cppsupportpart>
<kdevdebugger>
<general>
- <gdbpath></gdbpath>
- <dbgshell></dbgshell>
- <configGdbScript></configGdbScript>
- <runShellScript></runShellScript>
- <runGdbScript></runGdbScript>
+ <gdbpath/>
+ <dbgshell/>
+ <configGdbScript/>
+ <runShellScript/>
+ <runGdbScript/>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs
index 5a814c9..67d2f75 100644
--- a/osirion.kdevelop.pcs
+++ b/osirion.kdevelop.pcs
Binary files differ
diff --git a/osirion.kdevses b/osirion.kdevses
index 5fce955..753d24f 100644
--- a/osirion.kdevses
+++ b/osirion.kdevses
@@ -1,13 +1,34 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
- <DocsAndViews NumberOfDocuments="2" >
- <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/game/Makefile.am" >
- <View0 Encoding="" line="0" Type="Source" />
+ <DocsAndViews NumberOfDocuments="9" >
+ <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/filesystem/file.cc" >
+ <View0 Encoding="" line="7" Type="Source" />
</Doc0>
- <Doc1 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/game/game.cc" >
- <View0 Encoding="" line="27" Type="Source" />
+ <Doc1 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/filesystem/filesystem.cc" >
+ <View0 Encoding="" line="22" Type="Source" />
</Doc1>
+ <Doc2 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/filesystem/path.cc" >
+ <View0 Encoding="" line="18" Type="Source" />
+ </Doc2>
+ <Doc3 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/applicationinterface.cc" >
+ <View0 Encoding="" line="8" Type="Source" />
+ </Doc3>
+ <Doc4 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/game/game.h" >
+ <View0 Encoding="" line="13" Type="Source" />
+ </Doc4>
+ <Doc5 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/game/game.cc" >
+ <View0 Encoding="" line="23" Type="Source" />
+ </Doc5>
+ <Doc6 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/gl/gllib.cc" >
+ <View0 Encoding="" line="8" Type="Source" />
+ </Doc6>
+ <Doc7 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/video.cc" >
+ <View0 Encoding="" line="8" Type="Source" />
+ </Doc7>
+ <Doc8 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/view.cc" >
+ <View0 Encoding="" line="45" Type="Source" />
+ </Doc8>
</DocsAndViews>
<pluginList>
<kdevdebugger>
diff --git a/src/Makefile.am b/src/Makefile.am
index ad350fc..cd06cd7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,17 @@
# set the include path found by configure
AM_CPPFLAGS = $(DEBUG_CFLAGS) $(WARN_CFLAGS) $(all_includes)
+INCLUDES = -I$(top_srcdir)/src
+SUBDIRS = math sys filesystem core game server gl client
-SUBDIRS = math common sys filesystem core game server gl client
+noinst_HEADERS = config.h
+bin_PROGRAMS = osiriond osirion
+# dedicated server
+osiriond_SOURCES = osiriond.cc
+osiriond_LDADD = $(top_builddir)/src/server/libserver.la
+# client
+osirion_SOURCES = osirion.cc
+osirion_CFLAGS = $(LIBSDL_CFLAGS) $(GL_CFLAGS)
+osirion_LDADD = $(top_builddir)/src/client/libclient.la
+osirion_LDFLAGS = $(LIBSDL_LIBS) $(GL_LIBS)
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index 9807963..f1a3f9d 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -1,17 +1,13 @@
-
METASOURCES = AUTO
-bin_PROGRAMS = osirion
-
-osirion_LDADD = $(top_builddir)/src/math/libmath.la \
- $(top_builddir)/src/common/libcommon.la $(top_builddir)/src/sys/libsys.la \
- $(top_builddir)/src/filesystem/libfilesystem.la $(top_builddir)/src/core/libcore.la $(top_builddir)/src/game/libgame.la \
- $(top_builddir)/src/gl/libgl.la
-osirion_SOURCES = application.cc camera.cc client.cc console.cc hud.cc input.cc main.cc \
- shipdrawer.cc stardrawer.cc video.cc view.cc
-
INCLUDES = -I$(top_srcdir)/src
-osirion_CFLAGS = $(LIBSDL_CFLAGS) $(GL_CFLAGS)
-osirion_LDFLAGS = $(LIBSDL_LIBS) $(GL_LIBS)
+libclient_la_SOURCES = application.cc camera.cc client.cc console.cc hud.cc input.cc \
+ shipdrawer.cc stardrawer.cc video.cc view.cc
+libclient_la_CFLAGS = $(LIBSDL_CFLAGS) $(GL_CFLAGS)
+libclient_la_LDFLAGS = -avoid-version -no-undefined $(GL_LIBS) $(LIBSDL_LIBS)
+noinst_LTLIBRARIES = libclient.la
noinst_HEADERS = application.h camera.h client.h console.h input.h shipdrawer.h stardrawer.h \
- video.h view.h
+ video.h view.h
+libclient_la_LIBADD = $(top_builddir)/src/math/libmath.la \
+ $(top_builddir)/src/sys/libsys.la $(top_builddir)/src/filesystem/libfilesystem.la \
+ $(top_builddir)/src/core/libcore.la $(top_builddir)/src/game/libgame.la $(top_builddir)/src/gl/libgl.la
diff --git a/src/client/console.h b/src/client/console.h
index 8e8ab02..1a36d00 100644
--- a/src/client/console.h
+++ b/src/client/console.h
@@ -7,12 +7,12 @@
#ifndef __INCLUDED_CLIENT_CONSOLE_H__
#define __INCLUDED_CLIENT_CONSOLE_H__
-#include "common/consoleinterface.h"
+#include "sys/consoleinterface.h"
namespace client {
/// client console implementation
-class Console : public common::ConsoleInterface {
+class Console : public sys::ConsoleInterface {
public:
/// stream to send normal messages too
virtual std::ostream & messagestream();
diff --git a/src/client/main.cc b/src/client/main.cc
deleted file mode 100644
index 6955042..0000000
--- a/src/client/main.cc
+++ /dev/null
@@ -1,14 +0,0 @@
-/* client/main.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
-*/
-
-#include "client/client.h"
-
-int main( int argc, char *argv[] )
-{
- client::application.init();
- client::application.run();
- client::application.shutdown();
-}
-
diff --git a/src/client/video.cc b/src/client/video.cc
index 9a542f3..ca0401f 100644
--- a/src/client/video.cc
+++ b/src/client/video.cc
@@ -6,7 +6,7 @@
#include "client/client.h"
#include "gl/gllib.h"
-#include "common/common.h"
+#include "sys/sys.h"
#include <SDL/SDL.h>
diff --git a/src/client/view.cc b/src/client/view.cc
index 63a6942..30dd6d6 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -9,7 +9,7 @@
#include "client/stardrawer.h"
#include "game/game.h"
#include "gl/gllib.h"
-#include "common/common.h"
+#include "sys/sys.h"
#include "math/mathlib.h"
#include <SDL/SDL.h>
@@ -17,8 +17,6 @@
namespace client
{
-using namespace common;
-
ShipDrawer *shipdrawer = 0;
StarDrawer *stardrawer = 0;
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 8046b79..a70652e 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -2,10 +2,9 @@ METASOURCES = AUTO
INCLUDES = -I$(top_srcdir)/src
libcore_la_SOURCES = applicationinterface.cc gameinterface.cc
-libcore_la_LDFLAGS = -avoid-version
+libcore_la_LDFLAGS = -avoid-version -no-undefined
libcore_la_LIBADD = $(top_builddir)/src/math/libmath.la \
- $(top_builddir)/src/common/libcommon.la $(top_builddir)/src/sys/libsys.la \
- $(top_builddir)/src/filesystem/libfilesystem.la
+ $(top_builddir)/src/sys/libsys.la $(top_builddir)/src/filesystem/libfilesystem.la
noinst_LTLIBRARIES = libcore.la
noinst_HEADERS = applicationinterface.h core.h gameinterface.h
diff --git a/src/core/applicationinterface.cc b/src/core/applicationinterface.cc
index ba22d8c..209a4f5 100644
--- a/src/core/applicationinterface.cc
+++ b/src/core/applicationinterface.cc
@@ -7,17 +7,14 @@
#include "core/core.h"
#include "filesystem/filesystem.h"
#include "sys/sys.h"
-#include "common/common.h"
#include <iostream>
-
-#include <stdlib.h>
-
#include <errno.h>
#include <signal.h>
namespace core {
+// --------------- signal_handler -----------------------------------
extern "C" void signal_handler(int signum)
{
switch(signum){
@@ -25,24 +22,30 @@ extern "C" void signal_handler(int signum)
case SIGINT:
case SIGQUIT:
case SIGTERM:
- con_warn << "received signal " << signum << ", shutting down..." << std::endl;
- if (ApplicationInterface::instance());
+ if (ApplicationInterface::instance()) {
+ con_warn << "received signal " << signum << ", shutting down..." << std::endl;
ApplicationInterface::instance()->shutdown();
- exit(1);
+ ApplicationInterface::instance()->quit(0);
+ } else {
+ std::cerr << "received signal " << signum << ", no application found, terminated..." << std::endl;
+ sys::quit(1);
+ }
break;
default:
- con_warn << "received signal " << signum << ", terminated..." << std::endl;
- exit(1);
+ std::cerr << "received signal " << signum << ", terminated..." << std::endl;
+ sys::quit(1);
break;
}
}
+// --------------- ApplicationInterface -----------------------------
+
ApplicationInterface *ApplicationInterface::applicationinterface_instance = 0;
ApplicationInterface::ApplicationInterface() {
if (applicationinterface_instance) {
std::cerr << "multiple singleton instances: core::ApplicationInterface" << std::endl;
- exit(2);
+ sys::quit(2);
}
applicationinterface_instance = this;
@@ -87,6 +90,11 @@ void ApplicationInterface::shutdown()
filesystem::shutdown();
}
+void ApplicationInterface::quit(int status)
+{
+ sys::quit(status);
+}
+
void ApplicationInterface::frame(float seconds)
{
if (game())
diff --git a/src/core/applicationinterface.h b/src/core/applicationinterface.h
index 19eaee6..6093427 100644
--- a/src/core/applicationinterface.h
+++ b/src/core/applicationinterface.h
@@ -24,6 +24,9 @@ public:
/// shutdown the application
virtual void shutdown();
+ /// quit the application
+ virtual void quit(int status);
+
/// run a core frame
virtual void frame(float seconds);
diff --git a/src/filesystem/Makefile.am b/src/filesystem/Makefile.am
index 2eb094f..a490cd3 100644
--- a/src/filesystem/Makefile.am
+++ b/src/filesystem/Makefile.am
@@ -2,8 +2,7 @@ METASOURCES = AUTO
libfilesystem_la_SOURCES = file.cc filesystem.cc inifile.cc path.cc
libfilesystem_la_LDFLAGS = -avoid-version -no-undefined
-libfilesystem_la_LIBADD = $(top_builddir)/src/sys/libsys.la \
- $(top_builddir)/src/common/libcommon.la
+libfilesystem_la_LIBADD = $(top_builddir)/src/sys/libsys.la
noinst_LTLIBRARIES = libfilesystem.la
noinst_HEADERS = file.h filesystem.h inifile.h path.h
diff --git a/src/filesystem/file.cc b/src/filesystem/file.cc
index 4e68bbd..cd6ae1b 100644
--- a/src/filesystem/file.cc
+++ b/src/filesystem/file.cc
@@ -5,7 +5,7 @@
*/
// project headers
-#include "common/common.h"
+#include "sys/sys.h"
#include "filesystem/filesystem.h"
namespace filesystem {
diff --git a/src/filesystem/filesystem.cc b/src/filesystem/filesystem.cc
index 5ae4da7..b720198 100644
--- a/src/filesystem/filesystem.cc
+++ b/src/filesystem/filesystem.cc
@@ -6,7 +6,7 @@
// project headers
#include "filesystem/filesystem.h"
-#include "common/common.h"
+#include "sys/sys.h"
std::string filesystem::datadir = "";
std::string filesystem::homedir = "";
diff --git a/src/filesystem/path.cc b/src/filesystem/path.cc
index ac780c4..c090791 100644
--- a/src/filesystem/path.cc
+++ b/src/filesystem/path.cc
@@ -6,13 +6,7 @@
// project headers
#include "filesystem/path.h"
-#include "common/common.h"
-
-#ifdef _WIN32
-#include <dlfcn.h>
-#else
-#include <sys/stat.h>
-#endif
+#include "sys/sys.h"
namespace filesystem {
@@ -21,14 +15,10 @@ void Path::create(std::string path) {
if (tmp[tmp.size()-1] == '/')
tmp = tmp.substr(0, tmp.size() - 1);
-#ifdef _WIN32
- mkdir(tmp.c_str());
-#else
- if (!mkdir(tmp.c_str(), 0777))
- con_warn << "Could not create directory " << tmp << std::endl;
+ if (!sys::mkdir(tmp.c_str()))
+ con_warn << "could not create directory " << tmp << std::endl;
else
- con_debug << "Path created " << tmp << std::endl;
-#endif
+ con_debug << "directory created " << tmp << std::endl;
}
bool Path::exists(std::string path) {
diff --git a/src/game/Makefile.am b/src/game/Makefile.am
index 1ed5015..f86c814 100644
--- a/src/game/Makefile.am
+++ b/src/game/Makefile.am
@@ -1,11 +1,7 @@
INCLUDES = -I$(top_srcdir)/src
METASOURCES = AUTO
-libgame_la_LDFLAGS = -avoid-version --no-undefined
-libgame_la_LIBADD = $(top_builddir)/src/math/libmath.la \
- $(top_builddir)/src/common/libcommon.la \
- $(top_builddir)/src/filesystem/libfilesystem.la \
- $(top_builddir)/src/core/libcore.la
+libgame_la_LDFLAGS = -avoid-version
libgame_la_SOURCES = game.cc sector.cc ship.cc shipspecs.cc star.cc
noinst_LTLIBRARIES = libgame.la
diff --git a/src/game/game.cc b/src/game/game.cc
index b2b0822..7f2ad17 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -10,7 +10,7 @@
#include "game/ship.h"
#include "game/star.h"
#include "filesystem/filesystem.h"
-#include "common/common.h"
+#include "sys/sys.h"
// C++ headers
#include <vector>
diff --git a/src/game/game.h b/src/game/game.h
index 5a0afc7..6f77bcf 100644
--- a/src/game/game.h
+++ b/src/game/game.h
@@ -11,7 +11,7 @@
#include "game/ship.h"
#include "game/star.h"
#include "core/core.h"
-#include "common/common.h"
+#include "sys/sys.h"
/// the game-specific engine
/** The main game functions. The console should be initialized before calling these.
diff --git a/src/gl/Makefile.am b/src/gl/Makefile.am
index 7c1445e..7ddb67b 100644
--- a/src/gl/Makefile.am
+++ b/src/gl/Makefile.am
@@ -8,3 +8,4 @@ libgl_la_CXXFLAGS = @GL_CFLAGS@
noinst_LTLIBRARIES = libgl.la
noinst_HEADERS = box.h gllib.h sphere.h
+libgl_la_LIBADD = $(top_builddir)/src/math/libmath.la
diff --git a/src/gl/gllib.cc b/src/gl/gllib.cc
index e57ab5d..3d3e26c 100644
--- a/src/gl/gllib.cc
+++ b/src/gl/gllib.cc
@@ -6,7 +6,7 @@
// project includes
#include "gl/gllib.h"
-#include "common/common.h"
+#include "sys/sys.h"
// system includes
#include "GL/gl.h"
diff --git a/src/server/Makefile.am b/src/server/Makefile.am
index 729fabf..6875dbf 100644
--- a/src/server/Makefile.am
+++ b/src/server/Makefile.am
@@ -1,10 +1,9 @@
METASOURCES = AUTO
-bin_PROGRAMS = osiriond
-osiriond_SOURCES = application.cc console.cc main.cc server.cc timer.cc
-osiriond_LDADD = $(top_builddir)/src/math/libmath.la \
- $(top_builddir)/src/common/libcommon.la $(top_builddir)/src/sys/libsys.la \
- $(top_builddir)/src/filesystem/libfilesystem.la $(top_builddir)/src/core/libcore.la $(top_builddir)/src/game/libgame.la
+libserver_la_SOURCES = application.cc console.cc server.cc timer.cc
noinst_HEADERS = application.h console.h server.h timer.h
-
+noinst_LTLIBRARIES = libserver.la
INCLUDES = -I$(top_srcdir)/src
-
+libserver_la_LDFLAGS = -avoid-version -no-undefined
+libserver_la_LIBADD = $(top_builddir)/src/math/libmath.la \
+ $(top_builddir)/src/sys/libsys.la $(top_builddir)/src/filesystem/libfilesystem.la \
+ $(top_builddir)/src/core/libcore.la $(top_builddir)/src/game/libgame.la
diff --git a/src/server/application.cc b/src/server/application.cc
index b6cd91f..0d3fe4b 100644
--- a/src/server/application.cc
+++ b/src/server/application.cc
@@ -14,6 +14,10 @@ namespace server {
void Application::init()
{
+ // FIXME core should be able to load game.so
+ // force initialization of the game object
+ server::game = new game::Game();
+
// initialize core
core::ApplicationInterface::init();
@@ -44,7 +48,15 @@ void Application::shutdown()
core::ApplicationInterface::shutdown();
- exit(0);
+ quit(0);
+}
+
+void Application::quit(int status)
+{
+ // FIXME core should be able to unload game.so
+ delete server::game;
+
+ core::ApplicationInterface::quit(status);
}
}
diff --git a/src/server/application.h b/src/server/application.h
index c12a608..b081726 100644
--- a/src/server/application.h
+++ b/src/server/application.h
@@ -22,6 +22,9 @@ public:
/// shutdown the server Application
virtual void shutdown();
+
+ /// quit the server Application
+ virtual void quit(int status);
};
}
diff --git a/src/server/console.h b/src/server/console.h
index 188d2b6..34166be 100644
--- a/src/server/console.h
+++ b/src/server/console.h
@@ -7,12 +7,12 @@
#ifndef __INCLUDED_SERVER_CONSOLE_H__
#define __INCLUDED_SERVER_CONSOLE_H__
-#include "common/consoleinterface.h"
+#include "sys/consoleinterface.h"
namespace server {
/// server console implementation
-class Console : public common::ConsoleInterface {
+class Console : public sys::ConsoleInterface {
public:
/// stream to send normal messages too
virtual std::ostream & messagestream();
diff --git a/src/server/main.cc b/src/server/main.cc
deleted file mode 100644
index 052c68d..0000000
--- a/src/server/main.cc
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- server/main.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
-*/
-
-#include "server/server.h"
-
-int main( int argc, char *argv[] )
-{
- server::application.init();
- server::application.run();
- server::application.shutdown();
-}
diff --git a/src/server/server.cc b/src/server/server.cc
index ad8960e..fc37aa6 100644
--- a/src/server/server.cc
+++ b/src/server/server.cc
@@ -14,7 +14,7 @@ namespace server {
Application application;
Console console;
-game::Game Game;
+game::Game *game;
}
diff --git a/src/server/server.h b/src/server/server.h
index 14d1d4b..7871c5f 100644
--- a/src/server/server.h
+++ b/src/server/server.h
@@ -21,7 +21,7 @@ extern Application application;
extern Console console;
/// global Game instance
-extern game::Game game;
+extern game::Game *game;
} // namespace server
diff --git a/src/sys/Makefile.am b/src/sys/Makefile.am
index 44f69c4..be1c636 100644
--- a/src/sys/Makefile.am
+++ b/src/sys/Makefile.am
@@ -2,5 +2,5 @@ INCLUDES = -I$(top_srcdir)/src
METASOURCES = AUTO
libsys_la_LDFLAGS = -avoid-version -no-undefined
noinst_LTLIBRARIES = libsys.la
-libsys_la_SOURCES = sys.cc
-noinst_HEADERS = sys.h
+libsys_la_SOURCES = consoleinterface.cc sys.cc
+noinst_HEADERS = consoleinterface.h sys.h
diff --git a/src/sys/consoleinterface.cc b/src/sys/consoleinterface.cc
new file mode 100644
index 0000000..45df367
--- /dev/null
+++ b/src/sys/consoleinterface.cc
@@ -0,0 +1,35 @@
+/*
+ sys/consoleinterface.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#include "sys/consoleinterface.h"
+
+#include <iostream>
+
+#include <stdlib.h>
+
+namespace sys {
+
+ConsoleInterface *ConsoleInterface::consoleinterface_instance = 0;
+
+ConsoleInterface::ConsoleInterface() {
+ if (consoleinterface_instance) {
+ std::cerr << "multiple singleton instances: sys::ConsoleInterface" << std::endl;
+ sys::quit(2);
+ }
+ consoleinterface_instance = this;
+}
+
+ConsoleInterface::~ConsoleInterface()
+{
+ consoleinterface_instance = 0;
+}
+
+ConsoleInterface *ConsoleInterface::instance()
+{
+ return consoleinterface_instance;
+}
+
+} // namespace sys
diff --git a/src/sys/consoleinterface.h b/src/sys/consoleinterface.h
new file mode 100644
index 0000000..e0228ae
--- /dev/null
+++ b/src/sys/consoleinterface.h
@@ -0,0 +1,59 @@
+/*
+ sys/consoleinterface.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2.
+*/
+
+#ifndef __INCLUDED_SYS_CONSOLEINTERFACE_H__
+#define __INCLUDED_SYS_CONSOLEINTERFACE_H__
+
+// project headers
+#include "sys/sys.h"
+
+// C++ headers
+#include <iostream>
+
+/// global define to send a message to the system console
+#define con_print sys::ConsoleInterface::instance()->messagestream()
+/// global define to send a warning message to the system console
+#define con_warn sys::ConsoleInterface::instance()->warningstream()
+
+#ifdef HAVE_DEBUG_MESSAGES
+/// global define to send a debug message to the system console
+#define con_debug sys::ConsoleInterface::instance()->debugstream()
+#else
+#define con_debug if (0) *(std::ostream*)(0)
+#endif
+
+namespace sys {
+
+/// interface for the client and server Console classes
+class ConsoleInterface {
+public:
+ /// default constructor
+ ConsoleInterface();
+
+ /// default destructor
+ virtual ~ConsoleInterface();
+
+ /// stream to send normal messages too
+ virtual std::ostream & messagestream() = 0;
+
+ /// stream to send warning messages too
+ virtual std::ostream & warningstream() = 0;
+
+ /// stream to send debug messages too
+ virtual std::ostream & debugstream() = 0;
+
+ /// a pointer to the current console instance
+ static ConsoleInterface *instance();
+
+private:
+ /// console singleton
+ static ConsoleInterface *consoleinterface_instance;
+};
+
+} // namespace sys
+
+#endif // __INCLUDED_SYS_CONSOLEINTERFACE_H__
+
diff --git a/src/sys/sys.cc b/src/sys/sys.cc
index 97da23e..dc342bd 100644
--- a/src/sys/sys.cc
+++ b/src/sys/sys.cc
@@ -8,15 +8,20 @@
#include "sys/sys.h"
// system headers
-#include <signal.h>
+#ifdef _WIN32
+
+#include <dlfcn.h>
+
+#else
+#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
+#endif
+#include <stdlib.h>
-namespace sys {
-
-bool mkdir(const char *path)
+bool sys::mkdir(const char *path)
{
#ifdef _WIN32
::mkdir(path);
@@ -27,7 +32,7 @@ bool mkdir(const char *path)
#endif
}
-void signal(int signum, signalfunc handler)
+void sys::signal(int signum, signalfunc handler)
{
#ifndef _WIN32
struct sigaction sa;
@@ -35,8 +40,10 @@ void signal(int signum, signalfunc handler)
sa.sa_handler = handler;
sa.sa_flags = 0;
- sigaction(signum, &sa, 0);
+ ::sigaction(signum, &sa, 0);
#endif
}
+void sys::quit(int status) {
+ exit(status);
}
diff --git a/src/sys/sys.h b/src/sys/sys.h
index 0d05b67..86642e5 100644
--- a/src/sys/sys.h
+++ b/src/sys/sys.h
@@ -7,13 +7,23 @@
#ifndef __INCLUDED_SYS_H__
#define __INCLUDED_SYS_H__
+#include "config.h"
+
/// contains operating system dependent functions
namespace sys {
typedef void (* signalfunc)(int signum);
+ /// create a directory
bool mkdir(const char *path);
+ /// intercept OS signals
void signal(int signum, signalfunc handler);
+ /// quit
+ /** @param status return value
+ */
+ void quit(int status);
}
+#include "sys/consoleinterface.h"
+
#endif // __INCLUDED_SYS_H__