mirror of https://github.com/OpenTTD/OpenTTD
Codechange: use C++ initialisation over MemSetT
parent
6680169251
commit
82244779eb
|
@ -336,7 +336,6 @@ bool DLSFile::ReadDLSWave(FileHandle &f, DWORD list_length, long offset)
|
||||||
DLSWave &wave = this->waves.emplace_back();
|
DLSWave &wave = this->waves.emplace_back();
|
||||||
|
|
||||||
/* Set default values. */
|
/* Set default values. */
|
||||||
MemSetT(&wave.wave_sample, 0);
|
|
||||||
wave.wave_sample.cbSize = sizeof(WSMPL);
|
wave.wave_sample.cbSize = sizeof(WSMPL);
|
||||||
wave.wave_sample.usUnityNote = 60;
|
wave.wave_sample.usUnityNote = 60;
|
||||||
wave.file_offset = offset; // Store file offset so we can resolve the wave pool table later on.
|
wave.file_offset = offset; // Store file offset so we can resolve the wave pool table later on.
|
||||||
|
@ -441,8 +440,7 @@ bool DLSFile::LoadFile(std::string_view file)
|
||||||
|
|
||||||
Debug(driver, 2, "DMusic: Parsing DLS file");
|
Debug(driver, 2, "DMusic: Parsing DLS file");
|
||||||
|
|
||||||
DLSHEADER header;
|
DLSHEADER header{};
|
||||||
MemSetT(&header, 0);
|
|
||||||
|
|
||||||
/* Iterate over all chunks in the file. */
|
/* Iterate over all chunks in the file. */
|
||||||
while (hdr.length > 0) {
|
while (hdr.length > 0) {
|
||||||
|
@ -845,8 +843,7 @@ static void * DownloadArticulationData(int base_offset, void *data, const std::v
|
||||||
|
|
||||||
static std::optional<std::string_view> LoadDefaultDLSFile(std::optional<std::string_view> user_dls)
|
static std::optional<std::string_view> LoadDefaultDLSFile(std::optional<std::string_view> user_dls)
|
||||||
{
|
{
|
||||||
DMUS_PORTCAPS caps;
|
DMUS_PORTCAPS caps{};
|
||||||
MemSetT(&caps, 0);
|
|
||||||
caps.dwSize = sizeof(DMUS_PORTCAPS);
|
caps.dwSize = sizeof(DMUS_PORTCAPS);
|
||||||
_port->GetCaps(&caps);
|
_port->GetCaps(&caps);
|
||||||
|
|
||||||
|
@ -910,7 +907,7 @@ static std::optional<std::string_view> LoadDefaultDLSFile(std::optional<std::str
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill download data. */
|
/* Fill download data. */
|
||||||
MemSetT(wave, 0);
|
*wave = {};
|
||||||
wave->dlInfo.dwDLType = DMUS_DOWNLOADINFO_WAVE;
|
wave->dlInfo.dwDLType = DMUS_DOWNLOADINFO_WAVE;
|
||||||
wave->dlInfo.cbSize = wave_size;
|
wave->dlInfo.cbSize = wave_size;
|
||||||
wave->dlInfo.dwDLId = dlid_wave + i;
|
wave->dlInfo.dwDLId = dlid_wave + i;
|
||||||
|
@ -989,7 +986,7 @@ static std::optional<std::string_view> LoadDefaultDLSFile(std::optional<std::str
|
||||||
|
|
||||||
/* Instrument header. */
|
/* Instrument header. */
|
||||||
DMUS_INSTRUMENT *inst_data = (DMUS_INSTRUMENT *)instrument;
|
DMUS_INSTRUMENT *inst_data = (DMUS_INSTRUMENT *)instrument;
|
||||||
MemSetT(inst_data, 0);
|
*inst_data = {};
|
||||||
offset_table[last_offset++] = reinterpret_cast<const std::byte *>(inst_data) - inst_base;
|
offset_table[last_offset++] = reinterpret_cast<const std::byte *>(inst_data) - inst_base;
|
||||||
inst_data->ulPatch = (dls_file.instruments[i].hdr.Locale.ulBank & F_INSTRUMENT_DRUMS) | ((dls_file.instruments[i].hdr.Locale.ulBank & 0x7F7F) << 8) | (dls_file.instruments[i].hdr.Locale.ulInstrument & 0x7F);
|
inst_data->ulPatch = (dls_file.instruments[i].hdr.Locale.ulBank & F_INSTRUMENT_DRUMS) | ((dls_file.instruments[i].hdr.Locale.ulBank & 0x7F7F) << 8) | (dls_file.instruments[i].hdr.Locale.ulInstrument & 0x7F);
|
||||||
instrument = inst_data + 1;
|
instrument = inst_data + 1;
|
||||||
|
@ -1092,8 +1089,7 @@ std::optional<std::string_view> MusicDriver_DMusic::Start(const StringList &parm
|
||||||
/* Print all valid output ports. */
|
/* Print all valid output ports. */
|
||||||
char desc[DMUS_MAX_DESCRIPTION];
|
char desc[DMUS_MAX_DESCRIPTION];
|
||||||
|
|
||||||
DMUS_PORTCAPS caps;
|
DMUS_PORTCAPS caps{};
|
||||||
MemSetT(&caps, 0);
|
|
||||||
caps.dwSize = sizeof(DMUS_PORTCAPS);
|
caps.dwSize = sizeof(DMUS_PORTCAPS);
|
||||||
|
|
||||||
Debug(driver, 1, "Detected DirectMusic ports:");
|
Debug(driver, 1, "Detected DirectMusic ports:");
|
||||||
|
@ -1107,8 +1103,7 @@ std::optional<std::string_view> MusicDriver_DMusic::Start(const StringList &parm
|
||||||
GUID guidPort;
|
GUID guidPort;
|
||||||
if (pIdx >= 0) {
|
if (pIdx >= 0) {
|
||||||
/* Check if the passed port is a valid port. */
|
/* Check if the passed port is a valid port. */
|
||||||
DMUS_PORTCAPS caps;
|
DMUS_PORTCAPS caps{};
|
||||||
MemSetT(&caps, 0);
|
|
||||||
caps.dwSize = sizeof(DMUS_PORTCAPS);
|
caps.dwSize = sizeof(DMUS_PORTCAPS);
|
||||||
if (FAILED(_music->EnumPort(pIdx, &caps))) return "Supplied port parameter is not a valid port";
|
if (FAILED(_music->EnumPort(pIdx, &caps))) return "Supplied port parameter is not a valid port";
|
||||||
if (caps.dwClass != DMUS_PC_OUTPUTCLASS) return "Supplied port parameter is not an output port";
|
if (caps.dwClass != DMUS_PC_OUTPUTCLASS) return "Supplied port parameter is not an output port";
|
||||||
|
@ -1118,8 +1113,7 @@ std::optional<std::string_view> MusicDriver_DMusic::Start(const StringList &parm
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create new port. */
|
/* Create new port. */
|
||||||
DMUS_PORTPARAMS params;
|
DMUS_PORTPARAMS params{};
|
||||||
MemSetT(¶ms, 0);
|
|
||||||
params.dwSize = sizeof(DMUS_PORTPARAMS);
|
params.dwSize = sizeof(DMUS_PORTPARAMS);
|
||||||
params.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS;
|
params.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS;
|
||||||
params.dwChannelGroups = 1;
|
params.dwChannelGroups = 1;
|
||||||
|
@ -1128,8 +1122,7 @@ std::optional<std::string_view> MusicDriver_DMusic::Start(const StringList &parm
|
||||||
if (FAILED(_port->Activate(TRUE))) return "Failed to activate port";
|
if (FAILED(_port->Activate(TRUE))) return "Failed to activate port";
|
||||||
|
|
||||||
/* Create playback buffer. */
|
/* Create playback buffer. */
|
||||||
DMUS_BUFFERDESC desc;
|
DMUS_BUFFERDESC desc{};
|
||||||
MemSetT(&desc, 0);
|
|
||||||
desc.dwSize = sizeof(DMUS_BUFFERDESC);
|
desc.dwSize = sizeof(DMUS_BUFFERDESC);
|
||||||
desc.guidBufferFormat = KSDATAFORMAT_SUBTYPE_DIRECTMUSIC;
|
desc.guidBufferFormat = KSDATAFORMAT_SUBTYPE_DIRECTMUSIC;
|
||||||
desc.cbBuffer = 1024;
|
desc.cbBuffer = 1024;
|
||||||
|
|
Loading…
Reference in New Issue