Skip to content

Commit 91b239b

Browse files
committed
Add shitty setVehicleModelExhaustPosition/getVehicleModelExhaustPosition
On long term, this function should be deprecated and merged with a new setVehicleModelComponentPosition (sets component position per model id). Alternatively, an even better solution would be to make this function vehicle-specific rather than model-specific
1 parent 9631567 commit 91b239b

File tree

8 files changed

+108
-6
lines changed

8 files changed

+108
-6
lines changed

Client/game_sa/CModelInfoSA.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,25 @@ void* CModelInfoSA::SetVehicleSuspensionData ( void* pSuspensionLines )
936936
return pOrigSuspensionLines;
937937
}
938938

939+
940+
CVector CModelInfoSA::GetVehicleExhaustFumesPosition()
941+
{
942+
if (!IsVehicle())
943+
return CVector();
944+
945+
auto pVehicleModel = reinterpret_cast<CVehicleModelInfoSAInterface*>(m_pInterface);
946+
return pVehicleModel->pVisualInfo->exhaustPosition;
947+
}
948+
949+
void CModelInfoSA::SetVehicleExhaustFumesPosition(const CVector& position)
950+
{
951+
if (!IsVehicle())
952+
return;
953+
954+
auto pVehicleModel = reinterpret_cast<CVehicleModelInfoSAInterface*>(m_pInterface);
955+
pVehicleModel->pVisualInfo->exhaustPosition = position;
956+
}
957+
939958
void CModelInfoSA::SetCustomModel ( RpClump* pClump )
940959
{
941960
// Error

Client/game_sa/CModelInfoSA.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,13 @@ class CBaseModelInfoSAInterface
223223
// +772 = Anim file index
224224
};
225225

226+
class CVehicleModelVisualInfoSAInterface // Not sure about this name. If somebody knows more, please change
227+
{
228+
public:
229+
uint8_t pad[72];
230+
CVector exhaustPosition; // +72
231+
};
232+
226233

227234
class CVehicleModelInfoSAInterface : public CBaseModelInfoSAInterface
228235
{
@@ -231,7 +238,7 @@ class CVehicleModelInfoSAInterface : public CBaseModelInfoSAInterface
231238
RpMaterial* pPlateMaterial; // +36
232239
char plateText[8]; // +40
233240
char pad[44];
234-
class CVehicleStructure* pSomeInfo; // +92
241+
CVehicleModelVisualInfoSAInterface* pVisualInfo; // +92
235242
};
236243

237244
enum eModelInfoType : unsigned char
@@ -331,6 +338,8 @@ class CModelInfoSA : public CModelInfo
331338
unsigned int GetNumRemaps ( void );
332339
void* GetVehicleSuspensionData( void );
333340
void* SetVehicleSuspensionData( void* pSuspensionLines );
341+
CVector GetVehicleExhaustFumesPosition() override;
342+
void SetVehicleExhaustFumesPosition(const CVector& position) override;
334343

335344
// ONLY use for peds
336345
void GetVoice ( short* psVoiceType, short* psVoice );
@@ -361,4 +370,4 @@ class CModelInfoSA : public CModelInfo
361370
void RwSetSupportedUpgrades ( RwFrame * parent, DWORD dwModel );
362371
};
363372

364-
#endif
373+
#endif

Client/game_sa/CRenderWareSA.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,18 +375,18 @@ void CRenderWareSA::ReplaceModel ( RpClump* pNew, unsigned short usModelID, DWOR
375375
if ( dwFunc == FUNC_LoadVehicleModel )
376376
{
377377
CVehicleModelInfoSAInterface* pVehicleModelInfoInterface = (CVehicleModelInfoSAInterface*)pModelInfo->GetInterface ();
378-
if ( pVehicleModelInfoInterface->pSomeInfo )
378+
if ( pVehicleModelInfoInterface->pVisualInfo )
379379
{
380380
DWORD dwDeleteFunc = FUNC_CVehicleStructure_delete;
381-
CVehicleStructure* pSomeInfo = pVehicleModelInfoInterface->pSomeInfo;
381+
CVehicleModelVisualInfoSAInterface* info = pVehicleModelInfoInterface->pVisualInfo;
382382
__asm
383383
{
384-
mov eax, pSomeInfo
384+
mov eax, info
385385
push eax
386386
call dwDeleteFunc
387387
add esp, 4
388388
}
389-
pVehicleModelInfoInterface->pSomeInfo = NULL;
389+
pVehicleModelInfoInterface->pVisualInfo = nullptr;
390390
}
391391
}
392392

Client/mods/deathmatch/logic/CClientVehicle.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4878,6 +4878,22 @@ bool CClientVehicle::DoesSupportUpgrade ( const SString& strFrameName )
48784878
return true;
48794879
}
48804880

