cmake+ci: run clang-tidy (#512)

* cmake+ci: run clang-tidy

* Remove DESCRIPTION from LEGO1/LegoOmni.mingw.def

* Add initial .clang-tidy and fixes

* fix file perms

* Comment out DESCRIPTION

* Remove LegoEntity::~LegoEntity and MxPresenter::~MxPresenter from mingw's LEGO1.def

* Looks like clang is allergic to the libs in the directx5 SDK

* Update .clang-tidy

* Fix typo in .clang-tidy

* Attempt to generate an action error

* Revert "Attempt to generate an action error"

This reverts commit 96c4c65fed.

* cmake: test with -Wparentheses + optionally with -Werror

* ci: -k0 is a Ninja argument

* Use -Werror only for msys2 builds

* cmake: only emit warnings for specific warnings

* cmake: and don't do -Werror/-WX anymore

* Fix warnings

* Fix mingw warnings

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Anonymous Maarten
2024-02-01 21:42:10 +01:00
committed by GitHub
parent 97d1ba7c71
commit 9e686e2a87
308 changed files with 2863 additions and 1995 deletions

View File

@@ -31,8 +31,9 @@ void MxAudioManager::Destroy(MxBool p_fromDestructor)
Init();
this->m_criticalSection.Leave();
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxMediaManager::Destroy();
}
}
// FUNCTION: LEGO1 0x100b8e40
@@ -48,11 +49,13 @@ MxResult MxAudioManager::InitPresenters()
g_count++;
}
if (result)
if (result) {
Destroy();
}
if (success)
if (success) {
this->m_criticalSection.Leave();
}
return result;
}

View File

@@ -20,17 +20,20 @@ void MxLoopingMIDIPresenter::StreamingTickle()
return;
}
if (m_chunk->GetTime() + m_action->GetDuration() <= m_action->GetElapsedTime())
if (m_chunk->GetTime() + m_action->GetDuration() <= m_action->GetElapsedTime()) {
ProgressTickleState(e_done);
}
}
// FUNCTION: LEGO1 0x100c2ae0
void MxLoopingMIDIPresenter::DoneTickle()
{
if (m_action->GetLoopCount())
if (m_action->GetLoopCount()) {
MxMIDIPresenter::DoneTickle();
else
}
else {
EndAction();
}
}
// FUNCTION: LEGO1 0x100c2b00

View File

@@ -34,14 +34,16 @@ void MxMIDIPresenter::Destroy(MxBool p_fromDestructor)
m_criticalSection.Enter();
if (m_subscriber && m_chunk)
if (m_subscriber && m_chunk) {
m_subscriber->DestroyChunk(m_chunk);
}
Init();
m_criticalSection.Leave();
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxMusicPresenter::Destroy();
}
}
// FUNCTION: LEGO1 0x100c2890
@@ -61,24 +63,28 @@ void MxMIDIPresenter::StartingTickle()
{
MxStreamChunk* chunk = CurrentChunk();
if (chunk && m_action->GetElapsedTime() >= chunk->GetTime())
if (chunk && m_action->GetElapsedTime() >= chunk->GetTime()) {
ProgressTickleState(e_streaming);
}
}
// FUNCTION: LEGO1 0x100c2910
void MxMIDIPresenter::StreamingTickle()
{
if (m_chunk)
if (m_chunk) {
ProgressTickleState(e_done);
else
}
else {
m_chunk = NextChunk();
}
}
// FUNCTION: LEGO1 0x100c2940
void MxMIDIPresenter::DoneTickle()
{
if (!MusicManager()->GetMIDIInitialized())
if (!MusicManager()->GetMIDIInitialized()) {
EndAction();
}
}
// FUNCTION: LEGO1 0x100c2960
@@ -95,8 +101,9 @@ MxResult MxMIDIPresenter::PutData()
if (m_currentTickleState == e_streaming && m_chunk && !MusicManager()->GetMIDIInitialized()) {
SetVolume(((MxDSSound*) m_action)->GetVolume());
if (MusicManager()->InitializeMIDI(m_chunk->GetData(), 1) != SUCCESS)
if (MusicManager()->InitializeMIDI(m_chunk->GetData(), 1) != SUCCESS) {
EndAction();
}
}
m_criticalSection.Leave();

View File

