Skip to content

Commit 9d746c3

Browse files
committed
Review
1 parent 2ee6959 commit 9d746c3

File tree

2 files changed

+46
-48
lines changed

2 files changed

+46
-48
lines changed

Client/game_sa/CModelInfoSA.h

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ class CBaseModelInfoSAInterface
232232
// +726 = Word array as referenced in CVehicleModelInfo::GetVehicleUpgrade(int)
233233
// +762 = Array of WORD containing something relative to paintjobs
234234
// +772 = Anim file index
235+
236+
void Shutdown()
237+
{
238+
((void(*)())VFTBL->Shutdown)();
239+
}
235240
};
236241
static_assert(sizeof(CBaseModelInfoSAInterface) == 0x20, "Invalid size for CBaseModelInfoSAInterface");
237242

@@ -278,30 +283,31 @@ class CVehicleModelVisualInfoSAInterface // Not sure about this name.
278283
int m_maskComponentDamagable;
279284
};
280285

281-
class CVehicleModelInfoSAInterface : public CBaseModelInfoSAInterface
286+
class CVehicleModelInfoSAInterface : public CClumpModelInfoSAInterface
282287
{
283288
public:
284-
uint32 pad1; // +32
285-
RpMaterial* pPlateMaterial; // +36
289+
RpMaterial* pPlateMaterial;
286290
char plateText[8];
287-
char pad[2];
291+
std::uint8_t field_30;
292+
std::uint8_t plateType;
288293
char gameName[8];
289-
char pad2[2];
290-
unsigned int uiVehicleType;
294+
std::uint8_t field_3A[2];
295+
std::uint32_t vehicleType;
291296
float fWheelSizeFront;
292297
float fWheelSizeRear;
293-
short sWheelModel;
294-
short sHandlingID;
295-
byte ucNumDoors;
296-
byte ucVehicleList;
297-
byte ucVehicleFlags;
298-
byte ucWheelUpgradeClass;
299-
byte ucTimesUsed;
300-
short sVehFrequency;
301-
unsigned int uiComponentRules;
302-
float fSteeringAngle;
303-
CVehicleModelVisualInfoSAInterface* pVisualInfo; // +92
304-
char pad3[464];
298+
std::int16_t wheelModelID;
299+
std::int16_t handlingID;
300+
std::uint8_t numDoors;
301+
std::uint8_t vehicleClass;
302+
std::uint8_t vehicleFlags;
303+
std::uint8_t wheelUpgradeClass;
304+
std::uint8_t timesUsed;
305+
std::uint8_t field_51;
306+
std::int16_t vehFrequency;
307+
std::uint32_t componentRules;
308+
float bikeSteeringAngle;
309+
CVehicleModelVisualInfoSAInterface* pVisualInfo; // vehicleStruct
310+
std::uint8_t field_60[464];
305311

306312
union
307313
{
@@ -311,24 +317,22 @@ class CVehicleModelInfoSAInterface : public CBaseModelInfoSAInterface
311317
size_t m_numDirtMaterials;
312318
RpMaterial* m_staticDirtMaterials[30];
313319
};
314-
RpMaterial* pDirtMaterial[32];
315320
};
316321

317-
char pad4[64];
318-
char primColors[8];
319-
char secondColors[8];
320-
char treeColors[8];
321-
char fourColors[8];
322-
unsigned char ucNumOfColorVariations;
323-
unsigned char ucLastColorVariation;
324-
unsigned char ucPrimColor;
325-
unsigned char ucSecColor;
326-
unsigned char ucTertColor;
327-
unsigned char ucQuatColor;
328-
char upgrades[36];
329-
char anRemapTXDs[8];
330-
char pad5[2];
331-
char pAnimBlock[4];
322+
std::uint8_t primColors[8];
323+
std::uint8_t secondColors[8];
324+
std::uint8_t treeColors[8];
325+
std::uint8_t fourColors[8];
326+
std::uint8_t numOfColorVariations;
327+
std::uint8_t lastColorVariation;
328+
std::uint8_t primColor;
329+
std::uint8_t secColor;
330+
std::uint8_t tertColor;
331+
std::uint8_t quatColor;
332+
std::uint8_t upgrades[36];
333+
std::uint8_t anRemapTXDs[8];
334+
std::uint8_t field_302[2];
335+
void* pAnimBlock; // CAnimBlock*
332336
};
333337

334338
class CModelInfoSA : public CModelInfo

Client/multiplayer_sa/CMultiplayerSA_Vehicles.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "StdInc.h"
1212
#include "..\game_sa\gamesa_renderware.h"
1313

14-
#define FUNC_CVehicleModelInfo_ResetColors 0x4C8490
1514
#define FUNC_CBaseModelInfo_Shutdown 0x4C4D50
1615
#define IN_PLACE_BUFFER_DIRT_SIZE 30
1716

@@ -114,18 +113,12 @@ static void _declspec(naked) HOOK_CAEVehicleAudioEntity__Initialise()
114113
}
115114
}
116115

117-
static void CVehicleModelInfo_Shutdown()
116+
static void __fastcall CVehicleModelInfo_Shutdown(CVehicleModelInfoSAInterface* mi)
118117
{
119-
CVehicleModelInfoSAInterface* mi = nullptr;
120-
_asm
121-
{
122-
mov mi, ecx
123-
}
124-
125118
if (!mi)
126119
return;
127120

128-
((void(__cdecl*)(void*))FUNC_CBaseModelInfo_Shutdown)(mi);
121+
mi->Shutdown();
129122

130123
delete[] mi->m_dirtMaterials;
131124
mi->m_dirtMaterials = nullptr;
@@ -145,12 +138,10 @@ static void _declspec(naked) HOOK_CVehicleModelInfo_SetDirtTextures()
145138
{
146139
_asm
147140
{
148-
pushad
149141
push ebx
150142
push esi
151143
call SetDirtTextures
152144
add esp, 8
153-
popad
154145

155146
jmp CONTINUE_CVehicleModelInfo_SetDirtTextures
156147
}
@@ -195,7 +186,10 @@ static void __fastcall FindEditableMaterialList(CVehicleModelInfoSAInterface* mi
195186
std::copy(list.begin(), list.end(), mi->m_staticDirtMaterials);
196187
}
197188

198-
((void(__thiscall*)(CVehicleModelInfoSAInterface*))FUNC_CVehicleModelInfo_ResetColors)(mi);
189+
mi->primColor = 255;
190+
mi->secColor = 255;
191+
mi->tertColor = 255;
192+
mi->quatColor = 255;
199193
}
200194

201195
#define HOOKPOS_CVehicleModelInfo_SetClump 0x4C9648
@@ -205,9 +199,9 @@ static void _declspec(naked) HOOK_CVehicleModelInfo_SetClump()
205199
{
206200
_asm
207201
{
208-
pushad
202+
push ecx
209203
call FindEditableMaterialList
210-
popad
204+
pop ecx
211205

212206
jmp CONTINUE_CVehicleModelInfo_SetClump
213207
}

0 commit comments

Comments
 (0)