From f35cb961f2beb1bcfb3e8e3b9e96011ae5d1df13 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 8 Dec 2017 02:00:42 +0100 Subject: WAGE: Avoid calling method of nullptr --- engines/wage/entities.h | 2 +- engines/wage/script.cpp | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/wage/entities.h b/engines/wage/entities.h index 0b5f96d37a..4f08cbb0c3 100644 --- a/engines/wage/entities.h +++ b/engines/wage/entities.h @@ -125,7 +125,7 @@ public: void setDesignBounds(Common::Rect *bounds); - Common::String toString() { return _name; } + Common::String toString() const { return _name; } }; class Chr : public Designed { diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp index 9f8093c50c..de0b6bdb0e 100644 --- a/engines/wage/script.cpp +++ b/engines/wage/script.cpp @@ -56,6 +56,13 @@ namespace Wage { +static Common::String toString(const Designed *d) { + if (!d) + return ""; + else + return d->toString(); +} + Common::String Script::Operand::toString() { switch(_type) { case NUMBER: @@ -64,13 +71,13 @@ Common::String Script::Operand::toString() { case TEXT_INPUT: return *_value.string; case OBJ: - return _value.obj->toString(); + return Wage::toString(_value.obj); case CHR: - return _value.chr->toString(); + return Wage::toString(_value.chr); case SCENE: - return _value.scene->toString(); + return Wage::toString(_value.scene); case CLICK_INPUT: - return _value.inputClick->toString(); + return Wage::toString(_value.inputClick); default: error("Unhandled operand type: _type"); } -- cgit v1.2.3