Skip to content

Commit

Permalink
GH-794 Fix default value evaluation in ScriptPlaceHolderInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
Naros committed Sep 7, 2024
1 parent 30eea75 commit f53b762
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/common/variant_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,11 @@ namespace VariantUtils
Variant::evaluate(p_operator, p_left, p_right, r_value, valid);
return valid;
}

Variant evaluate(Variant::Operator p_operator, const Variant& p_left, const Variant& p_right)
{
Variant result;
evaluate(p_operator, p_left, p_right, result);
return result;
}
}
7 changes: 7 additions & 0 deletions src/common/variant_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ namespace VariantUtils
/// @param r_value the return value
/// @return true if the evaluation was successful, false otherwise
bool evaluate(Variant::Operator p_operator, const Variant& p_left, const Variant& p_right, Variant& r_value);

/// Evaluates two variants, returning the result.
/// @param p_operator the operation to be performed
/// @param p_left the left operand
/// @param p_right the right operand
/// @return the evaluated result value between the two operands
Variant evaluate(Variant::Operator p_operator, const Variant& p_left, const Variant& p_right);
}

#endif // ORCHESTRATOR_VARIANT_UTILS_H
4 changes: 2 additions & 2 deletions src/script/instances/script_instance_placeholder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ bool OScriptPlaceHolderInstance::set(const StringName& p_name, const Variant& p_
Variant def_value = _script->get_property_default_value(p_name);

Variant result;
if (VariantUtils::evaluate(Variant::OP_EQUAL, def_value, p_value, result))
if (VariantUtils::evaluate(Variant::OP_EQUAL, def_value, p_value))
{
_values.erase(p_name);
return true;
Expand All @@ -128,7 +128,7 @@ bool OScriptPlaceHolderInstance::set(const StringName& p_name, const Variant& p_
{
Variant def_value = _script->get_property_default_value(p_name);
Variant result;
if (VariantUtils::evaluate(Variant::OP_NOT_EQUAL, def_value, p_value, result))
if (VariantUtils::evaluate(Variant::OP_NOT_EQUAL, def_value, p_value))
_values[p_name] = p_value;
return true;
}
Expand Down

0 comments on commit f53b762

Please sign in to comment.