engine: server: enable sv_zmax clamping back to avoid overflowing zmax value encoded in delta

This commit is contained in:
Alibek Omarov 2025-02-08 16:38:11 +03:00
parent b5cb0b9f10
commit eb51d17cd2

View file

@ -189,24 +189,15 @@ void SV_UpdateMovevars( qboolean initialize )
if( !initialize && !host.movevars_changed ) if( !initialize && !host.movevars_changed )
return; return;
// NOTE: this breaks Natural Selection mod on ns_machina map that uses model as sky // NOTE: Natural Selection mod on ns_machina map that uses model as sky
// it sets the value to 4000000 that even exceeds the coord limit // it sets the value to 4000000 that even exceeds the coord limit, but
#if 0 // it's fine until the value fits in "zmax" delta field
// check range // However, some stupid mappers set an insane value like 999999999 which
if( sv_zmax.value < 256.0f ) Cvar_SetValue( "sv_zmax", 256.0f ); // overflows delta. In this case, just clamp it to something bigger
if( sv_zmax.value < 256.0f )
// clamp it right Cvar_DirectSet( &sv_zmax, "256" );
if( FBitSet( host.features, ENGINE_WRITE_LARGE_COORD )) else if( sv_zmax.value > 16777216.0f ) // 2^24
{ Cvar_DirectSet( &sv_zmax, "16777216" );
if( sv_zmax.value > 131070.0f )
Cvar_SetValue( "sv_zmax", 131070.0f );
}
else
{
if( sv_zmax.value > 32767.0f )
Cvar_SetValue( "sv_zmax", 32767.0f );
}
#endif
svgame.movevars.gravity = sv_gravity.value; svgame.movevars.gravity = sv_gravity.value;
svgame.movevars.stopspeed = sv_stopspeed.value; svgame.movevars.stopspeed = sv_stopspeed.value;