mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-13 03:44:05 +02:00
better float detection in old console
This commit is contained in:
@@ -86,8 +86,8 @@ ValueType TPTScriptInterface::testType(std::string word)
|
|||||||
{
|
{
|
||||||
if (!(rawWord[i] >= '0' && rawWord[i] <= '9') && !(rawWord[i] == '-' && !i))
|
if (!(rawWord[i] >= '0' && rawWord[i] <= '9') && !(rawWord[i] == '-' && !i))
|
||||||
{
|
{
|
||||||
if (rawWord[i] == '.' && i)
|
if (rawWord[i] == '.' && rawWord[i+1])
|
||||||
return TypeFloat;
|
goto parseFloat;
|
||||||
else if (rawWord[i] == ',' && rawWord[i+1] >= '0' && rawWord[i+1] <= '9')
|
else if (rawWord[i] == ',' && rawWord[i+1] >= '0' && rawWord[i+1] <= '9')
|
||||||
goto parsePoint;
|
goto parsePoint;
|
||||||
else if ((rawWord[i] == '#' || rawWord[i] == 'x') &&
|
else if ((rawWord[i] == '#' || rawWord[i] == 'x') &&
|
||||||
@@ -99,17 +99,23 @@ ValueType TPTScriptInterface::testType(std::string word)
|
|||||||
goto parseString;
|
goto parseString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return TypeNumber;
|
||||||
|
parseFloat:
|
||||||
|
for (i++; i < word.length(); i++)
|
||||||
|
if(!((rawWord[i] >= '0' && rawWord[i] <= '9') || (rawWord[i] >= 'a' && rawWord[i] <= 'f') || (rawWord[i] >= 'A' && rawWord[i] <= 'F')))
|
||||||
|
{
|
||||||
|
goto parseString;
|
||||||
|
}
|
||||||
|
return TypeFloat;
|
||||||
parseNumberHex:
|
parseNumberHex:
|
||||||
i++;
|
for (i++; i < word.length(); i++)
|
||||||
for (; i < word.length(); i++)
|
|
||||||
if(!((rawWord[i] >= '0' && rawWord[i] <= '9') || (rawWord[i] >= 'a' && rawWord[i] <= 'f') || (rawWord[i] >= 'A' && rawWord[i] <= 'F')))
|
if(!((rawWord[i] >= '0' && rawWord[i] <= '9') || (rawWord[i] >= 'a' && rawWord[i] <= 'f') || (rawWord[i] >= 'A' && rawWord[i] <= 'F')))
|
||||||
{
|
{
|
||||||
goto parseString;
|
goto parseString;
|
||||||
}
|
}
|
||||||
return TypeNumber;
|
return TypeNumber;
|
||||||
parsePoint:
|
parsePoint:
|
||||||
i++;
|
for (i++; i < word.length(); i++)
|
||||||
for (; i < word.length(); i++)
|
|
||||||
if(!(rawWord[i] >= '0' && rawWord[i] <= '9'))
|
if(!(rawWord[i] >= '0' && rawWord[i] <= '9'))
|
||||||
{
|
{
|
||||||
goto parseString;
|
goto parseString;
|
||||||
|
Reference in New Issue
Block a user