Skip to content

Commit d7c9b06

Browse files
authored
Merge pull request #225 from patrikjuvonen/issue-9898
0009898: add setVehicleModelExhaustFumesPosition and getVehicleModelExhaustFumesPosition OOP methods
2 parents d34dd97 + b6940c7 commit d7c9b06

File tree

6 files changed

+79
-37
lines changed

6 files changed

+79
-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
@@ -3414,6 +3414,34 @@ bool CStaticFunctionDefinitions::IsVehicleWindowOpen(CClientVehicle& Vehicle, uc
34143414
return Vehicle.IsWindowOpen(ucWindow);
34153415
}
34163416

3417+
bool CStaticFunctionDefinitions::SetVehicleModelExhaustFumesPosition(unsigned short usModel, CVector& vecPosition)
3418+
{
3419+
if (CClientVehicleManager::IsValidModel(usModel))
3420+
{
3421+
auto pModelInfo = g_pGame->GetModelInfo(usModel);
3422+
if (pModelInfo)
3423+
{
3424+
pModelInfo->SetVehicleExhaustFumesPosition(vecPosition);
3425+
return true;
3426+
}
3427+
}
3428+
return false;
3429+
}
3430+
3431+
bool CStaticFunctionDefinitions::GetVehicleModelExhaustFumesPosition(unsigned short usModel, CVector& vecPosition)
3432+
{
3433+
if (CClientVehicleManager::IsValidModel(usModel))
3434+
{
3435+
auto pModelInfo = g_pGame->GetModelInfo(usModel);
3436+
if (pModelInfo)
3437+
{
3438+
vecPosition = pModelInfo->GetVehicleExhaustFumesPosition();
3439+
return true;
3440+
}
3441+
}
3442+
return false;
3443+
}
3444+
34173445
bool CStaticFunctionDefinitions::SetElementCollisionsEnabled(CClientEntity& Entity, bool bEnabled)
34183446
{
34193447
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 SetVehicleModelExhaustFumesPosition(unsigned short usModel, CVector& vecPosition);
222+
static bool GetVehicleModelExhaustFumesPosition(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: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM)
205205
lua_classfunction(luaVM, "getUpgradeSlotName", "getVehicleUpgradeSlotName");
206206
lua_classfunction(luaVM, "getCompatibleUpgrades", "getVehicleCompatibleUpgrades");
207207
lua_classfunction(luaVM, "getUpgradeOnSlot", "getVehicleUpgradeOnSlot");
208+
lua_classfunction(luaVM, "getModelExhaustFumesPosition", OOP_GetVehicleModelExhaustFumesPosition);
208209

209210
lua_classfunction(luaVM, "setComponentVisible", "setVehicleComponentVisible");
210211
lua_classfunction(luaVM, "setSirensOn", "setVehicleSirensOn");
@@ -245,6 +246,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM)
245246
lua_classfunction(luaVM, "setColor", "setVehicleColor");
246247
lua_classfunction(luaVM, "setPlateText", "setVehiclePlateText");
247248
lua_classfunction(luaVM, "setGravity", "setVehicleGravity");
249+
lua_classfunction(luaVM, "setModelExhaustFumesPosition", "setVehicleModelExhaustFumesPosition");
248250

249251
lua_classfunction(luaVM, "resetComponentPosition", "resetVehicleComponentPosition");
250252
lua_classfunction(luaVM, "resetComponentRotation", "resetVehicleComponentRotation");
@@ -3751,20 +3753,21 @@ int CLuaVehicleDefs::IsVehicleWindowOpen(lua_State* luaVM)
37513753