@@ -82,8 +82,9 @@ MxResult MxMusicManager::ResetStream()
}
if (m_midiHdrP->dwFlags & MHDR_DONE || m_midiHdrP->dwFlags & MHDR_PREPARED) {
if (midiOutUnprepareHeader((HMIDIOUT) m_midiStreamH, m_midiHdrP, sizeof(MIDIHDR)) != MMSYSERR_NOERROR)
if (midiOutUnprepareHeader((HMIDIOUT) m_midiStreamH, m_midiHdrP, sizeof(MIDIHDR)) != MMSYSERR_NOERROR) {
goto done;
}
memset(m_midiHdrP, 0, sizeof(MIDIHDR));
}
@@ -131,8 +132,9 @@ void MxMusicManager::SetMIDIVolume()
// FUNCTION: LEGO1 0x100c0820
void CALLBACK MxMusicManager::MidiCallbackProc(HDRVR p_hdrvr, UINT p_uMsg, DWORD p_dwUser, DWORD p_dw1, DWORD p_dw2)
{
if (p_uMsg == MOM_DONE)
if (p_uMsg == MOM_DONE) {
((MxMusicManager*) p_dwUser)->ResetStream();
}
}
// FUNCTION: LEGO1 0x100c0840
@@ -147,21 +149,25 @@ MxResult MxMusicManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
locked = TRUE;
m_thread = new MxTickleThread(this, p_frequencyMS);
if (!m_thread || m_thread->Start(0, 0) != SUCCESS)
if (!m_thread || m_thread->Start(0, 0) != SUCCESS) {
goto done;
}
}
else
else {
TickleManager()->RegisterClient(this, p_frequencyMS);
}
status = SUCCESS;
}
done:
if (status != SUCCESS)
if (status != SUCCESS) {
Destroy();
}
if (locked)
if (locked) {
m_criticalSection.Leave();
}
return status;
}
@@ -211,22 +217,26 @@ MxResult MxMusicManager::InitializeMIDI(MxU8* p_data, MxS32 p_loopCount)
for (; device < total; device++) {
MIDIOUTCAPSA caps;
midiOutGetDevCapsA(device, &caps, sizeof(MIDIOUTCAPSA));
if (caps.wTechnology == MOD_FMSYNTH)
if (caps.wTechnology == MOD_FMSYNTH) {
break;
}
}
if (device >= total)
if (device >= total) {
device = -1;
}
if (midiStreamOpen(&m_midiStreamH, &device, 1, (DWORD) MidiCallbackProc, (DWORD) this, CALLBACK_FUNCTION) !=
MMSYSERR_NOERROR)
MMSYSERR_NOERROR) {
goto done;
}
GetMIDIVolume(m_midiVolume);
m_midiHdrP = new MIDIHDR();
if (!m_midiHdrP)
if (!m_midiHdrP) {
goto done;
}
memset(m_midiHdrP, 0, sizeof(MIDIHDR));
@@ -236,8 +246,9 @@ MxResult MxMusicManager::InitializeMIDI(MxU8* p_data, MxS32 p_loopCount)
m_bufferOffset += 0x14;
timediv.dwTimeDiv = *((DWORD*) m_bufferOffset);
if (midiStreamProperty(m_midiStreamH, (LPBYTE) &timediv, MIDIPROP_SET | MIDIPROP_TIMEDIV) != MMSYSERR_NOERROR)
if (midiStreamProperty(m_midiStreamH, (LPBYTE) &timediv, MIDIPROP_SET | MIDIPROP_TIMEDIV) != MMSYSERR_NOERROR) {
goto done;
}
m_bufferOffset += 0x14;
m_bufferSize = *((MxU32*) m_bufferOffset);
@@ -246,12 +257,14 @@ MxResult MxMusicManager::InitializeMIDI(MxU8* p_data, MxS32 p_loopCount)
m_midiInitialized = TRUE;
ResetBuffer();
if (ResetStream() != SUCCESS)
if (ResetStream() != SUCCESS) {
goto done;
}
SetMIDIVolume();
if (midiStreamRestart(m_midiStreamH) != MMSYSERR_NOERROR)
if (midiStreamRestart(m_midiStreamH) != MMSYSERR_NOERROR) {
goto done;
}
result = SUCCESS;
}

View File

