From c738383256fb05f2e59a18cf49efeb2a4a5d098e Mon Sep 17 00:00:00 2001 From: Uladzislau Nikalayevich Date: Wed, 22 Jan 2025 21:01:17 +0300 Subject: [PATCH 1/3] Apply element filter for buildings in engineApplyShaderToWorldTexture --- Client/game_sa/CBuildingsPoolSA.cpp | 10 ++++++++++ Client/game_sa/CBuildingsPoolSA.h | 1 + Client/game_sa/CPoolsSA.cpp | 6 +++++- Client/mods/deathmatch/logic/CClientGame.cpp | 3 +++ Client/multiplayer_sa/multiplayersa_init.cpp | 4 ++-- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Client/game_sa/CBuildingsPoolSA.cpp b/Client/game_sa/CBuildingsPoolSA.cpp index 683330ed3c..812ead5b34 100644 --- a/Client/game_sa/CBuildingsPoolSA.cpp +++ b/Client/game_sa/CBuildingsPoolSA.cpp @@ -48,6 +48,16 @@ inline bool CBuildingsPoolSA::AddBuildingToPool(CClientBuilding* pClientBuilding return true; } +CClientEntity* CBuildingsPoolSA::GetClientBuilding(CBuildingSAInterface* pGameInterface) const noexcept +{ + auto poolIndex = (*m_ppBuildingPoolInterface)->GetObjectIndex(pGameInterface); + + if (poolIndex == -1) + return nullptr; + + return m_buildingPool.entities[poolIndex].pClientEntity; +} + CBuilding* CBuildingsPoolSA::AddBuilding(CClientBuilding* pClientBuilding, uint16_t modelId, CVector* vPos, CVector4D* vRot, uint8_t interior) { if (!HasFreeBuildingSlot()) diff --git a/Client/game_sa/CBuildingsPoolSA.h b/Client/game_sa/CBuildingsPoolSA.h index 38e64970f1..ff201f3393 100644 --- a/Client/game_sa/CBuildingsPoolSA.h +++ b/Client/game_sa/CBuildingsPoolSA.h @@ -30,6 +30,7 @@ class CBuildingsPoolSA : public CBuildingsPool void RestoreBackup() override; bool Resize(int size) override; int GetSize() const override { return (*m_ppBuildingPoolInterface)->m_nSize; }; + CClientEntity* GetClientBuilding(CBuildingSAInterface* pGameInterface) const noexcept; private: void RemoveBuildingFromWorld(CBuildingSAInterface* pBuilding); diff --git a/Client/game_sa/CPoolsSA.cpp b/Client/game_sa/CPoolsSA.cpp index bd7a5f9c96..6d926ecfc8 100644 --- a/Client/game_sa/CPoolsSA.cpp +++ b/Client/game_sa/CPoolsSA.cpp @@ -566,8 +566,12 @@ CClientEntity* CPoolsSA::GetClientEntity(DWORD* pGameInterface) { return pThePedEntity->pClientEntity; } + + auto clientBuilding = m_BuildingsPool.GetClientBuilding(reinterpret_cast(pGameInterface)); + if (clientBuilding) + return clientBuilding; } - return NULL; + return nullptr; } static void CreateMissionTrain(const CVector& vecPos, bool bDirection, std::uint32_t uiTrainType, CTrainSAInterface** ppTrainBeginning, diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index dcb73b1738..f195dceaad 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -3734,6 +3734,9 @@ void CClientGame::StaticGameEntityRenderHandler(CEntitySAInterface* pGameEntity) case CCLIENTOBJECT: iTypeMask = TYPE_MASK_OBJECT; break; + case CCLIENTBUILDING: + iTypeMask = TYPE_MASK_WORLD; + break; default: iTypeMask = TYPE_MASK_OTHER; break; diff --git a/Client/multiplayer_sa/multiplayersa_init.cpp b/Client/multiplayer_sa/multiplayersa_init.cpp index 30e36ffec3..3ee28f9f22 100644 --- a/Client/multiplayer_sa/multiplayersa_init.cpp +++ b/Client/multiplayer_sa/multiplayersa_init.cpp @@ -82,8 +82,8 @@ void LogEvent(uint uiDebugId, const char* szType, const char* szContext, const c void CallGameEntityRenderHandler(CEntitySAInterface* pEntity) { - // Only call if not a building or a dummy - if (!pEntity || (pEntity->nType != ENTITY_TYPE_BUILDING && pEntity->nType != ENTITY_TYPE_DUMMY)) + // Only call if not a dummy + if (!pEntity || pEntity->nType != ENTITY_TYPE_DUMMY) if (pGameEntityRenderHandler) pGameEntityRenderHandler(pEntity); } From e708fc79bca45a35f7bda78db064298c0ee8288d Mon Sep 17 00:00:00 2001 From: Uladzislau Nikalayevich Date: Thu, 23 Jan 2025 09:42:26 +0300 Subject: [PATCH 2/3] review --- Client/game_sa/CBuildingsPoolSA.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/game_sa/CBuildingsPoolSA.cpp b/Client/game_sa/CBuildingsPoolSA.cpp index 812ead5b34..71280351c0 100644 --- a/Client/game_sa/CBuildingsPoolSA.cpp +++ b/Client/game_sa/CBuildingsPoolSA.cpp @@ -50,7 +50,7 @@ inline bool CBuildingsPoolSA::AddBuildingToPool(CClientBuilding* pClientBuilding CClientEntity* CBuildingsPoolSA::GetClientBuilding(CBuildingSAInterface* pGameInterface) const noexcept { - auto poolIndex = (*m_ppBuildingPoolInterface)->GetObjectIndex(pGameInterface); + std::uint32_t poolIndex = (*m_ppBuildingPoolInterface)->GetObjectIndex(pGameInterface); if (poolIndex == -1) return nullptr; From a11d88c75756e3b01e2e2067e2a1c91b35ae0bb4 Mon Sep 17 00:00:00 2001 From: Uladzislau Nikalayevich Date: Thu, 23 Jan 2025 10:08:34 +0300 Subject: [PATCH 3/3] static_cast --- Client/game_sa/CBuildingsPoolSA.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/game_sa/CBuildingsPoolSA.cpp b/Client/game_sa/CBuildingsPoolSA.cpp index 71280351c0..89773889de 100644 --- a/Client/game_sa/CBuildingsPoolSA.cpp +++ b/Client/game_sa/CBuildingsPoolSA.cpp @@ -52,7 +52,7 @@ CClientEntity* CBuildingsPoolSA::GetClientBuilding(CBuildingSAInterface* pGameIn { std::uint32_t poolIndex = (*m_ppBuildingPoolInterface)->GetObjectIndex(pGameInterface); - if (poolIndex == -1) + if (poolIndex == static_cast(-1)) return nullptr; return m_buildingPool.entities[poolIndex].pClientEntity;