diff options
author | Willem Jan Palenstijn | 2017-12-08 12:33:40 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2017-12-08 11:41:32 +0000 |
commit | c6c39d557850157d94e8e42d3f79391640264689 (patch) | |
tree | 426a432e472b6e4190328f134ae257b69a654da1 | |
parent | f35cb961f2beb1bcfb3e8e3b9e96011ae5d1df13 (diff) | |
download | scummvm-rg350-c6c39d557850157d94e8e42d3f79391640264689.tar.gz scummvm-rg350-c6c39d557850157d94e8e42d3f79391640264689.tar.bz2 scummvm-rg350-c6c39d557850157d94e8e42d3f79391640264689.zip |
WAGE: Handle null strings in toString and improve consistency
-rw-r--r-- | engines/wage/script.cpp | 17 | ||||
-rw-r--r-- | engines/wage/script.h | 2 |
2 files changed, 15 insertions, 4 deletions
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp index de0b6bdb0e..7a8ba14ad4 100644 --- a/engines/wage/script.cpp +++ b/engines/wage/script.cpp @@ -63,13 +63,24 @@ static Common::String toString(const Designed *d) { return d->toString(); } -Common::String Script::Operand::toString() { +static Common::String toString(const Common::String *d) { + if (!d) + return "<NULL>"; + else + return *d; +} + +static Common::String toString(int16 val) { + return Common::String::format("%d", val); +} + +Common::String Script::Operand::toString() const { switch(_type) { case NUMBER: - return Common::String::format("%d", _value.number); + return Wage::toString(_value.number); case STRING: case TEXT_INPUT: - return *_value.string; + return Wage::toString(_value.string); case OBJ: return Wage::toString(_value.obj); case CHR: diff --git a/engines/wage/script.h b/engines/wage/script.h index df7ec7e4d6..279e4cfae8 100644 --- a/engines/wage/script.h +++ b/engines/wage/script.h @@ -119,7 +119,7 @@ private: delete _value.string; } - Common::String toString(); + Common::String toString() const; }; struct ScriptText { |