From 02a1e1f6892316429c98e5ccb9ae66c5b0124fdd Mon Sep 17 00:00:00 2001 From: Youssef Maged <57957016+iManGaaX@users.noreply.github.com> Date: Fri, 4 Sep 2026 18:01:00 +0300 Subject: [PATCH 1/8] Implement GetStreamedWorldModels function Added GetStreamedWorldModels function to retrieve world model data. --- .../logic/luadefs/CLuaElementDefs.cpp | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp index 0073f4f88bf..9acce9d117c 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp @@ -13,6 +13,11 @@ #include "StdInc.h" #include #include "CLuaElementDefs.h" +#include +#include +#include "../game_sa/CGameSA.h" +#include "../game_sa/CPoolsSA.h" +#include "../game_sa/CBuildingSA.h" using std::list; void CLuaElementDefs::LoadFunctions() @@ -71,6 +76,7 @@ void CLuaElementDefs::LoadFunctions() {"isElementCallPropagationEnabled", IsElementCallPropagationEnabled}, {"isElementWaitingForGroundToLoad", IsElementWaitingForGroundToLoad}, {"isElementOnFire", ArgumentParser}, + {"getStreamedWorldModels", GetStreamedWorldModels}, // Element set funcs {"createElement", CreateElement}, @@ -2659,3 +2665,117 @@ bool CLuaElementDefs::IsElementOnFire(CClientEntity* entity) noexcept { return entity->IsOnFire(); } + +int CLuaElementDefs::GetStreamedWorldModels(lua_State* luaVM) +{ + lua_newtable(luaVM); + + constexpr float fRadToDeg = 180.0f / 3.14159265358979323846f; + int iIndex = 1; + + auto* ppBuildingPool = reinterpret_cast**>(CLASS_CBuildingPool); + auto* ppObjectPool = reinterpret_cast**>(CLASS_CObjectPool); + + CPools* pPools = g_pGame->GetPools(); + + auto PushNumberField = [&](const char* szKey, lua_Number number) + { + lua_pushstring(luaVM, szKey); + lua_pushnumber(luaVM, number); + lua_settable(luaVM, -3); + }; + + auto PushBoolField = [&](const char* szKey, bool bValue) + { + lua_pushstring(luaVM, szKey); + lua_pushboolean(luaVM, bValue); + lua_settable(luaVM, -3); + }; + + auto PushStringField = [&](const char* szKey, const char* szValue) + { + lua_pushstring(luaVM, szKey); + lua_pushstring(luaVM, szValue); + lua_settable(luaVM, -3); + }; + + auto ProcessPool = [&](auto* pPool, const char* szType, bool bIsObject) + { + if (!pPool || !pPool->m_pObjects || !pPool->m_byteMap) + return; + + for (int i = 0; i < pPool->m_nSize; ++i) + { + if (pPool->IsEmpty(i)) + continue; + + auto* pInterface = pPool->GetObject(i); + + if (!pInterface || !pInterface->m_pRwObject) + continue; + + if (pPools->GetClientEntity(reinterpret_cast(pInterface))) + continue; + + CVector vecPosObj = pInterface->HasMatrix() ? pInterface->matrix->vPos : pInterface->m_transform.m_translate; + CVector vecRot; + + if (pInterface->HasMatrix()) + { + CVector vRight = pInterface->matrix->vRight; + CVector vFront = pInterface->matrix->vFront; + CVector vUp = pInterface->matrix->vUp; + + vRight.Normalize(); + vFront.Normalize(); + vUp.Normalize(); + + vecRot.fX = asin(std::clamp(vFront.fZ, -1.0f, 1.0f)); + vecRot.fY = atan2(-vRight.fZ, vUp.fZ); + vecRot.fZ = atan2(-vFront.fX, vFront.fY); + } + + lua_pushnumber(luaVM, static_cast(iIndex++)); + lua_newtable(luaVM); + + PushStringField("type", szType); + PushNumberField("model", pInterface->m_nModelIndex); + + PushNumberField("x", vecPosObj.fX); + PushNumberField("y", vecPosObj.fY); + PushNumberField("z", vecPosObj.fZ); + + PushNumberField("rx", vecRot.fX * fRadToDeg); + PushNumberField("ry", vecRot.fY * fRadToDeg); + PushNumberField("rz", vecRot.fZ * fRadToDeg); + + PushNumberField("interior", pInterface->m_areaCode); + PushNumberField("ipl", pInterface->m_iplIndex); + + PushNumberField("lodModel", pInterface->m_pLod ? pInterface->m_pLod->m_nModelIndex : 0); + + PushBoolField("lod", pInterface->m_pLod != nullptr); + PushBoolField("collisions", pInterface->bUsesCollision); + PushBoolField("isStatic", pInterface->bIsStatic); + PushBoolField("visible", pInterface->bIsVisible); + + if (bIsObject) + { + auto* pObject = static_cast(static_cast(pInterface)); + + PushNumberField("health", pObject->fHealth); + PushNumberField("scale", pObject->fScale); + } + + lua_settable(luaVM, -3); + } + }; + + if (ppBuildingPool && *ppBuildingPool) + ProcessPool(*ppBuildingPool, "building", false); + + if (ppObjectPool && *ppObjectPool) + ProcessPool(*ppObjectPool, "object", true); + + return 1; +} From bdaf3a792ad4842dcdda33341202cb157d0f74ed Mon Sep 17 00:00:00 2001 From: Youssef Maged <57957016+iManGaaX@users.noreply.github.com> Date: Fri, 4 Sep 2026 18:02:33 +0300 Subject: [PATCH 2/8] Add LUA_DECLARE for GetStreamedWorldModels --- Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h index 1ab2775ce52..4ca1718614e 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h @@ -72,6 +72,7 @@ class CLuaElementDefs : public CLuaDefs LUA_DECLARE(IsElementCallPropagationEnabled); LUA_DECLARE(IsElementWaitingForGroundToLoad); static bool IsElementOnFire(CClientEntity* entity) noexcept; + LUA_DECLARE(GetStreamedWorldModels); // Element set funcs LUA_DECLARE(CreateElement); From 2dc3a250999cdb50e2796de66db09018c6649949 Mon Sep 17 00:00:00 2001 From: Youssef Maged <57957016+iManGaaX@users.noreply.github.com> Date: Fri, 4 Sep 2026 19:28:04 +0300 Subject: [PATCH 3/8] Remove GetStreamedWorldModels function Removed GetStreamedWorldModels function and its implementation. --- .../logic/luadefs/CLuaElementDefs.cpp | 120 ------------------ 1 file changed, 120 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp index 9acce9d117c..0073f4f88bf 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp @@ -13,11 +13,6 @@ #include "StdInc.h" #include #include "CLuaElementDefs.h" -#include -#include -#include "../game_sa/CGameSA.h" -#include "../game_sa/CPoolsSA.h" -#include "../game_sa/CBuildingSA.h" using std::list; void CLuaElementDefs::LoadFunctions() @@ -76,7 +71,6 @@ void CLuaElementDefs::LoadFunctions() {"isElementCallPropagationEnabled", IsElementCallPropagationEnabled}, {"isElementWaitingForGroundToLoad", IsElementWaitingForGroundToLoad}, {"isElementOnFire", ArgumentParser}, - {"getStreamedWorldModels", GetStreamedWorldModels}, // Element set funcs {"createElement", CreateElement}, @@ -2665,117 +2659,3 @@ bool CLuaElementDefs::IsElementOnFire(CClientEntity* entity) noexcept { return entity->IsOnFire(); } - -int CLuaElementDefs::GetStreamedWorldModels(lua_State* luaVM) -{ - lua_newtable(luaVM); - - constexpr float fRadToDeg = 180.0f / 3.14159265358979323846f; - int iIndex = 1; - - auto* ppBuildingPool = reinterpret_cast**>(CLASS_CBuildingPool); - auto* ppObjectPool = reinterpret_cast**>(CLASS_CObjectPool); - - CPools* pPools = g_pGame->GetPools(); - - auto PushNumberField = [&](const char* szKey, lua_Number number) - { - lua_pushstring(luaVM, szKey); - lua_pushnumber(luaVM, number); - lua_settable(luaVM, -3); - }; - - auto PushBoolField = [&](const char* szKey, bool bValue) - { - lua_pushstring(luaVM, szKey); - lua_pushboolean(luaVM, bValue); - lua_settable(luaVM, -3); - }; - - auto PushStringField = [&](const char* szKey, const char* szValue) - { - lua_pushstring(luaVM, szKey); - lua_pushstring(luaVM, szValue); - lua_settable(luaVM, -3); - }; - - auto ProcessPool = [&](auto* pPool, const char* szType, bool bIsObject) - { - if (!pPool || !pPool->m_pObjects || !pPool->m_byteMap) - return; - - for (int i = 0; i < pPool->m_nSize; ++i) - { - if (pPool->IsEmpty(i)) - continue; - - auto* pInterface = pPool->GetObject(i); - - if (!pInterface || !pInterface->m_pRwObject) - continue; - - if (pPools->GetClientEntity(reinterpret_cast(pInterface))) - continue; - - CVector vecPosObj = pInterface->HasMatrix() ? pInterface->matrix->vPos : pInterface->m_transform.m_translate; - CVector vecRot; - - if (pInterface->HasMatrix()) - { - CVector vRight = pInterface->matrix->vRight; - CVector vFront = pInterface->matrix->vFront; - CVector vUp = pInterface->matrix->vUp; - - vRight.Normalize(); - vFront.Normalize(); - vUp.Normalize(); - - vecRot.fX = asin(std::clamp(vFront.fZ, -1.0f, 1.0f)); - vecRot.fY = atan2(-vRight.fZ, vUp.fZ); - vecRot.fZ = atan2(-vFront.fX, vFront.fY); - } - - lua_pushnumber(luaVM, static_cast(iIndex++)); - lua_newtable(luaVM); - - PushStringField("type", szType); - PushNumberField("model", pInterface->m_nModelIndex); - - PushNumberField("x", vecPosObj.fX); - PushNumberField("y", vecPosObj.fY); - PushNumberField("z", vecPosObj.fZ); - - PushNumberField("rx", vecRot.fX * fRadToDeg); - PushNumberField("ry", vecRot.fY * fRadToDeg); - PushNumberField("rz", vecRot.fZ * fRadToDeg); - - PushNumberField("interior", pInterface->m_areaCode); - PushNumberField("ipl", pInterface->m_iplIndex); - - PushNumberField("lodModel", pInterface->m_pLod ? pInterface->m_pLod->m_nModelIndex : 0); - - PushBoolField("lod", pInterface->m_pLod != nullptr); - PushBoolField("collisions", pInterface->bUsesCollision); - PushBoolField("isStatic", pInterface->bIsStatic); - PushBoolField("visible", pInterface->bIsVisible); - - if (bIsObject) - { - auto* pObject = static_cast(static_cast(pInterface)); - - PushNumberField("health", pObject->fHealth); - PushNumberField("scale", pObject->fScale); - } - - lua_settable(luaVM, -3); - } - }; - - if (ppBuildingPool && *ppBuildingPool) - ProcessPool(*ppBuildingPool, "building", false); - - if (ppObjectPool && *ppObjectPool) - ProcessPool(*ppObjectPool, "object", true); - - return 1; -} From 1f5ec535afac25cc1ffa06e16a454fdd3b7300e1 Mon Sep 17 00:00:00 2001 From: Youssef Maged <57957016+iManGaaX@users.noreply.github.com> Date: Fri, 4 Sep 2026 19:28:28 +0300 Subject: [PATCH 4/8] Remove GetStreamedWorldModels declaration Removed declaration for GetStreamedWorldModels. --- Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h index 4ca1718614e..1ab2775ce52 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h @@ -72,7 +72,6 @@ class CLuaElementDefs : public CLuaDefs LUA_DECLARE(IsElementCallPropagationEnabled); LUA_DECLARE(IsElementWaitingForGroundToLoad); static bool IsElementOnFire(CClientEntity* entity) noexcept; - LUA_DECLARE(GetStreamedWorldModels); // Element set funcs LUA_DECLARE(CreateElement); From 72ed71ea51d756a4648c9b843d97d42790be8b2a Mon Sep 17 00:00:00 2001 From: Youssef Maged <57957016+iManGaaX@users.noreply.github.com> Date: Fri, 4 Sep 2026 19:28:54 +0300 Subject: [PATCH 5/8] Add GetStreamedWorldModels declaration --- Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h index 5ad83bdeae0..8c3ec44530d 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h @@ -17,6 +17,7 @@ class CLuaWorldDefs : public CLuaDefs LUA_DECLARE(GetTime); LUA_DECLARE(GetGroundPosition); + LUA_DECLARE(GetStreamedWorldModels); LUA_DECLARE(GetRoofPosition); static std::variant> ProcessLineAgainstMesh(CClientEntity* e, CVector start, From b4015fee1bd3912c51260c424cd6249adc6669a7 Mon Sep 17 00:00:00 2001 From: Youssef Maged <57957016+iManGaaX@users.noreply.github.com> Date: Fri, 4 Sep 2026 19:29:13 +0300 Subject: [PATCH 6/8] Implement GetStreamedWorldModels function Added GetStreamedWorldModels function to retrieve world model data and populate Lua table. --- .../logic/luadefs/CLuaWorldDefs.cpp | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp index 87e8a23a6c0..630ca9f6fbc 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp @@ -14,6 +14,8 @@ #include #include #include "lua/CLuaFunctionParser.h" +#include +#include "../game_sa/CPoolsSA.h" void CLuaWorldDefs::LoadFunctions() { @@ -23,6 +25,7 @@ void CLuaWorldDefs::LoadFunctions() {"getColorFilter", ArgumentParser}, {"getRoofPosition", GetRoofPosition}, {"getGroundPosition", GetGroundPosition}, + {"getStreamedWorldModels", GetStreamedWorldModels}, {"processLineAgainstMesh", ArgumentParser}, {"processLineOfSight", ProcessLineOfSight}, {"getWorldFromScreenPosition", GetWorldFromScreenPosition}, @@ -2388,3 +2391,117 @@ CLuaMultiReturn**>(CLASS_CBuildingPool); + auto* ppObjectPool = reinterpret_cast**>(CLASS_CObjectPool); + + CPools* pPools = g_pGame->GetPools(); + + auto PushNumberField = [&](const char* szKey, lua_Number number) + { + lua_pushstring(luaVM, szKey); + lua_pushnumber(luaVM, number); + lua_settable(luaVM, -3); + }; + + auto PushBoolField = [&](const char* szKey, bool bValue) + { + lua_pushstring(luaVM, szKey); + lua_pushboolean(luaVM, bValue); + lua_settable(luaVM, -3); + }; + + auto PushStringField = [&](const char* szKey, const char* szValue) + { + lua_pushstring(luaVM, szKey); + lua_pushstring(luaVM, szValue); + lua_settable(luaVM, -3); + }; + + auto ProcessPool = [&](auto* pPool, const char* szType, bool bIsObject) + { + if (!pPool || !pPool->m_pObjects || !pPool->m_byteMap) + return; + + for (int i = 0; i < pPool->m_nSize; ++i) + { + if (pPool->IsEmpty(i)) + continue; + + auto* pInterface = pPool->GetObject(i); + + if (!pInterface || !pInterface->m_pRwObject) + continue; + + if (pPools->GetClientEntity(reinterpret_cast(pInterface))) + continue; + + CVector vecPosObj = pInterface->HasMatrix() ? pInterface->matrix->vPos : pInterface->m_transform.m_translate; + CVector vecRot; + + if (pInterface->HasMatrix()) + { + CVector vRight = pInterface->matrix->vRight; + CVector vFront = pInterface->matrix->vFront; + CVector vUp = pInterface->matrix->vUp; + + vRight.Normalize(); + vFront.Normalize(); + vUp.Normalize(); + + vecRot.fX = asin(std::clamp(vFront.fZ, -1.0f, 1.0f)); + vecRot.fY = atan2(-vRight.fZ, vUp.fZ); + vecRot.fZ = atan2(-vFront.fX, vFront.fY); + } + + lua_pushnumber(luaVM, static_cast(iIndex++)); + lua_newtable(luaVM); + + PushStringField("type", szType); + PushNumberField("model", pInterface->m_nModelIndex); + + PushNumberField("x", vecPosObj.fX); + PushNumberField("y", vecPosObj.fY); + PushNumberField("z", vecPosObj.fZ); + + PushNumberField("rx", vecRot.fX * fRadToDeg); + PushNumberField("ry", vecRot.fY * fRadToDeg); + PushNumberField("rz", vecRot.fZ * fRadToDeg); + + PushNumberField("interior", pInterface->m_areaCode); + PushNumberField("ipl", pInterface->m_iplIndex); + + PushNumberField("lodModel", pInterface->m_pLod ? pInterface->m_pLod->m_nModelIndex : 0); + + PushBoolField("lod", pInterface->m_pLod != nullptr); + PushBoolField("collisions", pInterface->bUsesCollision); + PushBoolField("isStatic", pInterface->bIsStatic); + PushBoolField("visible", pInterface->bIsVisible); + + if (bIsObject) + { + auto* pObject = static_cast(static_cast(pInterface)); + + PushNumberField("health", pObject->fHealth); + PushNumberField("scale", pObject->fScale); + } + + lua_settable(luaVM, -3); + } + }; + + if (ppBuildingPool && *ppBuildingPool) + ProcessPool(*ppBuildingPool, "building", false); + + if (ppObjectPool && *ppObjectPool) + ProcessPool(*ppObjectPool, "object", true); + + return 1; +} From 5111bee411291e874a4d7ccf2fa1dde7ed359b18 Mon Sep 17 00:00:00 2001 From: Youssef Maged <57957016+iManGaaX@users.noreply.github.com> Date: Fri, 4 Sep 2026 19:32:12 +0300 Subject: [PATCH 7/8] Implement GetStreamedWorldModels function --- .../logic/luadefs/CLuaWorldDefs.cpp | 228 +++++++++--------- 1 file changed, 114 insertions(+), 114 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp index 630ca9f6fbc..06f47f7c0aa 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp @@ -255,6 +255,120 @@ int CLuaWorldDefs::GetRoofPosition(lua_State* luaVM) return 1; } +int CLuaWorldDefs::GetStreamedWorldModels(lua_State* luaVM) +{ + lua_newtable(luaVM); + + constexpr float fRadToDeg = 180.0f / 3.14159265358979323846f; + int iIndex = 1; + + auto* ppBuildingPool = reinterpret_cast**>(CLASS_CBuildingPool); + auto* ppObjectPool = reinterpret_cast**>(CLASS_CObjectPool); + + CPools* pPools = g_pGame->GetPools(); + + auto PushNumberField = [&](const char* szKey, lua_Number number) + { + lua_pushstring(luaVM, szKey); + lua_pushnumber(luaVM, number); + lua_settable(luaVM, -3); + }; + + auto PushBoolField = [&](const char* szKey, bool bValue) + { + lua_pushstring(luaVM, szKey); + lua_pushboolean(luaVM, bValue); + lua_settable(luaVM, -3); + }; + + auto PushStringField = [&](const char* szKey, const char* szValue) + { + lua_pushstring(luaVM, szKey); + lua_pushstring(luaVM, szValue); + lua_settable(luaVM, -3); + }; + + auto ProcessPool = [&](auto* pPool, const char* szType, bool bIsObject) + { + if (!pPool || !pPool->m_pObjects || !pPool->m_byteMap) + return; + + for (int i = 0; i < pPool->m_nSize; ++i) + { + if (pPool->IsEmpty(i)) + continue; + + auto* pInterface = pPool->GetObject(i); + + if (!pInterface || !pInterface->m_pRwObject) + continue; + + if (pPools->GetClientEntity(reinterpret_cast(pInterface))) + continue; + + CVector vecPosObj = pInterface->HasMatrix() ? pInterface->matrix->vPos : pInterface->m_transform.m_translate; + CVector vecRot; + + if (pInterface->HasMatrix()) + { + CVector vRight = pInterface->matrix->vRight; + CVector vFront = pInterface->matrix->vFront; + CVector vUp = pInterface->matrix->vUp; + + vRight.Normalize(); + vFront.Normalize(); + vUp.Normalize(); + + vecRot.fX = asin(std::clamp(vFront.fZ, -1.0f, 1.0f)); + vecRot.fY = atan2(-vRight.fZ, vUp.fZ); + vecRot.fZ = atan2(-vFront.fX, vFront.fY); + } + + lua_pushnumber(luaVM, static_cast(iIndex++)); + lua_newtable(luaVM); + + PushStringField("type", szType); + PushNumberField("model", pInterface->m_nModelIndex); + + PushNumberField("x", vecPosObj.fX); + PushNumberField("y", vecPosObj.fY); + PushNumberField("z", vecPosObj.fZ); + + PushNumberField("rx", vecRot.fX * fRadToDeg); + PushNumberField("ry", vecRot.fY * fRadToDeg); + PushNumberField("rz", vecRot.fZ * fRadToDeg); + + PushNumberField("interior", pInterface->m_areaCode); + PushNumberField("ipl", pInterface->m_iplIndex); + + PushNumberField("lodModel", pInterface->m_pLod ? pInterface->m_pLod->m_nModelIndex : 0); + + PushBoolField("lod", pInterface->m_pLod != nullptr); + PushBoolField("collisions", pInterface->bUsesCollision); + PushBoolField("isStatic", pInterface->bIsStatic); + PushBoolField("visible", pInterface->bIsVisible); + + if (bIsObject) + { + auto* pObject = static_cast(static_cast(pInterface)); + + PushNumberField("health", pObject->fHealth); + PushNumberField("scale", pObject->fScale); + } + + lua_settable(luaVM, -3); + } + }; + + if (ppBuildingPool && *ppBuildingPool) + ProcessPool(*ppBuildingPool, "building", false); + + if (ppObjectPool && *ppObjectPool) + ProcessPool(*ppObjectPool, "object", true); + + return 1; +} + std::variant> CLuaWorldDefs::ProcessLineAgainstMesh(CClientEntity* e, CVector start, CVector end) @@ -2391,117 +2505,3 @@ CLuaMultiReturn**>(CLASS_CBuildingPool); - auto* ppObjectPool = reinterpret_cast**>(CLASS_CObjectPool); - - CPools* pPools = g_pGame->GetPools(); - - auto PushNumberField = [&](const char* szKey, lua_Number number) - { - lua_pushstring(luaVM, szKey); - lua_pushnumber(luaVM, number); - lua_settable(luaVM, -3); - }; - - auto PushBoolField = [&](const char* szKey, bool bValue) - { - lua_pushstring(luaVM, szKey); - lua_pushboolean(luaVM, bValue); - lua_settable(luaVM, -3); - }; - - auto PushStringField = [&](const char* szKey, const char* szValue) - { - lua_pushstring(luaVM, szKey); - lua_pushstring(luaVM, szValue); - lua_settable(luaVM, -3); - }; - - auto ProcessPool = [&](auto* pPool, const char* szType, bool bIsObject) - { - if (!pPool || !pPool->m_pObjects || !pPool->m_byteMap) - return; - - for (int i = 0; i < pPool->m_nSize; ++i) - { - if (pPool->IsEmpty(i)) - continue; - - auto* pInterface = pPool->GetObject(i); - - if (!pInterface || !pInterface->m_pRwObject) - continue; - - if (pPools->GetClientEntity(reinterpret_cast(pInterface))) - continue; - - CVector vecPosObj = pInterface->HasMatrix() ? pInterface->matrix->vPos : pInterface->m_transform.m_translate; - CVector vecRot; - - if (pInterface->HasMatrix()) - { - CVector vRight = pInterface->matrix->vRight; - CVector vFront = pInterface->matrix->vFront; - CVector vUp = pInterface->matrix->vUp; - - vRight.Normalize(); - vFront.Normalize(); - vUp.Normalize(); - - vecRot.fX = asin(std::clamp(vFront.fZ, -1.0f, 1.0f)); - vecRot.fY = atan2(-vRight.fZ, vUp.fZ); - vecRot.fZ = atan2(-vFront.fX, vFront.fY); - } - - lua_pushnumber(luaVM, static_cast(iIndex++)); - lua_newtable(luaVM); - - PushStringField("type", szType); - PushNumberField("model", pInterface->m_nModelIndex); - - PushNumberField("x", vecPosObj.fX); - PushNumberField("y", vecPosObj.fY); - PushNumberField("z", vecPosObj.fZ); - - PushNumberField("rx", vecRot.fX * fRadToDeg); - PushNumberField("ry", vecRot.fY * fRadToDeg); - PushNumberField("rz", vecRot.fZ * fRadToDeg); - - PushNumberField("interior", pInterface->m_areaCode); - PushNumberField("ipl", pInterface->m_iplIndex); - - PushNumberField("lodModel", pInterface->m_pLod ? pInterface->m_pLod->m_nModelIndex : 0); - - PushBoolField("lod", pInterface->m_pLod != nullptr); - PushBoolField("collisions", pInterface->bUsesCollision); - PushBoolField("isStatic", pInterface->bIsStatic); - PushBoolField("visible", pInterface->bIsVisible); - - if (bIsObject) - { - auto* pObject = static_cast(static_cast(pInterface)); - - PushNumberField("health", pObject->fHealth); - PushNumberField("scale", pObject->fScale); - } - - lua_settable(luaVM, -3); - } - }; - - if (ppBuildingPool && *ppBuildingPool) - ProcessPool(*ppBuildingPool, "building", false); - - if (ppObjectPool && *ppObjectPool) - ProcessPool(*ppObjectPool, "object", true); - - return 1; -} From 132cddfbfc6145e1ab067b8e9c2398f6fe2b2bfb Mon Sep 17 00:00:00 2001 From: Youssef Maged <57957016+iManGaaX@users.noreply.github.com> Date: Fri, 4 Sep 2026 19:34:17 +0300 Subject: [PATCH 8/8] Restore GetStreamedWorldModels declaration --- Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h index 8c3ec44530d..89d69cb4874 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h @@ -17,8 +17,8 @@ class CLuaWorldDefs : public CLuaDefs LUA_DECLARE(GetTime); LUA_DECLARE(GetGroundPosition); - LUA_DECLARE(GetStreamedWorldModels); LUA_DECLARE(GetRoofPosition); + LUA_DECLARE(GetStreamedWorldModels); static std::variant> ProcessLineAgainstMesh(CClientEntity* e, CVector start, CVector end);