Advertisement
dominus

Untitled

Apr 12th, 2024
1,316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.34 KB | None | 0 0
  1. diff --git a/gamewin.cc b/gamewin.cc
  2. index 15df83838..4c8c92333 100644
  3. --- a/gamewin.cc
  4. +++ b/gamewin.cc
  5. @@ -173,111 +173,94 @@ void Background_noise::handle_event(unsigned long curtime, uintptr udata) {
  6.     } else if (weather == 1) {
  7.         currentstate = SnowStorm;
  8.     } else if (nighttime) {
  9. -       currentstate = Nighttime;    // Night time
  10. +       currentstate = Nighttime;
  11.     } else {
  12.         currentstate = Outside;
  13.     }
  14.  
  15.     MyMidiPlayer* player = Audio::get_ptr()->get_midi();
  16. -   // Lets allow this for Digital Muisc and MT32Emu only,
  17. -   // for MT32/FakeMT32 conversion as well.
  18. -   // if (player) {
  19. -   // if (player && player->get_ogg_enabled()){
  20. -   if (player
  21. -       && (player->get_ogg_enabled() || player->is_mt32()
  22. -           || player->is_adlib())) {
  23. -       delay = 1000;    // Quickly get back to this function check
  24. -       // We've got OGG so play the background SFX tracks
  25. +   // The sfx tracks only play for Digital Music, MT32emu, MT32/FakeMT32
  26. +   // FMOpl is not sounding acceptable.
  27. +   const bool    play_bg_tracks = player && (player->get_ogg_enabled() || player->is_mt32());
  28.  
  29. +   if (player || play_bg_tracks) {
  30. +       delay = 1000;    // Quickly get back to this function check
  31.         const int curr_track = player->get_current_track();
  32. -
  33. -       // Testing. Original seems to allow crickets for all songs at night,
  34. -       // except when in a dungeon. Also, only do it sometimes.
  35. -       if (nighttime && currentstate != Dungeon && rand() % 6 == 0) {
  36. -           // Play the cricket sounds at night
  37. -           Audio::get_ptr()->play_sound_effect(
  38. -                   Audio::game_sfx(61), AUDIO_MAX_VOLUME - 30);
  39. -       }
  40. -
  41.         if ((curr_track == -1 || laststate != currentstate)
  42.             && Audio::get_ptr()->is_music_enabled()) {
  43. -           // Don't override bee cave music with dungeon music.
  44. -           const bool notbees = !GAME_BG || curr_track != 54;
  45.             // ++++ TODO: Need to come up with a way to replace repeating songs
  46.             // here, just so they don't loop forever.
  47.             // Conditions: not playing music, playing a background music
  48.             if (curr_track == -1 || gwin->is_bg_track(curr_track)
  49. -               || (((currentstate == Dungeon && notbees)
  50. -                    || currentstate == DangerNear)
  51. +               || (((currentstate == Dungeon)
  52. +                   || currentstate == DangerNear)
  53.                     && !is_combat_music(curr_track))) {
  54. -               // Not already playing music
  55.                 int tracknum = 255;
  56. -
  57.                 // Get the relevant track number.
  58.                 if (nearby_hostile && !gwin->in_combat()) {
  59.                     tracknum  = Audio::game_music(10);
  60.                     laststate = DangerNear;
  61.                 } else if (gwin->is_in_dungeon()) {
  62. -                   // Start the SFX music track then
  63. -                   tracknum  = Audio::game_music(52);
  64. +                   if (play_bg_tracks)
  65. +                       tracknum  = Audio::game_music(52);
  66.                     laststate = Dungeon;
  67.                 } else if (weather == 1) {    // Snowstorm
  68. -                   tracknum  = Audio::game_music(5);
  69. +                   if (play_bg_tracks)
  70. +                       tracknum  = Audio::game_music(5);
  71.                     laststate = SnowStorm;
  72.                 } else if (weather == 2) {    // Rainstorm
  73. -                   tracknum  = Audio::game_music(4);
  74. +                   if (play_bg_tracks)
  75. +                       tracknum  = Audio::game_music(4);
  76.                     laststate = RainStorm;
  77. -               } else if (bghour < 6 || bghour > 20) {
  78. -                   tracknum  = Audio::game_music(7);
  79. +               } else if (nighttime) {
  80. +                   // Disabled nighttime sfx track as it is very distracting
  81. +                   /*if (play_bg_tracks)
  82. +                       tracknum  = Audio::game_music(7);*/
  83.                     laststate = Nighttime;
  84.                 } else {
  85. -                   // Start the SFX music track then
  86. -                   tracknum  = Audio::game_music(6);
  87. +                   if (play_bg_tracks)
  88. +                       tracknum  = Audio::game_music(6);
  89.                     laststate = Outside;
  90.                 }
  91.                 Audio::get_ptr()->start_music(tracknum, true);
  92.             }
  93.         }
  94. -   } else {
  95. -       Main_actor* ava = gwin->get_main_actor();
  96. -       // Tests to see if track is playing the SFX tracks, possible
  97. -       // when the game has been restored
  98. -       // and the Audio option was changed from OGG to something else
  99. -       if (player && player->get_current_track() >= Audio::game_music(4)
  100. -           && player->get_current_track() <= Audio::game_music(8)) {
  101. -           player->stop_music();
  102. -       }
  103. -
  104. -       // Not OGG so play the SFX sounds manually
  105. -       //  Only if outside.
  106. -       if (ava && !gwin->is_main_actor_inside() &&
  107. -           // +++++SI SFX's don't sound right.
  108. -           Game::get_game_type() == BLACK_GATE) {
  109. -           int                        sound;    // BG SFX #.
  110. -           static const unsigned char bgnight[] = {61, 61, 255};
  111. -           static const unsigned char bgday[]   = {82, 85, 85};
  112. -           if (repeats > 0) {    // Repeating?
  113. -               sound = last_sound;
  114. -           } else {
  115. -               const int hour = gwin->get_clock()->get_hour();
  116. -               if (hour < 6 || hour > 20) {
  117. -                   sound = bgnight[rand() % sizeof(bgnight)];
  118. -               } else {
  119. -                   sound = bgday[rand() % sizeof(bgday)];
  120. -               }
  121. -               // Translate BG to SI #'s.
  122. -               sound      = Audio::game_sfx(sound);
  123. -               last_sound = sound;
  124. -           }
  125. -           Audio::get_ptr()->play_sound_effect(sound);
  126. -           repeats++;    // Count it.
  127. -           if (rand() % (repeats + 1) == 0) {
  128. -               // Repeat.
  129. -               delay = 500 + rand() % 1000;
  130. -           } else {
  131. -               delay   = 4000 + rand() % 3000;
  132. -               repeats = 0;
  133. +   }
  134. +
  135. +   // Tests to see if day sfx track is playing, possible
  136. +   // when the game has been restored
  137. +   // and the Audio option was changed from OGG/MT32 to something else
  138. +   // If nighttime sfx track is uncommented, also query whether track 7 plays
  139. +   if (player && !play_bg_tracks && player->get_current_track() == 6) {
  140. +       player->stop_music();
  141. +   }
  142. +   Main_actor* ava = gwin->get_main_actor();
  143. +   // Testing. When outside play birds during daytime or crickets at night
  144. +   if (ava && !gwin->is_main_actor_inside() && currentstate != Dungeon) {
  145. +       int                        sound;    // SFX #.
  146. +       int                       volume;    // keep the volume down.
  147. +       static const unsigned char bgnight[] = {61, 61, 255};
  148. +       static const unsigned char bgday[]   = {82, 85, 85};
  149. +       if (repeats > 0) {    // Repeating?
  150. +           sound = last_sound;
  151. +       } else {
  152. +           if (nighttime) {
  153. +               sound = bgnight[rand() % sizeof(bgnight)];
  154. +           // only play daytime sfx when no music track is playing
  155. +           } else if (!play_bg_tracks && player->get_current_track() == -1) {
  156. +               sound = bgday[rand() % sizeof(bgday)];
  157.             }
  158. +           last_sound = sound;
  159. +       }
  160. +       Audio::get_ptr()->play_sound_effect(
  161. +               Audio::game_sfx(sound), AUDIO_MAX_VOLUME - 200);
  162. +       repeats++;    // Count it.
  163. +       if (rand() % (repeats + 1) == 0) {
  164. +           // Repeat.
  165. +           delay = 500 + rand() % 1000;
  166. +       } else {
  167. +           delay   = 4000 + rand() % 3000;
  168. +           repeats = 0;
  169.         }
  170.     }
  171.  
  172.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement