HPL1: fix removal of player collide scripts

the problem was caused by an incorrect fix for iterator invalidation
This commit is contained in:
grisenti 2023-01-09 22:50:25 +01:00
parent fe0ec0f5f5
commit 873d28366b

View File

@ -524,17 +524,21 @@ void cPlayer::AddCollideScript(eGameCollideScriptType aType, const tString &asFu
//-----------------------------------------------------------------------
void cPlayer::RemoveCollideScriptWithChildEntity(iGameEntity *apEntity) {
for (auto& kv : m_mapCollideCallbacks) {
cGameCollideScript *pCallback = kv.second;
tGameCollideScriptMapIt it = m_mapCollideCallbacks.begin();
for (; it != m_mapCollideCallbacks.end();) {
cGameCollideScript *pCallback = it->second;
tGameCollideScriptMapIt currentIt = it;
++it;
if (pCallback && pCallback->mpEntity == apEntity) {
if (mbUpdatingCollisionCallbacks)
if (mbUpdatingCollisionCallbacks) {
pCallback->mbDeleteMe = true;
else
} else {
hplDelete(pCallback);
m_mapCollideCallbacks.erase(currentIt);
}
}
}
m_mapCollideCallbacks.clear();
}
//-----------------------------------------------------------------------