1
0
Fork 0

Codechange: Use std::array and proper unique_ptr init for original sounds.

Avoids C-style memory clearing.
pull/11566/head
Peter Nelson 2023-11-27 18:39:57 +00:00
parent 0a8bcdd344
commit f1efb392ae
No known key found for this signature in database
GPG Key ID: 8EF8F0A467DF75ED
2 changed files with 4 additions and 4 deletions

View File

@ -156,7 +156,7 @@ bool LoadNewGRFSound(SoundEntry *sound)
Debug(grf, 1, "LoadNewGRFSound [{}]: RIFF does not contain any sound data", file.GetSimplifiedFilename());
/* Clear everything that was read */
MemSetT(sound, 0);
*sound = {};
return false;
}

View File

@ -21,7 +21,7 @@
#include "safeguards.h"
static SoundEntry _original_sounds[ORIGINAL_SAMPLE_COUNT];
static std::array<SoundEntry, ORIGINAL_SAMPLE_COUNT> _original_sounds;
static void OpenBankFile(const std::string &filename)
{
@ -31,12 +31,12 @@ static void OpenBankFile(const std::string &filename)
*/
static std::unique_ptr<RandomAccessFile> original_sound_file;
memset(_original_sounds, 0, sizeof(_original_sounds));
_original_sounds.fill({});
/* If there is no sound file (nosound set), don't load anything */
if (filename.empty()) return;
original_sound_file.reset(new RandomAccessFile(filename, BASESET_DIR));
original_sound_file = std::make_unique<RandomAccessFile>(filename, BASESET_DIR);
size_t pos = original_sound_file->GetPos();
uint count = original_sound_file->ReadDword();