wire in the new timer sound and get rid of some of the sound glitches.
note: there is still one glitch, the timer sound will not start playing while in a dialog (but now it will continue playing if a dialog is opened).
This commit is contained in:
parent
6ee4558d1d
commit
5cc4bd41e1
6 changed files with 26 additions and 12 deletions
|
@ -7,6 +7,7 @@ Version 1.3.6+svn:
|
|||
* language and i18n:
|
||||
* updated translations: Danish, Japanese, Swedish
|
||||
* multiplayer:
|
||||
* improvements to the sound of the timer countdown
|
||||
* unit descriptions are no longer evaluated for the recruitment checksum
|
||||
and thus avoiding an OOS error when different languages are used.
|
||||
The change is incompatible with older trunk versions fixes (bug #9472).
|
||||
|
|
|
@ -85,6 +85,7 @@ namespace game_config
|
|||
|
||||
namespace sounds {
|
||||
const std::string turn_bell = "bell.wav",
|
||||
timer_bell = "timer.wav",
|
||||
receive_message = "receive.wav",
|
||||
user_arrive = "arrive.wav",
|
||||
user_leave = "leave.wav";
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace game_config
|
|||
|
||||
extern std::map<std::string, std::vector<Uint32> > team_rgb_colors;
|
||||
namespace sounds {
|
||||
extern const std::string turn_bell, receive_message, user_arrive, user_leave;
|
||||
extern const std::string turn_bell, timer_bell, receive_message, user_arrive, user_leave;
|
||||
extern const std::string button_press, checkbox_release, slider_adjust,
|
||||
menu_expand, menu_contract, menu_select;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ playmp_controller::playmp_controller(const config& level, const game_data& gamei
|
|||
bool skip_replay)
|
||||
: playsingle_controller(level, gameinfo, state_of_game, ticks, num_turns, game_config, video, skip_replay)
|
||||
{
|
||||
beep_warning_time_ = 10000; //Starts beeping each second when time is less than this (millisec)
|
||||
turn_data_ = NULL;
|
||||
}
|
||||
|
||||
|
@ -63,6 +62,7 @@ void playmp_controller::shout(){
|
|||
}
|
||||
|
||||
void playmp_controller::play_side(const unsigned int team_index, bool save){
|
||||
beep_warning_time_ = 10000; //Starts beeping each second when time is less than this (millisec)
|
||||
do {
|
||||
player_type_changed_ = false;
|
||||
end_turn_ = false;
|
||||
|
@ -93,6 +93,9 @@ void playmp_controller::play_side(const unsigned int team_index, bool save){
|
|||
}
|
||||
}
|
||||
LOG_NG << "human finished turn...\n";
|
||||
if(beep_warning_time_ < 10000) {
|
||||
sound::stop_bell();
|
||||
}
|
||||
} else if(current_team().is_ai()) {
|
||||
play_ai_turn();
|
||||
} else if(current_team().is_network()) {
|
||||
|
@ -143,20 +146,21 @@ void playmp_controller::play_human_turn(){
|
|||
const int ticks = SDL_GetTicks();
|
||||
int new_time = current_team().countdown_time()-maximum<int>(1,(ticks - cur_ticks));
|
||||
if (new_time > 0 ){
|
||||
current_team().set_countdown_time(current_team().countdown_time()-maximum<int>(1,(ticks - cur_ticks)));
|
||||
current_team().set_countdown_time(new_time);
|
||||
cur_ticks = ticks;
|
||||
if ( current_team().countdown_time() <= beep_warning_time_){
|
||||
beep_warning_time_ = beep_warning_time_ - 1000;
|
||||
if (current_team().countdown_time() <= beep_warning_time_){
|
||||
beep_warning_time_ = -1;
|
||||
const bool bell_on = preferences::turn_bell();
|
||||
if(bell_on || preferences::sound_on() || preferences::UI_sound_on()) {
|
||||
preferences::set_turn_bell(true);
|
||||
sound::play_bell(game_config::sounds::turn_bell);
|
||||
sound::play_bell(game_config::sounds::timer_bell, new_time);
|
||||
preferences::set_turn_bell(bell_on);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Clock time ended
|
||||
// If no turn bonus or action bonus -> defeat
|
||||
beep_warning_time_ = 10000;
|
||||
const int action_increment = lexical_cast_default<int>(level_["mp_countdown_action_bonus"],0);
|
||||
if ( lexical_cast_default<int>(level_["mp_countdown_turn_bonus"],0) == 0
|
||||
&& (action_increment == 0 || current_team().action_bonus_count() == 0)) {
|
||||
|
|
|
@ -41,7 +41,7 @@ std::vector<Mix_Chunk*> channel_chunks;
|
|||
std::vector<int> channel_ids;
|
||||
|
||||
static bool play_sound_internal(const std::string& files, channel_group group, bool sound_on,
|
||||
unsigned int distance=0, int id=-1);
|
||||
unsigned int distance=0, int id=-1, int loop_ticks=0);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -647,7 +647,7 @@ void play_sound_positioned(const std::string &files, int id, unsigned int distan
|
|||
play_sound_internal(files, SOUND_SOURCES, preferences::sound_on(), distance, id);
|
||||
}
|
||||
|
||||
bool play_sound_internal(const std::string& files, channel_group group, bool sound_on, unsigned int distance, int id)
|
||||
bool play_sound_internal(const std::string& files, channel_group group, bool sound_on, unsigned int distance, int id, int loop_ticks)
|
||||
{
|
||||
if(files.empty() || distance >= DISTANCE_SILENT || !sound_on || !mix_ok) {
|
||||
return false;
|
||||
|
@ -709,7 +709,15 @@ bool play_sound_internal(const std::string& files, channel_group group, bool sou
|
|||
it = sound_cache.begin();
|
||||
}
|
||||
|
||||
const int res = Mix_PlayChannel(channel, it->get_data(), 0);
|
||||
int res;
|
||||
if(loop_ticks > 0) {
|
||||
res = Mix_PlayChannel(channel, it->get_data(), -1);
|
||||
if(res >= 0) {
|
||||
Mix_ExpireChannel(channel, loop_ticks);
|
||||
}
|
||||
} else {
|
||||
res = Mix_PlayChannel(channel, it->get_data(), 0);
|
||||
}
|
||||
if(res < 0) {
|
||||
ERR_AUDIO << "error playing sound effect: " << Mix_GetError() << "\n";
|
||||
//still keep it in the sound cache, in case we want to try again later
|
||||
|
@ -727,9 +735,9 @@ void play_sound(const std::string& files, channel_group group)
|
|||
}
|
||||
|
||||
// Play bell on separate volume than sound
|
||||
void play_bell(const std::string& files)
|
||||
void play_bell(const std::string& files, int loop_ticks)
|
||||
{
|
||||
play_sound_internal(files, SOUND_BELL, preferences::turn_bell());
|
||||
play_sound_internal(files, SOUND_BELL, preferences::turn_bell(),0,-1,loop_ticks);
|
||||
}
|
||||
|
||||
// Play UI sounds on separate volume than soundfx
|
||||
|
|
|
@ -68,7 +68,7 @@ void play_sound(const std::string& files, channel_group group = SOUND_FX);
|
|||
void play_sound_positioned(const std::string &files, int id, unsigned int distance);
|
||||
|
||||
// Play sound, or random one of comma-separated sounds in bell channel
|
||||
void play_bell(const std::string& files);
|
||||
void play_bell(const std::string& files, int loop_ticks=0);
|
||||
|
||||
// Play user-interface sound, or random one of comma-separated sounds.
|
||||
void play_UI_sound(const std::string& files);
|
||||
|
|
Loading…
Add table
Reference in a new issue