diff --git a/src/space/space.cpp b/src/space/space.cpp index 5ad6dba..48a42bb 100644 --- a/src/space/space.cpp +++ b/src/space/space.cpp @@ -827,8 +827,31 @@ bool Space::to_bool() const if( type == type_bool ) return value.value_bool; - long long val = to_long_long(); - return (val != 0) ? true : false; + if( type == type_long ) + return value.value_long != 0; + + if( type == type_float ) + return value.value_float != 0.0f; + + if( type == type_double ) + return value.value_double != 0.0; + + if( type == type_long_double ) + return value.value_long_double != 0.0L; + + if( type == type_string ) + return !value.value_string.empty(); + + if( type == type_wstring ) + return !value.value_wstring.empty(); + + if( type == type_table ) + return !value.value_table.empty(); + + if( type == type_object ) + return !value.value_object.empty(); + + return false; } short Space::to_short() const