Skip to content

Commit f36fd7f

Browse files
committed
CClientVehicle: move ModelExhaustFumes logic to CStaticFuncDefs
1 parent 149a0ad commit f36fd7f

File tree

5 files changed

+52
-37
lines changed

5 files changed

+52
-37
lines changed

Client/mods/deathmatch/logic/CClientVehicle.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4724,22 +4724,6 @@ bool CClientVehicle::DoesSupportUpgrade(const SString& strFrameName)
47244724
return true;
47254725
}
47264726

4727-
void CClientVehicle::SetModelExhaustFumesPosition(unsigned short modelID, const CVector& position)
4728-
{
4729-
auto pModelInfo = g_pGame->GetModelInfo(modelID);
4730-
if (pModelInfo)
4731-
pModelInfo->SetVehicleExhaustFumesPosition(position);
4732-
}
4733-
4734-
CVector CClientVehicle::GetModelExhaustFumesPosition(unsigned short modelID)
4735-
{
4736-
auto pModelInfo = g_pGame->GetModelInfo(modelID);
4737-
if (pModelInfo)
4738-
return pModelInfo->GetVehicleExhaustFumesPosition();
4739-
4740-
return CVector();
4741-
}
4742-
47434727
bool CClientVehicle::OnVehicleFallThroughMap()
47444728
{
47454729
// if we have fallen through the map a small number of times

Client/mods/deathmatch/logic/CClientVehicle.h

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

485485
void SetHeliBladeCollisionsEnabled(bool bEnable) { m_bEnableHeliBladeCollisions = bEnable; }
486486

487-
static void SetModelExhaustFumesPosition(unsigned short modelID, const CVector& position);
488-
static CVector GetModelExhaustFumesPosition(unsigned short modelID);
489-
490487
bool OnVehicleFallThroughMap();
491488

492489
protected:

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3415,6 +3415,34 @@ bool CStaticFunctionDefinitions::IsVehicleWindowOpen(CClientVehicle& Vehicle, uc
34153415
return Vehicle.IsWindowOpen(ucWindow);
34163416
}
34173417

3418+
bool CStaticFunctionDefinitions::SetModelExhaustFumesPosition(unsigned short usModel, CVector& vecPosition)
3419+
{
3420+
if (CVehicleNames::IsValidModel(usModel))
3421+
{
3422+
auto pModelInfo = g_pGame->GetModelInfo(usModel);
3423+
if (pModelInfo)
3424+
{
3425+
pModelInfo->SetVehicleExhaustFumesPosition(vecPosition);
3426+
return true;
3427+
}
3428+
}
3429+
return false;
3430+
}
3431+
3432+
bool CStaticFunctionDefinitions::GetModelExhaustFumesPosition(unsigned short usModel, CVector& vecPosition)
3433+
{
3434+
if (CVehicleNames::IsValidModel(usModel))
3435+
{
3436+
auto pModelInfo = g_pGame->GetModelInfo(usModel);
3437+
if (pModelInfo)
3438+
{
3439+
vecPosition = pModelInfo->GetVehicleExhaustFumesPosition();
3440+
return true;
3441+
}
3442+
}
3443+
return false;
3444+
}
3445+
34183446
bool CStaticFunctionDefinitions::SetElementCollisionsEnabled(CClientEntity& Entity, bool bEnabled)
34193447
{
34203448
switch (Entity.GetType())

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ class CStaticFunctionDefinitions
218218
static bool GetVehicleNitroLevel(CClientVehicle& Vehicle, float& fLevel);
219219
static bool GetHeliBladeCollisionsEnabled(CClientVehicle& Vehicle);
220220
static bool IsVehicleWindowOpen(CClientVehicle& Vehicle, uchar ucWindow);
221+
static bool SetModelExhaustFumesPosition(unsigned short usModel, CVector& vecPosition);
222+
static bool GetModelExhaustFumesPosition(unsigned short usModel, CVector& vecPosition);
221223

222224
// Vehicle set functions
223225
static bool FixVehicle(CClientEntity& Entity);

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

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3751,20 +3751,21 @@ int CLuaVehicleDefs::IsVehicleWindowOpen(lua_State* luaVM)
37513751

37523752
int CLuaVehicleDefs::SetVehicleModelExhaustFumesPosition(lua_State* luaVM)
37533753
{
3754-
// bool setVehicleModelExhaustPosition(int modelID, float x, float y, float z)
3755-
unsigned short modelID;
3756-
CVector position;
3754+
// bool setVehicleModelExhaustPosition ( int modelID, float x, float y, float z )
3755+
unsigned short usModel;
3756+
CVector vecPosition;
37573757

37583758
CScriptArgReader argStream(luaVM);
3759-
argStream.ReadNumber(modelID);
3760-
argStream.ReadVector3D(position);
3759+
argStream.ReadNumber(usModel);
3760+
argStream.ReadVector3D(vecPosition);
37613761

37623762
if (!argStream.HasErrors())
37633763
{
3764-
CClientVehicle::SetModelExhaustFumesPosition(modelID, position);
3765-
3766-
lua_pushboolean(luaVM, true);
3767-
return 1;
3764+
if (CStaticFunctionDefinitions::SetModelExhaustFumesPosition(usModel, vecPosition))
3765+
{
3766+
lua_pushboolean(luaVM, true);
3767+
return 1;
3768+
}
37683769
}
37693770
else
37703771
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
@@ -3775,20 +3776,23 @@ int CLuaVehicleDefs::SetVehicleModelExhaustFumesPosition(lua_State* luaVM)
37753776

37763777
int CLuaVehicleDefs::GetVehicleModelExhaustFumesPosition(lua_State* luaVM)
37773778
{
3778-
// bool getVehicleModelExhaustPosition(int modelID)
3779-
unsigned short modelID;
3779+
// float, float, float getVehicleModelExhaustPosition ( int modelID )
3780+
unsigned short usModel;
37803781

37813782
CScriptArgReader argStream(luaVM);
3782-
argStream.ReadNumber(modelID);
3783+
argStream.ReadNumber(usModel);
37833784

37843785
if (!argStream.HasErrors())
37853786
{
3786-
CVector position = CClientVehicle::GetModelExhaustFumesPosition(modelID);
3787-
3788-
lua_pushnumber(luaVM, position.fX);
3789-
lua_pushnumber(luaVM, position.fY);
3790-
lua_pushnumber(luaVM, position.fZ);
3791-
return 3;
3787+
CVector vecPosition;
3788+
3789+
if (CStaticFunctionDefinitions::GetModelExhaustFumesPosition(usModel, vecPosition))
3790+
{
3791+
lua_pushnumber(luaVM, vecPosition.fX);
3792+
lua_pushnumber(luaVM, vecPosition.fY);
3793+
lua_pushnumber(luaVM, vecPosition.fZ);
3794+
return 3;
3795+
}
37923796
}
37933797
else
37943798
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

0 commit comments

Comments
 (0)