4881+
void CClientVehicle::SetModelExhaustPosition(unsigned short modelID, const CVector& position)
4882+
{
4883+
auto pModelInfo = g_pGame->GetModelInfo(modelID);
4884+
if (pModelInfo)
4885+
pModelInfo->SetVehicleExhaustFumesPosition(position);
4886+
}
4887+
4888+
CVector CClientVehicle::GetModelExhaustPosition(unsigned short modelID)
4889+
{
4890+
auto pModelInfo = g_pGame->GetModelInfo(modelID);
4891+
if (pModelInfo)
4892+
return pModelInfo->GetVehicleExhaustFumesPosition();
4893+
4894+
return CVector();
4895+
}
4896+
48814897
bool CClientVehicle::OnVehicleFallThroughMap ( )
48824898
{
48834899
// if we have fallen through the map a small number of times

Client/mods/deathmatch/logic/CClientVehicle.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,9 @@ class CClientVehicle : public CClientStreamElement
494494

495495
void SetHeliBladeCollisionsEnabled ( bool bEnable ) { m_bEnableHeliBladeCollisions = bEnable; }
496496

497+
static void SetModelExhaustPosition(unsigned short modelID, const CVector& position);
498+
static CVector GetModelExhaustPosition(unsigned short modelID);
499+
497500
bool OnVehicleFallThroughMap ( );
498501

499502
protected:

Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ void CLuaVehicleDefs::LoadFunctions ( void )
127127
CLuaCFunctions::AddFunction ( "setVehiclePlateText", SetVehiclePlateText );
128128
CLuaCFunctions::AddFunction ( "setHeliBladeCollisionsEnabled", SetHeliBladeCollisionsEnabled );
129129
CLuaCFunctions::AddFunction ( "setVehicleWindowOpen", SetVehicleWindowOpen );
130+
CLuaCFunctions::AddFunction("setVehicleModelExhaustPosition", SetVehicleModelExhaustPosition);
131+
CLuaCFunctions::AddFunction("getVehicleModelExhaustPosition", GetVehicleModelExhaustPosition);
130132
}
131133

132134

@@ -3550,3 +3552,51 @@ int CLuaVehicleDefs::IsVehicleWindowOpen ( lua_State* luaVM )
35503552
lua_pushboolean ( luaVM, false );
35513553
return 1;
35523554
}
3555+
3556+
int CLuaVehicleDefs::SetVehicleModelExhaustPosition(lua_State* luaVM)
3557+
{
3558+
// bool setVehicleModelExhaustPosition(int modelID, float x, float y, float z)
3559+
unsigned short modelID; CVector position;
3560+
3561+
CScriptArgReader argStream(luaVM);
3562+
argStream.ReadNumber(modelID);
3563+
argStream.ReadVector3D(position);
3564+
3565+
if (!argStream.HasErrors())
3566+
{
3567+
CClientVehicle::SetModelExhaustPosition(modelID, position);
3568+
3569+
lua_pushboolean(luaVM, true);
3570+
return 1;
3571+
}
3572+
else
3573+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
3574+
3575+
lua_pushboolean(luaVM, false);
3576+
return 1;
3577+
}
3578+
3579+
int CLuaVehicleDefs::GetVehicleModelExhaustPosition(lua_State* luaVM)
3580+
{
3581+
// bool getVehicleModelExhaustPosition(int modelID, float x, float y, float z)
3582+
unsigned short modelID;
3583+
3584+
CScriptArgReader argStream(luaVM);
3585+
argStream.ReadNumber(modelID);
3586+
3587+
if (!argStream.HasErrors())
3588+
{
3589+
CVector position = CClientVehicle::GetModelExhaustPosition(modelID);
3590+
3591+
lua_pushnumber(luaVM, position.fX);
3592+
lua_pushnumber(luaVM, position.fY);
3593+
lua_pushnumber(luaVM, position.fZ);
3594+
return 3;
3595+
}
3596+
else
3597+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
3598+
3599+
lua_pushboolean(luaVM, false);
3600+
return 1;
3601+
}
3602+

Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ class CLuaVehicleDefs : public CLuaDefs
134134
LUA_DECLARE ( SetHeliBladeCollisionsEnabled );
135135
LUA_DECLARE ( SetVehicleWindowOpen );
136136

137+
LUA_DECLARE(SetVehicleModelExhaustPosition);
138+
LUA_DECLARE(GetVehicleModelExhaustPosition);
139+
137140
// Components
138141
LUA_DECLARE ( SetVehicleComponentPosition );
139142
LUA_DECLARE ( GetVehicleComponentPosition );

Client/sdk/game/CModelInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ class CModelInfo
150150
virtual unsigned int GetNumRemaps ( void ) = 0;
151151
virtual void* GetVehicleSuspensionData( void ) = 0;
152152
virtual void* SetVehicleSuspensionData( void* pSuspensionLines ) = 0;
153+
virtual CVector GetVehicleExhaustFumesPosition() = 0;
154+
virtual void SetVehicleExhaustFumesPosition(const CVector& position) = 0;
153155

154156
// Init the supported upgrades structure
155157
virtual void InitialiseSupportedUpgrades ( RpClump * pClump ) = 0;

0 commit comments

Comments
 (0)