diff --git a/Client/core/CCore.cpp b/Client/core/CCore.cpp index 3d32a3b7d4..4fbea21a47 100644 --- a/Client/core/CCore.cpp +++ b/Client/core/CCore.cpp @@ -2012,11 +2012,21 @@ void CCore::OnPreHUDRender() { IDirect3DDevice9* pDevice = CGraphics::GetSingleton().GetDevice(); - CGraphics::GetSingleton().EnteringMTARenderZone(); + if (CGraphics::GetSingleton().HasLine3DPostFXQueueItems() || CGraphics::GetSingleton().HasPrimitive3DPostFXQueueItems()) + { + /* + Although MTA render zones are expensive, we should use them twice in the bounds of the function + because some of render states from PostFX drain to the 2D part of the frame. + */ + CGraphics::GetSingleton().EnteringMTARenderZone(); + + CGraphics::GetSingleton().DrawPrimitive3DPostFXQueue(); + CGraphics::GetSingleton().DrawLine3DPostFXQueue(); + + CGraphics::GetSingleton().LeavingMTARenderZone(); + } - // Draw post-fx 3D primitives - CGraphics::GetSingleton().DrawPrimitive3DPostFXQueue(); - CGraphics::GetSingleton().DrawLine3DPostFXQueue(); + CGraphics::GetSingleton().EnteringMTARenderZone(); // Maybe capture screen and other stuff CGraphics::GetSingleton().GetRenderItemManager()->DoPulse(); diff --git a/Client/core/Graphics/CGraphics.cpp b/Client/core/Graphics/CGraphics.cpp index 274d0d13e4..284412415c 100644 --- a/Client/core/Graphics/CGraphics.cpp +++ b/Client/core/Graphics/CGraphics.cpp @@ -1651,6 +1651,11 @@ bool CGraphics::HasLine3DPreGUIQueueItems(void) return m_pLine3DBatcherPreGUI->HasItems() || m_pMaterialLine3DBatcherPreGUI->HasItems(); } +bool CGraphics::HasLine3DPostFXQueueItems() +{ + return m_pLine3DBatcherPostFX->HasItems() || m_pMaterialLine3DBatcherPostFX->HasItems(); +} + void CGraphics::DrawPrimitive3DPostFXQueue(void) { m_pPrimitive3DBatcherPostFX->Flush(); @@ -1662,6 +1667,11 @@ bool CGraphics::HasPrimitive3DPreGUIQueueItems(void) return m_pMaterialPrimitive3DBatcherPreGUI->HasItems() || m_pPrimitive3DBatcherPreGUI->HasItems(); } +bool CGraphics::HasPrimitive3DPostFXQueueItems() +{ + return m_pMaterialPrimitive3DBatcherPostFX->HasItems() || m_pPrimitive3DBatcherPostFX->HasItems(); +} + void CGraphics::DrawQueue(std::vector& Queue) { BeginDrawBatch(); diff --git a/Client/core/Graphics/CGraphics.h b/Client/core/Graphics/CGraphics.h index 44cd7c9a7f..05efb20241 100644 --- a/Client/core/Graphics/CGraphics.h +++ b/Client/core/Graphics/CGraphics.h @@ -190,9 +190,11 @@ class CGraphics : public CGraphicsInterface, public CSingleton void DrawLine3DPreGUIQueue(void); void DrawLine3DPostFXQueue(void); bool HasLine3DPreGUIQueueItems(void); + bool HasLine3DPostFXQueueItems(); void DrawPrimitive3DPostFXQueue(void); void DrawPrimitive3DPreGUIQueue(void); bool HasPrimitive3DPreGUIQueueItems(void); + bool HasPrimitive3DPostFXQueueItems(); void DidRenderScene(); void SetProgressMessage(const SString& strMessage); 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();