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

@@ -64,10 +64,12 @@ void LegoCameraController::OnRButtonUp(MxPoint32 p_point)
// FUNCTION: LEGO1 0x10012230
void LegoCameraController::OnMouseMove(MxU8 p_modifier, MxPoint32 p_point)
{
if (p_modifier & c_lButtonState)
if (p_modifier & c_lButtonState) {
LeftDrag(p_point.GetX(), p_point.GetY());
else if (p_modifier & c_rButtonState)
}
else if (p_modifier & c_rButtonState) {
RightDrag(p_point.GetX(), p_point.GetY());
}
}
// FUNCTION: LEGO1 0x10012260
@@ -90,8 +92,9 @@ Mx3DPointFloat LegoCameraController::GetWorldUp()
vec = m_lego3DView->GetPointOfView()->GetWorldUp();
return Mx3DPointFloat(vec[0], vec[1], vec[2]);
}
else
else {
return Mx3DPointFloat(0, 0, 0);
}
}
// FUNCTION: LEGO1 0x100127f0
@@ -102,8 +105,9 @@ Mx3DPointFloat LegoCameraController::GetWorldLocation()
vec = m_lego3DView->GetPointOfView()->GetWorldPosition();
return Mx3DPointFloat(vec[0], vec[1] - m_entityOffsetUp, vec[2]);
}
else
else {
return Mx3DPointFloat(0, 0, 0);
}
}
// FUNCTION: LEGO1 0x100128a0
@@ -114,6 +118,7 @@ Mx3DPointFloat LegoCameraController::GetWorldDirection()
vec = m_lego3DView->GetPointOfView()->GetWorldDirection();
return Mx3DPointFloat(vec[0], vec[1], vec[2]);
}
else
else {
return Mx3DPointFloat(0, 0, 0);
}
}

View File

