Skip to content

Commit

Permalink
Merge pull request #5847 from ampitere/fix_map_crash_when_counting_tr…
Browse files Browse the repository at this point in the history
…usts

[CPP] Fix map crash when counting trusts
  • Loading branch information
claywar authored May 29, 2024
2 parents 8336e03 + 0483505 commit 1c250d2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/map/party.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,12 @@ void CParty::RemoveMember(CBattleEntity* PEntity)
}
}

auto trustCount = static_cast<CCharEntity*>(m_PLeader)->PTrusts.size();
size_t trustCount = 0;
if (m_PLeader != nullptr)
{
trustCount = static_cast<CCharEntity*>(m_PLeader)->PTrusts.size();
}

PChar->PLatentEffectContainer->CheckLatentsPartyMembers(members.size(), trustCount);

PChar->pushPacket(new CPartyDefinePacket(nullptr));
Expand Down Expand Up @@ -855,7 +860,12 @@ void CParty::ReloadParty()
{
RefreshFlags(info);
CBattleEntity* PLeader = GetLeader();
auto trustCount = static_cast<CCharEntity*>(PLeader)->PTrusts.size();
size_t trustCount = 0;

if (PLeader != nullptr)
{
trustCount = static_cast<CCharEntity*>(PLeader)->PTrusts.size();
}

// regular party
for (auto& member : members)
Expand Down

0 comments on commit 1c250d2

Please sign in to comment.