diff options
39 files changed, 115 insertions, 82 deletions
diff --git a/.gitignore b/.gitignore index 7a836240b8..f43f68f25f 100644 --- a/.gitignore +++ b/.gitignore @@ -343,3 +343,5 @@ platform/windows/godot_res.res # compile commands (https://clang.llvm.org/docs/JSONCompilationDatabase.html) compile_commands.json +# Cppcheck +*.cppcheck diff --git a/core/pool_vector.h b/core/pool_vector.h index aba66e3909..98a52c6938 100644 --- a/core/pool_vector.h +++ b/core/pool_vector.h @@ -488,9 +488,7 @@ T PoolVector<T>::get(int p_index) const { template <class T> void PoolVector<T>::set(int p_index, const T &p_val) { - if (p_index < 0 || p_index >= size()) { - ERR_FAIL_COND(p_index < 0 || p_index >= size()); - } + ERR_FAIL_INDEX(p_index, size()); Write w = write(); w[p_index] = p_val; diff --git a/core/ustring.cpp b/core/ustring.cpp index 21ac304a1b..706e8a3cc1 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -778,7 +778,7 @@ Vector<String> String::split(const String &p_splitter, bool p_allow_empty, int p if (p_allow_empty || (end > from)) { if (p_maxsplit <= 0) ret.push_back(substr(from, end - from)); - else if (p_maxsplit > 0) { + else { // Put rest of the string and leave cycle. if (p_maxsplit == ret.size()) { diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index 83e3729391..5395a8fcb0 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -182,7 +182,7 @@ </signals> <constants> <constant name="NOTIFICATION_EDITOR_SETTINGS_CHANGED" value="10000"> - Emitted when editor settings change. It used by various editor plugins to update their visuals on theme changes or logic on configuration changes. + Emitted when editor settings change. It used by various editor plugins to update their visuals on theme changes or logic on configuration changes. </constant> </constants> </class> diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 5a90354124..889ce4d3eb 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -553,7 +553,7 @@ <return type="void"> </return> <description> - Moves this node to the top of the array of nodes of the parent node. This is often useful in GUIs ([Control] nodes), because their order of drawing depends on their order in the tree. + Moves this node to the bottom of parent node's children hierarchy. This is often useful in GUIs ([Control] nodes), because their order of drawing depends on their order in the tree, i.e. the further they are on the node list, the higher they are drawn. After using [code]raise[/code], a Control will be drawn on top of their siblings. </description> </method> <method name="remove_and_skip"> diff --git a/doc/classes/String.xml b/doc/classes/String.xml index 1934c5af9a..e513a44b1d 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -385,19 +385,30 @@ <return type="int"> </return> <description> - Converts a string containing a hexadecimal number into an integer. + Converts a string containing a hexadecimal number into an integer. Hexadecimal strings are expected to be prefixed with "[code]0x[/code]" otherwise [code]0[/code] is returned. + [codeblock] + print("0xff".hex_to_int()) # Print "255" + [/codeblock] </description> </method> <method name="http_escape"> <return type="String"> </return> <description> + Escapes (encodes) a string to URL friendly format. Also referred to as 'URL encode'. + [codeblock] + print("https://example.org/?escaped=" + "Godot Engine:'docs'".http_escape()) + [/codeblock] </description> </method> <method name="http_unescape"> <return type="String"> </return> <description> + Unescapes (decodes) a string in URL encoded format. Also referred to as 'URL decode'. + [codeblock] + print("https://example.org/?escaped=" + "Godot%20Engine%3A%27docs%27".http_unescape()) + [/codeblock] </description> </method> <method name="insert"> diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index 772d20a92e..5d5a62456f 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -141,13 +141,6 @@ Returns [code]true[/code] if the size override is enabled. See [method set_size_override]. </description> </method> - <method name="is_size_override_stretch_enabled" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the size stretch override is enabled. See [method set_size_override_stretch]. - </description> - </method> <method name="set_attach_to_screen_rect"> <return type="void"> </return> @@ -175,15 +168,6 @@ Sets the size override of the viewport. If the [code]enable[/code] parameter is [code]true[/code] the override is used, otherwise it uses the default size. If the size parameter is [code](-1, -1)[/code], it won't update the size. </description> </method> - <method name="set_size_override_stretch"> - <return type="void"> - </return> - <argument index="0" name="enabled" type="bool"> - </argument> - <description> - If [code]true[/code], the size override affects stretch as well. - </description> - </method> <method name="unhandled_input"> <return type="void"> </return> diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 7efe6a987a..c4cfd1e765 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -2526,19 +2526,19 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy int v = value; GLuint *gui = (GLuint *)data; - gui[0] = v & 1 ? GL_TRUE : GL_FALSE; - gui[1] = v & 2 ? GL_TRUE : GL_FALSE; - gui[2] = v & 4 ? GL_TRUE : GL_FALSE; + gui[0] = (v & 1) ? GL_TRUE : GL_FALSE; + gui[1] = (v & 2) ? GL_TRUE : GL_FALSE; + gui[2] = (v & 4) ? GL_TRUE : GL_FALSE; } break; case ShaderLanguage::TYPE_BVEC4: { int v = value; GLuint *gui = (GLuint *)data; - gui[0] = v & 1 ? GL_TRUE : GL_FALSE; - gui[1] = v & 2 ? GL_TRUE : GL_FALSE; - gui[2] = v & 4 ? GL_TRUE : GL_FALSE; - gui[3] = v & 8 ? GL_TRUE : GL_FALSE; + gui[0] = (v & 1) ? GL_TRUE : GL_FALSE; + gui[1] = (v & 2) ? GL_TRUE : GL_FALSE; + gui[2] = (v & 4) ? GL_TRUE : GL_FALSE; + gui[3] = (v & 8) ? GL_TRUE : GL_FALSE; } break; case ShaderLanguage::TYPE_INT: { @@ -3441,7 +3441,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: glGenBuffers(1, &surface->vertex_id); glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id); - glBufferData(GL_ARRAY_BUFFER, array_size, vr.ptr(), p_format & VS::ARRAY_FLAG_USE_DYNAMIC_UPDATE ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, array_size, vr.ptr(), (p_format & VS::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind if (p_format & VS::ARRAY_FORMAT_INDEX) { diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 4de910ee1c..aa61cf5dcc 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -256,7 +256,7 @@ OS::TimeZoneInfo OS_Unix::get_time_zone_info() const { void OS_Unix::delay_usec(uint32_t p_usec) const { - struct timespec rem = { static_cast<time_t>(p_usec / 1000000), static_cast<long>((p_usec % 1000000) * 1000) }; + struct timespec rem = { static_cast<time_t>(p_usec / 1000000), (static_cast<long>(p_usec) % 1000000) * 1000 }; while (nanosleep(&rem, &rem) == EINTR) { } } diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 547d627925..8a8d52c6f1 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -210,13 +210,13 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p if (is_subsequence_of_type && !is_selected_equal) { if (is_substring_of_type) { - if (!is_substring_of_selected || (is_substring_of_selected && (current_type_prefered && !selected_type_prefered))) { + if (!is_substring_of_selected || (current_type_prefered && !selected_type_prefered)) { *to_select = item; } } else { // substring results weigh more than subsequences, so let's make sure we don't override them if (!is_substring_of_selected) { - if (!is_subsequence_of_selected || (is_subsequence_of_selected && (current_type_prefered && !selected_type_prefered))) { + if (!is_subsequence_of_selected || (current_type_prefered && !selected_type_prefered)) { *to_select = item; } } diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 9a049f3ae3..5f8660e108 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -474,7 +474,7 @@ void DependencyRemoveDialog::show(const Vector<String> &p_folders, const Vector< removed_deps.sort(); if (removed_deps.empty()) { owners->hide(); - text->set_text(TTR("Remove selected files from the project? (no undo)")); + text->set_text(TTR("Remove selected files from the project? (Can't be restored)")); set_size(Size2()); popup_centered(); } else { diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 4ec24c76f2..fbfc999dbf 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -337,7 +337,7 @@ bool EditorHelpSearch::Runner::_phase_match_classes() { if (term.length() > 1) { if (search_flags & SEARCH_METHODS) for (int i = 0; i < class_doc.methods.size(); i++) { - String method_name = search_flags & SEARCH_CASE_SENSITIVE ? class_doc.methods[i].name : class_doc.methods[i].name.to_lower(); + String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.methods[i].name : class_doc.methods[i].name.to_lower(); if (method_name.find(term) > -1 || (term.begins_with(".") && method_name.begins_with(term.right(1))) || (term.ends_with("(") && method_name.ends_with(term.left(term.length() - 1).strip_edges())) || @@ -405,7 +405,7 @@ bool EditorHelpSearch::Runner::_phase_member_items() { ClassMatch &match = iterator_match->value(); - TreeItem *parent = search_flags & SEARCH_SHOW_HIERARCHY ? class_items[match.doc->name] : root_item; + TreeItem *parent = (search_flags & SEARCH_SHOW_HIERARCHY) ? class_items[match.doc->name] : root_item; for (int i = 0; i < match.methods.size(); i++) _create_method_item(parent, match.doc, match.methods[i]); for (int i = 0; i < match.signals.size(); i++) diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp index 1787a3b88d..e728dbac31 100644 --- a/editor/import/resource_importer_wav.cpp +++ b/editor/import/resource_importer_wav.cpp @@ -62,6 +62,10 @@ String ResourceImporterWAV::get_resource_type() const { bool ResourceImporterWAV::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { + if (p_option == "force/max_rate_hz" && !bool(p_options["force/max_rate"])) { + return false; + } + return true; } @@ -77,7 +81,7 @@ void ResourceImporterWAV::get_import_options(List<ImportOption> *r_options, int r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/8_bit"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/mono"), false)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/max_rate"), false)); + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/max_rate", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "force/max_rate_hz", PROPERTY_HINT_EXP_RANGE, "11025,192000,1"), 44100)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "edit/trim"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "edit/normalize"), true)); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 7f7ae8f273..fc72f25b04 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -6048,7 +6048,6 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const void EditorSpatialGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard) { Ref<SpatialMaterial> handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial)); - handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial)); handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true); Ref<Texture> handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons"); diff --git a/main/input_default.cpp b/main/input_default.cpp index 199fcfcf66..a03d015fc3 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -873,7 +873,7 @@ void InputDefault::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) { return; } float deadzone = p_value.min == 0 ? 0.5f : 0.0f; - bool pressed = p_value.value > deadzone ? true : false; + bool pressed = p_value.value > deadzone; if (pressed == joy_buttons_pressed.has(_combine_device(map.index, p_device))) { // button already pressed or released, this is an axis bounce value return; diff --git a/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist b/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist index b7cd94e3d5..e7c4f8f340 100644 --- a/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist +++ b/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist @@ -36,6 +36,8 @@ <string>$camera_usage_description</string> <key>NSPhotoLibraryUsageDescription</key> <string>$photolibrary_usage_description</string> + <key>NSMicrophoneUsageDescription</key> + <string>$microphone_usage_description</string> <key>UIRequiresFullScreen</key> <true/> <key>UIStatusBarHidden</key> diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp index 093e2f3006..f23c66dbcf 100644 --- a/modules/assimp/editor_scene_importer_assimp.cpp +++ b/modules/assimp/editor_scene_importer_assimp.cpp @@ -854,7 +854,7 @@ Ref<Material> EditorSceneImporterAssimp::_generate_material_from_index(ImportSta if (found) { Ref<Texture> texture = _load_texture(state, path); - if (texture != NULL) { + if (texture.is_valid()) { _set_texture_mapping_mode(map_mode, texture); mat->set_feature(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING, true); mat->set_texture(SpatialMaterial::TEXTURE_NORMAL, texture); diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index 085cce9733..8d21b25b20 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -728,12 +728,12 @@ bool RigidBodyBullet::is_axis_locked(PhysicsServer::BodyAxis p_axis) const { void RigidBodyBullet::reload_axis_lock() { - btBody->setLinearFactor(btVector3(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_X), !is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Y), !is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Z))); + btBody->setLinearFactor(btVector3(float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_X)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Y)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Z)))); if (PhysicsServer::BODY_MODE_CHARACTER == mode) { /// When character angular is always locked btBody->setAngularFactor(btVector3(0., 0., 0.)); } else { - btBody->setAngularFactor(btVector3(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_X), !is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Y), !is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Z))); + btBody->setAngularFactor(btVector3(float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_X)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Y)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Z)))); } } diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 20e454c218..2cf566941e 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -578,7 +578,7 @@ void GridMapEditor::_update_paste_indicator() { return; } - Vector3 center = 0.5 * Vector3(node->get_center_x(), node->get_center_y(), node->get_center_z()); + Vector3 center = 0.5 * Vector3(float(node->get_center_x()), float(node->get_center_y()), float(node->get_center_z())); Vector3 scale = (Vector3(1, 1, 1) + (paste_indicator.end - paste_indicator.begin)) * node->get_cell_size(); Transform xf; xf.scale(scale); diff --git a/modules/mono/utils/string_utils.cpp b/modules/mono/utils/string_utils.cpp index 877122985d..2b014c2a45 100644 --- a/modules/mono/utils/string_utils.cpp +++ b/modules/mono/utils/string_utils.cpp @@ -44,7 +44,7 @@ int sfind(const String &p_text, int p_from) { int src_len = 2; int len = p_text.length(); - if (src_len == 0 || len == 0) + if (len == 0) return -1; const CharType *src = p_text.c_str(); diff --git a/modules/opus/audio_stream_opus.cpp b/modules/opus/audio_stream_opus.cpp index 70d0f770d8..615081d818 100644 --- a/modules/opus/audio_stream_opus.cpp +++ b/modules/opus/audio_stream_opus.cpp @@ -280,7 +280,7 @@ int AudioStreamPlaybackOpus::mix(int16_t *p_buffer, int p_frames) { int todo = p_frames; - if (todo == 0 || todo < MIN_MIX) { + if (todo < MIN_MIX) { break; } diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index df5bb9ca2e..b816e37936 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -1487,7 +1487,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p Variant **output_args = (Variant **)(input_args + max_input_args); int flow_max = f->flow_stack_size; int *flow_stack = flow_max ? (int *)(output_args + max_output_args) : (int *)NULL; - int *pass_stack = flow_stack + flow_max; + int *pass_stack = flow_stack ? (int *)(flow_stack + flow_max) : (int *)NULL; String error_str; @@ -1905,7 +1905,7 @@ Variant VisualScriptInstance::call(const StringName &p_method, const Variant **p Variant **output_args = (Variant **)(input_args + max_input_args); int flow_max = f->flow_stack_size; int *flow_stack = flow_max ? (int *)(output_args + max_output_args) : (int *)NULL; - int *pass_stack = flow_stack + flow_max; + int *pass_stack = flow_stack ? (int *)(flow_stack + flow_max) : (int *)NULL; for (int i = 0; i < f->node_count; i++) { sequence_bits[i] = false; //all starts as false diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index f8cb6cfa3c..0413bbf303 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -570,7 +570,6 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const Node *bnode = _get_base_node(); if (bnode) { property.hint_string = bnode->get_path(); //convert to loong string - } else { } } } @@ -1035,8 +1034,6 @@ PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const pi.name = (call_mode == CALL_MODE_INSTANCE ? String("instance") : Variant::get_type_name(basic_type).to_lower()); _adjust_input_index(pi); return pi; - } else { - p_idx--; } } @@ -1352,7 +1349,6 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { Node *bnode = _get_base_node(); if (bnode) { property.hint_string = bnode->get_path(); //convert to loong string - } else { } } } @@ -1794,8 +1790,6 @@ PropertyInfo VisualScriptPropertyGet::get_input_value_port_info(int p_idx) const pi.type = (call_mode == CALL_MODE_INSTANCE ? Variant::OBJECT : basic_type); pi.name = (call_mode == CALL_MODE_INSTANCE ? String("instance") : Variant::get_type_name(basic_type).to_lower()); return pi; - } else { - p_idx--; } } return PropertyInfo(); @@ -2073,7 +2067,6 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { Node *bnode = _get_base_node(); if (bnode) { property.hint_string = bnode->get_path(); //convert to loong string - } else { } } } diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp index 962560cc96..ebd0f0b3cb 100644 --- a/modules/visual_script/visual_script_yield_nodes.cpp +++ b/modules/visual_script/visual_script_yield_nodes.cpp @@ -431,7 +431,6 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const { Node *bnode = _get_base_node(); if (bnode) { property.hint_string = bnode->get_path(); //convert to loong string - } else { } } } diff --git a/modules/vorbis/audio_stream_ogg_vorbis.cpp b/modules/vorbis/audio_stream_ogg_vorbis.cpp index e652abbe6a..2f4a45f108 100644 --- a/modules/vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/vorbis/audio_stream_ogg_vorbis.cpp @@ -103,7 +103,7 @@ int AudioStreamPlaybackOGGVorbis::mix(int16_t *p_buffer, int p_frames) { int todo = p_frames; - if (todo == 0 || todo < MIN_MIX) { + if (todo < MIN_MIX) { break; } diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp index 23cbf916eb..e24cb850ec 100644 --- a/modules/websocket/websocket_multiplayer_peer.cpp +++ b/modules/websocket/websocket_multiplayer_peer.cpp @@ -191,7 +191,7 @@ void WebSocketMultiplayerPeer::_send_sys(Ref<WebSocketPeer> p_peer, uint8_t p_ty p_peer->put_packet(&(message.read()[0]), message.size()); } -PoolVector<uint8_t> WebSocketMultiplayerPeer::_make_pkt(uint32_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size) { +PoolVector<uint8_t> WebSocketMultiplayerPeer::_make_pkt(uint8_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size) { PoolVector<uint8_t> out; out.resize(PROTO_SIZE + p_data_size); diff --git a/modules/websocket/websocket_multiplayer_peer.h b/modules/websocket/websocket_multiplayer_peer.h index 7fd97a6595..e3ab0784ab 100644 --- a/modules/websocket/websocket_multiplayer_peer.h +++ b/modules/websocket/websocket_multiplayer_peer.h @@ -41,7 +41,7 @@ class WebSocketMultiplayerPeer : public NetworkedMultiplayerPeer { GDCLASS(WebSocketMultiplayerPeer, NetworkedMultiplayerPeer); private: - PoolVector<uint8_t> _make_pkt(uint32_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size); + PoolVector<uint8_t> _make_pkt(uint8_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size); void _store_pkt(int32_t p_source, int32_t p_dest, const uint8_t *p_data, uint32_t p_data_size); Error _server_relay(int32_t p_from, int32_t p_to, const uint8_t *p_buffer, uint32_t p_buffer_size); diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp index 1e140a716f..0d09a4d74e 100644 --- a/modules/websocket/wsl_server.cpp +++ b/modules/websocket/wsl_server.cpp @@ -42,7 +42,7 @@ WSLServer::PendingPeer::PendingPeer() { memset(req_buf, 0, sizeof(req_buf)); } -bool WSLServer::PendingPeer::_parse_request(String &r_key) { +bool WSLServer::PendingPeer::_parse_request(const PoolStringArray p_protocols) { Vector<String> psa = String((char *)req_buf).split("\r\n"); int len = psa.size(); if (len < 4) { @@ -87,11 +87,29 @@ bool WSLServer::PendingPeer::_parse_request(String &r_key) { _WLS_CHECK_EX("connection"); #undef _WLS_CHECK_EX #undef _WLS_CHECK - r_key = headers["sec-websocket-key"]; + key = headers["sec-websocket-key"]; + if (headers.has("sec-websocket-protocol")) { + Vector<String> protos = headers["sec-websocket-protocol"].split(","); + for (int i = 0; i < protos.size(); i++) { + // Check if we have the given protocol + for (int j = 0; j < p_protocols.size(); j++) { + if (protos[i] != p_protocols[j]) + continue; + protocol = protos[i]; + break; + } + // Found a protocol + if (protocol != "") + break; + } + if (protocol == "") // Invalid protocol(s) requested + return false; + } else if (p_protocols.size() > 0) // No protocol requested, but we need one + return false; return true; } -Error WSLServer::PendingPeer::do_handshake() { +Error WSLServer::PendingPeer::do_handshake(PoolStringArray p_protocols) { if (OS::get_singleton()->get_ticks_msec() - time > WSL_SERVER_TIMEOUT) return ERR_TIMEOUT; if (!has_request) { @@ -111,13 +129,15 @@ Error WSLServer::PendingPeer::do_handshake() { int l = req_pos; if (l > 3 && r[l] == '\n' && r[l - 1] == '\r' && r[l - 2] == '\n' && r[l - 3] == '\r') { r[l - 3] = '\0'; - if (!_parse_request(key)) { + if (!_parse_request(p_protocols)) { return FAILED; } String s = "HTTP/1.1 101 Switching Protocols\r\n"; s += "Upgrade: websocket\r\n"; s += "Connection: Upgrade\r\n"; s += "Sec-WebSocket-Accept: " + WSLPeer::compute_key_response(key) + "\r\n"; + if (protocol != "") + s += "Sec-WebSocket-Protocol: " + protocol + "\r\n"; s += "\r\n"; response = s.utf8(); has_request = true; @@ -143,6 +163,7 @@ Error WSLServer::listen(int p_port, PoolVector<String> p_protocols, bool gd_mp_a ERR_FAIL_COND_V(is_listening(), ERR_ALREADY_IN_USE); _is_multiplayer = gd_mp_api; + _protocols = p_protocols; _server->listen(p_port); return OK; @@ -167,7 +188,7 @@ void WSLServer::poll() { List<Ref<PendingPeer> > remove_peers; for (List<Ref<PendingPeer> >::Element *E = _pending.front(); E; E = E->next()) { Ref<PendingPeer> ppeer = E->get(); - Error err = ppeer->do_handshake(); + Error err = ppeer->do_handshake(_protocols); if (err == ERR_BUSY) { continue; } else if (err != OK) { @@ -188,7 +209,7 @@ void WSLServer::poll() { _peer_map[id] = ws_peer; remove_peers.push_back(ppeer); - _on_connect(id, ""); + _on_connect(id, ppeer->protocol); } for (List<Ref<PendingPeer> >::Element *E = remove_peers.front(); E; E = E->next()) { _pending.erase(E->get()); diff --git a/modules/websocket/wsl_server.h b/modules/websocket/wsl_server.h index b0520bd731..2ceb941073 100644 --- a/modules/websocket/wsl_server.h +++ b/modules/websocket/wsl_server.h @@ -49,7 +49,7 @@ private: class PendingPeer : public Reference { private: - bool _parse_request(String &r_key); + bool _parse_request(const PoolStringArray p_protocols); public: Ref<StreamPeer> connection; @@ -58,13 +58,14 @@ private: uint8_t req_buf[WSL_MAX_HEADER_SIZE]; int req_pos; String key; + String protocol; bool has_request; CharString response; int response_sent; PendingPeer(); - Error do_handshake(); + Error do_handshake(const PoolStringArray p_protocols); }; int _in_buf_size; @@ -74,6 +75,7 @@ private: List<Ref<PendingPeer> > _pending; Ref<TCP_Server> _server; + PoolStringArray _protocols; public: Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets); diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp index 63bc5f69d1..5b8cf01138 100644 --- a/platform/android/file_access_jandroid.cpp +++ b/platform/android/file_access_jandroid.cpp @@ -62,7 +62,7 @@ Error FileAccessJAndroid::_open(const String &p_path, int p_mode_flags) { JNIEnv *env = ThreadAndroid::get_env(); jstring js = env->NewStringUTF(path.utf8().get_data()); - int res = env->CallIntMethod(io, _file_open, js, p_mode_flags & WRITE ? true : false); + int res = env->CallIntMethod(io, _file_open, js, (p_mode_flags & WRITE) ? true : false); env->DeleteLocalRef(js); OS::get_singleton()->print("fopen: '%s' ret %i\n", path.utf8().get_data(), res); diff --git a/platform/iphone/camera_ios.mm b/platform/iphone/camera_ios.mm index 5a54eaee9b..029ce6debf 100644 --- a/platform/iphone/camera_ios.mm +++ b/platform/iphone/camera_ios.mm @@ -397,6 +397,22 @@ void CameraIOS::update_feeds() { }; CameraIOS::CameraIOS() { + // check if we have our usage description + NSString *usage_desc = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSCameraUsageDescription"]; + if (usage_desc == NULL) { + // don't initialise if we don't get anything + print_line("No NSCameraUsageDescription key in pList, no access to cameras."); + return; + } else if (usage_desc.length == 0) { + // don't initialise if we don't get anything + print_line("Empty NSCameraUsageDescription key in pList, no access to cameras."); + return; + } + + // now we'll request access. + // If this is the first time the user will be prompted with the string (iOS will read it). + // Once a decision is made it is returned. If the user wants to change it later on they + // need to go into setting. print_line("Requesting Camera permissions"); [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 99ce2e8f87..85a45d62f8 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -268,8 +268,9 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options) r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/in_app_purchases"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/push_notifications"), false)); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/camera_usage_description"), "Godot would like to use your camera")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/photolibrary_usage_description"), "Godot would like to use your photos")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/camera_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the camera"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/microphone_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the microphone"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/photolibrary_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need access to the photo library"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/portrait"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/landscape_left"), true)); @@ -398,6 +399,9 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_ } else if (lines[i].find("$camera_usage_description") != -1) { String description = p_preset->get("privacy/camera_usage_description"); strnew += lines[i].replace("$camera_usage_description", description) + "\n"; + } else if (lines[i].find("$microphone_usage_description") != -1) { + String description = p_preset->get("privacy/microphone_usage_description"); + strnew += lines[i].replace("$microphone_usage_description", description) + "\n"; } else if (lines[i].find("$photolibrary_usage_description") != -1) { String description = p_preset->get("privacy/photolibrary_usage_description"); strnew += lines[i].replace("$photolibrary_usage_description", description) + "\n"; diff --git a/platform/x11/godot_x11.cpp b/platform/x11/godot_x11.cpp index 9baa4d6dca..755ef7a84f 100644 --- a/platform/x11/godot_x11.cpp +++ b/platform/x11/godot_x11.cpp @@ -43,6 +43,7 @@ int main(int argc, char *argv[]) { setlocale(LC_CTYPE, ""); char *cwd = (char *)malloc(PATH_MAX); + ERR_FAIL_COND_V(!cwd, ERR_OUT_OF_MEMORY); char *ret = getcwd(cwd, PATH_MAX); Error err = Main::setup(argv[0], argc - 1, &argv[1]); diff --git a/scene/3d/baked_lightmap.h b/scene/3d/baked_lightmap.h index fac4ad3908..3a9f4cf01d 100644 --- a/scene/3d/baked_lightmap.h +++ b/scene/3d/baked_lightmap.h @@ -179,7 +179,7 @@ public: void set_extents(const Vector3 &p_extents); Vector3 get_extents() const; - void set_bake_default_texels_per_unit(const float &p_extents); + void set_bake_default_texels_per_unit(const float &p_bake_texels_per_unit); float get_bake_default_texels_per_unit() const; void set_propagation(float p_propagation); diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 00a168fc39..a6ccdb5791 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -257,7 +257,7 @@ String Particles::get_configuration_warning() const { SpatialMaterial *spat = Object::cast_to<SpatialMaterial>(draw_passes[i]->surface_get_material(j).ptr()); anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == SpatialMaterial::BILLBOARD_PARTICLES); } - if (meshes_found && anim_material_found) break; + if (anim_material_found) break; } } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 7a015f77db..3dcbf64e7c 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1191,7 +1191,7 @@ void LineEdit::set_cursor_position(int p_pos) { if (cursor_pos <= window_pos) { /* Adjust window if cursor goes too much to the left */ set_window_pos(MAX(0, cursor_pos - 1)); - } else if (cursor_pos > window_pos) { + } else { /* Adjust window if cursor goes too much to the right */ int window_width = get_size().width - style->get_minimum_size().width; bool display_clear_icon = !text.empty() && is_editable() && clear_button_enabled; diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 89cbf0becd..af2a8c931f 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -1815,7 +1815,7 @@ T Animation::_interpolate(const Vector<TKey<T> > &p_keys, float p_time, Interpol next = idx; } - } else if (idx < 0) { + } else { // only allow extending first key to anim start if looping if (loop) diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 339f008a3d..12bf007bb1 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1537,9 +1537,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r f->store_line("]\n"); //one empty line } - { - } - #ifdef TOOLS_ENABLED //keep order from cached ids Set<int> cached_ids_found; diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp index f6a01939da..7d89764d20 100644 --- a/servers/arvr_server.cpp +++ b/servers/arvr_server.cpp @@ -87,11 +87,11 @@ real_t ARVRServer::get_world_scale() const { }; void ARVRServer::set_world_scale(real_t p_world_scale) { - if (world_scale < 0.01) { - world_scale = 0.01; - } else if (world_scale > 1000.0) { - world_scale = 1000.0; - }; + if (p_world_scale < 0.01) { + p_world_scale = 0.01; + } else if (p_world_scale > 1000.0) { + p_world_scale = 1000.0; + } world_scale = p_world_scale; }; |