From 856547be238fded2396eaf82e7c7d9502836bb22 Mon Sep 17 00:00:00 2001 From: Garux Date: Mon, 5 Apr 2021 17:06:49 +0300 Subject: [PATCH] Fix Q1 MDL group frame loading, e.g. Q1 progs/flame2.mdl --- code/AssetLib/MDL/MDLFileData.h | 4 +++- code/AssetLib/MDL/MDLLoader.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/MDL/MDLFileData.h b/code/AssetLib/MDL/MDLFileData.h index bbb6f7728..872cee7f8 100644 --- a/code/AssetLib/MDL/MDLFileData.h +++ b/code/AssetLib/MDL/MDLFileData.h @@ -696,6 +696,8 @@ struct GroupFrame //! 0 = simple frame, !0 = group frame int32_t type; + int32_t numframes; + //! Minimum vertex for all single frames Vertex min; @@ -703,7 +705,7 @@ struct GroupFrame Vertex max; //! Time for all single frames - float *time; + float time; // float[numframes] //! List of single frames SimpleFrame *frames; diff --git a/code/AssetLib/MDL/MDLLoader.cpp b/code/AssetLib/MDL/MDLLoader.cpp index a4286a716..b5010a37f 100644 --- a/code/AssetLib/MDL/MDLLoader.cpp +++ b/code/AssetLib/MDL/MDLLoader.cpp @@ -428,7 +428,7 @@ void MDLImporter::InternReadFile_Quake1() { } else { // get the first frame in the group BE_NCONST MDL::GroupFrame *pcFrames2 = (BE_NCONST MDL::GroupFrame *)pcFrames; - pcFirstFrame = &(pcFrames2->frames[0]); + pcFirstFrame = (MDL::SimpleFrame *)( &pcFrames2->time + pcFrames2->numframes ); } BE_NCONST MDL::Vertex *pcVertices = (BE_NCONST MDL::Vertex *)((pcFirstFrame->name) + sizeof(pcFirstFrame->name)); VALIDATE_FILE_SIZE((const unsigned char *)(pcVertices + pcHeader->num_verts));