Skip to content

Commit

Permalink
engine: fix bsp21 loading
Browse files Browse the repository at this point in the history
  • Loading branch information
nillerusr committed Apr 4, 2023
1 parent d56e855 commit f1de24b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions engine/modelloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions engine/staticpropmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -1342,12 +1342,13 @@ void CStaticPropMgr::UnserializeModels( CUtlBuffer& buf )
case 9: UnserializeLump<StaticPropLumpV9_t>(&lump, buf); break;
case 10:
{
if( s_MapHeader.version == 21 )
if( s_MapVersion == 21 )
UnserializeLump<StaticPropLumpV10_21_t>(&lump, buf);
else
UnserializeLump<StaticPropLumpV10_t>(&lump, buf);
break;
}
case 11: UnserializeLump<StaticPropLumpV11_t>(&lump, buf);
default:
Assert("Unexpected version while deserializing lumps.");
}
Expand Down
6 changes: 6 additions & 0 deletions public/gamebspfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const StaticPropLumpV10_21_t&>(_rhs);
return *this;
}
};

struct StaticPropLeafLump_t
Expand Down

0 comments on commit f1de24b

Please sign in to comment.