From e388a4bbad67da4e72ae8a91f711a0b2a7c4aca4 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Fri, 8 Aug 2014 22:17:39 -0400 Subject: [PATCH] better float detection in old console --- src/lua/TPTScriptInterface.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/lua/TPTScriptInterface.cpp b/src/lua/TPTScriptInterface.cpp index 0da0617bc..af983acdc 100644 --- a/src/lua/TPTScriptInterface.cpp +++ b/src/lua/TPTScriptInterface.cpp @@ -86,8 +86,8 @@ ValueType TPTScriptInterface::testType(std::string word) { if (!(rawWord[i] >= '0' && rawWord[i] <= '9') && !(rawWord[i] == '-' && !i)) { - if (rawWord[i] == '.' && i) - return TypeFloat; + if (rawWord[i] == '.' && rawWord[i+1]) + goto parseFloat; else if (rawWord[i] == ',' && rawWord[i+1] >= '0' && rawWord[i+1] <= '9') goto parsePoint; else if ((rawWord[i] == '#' || rawWord[i] == 'x') && @@ -99,17 +99,23 @@ ValueType TPTScriptInterface::testType(std::string word) 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: - i++; - for (; i < word.length(); i++) + 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 TypeNumber; parsePoint: - i++; - for (; i < word.length(); i++) + for (i++; i < word.length(); i++) if(!(rawWord[i] >= '0' && rawWord[i] <= '9')) { goto parseString;