Advertisement
dominus

Untitled

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