mirror of
https://github.com/dhewm/dhewm3-sdk.git
synced 2024-11-21 12:11:07 +00:00
(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:
parent
ff09de0aaa
commit
5e13e6f36f
2 changed files with 16 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue