Advertisement
dominus

Untitled

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