mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- added bounds checker for all calls to vid_scalemode code - apparently it was possible to start gzdoom with vid_scalemode==8 from previous valid values and cause it to crash.
This commit is contained in:
parent
b8e35e0995
commit
ffa11dec54
1 changed files with 13 additions and 5 deletions
|
@ -46,6 +46,10 @@ namespace
|
|||
{ true, false, [](uint32_t Width)->uint32_t { return 640; }, [](uint32_t Height)->uint32_t { return 400; }, true }, // 3 - 640x400
|
||||
{ true, true, [](uint32_t Width)->uint32_t { return 1280; }, [](uint32_t Height)->uint32_t { return 800; }, true }, // 4 - 1280x800
|
||||
};
|
||||
bool isOutOfBounds(int x)
|
||||
{
|
||||
return (x < 0 || x >= NUMSCALEMODES || vScaleTable[x].isValid == false);
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Float, vid_scalefactor, 1.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
@ -56,31 +60,35 @@ CUSTOM_CVAR(Float, vid_scalefactor, 1.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
|||
|
||||
CUSTOM_CVAR(Int, vid_scalemode, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0 || self >= NUMSCALEMODES || vScaleTable[self].isValid == false)
|
||||
{
|
||||
if (isOutOfBounds(self))
|
||||
self = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewportLinearScale()
|
||||
{
|
||||
if (isOutOfBounds(vid_scalemode))
|
||||
vid_scalemode = 0;
|
||||
// vid_scalefactor > 1 == forced linear scale
|
||||
return (vid_scalefactor > 1.0) ? true : vScaleTable[vid_scalemode].isLinear;
|
||||
}
|
||||
|
||||
int ViewportScaledWidth(int width)
|
||||
{
|
||||
if (isOutOfBounds(vid_scalemode))
|
||||
vid_scalemode = 0;
|
||||
return vScaleTable[vid_scalemode].GetScaledWidth((int)((float)width * vid_scalefactor));
|
||||
}
|
||||
|
||||
int ViewportScaledHeight(int height)
|
||||
{
|
||||
if (isOutOfBounds(vid_scalemode))
|
||||
vid_scalemode = 0;
|
||||
return vScaleTable[vid_scalemode].GetScaledHeight((int)((float)height * vid_scalefactor));
|
||||
}
|
||||
|
||||
bool ViewportIsScaled43()
|
||||
{
|
||||
if (isOutOfBounds(vid_scalemode))
|
||||
vid_scalemode = 0;
|
||||
return vScaleTable[vid_scalemode].isScaled43;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue