From 05ef63bf64885e94d0abe6b52fb4180c6cbaeed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Brammer?= Date: Wed, 11 Apr 2012 02:25:24 +0200 Subject: [PATCH] Script: Make 0==nil false again This was probably broken by the C4V_Any/C4V_Nil separation. Also clean the function up a bit and add an assert that should catch similar stuff in the future. --- src/script/C4Value.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/script/C4Value.cpp b/src/script/C4Value.cpp index c344640a0..e633efe02 100644 --- a/src/script/C4Value.cpp +++ b/src/script/C4Value.cpp @@ -504,19 +504,13 @@ bool C4Value::operator == (const C4Value& Value2) const { switch (Type) { - case C4V_Any: + case C4V_Nil: assert(!Data); return Value2.Type == Type; case C4V_Int: case C4V_Bool: - switch (Value2.Type) - { - case C4V_Int: - case C4V_Bool: - return Data == Value2.Data; - default: - return false; - } + return (Value2.Type == C4V_Int || Value2.Type == C4V_Bool) && + Data == Value2.Data; case C4V_PropList: if (Value2.Type == C4V_PropList) { @@ -527,14 +521,16 @@ bool C4Value::operator == (const C4Value& Value2) const if (!Data.PropList->IsFrozen() || !Value2.Data.PropList->IsFrozen()) return false; return (*Data.PropList == *Value2.Data.PropList); } + return false; case C4V_String: return Type == Value2.Type && Data.Str == Value2.Data.Str; case C4V_Array: - return Type == Value2.Type && *(Data.Array) == *(Value2.Data.Array); + return Type == Value2.Type && + (Data.Array == Value2.Data.Array || *(Data.Array) == *(Value2.Data.Array)); default: + assert(!"Unexpected C4Value type (denumeration missing?)"); return Data == Value2.Data; } - return GetData() == Value2.GetData(); } bool C4Value::operator != (const C4Value& Value2) const