Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am8
-rw-r--r--src/client/client.cc85
-rw-r--r--src/client/client.h13
-rw-r--r--src/client/input.cc8
-rw-r--r--src/dedicated/Makefile.am10
-rw-r--r--src/dedicated/console.cc6
-rw-r--r--src/dedicated/console.h10
-rw-r--r--src/dedicated/dedicated.cc45
-rw-r--r--src/dedicated/dedicated.h36
-rw-r--r--src/osirion.cc2
-rw-r--r--src/osiriond.cc4
11 files changed, 115 insertions, 112 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 9def3fe..3bd5adf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,7 +4,7 @@ SUFFIXES = .rc
.rc.o:
windres $< -o $@
-SUBDIRS = sys math auxiliary filesystem model core server audio render ui \
+SUBDIRS = auxiliary sys filesystem math model core dedicated audio render ui \
client game
noinst_HEADERS = config.h
@@ -15,17 +15,17 @@ else
bin_PROGRAMS = osiriond osirion
endif
-# dedicated server
+# dedicated dedicated
osiriond_SOURCES = osiriond.cc
EXTRA_osiriond_SOURCES = osiriond-res.rc
osiriond_DEPENDENCIES = $(ICON_SERVER) $(top_builddir)/src/core/libcore.la \
$(top_builddir)/src/filesystem/libfilesystem.la $(top_builddir)/src/game/libgame.la $(top_builddir)/src/math/libmath.la \
- $(top_builddir)/src/model/libmodel.la $(top_builddir)/src/server/libserver.la \
+ $(top_builddir)/src/model/libmodel.la $(top_builddir)/src/dedicated/libdedicated.la \
$(top_builddir)/src/sys/libsys.la $(top_builddir)/src/auxiliary/libauxiliary.la
osiriond_LDADD = $(top_builddir)/src/auxiliary/libauxiliary.la \
$(top_builddir)/src/core/libcore.la $(top_builddir)/src/filesystem/libfilesystem.la \
$(top_builddir)/src/game/libgame.la \
- $(top_builddir)/src/model/libmodel.la $(top_builddir)/src/server/libserver.la \
+ $(top_builddir)/src/model/libmodel.la $(top_builddir)/src/dedicated/libdedicated.la \
$(top_builddir)/src/math/libmath.la $(top_builddir)/src/sys/libsys.la $(HOST_LIBS) $(ICON_SERVER) $(CURSES_LIBS)
# client
diff --git a/src/client/client.cc b/src/client/client.cc
index 6fccbe8..a83beb7 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -29,44 +29,15 @@ core::Cvar *cl_frametime = 0;
Client app;
-//--- engine functions --------------------------------------------
-
-void func_snd_restart(std::string const &args)
-{
- // unload entity sounds
- for (core::Entity::Registry::iterator it = core::Entity::registry().begin(); it != core::Entity::registry().end(); it++) {
- core::Entity *entity = (*it).second;
- if (entity->state())
- entity->state()->clearsound();
- }
-
- audio::reset();
-}
-
-void func_r_restart(std::string const &args)
-{
- video::restart();
-}
+//--- public ------------------------------------------------------
-void func_ui_chat(std::string const &args)
-{
- if (core::application()->connected()) {
- client()->view()->chat()->set_small_view(false);
- client()->view()->chat()->toggle();
- }
-}
-void func_ui_chatsmall(std::string const &args)
+Client *client()
{
- if (core::application()->connected()) {
- client()->view()->chat()->set_small_view(true);
- client()->view()->chat()->toggle();
- }
+ return &app;
}
-//--- public ------------------------------------------------------
-
-void client_main(int count, char **arguments)
+void run(int count, char **arguments)
{
std::cout << core::name() << " " << core::version() << std::endl;
@@ -79,11 +50,6 @@ void client_main(int count, char **arguments)
app.shutdown();
}
-Client *client()
-{
- return &app;
-}
-
//--- private -----------------------------------------------------
void Client::quit(int status)
@@ -141,16 +107,16 @@ void Client::init(int count, char **arguments)
// add engine functions
core::Func *func = 0;
- func = core::Func::add("r_restart", (core::FuncPtr) func_r_restart);
+ func = core::Func::add("r_restart", Client::func_r_restart);
func->set_info("restart render subsystem");
- func = core::Func::add("ui_chat", func_ui_chat);
+ func = core::Func::add("ui_chat", Client::func_ui_chat);
func->set_info("toggle chat window");
- func = core::Func::add("ui_chatsmall", func_ui_chatsmall);
+ func = core::Func::add("ui_chatsmall", Client::func_ui_chatsmall);
func->set_info("toggle small chat window");
- func = core::Func::add("snd_restart", (core::FuncPtr) func_snd_restart);
+ func = core::Func::add("snd_restart", Client::func_snd_restart);
func->set_info("restart audio subsystem");
previous_timestamp = 0;
@@ -341,5 +307,40 @@ void Client::notify_remove_sound(size_t source)
audio::Sources::remove(source);
}
+//--- engine functions --------------------------------------------
+
+void Client::func_snd_restart(std::string const &args)
+{
+ // unload entity sounds
+ for (core::Entity::Registry::iterator it = core::Entity::registry().begin(); it != core::Entity::registry().end(); it++) {
+ core::Entity *entity = (*it).second;
+ if (entity->state())
+ entity->state()->clearsound();
+ }
+
+ audio::reset();
+}
+
+void Client::func_r_restart(std::string const &args)
+{
+ video::restart();
+}
+
+void Client::func_ui_chat(std::string const &args)
+{
+ if (core::application()->connected()) {
+ client()->view()->chat()->set_small_view(false);
+ client()->view()->chat()->toggle();
+ }
+}
+
+void Client::func_ui_chatsmall(std::string const &args)
+{
+ if (core::application()->connected()) {
+ client()->view()->chat()->set_small_view(true);
+ client()->view()->chat()->toggle();
+ }
+}
+
} // namespace client
diff --git a/src/client/client.h b/src/client/client.h
index 6fb294d..33f64e5 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -13,6 +13,9 @@
/// client part of the engine
namespace client {
+/// run the client application
+void run(int count, char **arguments);
+
/// client application implementation
class Client : public core::Application
{
@@ -61,15 +64,17 @@ protected:
virtual void frame(unsigned long timestamp);
private:
+
+ static void func_snd_restart(std::string const &args);
+ static void func_r_restart(std::string const &args);
+ static void func_ui_chat(std::string const &args);
+ static void func_ui_chatsmall(std::string const &args);
+
View *client_view;
unsigned long previous_timestamp;
};
-
-/// the client main loop
-void client_main(int count, char **arguments);
-
Client *client();
}
diff --git a/src/client/input.cc b/src/client/input.cc
index 1df64df..026237e 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -321,9 +321,11 @@ void shutdown()
core::Func::remove("ui_control");
core::Func::remove("ui_view");
- keyboard->save_binds();
- delete keyboard;
- keyboard = 0;
+ if (keyboard) {
+ keyboard->save_binds();
+ delete keyboard;
+ keyboard = 0;
+ }
SDL_ShowCursor(SDL_ENABLE);
SDL_WM_GrabInput(SDL_GRAB_OFF);
diff --git a/src/dedicated/Makefile.am b/src/dedicated/Makefile.am
index bc2f741..879829e 100644
--- a/src/dedicated/Makefile.am
+++ b/src/dedicated/Makefile.am
@@ -1,7 +1,7 @@
METASOURCES = AUTO
-libserver_la_SOURCES = console.cc server.cc
-noinst_HEADERS = console.h server.h
-noinst_LTLIBRARIES = libserver.la
+libdedicated_la_SOURCES = console.cc dedicated.cc
+noinst_HEADERS = console.h dedicated.h
+noinst_LTLIBRARIES = libdedicated.la
INCLUDES = -I$(top_srcdir)/src
-libserver_la_LDFLAGS = -avoid-version -no-undefined
-libserver_la_LIBADD = $(top_builddir)/src/core/libcore.la
+libdedicated_la_LDFLAGS = -avoid-version -no-undefined
+libdedicated_la_LIBADD = $(top_builddir)/src/core/libcore.la
diff --git a/src/dedicated/console.cc b/src/dedicated/console.cc
index 9fdad4f..74b1101 100644
--- a/src/dedicated/console.cc
+++ b/src/dedicated/console.cc
@@ -11,16 +11,16 @@
#include <iomanip>
#include <cmath>
-#include "server/console.h"
+#include "auxiliary/functions.h"
#include "core/core.h"
+#include "dedicated/console.h"
#include "sys/consoleinterface.h"
-#include "auxiliary/functions.h"
#ifdef HAVE_CURSES
#include <ncurses.h>
#endif
-namespace server {
+namespace dedicated {
bool console_initialized = false;
bool console_updated = false;
diff --git a/src/dedicated/console.h b/src/dedicated/console.h
index 13db3fc..6ab26ba 100644
--- a/src/dedicated/console.h
+++ b/src/dedicated/console.h
@@ -1,15 +1,15 @@
/*
- server/console.h
+ dedicated/console.h
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/
-#ifndef __INCLUDED_SERVER_CONSOLE_H__
-#define __INCLUDED_SERVER_CONSOLE_H__
+#ifndef __INCLUDED_DEDICATED_CONSOLE_H__
+#define __INCLUDED_DEDICATED_CONSOLE_H__
#include "sys/consoleinterface.h"
-namespace server {
+namespace dedicated {
class Console : public sys::ConsoleInterface {
public:
@@ -62,5 +62,5 @@ Console *console();
}
-#endif // __INCLUDED_SERVER_CONSOLE_H__
+#endif // __INCLUDED_DEDICATED_CONSOLE_H__
diff --git a/src/dedicated/dedicated.cc b/src/dedicated/dedicated.cc
index a4424a0..387fcbe 100644
--- a/src/dedicated/dedicated.cc
+++ b/src/dedicated/dedicated.cc
@@ -1,5 +1,5 @@
/*
- server/server.cc
+ dedicated/dedicated.cc
This file is part of the Osirion project and is distributed under
the terms and conditions of the GNU General Public License version 2
*/
@@ -10,36 +10,12 @@
#include "core/core.h"
#include "core/stats.h"
#include "core/timer.h"
-#include "server/console.h"
-#include "server/server.h"
+#include "dedicated/console.h"
+#include "dedicated/dedicated.h"
-namespace server {
+namespace dedicated {
-//--- private definition ------------------------------------------
-
-/// server Application implementation
-class Server : public core::Application {
-public:
- /// initialize the server Application
- virtual void init(int count, char **arguments);
-
- /// run the server Application
- virtual void run();
-
- /// shutdown the server Application
- virtual void shutdown();
-
- /// quit the server Application
- virtual void quit(int status);
-};
-
-
-Server app;
-
-//--- public ------------------------------------------------------
-
-/// the server main loop
-void main(int count, char **arguments)
+void run(int count, char **arguments)
{
std::cout << core::name() << " " << core::version() << std::endl;
@@ -47,14 +23,15 @@ void main(int count, char **arguments)
std::cout << arguments[i] << " ";
std::cout << std::endl;
+ Dedicated app;
app.init(count, arguments);
app.run();
app.shutdown();
}
-//--- private -----------------------------------------------------
+/* ---- class Dedicated -------------------------------------------- */
-void Server::init(int count, char **arguments)
+void Dedicated::init(int count, char **arguments)
{
con_print << "^BInitializing server..." << std::endl;
@@ -71,7 +48,7 @@ void Server::init(int count, char **arguments)
core::Application::connect(empty);
}
-void Server::run()
+void Dedicated::run()
{
float server_framerate = 1.0f / 25.0f;
@@ -89,7 +66,7 @@ void Server::run()
}
}
-void Server::shutdown()
+void Dedicated::shutdown()
{
con_print << "^BShutting down server..." << std::endl;
@@ -114,7 +91,7 @@ void Server::shutdown()
quit(0);
}
-void Server::quit(int status)
+void Dedicated::quit(int status)
{
core::Application::quit(status);
}
diff --git a/src/dedicated/dedicated.h b/src/dedicated/dedicated.h
index 4691e91..4b1f584 100644
--- a/src/dedicated/dedicated.h
+++ b/src/dedicated/dedicated.h
@@ -1,19 +1,37 @@
/*
- server/server.h
+ dedicated/dedicated.h
This file is part of the Osirion project and is distributed under
the terms and conditions of the GNU General Public License version 2
*/
-#ifndef __INCLUDED_SERVER_H__
-#define __INCLUDED_SERVER_H__
+#ifndef __INCLUDED_DEDICATED_H__
+#define __INCLUDED_DEDICATED_H__
-/// contains classes and functions to run a dedicated server
-namespace server {
+#include "core/application.h"
-/// the server main loop
-void main(int count, char **arguments);
+/// contains classes and functions to run the dedicated server
+namespace dedicated {
+
+/// run the dedicated server
+void run(int count, char **arguments);
-} // namespace server
+/// server application implementation
+class Dedicated : public core::Application {
+public:
+ /// initialize the server Application
+ virtual void init(int count, char **arguments);
+
+ /// run the server Application
+ virtual void run();
+
+ /// shutdown the server Application
+ virtual void shutdown();
+
+ /// quit the server Application
+ virtual void quit(int status);
+};
+
+} // namespace dedicated
-#endif // __INCLUDED_SERVER_H__
+#endif // __INCLUDED_DEDICATED_H__
diff --git a/src/osirion.cc b/src/osirion.cc
index 71bd1ec..cccbd2d 100644
--- a/src/osirion.cc
+++ b/src/osirion.cc
@@ -12,7 +12,7 @@ int main(int count, char **arguments)
// load the game modules
game::register_modules(true);
- client::client_main(count, arguments);
+ client::run(count, arguments);
return 0;
}
diff --git a/src/osiriond.cc b/src/osiriond.cc
index bd88df0..f38d553 100644
--- a/src/osiriond.cc
+++ b/src/osiriond.cc
@@ -4,7 +4,7 @@
the terms and conditions of the GNU General Public License version 2
*/
-#include "server/server.h"
+#include "dedicated/dedicated.h"
#include "game/game.h"
int main(int count, char **arguments)
@@ -12,7 +12,7 @@ int main(int count, char **arguments)
// preload the game module
game::register_modules(false);
- server::main(count, arguments);
+ dedicated::run(count, arguments);
return 0;
}