forked from Mirrors/openclonk
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.floating-point
parent
99638db4c9
commit
05ef63bf64
|
@ -504,19 +504,13 @@ bool C4Value::operator == (const C4Value& Value2) const
|
||||||
{
|
{
|
||||||
switch (Type)
|
switch (Type)
|
||||||
{
|
{
|
||||||
case C4V_Any:
|
case C4V_Nil:
|
||||||
assert(!Data);
|
assert(!Data);
|
||||||
return Value2.Type == Type;
|
return Value2.Type == Type;
|
||||||
case C4V_Int:
|
case C4V_Int:
|
||||||
case C4V_Bool:
|
case C4V_Bool:
|
||||||
switch (Value2.Type)
|
return (Value2.Type == C4V_Int || Value2.Type == C4V_Bool) &&
|
||||||
{
|
Data == Value2.Data;
|
||||||
case C4V_Int:
|
|
||||||
case C4V_Bool:
|
|
||||||
return Data == Value2.Data;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case C4V_PropList:
|
case C4V_PropList:
|
||||||
if (Value2.Type == 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;
|
if (!Data.PropList->IsFrozen() || !Value2.Data.PropList->IsFrozen()) return false;
|
||||||
return (*Data.PropList == *Value2.Data.PropList);
|
return (*Data.PropList == *Value2.Data.PropList);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
case C4V_String:
|
case C4V_String:
|
||||||
return Type == Value2.Type && Data.Str == Value2.Data.Str;
|
return Type == Value2.Type && Data.Str == Value2.Data.Str;
|
||||||
case C4V_Array:
|
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:
|
default:
|
||||||
|
assert(!"Unexpected C4Value type (denumeration missing?)");
|
||||||
return Data == Value2.Data;
|
return Data == Value2.Data;
|
||||||
}
|
}
|
||||||
return GetData() == Value2.GetData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool C4Value::operator != (const C4Value& Value2) const
|
bool C4Value::operator != (const C4Value& Value2) const
|
||||||
|
|
Loading…
Reference in New Issue