From 4fe54184e431c821d6ab20a8f3eef87b36834692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Tue, 4 Feb 2025 17:31:55 +0100 Subject: [PATCH 01/12] Remove dead code due to type limits Fixes issues found by PVS-Studio --- Source/Activities/MultiplayerServerLobby.cpp | 7 ++----- Source/Entities/MOSParticle.cpp | 6 ------ Source/Entities/MOSprite.cpp | 2 -- Source/GUI/GUIBanner.cpp | 4 ---- Source/GUI/GUIFont.cpp | 6 ------ 5 files changed, 2 insertions(+), 23 deletions(-) diff --git a/Source/Activities/MultiplayerServerLobby.cpp b/Source/Activities/MultiplayerServerLobby.cpp index 07cff8c9d9..c8c38e482b 100644 --- a/Source/Activities/MultiplayerServerLobby.cpp +++ b/Source/Activities/MultiplayerServerLobby.cpp @@ -1048,11 +1048,8 @@ void MultiplayerServerLobby::DrawGUI(BITMAP* pTargetBitmap, const Vector& target m_pRootBox->SetPositionAbs(0, 0); // We need to manually draw UI's to intermediate buffer first, then to the player's backbuffer to make it centered on each player's screen. - for (int i = 0; i < 4; i++) { - if (i < c_MaxClients) - finalDestBitmap = g_FrameMan.GetNetworkBackBufferIntermediateGUI8Current(i); - else - finalDestBitmap = pTargetBitmap; + for (int i = 0; i < c_MaxClients; i++) { + finalDestBitmap = g_FrameMan.GetNetworkBackBufferIntermediateGUI8Current(i); AllegroScreen drawScreen(drawBitmap); m_pGUIController->Draw(&drawScreen); diff --git a/Source/Entities/MOSParticle.cpp b/Source/Entities/MOSParticle.cpp index 848c77f08a..7a1aa246d2 100644 --- a/Source/Entities/MOSParticle.cpp +++ b/Source/Entities/MOSParticle.cpp @@ -126,12 +126,6 @@ void MOSParticle::Travel() { m_Atom->ClearMOIDIgnoreList(); if (m_SpriteAnimMode == ONCOLLIDE) { - // Change angular velocity after collision. - if (hitCount >= 1) { - m_AngularVel *= 0.5F * velMag * RandomNormalNum(); - m_AngularVel = -m_AngularVel; - } - // TODO: Rework this so it's less incomprehensible black magic math and not driven by AngularVel. double newFrame = m_Rotation.GetRadAngle(); diff --git a/Source/Entities/MOSprite.cpp b/Source/Entities/MOSprite.cpp index ef43a25f82..4d7e492f89 100644 --- a/Source/Entities/MOSprite.cpp +++ b/Source/Entities/MOSprite.cpp @@ -269,8 +269,6 @@ bool MOSprite::HitTestAtPixel(int pixelX, int pixelY, bool validOnly) const { } void MOSprite::SetFrame(unsigned int newFrame) { - if (newFrame < 0) - newFrame = 0; if (newFrame >= m_FrameCount) newFrame = m_FrameCount - 1; diff --git a/Source/GUI/GUIBanner.cpp b/Source/GUI/GUIBanner.cpp index d0b435c66f..dcee3cef54 100644 --- a/Source/GUI/GUIBanner.cpp +++ b/Source/GUI/GUIBanner.cpp @@ -328,8 +328,6 @@ void GUIBanner::Draw(BITMAP* pTargetBitmap) { } if (c == '\t') { } - if (c < 0) - c += m_CharIndexCap; if (c < 32 || c >= m_CharIndexCap) continue; @@ -362,8 +360,6 @@ int GUIBanner::CalculateWidth(const std::string text, FontMode mode) const { */ continue; } - if (c < 0) - c += m_CharIndexCap; if (c < 32 || c >= m_CharIndexCap) continue; diff --git a/Source/GUI/GUIFont.cpp b/Source/GUI/GUIFont.cpp index 717afd4e74..d97be5c8ab 100644 --- a/Source/GUI/GUIFont.cpp +++ b/Source/GUI/GUIFont.cpp @@ -134,9 +134,6 @@ void GUIFont::Draw(GUIBitmap* Bitmap, int X, int Y, const std::string& Text, uns if (c == '\t') { X += m_Characters[' '].m_Width * 4; } - if (c < 0) { - c += m_CharIndexCap; - } if (c < 32 || c >= m_CharIndexCap) { continue; } @@ -270,9 +267,6 @@ int GUIFont::CalculateWidth(const std::string& Text) { Width = 0; continue; } - if (c < 0) { - c += m_CharIndexCap; - } if (c < 32 || c >= m_CharIndexCap) { continue; From 4c7fddcf5ee720a3ac77fe947d6e70acf04c112e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 9 Feb 2025 23:14:50 +0100 Subject: [PATCH 02/12] Fix erroneous self-assignment for editor previous modes Fixed issues found by PVS-Studio --- Source/Activities/AreaEditor.cpp | 2 +- Source/Activities/AssemblyEditor.cpp | 2 +- Source/Activities/GibEditor.cpp | 2 +- Source/Activities/SceneEditor.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Activities/AreaEditor.cpp b/Source/Activities/AreaEditor.cpp index ff6f910355..f3046ae0da 100644 --- a/Source/Activities/AreaEditor.cpp +++ b/Source/Activities/AreaEditor.cpp @@ -371,7 +371,7 @@ void AreaEditor::Update() { } // Open the save scene dialog to ask user where to save it then else { - m_PreviousMode = m_PreviousMode; + m_PreviousMode = m_EditorMode; m_EditorMode = EditorActivity::SAVEDIALOG; m_ModeChange = true; } diff --git a/Source/Activities/AssemblyEditor.cpp b/Source/Activities/AssemblyEditor.cpp index 3d103e407d..ce8282ae9d 100644 --- a/Source/Activities/AssemblyEditor.cpp +++ b/Source/Activities/AssemblyEditor.cpp @@ -296,7 +296,7 @@ void AssemblyEditor::Update() { } // Open the save scene dialog to ask user where to save it then else { - m_PreviousMode = m_PreviousMode; + m_PreviousMode = m_EditorMode; m_EditorMode = EditorActivity::SAVEDIALOG; m_ModeChange = true; } diff --git a/Source/Activities/GibEditor.cpp b/Source/Activities/GibEditor.cpp index 66140b9fcb..4dcb216ed4 100644 --- a/Source/Activities/GibEditor.cpp +++ b/Source/Activities/GibEditor.cpp @@ -462,7 +462,7 @@ void GibEditor::Update() { } // Open the save object dialog to ask user where to save it then else { - m_PreviousMode = m_PreviousMode; + m_PreviousMode = m_EditorMode; m_EditorMode = EditorActivity::SAVEDIALOG; m_ModeChange = true; } diff --git a/Source/Activities/SceneEditor.cpp b/Source/Activities/SceneEditor.cpp index 6680766a7e..fc502f9a1c 100644 --- a/Source/Activities/SceneEditor.cpp +++ b/Source/Activities/SceneEditor.cpp @@ -418,7 +418,7 @@ void SceneEditor::Update() { } // Open the save scene dialog to ask user where to save it then else { - m_PreviousMode = m_PreviousMode; + m_PreviousMode = m_EditorMode; m_EditorMode = EditorActivity::SAVEDIALOG; m_ModeChange = true; } From 2ac4115870973d7052d47e3082ca7b846682c78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 9 Feb 2025 23:22:05 +0100 Subject: [PATCH 03/12] Drop conditions for same if {} and else {} blocks Fixed issues found by PVS-Studio --- Source/Entities/ACRocket.cpp | 19 +++++-------------- Source/Menus/MetagameGUI.cpp | 2 +- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/Source/Entities/ACRocket.cpp b/Source/Entities/ACRocket.cpp index 64e01570a9..2b922ff02d 100644 --- a/Source/Entities/ACRocket.cpp +++ b/Source/Entities/ACRocket.cpp @@ -349,20 +349,11 @@ void ACRocket::PreControllerUpdate() { m_Paths[RIGHT][m_GearState].SetHFlip(m_HFlipped); m_Paths[LEFT][m_GearState].SetHFlip(!m_HFlipped); - if (!m_LimbPushForcesAndCollisionsDisabled) { - if (m_pRLeg) { - m_pRFootGroup->PushAsLimb(m_Pos.GetFloored() + RotateOffset(m_pRLeg->GetParentOffset()), m_pRLeg->GetMaxLength(), m_Vel, m_Rotation, m_Paths[RIGHT][m_GearState], deltaTime, nullptr, true); - } - if (m_pLLeg) { - m_pLFootGroup->PushAsLimb(m_Pos.GetFloored() + RotateOffset(m_pLLeg->GetParentOffset()), m_pLLeg->GetMaxLength(), m_Vel, m_Rotation, m_Paths[LEFT][m_GearState], deltaTime, nullptr, true); - } - } else { - if (m_pRLeg) { - m_pRFootGroup->PushAsLimb(m_Pos.GetFloored() + RotateOffset(m_pRLeg->GetParentOffset()), m_pRLeg->GetMaxLength(), m_Vel, m_Rotation, m_Paths[RIGHT][m_GearState], deltaTime, nullptr, true); - } - if (m_pLLeg) { - m_pLFootGroup->PushAsLimb(m_Pos.GetFloored() + RotateOffset(m_pLLeg->GetParentOffset()), m_pLLeg->GetMaxLength(), m_Vel, m_Rotation, m_Paths[LEFT][m_GearState], deltaTime, nullptr, true); - } + if (m_pRLeg) { + m_pRFootGroup->PushAsLimb(m_Pos.GetFloored() + RotateOffset(m_pRLeg->GetParentOffset()), m_pRLeg->GetMaxLength(), m_Vel, m_Rotation, m_Paths[RIGHT][m_GearState], deltaTime, nullptr, true); + } + if (m_pLLeg) { + m_pLFootGroup->PushAsLimb(m_Pos.GetFloored() + RotateOffset(m_pLLeg->GetParentOffset()), m_pLLeg->GetMaxLength(), m_Vel, m_Rotation, m_Paths[LEFT][m_GearState], deltaTime, nullptr, true); } } diff --git a/Source/Menus/MetagameGUI.cpp b/Source/Menus/MetagameGUI.cpp index 9295e60187..6fd9a417f0 100644 --- a/Source/Menus/MetagameGUI.cpp +++ b/Source/Menus/MetagameGUI.cpp @@ -5634,7 +5634,7 @@ void MetagameGUI::PlayerTextIndication(int metaPlayer, std::string text, const V void MetagameGUI::FundsChangeIndication(int metaPlayer, float change, const Vector& screenPos, double animLengthMS) { char str[256]; - std::snprintf(str, sizeof(str), change >= 1.0 ? "%c +%.0f oz" : (change <= -1.0 ? "%c %.0f oz" : "%c %.0f oz"), -58, change); + std::snprintf(str, sizeof(str), change >= 1.0 ? "%c +%.0f oz" : "%c %.0f oz", -58, change); m_apFundsChangeLabel[metaPlayer]->SetText(str); m_apFundsChangeLabel[metaPlayer]->SetHAlignment(GUIFont::Right); m_apFundsChangeLabel[metaPlayer]->SetVAlignment(GUIFont::Top); From d2b0331b037a9400056fea9b608e7af1a01d4626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 9 Feb 2025 23:23:05 +0100 Subject: [PATCH 04/12] Fix duplicate condition Fixed issues found by PVS-Studio --- Source/Entities/ACraft.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/Entities/ACraft.cpp b/Source/Entities/ACraft.cpp index f43c42db59..924dc092ae 100644 --- a/Source/Entities/ACraft.cpp +++ b/Source/Entities/ACraft.cpp @@ -405,9 +405,6 @@ bool ACraft::HandlePieCommand(PieSliceType pieSliceIndex) { } else if (pieSliceIndex == PieSliceType::Sentry) { m_AIMode = AIMODE_SENTRY; m_DeliveryState = FALL; - } else if (pieSliceIndex == PieSliceType::Return) { - m_AIMode = AIMODE_RETURN; - m_DeliveryState = LAUNCH; } else if (pieSliceIndex == PieSliceType::GoTo) { m_AIMode = AIMODE_GOTO; m_DeliveryState = FALL; From a348d464d9d9e72f1c5497cac316bc9ef4a715ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 9 Feb 2025 23:23:34 +0100 Subject: [PATCH 05/12] Remove dead code Fixed issues found by PVS-Studio --- Source/Entities/ACraft.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/Entities/ACraft.cpp b/Source/Entities/ACraft.cpp index 924dc092ae..403165bf87 100644 --- a/Source/Entities/ACraft.cpp +++ b/Source/Entities/ACraft.cpp @@ -549,7 +549,6 @@ void ACraft::DropAllInventory() { m_Inventory.erase(exitee); // Reset timer interval and quit until next one is due m_ExitTimer.Reset(); - break; } else { (*exitee)->SetVel(m_Vel + exitVel * antiGravBoost); (*exitee)->SetAngularVel(5.0F * RandomNormalNum()); @@ -563,9 +562,7 @@ void ACraft::DropAllInventory() { m_Inventory.erase(exitee); // Reset timer interval and quit until next one is due m_ExitTimer.Reset(); - break; } - droppedSomething = true; } if (m_Inventory.empty()) { From 0a7b5c86f24a960aedd93c581e6c8a08afdfc088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 9 Feb 2025 23:24:44 +0100 Subject: [PATCH 06/12] Remove duplicated clearing of banners Fixed issues found by PVS-Studio --- Source/GUI/GUIBanner.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/GUI/GUIBanner.cpp b/Source/GUI/GUIBanner.cpp index dcee3cef54..ced62b19cc 100644 --- a/Source/GUI/GUIBanner.cpp +++ b/Source/GUI/GUIBanner.cpp @@ -20,7 +20,6 @@ GUIBanner::GUIBanner() { m_BannerPosY = 240; m_FlySpeed = 1500; m_FlySpacing = 100; - m_BannerChars.clear(); m_AnimMode = BLINKING; m_AnimState = NOTSTARTED; m_TotalAnimTimer.Reset(); From 2183da0f895b9e9bc9ded1b5a025c62954dfd864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 9 Feb 2025 23:25:28 +0100 Subject: [PATCH 07/12] Remove variable shadowing class member field Fixed issues found by PVS-Studio --- Source/Menus/MetagameGUI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Menus/MetagameGUI.cpp b/Source/Menus/MetagameGUI.cpp index 6fd9a417f0..b68cb70ea1 100644 --- a/Source/Menus/MetagameGUI.cpp +++ b/Source/Menus/MetagameGUI.cpp @@ -157,7 +157,7 @@ void MetagameGUI::Clear() { m_AnimMetaPlayer = Players::NoPlayer; m_AnimDefenseTeam = Activity::NoTeam; m_AnimActivityChange = false; - Scene* m_pAnimScene = 0; + m_pAnimScene = 0; m_AnimRatio = 0; m_AnimProgress = 0; m_AnimTotalFunds = 0; From c999e674550f8d351efc3c10bf94d8cad6c55816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 9 Feb 2025 23:26:18 +0100 Subject: [PATCH 08/12] Rework checking of root parent node for nullptr In some cases `rootParentAsMOSR` could be accessed first and only then checked for being empty. Fixed issues found by PVS-Studio --- Source/Entities/Attachable.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Source/Entities/Attachable.cpp b/Source/Entities/Attachable.cpp index 702614ef9c..a6e0ee4abe 100644 --- a/Source/Entities/Attachable.cpp +++ b/Source/Entities/Attachable.cpp @@ -381,23 +381,25 @@ void Attachable::Update() { m_Team = m_Parent->GetTeam(); MOSRotating* rootParentAsMOSR = dynamic_cast(GetRootParent()); - float currentRotAngleOffset = (GetRotAngle() * GetFlipFactor()) - rootParentAsMOSR->GetRotAngle(); - if (rootParentAsMOSR && CanCollideWithTerrain()) { - // Note: This safety check exists to ensure the parent's AtomGroup contains this Attachable's Atoms in a subgroup. Hardcoded Attachables need this in order to work, since they're cloned before their parent's AtomGroup exists. - if (!rootParentAsMOSR->GetAtomGroup()->ContainsSubGroup(m_AtomSubgroupID)) { - AddOrRemoveAtomsFromRootParentAtomGroup(true, false); - } + if (rootParentAsMOSR) { + float currentRotAngleOffset = (GetRotAngle() * GetFlipFactor()) - rootParentAsMOSR->GetRotAngle(); + if (CanCollideWithTerrain()) { + // Note: This safety check exists to ensure the parent's AtomGroup contains this Attachable's Atoms in a subgroup. Hardcoded Attachables need this in order to work, since they're cloned before their parent's AtomGroup exists. + if (!rootParentAsMOSR->GetAtomGroup()->ContainsSubGroup(m_AtomSubgroupID)) { + AddOrRemoveAtomsFromRootParentAtomGroup(true, false); + } - if (std::abs(currentRotAngleOffset - m_PrevRotAngleOffset) > 0.01745F) { // Update for 1 degree differences - Matrix atomRotationForSubgroup(rootParentAsMOSR->FacingAngle(GetRotAngle()) - rootParentAsMOSR->FacingAngle(rootParentAsMOSR->GetRotAngle())); - Vector atomOffsetForSubgroup(g_SceneMan.ShortestDistance(rootParentAsMOSR->GetPos(), m_Pos, g_SceneMan.SceneWrapsX()).FlipX(rootParentAsMOSR->IsHFlipped())); - Matrix rootParentAngleToUse(rootParentAsMOSR->GetRotAngle() * rootParentAsMOSR->GetFlipFactor()); - atomOffsetForSubgroup /= rootParentAngleToUse; - rootParentAsMOSR->GetAtomGroup()->UpdateSubAtoms(GetAtomSubgroupID(), atomOffsetForSubgroup, atomRotationForSubgroup); + if (std::abs(currentRotAngleOffset - m_PrevRotAngleOffset) > 0.01745F) { // Update for 1 degree differences + Matrix atomRotationForSubgroup(rootParentAsMOSR->FacingAngle(GetRotAngle()) - rootParentAsMOSR->FacingAngle(rootParentAsMOSR->GetRotAngle())); + Vector atomOffsetForSubgroup(g_SceneMan.ShortestDistance(rootParentAsMOSR->GetPos(), m_Pos, g_SceneMan.SceneWrapsX()).FlipX(rootParentAsMOSR->IsHFlipped())); + Matrix rootParentAngleToUse(rootParentAsMOSR->GetRotAngle() * rootParentAsMOSR->GetFlipFactor()); + atomOffsetForSubgroup /= rootParentAngleToUse; + rootParentAsMOSR->GetAtomGroup()->UpdateSubAtoms(GetAtomSubgroupID(), atomOffsetForSubgroup, atomRotationForSubgroup); + } } + m_PrevRotAngleOffset = currentRotAngleOffset; } m_DeepCheck = false; - m_PrevRotAngleOffset = currentRotAngleOffset; } MOSRotating::Update(); From dcd225bf4a1790fbbdade230be4769a1300325fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 9 Feb 2025 23:28:58 +0100 Subject: [PATCH 09/12] Fix incorrect condition verification in MetagameGUI `progress` was first checked for being <=0, then it is checked for >0, which cannot occur in the same branch. Fixed issues found by PVS-Studio --- Source/Menus/MetagameGUI.cpp | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Source/Menus/MetagameGUI.cpp b/Source/Menus/MetagameGUI.cpp index b68cb70ea1..5ef6109db1 100644 --- a/Source/Menus/MetagameGUI.cpp +++ b/Source/Menus/MetagameGUI.cpp @@ -4965,24 +4965,19 @@ void MetagameGUI::UpdatePostBattleResidents(float progress) { m_apPlayerBrainTravelLabel[mp]->SetVisible(progress <= 0); if (progress <= 0) { - // Death mask - if (progress > 0) - std::snprintf(str, sizeof(str), "%c", -26); // Brain with line blinking over it and the funds still showing - else { - if (quadIndex <= 1) { - if (m_aAnimDestroyed[mp]) - std::snprintf(str, sizeof(str), "%c %.0f oz ", -58, m_aBattleFunds[mp]); - else - std::snprintf(str, sizeof(str), "%c %.0f oz %c%c", -58, m_aBattleFunds[mp], m_aBattleAttacker[mp] ? -46 : -47, -26); - // std::snprintf(str, sizeof(str), "%c %.0f oz %c", -58, m_aBattleFunds[mp], m_AnimTimer2.AlternateReal(200) ? -39 : -26); - } else { - if (m_aAnimDestroyed[mp]) - std::snprintf(str, sizeof(str), " %c %.0f oz", -58, m_aBattleFunds[mp]); - else - std::snprintf(str, sizeof(str), "%c%c %c %.0f oz", m_aAnimDestroyed[mp] ? ' ' : -26, m_aBattleAttacker[mp] ? -46 : -47, -58, m_aBattleFunds[mp]); - // std::snprintf(str, sizeof(str), "%c %c %.0f oz", m_AnimTimer2.AlternateReal(200) ? -39 : -26, -58, m_aBattleFunds[mp]); - } + if (quadIndex <= 1) { + if (m_aAnimDestroyed[mp]) + std::snprintf(str, sizeof(str), "%c %.0f oz ", -58, m_aBattleFunds[mp]); + else + std::snprintf(str, sizeof(str), "%c %.0f oz %c%c", -58, m_aBattleFunds[mp], m_aBattleAttacker[mp] ? -46 : -47, -26); + // std::snprintf(str, sizeof(str), "%c %.0f oz %c", -58, m_aBattleFunds[mp], m_AnimTimer2.AlternateReal(200) ? -39 : -26); + } else { + if (m_aAnimDestroyed[mp]) + std::snprintf(str, sizeof(str), " %c %.0f oz", -58, m_aBattleFunds[mp]); + else + std::snprintf(str, sizeof(str), "%c%c %c %.0f oz", m_aAnimDestroyed[mp] ? ' ' : -26, m_aBattleAttacker[mp] ? -46 : -47, -58, m_aBattleFunds[mp]); + // std::snprintf(str, sizeof(str), "%c %c %.0f oz", m_AnimTimer2.AlternateReal(200) ? -39 : -26, -58, m_aBattleFunds[mp]); } m_apPlayerBrainTravelLabel[mp]->SetText(str); m_apPlayerBrainTravelLabel[mp]->SetToolTip("The specific brain that is being sent in to attack this place, and the funds he has been budgeted to do so with."); From 15264aba59a726a1577ce7a35c1a84afa581e159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 9 Feb 2025 23:30:25 +0100 Subject: [PATCH 10/12] Initialize member fields of MetagameGUI --- Source/Menus/MetagameGUI.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Menus/MetagameGUI.h b/Source/Menus/MetagameGUI.h index 50b005f437..309bff47ae 100644 --- a/Source/Menus/MetagameGUI.h +++ b/Source/Menus/MetagameGUI.h @@ -93,6 +93,8 @@ namespace RTE { m_ChannelHeight = channelHeight; m_CircleSize = circleSize; m_Square = squareSite; + m_FundsAmount = 0.f; + m_FundsTarget = 0.f; } }; From 493de37bab81b6dc2b33cf1bd448923d3b5f79f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 9 Feb 2025 23:30:59 +0100 Subject: [PATCH 11/12] Drop redundant check for current object in Scene Editor `m_pCurrentObject` is first checked for correctness, then re-assigned and then accessed multiple times without checking for nullptr. Fixed issues found by PVS-Studio --- Source/Menus/SceneEditorGUI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Menus/SceneEditorGUI.cpp b/Source/Menus/SceneEditorGUI.cpp index 7e2b61bc0e..c16e251834 100644 --- a/Source/Menus/SceneEditorGUI.cpp +++ b/Source/Menus/SceneEditorGUI.cpp @@ -529,7 +529,7 @@ void SceneEditorGUI::Update() { } // Apply the team to the current actor, if applicable - if (m_pCurrentObject && m_DrawCurrentObject) { + if (m_DrawCurrentObject) { // Set the team of SceneObject based on what's been selected // Only if full featured mode, otherwise it's based on the controller when placed if (m_FeatureSet == ONLOADEDIT) From caaed0afab9e54e530667fe0bdd12b9395886822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 9 Feb 2025 23:34:57 +0100 Subject: [PATCH 12/12] Mention PVS-Studio in the readme See licensing at https://pvs-studio.com/en/order/open-source-license/ --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 156e74ed57..2907ae5b54 100644 --- a/README.md +++ b/README.md @@ -168,3 +168,7 @@ This repository includes launch configurations to automatically build and debug These launch configurations are accessible via the [Run and Debug](https://code.visualstudio.com/docs/editor/debugging#_run-and-debug-view) view, and provide profiles to build and run the game in Release mode or any of the [3 Debug modes](https://github.com/cortex-command-community/Cortex-Command-Community-Project-Source/wiki/Meson-build-options). All configurations will run pre-launch tasks to build the game using the supported backend before launching. + +## SAST Tools + +[PVS-Studio](https://pvs-studio.com/en/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source) - static analyzer for C, C++, C#, and Java code.