From 35613f0860a2d8cb643ca8de006de08503e48e53 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 18 Oct 2008 17:58:45 +0000 Subject: example module --- src/core/application.cc | 55 +++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 25 deletions(-) (limited to 'src/core/application.cc') diff --git a/src/core/application.cc b/src/core/application.cc index 0d52b76..71d739f 100644 --- a/src/core/application.cc +++ b/src/core/application.cc @@ -84,20 +84,6 @@ void func_msg(std::string const &args) 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; - } - std::string name(args); aux::to_label(name); application()->load(name); @@ -311,13 +297,32 @@ void Application::quit(int status) Module *Application::load(std::string const &module_label) { - if (game() && Module::current()->interactive()) { + if (!module_label.size()) { + if (Module::active()) { + con_print << " active module: " << Module::active()->label() << " " << Module::active()->name() << std::endl; + } + if (Module::loaded()) { + con_print << " loaded module: " << Module::loaded()->label() << " " << Module::loaded()->name() << std::endl; + } + if (module_interactive) { + con_print << " fallback module: " << module_interactive->label() << " " << module_interactive->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 0; + } +/* + if (Module::active() && Module::active()->interactive()) { con_warn << "Connected. Disconnect first.\n"; return 0; } - - if (Module::current() && Module::current()->interactive()) { - module_interactive = Module::current(); +*/ + if (Module::loaded() && Module::loaded()->interactive()) { + module_interactive = Module::loaded(); } return Module::load(module_label.c_str()); } @@ -325,13 +330,13 @@ Module *Application::load(std::string const &module_label) void Application::connect(std::string const &host) { if (connected()) { - if (!Module::current()->interactive() && module_interactive) { - /* if the current running module is non-interactive, - disconnect, and load the last interactive module_interactive - */ - disconnect(); - Module::load(module_interactive->label().c_str()); - + if (!Module::active()->interactive()) { + if ((Module::loaded() == Module::active()) && (module_interactive)) { + disconnect(); + Module::load(module_interactive->label().c_str()); + } else { + disconnect(); + } } else { con_warn << "Connected. Disconnect first.\n"; return; -- cgit v1.2.3