Skip to content

Commit

Permalink
Fix invalid return from some more _get/_set
Browse files Browse the repository at this point in the history
Invalidly returned `true` on the non-matched path

(cherry picked from commit 3ef6314)
  • Loading branch information
AThousandShips authored and YuriSizov committed Jan 23, 2024
1 parent e33eb36 commit f563f8b
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 45 deletions.
12 changes: 8 additions & 4 deletions scene/2d/skeleton_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ bool Bone2D::_set(const StringName &p_path, const Variant &p_value) {
} else if (path.begins_with("default_length")) {
set_length(p_value);
}

#ifdef TOOLS_ENABLED
if (path.begins_with("editor_settings/show_bone_gizmo")) {
else if (path.begins_with("editor_settings/show_bone_gizmo")) {
_editor_set_show_bone_gizmo(p_value);
}
#endif // TOOLS_ENABLED
else {
return false;
}

return true;
}
Expand All @@ -70,12 +72,14 @@ bool Bone2D::_get(const StringName &p_path, Variant &r_ret) const {
} else if (path.begins_with("default_length")) {
r_ret = get_length();
}

#ifdef TOOLS_ENABLED
if (path.begins_with("editor_settings/show_bone_gizmo")) {
else if (path.begins_with("editor_settings/show_bone_gizmo")) {
r_ret = _editor_get_show_bone_gizmo();
}
#endif // TOOLS_ENABLED
else {
return false;
}

return true;
}
Expand Down
28 changes: 16 additions & 12 deletions scene/resources/skeleton_modification_2d_ccdik.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,23 @@ bool SkeletonModification2DCCDIK::_set(const StringName &p_path, const Variant &
} else if (what == "constraint_in_localspace") {
set_ccdik_joint_constraint_in_localspace(which, p_value);
}

#ifdef TOOLS_ENABLED
if (what.begins_with("editor_draw_gizmo")) {
else if (what.begins_with("editor_draw_gizmo")) {
set_ccdik_joint_editor_draw_gizmo(which, p_value);
}
#endif // TOOLS_ENABLED

return true;
else {
return false;
}
}

#ifdef TOOLS_ENABLED
if (path.begins_with("editor/draw_gizmo")) {
else if (path.begins_with("editor/draw_gizmo")) {
set_editor_draw_gizmo(p_value);
}
#endif // TOOLS_ENABLED
else {
return false;
}

return true;
}
Expand Down Expand Up @@ -104,21 +106,23 @@ bool SkeletonModification2DCCDIK::_get(const StringName &p_path, Variant &r_ret)
} else if (what == "constraint_in_localspace") {
r_ret = get_ccdik_joint_constraint_in_localspace(which);
}

#ifdef TOOLS_ENABLED
if (what.begins_with("editor_draw_gizmo")) {
else if (what.begins_with("editor_draw_gizmo")) {
r_ret = get_ccdik_joint_editor_draw_gizmo(which);
}
#endif // TOOLS_ENABLED

return true;
else {
return false;
}
}

#ifdef TOOLS_ENABLED
if (path.begins_with("editor/draw_gizmo")) {
else if (path.begins_with("editor/draw_gizmo")) {
r_ret = get_editor_draw_gizmo();
}
#endif // TOOLS_ENABLED
else {
return false;
}

return true;
}
Expand Down
9 changes: 8 additions & 1 deletion scene/resources/skeleton_modification_2d_fabrik.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ bool SkeletonModification2DFABRIK::_set(const StringName &p_path, const Variant
set_fabrik_joint_magnet_position(which, p_value);
} else if (what == "use_target_rotation") {
set_fabrik_joint_use_target_rotation(which, p_value);
} else {
return false;
}
} else {
return false;
}

return true;
Expand All @@ -73,8 +77,11 @@ bool SkeletonModification2DFABRIK::_get(const StringName &p_path, Variant &r_ret
r_ret = get_fabrik_joint_magnet_position(which);
} else if (what == "use_target_rotation") {
r_ret = get_fabrik_joint_use_target_rotation(which);
} else {
return false;
}
return true;
} else {
return false;
}
return true;
}
Expand Down
26 changes: 14 additions & 12 deletions scene/resources/skeleton_modification_2d_jiggle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ bool SkeletonModification2DJiggle::_set(const StringName &p_path, const Variant
set_jiggle_joint_use_gravity(which, p_value);
} else if (what == "gravity") {
set_jiggle_joint_gravity(which, p_value);
} else {
return false;
}
return true;
} else if (path == "use_colliders") {
set_use_colliders(p_value);
} else if (path == "collision_mask") {
set_collision_mask(p_value);
} else {
if (path == "use_colliders") {
set_use_colliders(p_value);
} else if (path == "collision_mask") {
set_collision_mask(p_value);
}
return false;
}
return true;
}
Expand Down Expand Up @@ -93,14 +94,15 @@ bool SkeletonModification2DJiggle::_get(const StringName &p_path, Variant &r_ret
r_ret = get_jiggle_joint_use_gravity(which);
} else if (what == "gravity") {
r_ret = get_jiggle_joint_gravity(which);
} else {
return false;
}
return true;
} else if (path == "use_colliders") {
r_ret = get_use_colliders();
} else if (path == "collision_mask") {
r_ret = get_collision_mask();
} else {
if (path == "use_colliders") {
r_ret = get_use_colliders();
} else if (path == "collision_mask") {
r_ret = get_collision_mask();
}
return false;
}
return true;
}
Expand Down
12 changes: 8 additions & 4 deletions scene/resources/skeleton_modification_2d_lookat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ bool SkeletonModification2DLookAt::_set(const StringName &p_path, const Variant
} else if (path.begins_with("additional_rotation")) {
set_additional_rotation(Math::deg_to_rad(float(p_value)));
}