@@ -59,46 +59,55 @@ MxResult MxSoundManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
MxResult status = FAILURE;
MxBool locked = FALSE;
if (MxAudioManager::InitPresenters() != SUCCESS)
if (MxAudioManager::InitPresenters() != SUCCESS) {
goto done;
}
m_criticalSection.Enter();
locked = TRUE;
if (DirectSoundCreate(NULL, &m_directSound, NULL) != DS_OK)
if (DirectSoundCreate(NULL, &m_directSound, NULL) != DS_OK) {
goto done;
}
if (m_directSound->SetCooperativeLevel(MxOmni::GetInstance()->GetWindowHandle(), DSSCL_PRIORITY) != DS_OK)
if (m_directSound->SetCooperativeLevel(MxOmni::GetInstance()->GetWindowHandle(), DSSCL_PRIORITY) != DS_OK) {
goto done;
}
DSBUFFERDESC desc;
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
if (MxOmni::IsSound3D())
if (MxOmni::IsSound3D()) {
desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRL3D;
else
}
else {
desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME;
}
if (m_directSound->CreateSoundBuffer(&desc, &m_dsBuffer, NULL) != DS_OK) {
if (!MxOmni::IsSound3D())
if (!MxOmni::IsSound3D()) {
goto done;
}
MxOmni::SetSound3D(FALSE);
desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME;
if (m_directSound->CreateSoundBuffer(&desc, &m_dsBuffer, NULL) != DS_OK)
if (m_directSound->CreateSoundBuffer(&desc, &m_dsBuffer, NULL) != DS_OK) {
goto done;
}
}
WAVEFORMATEX format;
format.wFormatTag = WAVE_FORMAT_PCM;
if (MxOmni::IsSound3D())
if (MxOmni::IsSound3D()) {
format.nChannels = 2;
else
}
else {
format.nChannels = 1;
}
format.nSamplesPerSec = 11025; // KHz
format.wBitsPerSample = 16;
@@ -111,20 +120,24 @@ MxResult MxSoundManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
if (p_createThread) {
m_thread = new MxTickleThread(this, p_frequencyMS);
if (!m_thread || m_thread->Start(0, 0) != SUCCESS)
if (!m_thread || m_thread->Start(0, 0) != SUCCESS) {
goto done;
}
}
else
else {
TickleManager()->RegisterClient(this, p_frequencyMS);
}
status = SUCCESS;
done:
if (status != SUCCESS)
if (status != SUCCESS) {
Destroy();
}
if (locked)
if (locked) {
m_criticalSection.Leave();
}
return status;
}
@@ -144,8 +157,9 @@ void MxSoundManager::SetVolume(MxS32 p_volume)
MxPresenter* presenter;
MxPresenterListCursor cursor(m_presenters);
while (cursor.Next(presenter))
while (cursor.Next(presenter)) {
((MxAudioPresenter*) presenter)->SetVolume(((MxAudioPresenter*) presenter)->GetVolume());
}
m_criticalSection.Leave();
}
@@ -160,8 +174,9 @@ MxPresenter* MxSoundManager::FUN_100aebd0(const MxAtomId& p_atomId, MxU32 p_obje
while (cursor.Next(presenter)) {
if (presenter->GetAction()->GetAtomId().GetInternal() == p_atomId.GetInternal() &&
presenter->GetAction()->GetObjectId() == p_objectId)
presenter->GetAction()->GetObjectId() == p_objectId) {
return presenter;
}
}
return NULL;
@@ -170,8 +185,9 @@ MxPresenter* MxSoundManager::FUN_100aebd0(const MxAtomId& p_atomId, MxU32 p_obje
// FUNCTION: LEGO1 0x100aecf0
MxS32 MxSoundManager::FUN_100aecf0(MxU32 p_undefined)
{
if (!p_undefined)
if (!p_undefined) {
return -10000;
}
return g_mxcoreCount[p_undefined];
}
@@ -183,9 +199,11 @@ void MxSoundManager::Pause()
MxPresenter* presenter;
MxPresenterListCursor cursor(m_presenters);
while (cursor.Next(presenter))
if (presenter->IsA("MxWavePresenter"))
while (cursor.Next(presenter)) {
if (presenter->IsA("MxWavePresenter")) {
((MxWavePresenter*) presenter)->Pause();
}
}
}
// FUNCTION: LEGO1 0x100aee10
@@ -196,7 +214,9 @@ void MxSoundManager::Resume()
MxPresenter* presenter;
MxPresenterListCursor cursor(m_presenters);
while (cursor.Next(presenter))
if (presenter->IsA("MxWavePresenter"))
while (cursor.Next(presenter)) {
if (presenter->IsA("MxWavePresenter")) {
((MxWavePresenter*) presenter)->Resume();
}
}
}

View File

@@ -8,15 +8,17 @@ DECOMP_SIZE_ASSERT(MxSoundPresenter, 0x54)
// FUNCTION: LEGO1 0x100b1a50
void MxSoundPresenter::Destroy(MxBool p_fromDestructor)
{
if (MSoundManager())
if (MSoundManager()) {
MSoundManager()->UnregisterPresenter(*this);
}
this->m_criticalSection.Enter();
MxMediaPresenter::Init();
this->m_criticalSection.Leave();
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxMediaPresenter::Destroy(FALSE);
}
}
// FUNCTION: LEGO1 0x100b1aa0

View File

