From 0300f4fe7caec7cfbba13f77f6cb1d15cfc85680 Mon Sep 17 00:00:00 2001 From: sousateew Date: Wed, 18 Jun 2025 20:55:06 -0300 Subject: [PATCH] Add engineIsModelValid --- .../mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp | 11 +++++++++++ Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h | 1 + 2 files changed, 12 insertions(+) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp index 3de38bbf76..e8719f377c 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp @@ -150,6 +150,7 @@ void CLuaEngineDefs::LoadFunctions() {"engineGetPoolUsedCapacity", ArgumentParser}, {"engineSetPoolCapacity", ArgumentParser}, {"enginePreloadWorldArea", ArgumentParser}, + {"engineIsModelValid", ArgumentParser} // CLuaCFunctions::AddFunction ( "engineReplaceMatchingAtomics", EngineReplaceMatchingAtomics ); // CLuaCFunctions::AddFunction ( "engineReplaceWheelAtomics", EngineReplaceWheelAtomics ); @@ -2593,3 +2594,13 @@ void CLuaEngineDefs::EnginePreloadWorldArea(CVector position, std::optionalGetStreaming()->LoadSceneCollision(&position); } + +bool CLuaEngineDefs::EngineIsModelValid(uint uiModelId) +{ + CModelInfo* pModelInfo = g_pGame->GetModelInfo(uiModelId); + + if (uiModelId >= 20000 || !pModelInfo) + return false; + + return true; +} \ No newline at end of file diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h index 48fa2706a4..eb57f9a849 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h @@ -82,6 +82,7 @@ class CLuaEngineDefs : public CLuaDefs static bool EngineRestreamWorld(); static bool EngineSetModelVisibleTime(std::string strModelId, char cHourOn, char cHourOff); static std::variant> EngineGetModelVisibleTime(std::string strModelId); + static bool EngineIsModelValid(uint uiModelID); static size_t EngineGetPoolCapacity(ePools pool); static size_t EngineGetPoolDefaultCapacity(ePools pool);