Skip to content

Commit

Permalink
Fix #1089: Model not unload with stop resource
Browse files Browse the repository at this point in the history
  • Loading branch information
botder committed Sep 29, 2019
1 parent 185f57c commit b296565
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions Client/mods/deathmatch/logic/CClientDFF.cpp
Expand Up @@ -151,6 +151,10 @@ bool CClientDFF::DoReplaceModel(unsigned short usModel, bool bAlphaTransparency)
{
return ReplaceVehicleModel(pClump, usModel, bAlphaTransparency);
}
else if (CClientPlayerManager::IsValidModel(usModel))
{
return ReplacePedModel(pClump, usModel, bAlphaTransparency);
}
else if (CClientObjectManager::IsValidModel(usModel))
{
if (CVehicleUpgrades::IsUpgrade(usModel))
Expand All @@ -166,10 +170,6 @@ bool CClientDFF::DoReplaceModel(unsigned short usModel, bool bAlphaTransparency)
}
return ReplaceObjectModel(pClump, usModel, bAlphaTransparency);
}
else if (CClientPlayerManager::IsValidModel(usModel))
{
return ReplacePedModel(pClump, usModel, bAlphaTransparency);
}
}

// No supported type or no loaded clump
Expand Down Expand Up @@ -224,7 +224,14 @@ void CClientDFF::InternalRestoreModel(unsigned short usModel)
// eventually stream them back in with async loading.
m_pManager->GetVehicleManager()->RestreamVehicles(usModel);
}

// Is this an ped ID?
else if (CClientPlayerManager::IsValidModel(usModel))
{
// Stream the ped of that model out so we have no
// loaded when we do the restore. The streamer will
// eventually stream them back in with async loading.
m_pManager->GetPedManager()->RestreamPeds(usModel);
}
// Is this an object ID?
else if (CClientObjectManager::IsValidModel(usModel))
{
Expand All @@ -242,14 +249,6 @@ void CClientDFF::InternalRestoreModel(unsigned short usModel)
m_pManager->GetObjectManager()->RestreamObjects(usModel);
g_pGame->GetModelInfo(usModel)->RestreamIPL();
}
// Is this an ped ID?
else if (CClientPlayerManager::IsValidModel(usModel))
{
// Stream the ped of that model out so we have no
// loaded when we do the restore. The streamer will
// eventually stream them back in with async loading.
m_pManager->GetPedManager()->RestreamPeds(usModel);
}
else
return;

Expand Down

2 comments on commit b296565

@qaisjp
Copy link
Contributor

@qaisjp qaisjp commented on b296565 Sep 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this fix the bug? Does CClientObjectManager::IsValidModel think the ped model is an object?

@botder
Copy link
Member Author

@botder botder commented on b296565 Sep 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CClientObjectManager::IsValidModel source code:

bool CClientObjectManager::IsValidModel(unsigned long ulObjectModel)
{
bool bIsValid = false;
if (ulObjectModel < 20001)
{
unsigned int uiChunk = ulObjectModel / (sizeof(unsigned int) * 8);
unsigned int shift = ulObjectModel - (uiChunk * sizeof(unsigned int) * 8);
unsigned int bit = 1 << shift;
bIsValid = !!(g_uiValidObjectModels[uiChunk] & bit);
// Return whether we can grab the model information or not
if (bIsValid && !g_pGame->GetModelInfo(ulObjectModel))
{
bIsValid = false;
}
}
return bIsValid;
}

// Generated by MTA10\utils\gentable\gentable_objmodels.cpp
// (Currently excludes peds (below 300) and vehicles)
static const unsigned int g_uiValidObjectModels[] = {

CClientPlayerManager::IsValidModel source code:

bool CClientPlayerManager::IsValidModel(unsigned long ulModel)
{
if (ulModel < MAX_MODEL_ID)
{
CModelInfo* pModelInfo = g_pGame->GetModelInfo(ulModel);
return pModelInfo && pModelInfo->IsPlayerModel();
}
return false;
}

Please sign in to comment.