Skip to content

Commit

Permalink
Fix crash in FrameShowLimit
Browse files Browse the repository at this point in the history
  • Loading branch information
hexagonrecursion committed Aug 17, 2024
1 parent 36ab303 commit 550b934
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions colobot-base/src/graphics/engine/pyro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,7 @@ void CPyro::ExploStart()
m_camera->SetType(CAM_TYPE_EXPLO);
m_main->DeselectAll();
}
m_main->RemoveFromSelectionHistory(m_object);
m_main->CutObjectLink(m_object);

for (int i = 0; i < OBJECTMAXPART; i++)
{
Expand Down Expand Up @@ -1656,7 +1656,7 @@ void CPyro::BurnStart()
m_camera->SetType(CAM_TYPE_EXPLO);
m_main->DeselectAll();
}
m_main->RemoveFromSelectionHistory(m_object);
m_main->CutObjectLink(m_object);

for (int i = 0; i < OBJECTMAXPART; i++)
{
Expand Down
9 changes: 7 additions & 2 deletions colobot-base/src/level/robotmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2071,7 +2071,7 @@ bool CRobotMain::DestroySelectedObject()
dynamic_cast<CControllableObject&>(*obj).SetSelect(false); // deselects the object
m_camera->SetType(Gfx::CAM_TYPE_EXPLO);
DeselectAll();
RemoveFromSelectionHistory(obj);
CutObjectLink(obj);

return true;
}
Expand Down Expand Up @@ -5910,11 +5910,16 @@ CObject* CRobotMain::PopFromSelectionHistory()
return obj;
}

void CRobotMain::RemoveFromSelectionHistory(CObject* object)
void CRobotMain::CutObjectLink(CObject* object)
{
auto it = std::remove_if(m_selectionHistory.begin(), m_selectionHistory.end(),
[object](const CObject* obj) { return obj == object; });
m_selectionHistory.erase(it, m_selectionHistory.end());

for (int i = 0; i < MAXSHOWLIMIT; i++)
{
if (m_showLimit[i].link == object) FlushShowLimit(i);
}
}

float CRobotMain::GetGlobalMagnifyDamage()
Expand Down
2 changes: 1 addition & 1 deletion colobot-base/src/level/robotmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ class CRobotMain : public CSingleton<CRobotMain>
Error CanFactoryError(ObjectType type, int team);
//@}

void RemoveFromSelectionHistory(CObject* object);
void CutObjectLink(CObject* object);

//! Returns global magnifyDamage setting
float GetGlobalMagnifyDamage();
Expand Down
4 changes: 2 additions & 2 deletions colobot-base/src/object/old_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void COldObject::DeleteObject(bool bAll)
{
m_camera->SetControllingObject(nullptr);
}
m_main->RemoveFromSelectionHistory(this);
m_main->CutObjectLink(this);

if ( !bAll )
{
Expand Down Expand Up @@ -596,7 +596,7 @@ void COldObject::DestroyObject(DestructionType type, CObject* killer)
m_camera->SetType(Gfx::CAM_TYPE_EXPLO);
m_main->DeselectAll();
}
m_main->RemoveFromSelectionHistory(this);
m_main->CutObjectLink(this);

CScoreboard* scoreboard = m_main->GetScoreboard();
if (scoreboard)
Expand Down

0 comments on commit 550b934

Please sign in to comment.