Skip to content

Commit 4ce809a

Browse files
Synchronize changes from 1.6 master branch [ci skip]
ff84958 Revert "Fix setVehicleDirtLevel (#3837)"
2 parents 58725cd + ff84958 commit 4ce809a

File tree

4 files changed

+37
-164
lines changed

4 files changed

+37
-164
lines changed

Client/game_sa/CModelInfoSA.h

Lines changed: 36 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <game/Common.h>
1515
#include <game/CModelInfo.h>
1616
#include "CRenderWareSA.h"
17-
#include "game/RenderWare.h"
1817

1918
class CPedModelInfoSA;
2019
class CPedModelInfoSAInterface;
@@ -232,11 +231,6 @@ class CBaseModelInfoSAInterface
232231
// +726 = Word array as referenced in CVehicleModelInfo::GetVehicleUpgrade(int)
233232
// +762 = Array of WORD containing something relative to paintjobs
234233
// +772 = Anim file index
235-
236-
void Shutdown()
237-
{
238-
((void(*)())VFTBL->Shutdown)();
239-
}
240234
};
241235
static_assert(sizeof(CBaseModelInfoSAInterface) == 0x20, "Invalid size for CBaseModelInfoSAInterface");
242236

@@ -265,66 +259,53 @@ class CTimeModelInfoSAInterface : public CBaseModelInfoSAInterface
265259
CTimeInfoSAInterface timeInfo;
266260
};
267261

268-
class CVehicleModelUpgradePosnDesc
269-
{
270-
CVector m_vPosition;
271-
RtQuat m_vRotation;
272-
int m_iParentId;
273-
};
274-
275262
class CVehicleModelVisualInfoSAInterface // Not sure about this name. If somebody knows more, please change
276263
{
277264
public:
278-
CVector vecDummies[15];
279-
CVehicleModelUpgradePosnDesc m_sUpgrade[18];
280-
RpAtomic* m_pExtra[6];
281-
std::uint8_t m_numExtras;
282-
std::uint8_t _pad[3];
283-
int m_maskComponentDamagable;
265+
CVector vecDummies[15];
266+
char m_sUpgrade[18];
284267
};
285268

286-
class CVehicleModelInfoSAInterface : public CClumpModelInfoSAInterface
269+
class CVehicleModelInfoSAInterface : public CBaseModelInfoSAInterface
287270
{
288271
public:
289-
RpMaterial* pPlateMaterial;
272+
uint32 pad1; // +32
273+
RpMaterial* pPlateMaterial; // +36
290274
char plateText[8];
291-
std::uint8_t field_30;
292-
std::uint8_t plateType;
275+
char pad[2];
293276
char gameName[8];
294-
std::uint8_t field_3A[2];
295-
std::uint32_t vehicleType;
277+
char pad2[2];
278+
unsigned int uiVehicleType;
296279
float fWheelSizeFront;
297280
float fWheelSizeRear;
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];
311-
RpMaterial** m_dirtMaterials;
312-
std::size_t m_numDirtMaterials;
313-
RpMaterial* m_staticDirtMaterials[30];
314-
std::uint8_t primColors[8];
315-
std::uint8_t secondColors[8];
316-
std::uint8_t treeColors[8];
317-
std::uint8_t fourColors[8];
318-
std::uint8_t numOfColorVariations;
319-
std::uint8_t lastColorVariation;
320-
std::uint8_t primColor;
321-
std::uint8_t secColor;
322-
std::uint8_t tertColor;
323-
std::uint8_t quatColor;
324-
std::uint8_t upgrades[36];
325-
std::uint8_t anRemapTXDs[8];
326-
std::uint8_t field_302[2];
327-
void* pAnimBlock; // CAnimBlock*
281+
short sWheelModel;
282+
short sHandlingID;
283+
byte ucNumDoors;
284+
byte ucVehicleList;
285+
byte ucVehicleFlags;
286+
byte ucWheelUpgradeClass;
287+
byte ucTimesUsed;
288+
short sVehFrequency;
289+
unsigned int uiComponentRules;
290+
float fSteeringAngle;
291+
CVehicleModelVisualInfoSAInterface* pVisualInfo; // +92
292+
char pad3[464];
293+
char pDirtMaterial[64]; // *RwMaterial
294+
char pad4[64];
295+
char primColors[8];
296+
char secondColors[8];
297+
char treeColors[8];
298+
char fourColors[8];
299+
unsigned char ucNumOfColorVariations;
300+
unsigned char ucLastColorVariation;
301+
unsigned char ucPrimColor;
302+
unsigned char ucSecColor;
303+
unsigned char ucTertColor;
304+
unsigned char ucQuatColor;
305+
char upgrades[36];
306+
char anRemapTXDs[8];
307+
char pad5[2];
308+
char pAnimBlock[4];
328309
};
329310

