diff options
author | Eugene Sandulenko | 2016-07-09 13:16:48 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | a8498f41a0c890870e053024abac0506152729a7 (patch) | |
tree | 25e9685ad848fda3ba6986762023d161b85affb8 /engines/director | |
parent | 82f78708e78254a6a5c80e1265724b75594e2389 (diff) | |
download | scummvm-rg350-a8498f41a0c890870e053024abac0506152729a7.tar.gz scummvm-rg350-a8498f41a0c890870e053024abac0506152729a7.tar.bz2 scummvm-rg350-a8498f41a0c890870e053024abac0506152729a7.zip |
DIRECTOR: Lingo: Made & and && work with any type
Diffstat (limited to 'engines/director')
-rw-r--r-- | engines/director/lingo/lingo-code.cpp | 10 | ||||
-rw-r--r-- | engines/director/lingo/lingo.cpp | 22 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 1 |
3 files changed, 27 insertions, 6 deletions
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index b2b96ade66..a576f1c91d 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -286,9 +286,8 @@ void Lingo::c_ampersand() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); - if (d1.type != STRING || d2.type != STRING) { - error("Wrong operands for & operation: %d %d", d1.type, d2.type); - } + d1.toString(); + d2.toString(); *d1.u.s += *d2.u.s; @@ -301,9 +300,8 @@ void Lingo::c_concat() { Datum d2 = g_lingo->pop(); Datum d1 = g_lingo->pop(); - if (d1.type != STRING || d2.type != STRING) { - error("Wrong operands for & operation: %d %d", d1.type, d2.type); - } + d1.toString(); + d2.toString(); *d1.u.s += " "; *d1.u.s += *d2.u.s; diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index b24c55b57d..fec6b645ea 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -210,4 +210,26 @@ float Datum::toFloat() { return u.f; } +Common::String *Datum::toString() { + Common::String *s = new Common::String; + switch (type) { + case INT: + s->format("%d", u.i); + break; + case FLOAT: + s->format("%f", u.f); + break; + case STRING: + delete s; + s = u.s; + default: + warning("Incorrect operation toInt() for type: %d", type); + } + + u.s = s; + type = STRING; + + return u.s; +} + } // End of namespace Director diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 449b0556ff..c88efabe31 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -106,6 +106,7 @@ struct Datum { /* interpreter stack type */ float toFloat(); int toInt(); + Common::String *toString(); }; struct Builtin { |