Skip to content

Add engineIsModelValid #4255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ void CLuaEngineDefs::LoadFunctions()
{"engineGetPoolUsedCapacity", ArgumentParser<EngineGetPoolUsedCapacity>},
{"engineSetPoolCapacity", ArgumentParser<EngineSetPoolCapacity>},
{"enginePreloadWorldArea", ArgumentParser<EnginePreloadWorldArea>},
{"engineIsModelValid", ArgumentParser<EngineIsModelValid>}

// CLuaCFunctions::AddFunction ( "engineReplaceMatchingAtomics", EngineReplaceMatchingAtomics );
// CLuaCFunctions::AddFunction ( "engineReplaceWheelAtomics", EngineReplaceWheelAtomics );
Expand Down Expand Up @@ -2593,3 +2594,13 @@ void CLuaEngineDefs::EnginePreloadWorldArea(CVector position, std::optional<Prel
if (option == PreloadAreaOption::ALL || option == PreloadAreaOption::COLLISIONS)
g_pGame->GetStreaming()->LoadSceneCollision(&position);
}

bool CLuaEngineDefs::EngineIsModelValid(uint uiModelId)
{
CModelInfo* pModelInfo = g_pGame->GetModelInfo(uiModelId);

if (uiModelId >= 20000 || !pModelInfo)
return false;

return true;
}
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class CLuaEngineDefs : public CLuaDefs
static bool EngineRestreamWorld();
static bool EngineSetModelVisibleTime(std::string strModelId, char cHourOn, char cHourOff);
static std::variant<bool, CLuaMultiReturn<char, char>> EngineGetModelVisibleTime(std::string strModelId);
static bool EngineIsModelValid(uint uiModelID);

static size_t EngineGetPoolCapacity(ePools pool);
static size_t EngineGetPoolDefaultCapacity(ePools pool);
Expand Down