Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-09-28 21:34:53 +0000
committerStijn Buys <ingar@osirion.org>2008-09-28 21:34:53 +0000
commit9252bfb61fabea1f45afacb19d805eb5fdd01599 (patch)
tree13fdfb005ab0b690766d35572f0eeecca28f6009 /src/core
parent6774f2b5d14c1957d163ef4b7914c2660b59fdfd (diff)
intro module
Diffstat (limited to 'src/core')
-rw-r--r--src/core/application.cc33
-rw-r--r--src/core/gameserver.cc2
-rw-r--r--src/core/module.cc1
-rw-r--r--src/core/module.h7
4 files changed, 42 insertions, 1 deletions
diff --git a/src/core/application.cc b/src/core/application.cc
index f8b9a73..2b3f41f 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -12,6 +12,7 @@
#include <sstream>
#include <fstream>
+#include "auxiliary/functions.h"
#include "sys/sys.h"
#include "math/mathlib.h"
#include "filesystem/filesystem.h"
@@ -80,6 +81,34 @@ void func_msg(std::string const &args)
con_print << "Not connected." << std::endl;
}
}
+
+void func_load(std::string const &args)
+{
+ if (!args.size()) {
+ if (Module::current()) {
+ con_print << " currently loaded: " << Module::current()->label() << " " << Module::current()->name() << std::endl;
+ }
+
+ std::string helpstr(" available modules:");
+ for(Module::Registry::iterator it = Module::registry().begin(); it != Module::registry().end(); it++) {
+ helpstr += ' ';
+ helpstr += (*it).first;
+ }
+ con_print << helpstr << std::endl;
+ return;
+ }
+
+ if (game()) {
+ con_warn << "Connected. Disconnect first.\n";
+ return;
+ }
+
+ std::string name(args);
+ aux::to_label(name);
+
+ Module::load(name.c_str());
+}
+
// --------------- signal_handler -----------------------------------
#ifndef _WIN32
@@ -224,6 +253,9 @@ void Application::init(int count, char **arguments)
func = Func::add("quit", func_quit);
func->set_info("exit the application");
+ func = Func::add("load", func_load);
+ func->set_info("[str] load a game module");
+
func = Func::add("connect", func_connect);
func->set_info("[ip] without ip, create a game");
@@ -260,6 +292,7 @@ void Application::shutdown()
Func::remove("connect");
Func::remove("disconnect");
+ Func::remove("load");
#ifdef _WIN32
// shutdown win32 socket library
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index e086096..70786af 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -621,7 +621,7 @@ void GameServer::frame(float seconds)
}
- // mark all entities as udpated
+ // mark all entities as updated
for (Entity::Registry::iterator it=Entity::registry().begin(); it != Entity::registry().end(); ) {
Entity *entity = (*it).second;
diff --git a/src/core/module.cc b/src/core/module.cc
index 89bc2fe..29c9eb8 100644
--- a/src/core/module.cc
+++ b/src/core/module.cc
@@ -38,6 +38,7 @@ Module *Module::add(const char *name, Module *module)
return 0;
}
module_registry[std::string(name)] = module;
+ module->module_label.assign(name);
if (!module_preload) {
module_preload = module;
con_debug << " " << name << " " << module->name() << std::endl;
diff --git a/src/core/module.h b/src/core/module.h
index bd99034..b46c296 100644
--- a/src/core/module.h
+++ b/src/core/module.h
@@ -30,6 +30,9 @@ public:
/// return the name of the module
inline std::string const & name() const { return module_name; }
+ /// label of the module
+ inline std::string const & label() const { return module_label; }
+
/*----- mutators -------------------------------------------------- */
/// initialize the game module
@@ -69,6 +72,9 @@ public:
/// currently loaded module
static inline Module *current() { return module_preload; }
+ /// module registry
+ static inline Registry & registry() { return module_registry; }
+
protected:
/// set the disconnected state
void abort();
@@ -77,6 +83,7 @@ protected:
private:
std::string module_name;
+ std::string module_label;
static Module *module_preload;