#ifdef TOOLS_ENABLED
if (path.begins_with("editor/draw_gizmo")) {
else if (path.begins_with("editor/draw_gizmo")) {
set_editor_draw_gizmo(p_value);
}
#endif // TOOLS_ENABLED
else {
return false;
}

return true;
}
Expand All @@ -77,12 +79,14 @@ bool SkeletonModification2DLookAt::_get(const StringName &p_path, Variant &r_ret
} else if (path.begins_with("additional_rotation")) {
r_ret = Math::rad_to_deg(get_additional_rotation());
}

#ifdef TOOLS_ENABLED
if (path.begins_with("editor/draw_gizmo")) {
else if (path.begins_with("editor/draw_gizmo")) {
r_ret = get_editor_draw_gizmo();
}
#endif // TOOLS_ENABLED
else {
return false;
}

return true;
}
Expand Down
8 changes: 4 additions & 4 deletions scene/resources/skeleton_modification_2d_physicalbones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ bool SkeletonModification2DPhysicalBones::_set(const StringName &p_path, const V

if (what == "nodepath") {
set_physical_bone_node(which, p_value);
return true;
}
return true;
}
return true;
return false;
}

bool SkeletonModification2DPhysicalBones::_get(const StringName &p_path, Variant &r_ret) const {
Expand All @@ -79,10 +79,10 @@ bool SkeletonModification2DPhysicalBones::_get(const StringName &p_path, Variant

if (what == "nodepath") {
r_ret = get_physical_bone_node(which);
return true;
}
return true;
}
return true;
return false;
}

void SkeletonModification2DPhysicalBones::_get_property_list(List<PropertyInfo> *p_list) const {
Expand Down
12 changes: 8 additions & 4 deletions scene/resources/skeleton_modification_2d_stackholder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ bool SkeletonModification2DStackHolder::_set(const StringName &p_path, const Var
if (path == "held_modification_stack") {
set_held_modification_stack(p_value);
}

#ifdef TOOLS_ENABLED
if (path == "editor/draw_gizmo") {
else if (path == "editor/draw_gizmo") {
set_editor_draw_gizmo(p_value);
}
#endif // TOOLS_ENABLED
else {
return false;
}

return true;
}
Expand All @@ -53,12 +55,14 @@ bool SkeletonModification2DStackHolder::_get(const StringName &p_path, Variant &
if (path == "held_modification_stack") {
r_ret = get_held_modification_stack();
}

#ifdef TOOLS_ENABLED
if (path == "editor/draw_gizmo") {
else if (path == "editor/draw_gizmo") {
r_ret = get_editor_draw_gizmo();
}
#endif // TOOLS_ENABLED
else {
return false;
}

return true;
}
Expand Down
12 changes: 8 additions & 4 deletions scene/resources/skeleton_modification_2d_twoboneik.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ bool SkeletonModification2DTwoBoneIK::_set(const StringName &p_path, const Varia
} else if (path == "joint_two_bone2d_node") {
set_joint_two_bone2d_node(p_value);
}

#ifdef TOOLS_ENABLED
if (path.begins_with("editor/draw_gizmo")) {
else if (path.begins_with("editor/draw_gizmo")) {
set_editor_draw_gizmo(p_value);
} else if (path.begins_with("editor/draw_min_max")) {
set_editor_draw_min_max(p_value);
}
#endif // TOOLS_ENABLED
else {
return false;
}

return true;
}
Expand All @@ -71,14 +73,16 @@ bool SkeletonModification2DTwoBoneIK::_get(const StringName &p_path, Variant &r_
} else if (path == "joint_two_bone2d_node") {
r_ret = get_joint_two_bone2d_node();
}

#ifdef TOOLS_ENABLED
if (path.begins_with("editor/draw_gizmo")) {
else if (path.begins_with("editor/draw_gizmo")) {
r_ret = get_editor_draw_gizmo();
} else if (path.begins_with("editor/draw_min_max")) {
r_ret = get_editor_draw_min_max();
}
#endif // TOOLS_ENABLED
else {
return false;
}

return true;
}
Expand Down

0 comments on commit f563f8b

Please sign in to comment.