-
-
Notifications
You must be signed in to change notification settings - Fork 472
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
base: master
Are you sure you want to change the base?
Add engineIsModelValid #4255
Conversation
What about CJ models (do we even need to do a check if Also I'm not that good with C but wouldn't it make more sense to first check if the ID is larger than 20k and then try to get the model info? Anyways I could use this function yes, maybe for a hard clean of all models or something similar. |
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint -> std::uint32_t
|
||
bool CLuaEngineDefs::EngineIsModelValid(uint uiModelId) | ||
{ | ||
CModelInfo* pModelInfo = g_pGame->GetModelInfo(uiModelId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CModelInfo* modelInfo = g_pGame->GetModelInfo(modelId);
if (uiModelId >= 20000 || !pModelInfo) | ||
return false; | ||
|
||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (modelId < 20000 && modelInfo);
This PR adds a new utility function engineIsModelValid.
Some scripts may need to check whether a model ID corresponds to a valid and loaded model. This function provides a simple way to verify if a model is within valid bounds and has a valid model info entry.
It checks whether the model ID is above the base DFF limit and ensures that the corresponding model info exists and is valid.