mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 15:22:16 +00:00
- added range checks to UDMF coordinate fields.
This commit is contained in:
parent
e12f48699e
commit
f31fb64750
2 changed files with 24 additions and 9 deletions
|
@ -254,6 +254,20 @@ double UDMFParserBase::CheckFloat(const char *key)
|
||||||
return sc.Float;
|
return sc.Float;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double UDMFParserBase::CheckCoordinate(const char *key)
|
||||||
|
{
|
||||||
|
if (sc.TokenType != TK_IntConst && sc.TokenType != TK_FloatConst)
|
||||||
|
{
|
||||||
|
sc.ScriptMessage("Floating point value expected for key '%s'", key);
|
||||||
|
}
|
||||||
|
if (sc.Float < -32768 || sc.Float > 32768)
|
||||||
|
{
|
||||||
|
sc.ScriptMessage("Value %f out of range for a coordinate '%s'. Valid range is ]-32768 .. 32768]", key);
|
||||||
|
sc.Float = clamp(sc.Float, -32768 + EQUAL_EPSILON*2, 32768 - EQUAL_EPSILON*2);
|
||||||
|
}
|
||||||
|
return sc.Float;
|
||||||
|
}
|
||||||
|
|
||||||
DAngle UDMFParserBase::CheckAngle(const char *key)
|
DAngle UDMFParserBase::CheckAngle(const char *key)
|
||||||
{
|
{
|
||||||
return DAngle(CheckFloat(key)).Normalized360();
|
return DAngle(CheckFloat(key)).Normalized360();
|
||||||
|
@ -532,15 +546,15 @@ public:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NAME_X:
|
case NAME_X:
|
||||||
th->pos.X = CheckFloat(key);
|
th->pos.X = CheckCoordinate(key);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NAME_Y:
|
case NAME_Y:
|
||||||
th->pos.Y = CheckFloat(key);
|
th->pos.Y = CheckCoordinate(key);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NAME_Height:
|
case NAME_Height:
|
||||||
th->pos.Z = CheckFloat(key);
|
th->pos.Z = CheckCoordinate(key);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NAME_Angle:
|
case NAME_Angle:
|
||||||
|
@ -1370,11 +1384,11 @@ public:
|
||||||
switch(key)
|
switch(key)
|
||||||
{
|
{
|
||||||
case NAME_Heightfloor:
|
case NAME_Heightfloor:
|
||||||
sec->SetPlaneTexZ(sector_t::floor, CheckFloat(key));
|
sec->SetPlaneTexZ(sector_t::floor, CheckCoordinate(key));
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case NAME_Heightceiling:
|
case NAME_Heightceiling:
|
||||||
sec->SetPlaneTexZ(sector_t::ceiling, CheckFloat(key));
|
sec->SetPlaneTexZ(sector_t::ceiling, CheckCoordinate(key));
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case NAME_Texturefloor:
|
case NAME_Texturefloor:
|
||||||
|
@ -1815,20 +1829,20 @@ public:
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case NAME_X:
|
case NAME_X:
|
||||||
x = CheckFloat(key);
|
x = CheckCoordinate(key);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NAME_Y:
|
case NAME_Y:
|
||||||
y = CheckFloat(key);
|
y = CheckCoordinate(key);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NAME_ZCeiling:
|
case NAME_ZCeiling:
|
||||||
vd->zCeiling = CheckFloat(key);
|
vd->zCeiling = CheckCoordinate(key);
|
||||||
vd->flags |= VERTEXFLAG_ZCeilingEnabled;
|
vd->flags |= VERTEXFLAG_ZCeilingEnabled;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NAME_ZFloor:
|
case NAME_ZFloor:
|
||||||
vd->zFloor = CheckFloat(key);
|
vd->zFloor = CheckCoordinate(key);
|
||||||
vd->flags |= VERTEXFLAG_ZFloorEnabled;
|
vd->flags |= VERTEXFLAG_ZFloorEnabled;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ protected:
|
||||||
FName ParseKey(bool checkblock = false, bool *isblock = NULL);
|
FName ParseKey(bool checkblock = false, bool *isblock = NULL);
|
||||||
int CheckInt(const char *key);
|
int CheckInt(const char *key);
|
||||||
double CheckFloat(const char *key);
|
double CheckFloat(const char *key);
|
||||||
|
double CheckCoordinate(const char *key);
|
||||||
DAngle CheckAngle(const char *key);
|
DAngle CheckAngle(const char *key);
|
||||||
bool CheckBool(const char *key);
|
bool CheckBool(const char *key);
|
||||||
const char *CheckString(const char *key);
|
const char *CheckString(const char *key);
|
||||||
|
|
Loading…
Reference in a new issue