Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Fixes for WavReader to explictly handle "LIST" and "cue " chunks (RA2) #15007
Apologies for the noise in your queue - I closed this issue prematurely and would like to reopen it: #14986
When an unknown .wav data chunk type is encountered, it's handled in the current WavReader class by just reading the next int then reading that many bytes.
This causes a problem in my Dark Reign mod where there is junk data at the end of the wav file data (Usually with the chunk type "????" or sometimes combined with unicode chars). The chunk size value read here is huge and crashes OpenRA.
D2k uses wav files, and so does RA2, so I tested these out by playing a few matches. D2k wav files never hit the default block above. RA2 wav files hit this block for "LIST" and "cue " chunk types.
In order to handle the junk data in the DR wavs, I've altered the default statement to skip to the end of the stream, and handled the RA2 chunks explictly:
In addition, for one .wav file, the s.ReadByte() alignment reaches the end of the file, so we have to drop out early here:
This will let me use the DR wavs without having to make a copy of WavLoader and WavReader in my mod with this fix applied.