Check 'bpp' parameter to vidmode OSD command in EDuke32.

So that the game won't exit if you write 'vidmode 4' when intending
'setrendermode 4'.

git-svn-id: https://svn.eduke32.com/eduke32@2311 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-02-04 14:30:17 +00:00
parent e59e7f0f3c
commit 7b09accdce
2 changed files with 16 additions and 7 deletions

View file

@ -258,14 +258,15 @@ static int32_t osdcmd_vidmode(const osdfuncparm_t *parm)
#ifdef USE_OPENGL #ifdef USE_OPENGL
case 1: // bpp switch case 1: // bpp switch
tmp = Batol(parm->parms[0]); tmp = Batol(parm->parms[0]);
if (tmp==8 || tmp==16 || tmp==32) if (!(tmp==8 || tmp==16 || tmp==32))
return OSDCMD_SHOWHELP;
newbpp = tmp; newbpp = tmp;
break;
case 4: // fs, res, bpp switch case 4: // fs, res, bpp switch
newfullscreen = (Batol(parm->parms[3]) != 0); newfullscreen = (Batol(parm->parms[3]) != 0);
case 3: // res & bpp switch case 3: // res & bpp switch
tmp = Batol(parm->parms[2]); tmp = Batol(parm->parms[2]);
if (tmp==8 || tmp==16 || tmp==32) if (!(tmp==8 || tmp==16 || tmp==32))
return OSDCMD_SHOWHELP;
newbpp = tmp; newbpp = tmp;
#endif #endif
case 2: // res switch case 2: // res switch

View file

@ -371,12 +371,17 @@ static int32_t osdcmd_vidmode(const osdfuncparm_t *parm)
{ {
int32_t newbpp = ud.config.ScreenBPP, newwidth = ud.config.ScreenWidth, int32_t newbpp = ud.config.ScreenBPP, newwidth = ud.config.ScreenWidth,
newheight = ud.config.ScreenHeight, newfs = ud.config.ScreenMode; newheight = ud.config.ScreenHeight, newfs = ud.config.ScreenMode;
int32_t tmp;
if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP; if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP;
switch (parm->numparms) switch (parm->numparms)
{ {
case 1: // bpp switch case 1: // bpp switch
newbpp = Batol(parm->parms[0]); tmp = Batol(parm->parms[0]);
if (!(tmp==8 || tmp==16 || tmp==32))
return OSDCMD_SHOWHELP;
newbpp = tmp;
break; break;
case 2: // res switch case 2: // res switch
newwidth = Batol(parm->parms[0]); newwidth = Batol(parm->parms[0]);
@ -386,7 +391,10 @@ static int32_t osdcmd_vidmode(const osdfuncparm_t *parm)
case 4: case 4:
newwidth = Batol(parm->parms[0]); newwidth = Batol(parm->parms[0]);
newheight = Batol(parm->parms[1]); newheight = Batol(parm->parms[1]);
newbpp = Batol(parm->parms[2]); tmp = Batol(parm->parms[2]);
if (!(tmp==8 || tmp==16 || tmp==32))
return OSDCMD_SHOWHELP;
newbpp = tmp;
if (parm->numparms == 4) if (parm->numparms == 4)
newfs = (Batol(parm->parms[3]) != 0); newfs = (Batol(parm->parms[3]) != 0);
break; break;