From 1a28393dabf4f4696bf433ddde52e7a25253c955 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 16 Oct 2008 16:34:15 +0000 Subject: various user interface related updates --- src/client/client.cc | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src/client/client.cc') diff --git a/src/client/client.cc b/src/client/client.cc index 200becd..13c6214 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -41,9 +41,7 @@ void func_snd_restart(std::string const &args) entity->state()->clearsound(); } - audio::shutdown(); - - audio::init(); + audio::reset(); } void func_r_restart(std::string const &args) @@ -96,7 +94,7 @@ void Client::init(int count, char **arguments) con_print << "^BInitializing client..." << std::endl; // initialize core - core::Cvar::sv_dedicated = core::Cvar::set("sv_private", "0"); + core::Cvar::sv_private = core::Cvar::set("sv_private", "0"); core::Application::init(count, arguments); // client variables @@ -145,8 +143,10 @@ void Client::init(int count, char **arguments) func = core::Func::add("ui_console", func_ui_console); func->set_info("toggle console on or off"); - //func = core::Func::add("snd_restart", (core::FuncPtr) func_snd_restart); - //func->set_info("restart audio subsystem"); + func = core::Func::add("snd_restart", (core::FuncPtr) func_snd_restart); + func->set_info("restart audio subsystem"); + + previous_timestamp = 0; } void Client::run() @@ -182,10 +182,7 @@ void Client::run() Uint32 d = client_current_timestamp - client_previous_timestamp; if ((d > 0)) { if (d >= client_frame_lenght) { - float elapsed = (float)(d) / 1000.f; - - frame(elapsed); - + frame(client_current_timestamp); client_previous_timestamp = client_current_timestamp; } else { SDL_Delay(client_frame_lenght - d); @@ -197,9 +194,9 @@ void Client::run() } -void Client::frame(float seconds) +void Client::frame(unsigned long timestamp) { - core::Application::frame(seconds); + core::Application::frame(timestamp); if (!core::application()->connected()) { // load the intro if nothing is running @@ -217,8 +214,9 @@ void Client::frame(float seconds) } } - video::frame(seconds); - input::frame(seconds); + video::frame((float)(timestamp - previous_timestamp) / 1000.0f); + input::frame(); + previous_timestamp = timestamp; } void Client::shutdown() @@ -230,7 +228,7 @@ void Client::shutdown() core::Func::remove("r_restart"); core::Func::remove("ui_chat"); core::Func::remove("ui_console"); - //core::Func::remove("snd_restart"); + core::Func::remove("snd_restart"); audio::shutdown(); @@ -254,7 +252,7 @@ void Client::notify_connect() void Client::notify_disconnect() { - // FIXME unload sounds + audio::reset(); render::reset(); input::reset(); } -- cgit v1.2.3