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

@@ -108,8 +108,9 @@ MxU32 MxDSAction::GetSizeOnDisk()
// FUNCTION: LEGO1 0x100adc10
MxDSAction& MxDSAction::operator=(MxDSAction& p_dsAction)
{
if (this == &p_dsAction)
if (this == &p_dsAction) {
return *this;
}
MxDSObject::operator=(p_dsAction);
this->CopyFrom(p_dsAction);
@@ -121,8 +122,9 @@ MxDSAction* MxDSAction::Clone()
{
MxDSAction* clone = new MxDSAction();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}
@@ -136,35 +138,47 @@ MxLong MxDSAction::GetElapsedTime()
// FUNCTION: LEGO1 0x100add00
void MxDSAction::MergeFrom(MxDSAction& p_dsAction)
{
if (p_dsAction.m_startTime != INT_MIN)
if (p_dsAction.m_startTime != INT_MIN) {
this->m_startTime = p_dsAction.m_startTime;
}
if (p_dsAction.GetDuration() != INT_MIN)
if (p_dsAction.GetDuration() != INT_MIN) {
this->m_duration = p_dsAction.GetDuration();
}
if (p_dsAction.m_loopCount != -1)
if (p_dsAction.m_loopCount != -1) {
this->m_loopCount = p_dsAction.m_loopCount;
}
if (p_dsAction.m_location[0] != FLT_MAX)
if (p_dsAction.m_location[0] != FLT_MAX) {
this->m_location[0] = p_dsAction.m_location[0];
if (p_dsAction.m_location[1] != FLT_MAX)
}
if (p_dsAction.m_location[1] != FLT_MAX) {
this->m_location[1] = p_dsAction.m_location[1];
if (p_dsAction.m_location[2] != FLT_MAX)
}
if (p_dsAction.m_location[2] != FLT_MAX) {
this->m_location[2] = p_dsAction.m_location[2];
}
if (p_dsAction.m_direction[0] != FLT_MAX)
if (p_dsAction.m_direction[0] != FLT_MAX) {
this->m_direction[0] = p_dsAction.m_direction[0];
if (p_dsAction.m_direction[1] != FLT_MAX)
}
if (p_dsAction.m_direction[1] != FLT_MAX) {
this->m_direction[1] = p_dsAction.m_direction[1];
if (p_dsAction.m_direction[2] != FLT_MAX)
}
if (p_dsAction.m_direction[2] != FLT_MAX) {
this->m_direction[2] = p_dsAction.m_up[2]; // This is correct
}
if (p_dsAction.m_up[0] != FLT_MAX)
if (p_dsAction.m_up[0] != FLT_MAX) {
this->m_up[0] = p_dsAction.m_up[0];
if (p_dsAction.m_up[1] != FLT_MAX)
}
if (p_dsAction.m_up[1] != FLT_MAX) {
this->m_up[1] = p_dsAction.m_up[1];
if (p_dsAction.m_up[2] != FLT_MAX)
}
if (p_dsAction.m_up[2] != FLT_MAX) {
this->m_up[2] = p_dsAction.m_up[2];
}
MxU16 extraLength = p_dsAction.m_extraLength;
char* extraData = p_dsAction.m_extraData;
@@ -185,8 +199,9 @@ void MxDSAction::MergeFrom(MxDSAction& p_dsAction)
// FUNCTION: LEGO1 0x100ade60
void MxDSAction::AppendData(MxU16 p_extraLength, const char* p_extraData)
{
if (this->m_extraData == p_extraData || !p_extraData)
if (this->m_extraData == p_extraData || !p_extraData) {
return;
}
if (this->m_extraLength) {
char* concat = new char[p_extraLength + this->m_extraLength + sizeof(g_sep)];

View File

@@ -21,8 +21,9 @@ void MxDSAnim::CopyFrom(MxDSAnim& p_dsAnim)
// FUNCTION: LEGO1 0x100c9200
MxDSAnim& MxDSAnim::operator=(MxDSAnim& p_dsAnim)
{
if (this == &p_dsAnim)
if (this == &p_dsAnim) {
return *this;
}
MxDSMediaAction::operator=(p_dsAnim);
this->CopyFrom(p_dsAnim);
@@ -34,8 +35,9 @@ MxDSAction* MxDSAnim::Clone()
{
MxDSAnim* clone = new MxDSAnim();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}

View File

@@ -21,8 +21,9 @@ void MxDSEvent::CopyFrom(MxDSEvent& p_dsEvent)
// FUNCTION: LEGO1 0x100c9800
MxDSEvent& MxDSEvent::operator=(MxDSEvent& p_dsEvent)
{
if (this == &p_dsEvent)
if (this == &p_dsEvent) {
return *this;
}
MxDSMediaAction::operator=(p_dsEvent);
this->CopyFrom(p_dsEvent);
@@ -34,8 +35,9 @@ MxDSAction* MxDSEvent::Clone()
{
MxDSEvent* clone = new MxDSEvent();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}

View File

@@ -39,8 +39,9 @@ void MxDSMediaAction::CopyFrom(MxDSMediaAction& p_dsMediaAction)
// FUNCTION: LEGO1 0x100c8dc0
MxDSMediaAction& MxDSMediaAction::operator=(MxDSMediaAction& p_dsMediaAction)
{
if (this == &p_dsMediaAction)
if (this == &p_dsMediaAction) {
return *this;
}
MxDSAction::operator=(p_dsMediaAction);
this->CopyFrom(p_dsMediaAction);
@@ -52,8 +53,9 @@ MxDSAction* MxDSMediaAction::Clone()
{
MxDSMediaAction* clone = new MxDSMediaAction();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}
@@ -61,18 +63,21 @@ MxDSAction* MxDSMediaAction::Clone()
// FUNCTION: LEGO1 0x100c8e80
void MxDSMediaAction::CopyMediaSrcPath(const char* p_mediaSrcPath)
{
if (this->m_mediaSrcPath == p_mediaSrcPath)
if (this->m_mediaSrcPath == p_mediaSrcPath) {
return;
}
delete[] this->m_mediaSrcPath;
if (p_mediaSrcPath) {
this->m_mediaSrcPath = new char[strlen(p_mediaSrcPath) + 1];
if (this->m_mediaSrcPath)
if (this->m_mediaSrcPath) {
strcpy(this->m_mediaSrcPath, p_mediaSrcPath);
}
}
else
else {
this->m_mediaSrcPath = NULL;
}
}
// FUNCTION: LEGO1 0x100c8f00
@@ -86,10 +91,12 @@ MxU32 MxDSMediaAction::GetSizeOnDisk()
{
MxU32 totalSizeOnDisk = MxDSAction::GetSizeOnDisk();
if (this->m_mediaSrcPath)
if (this->m_mediaSrcPath) {
totalSizeOnDisk += strlen(this->m_mediaSrcPath) + 1;
else
}
else {
totalSizeOnDisk++;
}
totalSizeOnDisk += 24;
this->m_sizeOnDisk = totalSizeOnDisk - MxDSAction::GetSizeOnDisk();

View File

@@ -15,8 +15,9 @@ MxDSMultiAction::MxDSMultiAction()
// FUNCTION: LEGO1 0x100ca060
MxDSMultiAction::~MxDSMultiAction()
{
if (this->m_actions)
if (this->m_actions) {
delete this->m_actions;
}
}
// FUNCTION: LEGO1 0x100ca0d0
@@ -26,15 +27,17 @@ void MxDSMultiAction::CopyFrom(MxDSMultiAction& p_dsMultiAction)
MxDSActionListCursor cursor(p_dsMultiAction.m_actions);
MxDSAction* action;
while (cursor.Next(action))
while (cursor.Next(action)) {
this->m_actions->Append(action->Clone());
}
}
// FUNCTION: LEGO1 0x100ca260
MxDSMultiAction& MxDSMultiAction::operator=(MxDSMultiAction& p_dsMultiAction)
{
if (this == &p_dsMultiAction)
if (this == &p_dsMultiAction) {
return *this;
}
MxDSAction::operator=(p_dsMultiAction);
this->CopyFrom(p_dsMultiAction);
@@ -48,8 +51,9 @@ void MxDSMultiAction::SetUnknown90(MxLong p_unk0x90)
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action))
while (cursor.Next(action)) {
action->SetUnknown90(p_unk0x90);
}
}
// FUNCTION: LEGO1 0x100ca370
@@ -59,21 +63,24 @@ void MxDSMultiAction::MergeFrom(MxDSAction& p_dsMultiAction)
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action))
while (cursor.Next(action)) {
action->MergeFrom(p_dsMultiAction);
}
}
// FUNCTION: LEGO1 0x100ca450
MxBool MxDSMultiAction::HasId(MxU32 p_objectId)
{
if (this->GetObjectId() == p_objectId)
if (this->GetObjectId() == p_objectId) {
return TRUE;
}
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action)) {
if (action->HasId(p_objectId))
if (action->HasId(p_objectId)) {
return TRUE;
}
}
return FALSE;
@@ -84,8 +91,9 @@ MxDSAction* MxDSMultiAction::Clone()
{
MxDSMultiAction* clone = new MxDSMultiAction();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}
@@ -97,8 +105,9 @@ undefined4 MxDSMultiAction::VTable0x14()
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action))
while (cursor.Next(action)) {
result += action->VTable0x14();
}
return result;
}
@@ -110,8 +119,9 @@ MxU32 MxDSMultiAction::GetSizeOnDisk()
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action))
while (cursor.Next(action)) {
totalSizeOnDisk += action->GetSizeOnDisk();
}
this->m_sizeOnDisk = totalSizeOnDisk - MxDSAction::GetSizeOnDisk();
@@ -151,6 +161,7 @@ void MxDSMultiAction::SetAtomId(MxAtomId p_atomId)
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action))
while (cursor.Next(action)) {
action->SetAtomId(p_atomId);
}
}

