diff options
| author | jacob1 <jfu614@gmail.com> | 2013-09-27 21:41:46 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-09-27 21:41:46 (GMT) |
| commit | c480c9ea19ba5757830d0bb2274ca6b142ef4b4b (patch) | |
| tree | fb623d99a5315642f59bdab6c38d1b28e4c47d43 | |
| parent | 48f1adb0385c313f3ce1a4c183c16be3bb7b27cb (diff) | |
| parent | ceca61114a946506a3596c0ea1c0d55723d10ce1 (diff) | |
| download | powder-c480c9ea19ba5757830d0bb2274ca6b142ef4b4b.zip powder-c480c9ea19ba5757830d0bb2274ca6b142ef4b4b.tar.gz | |
Merge branch 'HEAD' of https://github.com/FacialTurd/The-Powder-Toy.git
| -rw-r--r-- | src/cat/TPTSTypes.cpp | 18 | ||||
| -rw-r--r-- | src/cat/TPTScriptInterface.cpp | 2 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/cat/TPTSTypes.cpp b/src/cat/TPTSTypes.cpp index 87d1097..0a3e940 100644 --- a/src/cat/TPTSTypes.cpp +++ b/src/cat/TPTSTypes.cpp @@ -48,6 +48,13 @@ AnyType::operator StringType() { return StringType(*((std::string*)value)); } + else if (type == TypePoint && value) + { + ui::Point thisPoint = *((ui::Point*)value); + std::stringstream pointStream; + pointStream << thisPoint.X << "," << thisPoint.Y; + return StringType(pointStream.str()); + } else throw InvalidConversionException(type, TypeString); @@ -61,10 +68,13 @@ AnyType::operator PointType() } else if(type == TypeString) { - ui::Point thisPoint = *((ui::Point*)value); - std::stringstream pointStream; - pointStream << thisPoint.X << "," << thisPoint.Y; - return StringType(pointStream.str()); + std::stringstream pointStream(*((std::string*)value)); + int x, y; + char comma; + pointStream >> x >> comma >> y; + if (pointStream.fail() || comma != ',') + throw InvalidConversionException(type, TypePoint); + return PointType(ui::Point(x, y)); } else throw InvalidConversionException(type, TypePoint); diff --git a/src/cat/TPTScriptInterface.cpp b/src/cat/TPTScriptInterface.cpp index 6519aec..87e0584 100644 --- a/src/cat/TPTScriptInterface.cpp +++ b/src/cat/TPTScriptInterface.cpp @@ -146,7 +146,7 @@ int TPTScriptInterface::parseNumber(char * stringData) } else { - return atoi(stringData); + return atof(stringData); } return currentNumber; } |
