From 2846ba00c76c7ae8eea75e444ce1c69deeff3096 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:42:26 +0100 Subject: [PATCH] [rend2] Fix ghoul2 related crash, when other model type was loaded instead --- code/rd-rend2/G2_API.cpp | 7 ++++--- codemp/rd-rend2/G2_API.cpp | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/code/rd-rend2/G2_API.cpp b/code/rd-rend2/G2_API.cpp index 9f4d7bd3fa..babe6f0534 100644 --- a/code/rd-rend2/G2_API.cpp +++ b/code/rd-rend2/G2_API.cpp @@ -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) diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index aa152699c8..b54fc4fa80 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -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)