Skip to content

Pvs studio fixes #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Activities/AreaEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Activities/AssemblyEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Activities/GibEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 2 additions & 5 deletions Source/Activities/MultiplayerServerLobby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Source/Activities/SceneEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
19 changes: 5 additions & 14 deletions Source/Entities/ACRocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
6 changes: 0 additions & 6 deletions Source/Entities/ACraft.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure this borks delivery in some cases

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, those breaks seem to be actually intentional. it's what we like to call Dan ™️ code (overly verbose code from the initial oss release that works mostly by luck)

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -552,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());
Expand All @@ -566,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()) {
Expand Down
6 changes: 0 additions & 6 deletions Source/Entities/MOSParticle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@ void MOSParticle::Travel() {
m_Atom->ClearMOIDIgnoreList();

if (m_SpriteAnimMode == ONCOLLIDE) {
// Change angular velocity after collision.
if (hitCount >= 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this also makes hitCount unused

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should actually return hitcount from Atom travel instead?

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();

Expand Down
2 changes: 0 additions & 2 deletions Source/Entities/MOSprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ bool MOSprite::HitTestAtPixel(int pixelX, int pixelY, bool validOnly) const {
}

void MOSprite::SetFrame(unsigned int newFrame) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure this is lua accessible so I'd rather this accept int instead, to avoid underflow issues

if (newFrame < 0)
newFrame = 0;
if (newFrame >= m_FrameCount)
newFrame = m_FrameCount - 1;

Expand Down
4 changes: 0 additions & 4 deletions Source/GUI/GUIBanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
6 changes: 0 additions & 6 deletions Source/GUI/GUIFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Menus/MetagameGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down