View File

@@ -52,8 +52,9 @@ void MxDSObject::CopyFrom(MxDSObject& p_dsObject)
// FUNCTION: LEGO1 0x100bf8c0
MxDSObject& MxDSObject::operator=(MxDSObject& p_dsObject)
{
if (this == &p_dsObject)
if (this == &p_dsObject) {
return *this;
}
this->CopyFrom(p_dsObject);
return *this;
@@ -108,17 +109,21 @@ MxU32 MxDSObject::GetSizeOnDisk()
{
MxU32 sizeOnDisk;
if (this->m_sourceName)
if (this->m_sourceName) {
sizeOnDisk = strlen(this->m_sourceName) + 3;
else
}
else {
sizeOnDisk = 3;
}
sizeOnDisk += 4;
if (this->m_objectName)
if (this->m_objectName) {
sizeOnDisk += strlen(this->m_objectName) + 1;
else
}
else {
sizeOnDisk++;
}
sizeOnDisk += 4;
this->m_sizeOnDisk = sizeOnDisk;

View File

@@ -21,8 +21,9 @@ void MxDSObjectAction::CopyFrom(MxDSObjectAction& p_dsObjectAction)
// FUNCTION: LEGO1 0x100c8a80
MxDSObjectAction& MxDSObjectAction::operator=(MxDSObjectAction& p_dsObjectAction)
{
if (this == &p_dsObjectAction)
if (this == &p_dsObjectAction) {
return *this;
}
MxDSMediaAction::operator=(p_dsObjectAction);
this->CopyFrom(p_dsObjectAction);
@@ -34,8 +35,9 @@ MxDSAction* MxDSObjectAction::Clone()
{
MxDSObjectAction* clone = new MxDSObjectAction();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}

View File

@@ -23,8 +23,9 @@ void MxDSParallelAction::CopyFrom(MxDSParallelAction& p_dsParallelAction)
// FUNCTION: LEGO1 0x100cb0a0
MxDSParallelAction& MxDSParallelAction::operator=(MxDSParallelAction& p_dsParallelAction)
{
if (this == &p_dsParallelAction)
if (this == &p_dsParallelAction) {
return *this;
}
MxDSMultiAction::operator=(p_dsParallelAction);
this->CopyFrom(p_dsParallelAction);
@@ -36,8 +37,9 @@ MxDSAction* MxDSParallelAction::Clone()
{
MxDSParallelAction* clone = new MxDSParallelAction();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}
@@ -45,15 +47,17 @@ MxDSAction* MxDSParallelAction::Clone()
// FUNCTION: LEGO1 0x100cb160
MxLong MxDSParallelAction::GetDuration()
{
if (this->m_duration)
if (this->m_duration) {
return this->m_duration;
}
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action)) {
if (!action)
if (!action) {
continue;
}
MxLong duration = action->GetDuration();
if (duration == -1) {
@@ -65,10 +69,12 @@ MxLong MxDSParallelAction::GetDuration()
if (action->IsA("MxDSMediaAction")) {
MxLong sustainTime = ((MxDSMediaAction*) action)->GetSustainTime();
if (sustainTime == -1)
if (sustainTime == -1) {
duration = -1;
else if (sustainTime)
}
else if (sustainTime) {
duration += sustainTime;
}
}
if (duration == -1) {
@@ -76,12 +82,14 @@ MxLong MxDSParallelAction::GetDuration()
break;
}
if (this->m_duration < duration)
if (this->m_duration < duration) {
this->m_duration = duration;
}
}
if (this->IsBit3())
if (this->IsBit3()) {
this->m_duration *= this->m_loopCount;
}
return this->m_duration;
}

View File

@@ -19,8 +19,9 @@ MxDSSelectAction::MxDSSelectAction()
// FUNCTION: LEGO1 0x100cb8d0
MxDSSelectAction::~MxDSSelectAction()
{
if (this->m_unk0xac)
if (this->m_unk0xac) {
delete this->m_unk0xac;
}
}
// FUNCTION: LEGO1 0x100cb950
@@ -32,8 +33,9 @@ void MxDSSelectAction::CopyFrom(MxDSSelectAction& p_dsSelectAction)
MxStringListCursor cursor(p_dsSelectAction.m_unk0xac);
MxString string;
while (cursor.Next(string))
while (cursor.Next(string)) {
this->m_unk0xac->Append(string);
}
}
// FUNCTION: LEGO1 0x100cbd50
@@ -51,8 +53,9 @@ MxDSAction* MxDSSelectAction::Clone()
{
MxDSSelectAction* clone = new MxDSSelectAction();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}
@@ -66,8 +69,9 @@ MxU32 MxDSSelectAction::GetSizeOnDisk()
MxStringListCursor cursor(this->m_unk0xac);
MxString string;
while (cursor.Next(string))
while (cursor.Next(string)) {
totalSizeOnDisk += strlen(string.GetData()) + 1;
}
// Note: unlike the other classes, MxDSSelectAction does not have its own
// sizeOnDisk member. Instead, it overrides the one from MxDSMultiAction.
@@ -95,8 +99,9 @@ void MxDSSelectAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24)
MxS32 random = rand() % value;
string = itoa((MxS16) random, buffer, 10);
}
else
else {
string = VariableTable()->GetVariable((char*) *p_source);
}
*p_source += strlen((char*) *p_source) + 1;
@@ -109,8 +114,9 @@ void MxDSSelectAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24)
MxU32 i;
for (i = 0; i < count; i++) {
if (!strcmp(string.GetData(), (char*) *p_source))
if (!strcmp(string.GetData(), (char*) *p_source)) {
index = i;
}
this->m_unk0xac->Append((char*) *p_source);
*p_source += strlen((char*) *p_source) + 1;
@@ -122,10 +128,12 @@ void MxDSSelectAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24)
MxDSAction* action = (MxDSAction*) DeserializeDSObjectDispatch(p_source, p_unk0x24);
if (index == i)
if (index == i) {
this->m_actions->Append(action);
else
}
else {
delete action;
}
*p_source += extraFlag;
}

