Skip to content

Commit 6a17b64

Browse files
authored
Fix for missing vehicle paintjobs after model replacement (#4402)
1 parent f270152 commit 6a17b64

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Client/game_sa/CRenderWareSA.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ RpClump* CRenderWareSA::ReadDFF(const SString& strFilename, const SString& buffe
283283
return NULL;
284284
}
285285

286-
// rockstar's collision hack: set the global particle emitter to the modelinfo pointer of this model
287286
if (bLoadEmbeddedCollisions)
288287
{
289288
// Vehicles have their collision loaded through the CollisionModel plugin, so we need to remove the current collision to prevent a memory leak.
@@ -295,15 +294,26 @@ RpClump* CRenderWareSA::ReadDFF(const SString& strFilename, const SString& buffe
295294
((void(__thiscall*)(CBaseModelInfoSAInterface*))0x4C4C40)(modelInfoInterface); // CBaseModelInfo::DeleteCollisionModel
296295
}
297296

297+
// rockstar's collision hack
298+
// It sets the pointer CCollisionPlugin::ms_currentModel to the model info of the given vehicle in order to correctly set up the vehicle’s
299+
// collision during collision plugin reading (0x41B2BD).
298300
RpPrtStdGlobalDataSetStreamEmbedded((void*)pPool[usModelID]);
301+
302+
// Call CVehicleModelInfo::UseCommonVehicleTexDicationary
303+
((void(__cdecl*)())0x4C75A0)();
299304
}
300305

301306
// read the clump with all its extensions
302307
RpClump* pClump = RpClumpStreamRead(streamModel);
303308

304-
// reset collision hack
305309
if (bLoadEmbeddedCollisions)
306-
RpPrtStdGlobalDataSetStreamEmbedded(NULL);
310+
{
311+
// reset collision hack
312+
RpPrtStdGlobalDataSetStreamEmbedded(nullptr);
313+
314+
// Call CVehicleModelInfo::StopUsingCommonVehicleTexDicationary
315+
((void(__cdecl*)())0x4C75C0)();
316+
}
307317

308318
// close the stream
309319
RwStreamClose(streamModel, NULL);

0 commit comments

Comments
 (0)