Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-09-28 18:02:06 +0000
committerStijn Buys <ingar@osirion.org>2008-09-28 18:02:06 +0000
commitf46be446304dcb2d609fcd2648fd36d3f2fda054 (patch)
tree36e194d6e2d9d8fc48d03c4b8bb56d63e12276cf /src
parentfd778219e40c5fbb4d0af1839cbc313caaf10d9d (diff)
intro module groundworks
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am3
-rw-r--r--src/core/Makefile.am6
-rw-r--r--src/core/entity.cc25
-rw-r--r--src/core/entity.h17
-rw-r--r--src/core/netserver.h6
-rw-r--r--src/core/parser.cc70
-rw-r--r--src/core/parser.h25
-rw-r--r--src/game/Makefile.am3
-rw-r--r--src/game/base/base.cc74
-rw-r--r--src/game/base/base.h2
-rw-r--r--src/game/game.cc1
-rw-r--r--src/game/intro/Makefile.am6
-rw-r--r--src/game/intro/intro.cc59
-rw-r--r--src/game/intro/intro.h47
14 files changed, 268 insertions, 76 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 494e50b..aad662b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,7 +4,8 @@ SUFFIXES = .rc
.rc.o:
windres $< -o $@
-SUBDIRS = sys math auxiliary filesystem model core server audio render client game
+SUBDIRS = sys auxiliary math filesystem model core server audio render client \
+ game
noinst_HEADERS = config.h
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 8c44d13..18d8185 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -3,8 +3,8 @@ INCLUDES = -I$(top_srcdir)/src
libcore_la_SOURCES = application.cc clientstate.cc commandbuffer.cc core.cc \
cvar.cc entity.cc func.cc gameconnection.cc gameinterface.cc gameserver.cc \
- module.cc netclient.cc netconnection.cc netserver.cc player.cc stats.cc timer.cc \
- zone.cc
+ module.cc netclient.cc netconnection.cc netserver.cc parser.cc player.cc stats.cc \
+ timer.cc zone.cc
libcore_la_LDFLAGS = -avoid-version -no-undefined
libcore_la_LIBADD = $(top_builddir)/src/model/libmodel.la \
$(top_builddir)/src/filesystem/libfilesystem.la $(top_builddir)/src/math/libmath.la $(top_builddir)/src/sys/libsys.la \
@@ -13,4 +13,4 @@ libcore_la_LIBADD = $(top_builddir)/src/model/libmodel.la \
noinst_LTLIBRARIES = libcore.la
noinst_HEADERS = application.h clientstate.h commandbuffer.h core.h cvar.h \
entity.h func.h gameconnection.h gameinterface.h gameserver.h message.h module.h net.h \
- netclient.h netconnection.h netserver.h player.h range.h stats.h timer.h
+ netclient.h netconnection.h netserver.h player.h range.h stats.h timer.h parser.h
diff --git a/src/core/entity.cc b/src/core/entity.cc
index bed17fb..e74b8b5 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -7,6 +7,7 @@
#include <vector>
#include <iomanip>
+#include "auxiliary/functions.h"
#include "sys/sys.h"
#include "core/entity.h"
#include "core/cvar.h"
@@ -170,6 +171,30 @@ void Entity::set_zone(Zone *zone)
entity_zone->add(this);
}
+void Entity::set_label(char const *label)
+{
+ entity_label.assign(label);
+ aux::to_label(entity_label);
+}
+
+void Entity::set_label(std::string const &label)
+{
+ entity_label.assign(label);
+ aux::to_label(entity_label);
+}
+
+void Entity::set_name(char const *name)
+{
+ entity_name.assign(name);
+ aux::strip_quotes(entity_name);
+}
+
+void Entity::set_name(std::string const &name)
+{
+ entity_name.assign(name);
+ aux::strip_quotes(entity_name);
+}
+
void Entity::serialize_server_create(std::ostream & os) const
{
os << entity_moduletypeid << " "
diff --git a/src/core/entity.h b/src/core/entity.h
index c988143..4861b07 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -155,6 +155,18 @@ public:
*/
virtual void set_zone(Zone *zone);
+ /// set the label
+ void set_label(char const *label);
+
+ /// set the label
+ void set_label(std::string const &label);
+
+ /// set the name
+ void set_name(char const *name);
+
+ /// set the name
+ void set_name(std::string const &name);
+
/// clear all update flags
virtual void clear_updates();
@@ -183,8 +195,6 @@ public:
math::Axis entity_axis;
float entity_radius;
- std::string entity_name;
- std::string entity_label;
std::string entity_modelname;
model::Model *entity_model;
Shape entity_shape;
@@ -210,6 +220,9 @@ protected:
bool entity_serverside;
+ std::string entity_name;
+ std::string entity_label;
+
private:
// add an entity to the registry
static void add(Entity *ent);
diff --git a/src/core/netserver.h b/src/core/netserver.h
index 4dcae69..1d2e131 100644
--- a/src/core/netserver.h
+++ b/src/core/netserver.h
@@ -23,13 +23,17 @@
namespace core
{
-/// Network server
+/// network server
class NetServer
{
public:
+ /// type definition for a list of network clients
typedef std::list<NetClient *> Clients;
+ /// create a new network server, listening on host:port
NetServer(std::string const host, unsigned int const port);
+
+ /// disconnect clients and shutdown the network server
~NetServer();
/*----- inspectors ------------------------------------------------ */
diff --git a/src/core/parser.cc b/src/core/parser.cc
new file mode 100644
index 0000000..99dc1d5
--- /dev/null
+++ b/src/core/parser.cc
@@ -0,0 +1,70 @@
+/*
+ core/parser.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#include "core/parser.h"
+#include "auxiliary/functions.h"
+#include "sys/sys.h"
+
+namespace core {
+
+bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity)
+{
+ std::string shapename;
+ std::string strval;
+ float direction;
+ float pitch;
+ float roll;
+
+ if (inifile.got_key_string("shape", shapename)) {
+
+ if (shapename.compare("axis") == 0) {
+ entity->entity_shape = core::Entity::Axis;
+ return true;
+ } else if (shapename.compare("cube") == 0) {
+ entity->entity_shape = core::Entity::Cube;
+ return true;
+ } else if (shapename.compare("diamond") == 0) {
+ entity->entity_shape = core::Entity::Diamond;
+ return true;
+ } else if (shapename.compare("sphere") == 0) {
+ entity->entity_shape = core::Entity::Sphere;
+ return true;
+ } else {
+ con_warn << inifile.name() << " unknown shape '" << shapename << "' at line " << inifile.line() << std::endl;
+ return false;
+ }
+
+ } else if (inifile.got_key_string("label", strval)) {
+ entity->set_label(strval);
+ return true;
+ } else if (inifile.got_key_string("name", strval)) {
+ entity->set_name(strval);
+ return true;
+ } else if (inifile.got_key_string("model", entity->entity_modelname)) {
+ return true;
+ } else if (inifile.got_key_angle("direction", direction)) {
+ entity->axis().change_direction(direction);
+ return true;
+ } else if (inifile.got_key_angle("pitch", pitch)) {
+ entity->axis().change_pitch(pitch);
+ return true;
+ } else if (inifile.got_key_angle("roll", roll)) {
+ entity->axis().change_roll(roll);
+ return true;
+ } else if (inifile.got_key_angle("radius", entity->entity_radius)) {
+ return true;
+ } else if (inifile.got_key_vector3f("location", entity->entity_location)) {
+ return true;
+ } else if (inifile.got_key_color("color", entity->entity_color)) {
+ return true;
+ } else if (inifile.got_key_color("colorsecond", entity->entity_color_second)) {
+ return true;
+ }
+
+ return false;
+}
+
+}
diff --git a/src/core/parser.h b/src/core/parser.h
new file mode 100644
index 0000000..4f7b843
--- /dev/null
+++ b/src/core/parser.h
@@ -0,0 +1,25 @@
+/*
+ core/parser.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_CORE_PARSER_H__
+#define __INCLUDED_CORE_PARSER_H__
+
+
+#include "filesystem/inifile.h"
+#include "core/entity.h"
+
+namespace core {
+
+/// general parser routines
+class Parser {
+public:
+ /// read default entity keys from an ini file
+ static bool got_entity_key(filesystem::IniFile &inifile, core::Entity *entity);
+};
+
+}
+
+#endif // __INCLUDED_CORE_PARSER_H__ \ No newline at end of file
diff --git a/src/game/Makefile.am b/src/game/Makefile.am
index 91838e6..a6a5290 100644
--- a/src/game/Makefile.am
+++ b/src/game/Makefile.am
@@ -7,4 +7,5 @@ libgame_la_SOURCES = game.cc
noinst_LTLIBRARIES = libgame.la
noinst_HEADERS = game.h
SUBDIRS = base intro
-libgame_la_LIBADD = $(top_builddir)/src/game/base/libbase.la
+libgame_la_LIBADD = $(top_builddir)/src/game/base/libbase.la \
+ $(top_builddir)/src/game/intro/libintro.la
diff --git a/src/game/base/base.cc b/src/game/base/base.cc
index 70d9335..d337391 100644
--- a/src/game/base/base.cc
+++ b/src/game/base/base.cc
@@ -9,6 +9,7 @@
#include "auxiliary/functions.h"
#include "core/gameserver.h"
+#include "core/parser.h"
#include "filesystem/filesystem.h"
#include "filesystem/inifile.h"
#include "base/base.h"
@@ -308,65 +309,6 @@ bool Base::load_world()
return true;
}
-bool Base::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity)
-{
- std::string shapename;
- std::string strval;
- float direction;
- float pitch;
- float roll;
-
- if (inifile.got_key_string("shape", shapename)) {
-
- if (shapename.compare("axis") == 0) {
- entity->entity_shape = core::Entity::Axis;
- return true;
- } else if (shapename.compare("cube") == 0) {
- entity->entity_shape = core::Entity::Cube;
- return true;
- } else if (shapename.compare("diamond") == 0) {
- entity->entity_shape = core::Entity::Diamond;
- return true;
- } else if (shapename.compare("sphere") == 0) {
- entity->entity_shape = core::Entity::Sphere;
- return true;
- } else {
- con_warn << inifile.name() << " unknown shape '" << shapename << "' at line " << inifile.line() << std::endl;
- return false;
- }
-
- } else if (inifile.got_key_string("label", strval)) {
- aux::to_label(strval);
- entity->entity_label.assign(strval);
- return true;
- } else if (inifile.got_key_string("name", strval)) {
- aux::strip_quotes(strval);
- entity->entity_name.assign(strval);
- return true;
- } else if (inifile.got_key_string("model", entity->entity_modelname)) {
- return true;
- } else if (inifile.got_key_angle("direction", direction)) {
- entity->axis().change_direction(direction);
- return true;
- } else if (inifile.got_key_angle("pitch", pitch)) {
- entity->axis().change_pitch(pitch);
- return true;
- } else if (inifile.got_key_angle("roll", roll)) {
- entity->axis().change_roll(roll);
- return true;
- } else if (inifile.got_key_angle("radius", entity->entity_radius)) {
- return true;
- } else if (inifile.got_key_vector3f("location", entity->entity_location)) {
- return true;
- } else if (inifile.got_key_color("color", entity->entity_color)) {
- return true;
- } else if (inifile.got_key_color("colorsecond", entity->entity_color_second)) {
- return true;
- }
-
- return false;
-}
-
bool Base::load_zone(core::Zone *zone)
{
using math::Vector3f;
@@ -417,7 +359,7 @@ bool Base::load_zone(core::Zone *zone)
con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl;
}
} else if (zoneini.section().compare("star") == 0) {
- if (got_entity_key(zoneini, star)) {
+ if (core::Parser::got_entity_key(zoneini, star)) {
continue;
} else if (zoneini.got_key_string("texture", star->entity_texture)) {
continue;
@@ -425,13 +367,13 @@ bool Base::load_zone(core::Zone *zone)
con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl;
}
} else if (zoneini.section().compare("navpoint") == 0) {
- if (got_entity_key(zoneini, navpoint)) {
+ if (core::Parser::got_entity_key(zoneini, navpoint)) {
continue;
} else {
con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl;
}
} else if (zoneini.section().compare("jumppoint") == 0) {
- if (got_entity_key(zoneini, jumppoint)) {
+ if (core::Parser::got_entity_key(zoneini, jumppoint)) {
continue;
} else if (zoneini.got_key_string("target", jumppoint->jumppoint_targetlabel)) {
continue;
@@ -439,7 +381,7 @@ bool Base::load_zone(core::Zone *zone)
con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl;
}
} else if (zoneini.section().compare("planet") == 0) {
- if (got_entity_key(zoneini, planet)) {
+ if (core::Parser::got_entity_key(zoneini, planet)) {
continue;
} else if (zoneini.got_key_string("texture", planet->entity_texture)) {
continue;
@@ -450,21 +392,21 @@ bool Base::load_zone(core::Zone *zone)
}
} else if (zoneini.section().compare("racetrack") == 0) {
- if (got_entity_key(zoneini, racetrack)) {
+ if (core::Parser::got_entity_key(zoneini, racetrack)) {
continue;
} else {
con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl;
}
} else if (zoneini.section().compare("checkpoint") == 0) {
- if (got_entity_key(zoneini, checkpoint)) {
+ if (core::Parser::got_entity_key(zoneini, checkpoint)) {
continue;
} else {
con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl;
}
} else if (zoneini.section().compare("entity") == 0) {
- if (got_entity_key(zoneini, entity)) {
+ if (core::Parser::got_entity_key(zoneini, entity)) {
continue;
} else {
con_warn << zoneini.name() << " unknown key '" << zoneini.key() << "' at line " << zoneini.line() << std::endl;
diff --git a/src/game/base/base.h b/src/game/base/base.h
index fea1919..db3e7d9 100644
--- a/src/game/base/base.h
+++ b/src/game/base/base.h
@@ -1,5 +1,5 @@
/*
- game/game.h
+ base/base.h
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/
diff --git a/src/game/game.cc b/src/game/game.cc
index 0b7e0f2..26214cf 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -12,6 +12,7 @@
namespace game
{
+/// register game modules
void register_modules(bool register_client_modules)
{
con_print << "^BRegistering game modules..." << std::endl;
diff --git a/src/game/intro/Makefile.am b/src/game/intro/Makefile.am
index 66ea90d..fc5b019 100644
--- a/src/game/intro/Makefile.am
+++ b/src/game/intro/Makefile.am
@@ -1,2 +1,6 @@
-INCLUDES = -I$(top_srcdir)/src
+INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/game
METASOURCES = AUTO
+libintro_la_LDFLAGS = -avoid-version
+noinst_LTLIBRARIES = libintro.la
+libintro_la_SOURCES = intro.cc
+noinst_HEADERS = intro.h
diff --git a/src/game/intro/intro.cc b/src/game/intro/intro.cc
new file mode 100644
index 0000000..c0ae6da
--- /dev/null
+++ b/src/game/intro/intro.cc
@@ -0,0 +1,59 @@
+/*
+ intro/intro.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#include "intro/intro.h"
+#include "sys/sys.h"
+
+namespace intro {
+
+Intro::Intro() : core::Module("Introduction")
+{
+ intro_zone = 0;
+}
+
+Intro::~Intro()
+{
+}
+
+void Intro::init()
+{
+ /// intialize a single zone for the introduction
+ intro_zone = new core::Zone("intro");
+ intro_zone->set_name("Introduction");
+ core::Zone::add(intro_zone);
+
+ /// add a planet
+ core::EntityGlobe *planet = new core::EntityGlobe();
+ planet->set_zone(intro_zone);
+ planet->set_name("Planet");
+ planet->set_label("planet");
+ planet->entity_texture.assign("planets/seymour");
+ planet->entity_location.assign(0, -32.0f, 0.0f);
+ planet->entity_radius = 64.0f;
+ planet->entity_rotationspeed = 1.0f;
+
+ module_running = true;
+}
+
+void Intro::player_connect(core::Player *player)
+{
+ player->set_zone(intro_zone);
+}
+
+void Intro::player_disconnect(core::Player *player)
+{
+}
+
+void Intro::frame(float seconds)
+{
+}
+
+void Intro::shutdown()
+{
+}
+
+}
+
diff --git a/src/game/intro/intro.h b/src/game/intro/intro.h
new file mode 100644
index 0000000..21dc604
--- /dev/null
+++ b/src/game/intro/intro.h
@@ -0,0 +1,47 @@
+/*
+ intro/intro.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_INTRO_H__
+#define __INCLUDED_INTRO_H__
+
+#include "core/core.h"
+
+/// introduction game module
+namespace intro
+{
+
+/// introduction game module
+class Intro : public core::Module
+{
+public:
+ /// create an introduction game module
+ Intro();
+ /// delete an introduction game module
+ ~Intro();
+
+ /// run the introduction
+ void init();
+
+ /// shutdown the introduction
+ void shutdown();
+
+ /// run one frame
+ void frame(float seconds);
+
+ /// is called when a player connects
+ void player_connect(core::Player *player);
+
+ /// is called when a player disconnects
+ void player_disconnect(core::Player *player);
+
+private:
+ core::Zone *intro_zone;
+};
+
+}
+
+#endif // __INCLUDED_INTRO_H__
+