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-11-08 10:17:37 +0000
committerStijn Buys <ingar@osirion.org>2008-11-08 10:17:37 +0000
commit4cad4a27677b0490d3ba0018bc3404961f925ed5 (patch)
treef9d59542f27f66a9fb4c8938f40aec66994449fc /src/core/application.cc
parent27ab3566118e77754fefb32a41ee06cf24a59dfe (diff)
docking, bumps network protocol version
Diffstat (limited to 'src/core/application.cc')
-rw-r--r--src/core/application.cc151
1 files changed, 76 insertions, 75 deletions
diff --git a/src/core/application.cc b/src/core/application.cc
index 09e900d..300aaa6 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -27,69 +27,7 @@
namespace core
{
-// --------------- engine functions ------------------------------
-void func_help(std::string const &args)
-{
- std::istringstream argstream(args);
- std::string topic;
- if (!(argstream >> topic))
- topic.assign("help");
-
- topic.append(".txt");
- CommandBuffer::print_file("help/" + topic);
-}
-
-void func_quit(std::string const &args)
-{
- application()->shutdown();
- application()->quit(0);
-}
-
-void func_connect(std::string const &args)
-{
- std::istringstream argstream(args);
- std::string host;
- if (!(argstream >> host))
- host.clear();
-
- application()->connect(host);
-}
-
-void func_disconnect(std::string const &args)
-{
- application()->disconnect();
-}
-
-void func_say(std::string const &args)
-{
- if (connection()) {
- connection()->say(args);
- } else if (server()) {
- server()->say(localplayer(), args);
- } else {
- con_print << "Not connected." << std::endl;
- }
-}
-
-void func_msg(std::string const &args)
-{
- if (connection()) {
- connection()->private_message(args);
- } else if (server()) {
- server()->private_message(localplayer(), args);
- } else {
- con_print << "Not connected." << std::endl;
- }
-}
-
-void func_load(std::string const &args)
-{
- std::string name(args);
- aux::to_label(name);
- application()->load(name);
-}
-
-// --------------- signal_handler -----------------------------------
+/* ---- signal handler --------------------------------------------- */
#ifndef _WIN32
extern "C" void signal_handler(int signum)
@@ -101,11 +39,11 @@ extern "C" void signal_handler(int signum)
case SIGTERM:
if (Application::instance()) {
con_warn << "Received signal " << signum << ", shutting down...\n";
- application()->shutdown();
- application()->quit(0);
+ Application::instance()->shutdown();
+ Application::instance()->quit(0);
} else {
std::cerr << "Received signal " << signum << ", terminated...\n";
- application()->quit(1);
+ Application::instance()->quit(1);
}
break;
#ifdef HAVE_CURSES
@@ -115,13 +53,13 @@ extern "C" void signal_handler(int signum)
#endif
default:
std::cerr << "Received signal " << signum << ", terminated...\n";
- application()->quit(1);
+ Application::instance()->quit(1);
break;
}
}
#endif
-// --------------- Application -----------------------------
+/* ---- class Application ------------------------------------------ */
Application *Application::application_instance = 0;
@@ -229,25 +167,25 @@ void Application::init(int count, char **arguments)
// register our engine functions
Func *func = 0;
- func = Func::add("help", func_help);
+ func = Func::add("help", Application::func_help);
func->set_info("help function");
- func = Func::add("quit", func_quit);
+ func = Func::add("quit", Application::func_quit);
func->set_info("exit the application");
- func = Func::add("load", func_load);
+ func = Func::add("load", Application::func_load);
func->set_info("[str] load a game module");
- func = Func::add("connect", func_connect);
+ func = Func::add("connect", Application::func_connect);
func->set_info("[ip] without ip, create a game");
- func = Func::add("disconnect", func_disconnect);
+ func = Func::add("disconnect", Application::func_disconnect);
func->set_info("leave the current game");
- func = Func::add("say", func_say);
+ func = Func::add("say", Application::func_say);
func->set_info("say [text] say something on the public chat");
- func = Func::add("msg", func_msg);
+ func = Func::add("msg", Application::func_msg);
func->set_info("msg [player] [text] send a private message to another player");
func = 0;
@@ -552,4 +490,67 @@ void Application::notify_remove_sound(size_t source)
// Dedicated servers don't need sounds
}
+/* -- static engine functions -------------------------------------- */
+
+void Application::func_help(std::string const &args)
+{
+ std::istringstream argstream(args);
+ std::string topic;
+ if (!(argstream >> topic))
+ topic.assign("help");
+
+ topic.append(".txt");
+ CommandBuffer::print_file("help/" + topic);
+}
+
+void Application::func_quit(std::string const &args)
+{
+ Application::instance()->shutdown();
+ Application::instance()->quit(0);
+}
+
+void Application::func_connect(std::string const &args)
+{
+ std::istringstream argstream(args);
+ std::string host;
+ if (!(argstream >> host))
+ host.clear();
+
+ Application::instance()->connect(host);
+}
+
+void Application::func_disconnect(std::string const &args)
+{
+ Application::instance()->disconnect();
+}
+
+void Application::func_say(std::string const &args)
+{
+ if (connection()) {
+ connection()->say(args);
+ } else if (server()) {
+ server()->say(localplayer(), args);
+ } else {
+ con_print << "Not connected." << std::endl;
+ }
+}
+
+void Application::func_msg(std::string const &args)
+{
+ if (connection()) {
+ connection()->private_message(args);
+ } else if (server()) {
+ server()->private_message(localplayer(), args);
+ } else {
+ con_print << "Not connected." << std::endl;
+ }
+}
+
+void Application::func_load(std::string const &args)
+{
+ std::string name(args);
+ aux::to_label(name);
+ Application::instance()->load(name);
+}
+
}