aboutsummaryrefslogtreecommitdiff
path: root/engines/director/lingo/lingo.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2016-07-02 12:38:10 +0200
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commitca40ccd9d123d18d9ba5e7b9a504a9fb6ee10355 (patch)
tree816cfcf4489314b7a1e9b4b4d28eb80186e62b41 /engines/director/lingo/lingo.cpp
parent32fb9a33442af5786a207f1b9b053f0ef5cda8ae (diff)
downloadscummvm-rg350-ca40ccd9d123d18d9ba5e7b9a504a9fb6ee10355.tar.gz
scummvm-rg350-ca40ccd9d123d18d9ba5e7b9a504a9fb6ee10355.tar.bz2
scummvm-rg350-ca40ccd9d123d18d9ba5e7b9a504a9fb6ee10355.zip
DIRECTOR: Lingo: Added float constants and automatic type conversion
Diffstat (limited to 'engines/director/lingo/lingo.cpp')
-rw-r--r--engines/director/lingo/lingo.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index d8c3bdfad1..9d23b62cf9 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -162,4 +162,48 @@ void Lingo::processEvent(LEvent event, int entityId) {
debug(2, "processEvent(%s) for %d", _eventHandlerTypes[event], entityId);
}
+int Lingo::alignTypes(Datum &d1, Datum &d2) {
+ int opType = INT;
+
+ if (d1.type == FLOAT || d2.type == FLOAT) {
+ opType = FLOAT;
+ d1.toFloat();
+ d2.toFloat();
+ }
+
+ return opType;
+}
+
+int Datum::toInt() {
+ switch (type) {
+ case INT:
+ // no-op
+ break;
+ case FLOAT:
+ u.i = (int)u.f;
+ type = FLOAT;
+ break;
+ default:
+ warning("Incorrect operation toInt() for type: %d", type);
+ }
+
+ return u.i;
+}
+
+float Datum::toFloat() {
+ switch (type) {
+ case INT:
+ u.f = (float)u.i;
+ type = FLOAT;
+ break;
+ case FLOAT:
+ // no-op
+ break;
+ default:
+ warning("Incorrect operation toFloat() for type: %d", type);
+ }
+
+ return u.f;
+}
+
} // End of namespace Director