diff options
author | Stijn Buys <ingar@osirion.org> | 2008-02-02 13:23:00 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-02-02 13:23:00 +0000 |
commit | cdc5a69a108654ff378839e8cf93669de31ff9c5 (patch) | |
tree | 10bdc47d0d51485f49387bee3aeae7037c47df6e /src/core | |
parent | 1765b93250ac3b89947c3da7f0c7266a910367c9 (diff) |
removed libcommon
modularized client and server
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/Makefile.am | 5 | ||||
-rw-r--r-- | src/core/applicationinterface.cc | 28 | ||||
-rw-r--r-- | src/core/applicationinterface.h | 3 |
3 files changed, 23 insertions, 13 deletions
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); |