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 14:33:14 +0000
committerStijn Buys <ingar@osirion.org>2008-11-08 14:33:14 +0000
commit731dfb8f3ca9c34e4160021cb221c3056c00dbf9 (patch)
treecb8214aa1a8990dbb4b0e1ef4688eea030c76a52 /src/client
parent1317b6c1a231f5ccaf4ce11814863c77f93d8921 (diff)
finalized renaming from server namespace to dedicated
Diffstat (limited to 'src/client')
-rw-r--r--src/client/client.cc85
-rw-r--r--src/client/client.h13
-rw-r--r--src/client/input.cc8
3 files changed, 57 insertions, 49 deletions
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);