From f1de24b0b21cd22b6aa494af5bc9577ae3f42a5e Mon Sep 17 00:00:00 2001 From: nillerusr Date: Tue, 4 Apr 2023 23:22:06 +0300 Subject: [PATCH] engine: fix bsp21 loading --- engine/modelloader.cpp | 4 ++++ engine/staticpropmgr.cpp | 5 +++-- public/gamebspfile.h | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/engine/modelloader.cpp b/engine/modelloader.cpp index 3070dc55..a51cd110 100644 --- a/engine/modelloader.cpp +++ b/engine/modelloader.cpp @@ -396,6 +396,8 @@ static worldbrushdata_t *s_pMap = NULL; static int s_nMapLoadRecursion = 0; static CUtlBuffer s_MapBuffer; +int s_MapVersion = 0; + // Lump files are patches for a shipped map // List of lump files found when map was loaded. Each entry is the lump file index for that lump id. struct lumpfiles_t @@ -469,6 +471,8 @@ void CMapLoadHelper::Init( model_t *pMapModel, const char *loadname ) return; } + s_MapVersion = s_MapHeader.version; + V_strcpy_safe( s_szLoadName, loadname ); // Store map version, but only do it once so that the communication between the engine and Hammer isn't broken. The map version diff --git a/engine/staticpropmgr.cpp b/engine/staticpropmgr.cpp index fb298443..46a91c0f 100644 --- a/engine/staticpropmgr.cpp +++ b/engine/staticpropmgr.cpp @@ -60,7 +60,7 @@ ConVar r_staticpropinfo( "r_staticpropinfo", "0" ); ConVar r_drawmodeldecals( "r_drawmodeldecals", "1" ); extern ConVar mat_fullbright; static bool g_MakingDevShots = false; -extern dheader_t s_MapHeader; +extern int s_MapVersion; //----------------------------------------------------------------------------- // Index into the fade list //----------------------------------------------------------------------------- @@ -1342,12 +1342,13 @@ void CStaticPropMgr::UnserializeModels( CUtlBuffer& buf ) case 9: UnserializeLump(&lump, buf); break; case 10: { - if( s_MapHeader.version == 21 ) + if( s_MapVersion == 21 ) UnserializeLump(&lump, buf); else UnserializeLump(&lump, buf); break; } + case 11: UnserializeLump(&lump, buf); default: Assert("Unexpected version while deserializing lumps."); } diff --git a/public/gamebspfile.h b/public/gamebspfile.h index 151d160e..597dda03 100644 --- a/public/gamebspfile.h +++ b/public/gamebspfile.h @@ -443,6 +443,12 @@ struct StaticPropLump_t m_FlagsEx = _rhs.m_FlagsEx; return *this; } + + inline StaticPropLump_t& operator=(const StaticPropLumpV11_t& _rhs) + { + (*this) = reinterpret_cast(_rhs); + return *this; + } }; struct StaticPropLeafLump_t