@@ -51,8 +51,9 @@ void LegoEntity::Destroy(MxBool p_fromDestructor)
{
if (m_roi) {
if (m_flags & c_bit1) {
if (m_roi->GetUnknown0x104() == this)
if (m_roi->GetUnknown0x104() == this) {
m_roi->SetUnknown0x104(NULL);
}
GetUnkSaveDataWriter()->FUN_10083db0(m_roi);
}
@@ -92,8 +93,9 @@ void LegoEntity::FUN_10010c30()
{
LegoWorld* world = GetCurrentWorld();
if (m_cameraFlag && world && world->GetCamera() && m_roi)
if (m_cameraFlag && world && world->GetCamera() && m_roi) {
world->GetCamera()->FUN_100123e0(m_roi->GetLocal2World(), 1);
}
}
// FUNCTION: LEGO1 0x10010e10

View File

@@ -148,8 +148,9 @@ void LegoNavController::SetDefaults(
// FUNCTION: LEGO1 0x10054e40
void LegoNavController::SetTargets(int p_hPos, int p_vPos, MxBool p_accel)
{
if (this->m_trackDefault != FALSE)
if (this->m_trackDefault != FALSE) {
ResetToDefault();
}
if (p_accel != FALSE) {
this->m_targetTurnSpeed = CalculateNewTargetSpeed(p_hPos, this->m_hMax / 2, this->m_turnMaxSpeed);
@@ -178,12 +179,15 @@ float LegoNavController::CalculateNewTargetSpeed(int p_pos, int p_center, float
float result;
int diff = p_pos - p_center;
if (diff > this->m_mouseDeadzone)
if (diff > this->m_mouseDeadzone) {
result = (diff - m_mouseDeadzone) * p_maxSpeed / (p_center - m_mouseDeadzone);
else if (diff < -m_mouseDeadzone)
}
else if (diff < -m_mouseDeadzone) {
result = (diff + m_mouseDeadzone) * p_maxSpeed / (p_center - m_mouseDeadzone);
else
}
else {
result = 0.0f;
}
return result;
}
@@ -196,8 +200,9 @@ float LegoNavController::CalculateNewAccel(int p_pos, int p_center, float p_maxA
result = Abs(diff) * p_maxAccel / p_center;
if (result < p_minAccel)
if (result < p_minAccel) {
result = (float) p_minAccel;
}
return result;
}
@@ -214,10 +219,12 @@ float LegoNavController::CalculateNewVel(float p_targetVel, float p_currentVel,
float deltaVel = p_accel * p_time;
newVel = p_currentVel + (deltaVel * vSign);
if (vSign > 0)
if (vSign > 0) {
newVel = Min(newVel, p_targetVel);
else
}
else {
newVel = Max(newVel, p_targetVel);
}
}
return newVel;

View File

@@ -65,16 +65,19 @@ MxResult LegoWorld::Create(MxDSAction& p_dsAction)
m_entityList = new LegoEntityList(TRUE);
if (!m_entityList)
if (!m_entityList) {
return FAILURE;
}
m_cacheSoundList = new LegoCacheSoundList(TRUE);
if (!m_cacheSoundList)
if (!m_cacheSoundList) {
return FAILURE;
}
if (!VTable0x54())
if (!VTable0x54()) {
return FAILURE;
}
if (p_dsAction.GetFlags() & MxDSAction::c_enabled) {
if (GetCurrentWorld()) {
@@ -146,8 +149,9 @@ void LegoWorld::Destroy(MxBool p_fromDestructor)
presenter->EndAction();
}
}
else
else {
delete object;
}
}
MxPresenterListCursor controlPresenterCursor(&m_controlPresenters);
@@ -174,8 +178,9 @@ void LegoWorld::Destroy(MxBool p_fromDestructor)
while (cursor.First(entity)) {
cursor.Detach();
if (!(entity->GetFlags() & LegoEntity::c_bit2))
if (!(entity->GetFlags() & LegoEntity::c_bit2)) {
delete entity;
}
}
delete m_entityList;
@@ -201,8 +206,9 @@ void LegoWorld::Destroy(MxBool p_fromDestructor)
delete roi;
}
if (!p_fromDestructor)
if (!p_fromDestructor) {
LegoEntity::Destroy(FALSE);
}
}
// FUNCTION: LEGO1 0x1001f5e0
@@ -284,42 +290,48 @@ void LegoWorld::Add(MxCore* p_object)
if (p_object->IsA("MxControlPresenter")) {
MxPresenterListCursor cursor(&m_controlPresenters);
if (cursor.Find((MxPresenter*) p_object))
if (cursor.Find((MxPresenter*) p_object)) {
return;
}
m_controlPresenters.Append((MxPresenter*) p_object);
}
else if (p_object->IsA("MxEntity")) {
LegoEntityListCursor cursor(m_entityList);
if (cursor.Find((LegoEntity*) p_object))
if (cursor.Find((LegoEntity*) p_object)) {
return;
}
m_entityList->Append((LegoEntity*) p_object);
}
else if (p_object->IsA("LegoLocomotionAnimPresenter") || p_object->IsA("LegoHideAnimPresenter") || p_object->IsA("LegoLoopingAnimPresenter")) {
MxPresenterListCursor cursor(&m_animPresenters);
if (cursor.Find((MxPresenter*) p_object))
if (cursor.Find((MxPresenter*) p_object)) {
return;
}
((MxPresenter*) p_object)->SendToCompositePresenter(Lego());
m_animPresenters.Append(((MxPresenter*) p_object));
if (p_object->IsA("LegoHideAnimPresenter"))
if (p_object->IsA("LegoHideAnimPresenter")) {
m_hideAnimPresenter = (LegoHideAnimPresenter*) p_object;
}
}
else if (p_object->IsA("LegoCacheSound")) {
LegoCacheSoundListCursor cursor(m_cacheSoundList);
if (cursor.Find((LegoCacheSound*) p_object))
if (cursor.Find((LegoCacheSound*) p_object)) {
return;
}
m_cacheSoundList->Append((LegoCacheSound*) p_object);
}
else {
if (m_set0xa8.find(p_object) == m_set0xa8.end())
if (m_set0xa8.find(p_object) == m_set0xa8.end()) {
m_set0xa8.insert(p_object);
}
}
if (!m_set0xd0.empty() && p_object->IsA("MxPresenter")) {
@@ -349,38 +361,45 @@ void LegoWorld::Remove(MxCore* p_object)
else if (p_object->IsA("LegoLocomotionAnimPresenter") || p_object->IsA("LegoHideAnimPresenter") || p_object->IsA("LegoLoopingAnimPresenter")) {
MxPresenterListCursor cursor(&m_animPresenters);
if (cursor.Find((MxPresenter*) p_object))
if (cursor.Find((MxPresenter*) p_object)) {
cursor.Detach();
}
if (p_object->IsA("LegoHideAnimPresenter"))
if (p_object->IsA("LegoHideAnimPresenter")) {
m_hideAnimPresenter = NULL;
}
}
else if (p_object->IsA("MxEntity")) {
if (p_object->IsA("LegoPathActor"))
if (p_object->IsA("LegoPathActor")) {
FUN_1001fc80((IslePathActor*) p_object);
}
if (m_entityList) {
LegoEntityListCursor cursor(m_entityList);
if (cursor.Find((LegoEntity*) p_object))
if (cursor.Find((LegoEntity*) p_object)) {
cursor.Detach();
}
}
}
else if (p_object->IsA("LegoCacheSound")) {
LegoCacheSoundListCursor cursor(m_cacheSoundList);
if (cursor.Find((LegoCacheSound*) p_object))
if (cursor.Find((LegoCacheSound*) p_object)) {
cursor.Detach();
}
}
else {
it = m_set0xa8.find(p_object);
if (it != m_set0xa8.end())
if (it != m_set0xa8.end()) {
m_set0xa8.erase(it);
}
}
it = m_set0xd0.find(p_object);
if (it != m_set0xd0.end())
if (it != m_set0xd0.end()) {
m_set0xd0.erase(it);
}
}
}
@@ -393,8 +412,9 @@ MxCore* LegoWorld::Find(const char* p_class, const char* p_name)
while (cursor.Next(presenter)) {
MxDSAction* action = presenter->GetAction();
if (!strcmp(action->GetObjectName(), p_name))
if (!strcmp(action->GetObjectName(), p_name)) {
return presenter;
}
}
return NULL;
@@ -404,12 +424,14 @@ MxCore* LegoWorld::Find(const char* p_class, const char* p_name)
LegoEntity* entity;
while (cursor.Next(entity)) {
if (!p_name)
if (!p_name) {
return entity;
}
LegoROI* roi = entity->GetROI();
if (roi && !strcmpi(roi->GetUnknown0xe4(), p_name))
if (roi && !strcmpi(roi->GetUnknown0xe4(), p_name)) {
return entity;
}
}
return NULL;
@@ -419,8 +441,9 @@ MxCore* LegoWorld::Find(const char* p_class, const char* p_name)
MxPresenter* presenter;
while (cursor.Next(presenter)) {
if (!strcmpi(((LegoAnimPresenter*) presenter)->GetActionObjectName(), p_name))
if (!strcmpi(((LegoAnimPresenter*) presenter)->GetActionObjectName(), p_name)) {
return presenter;
}
}
return NULL;
@@ -431,8 +454,9 @@ MxCore* LegoWorld::Find(const char* p_class, const char* p_name)
MxPresenter* presenter = (MxPresenter*) *it;
MxDSAction* action = presenter->GetAction();
if (!strcmp(action->GetObjectName(), p_name))
if (!strcmp(action->GetObjectName(), p_name)) {
return *it;
}
}
}
@@ -447,8 +471,9 @@ MxCore* LegoWorld::Find(const MxAtomId& p_atom, MxS32 p_entityId)
LegoEntity* entity;
while (entityCursor.Next(entity)) {
if (entity->GetAtom() == p_atom && entity->GetEntityId() == p_entityId)
if (entity->GetAtom() == p_atom && entity->GetEntityId() == p_entityId) {
return entity;
}
}
MxPresenterListCursor controlPresenterCursor(&m_controlPresenters);
@@ -457,8 +482,9 @@ MxCore* LegoWorld::Find(const MxAtomId& p_atom, MxS32 p_entityId)
while (controlPresenterCursor.Next(presenter)) {
MxDSAction* action = presenter->GetAction();
if (action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId)
if (action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId) {
return presenter;
}
}
MxPresenterListCursor animPresenterCursor(&m_animPresenters);
@@ -466,8 +492,9 @@ MxCore* LegoWorld::Find(const MxAtomId& p_atom, MxS32 p_entityId)
while (animPresenterCursor.Next(presenter)) {
MxDSAction* action = presenter->GetAction();
if (action && action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId)
if (action && action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId) {
return presenter;
}
}
for (MxCoreSet::iterator it = m_set0xa8.begin(); it != m_set0xa8.end(); it++) {
@@ -477,8 +504,9 @@ MxCore* LegoWorld::Find(const MxAtomId& p_atom, MxS32 p_entityId)
MxPresenter* presenter = (MxPresenter*) *it;
MxDSAction* action = presenter->GetAction();
if (action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId)
if (action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId) {
return *it;
}
}
}
@@ -502,8 +530,9 @@ MxResult LegoWorld::Tickle()
ReadyWorld();
return TRUE;
case e_two:
if (PresentersPending())
if (PresentersPending()) {
break;
}
default:
m_startupTicks--;
}
@@ -519,8 +548,9 @@ MxBool LegoWorld::PresentersPending()
MxPresenter* presenter;
while (controlPresenterCursor.Next(presenter)) {
if (presenter->IsEnabled() && !presenter->HasTickleStatePassed(MxPresenter::e_starting))
if (presenter->IsEnabled() && !presenter->HasTickleStatePassed(MxPresenter::e_starting)) {
return TRUE;
}
}
MxPresenterListCursor animPresenterCursor(&m_animPresenters);
@@ -528,12 +558,14 @@ MxBool LegoWorld::PresentersPending()
while (animPresenterCursor.Next(presenter)) {
if (presenter->IsEnabled()) {
if (presenter->IsA("LegoLocomotionAnimPresenter")) {
if (!presenter->HasTickleStatePassed(MxPresenter::e_ready))
if (!presenter->HasTickleStatePassed(MxPresenter::e_ready)) {
return TRUE;
}
}
else {
if (!presenter->HasTickleStatePassed(MxPresenter::e_starting))
if (!presenter->HasTickleStatePassed(MxPresenter::e_starting)) {
return TRUE;
}
}
}
}
@@ -542,8 +574,9 @@ MxBool LegoWorld::PresentersPending()
if ((*it)->IsA("MxPresenter")) {
presenter = (MxPresenter*) *it;
if (presenter->IsEnabled() && !presenter->HasTickleStatePassed(MxPresenter::e_starting))
if (presenter->IsEnabled() && !presenter->HasTickleStatePassed(MxPresenter::e_starting)) {
return TRUE;
}
}
}

View File

@@ -100,8 +100,9 @@ MxResult LegoWorldPresenter::StartAction(MxStreamController* p_controller, MxDSA
action->SetOrigin(this);
m_list.push_back(presenter);
}
else if (presenter)
else if (presenter) {
delete presenter;
}
}
VideoManager()->RegisterPresenter(*this);