@@ -960,6 +960,11 @@ void parse_gamesnd_new(game_snd* gs, bool no_create)
960960 }
961961}
962962
963+ bool gamesnd_is_placeholder (const game_snd& gs)
964+ {
965+ return gs.sound_entries .empty () || gs.sound_entries [0 ].filename [0 ] == ' \0 ' ;
966+ }
967+
963968void gamesnd_parse_entry (game_snd *gs, bool &orig_no_create, SCP_vector<game_snd> *lookupVector, size_t lookupVectorMaxIndexableSize, bool (*is_reserved_index)(int ))
964969{
965970 SCP_string name;
@@ -1015,7 +1020,7 @@ void gamesnd_parse_entry(game_snd *gs, bool &orig_no_create, SCP_vector<game_snd
10151020 auto existing_gs = &lookupVector->at (vectorIndex);
10161021
10171022 // if the existing sound was an empty or placeholder sound, replace it, don't warn
1018- if (existing_gs-> sound_entries . empty () || existing_gs-> sound_entries [ 0 ]. filename [ 0 ] == ' \0 ' )
1023+ if (gamesnd_is_placeholder (* existing_gs) )
10191024 {
10201025 gs = existing_gs;
10211026 orig_no_create = true ; // prevent sound from being appended in parse_sound_table
@@ -1461,6 +1466,17 @@ void gamesnd_parse_soundstbl(bool first_stage)
14611466 // these vectors should be the same size
14621467 while (Snds_iface_handle.size () < Snds_iface.size ())
14631468 Snds_iface_handle.push_back (sound_handle::invalid ());
1469+
1470+ // mark any placeholder sounds as invalid
1471+ // (most places in the code already check for this, but it is possible for sexps and scripts to attempt to play an empty sound)
1472+ for (auto & snd : Snds)
1473+ if (gamesnd_is_placeholder (snd))
1474+ snd.flags |= GAME_SND_NOT_VALID;
1475+
1476+ // ditto for interface sounds
1477+ for (auto & snd : Snds_iface)
1478+ if (gamesnd_is_placeholder (snd))
1479+ snd.flags |= GAME_SND_NOT_VALID;
14641480 }
14651481 else
14661482 {
0 commit comments