Skip to content

Commit a411d77

Browse files
committed
Review
1 parent b85414f commit a411d77

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

Client/game_sa/CModelInfoSA.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,12 @@ void CModelInfoSA::RestoreOriginalModel()
15381538
CBaseModelInfoSAInterface* currentInterface = ppModelInfo[m_dwModelID];
15391539
ppModelInfo[m_dwModelID] = MapGet(m_convertedModelInterfaces, m_dwModelID);
15401540

1541-
delete currentInterface;
1541+
if (currentInterface)
1542+
{
1543+
ppModelInfo[m_dwModelID]->usNumberOfRefs = currentInterface->usNumberOfRefs;
1544+
delete currentInterface;
1545+
}
1546+
15421547
MapRemove(m_convertedModelInterfaces, m_dwModelID);
15431548
}
15441549

@@ -1814,13 +1819,13 @@ void CModelInfoSA::MakeClumpModel(ushort usBaseID)
18141819
bool CModelInfoSA::ConvertToClump()
18151820
{
18161821
// Get current interface
1817-
CAtomicModelInfoSAInterface* currentAtomicInterface = static_cast<CAtomicModelInfoSAInterface*>(ppModelInfo[m_dwModelID]);
1818-
if (!currentAtomicInterface)
1822+
CBaseModelInfoSAInterface* currentModelInterface = ppModelInfo[m_dwModelID];
1823+
if (!currentModelInterface)
18191824
return false;
18201825

18211826
// Create new clump interface
18221827
CClumpModelInfoSAInterface* newClumpInterface = new CClumpModelInfoSAInterface();
1823-
MemCpyFast(newClumpInterface, currentAtomicInterface, sizeof(CClumpModelInfoSAInterface));
1828+
MemCpyFast(newClumpInterface, currentModelInterface, sizeof(CBaseModelInfoSAInterface));
18241829
newClumpInterface->m_nAnimFileIndex = -1;
18251830

18261831
// (FileEX): We do not destroy or set pRwObject to nullptr here
@@ -1834,7 +1839,7 @@ bool CModelInfoSA::ConvertToClump()
18341839
ppModelInfo[m_dwModelID] = newClumpInterface;
18351840

18361841
// Store original interface
1837-
MapSet(m_convertedModelInterfaces, m_dwModelID, static_cast<CBaseModelInfoSAInterface*>(currentAtomicInterface));
1842+
MapSet(m_convertedModelInterfaces, m_dwModelID, currentModelInterface);
18381843
return true;
18391844
}
18401845

@@ -1851,7 +1856,7 @@ bool CModelInfoSA::ConvertToAtomic()
18511856

18521857
// (FileEX): We do not destroy or set pRwObject to nullptr here
18531858
// because our IsLoaded code expects the RwObject to exist.
1854-
// We destroy the old RwObject in CFileLoader_SetRelatedModelInfoCB after passing the IsLoaded condition in the SetCustomModel.
1859+
// We destroy the old RwObject in CRenderWareSA::ReplaceAllAtomicsInModel after passing the IsLoaded condition in the SetCustomModel.
18551860

18561861
// Set CAtomicModelInfo vtbl after copying data
18571862
newAtomicInterface->VFTBL = reinterpret_cast<CBaseModelInfo_SA_VTBL*>(VTBL_CAtomicModelInfo);

Client/game_sa/CModelInfoSA.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ static void* ARRAY_ModelInfo = *(void**)(0x403DA4 + 3);
6464

6565
#define VAR_CTempColModels_ModelPed1 0x968DF0
6666

67-
#define FUNC_CClumpModelInfo_SetClump 0x4C4F70
68-
#define FUNC_CClumpModelInfo_DeleteRwObject 0x4C4E70
69-
70-
#define FUNC_CAtomicModelInfo_SetAtomic 0x4C4360
71-
#define FUNC_CAtomicModelInfo_DeleteRwObject 0x4C4440
72-
7367
#define VTBL_CClumpModelInfo 0x85BD30
7468
#define VTBL_CAtomicModelInfo 0x85BBF0
7569

@@ -262,15 +256,15 @@ class CClumpModelInfoSAInterface : public CBaseModelInfoSAInterface
262256
uint32_t m_nAnimFileIndex;
263257
};
264258

265-
void DeleteRwObject() { ((void(__thiscall*)(CClumpModelInfoSAInterface*))FUNC_CClumpModelInfo_DeleteRwObject)(this); }
266-
void SetClump(RpClump* clump) { ((void(__thiscall*)(CClumpModelInfoSAInterface*, RpClump*))FUNC_CClumpModelInfo_SetClump)(this, clump); }
259+
void DeleteRwObject() { ((void(__thiscall*)(CClumpModelInfoSAInterface*))0x4C4E70)(this); }
260+
void SetClump(RpClump* clump) { ((void(__thiscall*)(CClumpModelInfoSAInterface*, RpClump*))0x4C4F70)(this, clump); }
267261
};
268262

269263
class CAtomicModelInfoSAInterface : public CBaseModelInfoSAInterface
270264
{
271265
public:
272-
void DeleteRwObject() { ((void(__thiscall*)(CAtomicModelInfoSAInterface*))FUNC_CAtomicModelInfo_DeleteRwObject)(this); }
273-
void SetAtomic(RpAtomic* atomic) { ((void(__thiscall*)(CAtomicModelInfoSAInterface*, RpAtomic*))FUNC_CAtomicModelInfo_SetAtomic)(this, atomic); }
266+
void DeleteRwObject() { ((void(__thiscall*)(CAtomicModelInfoSAInterface*))0x4C4440)(this); }
267+
void SetAtomic(RpAtomic* atomic) { ((void(__thiscall*)(CAtomicModelInfoSAInterface*, RpAtomic*))0x4C4360)(this, atomic); }
274268
};
275269

276270
class CTimeModelInfoSAInterface : public CAtomicModelInfoSAInterface

0 commit comments

Comments
 (0)