diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/csg/csg_shape.cpp | 24 | ||||
-rw-r--r-- | modules/csg/csg_shape.h | 4 | ||||
-rw-r--r-- | modules/gdscript/doc_classes/@GDScript.xml | 74 | ||||
-rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 14 | ||||
-rw-r--r-- | modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd | 3 | ||||
-rw-r--r-- | modules/gltf/gltf_document.cpp | 1 | ||||
-rw-r--r-- | modules/multiplayer/scene_replication_interface.cpp | 6 | ||||
-rw-r--r-- | modules/navigation/godot_navigation_server.cpp | 2 | ||||
-rw-r--r-- | modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml | 2 |
9 files changed, 83 insertions, 47 deletions
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 13c7a8202c..afb8e62eea 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -1255,6 +1255,30 @@ Vector3 CSGBox3D::get_size() const { return size; } +#ifndef DISABLE_DEPRECATED +// Kept for compatibility from 3.x to 4.0. +bool CSGBox3D::_set(const StringName &p_name, const Variant &p_value) { + if (p_name == "width") { + size.x = p_value; + _make_dirty(); + update_gizmos(); + return true; + } else if (p_name == "height") { + size.y = p_value; + _make_dirty(); + update_gizmos(); + return true; + } else if (p_name == "depth") { + size.z = p_value; + _make_dirty(); + update_gizmos(); + return true; + } else { + return false; + } +} +#endif + void CSGBox3D::set_material(const Ref<Material> &p_material) { material = p_material; _make_dirty(); diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h index 9012c37679..c244107bfb 100644 --- a/modules/csg/csg_shape.h +++ b/modules/csg/csg_shape.h @@ -248,6 +248,10 @@ class CSGBox3D : public CSGPrimitive3D { protected: static void _bind_methods(); +#ifndef DISABLE_DEPRECATED + // Kept for compatibility from 3.x to 4.0. + bool _set(const StringName &p_name, const Variant &p_value); +#endif public: void set_size(const Vector3 &p_size); diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 923b2fe30d..0b7e4e50e6 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -4,7 +4,7 @@ Built-in GDScript functions. </brief_description> <description> - A list of GDScript-specific utility functions accessed in any script. + A list of GDScript-specific utility functions and annotations accessible from any script. For the list of the global functions and constants see [@GlobalScope]. </description> <tutorials> @@ -20,7 +20,7 @@ <description> Returns a [Color] constructed from red ([param r8]), green ([param g8]), blue ([param b8]), and optionally alpha ([param a8]) integer channels, each divided by [code]255.0[/code] for their final value. [codeblock] - var red = Color8(255, 0, 0) # Same as Color(1, 0, 0) + var red = Color8(255, 0, 0) # Same as Color(1, 0, 0). var dark_blue = Color8(0, 0, 51) # Same as Color(0, 0, 0.2). var my_color = Color8(306, 255, 0, 102) # Same as Color(1.2, 1, 0, 0.4). [/codeblock] @@ -37,10 +37,10 @@ [codeblock] # Imagine we always want speed to be between 0 and 20. var speed = -10 - assert(speed < 20) # True, the program will continue - assert(speed >= 0) # False, the program will stop - assert(speed >= 0 and speed < 20) # You can also combine the two conditional statements in one check - assert(speed < 20, "the speed limit is 20") # Show a message + assert(speed < 20) # True, the program will continue. + assert(speed >= 0) # False, the program will stop. + assert(speed >= 0 and speed < 20) # You can also combine the two conditional statements in one check. + assert(speed < 20, "the speed limit is 20") # Show a message. [/codeblock] </description> </method> @@ -140,7 +140,7 @@ <param index="0" name="path" type="String" /> <description> Returns a [Resource] from the filesystem located at the absolute [param path]. Unless it's already referenced elsewhere (such as in another script or in the scene), the resource is loaded from disk on function call, which might cause a slight delay, especially when loading large scenes. To avoid unnecessary delays when loading something multiple times, either store the resource in a variable or use [method preload]. - [b]Note:[/b] Resource paths can be obtained by right-clicking on a resource in the FileSystem dock and choosing "Copy Path" or by dragging the file from the FileSystem dock into the script. + [b]Note:[/b] Resource paths can be obtained by right-clicking on a resource in the FileSystem dock and choosing "Copy Path", or by dragging the file from the FileSystem dock into the current script. [codeblock] # Load a scene called "main" located in the root of the project directory and cache it in a variable. var main = load("res://main.tscn") # main will contain a PackedScene resource. @@ -155,7 +155,7 @@ <param index="0" name="path" type="String" /> <description> Returns a [Resource] from the filesystem located at [param path]. During run-time, the resource is loaded when the script is being parsed. This function effectively acts as a reference to that resource. Note that this function requires [param path] to be a constant [String]. If you want to load a resource from a dynamic/variable path, use [method load]. - [b]Note:[/b] Resource paths can be obtained by right clicking on a resource in the Assets Panel and choosing "Copy Path" or by dragging the file from the FileSystem dock into the script. + [b]Note:[/b] Resource paths can be obtained by right-clicking on a resource in the Assets Panel and choosing "Copy Path", or by dragging the file from the FileSystem dock into the current script. [codeblock] # Create instance of a scene. var diamond = preload("res://diamond.tscn").instantiate() @@ -259,10 +259,12 @@ <annotation name="@export"> <return type="void" /> <description> - Mark the following property as exported (editable in the Inspector dock and saved to disk). To control the type of the exported property use the type hint notation. + Mark the following property as exported (editable in the Inspector dock and saved to disk). To control the type of the exported property, use the type hint notation. [codeblock] + @export var string = "" @export var int_number = 5 @export var float_number: float = 5 + @export var image : Image [/codeblock] </description> </annotation> @@ -273,20 +275,20 @@ Define a new category for the following exported properties. This helps to organize properties in the Inspector dock. See also [constant PROPERTY_USAGE_CATEGORY]. [codeblock] - @export_category("My Properties") - @export var number = 3 - @export var string = "" + @export_category("Statistics") + @export var hp = 30 + @export var speed = 1.25 [/codeblock] - [b]Note:[/b] Categories in the property list are supposed to indicate different base types, so the use of this annotation is not encouraged. See [annotation @export_group] and [annotation @export_subgroup] instead. + [b]Note:[/b] Categories in the Inspector dock's list usually divide properties coming from different classes (Node, Node2D, Sprite, etc.). For better clarity, it's recommended to use [annotation @export_group] and [annotation @export_subgroup], instead. </description> </annotation> <annotation name="@export_color_no_alpha"> <return type="void" /> <description> - Export a [Color] property without transparency (its alpha fixed as [code]1.0[/code]). + Export a [Color] property without allowing its transparency ([member Color.a]) to be edited. See also [constant PROPERTY_HINT_COLOR_NO_ALPHA]. [codeblock] - @export_color_no_alpha var modulate_color: Color + @export_color_no_alpha var dye_color : Color [/codeblock] </description> </annotation> @@ -296,7 +298,7 @@ Export a [String] property as a path to a directory. The path will be limited to the project folder and its subfolders. See [annotation @export_global_dir] to allow picking from the entire filesystem. See also [constant PROPERTY_HINT_DIR]. [codeblock] - @export_dir var sprite_folder: String + @export_dir var sprite_folder_path: String [/codeblock] </description> </annotation> @@ -343,8 +345,8 @@ If [param filter] is provided, only matching files will be available for picking. See also [constant PROPERTY_HINT_FILE]. [codeblock] - @export_file var sound_effect_file: String - @export_file("*.txt") var notes_file: String + @export_file var sound_effect_path: String + @export_file("*.txt") var notes_path: String [/codeblock] </description> </annotation> @@ -436,10 +438,10 @@ <annotation name="@export_global_dir"> <return type="void" /> <description> - Export a [String] property as a path to a directory. The path can be picked from the entire filesystem. See [annotation @export_dir] to limit it to the project folder and its subfolders. + Export a [String] property as an absolute path to a directory. The path can be picked from the entire filesystem. See [annotation @export_dir] to limit it to the project folder and its subfolders. See also [constant PROPERTY_HINT_GLOBAL_DIR]. [codeblock] - @export_global_dir var sprite_folder: String + @export_global_dir var sprite_folder_path: String [/codeblock] </description> </annotation> @@ -447,12 +449,12 @@ <return type="void" /> <param index="0" name="filter" type="String" default="""" /> <description> - Export a [String] property as a path to a file. The path can be picked from the entire filesystem. See [annotation @export_file] to limit it to the project folder and its subfolders. + Export a [String] property as an absolute path to a file. The path can be picked from the entire filesystem. See [annotation @export_file] to limit it to the project folder and its subfolders. If [param filter] is provided, only matching files will be available for picking. See also [constant PROPERTY_HINT_GLOBAL_FILE]. [codeblock] - @export_global_file var sound_effect_file: String - @export_global_file("*.txt") var notes_file: String + @export_global_file var sound_effect_path: String + @export_global_file("*.txt") var notes_path: String [/codeblock] </description> </annotation> @@ -466,13 +468,13 @@ Groups cannot be nested, use [annotation @export_subgroup] to add subgroups within groups. See also [constant PROPERTY_USAGE_GROUP]. [codeblock] - @export_group("My Properties") - @export var number = 3 - @export var string = "" + @export_group("Racer Properties") + @export var nickname = "Nick" + @export var age = 26 - @export_group("Prefixed Properties", "prefix_") - @export var prefix_number = 3 - @export var prefix_string = "" + @export_group("Car Properties", "car_") + @export var car_label = "Speedy" + @export var car_number = 3 @export_group("", "") @export var ungrouped_number = 3 @@ -544,13 +546,13 @@ Define a new subgroup for the following exported properties. This helps to organize properties in the Inspector dock. Subgroups work exactly like groups, except they need a parent group to exist. See [annotation @export_group]. See also [constant PROPERTY_USAGE_SUBGROUP]. [codeblock] - @export_group("My Properties") - @export var number = 3 - @export var string = "" + @export_group("Racer Properties") + @export var nickname = "Nick" + @export var age = 26 - @export_subgroup("My Prefixed Properties", "prefix_") - @export var prefix_number = 3 - @export var prefix_string = "" + @export_subgroup("Car Properties", "car_") + @export var car_label = "Speedy" + @export var car_number = 3 [/codeblock] [b]Note:[/b] Subgroups cannot be nested, they only provide one extra level of depth. Just like the next group ends the previous group, so do the subsequent subgroups. </description> @@ -571,7 +573,7 @@ <annotation name="@onready"> <return type="void" /> <description> - Mark the following property as assigned on [Node]'s ready state change. Values for these properties are not assigned immediately upon the node's creation, and instead are computed and stored right before [method Node._ready]. + Mark the following property as assigned when the [Node] is ready. Values for these properties are not assigned immediately when the node is initialized ([method Object._init]), and instead are computed and stored right before [method Node._ready]. [codeblock] @onready var character_name: Label = $Label [/codeblock] diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index de0dacece3..8d09249125 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -4278,11 +4278,15 @@ Variant GDScriptAnalyzer::make_variable_default_value(GDScriptParser::VariableNo } } else { GDScriptParser::DataType datatype = p_variable->get_datatype(); - if (datatype.is_hard_type() && datatype.kind == GDScriptParser::DataType::BUILTIN && datatype.builtin_type != Variant::OBJECT) { - if (datatype.builtin_type == Variant::ARRAY && datatype.has_container_element_type()) { - result = make_array_from_element_datatype(datatype.get_container_element_type()); - } else { - VariantInternal::initialize(&result, datatype.builtin_type); + if (datatype.is_hard_type()) { + if (datatype.kind == GDScriptParser::DataType::BUILTIN && datatype.builtin_type != Variant::OBJECT) { + if (datatype.builtin_type == Variant::ARRAY && datatype.has_container_element_type()) { + result = make_array_from_element_datatype(datatype.get_container_element_type()); + } else { + VariantInternal::initialize(&result, datatype.builtin_type); + } + } else if (datatype.kind == GDScriptParser::DataType::ENUM) { + result = 0; } } } diff --git a/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd b/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd index 092ae49d00..7416ecd87a 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd +++ b/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd @@ -86,7 +86,8 @@ func test(): var typed_int := 556 var converted_floats: Array[float] = [typed_int] - assert(str(converted_floats) == '[556]') + converted_floats.push_back(498) + assert(str(converted_floats) == '[556, 498]') assert(converted_floats.get_typed_builtin() == TYPE_FLOAT) diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 028028a103..e3ba290eb2 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -3285,7 +3285,6 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> p_state, const String &p_base_p tex.instantiate(); tex->set_name(img->get_name()); tex->set_keep_compressed_buffer(true); - p_state->source_images.push_back(img); tex->create_from_image(img, PortableCompressedTexture2D::COMPRESSION_MODE_BASIS_UNIVERSAL); p_state->images.push_back(tex); p_state->source_images.push_back(img); diff --git a/modules/multiplayer/scene_replication_interface.cpp b/modules/multiplayer/scene_replication_interface.cpp index 3466cb10df..68b6bc4a24 100644 --- a/modules/multiplayer/scene_replication_interface.cpp +++ b/modules/multiplayer/scene_replication_interface.cpp @@ -742,6 +742,7 @@ Error SceneReplicationInterface::on_sync_receive(int p_from, const uint8_t *p_bu ofs += 4; uint32_t size = decode_uint32(&p_buffer[ofs]); ofs += 4; + ERR_FAIL_COND_V(size > uint32_t(p_buffer_len - ofs), ERR_INVALID_DATA); MultiplayerSynchronizer *sync = nullptr; if (net_id & 0x80000000) { sync = Object::cast_to<MultiplayerSynchronizer>(multiplayer->get_path_cache()->get_cached_object(p_from, net_id & 0x7FFFFFFF)); @@ -756,14 +757,15 @@ Error SceneReplicationInterface::on_sync_receive(int p_from, const uint8_t *p_bu } Node *node = sync->get_root_node(); if (sync->get_multiplayer_authority() != p_from || !node) { - ERR_CONTINUE(true); + // Not valid for me. + ofs += size; + ERR_CONTINUE_MSG(true, "Ignoring sync data from non-authority or for missing node."); } if (!sync->update_inbound_sync_time(time)) { // State is too old. ofs += size; continue; } - ERR_FAIL_COND_V(size > uint32_t(p_buffer_len - ofs), ERR_BUG); const List<NodePath> props = sync->get_replication_config()->get_sync_properties(); Vector<Variant> vars; vars.resize(props.size()); diff --git a/modules/navigation/godot_navigation_server.cpp b/modules/navigation/godot_navigation_server.cpp index c3cb1c5f13..79e8c3a6d6 100644 --- a/modules/navigation/godot_navigation_server.cpp +++ b/modules/navigation/godot_navigation_server.cpp @@ -757,7 +757,7 @@ COMMAND_1(free, RID, p_object) { agent_owner.free(p_object); } else { - ERR_FAIL_COND("Invalid ID."); + ERR_FAIL_COND("Attempted to free a NavigationServer RID that did not exist (or was already freed)."); } } diff --git a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml index aaeb2025ee..e0d17277ef 100644 --- a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml +++ b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml @@ -16,7 +16,7 @@ <param index="1" name="tls_client_options" type="TLSOptions" default="null" /> <description> Starts a new multiplayer client connecting to the given [param url]. TLS certificates will be verified against the hostname when connecting using the [code]wss://[/code] protocol. You can pass the optional [param tls_client_options] parameter to customize the trusted certification authorities, or disable the common name verification. See [method TLSOptions.client] and [method TLSOptions.client_unsafe]. - [b]Note[/b]: It is recommended to specify the scheme part of the URL, i.e. the [param url] should start with either [code]ws://[/code] or [code]wss://[/code]. + [b]Note:[/b] It is recommended to specify the scheme part of the URL, i.e. the [param url] should start with either [code]ws://[/code] or [code]wss://[/code]. </description> </method> <method name="create_server"> |