From f88d31306d3c7fadfbc1542c85922612fd00b131 Mon Sep 17 00:00:00 2001 From: Kamil Schneider Date: Wed, 29 May 2024 14:24:58 +0200 Subject: [PATCH] Add sync argument to createVehicle (PR #3334) --- Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp | 3 ++- Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h | 2 +- Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 9c1853c21c..436e0d754e 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -4871,7 +4871,7 @@ bool CStaticFunctionDefinitions::SetWeaponAmmo(CElement* pElement, unsigned char } CVehicle* CStaticFunctionDefinitions::CreateVehicle(CResource* pResource, unsigned short usModel, const CVector& vecPosition, const CVector& vecRotation, - const char* szRegPlate, unsigned char ucVariant, unsigned char ucVariant2) + const char* szRegPlate, unsigned char ucVariant, unsigned char ucVariant2, bool bSynced) { unsigned char ucVariation = ucVariant; unsigned char ucVariation2 = ucVariant2; @@ -4890,6 +4890,7 @@ CVehicle* CStaticFunctionDefinitions::CreateVehicle(CResource* pResource, unsign pVehicle->SetRotationDegrees(vecRotation); pVehicle->SetRespawnPosition(vecPosition); pVehicle->SetRespawnRotationDegrees(vecRotation); + pVehicle->SetUnoccupiedSyncable(bSynced); if (szRegPlate && szRegPlate[0]) pVehicle->SetRegPlate(szRegPlate); diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h index fe9d20ebf8..75466c9dcf 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h @@ -240,7 +240,7 @@ class CStaticFunctionDefinitions // Vehicle create/destroy functions static CVehicle* CreateVehicle(CResource* pResource, unsigned short usModel, const CVector& vecPosition, const CVector& vecRotation, const char* szRegPlate, - unsigned char ucVariant, unsigned char ucVariant2); + unsigned char ucVariant, unsigned char ucVariant2, bool bSynced); // Vehicle get functions static bool GetVehicleVariant(CVehicle* pVehicle, unsigned char& ucVariant, unsigned char& ucVariant2); diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp index 0a35ebfa20..9b158a408b 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp +++ b/Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp @@ -290,6 +290,7 @@ int CLuaVehicleDefs::CreateVehicle(lua_State* luaVM) SString strNumberPlate; uchar ucVariant; uchar ucVariant2; + bool bSynced; CScriptArgReader argStream(luaVM); argStream.ReadNumber(usModel); @@ -303,6 +304,7 @@ int CLuaVehicleDefs::CreateVehicle(lua_State* luaVM) } argStream.ReadNumber(ucVariant, 254); argStream.ReadNumber(ucVariant2, 254); + argStream.ReadBool(bSynced, true); if (!argStream.HasErrors()) { @@ -316,7 +318,7 @@ int CLuaVehicleDefs::CreateVehicle(lua_State* luaVM) { // Create the vehicle and return its handle CVehicle* pVehicle = - CStaticFunctionDefinitions::CreateVehicle(pResource, usModel, vecPosition, vecRotation, strNumberPlate, ucVariant, ucVariant2); + CStaticFunctionDefinitions::CreateVehicle(pResource, usModel, vecPosition, vecRotation, strNumberPlate, ucVariant, ucVariant2, bSynced); if (pVehicle) { CElementGroup* pGroup = pResource->GetElementGroup();