Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-04 01:17:44 +0000
committerStijn Buys <ingar@osirion.org>2008-02-04 01:17:44 +0000
commit09fb43f3d36847977ac202c10c5a11f34af03a43 (patch)
tree45f4537347e9f8b3195cea00356963e9879a08fa /src/core
parent840f9b8678f607aecc15d47bc77248c4ac8b8574 (diff)
astyle
Diffstat (limited to 'src/core')
-rw-r--r--src/core/applicationinterface.cc51
-rw-r--r--src/core/commandbuffer.cc26
-rw-r--r--src/core/func.cc11
-rw-r--r--src/core/gameinterface.cc2
4 files changed, 51 insertions, 39 deletions
diff --git a/src/core/applicationinterface.cc b/src/core/applicationinterface.cc
index 63e1dea..561bf94 100644
--- a/src/core/applicationinterface.cc
+++ b/src/core/applicationinterface.cc
@@ -12,41 +12,47 @@
#include <errno.h>
#include <signal.h>
-namespace core {
+namespace core
+{
// --------------- function repository ------------------------------
-extern "C" void func_print(std::stringstream &args) {
+extern "C" void func_print(std::stringstream &args)
+{
char text[MAXCMDSIZE];
// FIXME leading space
- if(args.getline(text, MAXCMDSIZE))
+ if (args.getline(text, MAXCMDSIZE))
con_print << text << std::endl;
}
-extern "C" void func_help(std::stringstream &args) {
+extern "C" void func_help(std::stringstream &args)
+{
con_print << "This is the help function" << std::endl;
}
-extern "C" void func_quit(std::stringstream &args) {
- if(ApplicationInterface::instance()) {
+extern "C" void func_quit(std::stringstream &args)
+{
+ if (ApplicationInterface::instance()) {
ApplicationInterface::instance()->shutdown();
ApplicationInterface::instance()->quit(0);
}
}
-extern "C" void func_connect(std::stringstream &args) {
- if(ApplicationInterface::instance())
+extern "C" void func_connect(std::stringstream &args)
+{
+ if (ApplicationInterface::instance())
ApplicationInterface::instance()->connect();
}
-extern "C" void func_disconnect(std::stringstream &args) {
- if(ApplicationInterface::instance())
+extern "C" void func_disconnect(std::stringstream &args)
+{
+ if (ApplicationInterface::instance())
ApplicationInterface::instance()->disconnect();
}
// --------------- signal_handler -----------------------------------
extern "C" void signal_handler(int signum)
{
- switch(signum){
+ switch (signum) {
case SIGHUP:
case SIGINT:
case SIGQUIT:
@@ -71,13 +77,14 @@ extern "C" void signal_handler(int signum)
ApplicationInterface *ApplicationInterface::applicationinterface_instance = 0;
-ApplicationInterface::ApplicationInterface() {
+ApplicationInterface::ApplicationInterface()
+{
if (applicationinterface_instance) {
std::cerr << "multiple singleton instances: core::ApplicationInterface" << std::endl;
sys::quit(2);
}
applicationinterface_instance = this;
-
+
sys::signal(SIGHUP, signal_handler);
sys::signal(SIGINT, signal_handler);
sys::signal(SIGQUIT, signal_handler);
@@ -94,7 +101,7 @@ ApplicationInterface *ApplicationInterface::instance()
return applicationinterface_instance;
}
-void ApplicationInterface::init()
+void ApplicationInterface::init()
{
con_print << "Initializing core..." << std::endl;
con_debug << "Debug messages enabled" << std::endl;
@@ -110,10 +117,10 @@ void ApplicationInterface::init()
func_register("connect", func_connect);
func_register("disconnect", func_disconnect);
- if (game())
- game()->connected = false;
- else
- con_warn << "No game module loaded!" << std::endl;
+ if (game())
+ game()->connected = false;
+ else
+ con_warn << "No game module loaded!" << std::endl;
current_time = 0;
}
@@ -124,8 +131,8 @@ void ApplicationInterface::shutdown()
if (game())
if (game()->connected)
disconnect();
- else
- con_warn << "No game module loaded!" << std::endl;
+ else
+ con_warn << "No game module loaded!" << std::endl;
filesystem::shutdown();
}
@@ -133,7 +140,7 @@ void ApplicationInterface::shutdown()
void ApplicationInterface::quit(int status)
{
sys::quit(status);
-}
+}
void ApplicationInterface::connect()
{
@@ -141,7 +148,7 @@ void ApplicationInterface::connect()
con_warn << "No game module loaded!" << std::endl;
return;
}
-
+
if (game()->connected) {
con_warn << "Connected. Disconnect first." << std::endl;
}
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc
index fbeba7b..292013b 100644
--- a/src/core/commandbuffer.cc
+++ b/src/core/commandbuffer.cc
@@ -1,7 +1,7 @@
/*
core/commandbuffer.cc
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
*/
#include "core/commandbuffer.h"
@@ -11,18 +11,20 @@
#include <string>
#include <sstream>
-namespace core {
+namespace core
+{
std::stringstream cmd(std::stringstream::in | std::stringstream::out);
namespace commandbuffer {
-void exec(const char *text) {
+void exec(const char *text)
+{
std::stringstream cmdstream(text);
std::string cmdname;
cmdstream >> cmdname;
-
+
Func f = func_find(cmdname);
if (f) {
@@ -33,24 +35,26 @@ void exec(const char *text) {
con_print << "unknown command '" << cmdname << "'" << std::endl;
}
-void execute() {
+void execute()
+{
if (core::cmd.eof())
return;
char line[MAXCMDSIZE];
- while(core::cmd.getline(line, MAXCMDSIZE-1)) {
+ while (core::cmd.getline(line, MAXCMDSIZE-1)) {
exec(line);
}
cmd.clear();
}
-void clear() {
+void clear()
+{
char line[MAXCMDSIZE];
- while(core::cmd.getline(line, MAXCMDSIZE-1));
+ while (core::cmd.getline(line, MAXCMDSIZE-1));
}
-}
+} // namespace commandbuffer
-}
+} // namespace core
diff --git a/src/core/func.cc b/src/core/func.cc
index c4f14db..b89e556 100644
--- a/src/core/func.cc
+++ b/src/core/func.cc
@@ -1,13 +1,14 @@
/*
core/func.cc
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
*/
#include "core/func.h"
#include <map>
-namespace core {
+namespace core
+{
std::map<std::string, Func> functionmap;
@@ -15,7 +16,7 @@ void func_register(const char * functionname, Func functionptr)
{
functionmap[std::string(functionname)] = functionptr;
}
-
+
void func_unregister(std:: string functionname)
{
functionmap.erase(std::string(functionname));
@@ -26,4 +27,4 @@ Func func_find(std::string functionname)
return functionmap[functionname];
}
-}
+} // namespace core
diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc
index 86e8556..639a522 100644
--- a/src/core/gameinterface.cc
+++ b/src/core/gameinterface.cc
@@ -34,4 +34,4 @@ GameInterface *GameInterface::instance()
return gameinterface_instance;
}
-}
+} // namespace core