diff --git a/src/map/party.cpp b/src/map/party.cpp index b1706068bdc..ff1f686d523 100644 --- a/src/map/party.cpp +++ b/src/map/party.cpp @@ -335,7 +335,17 @@ void CParty::RemoveMember(CBattleEntity* PEntity) } } - auto trustCount = static_cast(m_PLeader)->PTrusts.size(); + size_t trustCount = 0; + if (m_PLeader != nullptr) + { + std::vector PTrusts = static_cast(m_PLeader)->PTrusts; + + if (!PTrusts.empty()) + { + trustCount = PTrusts.size(); + } + } + PChar->PLatentEffectContainer->CheckLatentsPartyMembers(members.size(), trustCount); PChar->pushPacket(new CPartyDefinePacket(nullptr)); @@ -854,8 +864,18 @@ void CParty::ReloadParty() else { RefreshFlags(info); - CBattleEntity* PLeader = GetLeader(); - auto trustCount = static_cast(PLeader)->PTrusts.size(); + CBattleEntity* PLeader = GetLeader(); + size_t trustCount = 0; + + if (PLeader != nullptr) + { + std::vector PTrusts = static_cast(PLeader)->PTrusts; + + if (!PTrusts.empty()) + { + trustCount = PTrusts.size(); + } + } // regular party for (auto& member : members)