Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Doxyfile4
-rw-r--r--configure.in28
-rw-r--r--osirion.kdevelop41
-rw-r--r--osirion.kdevelop.pcsbin178662 -> 217050 bytes
-rw-r--r--osirion.kdevses11
-rw-r--r--src/Makefile.am2
-rw-r--r--src/client/Makefile.am4
-rw-r--r--src/client/client.cc62
-rw-r--r--src/client/client.h19
-rw-r--r--src/client/input.cc6
-rw-r--r--src/client/main.cc5
-rw-r--r--src/client/stardrawer.h2
-rw-r--r--src/common/common.h6
-rw-r--r--src/common/console.cc14
-rw-r--r--src/common/console.h2
-rw-r--r--src/core/Makefile.am12
-rw-r--r--src/core/core.cc26
-rw-r--r--src/core/core.h4
-rw-r--r--src/filesystem/Makefile.am3
-rw-r--r--src/filesystem/file.cc4
-rw-r--r--src/filesystem/file.h3
-rw-r--r--src/filesystem/filesystem.cc15
-rw-r--r--src/filesystem/filesystem.h1
-rw-r--r--src/filesystem/inifile.cc4
-rw-r--r--src/filesystem/inifile.h10
-rw-r--r--src/game/Makefile.am9
-rw-r--r--src/game/game.cc74
-rw-r--r--src/game/game.h30
-rw-r--r--src/gl/gllib.cc2
-rw-r--r--src/gl/gllib.h3
-rw-r--r--src/math/Makefile.am2
-rw-r--r--src/server/Makefile.am9
-rw-r--r--src/server/console.cc7
-rw-r--r--src/server/main.cc35
-rw-r--r--src/server/server.cc56
-rw-r--r--src/server/server.h22
36 files changed, 337 insertions, 200 deletions
diff --git a/Doxyfile b/Doxyfile
index 4937bda..01272fd 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -25,7 +25,7 @@ ABBREVIATE_BRIEF = "The $name class" \
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
-STRIP_FROM_PATH = /home/ingar/projects/osirion
+STRIP_FROM_PATH = /home/ingar/projects/osirion/osirion-work
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
@@ -183,7 +183,7 @@ TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
-GENERATE_LATEX = YES
+GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
diff --git a/configure.in b/configure.in
index 3b0b911..0a52322 100644
--- a/configure.in
+++ b/configure.in
@@ -75,16 +75,14 @@ AC_ARG_ENABLE(warn,
AC_SUBST(WARN_CFLAGS)
-AC_MSG_CHECKING(whether to build a debug version)
-DEBUG_CFLAGS=""
-AC_ARG_ENABLE(debug,
+AC_MSG_CHECKING(whether to include debug messages)
+AC_ARG_ENABLE(debug_messages,
AC_HELP_STRING(
- [--disable-debug], [build without extra debug information]
+ [--disable-debug-messages], [build without extra debug information]
),
AC_MSG_RESULT(no),
AC_MSG_RESULT(yes)
- AC_DEFINE_UNQUOTED(HAVE_DEBUG, 1, [Defines if debug information is enabled])
- HAVE_DEBUG="-g"
+ AC_DEFINE_UNQUOTED(HAVE_DEBUG_MESSAGES, 1, [Defines if debug information is enabled])
)
AC_CHECK_HEADER(GL/gl.h,
@@ -152,18 +150,14 @@ AC_MSG_RESULT([
The Osirion Project $VERSION
Configuration summary:
-
- platform ...................... $host
-
- flags ......................... $CXXFLAGS
- debug information ............. $HAVE_DEBUG
+ platform ........... $host
+ flags .............. $CXXFLAGS
+ debug messages ..... $debug_messages
Installation directories:
-
- prefix ........................ $PREFIX
- program binaries .............. $BINDIR
- libraries ..................... $LIBDIR
- data .......................... $DATADIR
-
+ prefix ............. $PREFIX
+ program binaries ... $BINDIR
+ libraries .......... $LIBDIR
+ data ............... $DATADIR
])
diff --git a/osirion.kdevelop b/osirion.kdevelop
index dbc011b..35ce71d 100644
--- a/osirion.kdevelop
+++ b/osirion.kdevelop
@@ -16,30 +16,38 @@
<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/client/osirion</activetarget>
+ <activetarget>src/server/osiriond</activetarget>
<useconfiguration>debug</useconfiguration>
</general>
<run>
- <mainprogram>src/osirion</mainprogram>
+ <mainprogram/>
<terminal>true</terminal>
<directoryradio>executable</directoryradio>
<runarguments>
- <osirion/>
- <osiriond/>
+ <osirion></osirion>
+ <osiriond></osiriond>
</runarguments>
<debugarguments>
- <osiriond/>
- <osirion/>
+ <osiriond></osiriond>
+ <osirion></osirion>
</debugarguments>
<cwd>
<osiriond>/home/ingar/projects/osirion/debug/./src/game</osiriond>
<osirion>/home/ingar/projects/osirion/debug/./src/client</osirion>
</cwd>
+ <programargs/>
+ <globaldebugarguments/>
+ <globalcwd>/home/ingar/projects/osirion/osirion-work/debug</globalcwd>
+ <useglobalprogram>false</useglobalprogram>
+ <autocompile>false</autocompile>
+ <autoinstall>false</autoinstall>
+ <autokdesu>false</autokdesu>
+ <envvars/>
</run>
<configurations>
<optimized>
@@ -56,6 +64,7 @@
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<cxxflags>-O0 -g3</cxxflags>
+ <envvars/>
</debug>
</configurations>
<configurations>
@@ -68,6 +77,12 @@
<envvar value="1" name="WANT_AUTOCONF_2_5" />
<envvar value="1" name="WANT_AUTOMAKE_1_6" />
</envvars>
+ <abortonerror>true</abortonerror>
+ <runmultiplejobs>false</runmultiplejobs>
+ <numberofjobs>2</numberofjobs>
+ <dontact>false</dontact>
+ <makebin></makebin>
+ <prio>0</prio>
</make>
</kdevautoproject>
<kdevdoctreeview>
@@ -181,7 +196,7 @@
<designerpluginpaths/>
</qt>
<creategettersetter>
- <prefixGet/>
+ <prefixGet></prefixGet>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>
@@ -213,11 +228,11 @@
</cppsupportpart>
<kdevdebugger>
<general>
- <gdbpath/>
- <dbgshell/>
- <configGdbScript/>
- <runShellScript/>
- <runGdbScript/>
+ <gdbpath></gdbpath>
+ <dbgshell></dbgshell>
+ <configGdbScript></configGdbScript>
+ <runShellScript></runShellScript>
+ <runGdbScript></runGdbScript>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs
index 0d24e12..5a814c9 100644
--- a/osirion.kdevelop.pcs
+++ b/osirion.kdevelop.pcs
Binary files differ
diff --git a/osirion.kdevses b/osirion.kdevses
index 1e1faa2..5fce955 100644
--- a/osirion.kdevses
+++ b/osirion.kdevses
@@ -1,10 +1,13 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
- <DocsAndViews NumberOfDocuments="1" >
- <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/src/client/camera.cc" >
- <View0 Encoding="" line="65" Type="Source" />
+ <DocsAndViews NumberOfDocuments="2" >
+ <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/game/Makefile.am" >
+ <View0 Encoding="" line="0" 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>
</DocsAndViews>
<pluginList>
<kdevdebugger>
@@ -13,7 +16,7 @@
</kdevdebugger>
<kdevastyle>
<Extensions ext="*.cpp *.h,*.c *.h,*.cxx *.hxx,*.c++ *.h++,*.cc *.hh,*.C *.H,*.diff,*.inl,*.java,*.moc,*.patch,*.tlh,*.xpm" />
- <AStyle IndentPreprocessors="0" FillCount="4" PadParenthesesOut="1" IndentNamespaces="1" IndentLabels="1" Fill="Tabs" MaxStatement="40" Brackets="Break" MinConditional="-1" IndentBrackets="0" PadParenthesesUn="1" BlockBreak="0" KeepStatements="1" KeepBlocks="1" BlockIfElse="0" IndentSwitches="1" PadOperators="0" FStyle="UserDefined" IndentCases="0" FillEmptyLines="0" BracketsCloseHeaders="0" BlockBreakAll="0" PadParenthesesIn="1" IndentClasses="1" IndentBlocks="0" FillForce="0" />
+ <AStyle IndentPreprocessors="1" FillCount="8" PadParenthesesOut="0" IndentNamespaces="0" IndentLabels="0" Fill="Tabs" MaxStatement="40" Brackets="Linux" MinConditional="-1" IndentBrackets="0" PadParenthesesUn="1" BlockBreak="0" KeepStatements="1" KeepBlocks="1" BlockIfElse="0" IndentSwitches="1" PadOperators="0" FStyle="UserDefined" IndentCases="1" FillEmptyLines="0" BracketsCloseHeaders="0" BlockBreakAll="0" PadParenthesesIn="0" IndentClasses="0" IndentBlocks="0" FillForce="0" />
</kdevastyle>
<kdevbookmarks>
<bookmarks/>
diff --git a/src/Makefile.am b/src/Makefile.am
index a41d88f..ab95099 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,6 @@
# set the include path found by configure
AM_CPPFLAGS = $(DEBUG_CFLAGS) $(WARN_CFLAGS) $(all_includes)
-SUBDIRS = common filesystem math core game server gl client
+SUBDIRS = math common filesystem core game server gl client
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index 6298936..f8542e2 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -2,8 +2,10 @@
METASOURCES = AUTO
bin_PROGRAMS = osirion
-osirion_LDADD = $(top_builddir)/src/common/libcommon.la \
+osirion_LDADD = $(top_builddir)/src/math/libmath.la \
+ $(top_builddir)/src/common/libcommon.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 = camera.cc client.cc console.cc hud.cc input.cc main.cc \
diff --git a/src/client/client.cc b/src/client/client.cc
index a94219b..7a718a3 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -4,27 +4,30 @@
the terms and conditions of the GNU General Public License version 2
*/
-#include "client/camera.h"
-#include "client/view.h"
-#include "client/video.h"
-#include "client/input.h"
-#include "client/console.h"
-
+// project headers
+#include "client/client.h"
#include "game/game.h"
+#include "core/core.h"
#include "common/common.h"
+// SDL headers
#include <SDL/SDL.h>
+// C++ headers
+#include <cmath>
+
namespace client {
// public instances
-Camera camera;
-View view;
-Video video;
-Input input;
+Camera camera;
+View view;
+Video video;
+Input input;
// private instance of the client console object
-Console clientconsole;
+Console console_instance;
+// private instance of the game object
+game::Game game_instance;
void quit(int status)
{
@@ -34,6 +37,11 @@ void quit(int status)
void init()
{
+ // core initializes all the modules
+ core::init();
+
+ con_debug << "Initializing client..." << std::endl;
+
// Initialize the video subsystem
video.init();
if (!video.initialized) {
@@ -42,36 +50,44 @@ void init()
// initialize input
input.init();
-
- // initialize game
- game::init();
}
void run()
{
- Uint32 startup = SDL_GetTicks();
- while(game::initialized) {
- Uint32 chrono = SDL_GetTicks();
+ Uint32 chrono = SDL_GetTicks();
+
+ while(true) {
+ Uint32 current = SDL_GetTicks();
// overflow protection ~49 days
- if (chrono < startup) {
- startup = chrono;
+ if (current < chrono) {
+ chrono = current;
}
// update the game chronometers
- float elapsed = (float) ( chrono - startup) / 1000.0f;
- game::update(elapsed);
+ float elapsed = (float) ( current - chrono) / 1000.0f;
+ chrono = current;
+
+ core::frame(elapsed);
// update the video chronometers and draw
video.draw(elapsed);
- startup = chrono;
-
+
// process input
input.process();
}
+}
+
+void shutdown()
+{
+ con_debug << "Shutting down client..." << std::endl;
input.shutdown();
+
video.shutdown();
+
+ core::shutdown();
+
quit(0);
}
diff --git a/src/client/client.h b/src/client/client.h
index e3ff380..a25643c 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -7,22 +7,23 @@
#ifndef __INCLUDED_CLIENT_H__
#define __INCLUDED_CLIENT_H__
-#include "camera.h"
-#include "view.h"
-#include "input.h"
-#include "video.h"
-#include "console.h"
+#include "client/console.h"
+#include "client/camera.h"
+#include "client/view.h"
+#include "client/input.h"
+#include "client/video.h"
/// client-side functions to render and control the gameworld
-/*!
- * the client namespace contains the necessary functions to
- * accept input, send it to the game and render the result
+/** The client namespace contains the necessary functions to
+ * accept input, send it to the game and renders the result
*/
namespace client {
/// initialize the client
extern void init();
- /// run the client();
+ /// run the client
extern void run();
+ /// shutdown the client
+ extern void shutdown();
/// global Video object
extern Video video;
diff --git a/src/client/input.cc b/src/client/input.cc
index 7d26a2b..b18339e 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -43,7 +43,7 @@ void Input::handle_keypressed(SDL_keysym* keysym)
{
switch( keysym->sym ) {
case SDLK_ESCAPE:
- game::shutdown();
+ client::shutdown();
break;
case SDLK_LEFT:
camera.rotate_left();
@@ -88,8 +88,8 @@ void Input::process()
handle_keyreleased( &event.key.keysym );
break;
case SDL_QUIT:
- game::shutdown();
- break;
+ client::shutdown();
+ break;
}
}
diff --git a/src/client/main.cc b/src/client/main.cc
index e8486ca..7c5f7b7 100644
--- a/src/client/main.cc
+++ b/src/client/main.cc
@@ -3,10 +3,13 @@
the terms and conditions of the GNU General Public License version 2
*/
-#include "client.h"
+#include "client/client.h"
int main( int argc, char *argv[] )
{
client::init();
+
client::run();
+
+ client::shutdown();
}
diff --git a/src/client/stardrawer.h b/src/client/stardrawer.h
index 354da6a..6042659 100644
--- a/src/client/stardrawer.h
+++ b/src/client/stardrawer.h
@@ -6,7 +6,7 @@
#ifndef __INCLUDED_STARDRAWER_H__
#define __INCLUDED_STARDRAWER_H__
-#include "gl/sphere.h"
+#include "gl/gllib.h"
#include "game/star.h"
namespace client {
diff --git a/src/common/common.h b/src/common/common.h
index c47b09f..1be6827 100644
--- a/src/common/common.h
+++ b/src/common/common.h
@@ -12,13 +12,13 @@
/// common functions and components that are used by the other subsytems
namespace common {
- // initialize common components
+ /// initialize common components
void init();
- // shutdown common components
+ /// shutdown common components
void shutdown();
-} // namespace common
+}
#include "common/console.h"
diff --git a/src/common/console.cc b/src/common/console.cc
index e4fd215..a7d0dd7 100644
--- a/src/common/console.cc
+++ b/src/common/console.cc
@@ -6,21 +6,29 @@
#include "common/console.h"
-// TODO enforce singleton
+#include <iostream>
+
+#include <stdlib.h>
namespace common {
Console *Console::console_instance = 0;
Console::Console() {
+ if (console_instance) {
+ std::cerr << "duplicate common::Console::console_instance" << std::endl;
+ exit(2);
+ }
console_instance = this;
}
-Console::~Console() {
+Console::~Console()
+{
console_instance = 0;
}
-Console *Console::instance() {
+Console *Console::instance()
+{
return console_instance;
}
diff --git a/src/common/console.h b/src/common/console.h
index fbda5da..0706f11 100644
--- a/src/common/console.h
+++ b/src/common/console.h
@@ -45,7 +45,7 @@ public:
/// stream to send debug messages too
virtual std::ostream & debugstream() = 0;
- /// a pointer to the current console implementation
+ /// a pointer to the current console instance
static Console *instance();
private:
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 0f0020f..1f1cc2e 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -1,12 +1,12 @@
METASOURCES = AUTO
INCLUDES = -I$(top_srcdir)/src
-libcore_la_SOURCES = core.cc
-libcore_la_LDFLAGS = -avoid-version -no-undefined
-libcore_la_LIBADD = $(top_builddir)/src/common/libcommon.la \
- $(top_builddir)/src/math/libmath.la \
- $(top_builddir)/src/filesystem/libfilesystem.la
+libcore_la_SOURCES = core.cc game.cc
+libcore_la_LDFLAGS = -avoid-version
+libcore_la_LIBADD = $(top_builddir)/src/math/libmath.la \
+ $(top_builddir)/src/common/libcommon.la \
+ $(top_builddir)/src/filesystem/libfilesystem.la
noinst_LTLIBRARIES = libcore.la
-noinst_HEADERS = core.h
+noinst_HEADERS = core.h game.h
diff --git a/src/core/core.cc b/src/core/core.cc
index b576ba5..0a4ed60 100644
--- a/src/core/core.cc
+++ b/src/core/core.cc
@@ -12,23 +12,39 @@
namespace core
{
-/// initialize the core
-void init() {
+void init()
+{
+ con_debug << "Initializing core..." << std::endl;
+
common::init();
filesystem::init();
+
+ if (::core::Game::instance())
+ ::core::Game::instance()->init();
+ else
+ con_warn << "No game module found!" << std::endl;
- con_debug << "Initializing core..." << std::endl;
}
-/// shutdown the core
-void shutdown() {
+void shutdown()
+{
con_debug << "Shutting down core..." << std::endl;
+ if (::core::Game::instance())
+ ::core::Game::instance()->shutdown();
+ else
+ con_warn << "No game module found!" << std::endl;
+
filesystem::shutdown();
common::shutdown();
}
+void frame(float sec)
+{
+ if (::core::Game::instance())
+ ::core::Game::instance()->frame(sec);
}
+} //namespace core
diff --git a/src/core/core.h b/src/core/core.h
index d5e4542..09c7209 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -16,7 +16,11 @@ namespace core
/// shutdown the core
void shutdown();
+ /// run one frame
+ void frame(float sec);
};
+#include "core/game.h"
+
#endif // __INCLUDED_CORE_H__
diff --git a/src/filesystem/Makefile.am b/src/filesystem/Makefile.am
index 9ef09bd..c072b02 100644
--- a/src/filesystem/Makefile.am
+++ b/src/filesystem/Makefile.am
@@ -3,8 +3,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/common/libcommon.la
-
noinst_LTLIBRARIES = libfilesystem.la
-noinst_HEADERS = file.h filesystem.h path.h
+noinst_HEADERS = file.h filesystem.h inifile.h path.h
INCLUDES = -I$(top_srcdir)/src
diff --git a/src/filesystem/file.cc b/src/filesystem/file.cc
index 7f33337..4e68bbd 100644
--- a/src/filesystem/file.cc
+++ b/src/filesystem/file.cc
@@ -10,6 +10,10 @@
namespace filesystem {
+File::File() {}
+
+File::~File() {}
+
void File::open(const char * filename, ios_base::openmode mode) {
file_name.assign(filename);
std::string fn;
diff --git a/src/filesystem/file.h b/src/filesystem/file.h
index 5e997a2..aaafd01 100644
--- a/src/filesystem/file.h
+++ b/src/filesystem/file.h
@@ -16,6 +16,9 @@ namespace filesystem {
/// a class to open data files
class File : public std::ifstream {
public:
+ File();
+ virtual ~File();
+
/// open the file for reading
virtual void open(const char * filename, std::ios_base::openmode mode = std::ios_base::in);
diff --git a/src/filesystem/filesystem.cc b/src/filesystem/filesystem.cc
index 9c00930..5ae4da7 100644
--- a/src/filesystem/filesystem.cc
+++ b/src/filesystem/filesystem.cc
@@ -15,6 +15,21 @@ std::string filesystem::moddir = "";
void filesystem::init() {
con_debug << "Initializing filesystem..." << std::endl;
+
+ // FIXME datadir should by set by ./configure and read from config.h
+
+ // 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);
}
void filesystem::shutdown() {
diff --git a/src/filesystem/filesystem.h b/src/filesystem/filesystem.h
index 4032575..e1ff8c6 100644
--- a/src/filesystem/filesystem.h
+++ b/src/filesystem/filesystem.h
@@ -33,6 +33,7 @@ void shutdown();
// project headers
#include "filesystem/file.h"
#include "filesystem/path.h"
+#include "filesystem/inifile.h"
#endif // __INCLUDED_FILYSYSTEM_H__
diff --git a/src/filesystem/inifile.cc b/src/filesystem/inifile.cc
index 308a87d..57778b3 100644
--- a/src/filesystem/inifile.cc
+++ b/src/filesystem/inifile.cc
@@ -9,6 +9,10 @@
namespace filesystem {
+IniFile::IniFile() {}
+
+IniFile::~IniFile() {}
+
void IniFile::open(const char * filename, std::ios_base::openmode mode) {
last_read_was_section = false;
last_read_was_key = false;
diff --git a/src/filesystem/inifile.h b/src/filesystem/inifile.h
index f5b74a3..d3984c5 100644
--- a/src/filesystem/inifile.h
+++ b/src/filesystem/inifile.h
@@ -17,12 +17,15 @@
namespace filesystem {
/// a class to read .ini files
-/*! The IniFile class provides functions to read .ini files. A .ini file
+/** The IniFile class provides functions to read .ini files. A .ini file
* consists of one or more [section] headers followed by one or more key=value
* pairs. Lines starting with # or ; are considered comments
*/
class IniFile : public File {
public:
+ IniFile();
+ virtual ~IniFile();
+
/// open the file for reading
virtual void open(const char * filename, std::ios_base::openmode mode = std::ios_base::in);
@@ -68,9 +71,8 @@ private:
bool last_read_was_section;
unsigned int line_number;
-}
-; // class IniFile
+};
-} // namespace common
+}
#endif // __INCLUDED_FILESYSTEM_INIFILE_H__
diff --git a/src/game/Makefile.am b/src/game/Makefile.am
index 4268c84..1ed5015 100644
--- a/src/game/Makefile.am
+++ b/src/game/Makefile.am
@@ -1,11 +1,12 @@
INCLUDES = -I$(top_srcdir)/src
METASOURCES = AUTO
-libgame_la_LDFLAGS = -avoid-version -no-undefined
+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_SOURCES = game.cc sector.cc ship.cc shipspecs.cc star.cc
-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 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 <vector>
-namespace game {
+namespace game
+{
Ship ship;
Star star;
@@ -28,31 +29,16 @@ std::string author; // author of the game
// sectors in space
std::vector<Sector*> 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
diff --git a/src/game/game.h b/src/game/game.h
index f2a0eab..ee9e286 100644
--- a/src/game/game.h
+++ b/src/game/game.h
@@ -7,17 +7,26 @@
#ifndef __INCLUDED_GAME_H__
#define __INCLUDED_GAME_H__
+// project headers
#include "game/ship.h"
#include "game/star.h"
-
+#include "core/core.h"
#include "common/common.h"
-/// the game engine
-/**
- * The main game functions. The console should be initialized before calling these.
+/// the game-specific engine
+/** The main game functions. The console should be initialized before calling these.
*/
namespace game
{
+
+/// the only ship in the game
+extern Ship ship;
+
+/// the only star in the game
+extern Star star;
+
+class Game : public core::Game {
+public:
/// initialize the game
void init();
@@ -25,17 +34,10 @@ namespace game
void shutdown();
/// update the game state
- void update(float elapsed);
-
- /// the only ship in the game
- extern Ship ship;
-
- /// the only star in the game
- extern Star star;
-
- /// true while the game is running
- extern bool initialized;
+ void frame(float sec);
};
+}
+
#endif // __INCLUDED_GAME_H__
diff --git a/src/gl/gllib.cc b/src/gl/gllib.cc
index 32aa55e..e57ab5d 100644
--- a/src/gl/gllib.cc
+++ b/src/gl/gllib.cc
@@ -19,7 +19,7 @@ namespace gl
void init()
{
- con_debug << "Initiliazing gl..." << std::endl;
+ con_debug << "Initializing gl..." << std::endl;
}
void shutdown()
diff --git a/src/gl/gllib.h b/src/gl/gllib.h
index d8f146a..42fcea1 100644
--- a/src/gl/gllib.h
+++ b/src/gl/gllib.h
@@ -158,4 +158,7 @@ namespace gl
void frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble znear, GLdouble zfar);
};
+#include "gl/box.h"
+#include "gl/sphere.h"
+
#endif // __INCLUDED_GL_GLLIB_H__
diff --git a/src/math/Makefile.am b/src/math/Makefile.am
index 78a52fc..4549557 100644
--- a/src/math/Makefile.am
+++ b/src/math/Makefile.am
@@ -1,7 +1,7 @@
METASOURCES = AUTO
libmath_la_SOURCES = color.cc functions.cc plane.cc vector3f.cc
-libmath_la_LDFLAGS = -lm -avoid-version -no-undefined
+libmath_la_LDFLAGS = -avoid-version -no-undefined -lm
noinst_LTLIBRARIES = libmath.la
noinst_HEADERS = color.h functions.h mathlib.h plane.h vector3f.h
diff --git a/src/server/Makefile.am b/src/server/Makefile.am
index 9e99900..f842c05 100644
--- a/src/server/Makefile.am
+++ b/src/server/Makefile.am
@@ -1,9 +1,12 @@
-INCLUDES = -I$(top_srcdir)/src
METASOURCES = AUTO
bin_PROGRAMS = osiriond
-osiriond_SOURCES = console.cc main.cc timer.cc
+osiriond_SOURCES = 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/filesystem/libfilesystem.la \
+ $(top_builddir)/src/core/libcore.la \
$(top_builddir)/src/game/libgame.la
-noinst_HEADERS = console.h timer.h
+noinst_HEADERS = console.h server.h timer.h
+
+INCLUDES = -I$(top_srcdir)/src
+
diff --git a/src/server/console.cc b/src/server/console.cc
index 7a2d82d..3df0e09 100644
--- a/src/server/console.cc
+++ b/src/server/console.cc
@@ -1,13 +1,14 @@
/*
server/console.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
+ 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/console.h"
#include <iostream>
-namespace server {
+namespace server
+{
std::ostream & Console::messagestream()
{
return std::cout;
diff --git a/src/server/main.cc b/src/server/main.cc
index ae74471..56b29a8 100644
--- a/src/server/main.cc
+++ b/src/server/main.cc
@@ -4,40 +4,13 @@
the terms and conditions of the GNU General Public License version 2
*/
-// project headers
-#include "common/common.h"
-#include "game/game.h"
-
-#include "timer.h"
-#include "console.h"
-
-#include <iostream>
-
-void quit(int status)
-{
- exit(status);
-}
+#include "server/server.h"
int main( int argc, char *argv[] )
{
- // initialize system console;
- server::Console serverconsole;
-
- const float server_framerate = 1.0f / 20.0f;
- server::Timer timer;
-
- // initialize game
- game::init();
- timer.mark();
+ server::init();
- while(game::initialized) {
- float elapsed = timer.elapsed();
- game::update(elapsed);
- timer.sleep(server_framerate - elapsed);
- timer.mark();
- }
- // shutdown
- game::shutdown();
+ server::run();
- quit(0);
+ server::shutdown();
}
diff --git a/src/server/server.cc b/src/server/server.cc
new file mode 100644
index 0000000..69c58b2
--- /dev/null
+++ b/src/server/server.cc
@@ -0,0 +1,56 @@
+/*
+ server/server.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
+*/
+
+// project headers
+#include "server/server.h"
+#include "game/game.h"
+#include "core/core.h"
+#include "common/common.h"
+
+namespace server {
+
+// private instance of the server console object
+Console console_instance;
+// private instance of the game object
+game::Game game_instance;
+
+void init()
+{
+ // initialize core
+ core::init();
+
+ con_debug << "Initializing server..." << std::endl;
+}
+
+void run()
+{
+
+ const float server_framerate = 1.0f / 20.0f;
+ server::Timer timer;
+
+ timer.mark();
+
+ while(true) {
+ float elapsed = timer.elapsed();
+
+ core::frame(elapsed);
+
+ timer.sleep(server_framerate - elapsed);
+ timer.mark();
+ }
+
+}
+
+void shutdown()
+{
+ con_debug << "Shutting down server..." << std::endl;
+
+ core::shutdown();
+
+ exit(0);
+}
+
+}
diff --git a/src/server/server.h b/src/server/server.h
new file mode 100644
index 0000000..1f839a5
--- /dev/null
+++ b/src/server/server.h
@@ -0,0 +1,22 @@
+/*
+ server/server.h
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_SERVER_H__
+#define __INCLUDED_SERVER_H__
+
+#include "server/timer.h"
+#include "server/console.h"
+
+namespace server {
+ /// initialize the server
+ void init();
+ /// run the server
+ void run();
+ /// shutdown the server
+ void shutdown();
+}
+
+#endif // __INCLUDED_SERVER_H__