Skip to content

Commit

Permalink
Add sync argument to createVehicle (PR #3334)
Browse files Browse the repository at this point in the history
  • Loading branch information
znvjder authored May 29, 2024
1 parent c75ae36 commit f88d313
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ int CLuaVehicleDefs::CreateVehicle(lua_State* luaVM)
SString strNumberPlate;
uchar ucVariant;
uchar ucVariant2;
bool bSynced;

CScriptArgReader argStream(luaVM);
argStream.ReadNumber(usModel);
Expand All @@ -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())
{
Expand All @@ -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();
Expand Down

0 comments on commit f88d313

Please sign in to comment.