summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/io/resource_format_binary.cpp2
-rw-r--r--core/typedefs.h4
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp21
-rw-r--r--main/input_default.cpp6
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp14
-rw-r--r--modules/theora/video_stream_theora.cpp4
-rw-r--r--modules/visual_script/visual_script_property_selector.cpp11
-rw-r--r--scene/gui/rich_text_label.cpp4
-rw-r--r--scene/gui/scroll_container.cpp3
-rw-r--r--scene/gui/tree.cpp2
10 files changed, 34 insertions, 37 deletions
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 02c2c6ce1a..e5741014a4 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -1718,7 +1718,7 @@ void ResourceFormatSaverBinaryInstance::save_unicode_string(FileAccess *f, const
CharString utf8 = p_string.utf8();
if (p_bit_on_len) {
- f->store_32(utf8.length() + 1 | 0x80000000);
+ f->store_32((utf8.length() + 1) | 0x80000000);
} else {
f->store_32(utf8.length() + 1);
}
diff --git a/core/typedefs.h b/core/typedefs.h
index 76778429b0..2b26bf08f7 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -105,11 +105,11 @@ T *_nullptr() {
/** Generic ABS function, for math uses please use Math::abs */
#ifndef ABS
-#define ABS(m_v) ((m_v < 0) ? (-(m_v)) : (m_v))
+#define ABS(m_v) (((m_v) < 0) ? (-(m_v)) : (m_v))
#endif
#ifndef SGN
-#define SGN(m_v) ((m_v < 0) ? (-1.0) : (+1.0))
+#define SGN(m_v) (((m_v) < 0) ? (-1.0) : (+1.0))
#endif
#ifndef MIN
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 3e6a0ae81a..54e187e7bb 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -2199,7 +2199,7 @@ void SpatialEditorViewport::_notification(int p_what) {
bool shrink = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION));
- if (shrink != viewport_container->get_stretch_shrink() > 1) {
+ if (shrink != (viewport_container->get_stretch_shrink() > 1)) {
viewport_container->set_stretch_shrink(shrink ? 2 : 1);
}
@@ -4979,32 +4979,29 @@ void SpatialEditor::_unhandled_key_input(Ref<InputEvent> p_event) {
if (!k->is_pressed())
return;
- if (ED_IS_SHORTCUT("spatial_editor/tool_select", p_event))
+ if (ED_IS_SHORTCUT("spatial_editor/tool_select", p_event)) {
_menu_item_pressed(MENU_TOOL_SELECT);
-
- else if (ED_IS_SHORTCUT("spatial_editor/tool_move", p_event))
+ } else if (ED_IS_SHORTCUT("spatial_editor/tool_move", p_event)) {
_menu_item_pressed(MENU_TOOL_MOVE);
-
- else if (ED_IS_SHORTCUT("spatial_editor/tool_rotate", p_event))
+ } else if (ED_IS_SHORTCUT("spatial_editor/tool_rotate", p_event)) {
_menu_item_pressed(MENU_TOOL_ROTATE);
-
- else if (ED_IS_SHORTCUT("spatial_editor/tool_scale", p_event))
+ } else if (ED_IS_SHORTCUT("spatial_editor/tool_scale", p_event)) {
_menu_item_pressed(MENU_TOOL_SCALE);
- else if (ED_IS_SHORTCUT("spatial_editor/snap_to_floor", p_event))
+ } else if (ED_IS_SHORTCUT("spatial_editor/snap_to_floor", p_event)) {
snap_selected_nodes_to_floor();
-
- else if (ED_IS_SHORTCUT("spatial_editor/local_coords", p_event))
+ } else if (ED_IS_SHORTCUT("spatial_editor/local_coords", p_event)) {
if (are_local_coords_enabled()) {
_menu_item_toggled(false, MENU_TOOL_LOCAL_COORDS);
} else {
_menu_item_toggled(true, MENU_TOOL_LOCAL_COORDS);
}
- else if (ED_IS_SHORTCUT("spatial_editor/snap", p_event))
+ } else if (ED_IS_SHORTCUT("spatial_editor/snap", p_event)) {
if (is_snap_enabled()) {
_menu_item_toggled(false, MENU_TOOL_USE_SNAP);
} else {
_menu_item_toggled(true, MENU_TOOL_USE_SNAP);
}
+ }
}
}
}
diff --git a/main/input_default.cpp b/main/input_default.cpp
index 77a3699d50..913c143025 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -343,9 +343,9 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
button_event->set_pressed(st->is_pressed());
button_event->set_button_index(BUTTON_LEFT);
if (st->is_pressed()) {
- button_event->set_button_mask(mouse_button_mask | (1 << BUTTON_LEFT - 1));
+ button_event->set_button_mask(mouse_button_mask | (1 << (BUTTON_LEFT - 1)));
} else {
- button_event->set_button_mask(mouse_button_mask & ~(1 << BUTTON_LEFT - 1));
+ button_event->set_button_mask(mouse_button_mask & ~(1 << (BUTTON_LEFT - 1)));
}
_parse_input_event_impl(button_event, true);
@@ -576,7 +576,7 @@ void InputDefault::ensure_touch_mouse_raised() {
button_event->set_global_position(mouse_pos);
button_event->set_pressed(false);
button_event->set_button_index(BUTTON_LEFT);
- button_event->set_button_mask(mouse_button_mask & ~(1 << BUTTON_LEFT - 1));
+ button_event->set_button_mask(mouse_button_mask & ~(1 << (BUTTON_LEFT - 1)));
_parse_input_event_impl(button_event, true);
}
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 5fdb6a5196..fae88042af 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -597,29 +597,31 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu
if (mb->get_button_index() == BUTTON_LEFT) {
if (input_action == INPUT_DUPLICATE) {
-
//paste
_duplicate_paste();
input_action = INPUT_NONE;
_update_duplicate_indicator();
} else if (mb->get_shift()) {
input_action = INPUT_SELECT;
- } else if (mb->get_command())
+ } else if (mb->get_command()) {
input_action = INPUT_COPY;
- else {
+ } else {
input_action = INPUT_PAINT;
set_items.clear();
}
- } else if (mb->get_button_index() == BUTTON_RIGHT)
+ } else if (mb->get_button_index() == BUTTON_RIGHT) {
if (input_action == INPUT_DUPLICATE) {
-
input_action = INPUT_NONE;
_update_duplicate_indicator();
} else if (mb->get_shift()) {
input_action = INPUT_ERASE;
set_items.clear();
- } else
+ } else {
return false;
+ }
+ } else {
+ return false;
+ }
return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
} else {
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index 44052d473f..d9677b505c 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -332,8 +332,8 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
int w;
int h;
- w = (ti.pic_x + ti.frame_width + 1 & ~1) - (ti.pic_x & ~1);
- h = (ti.pic_y + ti.frame_height + 1 & ~1) - (ti.pic_y & ~1);
+ w = ((ti.pic_x + ti.frame_width + 1) & ~1) - (ti.pic_x & ~1);
+ h = ((ti.pic_y + ti.frame_height + 1) & ~1) - (ti.pic_y & ~1);
size.x = w;
size.y = h;
diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp
index 67143b41e2..64a6c19f91 100644
--- a/modules/visual_script/visual_script_property_selector.cpp
+++ b/modules/visual_script/visual_script_property_selector.cpp
@@ -190,15 +190,14 @@ void VisualScriptPropertySelector::_update_search() {
if (type_filter.size() && type_filter.find(E->get().type) == -1)
continue;
+ // capitalize() also converts underscore to space, we'll match again both possible styles
String get_text_raw = String(vformat(TTR("Get %s"), E->get().name));
String get_text = get_text_raw.capitalize();
-
String set_text_raw = String(vformat(TTR("Set %s"), E->get().name));
String set_text = set_text_raw.capitalize();
String input = search_box->get_text().capitalize();
- if (input == String() ||
- get_text_raw.findn(input) != -1 ||
- get_text.findn(input) != -1) {
+
+ if (input == String() || get_text_raw.findn(input) != -1 || get_text.findn(input) != -1) {
TreeItem *item = search_options->create_item(category ? category : root);
item->set_text(0, get_text);
item->set_metadata(0, E->get().name);
@@ -211,9 +210,7 @@ void VisualScriptPropertySelector::_update_search() {
item->set_metadata(2, connecting);
}
- if (input == String() ||
- set_text_raw.findn(input) != -1 &&
- set_text.findn(input) != -1) {
+ if (input == String() || set_text_raw.findn(input) != -1 || set_text.findn(input) != -1) {
TreeItem *item = search_options->create_item(category ? category : root);
item->set_text(0, set_text);
item->set_metadata(0, E->get().name);
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 81f1ee67c5..d8c312397d 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -421,7 +421,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
int cw = 0;
- bool visible = visible_characters < 0 || p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - line_descent - line_ascent, line_ascent + line_descent);
+ bool visible = visible_characters < 0 || (p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - line_descent - line_ascent, line_ascent + line_descent));
if (visible)
line_is_blank = false;
@@ -509,7 +509,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
ENSURE_WIDTH(img->image->get_width());
- bool visible = visible_characters < 0 || p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - font->get_descent() - img->image->get_height(), img->image->get_height());
+ bool visible = visible_characters < 0 || (p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - font->get_descent() - img->image->get_height(), img->image->get_height()));
if (visible)
line_is_blank = false;
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index e3fb602065..26da16569a 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -30,6 +30,7 @@
#include "scroll_container.h"
#include "core/os/os.h"
+
bool ScrollContainer::clips_input() const {
return true;
@@ -170,7 +171,7 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
Vector2 motion = Vector2(mm->get_relative().x, mm->get_relative().y);
drag_accum -= motion;
- if (beyond_deadzone || scroll_h && Math::abs(drag_accum.x) > deadzone || scroll_v && Math::abs(drag_accum.y) > deadzone) {
+ if (beyond_deadzone || (scroll_h && Math::abs(drag_accum.x) > deadzone) || (scroll_v && Math::abs(drag_accum.y) > deadzone)) {
if (!beyond_deadzone) {
propagate_notification(NOTIFICATION_SCROLL_BEGIN);
emit_signal("scroll_started");
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 23e4c26695..db0cae6eda 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1416,7 +1416,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
while (c) {
- if (cache.draw_relationship_lines == 1 && (c->get_parent() != root || c->get_parent() == root && !hide_root)) {
+ if (cache.draw_relationship_lines == 1 && (c->get_parent() != root || !hide_root)) {
int root_ofs = children_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin);
int parent_ofs = p_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin);
Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h / 2) - cache.offset + p_draw_ofs;