37523754
int CLuaVehicleDefs::SetVehicleModelExhaustFumesPosition(lua_State* luaVM)
37533755
{
3754-
// bool setVehicleModelExhaustPosition(int modelID, float x, float y, float z)
3755-
unsigned short modelID;
3756-
CVector position;
3756+
// bool setVehicleModelExhaustPosition ( int modelID, float x, float y, float z )
3757+
unsigned short usModel;
3758+
CVector vecPosition;
37573759

37583760
CScriptArgReader argStream(luaVM);
3759-
argStream.ReadNumber(modelID);
3760-
argStream.ReadVector3D(position);
3761+
argStream.ReadNumber(usModel);
3762+
argStream.ReadVector3D(vecPosition);
37613763

37623764
if (!argStream.HasErrors())
37633765
{
3764-
CClientVehicle::SetModelExhaustFumesPosition(modelID, position);
3765-
3766-
lua_pushboolean(luaVM, true);
3767-
return 1;
3766+
if (CStaticFunctionDefinitions::SetVehicleModelExhaustFumesPosition(usModel, vecPosition))
3767+
{
3768+
lua_pushboolean(luaVM, true);
3769+
return 1;
3770+
}
37683771
}
37693772
else
37703773
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
@@ -3775,20 +3778,48 @@ int CLuaVehicleDefs::SetVehicleModelExhaustFumesPosition(lua_State* luaVM)
37753778

37763779
int CLuaVehicleDefs::GetVehicleModelExhaustFumesPosition(lua_State* luaVM)
37773780
{
3778-
// bool getVehicleModelExhaustPosition(int modelID)
3779-
unsigned short modelID;
3781+
// float, float, float getVehicleModelExhaustPosition ( int modelID )
3782+
unsigned short usModel;
37803783

37813784
CScriptArgReader argStream(luaVM);
3782-
argStream.ReadNumber(modelID);
3785+
argStream.ReadNumber(usModel);
37833786

37843787
if (!argStream.HasErrors())
37853788
{
3786-
CVector position = CClientVehicle::GetModelExhaustFumesPosition(modelID);
3789+
CVector vecPosition;
3790+
3791+
if (CStaticFunctionDefinitions::GetVehicleModelExhaustFumesPosition(usModel, vecPosition))
3792+
{
3793+
lua_pushnumber(luaVM, vecPosition.fX);
3794+
lua_pushnumber(luaVM, vecPosition.fY);
3795+
lua_pushnumber(luaVM, vecPosition.fZ);
3796+
return 3;
3797+
}
3798+
}
3799+
else
3800+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
37873801

3788-
lua_pushnumber(luaVM, position.fX);
3789-
lua_pushnumber(luaVM, position.fY);
3790-
lua_pushnumber(luaVM, position.fZ);
3791-
return 3;
3802+
lua_pushboolean(luaVM, false);
3803+
return 1;
3804+
}
3805+
3806+
int CLuaVehicleDefs::OOP_GetVehicleModelExhaustFumesPosition(lua_State* luaVM)
3807+
{
3808+
// float, float, float getVehicleModelExhaustPosition ( int modelID )
3809+
unsigned short usModel;
3810+
3811+
CScriptArgReader argStream(luaVM);
3812+
argStream.ReadNumber(usModel);
3813+
3814+
if (!argStream.HasErrors())
3815+
{
3816+
CVector vecPosition;
3817+
3818+
if (CStaticFunctionDefinitions::GetVehicleModelExhaustFumesPosition(usModel, vecPosition))
3819+
{
3820+
lua_pushvector(luaVM, vecPosition);
3821+
return 1;
3822+
}
37923823
}
37933824
else
37943825
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class CLuaVehicleDefs : public CLuaDefs
137137
LUA_DECLARE(SetVehicleWindowOpen);
138138

139139
LUA_DECLARE(SetVehicleModelExhaustFumesPosition);
140-
LUA_DECLARE(GetVehicleModelExhaustFumesPosition);
140+
LUA_DECLARE_OOP(GetVehicleModelExhaustFumesPosition);
141141

142142
// Components
143143
LUA_DECLARE(SetVehicleComponentPosition);

0 commit comments

Comments
 (0)