Fix a bug where cvars of type CVAR_UINT couldn't be set to values larger than a signed int due to clamping by atoi/atol.

git-svn-id: https://svn.eduke32.com/eduke32@5666 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-03-14 00:07:52 +00:00
parent ea0e00a431
commit eeea08cfa6

View file

@ -2097,19 +2097,18 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
}
break;
case CVAR_INT:
case CVAR_UINT:
case CVAR_BOOL:
{
if (showval)
{
OSD_Printf((osd->cvars[i].c.type & CVAR_UINT) ? "\"%s\" is \"%u\"\n%s: %s\n" : "\"%s\" is \"%d\"\n%s: %s\n",osd->cvars[i].c.name,*(int32_t *)osd->cvars[i].c.vptr,osd->cvars[i].c.name,osd->cvars[i].c.desc);
OSD_Printf("\"%s\" is \"%d\"\n%s: %s\n",osd->cvars[i].c.name,*(int32_t *)osd->cvars[i].c.vptr,osd->cvars[i].c.name,osd->cvars[i].c.desc);
return OSDCMD_OK;
}
int32_t val = Batoi(parm->parms[0]);
if (osd->cvars[i].c.type & CVAR_BOOL) val = val != 0;
if (val < osd->cvars[i].c.min || ((osd->cvars[i].c.type & CVAR_UINT) ? ((unsigned) val > (unsigned) osd->cvars[i].c.max) : (val > osd->cvars[i].c.max)))
if (val < osd->cvars[i].c.min || ((val > osd->cvars[i].c.max)))
{
OSD_Printf("%s value out of range\n",osd->cvars[i].c.name);
return OSDCMD_OK;
@ -2119,6 +2118,28 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
OSD_Printf("%s %d",osd->cvars[i].c.name,val);
}
break;
case CVAR_UINT:
{
if (showval)
{
OSD_Printf("\"%s\" is \"%u\"\n%s: %s\n", osd->cvars[i].c.name, *(int32_t *) osd->cvars[i].c.vptr, osd->cvars[i].c.name, osd->cvars[i].c.desc);
return OSDCMD_OK;
}
uint32_t val = Bstrtoul(parm->parms[0], NULL, 0);
if (val < (unsigned)osd->cvars[i].c.min || val > (unsigned)osd->cvars[i].c.max)
{
OSD_Printf("%s value out of range\n", osd->cvars[i].c.name);
return OSDCMD_OK;
}
*(uint32_t *) osd->cvars[i].c.vptr = val;
if (!OSD_ParsingScript())
OSD_Printf("%s %d", osd->cvars[i].c.name, val);
}
break;
case CVAR_STRING:
{
if (showval)