From 9252bfb61fabea1f45afacb19d805eb5fdd01599 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 28 Sep 2008 21:34:53 +0000 Subject: intro module --- src/core/application.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/core/application.cc') 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 #include +#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 -- cgit v1.2.3