Skip to content
Permalink
Browse files

Add reference counter increment/decrement on dummies change (#1021)

  • Loading branch information...
forkerer authored and saml1er committed Jul 6, 2019
1 parent 889ff05 commit c2fbcdfe651fd2a61f97dbd1ca5ce4ccc2690a63
Showing with 4 additions and 0 deletions.
  1. +4 −0 Client/game_sa/CModelInfoSA.cpp
@@ -955,6 +955,8 @@ void CModelInfoSA::SetVehicleDummyPosition(eVehicleDummies eDummy, const CVector
if (iter == ms_ModelDefaultDummiesPosition.end())
{
ms_ModelDefaultDummiesPosition.insert({pVehicleModel, std::map<eVehicleDummies, CVector>()});
// Increment this model references count, so we don't unload it before we have a chance to reset the positions
m_pInterface->usNumberOfRefs++;
}

if (ms_ModelDefaultDummiesPosition[pVehicleModel].find(eDummy) == ms_ModelDefaultDummiesPosition[pVehicleModel].end())
@@ -976,6 +978,8 @@ void CModelInfoSA::ResetAllVehicleDummies()
pVehicleModel->pVisualInfo->vecDummies[dummy.first] = dummy.second;
}
ms_ModelDefaultDummiesPosition[pVehicleModel].clear();
// Decrement reference counter, since we reverted all position changes, the model can be safely unloaded
info.first->usNumberOfRefs--;
}
ms_ModelDefaultDummiesPosition.clear();
}

0 comments on commit c2fbcdf

Please sign in to comment.
You can’t perform that action at this time.