Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/gamewin.cc b/gamewin.cc
- index 15df83838..b976b6211 100644
- --- a/gamewin.cc
- +++ b/gamewin.cc
- @@ -164,6 +164,7 @@ void Background_noise::handle_event(unsigned long curtime, uintptr udata) {
- const int weather = gwin->get_effects()->get_weather();
- const bool nighttime = bghour < 6 || bghour > 20;
- const bool nearby_hostile = gwin->is_hostile_nearby();
- +
- if (nearby_hostile && !gwin->in_combat()) {
- currentstate = DangerNear;
- } else if (gwin->is_in_dungeon()) {
- @@ -173,111 +174,99 @@ void Background_noise::handle_event(unsigned long curtime, uintptr udata) {
- } else if (weather == 1) {
- currentstate = SnowStorm;
- } else if (nighttime) {
- - currentstate = Nighttime; // Night time
- + currentstate = Nighttime;
- } else {
- currentstate = Outside;
- }
- MyMidiPlayer* player = Audio::get_ptr()->get_midi();
- - // Lets allow this for Digital Muisc and MT32Emu only,
- - // for MT32/FakeMT32 conversion as well.
- - // if (player) {
- - // if (player && player->get_ogg_enabled()){
- - if (player
- - && (player->get_ogg_enabled() || player->is_mt32()
- - || player->is_adlib())) {
- - delay = 1000; // Quickly get back to this function check
- - // We've got OGG so play the background SFX tracks
- -
- - const int curr_track = player->get_current_track();
- -
- - // Testing. Original seems to allow crickets for all songs at night,
- - // except when in a dungeon. Also, only do it sometimes.
- - if (nighttime && currentstate != Dungeon && rand() % 6 == 0) {
- - // Play the cricket sounds at night
- - Audio::get_ptr()->play_sound_effect(
- - Audio::game_sfx(61), AUDIO_MAX_VOLUME - 30);
- - }
- -
- - if ((curr_track == -1 || laststate != currentstate)
- - && Audio::get_ptr()->is_music_enabled()) {
- - // Don't override bee cave music with dungeon music.
- - const bool notbees = !GAME_BG || curr_track != 54;
- - // ++++ TODO: Need to come up with a way to replace repeating songs
- - // here, just so they don't loop forever.
- - // Conditions: not playing music, playing a background music
- - if (curr_track == -1 || gwin->is_bg_track(curr_track)
- - || (((currentstate == Dungeon && notbees)
- - || currentstate == DangerNear)
- - && !is_combat_music(curr_track))) {
- + // The sfx tracks only play for Digital Music, FMOpl, MT32emu, MT32/FakeMT32
- + const bool play_sfx_tracks = player && (player->get_ogg_enabled() || player->is_mt32()
- + || player->is_adlib());
- +
- + delay = 1000; // Quickly get back to this function check
- +
- + // We've got OGG so play the background SFX tracks
- + const int curr_track = player->get_current_track();
- +
- + // Tests to see if day/night sfx track is playing, possible
- + // when the game has been restored
- + // and the Audio option was changed from OGG to something else
- + /*if (player && (curr_track == 6 || curr_track == 7)) {
- + player->stop_music();
- + }*/
- + Main_actor* ava = gwin->get_main_actor();
- + // Testing. When outside play birds during daytime or crickets at night
- + if (ava && !gwin->is_main_actor_inside() && currentstate != Dungeon) {
- + int sound; // SFX #.
- + int volume; // keep the volume down.
- + static const unsigned char bgnight[] = {61, 61, 255};
- + static const unsigned char bgday[] = {82, 85, 85};
- + if (repeats > 0) { // Repeating?
- + sound = last_sound;
- + } else {
- + if (nighttime) {
- + sound = bgnight[rand() % sizeof(bgnight)];
- + volume = AUDIO_MAX_VOLUME - 200;
- + } else {
- + sound = bgday[rand() % sizeof(bgday)];
- + volume = AUDIO_MAX_VOLUME - 200;
- + }
- + last_sound = sound;
- + }
- + Audio::get_ptr()->play_sound_effect(
- + Audio::game_sfx(sound), volume);
- + repeats++; // Count it.
- + if (rand() % (repeats + 1) == 0) {
- + // Repeat.
- + delay = 500 + rand() % 1000;
- + } else {
- + delay = 4000 + rand() % 3000;
- + repeats = 0;
- + }
- + }
- +
- + if ((curr_track == -1 || laststate != currentstate)
- + && Audio::get_ptr()->is_music_enabled()) {
- + // Don't override bee cave music with dungeon music.
- + const bool notbees = !GAME_BG || curr_track != 54;
- + // ++++ TODO: Need to come up with a way to replace repeating songs
- + // here, just so they don't loop forever.
- + // Conditions: not playing music, playing a background music
- + if (curr_track == -1 || gwin->is_bg_track(curr_track)
- + || (((currentstate == Dungeon && notbees)
- + || currentstate == DangerNear)
- + && !is_combat_music(curr_track))) {
- // Not already playing music
- - int tracknum = 255;
- -
- - // Get the relevant track number.
- - if (nearby_hostile && !gwin->in_combat()) {
- - tracknum = Audio::game_music(10);
- - laststate = DangerNear;
- - } else if (gwin->is_in_dungeon()) {
- - // Start the SFX music track then
- + int tracknum = 255;
- + // Get the relevant track number.
- + if (nearby_hostile && !gwin->in_combat()) {
- + tracknum = Audio::game_music(10);
- + laststate = DangerNear;
- + } else if (gwin->is_in_dungeon()) {
- + if (play_sfx_tracks)
- tracknum = Audio::game_music(52);
- - laststate = Dungeon;
- - } else if (weather == 1) { // Snowstorm
- + laststate = Dungeon;
- + } else if (weather == 1) { // Snowstorm
- + if (play_sfx_tracks)
- tracknum = Audio::game_music(5);
- - laststate = SnowStorm;
- - } else if (weather == 2) { // Rainstorm
- + laststate = SnowStorm;
- + } else if (weather == 2) { // Rainstorm
- + if (play_sfx_tracks)
- tracknum = Audio::game_music(4);
- - laststate = RainStorm;
- - } else if (bghour < 6 || bghour > 20) {
- - tracknum = Audio::game_music(7);
- - laststate = Nighttime;
- - } else {
- - // Start the SFX music track then
- - tracknum = Audio::game_music(6);
- - laststate = Outside;
- - }
- - Audio::get_ptr()->start_music(tracknum, true);
- - }
- - }
- - } else {
- - Main_actor* ava = gwin->get_main_actor();
- - // Tests to see if track is playing the SFX tracks, possible
- - // when the game has been restored
- - // and the Audio option was changed from OGG to something else
- - if (player && player->get_current_track() >= Audio::game_music(4)
- - && player->get_current_track() <= Audio::game_music(8)) {
- - player->stop_music();
- - }
- -
- - // Not OGG so play the SFX sounds manually
- - // Only if outside.
- - if (ava && !gwin->is_main_actor_inside() &&
- - // +++++SI SFX's don't sound right.
- - Game::get_game_type() == BLACK_GATE) {
- - int sound; // BG SFX #.
- - static const unsigned char bgnight[] = {61, 61, 255};
- - static const unsigned char bgday[] = {82, 85, 85};
- - if (repeats > 0) { // Repeating?
- - sound = last_sound;
- - } else {
- - const int hour = gwin->get_clock()->get_hour();
- - if (hour < 6 || hour > 20) {
- - sound = bgnight[rand() % sizeof(bgnight)];
- - } else {
- - sound = bgday[rand() % sizeof(bgday)];
- - }
- - // Translate BG to SI #'s.
- - sound = Audio::game_sfx(sound);
- - last_sound = sound;
- - }
- - Audio::get_ptr()->play_sound_effect(sound);
- - repeats++; // Count it.
- - if (rand() % (repeats + 1) == 0) {
- - // Repeat.
- - delay = 500 + rand() % 1000;
- + laststate = RainStorm;
- + } else if (nighttime) {
- + // Disabled nighttime sfx track as it sounds horrible
- + /*if (play_sfx_tracks)
- + tracknum = Audio::game_music(7);*/
- + laststate = Nighttime;
- } else {
- - delay = 4000 + rand() % 3000;
- - repeats = 0;
- + // Disabled daytime sfx track as it sounds horrible
- + /*if (play_sfx_tracks)
- + tracknum = Audio::game_music(6);*/
- + laststate = Outside;
- }
- + Audio::get_ptr()->start_music(tracknum, true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement