Skip to content

Commit

Permalink
[rend2] Fix ghoul2 related crash, when other model type was loaded in…
Browse files Browse the repository at this point in the history
…stead
  • Loading branch information
SomaZ committed Mar 18, 2024
1 parent 4e70447 commit 2846ba0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions code/rd-rend2/G2_API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2391,10 +2391,11 @@ qboolean G2_TestModelPointers(CGhoul2Info *ghlInfo) // returns true if the model
{
ghlInfo->mModel = RE_RegisterModel(ghlInfo->mFileName);
ghlInfo->currentModel = R_GetModelByHandle(ghlInfo->mModel);
if (ghlInfo->currentModel)
if (ghlInfo->currentModel &&
ghlInfo->currentModel->type == MOD_MDXM) //Rend2 - data is a union now, so we need to make sure it's also a glm that is loaded
{
//Rend2 - Not sure why, but we need MOD_MDXM here to stop ghoul2 crashes.
if (ghlInfo->currentModel->type == MOD_MDXM && ghlInfo->currentModel->data.glm && ghlInfo->currentModel->data.glm->header)
if (ghlInfo->currentModel->data.glm &&
ghlInfo->currentModel->data.glm->header)
{
mdxmHeader_t *mdxm = ghlInfo->currentModel->data.glm->header;
if (ghlInfo->currentModelSize)
Expand Down
3 changes: 2 additions & 1 deletion codemp/rd-rend2/G2_API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2988,7 +2988,8 @@ qboolean G2_TestModelPointers(CGhoul2Info *ghlInfo) // returns true if the model
ghlInfo->mModel = RE_RegisterModel(ghlInfo->mFileName);
}
ghlInfo->currentModel = R_GetModelByHandle(ghlInfo->mModel);
if (ghlInfo->currentModel)
if (ghlInfo->currentModel &&
ghlInfo->currentModel->type == MOD_MDXM) //Rend2 - data is a union now, so we need to make sure it's also a glm that is loaded
{
if (ghlInfo->currentModel->data.glm &&
ghlInfo->currentModel->data.glm->header)
Expand Down

0 comments on commit 2846ba0

Please sign in to comment.