Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-10-18 14:44:13 +0000
committerStijn Buys <ingar@osirion.org>2008-10-18 14:44:13 +0000
commitdb287e4a5133125bb6f25ba21ea97c47b19ac67f (patch)
treec977e4da6203344362a186010d017463d88def6e
parentade4627e7fe0f89d9fdb2e27f01444ad0aa2d41d (diff)
minor module updates
-rw-r--r--doc/STORYLINE21
-rw-r--r--src/core/application.cc6
-rw-r--r--src/core/commandbuffer.cc10
-rw-r--r--src/core/module.cc50
-rw-r--r--src/core/module.h22
-rw-r--r--src/filesystem/filesystem.cc4
-rw-r--r--src/game/base/base.cc5
-rw-r--r--src/game/game.cc4
-rw-r--r--src/game/intro/intro.cc2
9 files changed, 81 insertions, 43 deletions
diff --git a/doc/STORYLINE b/doc/STORYLINE
index 15e4377..9117c2d 100644
--- a/doc/STORYLINE
+++ b/doc/STORYLINE
@@ -192,9 +192,10 @@ The Alliance
and the massive rain of high-speed metallic debris following it. Some managed to retreat
to Tsu-Khan space, most fell victim to the united firepower of the Alliance fleet.
- News of the victory spread like fire through the Colonies, and the battle became legendary
- even before the Alliance fleet had returned. The heroic tales of the fleet plowing through
- the Emperial forces like a knight with a spear, gave birth to the name "Battle of The Lance".
+ News of the victory spread through the Colonies like fire, and the battle became legendary
+ even before the Alliance fleet had returned home. The heroic tales of the fleet plowing
+ through the Emperial forces like a knight with his spear, gave birth to the name
+ "Battle of The Lance".
Turning of the Tide
@@ -213,7 +214,7 @@ I. Chocolate milk
A cup of steaming hot chocolate milk! There were times I would have
laughed it the mere idea, but in these outskirts of the galaxy
chocolate was a hard to find commodity. And fresh milk? You'd have to
- have almost criminal connections to find it. fortunatly I had, and I did.
+ have almost criminal connections to find it. Fortunatly I had, and I did.
These were times for celebration. I had spend the loan I managed to get
from the local planetary bank on a small transport ship and I had just
finished my first day of marmitium transport from the Regula mining
@@ -273,7 +274,7 @@ I. Chocolate milk
a fresh start in live and I was determined not to let it get ruined by unfortunate
circumstances.
- It was hard to ignore the massive battleship looming over the station, but I docked and
+ It was hard to ignore the massive battleship looming over the outpost, but I docked and
went straight to the bar. The bartender looked at me as I walked in and pointed me to
my regular place at the bar. "I'll be right back", he said, and disappeared into the kitchen
compartment. As on most quiet evenings, the regular customers were kind enough to leave
@@ -299,9 +300,9 @@ II. Surprises
The military is always involved in business the common man would rather not know about, but I had
to admit, it just didn't sound right. A battleship in the Ghant system was curious, but a
more permanent presence didn't make any sense at all. I picked up the small metal spoon lying
- next to my cup and stirred my hot milk. "I wouldn't worry to much. They've probably discovered
+ next to my cup and stirred my hot milk. "I wouldn't worry too much. They've probably discovered
some interesting radiation in the neighbourhood and now they want to turn it into a weapon. You
- know these kind of people, of it goes kabooom, they immediately like it. "Besides", I continued,
+ know these kind of people, of it goes kabooom, they immediately like it." "Besides", I continued,
"the system has been quiet for months. I haven't seen a pirate in ages".
The tone in my voice couldn't hide my longing for more dangerous and exiting times,
@@ -341,3 +342,9 @@ II. Surprises
The spot grew larger as the ship approached the station.
+III. The suit
+
+ The design of the ship was unfamiliar. It looked like a patrol craft, armed to the teeth
+ and ready to defend itself if it were necessary. Fortunatly it looked like the pilot
+ had a more quiet evening in mind. It made a gracious arc around the Custodian before
+ heading straight to the docking clamps.
diff --git a/src/core/application.cc b/src/core/application.cc
index 837f294..0d52b76 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -309,9 +309,9 @@ void Application::quit(int status)
}
-Module *Application::load(std::string const &module_name)
+Module *Application::load(std::string const &module_label)
{
- if (game()) {
+ if (game() && Module::current()->interactive()) {
con_warn << "Connected. Disconnect first.\n";
return 0;
}
@@ -319,7 +319,7 @@ Module *Application::load(std::string const &module_name)
if (Module::current() && Module::current()->interactive()) {
module_interactive = Module::current();
}
- return Module::load(module_name.c_str());
+ return Module::load(module_label.c_str());
}
void Application::connect(std::string const &host)
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc
index 5ed3787..8c3c8a1 100644
--- a/src/core/commandbuffer.cc
+++ b/src/core/commandbuffer.cc
@@ -69,6 +69,12 @@ void func_list_model(std::string const &args)
model::Model::list();
}
+
+void func_list_module(std::string const &args)
+{
+ Module::list();
+}
+
void func_set(std::string const &args)
{
std::istringstream argstream(args);
@@ -168,6 +174,9 @@ void CommandBuffer::init()
Func::add("list_model", (FuncPtr) func_list_model);
func->set_info("list models");
+ Func::add("list_module", (FuncPtr) func_list_module);
+ func->set_info("list game modules");
+
func = Func::add("set", (FuncPtr)func_set);
func->set_info("[variable] [str] set variable value");
@@ -194,6 +203,7 @@ void CommandBuffer::shutdown()
Func::remove("list_func");
Func::remove("list_ent");
Func::remove("list_model");
+ Func::remove("list_module");
Func::remove("list_zone");
Func::remove("print");
Func::remove("print_file");
diff --git a/src/core/module.cc b/src/core/module.cc
index ae78260..319d651 100644
--- a/src/core/module.cc
+++ b/src/core/module.cc
@@ -4,6 +4,7 @@
the terms of the GNU General Public License version 2
*/
+#include "auxiliary/functions.h"
#include "core/module.h"
#include "sys/sys.h"
@@ -15,46 +16,51 @@ namespace core
Module *Module::module_preload = 0;
Module::Registry Module::module_registry;
-Module *Module::find(std::string const &name)
+Module *Module::find(const std::string &label)
{
- Registry::iterator it = module_registry.find(name);
+ Registry::iterator it = module_registry.find(label);
if (it == module_registry.end())
return 0;
else
return (*it).second;
}
-Module *Module::find(const char *name)
+Module *Module::find(const char *label)
{
- return(find(std::string(name)));
+ return(find(std::string(label)));
}
-Module *Module::add(const char *name, Module *module)
+Module *Module::add(Module *module)
{
- Module *m = find(name);
+ Module *m = find(module->label());
if (m) {
- con_warn << "module '" << name << "' already loaded!" << std::endl;
+ con_warn << "module '" << module->label() << "' already registered!" << std::endl;
delete module;
return 0;
}
- module_registry[std::string(name)] = module;
- module->module_label.assign(name);
+
+ module_registry[module->label()] = module;
+
if (!module_preload) {
module_preload = module;
- con_debug << " " << name << " " << module->name() << std::endl;
}
+ con_debug << " " << module->label() << " " << module->name() << std::endl;
+
return module;
}
-Module *Module::load(const char *name)
+Module *Module::load(const char *label)
{
- Module *module = find(name);
+ if (!label)
+ return 0;
+
+ Module *module = find(label);
if (!module) {
- con_warn << "could not find module '" << name << "'" << std::endl;
+ con_warn << "Could not find module '" << label << "'" << std::endl;
return 0;
}
- con_debug << " " << name << " " << module->name() << std::endl;
+ con_print << " module" << module->label() << " " << module->name() << std::endl;
module_preload = module;
return module;
}
@@ -63,17 +69,27 @@ void Module::clear()
{
for (Registry::iterator it = module_registry.begin(); it != module_registry.end(); it++) {
Module *module = (*it).second;
- delete module;
+ con_print << " " << module->label() << " " << module->name() << std::endl;
}
module_registry.clear();
module_preload = 0;
}
+void Module::list()
+{
+ for (Registry::iterator it = module_registry.begin(); it != module_registry.end(); it++) {
+ Module *module = (*it).second;
+ con_print << " " << module->label() << " " << module->name() << std::endl;
+
+ }
+ con_print << module_registry.size() << " registered game " << aux::plural("modules", module_registry.size()) << std::endl;
+}
+
/*-- instance functions --------------------------------------------*/
-Module::Module(const char *name) :
- module_name(name)
+Module::Module(const char *label, const char *name) :
+ module_label(label), module_name(name)
{
module_running = false;
module_interactive = true;
diff --git a/src/core/module.h b/src/core/module.h
index 20029cf..bc4f765 100644
--- a/src/core/module.h
+++ b/src/core/module.h
@@ -17,7 +17,7 @@ namespace core
class Module
{
public:
- Module(const char *name);
+ Module(const char *label, const char *name);
virtual ~Module();
/*----- inspectors ------------------------------------------------ */
@@ -27,12 +27,12 @@ public:
/// return true if the game module can not run a timeframe
inline bool error() const { return !module_running; }
- /// 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; }
+ /// return the name of the module
+ inline std::string const & name() const { return module_name; }
+
/// indicates if this is an interactive module or not
inline bool interactive() const { return module_interactive; }
@@ -58,16 +58,19 @@ public:
typedef std::map<std::string, Module *> Registry;
/// find a registered game module
- static Module *find(const char *name);
+ static Module *find(const char *label);
/// find a registered game module
- static Module *find(std::string const &name);
+ static Module *find(const std::string &label);
/// register a game module
- static Module *add(const char *name, Module *module);
+ static Module *add(Module *module);
/// load a registered game module
- static Module *load(const char *name);
+ static Module *load(const char *label);
+
+ /// list modules
+ static void list();
/// unload all modules
static void clear();
@@ -79,6 +82,7 @@ public:
static inline Registry & registry() { return module_registry; }
protected:
+
/// set the disconnected state
void abort();
@@ -86,8 +90,8 @@ protected:
bool module_interactive;
private:
- std::string module_name;
std::string module_label;
+ std::string module_name;
static Module *module_preload;
diff --git a/src/filesystem/filesystem.cc b/src/filesystem/filesystem.cc
index a8fca1d..19869a9 100644
--- a/src/filesystem/filesystem.cc
+++ b/src/filesystem/filesystem.cc
@@ -157,11 +157,11 @@ void init(std::string const & basename, std::string const & modname)
for (size_t i = 0; i < (*path).size(); i++)
if ((*path)[i] == '/') (*path)[i] = '\\';
#endif
- con_print << " directory: " << (*path) << std::endl;
+ con_print << " directory " << (*path) << std::endl;
}
// create writedir
- con_print << " home directory: " << filesystem_writedir << std::endl;
+ con_print << " home " << filesystem_writedir << std::endl;
}
void shutdown()
diff --git a/src/game/base/base.cc b/src/game/base/base.cc
index dee303b..f27d013 100644
--- a/src/game/base/base.cc
+++ b/src/game/base/base.cc
@@ -162,11 +162,11 @@ void func_impulse(core::Player *player, std::string const &args)
ship->impulse();
}
-/* ---- The Game class --------------------------------------------- */
+/* ---- class Base ------------------------------------------------ */
Base *Base::game_instance = 0;
-Base::Base() : core::Module("Project::OSiRiON")
+Base::Base() : core::Module("base", "Project::OSiRiON")
{
game_instance = this;
g_impulsespeed = 0;
@@ -216,6 +216,7 @@ void Base::init()
func = core::Func::add("list_ship", (core::FuncPtr) func_list_ship);
func->set_info("list ship statistics");
+ // add engine variables
g_impulsespeed = core::Cvar::get("g_impulsespeed", "15", core::Cvar::Game | core::Cvar::Archive);
g_impulsespeed->set_info("[float] speed of the impulse drive");
diff --git a/src/game/game.cc b/src/game/game.cc
index 7e89a0d..9f5b395 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -19,11 +19,11 @@ void register_modules(bool register_noninteractive_modules)
con_print << "^BRegistering game modules..." << std::endl;
// non-interactive modules
- core::Module::add("base", new base::Base());
+ core::Module::add(new base::Base());
// interactive modules
if (register_noninteractive_modules) {
- core::Module::add("intro", new intro::Intro());
+ core::Module::add(new intro::Intro());
}
}
diff --git a/src/game/intro/intro.cc b/src/game/intro/intro.cc
index 4eb9a10..abb3ba8 100644
--- a/src/game/intro/intro.cc
+++ b/src/game/intro/intro.cc
@@ -14,7 +14,7 @@
namespace intro {
-Intro::Intro() : core::Module("Introduction")
+Intro::Intro() : core::Module("intro", "Introduction")
{
module_interactive = false;
intro_zone = 0;