330311
class CModelInfoSA : public CModelInfo

Client/game_sa/gamesa_renderware.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ typedef RpHAnimHierarchy*(__cdecl* GetAnimHierarchyFromSkinClump_t)(RpClump*);
105105
typedef int(__cdecl* RpHAnimIDGetIndex_t)(RpHAnimHierarchy*, int);
106106
typedef RwMatrix*(__cdecl* RpHAnimHierarchyGetMatrixArray_t)(RpHAnimHierarchy*);
107107
typedef RtQuat*(__cdecl* RtQuatRotate_t)(RtQuat* quat, const RwV3d* axis, float angle, RwOpCombineType combineOp);
108-
typedef RpGeometry*(__cdecl* RpGeometryForAllMaterials_t)(RpGeometry* geom, void* callback, void* data);
109108

110109
/*****************************************************************************/
111110
/** Renderware function mappings **/
@@ -196,7 +195,6 @@ RWFUNC(GetAnimHierarchyFromSkinClump_t GetAnimHierarchyFromSkinClump, (GetAnimHi
196195
RWFUNC(RpHAnimIDGetIndex_t RpHAnimIDGetIndex, (RpHAnimIDGetIndex_t)0xDEAD)
197196
RWFUNC(RpHAnimHierarchyGetMatrixArray_t RpHAnimHierarchyGetMatrixArray, (RpHAnimHierarchyGetMatrixArray_t)0xDEAD)
198197
RWFUNC(RtQuatRotate_t RtQuatRotate, (RtQuatRotate_t)0xDEAD)
199-
RWFUNC(RpGeometryForAllMaterials_t RpGeometryForAllMaterials, (RpGeometryForAllMaterials_t)0xDEAD)
200198

201199
/*****************************************************************************/
202200
/** GTA function definitions and mappings **/

Client/game_sa/gamesa_renderware.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ void InitRwFunctions()
8989
RpHAnimIDGetIndex = (RpHAnimIDGetIndex_t)0x7C51A0;
9090
RpHAnimHierarchyGetMatrixArray = (RpHAnimHierarchyGetMatrixArray_t)0x7C5120;
9191
RtQuatRotate = (RtQuatRotate_t)0x7EB7C0;
92-
RpGeometryForAllMaterials = (RpGeometryForAllMaterials_t)0x74C790;
93-
92+
9493
SetTextureDict = (SetTextureDict_t)0x007319C0;
9594
LoadClumpFile = (LoadClumpFile_t)0x005371F0;
9695
LoadModel = (LoadModel_t)0x0040C6B0;

Client/multiplayer_sa/CMultiplayerSA_Vehicles.cpp

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
*****************************************************************************/
1010

1111
#include "StdInc.h"
12-
#include "..\game_sa\gamesa_renderware.h"
13-
14-
#define FUNC_CBaseModelInfo_Shutdown 0x4C4D50
15-
#define IN_PLACE_BUFFER_DIRT_SIZE 30
16-
17-
static RwTexture** const ms_aDirtTextures = (RwTexture**)0xC02BD0;
1812

1913
static bool __fastcall AreVehicleDoorsUndamageable(CVehicleSAInterface* vehicle)
2014
{
@@ -113,100 +107,6 @@ static void _declspec(naked) HOOK_CAEVehicleAudioEntity__Initialise()
113107
}
114108
}
115109

116-
static void __fastcall CVehicleModelInfo_Shutdown(CVehicleModelInfoSAInterface* mi)
117-
{
118-
if (!mi)
119-
return;
120-
121-
mi->Shutdown();
122-
123-
delete[] mi->m_dirtMaterials;
124-
mi->m_dirtMaterials = nullptr;
125-
}
126-
127-
static void SetDirtTextures(CVehicleModelInfoSAInterface* mi, std::uint32_t level)
128-
{
129-
RpMaterial** materials = mi->m_numDirtMaterials > IN_PLACE_BUFFER_DIRT_SIZE ? mi->m_dirtMaterials : mi->m_staticDirtMaterials;
130-
for (std::uint32_t i = 0; i < mi->m_numDirtMaterials; i++)
131-
RpMaterialSetTexture(materials[i], ms_aDirtTextures[level]);
132-
}
133-
134-
#define HOOKPOS_CVehicleModelInfo_SetDirtTextures 0x5D5DBB
135-
#define HOOKSIZE_CVehicleModelInfo_SetDirtTextures 6
136-
static constexpr DWORD CONTINUE_CVehicleModelInfo_SetDirtTextures = 0x5D5DE3;
137-
static void _declspec(naked) HOOK_CVehicleModelInfo_SetDirtTextures()
138-
{
139-
_asm
140-
{
141-
push ebx
142-
push esi
143-
call SetDirtTextures
144-
add esp, 8
145-
146-
jmp CONTINUE_CVehicleModelInfo_SetDirtTextures
147-
}
148-
}
149-
150-
static RpMaterial* GetAtomicGeometryMaterialsCB(RpMaterial* material, void* data)
151-
{
152-
RwTexture* texture = material->texture;
153-
if (!texture)
154-
return nullptr;
155-
156-
auto cbData = static_cast<std::vector<RpMaterial*>*>(data);
157-
if (texture->name && std::strcmp(texture->name, "vehiclegrunge256") == 0)
158-
cbData->push_back(material);
159-
160-
return material;
161-
}
162-
163-
static bool GetEditableMaterialListCB(RpAtomic* atomic, void* data)
164-
{
165-
RpGeometryForAllMaterials(atomic->geometry, &GetAtomicGeometryMaterialsCB, data);
166-
return true;
167-
}
168-
169-
static void __fastcall FindEditableMaterialList(CVehicleModelInfoSAInterface* mi)
170-
{
171-
std::vector<RpMaterial*> list;
172-
RpClumpForAllAtomics(reinterpret_cast<RpClump*>(mi->pRwObject), &GetEditableMaterialListCB, &list);
173-
174-
for (std::uint32_t i = 0; i < mi->pVisualInfo->m_numExtras; i++)
175-
GetEditableMaterialListCB(mi->pVisualInfo->m_pExtra[i], &list);
176-
177-
mi->m_numDirtMaterials = list.size();
178-
if (mi->m_numDirtMaterials > IN_PLACE_BUFFER_DIRT_SIZE)
179-
{
180-
mi->m_dirtMaterials = new RpMaterial*[mi->m_numDirtMaterials];
181-
std::copy(list.begin(), list.end(), mi->m_dirtMaterials);
182-
}
183-
else
184-
{
185-
mi->m_dirtMaterials = nullptr;
186-
std::copy(list.begin(), list.end(), mi->m_staticDirtMaterials);
187-
}
188-
189-
mi->primColor = 255;
190-
mi->secColor = 255;
191-
mi->tertColor = 255;
192-
mi->quatColor = 255;
193-
}
194-
195-
#define HOOKPOS_CVehicleModelInfo_SetClump 0x4C9648
196-
#define HOOKSIZE_CVehicleModelInfo_SetClump 24
197-
static constexpr DWORD CONTINUE_CVehicleModelInfo_SetClump = 0x4C9660;
198-
static void _declspec(naked) HOOK_CVehicleModelInfo_SetClump()
199-
{
200-
_asm
201-
{
202-
push ecx
203-
call FindEditableMaterialList
204-
pop ecx
205-
206-
jmp CONTINUE_CVehicleModelInfo_SetClump
207-
}
208-
}
209-
210110
//////////////////////////////////////////////////////////////////////////////////////////
211111
//
212112
// CMultiplayerSA::InitHooks_Vehicles
@@ -218,9 +118,4 @@ void CMultiplayerSA::InitHooks_Vehicles()
218118
{
219119
EZHookInstall(CDamageManager__ProgressDoorDamage);
220120
EZHookInstall(CAEVehicleAudioEntity__Initialise);
221-
222-
// Fix vehicle dirt level
223-
EZHookInstall(CVehicleModelInfo_SetClump);
224-
EZHookInstall(CVehicleModelInfo_SetDirtTextures);
225-
MemCpy((void*)0x85C5E4, &CVehicleModelInfo_Shutdown, 4);
226121
}

0 commit comments

Comments
 (0)