@@ -40,13 +40,15 @@ void MxWavePresenter::Destroy(MxBool p_fromDestructor)
m_dsBuffer->Release();
}
if (m_waveFormat)
if (m_waveFormat) {
delete[] ((MxU8*) m_waveFormat);
}
Init();
if (!p_fromDestructor)
if (!p_fromDestructor) {
MxSoundPresenter::Destroy(FALSE);
}
}
// FUNCTION: LEGO1 0x100b1b60
@@ -55,8 +57,9 @@ MxS8 MxWavePresenter::GetPlayedChunks()
DWORD dwCurrentPlayCursor, dwCurrentWriteCursor;
MxS8 playedChunks = -1;
if (m_dsBuffer->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor) == DS_OK)
if (m_dsBuffer->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor) == DS_OK) {
playedChunks = dwCurrentPlayCursor / m_chunkLength;
}
return playedChunks;
}
@@ -141,26 +144,32 @@ void MxWavePresenter::StartingTickle()
waveFormatEx.nBlockAlign = m_waveFormat->m_pcmWaveFormat.wf.nBlockAlign;
waveFormatEx.wBitsPerSample = m_waveFormat->m_pcmWaveFormat.wBitsPerSample;
if (waveFormatEx.wBitsPerSample == 8)
if (waveFormatEx.wBitsPerSample == 8) {
m_silenceData = 0x7F;
}
if (waveFormatEx.wBitsPerSample == 16)
if (waveFormatEx.wBitsPerSample == 16) {
m_silenceData = 0;
}
DSBUFFERDESC desc;
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
if (m_unk0x66)
if (m_unk0x66) {
desc.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRL3D | DSBCAPS_CTRLVOLUME;
else
}
else {
desc.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME;
}
if (m_action->GetFlags() & MxDSAction::c_looping)
if (m_action->GetFlags() & MxDSAction::c_looping) {
desc.dwBufferBytes = m_waveFormat->m_pcmWaveFormat.wf.nAvgBytesPerSec *
(m_action->GetDuration() / m_action->GetLoopCount()) / 1000;
else
}
else {
desc.dwBufferBytes = 2 * length;
}
desc.lpwfxFormat = &waveFormatEx;
@@ -209,19 +218,22 @@ void MxWavePresenter::DoneTickle()
MxS8 playedChunks = dwCurrentPlayCursor / m_chunkLength;
if (m_action->GetFlags() & MxDSAction::c_bit7 || m_action->GetFlags() & MxDSAction::c_looping ||
m_writtenChunks != playedChunks || m_lockSize + (m_chunkLength * playedChunks) <= dwCurrentPlayCursor)
m_writtenChunks != playedChunks || m_lockSize + (m_chunkLength * playedChunks) <= dwCurrentPlayCursor) {
MxMediaPresenter::DoneTickle();
}
}
else
else {
MxMediaPresenter::DoneTickle();
}
}
// FUNCTION: LEGO1 0x100b2130
void MxWavePresenter::LoopChunk(MxStreamChunk* p_chunk)
{
WriteToSoundBuffer(p_chunk->GetData(), p_chunk->GetLength());
if (IsEnabled())
if (IsEnabled()) {
m_subscriber->DestroyChunk(p_chunk);
}
}
// FUNCTION: LEGO1 0x100b2160
@@ -241,18 +253,21 @@ MxResult MxWavePresenter::PutData()
if (!m_started) {
m_dsBuffer->SetCurrentPosition(0);
if (m_dsBuffer->Play(0, 0, DSBPLAY_LOOPING) == DS_OK)
if (m_dsBuffer->Play(0, 0, DSBPLAY_LOOPING) == DS_OK) {
m_started = TRUE;
}
}
break;
case e_repeating:
if (m_started)
if (m_started) {
break;
}
m_dsBuffer->SetCurrentPosition(0);
if (m_dsBuffer->Play(0, 0, m_action->GetLoopCount() > 1) == DS_OK)
if (m_dsBuffer->Play(0, 0, m_action->GetLoopCount() > 1) == DS_OK) {
m_started = TRUE;
}
}
}
@@ -266,8 +281,9 @@ void MxWavePresenter::EndAction()
MxAutoLocker lock(&m_criticalSection);
MxMediaPresenter::EndAction();
if (m_dsBuffer)
if (m_dsBuffer) {
m_dsBuffer->Stop();
}
}
}
@@ -296,8 +312,9 @@ void MxWavePresenter::Enable(MxBool p_enable)
m_writtenChunks = 0;
m_started = FALSE;
}
else if (m_dsBuffer)
else if (m_dsBuffer) {
m_dsBuffer->Stop();
}
}
}
@@ -317,8 +334,9 @@ void MxWavePresenter::ParseExtra()
char soundValue[512];
if (KeyValueStringParse(soundValue, g_strSOUND, extraCopy)) {
if (!strcmpi(soundValue, "FALSE"))
if (!strcmpi(soundValue, "FALSE")) {
Enable(FALSE);
}
}
}
}
@@ -327,8 +345,9 @@ void MxWavePresenter::ParseExtra()
void MxWavePresenter::Pause()
{
if (!m_paused && m_started) {
if (m_dsBuffer)
if (m_dsBuffer) {
m_dsBuffer->Stop();
}
m_paused = TRUE;
}
}