From b4973888aeaea2dde6058bc06c3f6631349e7f3c Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 3 Feb 2008 01:43:03 +0000 Subject: command buffer handling engine function parsing buffered client console --- src/core/applicationinterface.cc | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/core/applicationinterface.cc') diff --git a/src/core/applicationinterface.cc b/src/core/applicationinterface.cc index 209a4f5..9a2cce2 100644 --- a/src/core/applicationinterface.cc +++ b/src/core/applicationinterface.cc @@ -14,6 +14,17 @@ namespace core { +// --------------- function repository ------------------------------ +extern "C" void func_print(std::stringstream &args) { + char text[MAXCMDSIZE]; + if(args.getline(text, MAXCMDSIZE)) + con_print << args << std::endl; +} + +extern "C" void func_help(std::stringstream &args) { + con_print << "This is the help function" << std::endl; +} + // --------------- signal_handler ----------------------------------- extern "C" void signal_handler(int signum) { @@ -71,10 +82,14 @@ void ApplicationInterface::init() con_debug << "Initializing core..." << std::endl; + // register our functions + func::add("print", func_print); + func::add("help", func_help); + if (game()) game()->init(); else - con_warn << "No game module found!" << std::endl; + con_warn << "No game module loaded!" << std::endl; } @@ -85,7 +100,7 @@ void ApplicationInterface::shutdown() if (game()) game()->shutdown(); else - con_warn << "No game module found!" << std::endl; + con_warn << "No game module loaded!" << std::endl; filesystem::shutdown(); } @@ -97,8 +112,12 @@ void ApplicationInterface::quit(int status) void ApplicationInterface::frame(float seconds) { - if (game()) + if (game()) { game()->frame(seconds); + } + + // execute commands in the buffer + commandbuffer::execute(); } } -- cgit v1.2.3