garrysmod-issues icon indicating copy to clipboard operation
garrysmod-issues copied to clipboard

mat_stub 1 crashes the game

Open Kefta opened this issue 6 years ago • 1 comments

I do not know the exact cause of the crash, but I did notice that the stub system is optional: https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/game/client/cdll_client_int.cpp#L729

This code needs to check the validity properly: https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/game/client/cdll_client_int.cpp#L729

Like this:

CMatStubHandler::CMatStubHandler()
{
	if ( mat_stub.GetInt() )
	{
		IMaterialSystemStub* pStub = GetStubMaterialSystem();

		if ( pStub != NULL )
		{
			m_pOldMaterialSystem = materials;

			// Replace all material system pointers with the stub.
			pStub->SetRealMaterialSystem( materials );
			materials->SetInStubMode( true );
			materials = pStub;
			engine->Mat_Stub( materials );
		}
		else
		{
			m_pOldMaterialSystem = 0;
		}
	}
	else
	{
		m_pOldMaterialSystem = 0;
	}
}

That's most likely not the cause of the crash though. Credit to @hellokittyhoodie for finding.

Kefta avatar Jun 21 '19 17:06 Kefta

I wouldn't consider this a big deal, it's a cheat only cvar that doesn't save. (And yes, that isn't the cause of the crash)

robotboy655 avatar Jun 21 '19 17:06 robotboy655

This was apparently already fixed, but I will also be removing the convar entirely, no purpose for it to exist as far as I can see.

robotboy655 avatar Mar 25 '24 22:03 robotboy655