Codechange: replace for loops with endof with range-based for loops

This commit is contained in:
Rubidium
2024-04-07 22:18:39 +02:00
committed by rubidium42
parent 095bdf32fe
commit 4e6d4fcf32
6 changed files with 26 additions and 29 deletions

View File

@@ -45,10 +45,10 @@ static DWORD WINAPI SoundThread(LPVOID)
SetCurrentThreadName("ottd:win-sound");
do {
for (WAVEHDR *hdr = _wave_hdr; hdr != endof(_wave_hdr); hdr++) {
if ((hdr->dwFlags & WHDR_INQUEUE) != 0) continue;
MxMixSamples(hdr->lpData, hdr->dwBufferLength / 4);
if (waveOutWrite(_waveout, hdr, sizeof(WAVEHDR)) != MMSYSERR_NOERROR) {
for (auto &hdr : _wave_hdr) {
if ((hdr.dwFlags & WHDR_INQUEUE) != 0) continue;
MxMixSamples(hdr.lpData, hdr.dwBufferLength / 4);
if (waveOutWrite(_waveout, &hdr, sizeof(WAVEHDR)) != MMSYSERR_NOERROR) {
MessageBox(nullptr, L"Sounds are disabled until restart.", L"waveOutWrite failed", MB_ICONINFORMATION);
return 0;
}