View File

@@ -21,8 +21,9 @@ void MxDSSerialAction::SetDuration(MxLong p_duration)
// FUNCTION: LEGO1 0x100cac10
MxDSSerialAction::~MxDSSerialAction()
{
if (this->m_cursor)
if (this->m_cursor) {
delete this->m_cursor;
}
this->m_cursor = NULL;
}
@@ -35,8 +36,9 @@ void MxDSSerialAction::CopyFrom(MxDSSerialAction& p_dsSerialAction)
// FUNCTION: LEGO1 0x100caca0
MxDSSerialAction& MxDSSerialAction::operator=(MxDSSerialAction& p_dsSerialAction)
{
if (this == &p_dsSerialAction)
if (this == &p_dsSerialAction) {
return *this;
}
MxDSMultiAction::operator=(p_dsSerialAction);
this->CopyFrom(p_dsSerialAction);
@@ -48,8 +50,9 @@ MxDSAction* MxDSSerialAction::Clone()
{
MxDSSerialAction* clone = new MxDSSerialAction();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}
@@ -57,23 +60,26 @@ MxDSAction* MxDSSerialAction::Clone()
// FUNCTION: LEGO1 0x100cad60
MxLong MxDSSerialAction::GetDuration()
{
if (this->m_duration)
if (this->m_duration) {
return this->m_duration;
}
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action)) {
if (!action)
if (!action) {
continue;
}
this->m_duration += action->GetDuration() + action->GetStartTime();
if (action->IsA("MxDSMediaAction")) {
MxLong sustainTime = ((MxDSMediaAction*) action)->GetSustainTime();
if (sustainTime && sustainTime != -1)
if (sustainTime && sustainTime != -1) {
this->m_duration += sustainTime;
}
}
}

