From c6c39d557850157d94e8e42d3f79391640264689 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 8 Dec 2017 12:33:40 +0100 Subject: WAGE: Handle null strings in toString and improve consistency --- engines/wage/script.cpp | 17 ++++++++++++++--- engines/wage/script.h | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'engines/wage') 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 ""; + 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 { -- cgit v1.2.3