(Hopefully) fix crashes in MP if r_aspectRatio = -1, fix #70

While I couldn't reproduce the crash, according to the bugreport it
happens if renderSystem->GetScreenWidth()/Height() returned 0 - and
that is indeed the only plausible reason I can imagine for it.

So I check for that case and handle it gracefully by defaulting to
4:3 FOV values.
This commit is contained in:
Daniel Gibson 2015-09-27 04:16:47 +02:00
parent ff09de0aaa
commit 5e13e6f36f
2 changed files with 16 additions and 2 deletions

View file

@ -2653,7 +2653,7 @@ void idGameLocal::CalcFov( float base_fov, float &fov_x, float &fov_y ) const {
// FIXME: somehow, this is happening occasionally
assert( fov_y > 0 );
if ( fov_y <= 0 ) {
Error( "idGameLocal::CalcFov: bad result" );
Error( "idGameLocal::CalcFov: bad result, fov_y == %f, base_fov == ", fov_y, base_fov );
}
switch( r_aspectRatio.GetInteger() ) {
@ -2662,6 +2662,13 @@ void idGameLocal::CalcFov( float base_fov, float &fov_x, float &fov_y ) const {
// auto mode => use aspect ratio from resolution, assuming screen's pixels are squares
ratio_x = renderSystem->GetScreenWidth();
ratio_y = renderSystem->GetScreenHeight();
if(ratio_x <= 0.0f || ratio_y <= 0.0f)
{
// for some reason (maybe this is a dedicated server?) GetScreenWidth()/Height()
// returned 0. Assume default 4:3 to avoid assert()/Error() below.
fov_x = base_fov;
return;
}
break;
case 0 :
// 4:3

View file

@ -2387,7 +2387,7 @@ void idGameLocal::CalcFov( float base_fov, float &fov_x, float &fov_y ) const {
// FIXME: somehow, this is happening occasionally
assert( fov_y > 0 );
if ( fov_y <= 0 ) {
Error( "idGameLocal::CalcFov: bad result" );
Error( "idGameLocal::CalcFov: bad result, fov_y == %f, base_fov == ", fov_y, base_fov );
}
switch( r_aspectRatio.GetInteger() ) {
@ -2396,6 +2396,13 @@ void idGameLocal::CalcFov( float base_fov, float &fov_x, float &fov_y ) const {
// auto mode => use aspect ratio from resolution, assuming screen's pixels are squares
ratio_x = renderSystem->GetScreenWidth();
ratio_y = renderSystem->GetScreenHeight();
if(ratio_x <= 0.0f || ratio_y <= 0.0f)
{
// for some reason (maybe this is a dedicated server?) GetScreenWidth()/Height()
// returned 0. Assume default 4:3 to avoid assert()/Error() below.
fov_x = base_fov;
return;
}
break;
case 0 :
// 4:3