From 067991730e8404058d2827f502fb4b2c8330d99d Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 1 Jul 2005 21:46:19 +0000 Subject: [PATCH] fix music problems, is openal faster now? SVN-Revision: 2666 --- data/levels/test/default.nut | 5 ----- src/audio/sound_manager.cpp | 14 ++++++++++++++ src/game_session.cpp | 1 + src/scripting/functions.cpp | 2 +- src/scripting/functions.hpp | 6 ++++-- src/scripting/wrapper.cpp | 8 ++++---- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/data/levels/test/default.nut b/data/levels/test/default.nut index 874b024a8..71be66eab 100644 --- a/data/levels/test/default.nut +++ b/data/levels/test/default.nut @@ -1,7 +1,2 @@ /* Default functions for the whole levelset */ -function wait(time) { - set_wakeup_time(time); - suspend(); -} - diff --git a/src/audio/sound_manager.cpp b/src/audio/sound_manager.cpp index a1ed57e6a..cd9d9cdd3 100644 --- a/src/audio/sound_manager.cpp +++ b/src/audio/sound_manager.cpp @@ -192,6 +192,13 @@ SoundManager::play_music(const std::string& filename, bool fade) void SoundManager::set_listener_position(const Vector& pos) { + static Uint32 lastticks = SDL_GetTicks(); + + Uint32 current_ticks = SDL_GetTicks(); + if(current_ticks - lastticks < 300) + return; + lastticks = current_ticks; + alListener3f(AL_POSITION, pos.x, pos.y, 0); } @@ -204,6 +211,13 @@ SoundManager::set_listener_velocity(const Vector& vel) void SoundManager::update() { + static Uint32 lastticks = SDL_GetTicks(); + + Uint32 current_ticks = SDL_GetTicks(); + if(current_ticks - lastticks < 300) + return; + lastticks = current_ticks; + // check for finished sound sources for(SoundSources::iterator i = sources.begin(); i != sources.end(); ) { SoundSource* source = *i; diff --git a/src/game_session.cpp b/src/game_session.cpp index fbeac4ea7..efbc9c558 100644 --- a/src/game_session.cpp +++ b/src/game_session.cpp @@ -684,6 +684,7 @@ GameSession::display_info_box(const std::string& text) running = false; box->draw(*context); draw(); + sound_manager->update(); } delete box; diff --git a/src/scripting/functions.cpp b/src/scripting/functions.cpp index 10e5f2b14..2e51cad65 100644 --- a/src/scripting/functions.cpp +++ b/src/scripting/functions.cpp @@ -12,7 +12,7 @@ namespace Scripting { -void set_wakeup_time(float seconds) +void wait(float seconds) { ScriptInterpreter::current()->set_wakeup_time(seconds); } diff --git a/src/scripting/functions.hpp b/src/scripting/functions.hpp index a2c518d20..debc9af70 100644 --- a/src/scripting/functions.hpp +++ b/src/scripting/functions.hpp @@ -6,8 +6,10 @@ namespace Scripting /** displays a text file and scrolls it over the screen */ void display_text_file(const std::string& filename); -/** Suspends the script execution for the specified number of seconds */ -void set_wakeup_time(float seconds); +/** @SUSPEND@ + * Suspends the script execution for the specified number of seconds + * */ +void wait(float seconds); /** translates a give text into the users language (by looking it up in the .po * files) */ diff --git a/src/scripting/wrapper.cpp b/src/scripting/wrapper.cpp index 90b39e87b..2d51cdb07 100644 --- a/src/scripting/wrapper.cpp +++ b/src/scripting/wrapper.cpp @@ -418,14 +418,14 @@ static int display_text_file_wrapper(HSQUIRRELVM v) return 0; } -static int set_wakeup_time_wrapper(HSQUIRRELVM v) +static int wait_wrapper(HSQUIRRELVM v) { float arg0; sq_getfloat(v, 2, &arg0); - Scripting::set_wakeup_time(arg0); + Scripting::wait(arg0); - return 0; + return sq_suspendvm(v); } static int translate_wrapper(HSQUIRRELVM v) @@ -452,7 +452,7 @@ static int import_wrapper(HSQUIRRELVM v) WrappedFunction supertux_global_functions[] = { { "display_text_file", &display_text_file_wrapper }, - { "set_wakeup_time", &set_wakeup_time_wrapper }, + { "wait", &wait_wrapper }, { "translate", &translate_wrapper }, { "import", &import_wrapper }, { 0, 0 } -- 2.11.0