View File

@@ -26,8 +26,9 @@ void MxDSSound::CopyFrom(MxDSSound& p_dsSound)
// FUNCTION: LEGO1 0x100c94e0
MxDSSound& MxDSSound::operator=(MxDSSound& p_dsSound)
{
if (this == &p_dsSound)
if (this == &p_dsSound) {
return *this;
}
MxDSMediaAction::operator=(p_dsSound);
this->CopyFrom(p_dsSound);
@@ -39,8 +40,9 @@ MxDSAction* MxDSSound::Clone()
{
MxDSSound* clone = new MxDSSound();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}

View File

@@ -21,8 +21,9 @@ void MxDSStill::CopyFrom(MxDSStill& p_dsStill)
// FUNCTION: LEGO1 0x100c9ad0
MxDSStill& MxDSStill::operator=(MxDSStill& p_dsStill)
{
if (this == &p_dsStill)
if (this == &p_dsStill) {
return *this;
}
MxDSMediaAction::operator=(p_dsStill);
this->CopyFrom(p_dsStill);
@@ -34,8 +35,9 @@ MxDSAction* MxDSStill::Clone()
{
MxDSStill* clone = new MxDSStill();
if (clone)
if (clone) {
*clone = *this;
}
return clone;
}

View File

@@ -17,8 +17,9 @@ MxDSStreamingAction::MxDSStreamingAction(MxDSAction& p_dsAction, MxU32 p_offset)
// FUNCTION: LEGO1 0x100cd090
MxBool MxDSStreamingAction::HasId(MxU32 p_objectId)
{
if (this->m_internalAction)
if (this->m_internalAction) {
return this->m_internalAction->HasId(p_objectId);
}
return FALSE;
}
@@ -32,12 +33,15 @@ MxDSStreamingAction::MxDSStreamingAction(MxDSStreamingAction& p_dsStreamingActio
// FUNCTION: LEGO1 0x100cd150
MxDSStreamingAction::~MxDSStreamingAction()
{
if (this->m_unk0xa0)
if (this->m_unk0xa0) {
delete this->m_unk0xa0;
if (this->m_unk0xa4)
}
if (this->m_unk0xa4) {
delete this->m_unk0xa4;
if (this->m_internalAction)
}
if (this->m_internalAction) {
delete this->m_internalAction;
}
}
// FUNCTION: LEGO1 0x100cd1e0
@@ -73,16 +77,18 @@ MxDSStreamingAction* MxDSStreamingAction::CopyFrom(MxDSStreamingAction& p_dsStre
// FUNCTION: LEGO1 0x100cd2a0
void MxDSStreamingAction::SetInternalAction(MxDSAction* p_dsAction)
{
if (this->m_internalAction)
if (this->m_internalAction) {
delete this->m_internalAction;
}
this->m_internalAction = p_dsAction;
}
// FUNCTION: LEGO1 0x100cd2d0
void MxDSStreamingAction::FUN_100cd2d0()
{
if (this->m_duration == -1)
if (this->m_duration == -1) {
return;
}
MxLong duration = this->m_duration / this->m_loopCount;
this->m_loopCount--;