diff options
150 files changed, 2393 insertions, 674 deletions
diff --git a/core/io/dtls_server.cpp b/core/io/dtls_server.cpp new file mode 100644 index 0000000000..aa302ced8f --- /dev/null +++ b/core/io/dtls_server.cpp @@ -0,0 +1,54 @@ +/*************************************************************************/ +/* dtls_server.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "dtls_server.h" +#include "core/os/file_access.h" +#include "core/project_settings.h" + +DTLSServer *(*DTLSServer::_create)() = NULL; +bool DTLSServer::available = false; + +DTLSServer *DTLSServer::create() { + + return _create(); +} + +bool DTLSServer::is_available() { + return available; +} + +void DTLSServer::_bind_methods() { + + ClassDB::bind_method(D_METHOD("setup", "key", "certificate", "chain"), &DTLSServer::setup, DEFVAL(Ref<X509Certificate>())); + ClassDB::bind_method(D_METHOD("take_connection", "udp_peer"), &DTLSServer::take_connection); +} + +DTLSServer::DTLSServer() { +} diff --git a/core/io/dtls_server.h b/core/io/dtls_server.h new file mode 100644 index 0000000000..ebef13da64 --- /dev/null +++ b/core/io/dtls_server.h @@ -0,0 +1,57 @@ +/*************************************************************************/ +/* dtls_server.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef DTLS_SERVER_H +#define DTLS_SERVER_H + +#include "core/io/net_socket.h" +#include "core/io/packet_peer_dtls.h" + +class DTLSServer : public Reference { + GDCLASS(DTLSServer, Reference); + +protected: + static DTLSServer *(*_create)(); + static void _bind_methods(); + + static bool available; + +public: + static bool is_available(); + static DTLSServer *create(); + + virtual Error setup(Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert, Ref<X509Certificate> p_ca_chain = Ref<X509Certificate>()) = 0; + virtual void stop() = 0; + virtual Ref<PacketPeerDTLS> take_connection(Ref<PacketPeerUDP> p_peer) = 0; + + DTLSServer(); +}; + +#endif // DTLS_SERVER_H diff --git a/core/io/net_socket.h b/core/io/net_socket.h index 710df2dd78..376fd87a27 100644 --- a/core/io/net_socket.h +++ b/core/io/net_socket.h @@ -61,7 +61,7 @@ public: virtual Error connect_to_host(IP_Address p_addr, uint16_t p_port) = 0; virtual Error poll(PollType p_type, int timeout) const = 0; virtual Error recv(uint8_t *p_buffer, int p_len, int &r_read) = 0; - virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) = 0; + virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port, bool p_peek = false) = 0; virtual Error send(const uint8_t *p_buffer, int p_len, int &r_sent) = 0; virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) = 0; virtual Ref<NetSocket> accept(IP_Address &r_ip, uint16_t &r_port) = 0; diff --git a/core/io/packet_peer_dtls.cpp b/core/io/packet_peer_dtls.cpp new file mode 100644 index 0000000000..64007c7e3b --- /dev/null +++ b/core/io/packet_peer_dtls.cpp @@ -0,0 +1,62 @@ +/*************************************************************************/ +/* packet_peer_dtls.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "packet_peer_dtls.h" +#include "core/os/file_access.h" +#include "core/project_settings.h" + +PacketPeerDTLS *(*PacketPeerDTLS::_create)() = NULL; +bool PacketPeerDTLS::available = false; + +PacketPeerDTLS *PacketPeerDTLS::create() { + + return _create(); +} + +bool PacketPeerDTLS::is_available() { + return available; +} + +void PacketPeerDTLS::_bind_methods() { + + ClassDB::bind_method(D_METHOD("poll"), &PacketPeerDTLS::poll); + ClassDB::bind_method(D_METHOD("connect_to_peer", "packet_peer", "validate_certs", "for_hostname", "valid_certificate"), &PacketPeerDTLS::connect_to_peer, DEFVAL(true), DEFVAL(String()), DEFVAL(Ref<X509Certificate>())); + ClassDB::bind_method(D_METHOD("get_status"), &PacketPeerDTLS::get_status); + ClassDB::bind_method(D_METHOD("disconnect_from_peer"), &PacketPeerDTLS::disconnect_from_peer); + + BIND_ENUM_CONSTANT(STATUS_DISCONNECTED); + BIND_ENUM_CONSTANT(STATUS_HANDSHAKING); + BIND_ENUM_CONSTANT(STATUS_CONNECTED); + BIND_ENUM_CONSTANT(STATUS_ERROR); + BIND_ENUM_CONSTANT(STATUS_ERROR_HOSTNAME_MISMATCH); +} + +PacketPeerDTLS::PacketPeerDTLS() { +} diff --git a/core/io/packet_peer_dtls.h b/core/io/packet_peer_dtls.h new file mode 100644 index 0000000000..b7cabb6ae0 --- /dev/null +++ b/core/io/packet_peer_dtls.h @@ -0,0 +1,68 @@ +/*************************************************************************/ +/* packet_peer_dtls.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef PACKET_PEER_DTLS_H +#define PACKET_PEER_DTLS_H + +#include "core/crypto/crypto.h" +#include "core/io/packet_peer_udp.h" + +class PacketPeerDTLS : public PacketPeer { + GDCLASS(PacketPeerDTLS, PacketPeer); + +protected: + static PacketPeerDTLS *(*_create)(); + static void _bind_methods(); + + static bool available; + +public: + enum Status { + STATUS_DISCONNECTED, + STATUS_HANDSHAKING, + STATUS_CONNECTED, + STATUS_ERROR, + STATUS_ERROR_HOSTNAME_MISMATCH + }; + + virtual void poll() = 0; + virtual Error connect_to_peer(Ref<PacketPeerUDP> p_base, bool p_validate_certs = true, const String &p_for_hostname = String(), Ref<X509Certificate> p_ca_certs = Ref<X509Certificate>()) = 0; + virtual void disconnect_from_peer() = 0; + virtual Status get_status() const = 0; + + static PacketPeerDTLS *create(); + static bool is_available(); + + PacketPeerDTLS(); +}; + +VARIANT_ENUM_CAST(PacketPeerDTLS::Status); + +#endif // PACKET_PEER_DTLS_H diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp index a8cfd741bb..f800ffc3db 100644 --- a/core/io/packet_peer_udp.cpp +++ b/core/io/packet_peer_udp.cpp @@ -133,7 +133,11 @@ Error PacketPeerUDP::put_packet(const uint8_t *p_buffer, int p_buffer_size) { } do { - err = _sock->sendto(p_buffer, p_buffer_size, sent, peer_addr, peer_port); + if (connected) { + err = _sock->send(p_buffer, p_buffer_size, sent); + } else { + err = _sock->sendto(p_buffer, p_buffer_size, sent, peer_addr, peer_port); + } if (err != OK) { if (err != ERR_BUSY) return FAILED; @@ -184,12 +188,69 @@ Error PacketPeerUDP::listen(int p_port, const IP_Address &p_bind_address, int p_ return OK; } +Error PacketPeerUDP::connect_socket(Ref<NetSocket> p_sock) { + Error err; + int read = 0; + uint16_t r_port; + IP_Address r_ip; + + err = p_sock->recvfrom(recv_buffer, sizeof(recv_buffer), read, r_ip, r_port, true); + ERR_FAIL_COND_V(err != OK, err); + err = p_sock->connect_to_host(r_ip, r_port); + ERR_FAIL_COND_V(err != OK, err); + _sock = p_sock; + peer_addr = r_ip; + peer_port = r_port; + packet_ip = peer_addr; + packet_port = peer_port; + connected = true; + return OK; +} + +Error PacketPeerUDP::connect_to_host(const IP_Address &p_host, int p_port) { + ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE); + ERR_FAIL_COND_V(!p_host.is_valid(), ERR_INVALID_PARAMETER); + + Error err; + + if (!_sock->is_open()) { + IP::Type ip_type = p_host.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6; + err = _sock->open(NetSocket::TYPE_UDP, ip_type); + ERR_FAIL_COND_V(err != OK, ERR_CANT_OPEN); + _sock->set_blocking_enabled(false); + } + + err = _sock->connect_to_host(p_host, p_port); + + // I see no reason why we should get ERR_BUSY (wouldblock/eagain) here. + // This is UDP, so connect is only used to tell the OS to which socket + // it shuold deliver packets when multiple are bound on the same address/port. + if (err != OK) { + close(); + ERR_FAIL_V_MSG(FAILED, "Unable to connect"); + } + + connected = true; + + peer_addr = p_host; + peer_port = p_port; + + // Flush any packet we might still have in queue. + rb.clear(); + return OK; +} + +bool PacketPeerUDP::is_connected_to_host() const { + return connected; +} + void PacketPeerUDP::close() { if (_sock.is_valid()) _sock->close(); rb.resize(16); queue_count = 0; + connected = false; } Error PacketPeerUDP::wait() { @@ -212,7 +273,13 @@ Error PacketPeerUDP::_poll() { uint16_t port; while (true) { - err = _sock->recvfrom(recv_buffer, sizeof(recv_buffer), read, ip, port); + if (connected) { + err = _sock->recv(recv_buffer, sizeof(recv_buffer), read); + ip = peer_addr; + port = peer_port; + } else { + err = _sock->recvfrom(recv_buffer, sizeof(recv_buffer), read, ip, port); + } if (err != OK) { if (err == ERR_BUSY) @@ -254,6 +321,7 @@ int PacketPeerUDP::get_packet_port() const { void PacketPeerUDP::set_dest_address(const IP_Address &p_address, int p_port) { + ERR_FAIL_COND_MSG(connected, "Destination address cannot be set for connected sockets"); peer_addr = p_address; peer_port = p_port; } @@ -264,6 +332,8 @@ void PacketPeerUDP::_bind_methods() { ClassDB::bind_method(D_METHOD("close"), &PacketPeerUDP::close); ClassDB::bind_method(D_METHOD("wait"), &PacketPeerUDP::wait); ClassDB::bind_method(D_METHOD("is_listening"), &PacketPeerUDP::is_listening); + ClassDB::bind_method(D_METHOD("connect_to_host", "host", "port"), &PacketPeerUDP::connect_to_host); + ClassDB::bind_method(D_METHOD("is_connected_to_host"), &PacketPeerUDP::is_connected_to_host); ClassDB::bind_method(D_METHOD("get_packet_ip"), &PacketPeerUDP::_get_packet_ip); ClassDB::bind_method(D_METHOD("get_packet_port"), &PacketPeerUDP::get_packet_port); ClassDB::bind_method(D_METHOD("set_dest_address", "host", "port"), &PacketPeerUDP::_set_dest_address); @@ -276,6 +346,7 @@ PacketPeerUDP::PacketPeerUDP() : packet_port(0), queue_count(0), peer_port(0), + connected(false), blocking(true), broadcast(false), _sock(Ref<NetSocket>(NetSocket::create())) { diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h index 15b4d00c37..b5a9fc9ec3 100644 --- a/core/io/packet_peer_udp.h +++ b/core/io/packet_peer_udp.h @@ -52,6 +52,7 @@ protected: IP_Address peer_addr; int peer_port; + bool connected; bool blocking; bool broadcast; Ref<NetSocket> _sock; @@ -70,6 +71,11 @@ public: void close(); Error wait(); bool is_listening() const; + + Error connect_socket(Ref<NetSocket> p_sock); // Used by UDPServer + Error connect_to_host(const IP_Address &p_host, int p_port); + bool is_connected_to_host() const; + IP_Address get_packet_address() const; int get_packet_port() const; void set_dest_address(const IP_Address &p_address, int p_port); diff --git a/core/io/udp_server.cpp b/core/io/udp_server.cpp new file mode 100644 index 0000000000..f041bf097f --- /dev/null +++ b/core/io/udp_server.cpp @@ -0,0 +1,119 @@ +/*************************************************************************/ +/* udp_server.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "udp_server.h" + +void UDPServer::_bind_methods() { + + ClassDB::bind_method(D_METHOD("listen", "port", "bind_address"), &UDPServer::listen, DEFVAL("*")); + ClassDB::bind_method(D_METHOD("is_connection_available"), &UDPServer::is_connection_available); + ClassDB::bind_method(D_METHOD("is_listening"), &UDPServer::is_listening); + ClassDB::bind_method(D_METHOD("take_connection"), &UDPServer::take_connection); + ClassDB::bind_method(D_METHOD("stop"), &UDPServer::stop); +} + +Error UDPServer::listen(uint16_t p_port, const IP_Address &p_bind_address) { + + ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE); + ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE); + ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER); + + Error err; + IP::Type ip_type = IP::TYPE_ANY; + + if (p_bind_address.is_valid()) + ip_type = p_bind_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6; + + err = _sock->open(NetSocket::TYPE_UDP, ip_type); + + if (err != OK) + return ERR_CANT_CREATE; + + _sock->set_blocking_enabled(false); + _sock->set_reuse_address_enabled(true); + err = _sock->bind(p_bind_address, p_port); + + if (err != OK) { + stop(); + return err; + } + bind_address = p_bind_address; + bind_port = p_port; + return OK; +} + +bool UDPServer::is_listening() const { + ERR_FAIL_COND_V(!_sock.is_valid(), false); + + return _sock->is_open(); +} + +bool UDPServer::is_connection_available() const { + + ERR_FAIL_COND_V(!_sock.is_valid(), false); + + if (!_sock->is_open()) + return false; + + Error err = _sock->poll(NetSocket::POLL_TYPE_IN, 0); + return (err == OK); +} + +Ref<PacketPeerUDP> UDPServer::take_connection() { + + Ref<PacketPeerUDP> conn; + if (!is_connection_available()) { + return conn; + } + + conn = Ref<PacketPeerUDP>(memnew(PacketPeerUDP)); + conn->connect_socket(_sock); + _sock = Ref<NetSocket>(NetSocket::create()); + listen(bind_port, bind_address); + return conn; +} + +void UDPServer::stop() { + + if (_sock.is_valid()) { + _sock->close(); + } + bind_port = 0; + bind_address = IP_Address(); +} + +UDPServer::UDPServer() : + _sock(Ref<NetSocket>(NetSocket::create())) { +} + +UDPServer::~UDPServer() { + + stop(); +} diff --git a/core/io/udp_server.h b/core/io/udp_server.h new file mode 100644 index 0000000000..5182a04246 --- /dev/null +++ b/core/io/udp_server.h @@ -0,0 +1,58 @@ +/*************************************************************************/ +/* udp_server.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef UDP_SERVER_H +#define UDP_SERVER_H + +#include "core/io/net_socket.h" +#include "core/io/packet_peer_udp.h" + +class UDPServer : public Reference { + GDCLASS(UDPServer, Reference); + +protected: + static void _bind_methods(); + int bind_port; + IP_Address bind_address; + Ref<NetSocket> _sock; + +public: + Error listen(uint16_t p_port, const IP_Address &p_bind_address = IP_Address("*")); + bool is_listening() const; + bool is_connection_available() const; + Ref<PacketPeerUDP> take_connection(); + + void stop(); + + UDPServer(); + ~UDPServer(); +}; + +#endif // UDP_SERVER_H diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 82f9e847e3..45b600a23d 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -40,12 +40,14 @@ #include "core/func_ref.h" #include "core/input_map.h" #include "core/io/config_file.h" +#include "core/io/dtls_server.h" #include "core/io/http_client.h" #include "core/io/image_loader.h" #include "core/io/marshalls.h" #include "core/io/multiplayer_api.h" #include "core/io/networked_multiplayer_peer.h" #include "core/io/packet_peer.h" +#include "core/io/packet_peer_dtls.h" #include "core/io/packet_peer_udp.h" #include "core/io/pck_packer.h" #include "core/io/resource_format_binary.h" @@ -53,6 +55,7 @@ #include "core/io/stream_peer_ssl.h" #include "core/io/tcp_server.h" #include "core/io/translation_loader_po.h" +#include "core/io/udp_server.h" #include "core/io/xml_parser.h" #include "core/math/a_star.h" #include "core/math/expression.h" @@ -154,6 +157,9 @@ void register_core_types() { ClassDB::register_class<StreamPeerTCP>(); ClassDB::register_class<TCP_Server>(); ClassDB::register_class<PacketPeerUDP>(); + ClassDB::register_class<UDPServer>(); + ClassDB::register_custom_instance_class<PacketPeerDTLS>(); + ClassDB::register_custom_instance_class<DTLSServer>(); // Crypto ClassDB::register_class<HashingContext>(); diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 439937e4f5..5899829e95 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -30,6 +30,9 @@ <member name="Geometry" type="Geometry" setter="" getter=""> The [Geometry] singleton. </member> + <member name="GodotSharp" type="GodotSharp" setter="" getter=""> + The [GodotSharp] singleton. Only available when using Godot's Mono build. + </member> <member name="IP" type="IP" setter="" getter=""> The [IP] singleton. </member> @@ -1520,25 +1523,25 @@ Variable is of type [Array]. </constant> <constant name="TYPE_RAW_ARRAY" value="20" enum="Variant.Type"> - Variable is of type [PoolByteArray]. + Variable is of type [PackedByteArray]. </constant> <constant name="TYPE_INT_ARRAY" value="21" enum="Variant.Type"> - Variable is of type [PoolIntArray]. + Variable is of type [PackedIntArray]. </constant> <constant name="TYPE_REAL_ARRAY" value="22" enum="Variant.Type"> - Variable is of type [PoolRealArray]. + Variable is of type [PackedRealArray]. </constant> <constant name="TYPE_STRING_ARRAY" value="23" enum="Variant.Type"> - Variable is of type [PoolStringArray]. + Variable is of type [PackedStringArray]. </constant> <constant name="TYPE_VECTOR2_ARRAY" value="24" enum="Variant.Type"> - Variable is of type [PoolVector2Array]. + Variable is of type [PackedVector2Array]. </constant> <constant name="TYPE_VECTOR3_ARRAY" value="25" enum="Variant.Type"> - Variable is of type [PoolVector3Array]. + Variable is of type [PackedVector3Array]. </constant> <constant name="TYPE_COLOR_ARRAY" value="26" enum="Variant.Type"> - Variable is of type [PoolColorArray]. + Variable is of type [PackedColorArray]. </constant> <constant name="TYPE_MAX" value="27" enum="Variant.Type"> Represents the size of the [enum Variant.Type] enum. diff --git a/doc/classes/AStar.xml b/doc/classes/AStar.xml index ccbb033444..d175aa6f45 100644 --- a/doc/classes/AStar.xml +++ b/doc/classes/AStar.xml @@ -152,7 +152,7 @@ </description> </method> <method name="get_id_path"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="from_id" type="int"> </argument> @@ -185,7 +185,7 @@ </description> </method> <method name="get_point_connections"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="id" type="int"> </argument> @@ -213,7 +213,7 @@ </description> </method> <method name="get_point_path"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> <argument index="0" name="from_id" type="int"> </argument> diff --git a/doc/classes/AStar2D.xml b/doc/classes/AStar2D.xml index d620ef2a79..af1fb3e273 100644 --- a/doc/classes/AStar2D.xml +++ b/doc/classes/AStar2D.xml @@ -111,7 +111,7 @@ </description> </method> <method name="get_id_path"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="from_id" type="int"> </argument> @@ -144,7 +144,7 @@ </description> </method> <method name="get_point_connections"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="id" type="int"> </argument> @@ -172,7 +172,7 @@ </description> </method> <method name="get_point_path"> - <return type="PoolVector2Array"> + <return type="PackedVector2Array"> </return> <argument index="0" name="from_id" type="int"> </argument> diff --git a/doc/classes/Animation.xml b/doc/classes/Animation.xml index f77dfdc9a1..46b0b952b6 100644 --- a/doc/classes/Animation.xml +++ b/doc/classes/Animation.xml @@ -274,7 +274,7 @@ </description> </method> <method name="method_track_get_key_indices" qualifiers="const"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="track_idx" type="int"> </argument> @@ -627,7 +627,7 @@ </description> </method> <method name="value_track_get_key_indices" qualifiers="const"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="track_idx" type="int"> </argument> diff --git a/doc/classes/AnimationNodeStateMachinePlayback.xml b/doc/classes/AnimationNodeStateMachinePlayback.xml index 0198237bed..b75ff04329 100644 --- a/doc/classes/AnimationNodeStateMachinePlayback.xml +++ b/doc/classes/AnimationNodeStateMachinePlayback.xml @@ -23,7 +23,7 @@ </description> </method> <method name="get_travel_path" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Returns the current travel path as computed internally by the A* algorithm. diff --git a/doc/classes/AnimationPlayer.xml b/doc/classes/AnimationPlayer.xml index 3e8315f686..cedfca4c31 100644 --- a/doc/classes/AnimationPlayer.xml +++ b/doc/classes/AnimationPlayer.xml @@ -86,7 +86,7 @@ </description> </method> <method name="get_animation_list" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Returns the list of stored animation names. @@ -111,7 +111,7 @@ </description> </method> <method name="get_queue"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Returns a list of the animation names that are currently queued to play. diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index 08455bb7bc..6c3e9e8fed 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -22,64 +22,64 @@ <method name="Array"> <return type="Array"> </return> - <argument index="0" name="from" type="PoolColorArray"> + <argument index="0" name="from" type="PackedColorArray"> </argument> <description> - Constructs an array from a [PoolColorArray]. + Constructs an array from a [PackedColorArray]. </description> </method> <method name="Array"> <return type="Array"> </return> - <argument index="0" name="from" type="PoolVector3Array"> + <argument index="0" name="from" type="PackedVector3Array"> </argument> <description> - Constructs an array from a [PoolVector3Array]. + Constructs an array from a [PackedVector3Array]. </description> </method> <method name="Array"> <return type="Array"> </return> - <argument index="0" name="from" type="PoolVector2Array"> + <argument index="0" name="from" type="PackedVector2Array"> </argument> <description> - Constructs an array from a [PoolVector2Array]. + Constructs an array from a [PackedVector2Array]. </description> </method> <method name="Array"> <return type="Array"> </return> - <argument index="0" name="from" type="PoolStringArray"> + <argument index="0" name="from" type="PackedStringArray"> </argument> <description> - Constructs an array from a [PoolStringArray]. + Constructs an array from a [PackedStringArray]. </description> </method> <method name="Array"> <return type="Array"> </return> - <argument index="0" name="from" type="PoolRealArray"> + <argument index="0" name="from" type="PackedRealArray"> </argument> <description> - Constructs an array from a [PoolRealArray]. + Constructs an array from a [PackedRealArray]. </description> </method> <method name="Array"> <return type="Array"> </return> - <argument index="0" name="from" type="PoolIntArray"> + <argument index="0" name="from" type="PackedIntArray"> </argument> <description> - Constructs an array from a [PoolIntArray]. + Constructs an array from a [PackedIntArray]. </description> </method> <method name="Array"> <return type="Array"> </return> - <argument index="0" name="from" type="PoolByteArray"> + <argument index="0" name="from" type="PackedByteArray"> </argument> <description> - Constructs an array from a [PoolByteArray]. + Constructs an array from a [PackedByteArray]. </description> </method> <method name="append"> diff --git a/doc/classes/ArrayMesh.xml b/doc/classes/ArrayMesh.xml index 2dbf55e522..857897dab4 100644 --- a/doc/classes/ArrayMesh.xml +++ b/doc/classes/ArrayMesh.xml @@ -7,7 +7,7 @@ The [ArrayMesh] is used to construct a [Mesh] by specifying the attributes as arrays. The most basic example is the creation of a single triangle: [codeblock] - var vertices = PoolVector3Array() + var vertices = PackedVector3Array() vertices.push_back(Vector3(0, 1, 0)) vertices.push_back(Vector3(1, 0, 0)) vertices.push_back(Vector3(0, 0, 1)) @@ -178,7 +178,7 @@ </argument> <argument index="1" name="offset" type="int"> </argument> - <argument index="2" name="data" type="PoolByteArray"> + <argument index="2" name="data" type="PackedByteArray"> </argument> <description> Updates a specified region of mesh arrays on the GPU. @@ -202,31 +202,31 @@ Amount of weights/bone indices per vertex (always 4). </constant> <constant name="ARRAY_VERTEX" value="0" enum="ArrayType"> - [PoolVector3Array], [PoolVector2Array], or [Array] of vertex positions. + [PackedVector3Array], [PackedVector2Array], or [Array] of vertex positions. </constant> <constant name="ARRAY_NORMAL" value="1" enum="ArrayType"> - [PoolVector3Array] of vertex normals. + [PackedVector3Array] of vertex normals. </constant> <constant name="ARRAY_TANGENT" value="2" enum="ArrayType"> - [PoolRealArray] of vertex tangents. Each element in groups of 4 floats, first 3 floats determine the tangent, and the last the binormal direction as -1 or 1. + [PackedRealArray] of vertex tangents. Each element in groups of 4 floats, first 3 floats determine the tangent, and the last the binormal direction as -1 or 1. </constant> <constant name="ARRAY_COLOR" value="3" enum="ArrayType"> - [PoolColorArray] of vertex colors. + [PackedColorArray] of vertex colors. </constant> <constant name="ARRAY_TEX_UV" value="4" enum="ArrayType"> - [PoolVector2Array] for UV coordinates. + [PackedVector2Array] for UV coordinates. </constant> <constant name="ARRAY_TEX_UV2" value="5" enum="ArrayType"> - [PoolVector2Array] for second UV coordinates. + [PackedVector2Array] for second UV coordinates. </constant> <constant name="ARRAY_BONES" value="6" enum="ArrayType"> - [PoolRealArray] or [PoolIntArray] of bone indices. Each element in groups of 4 floats. + [PackedRealArray] or [PackedIntArray] of bone indices. Each element in groups of 4 floats. </constant> <constant name="ARRAY_WEIGHTS" value="7" enum="ArrayType"> - [PoolRealArray] of bone weights. Each element in groups of 4 floats. + [PackedRealArray] of bone weights. Each element in groups of 4 floats. </constant> <constant name="ARRAY_INDEX" value="8" enum="ArrayType"> - [PoolIntArray] of integers used as indices referencing vertices, colors, normals, tangents, and textures. All of those arrays must have the same number of elements as the vertex array. No index can be beyond the vertex array size. When this index array is present, it puts the function into "index mode," where the index selects the *i*'th vertex, normal, tangent, color, UV, etc. This means if you want to have different normals or colors along an edge, you have to duplicate the vertices. + [PackedIntArray] of integers used as indices referencing vertices, colors, normals, tangents, and textures. All of those arrays must have the same number of elements as the vertex array. No index can be beyond the vertex array size. When this index array is present, it puts the function into "index mode," where the index selects the *i*'th vertex, normal, tangent, color, UV, etc. This means if you want to have different normals or colors along an edge, you have to duplicate the vertices. For triangles, the index array is interpreted as triples, referring to the vertices of each triangle. For lines, the index array is in pairs indicating the start and end of each line. </constant> <constant name="ARRAY_MAX" value="9" enum="ArrayType"> diff --git a/doc/classes/AudioStreamGeneratorPlayback.xml b/doc/classes/AudioStreamGeneratorPlayback.xml index 2552cd50a4..e3e17b8a93 100644 --- a/doc/classes/AudioStreamGeneratorPlayback.xml +++ b/doc/classes/AudioStreamGeneratorPlayback.xml @@ -37,7 +37,7 @@ <method name="push_buffer"> <return type="bool"> </return> - <argument index="0" name="frames" type="PoolVector2Array"> + <argument index="0" name="frames" type="PackedVector2Array"> </argument> <description> </description> diff --git a/doc/classes/AudioStreamSample.xml b/doc/classes/AudioStreamSample.xml index 898879ae27..6d99433c90 100644 --- a/doc/classes/AudioStreamSample.xml +++ b/doc/classes/AudioStreamSample.xml @@ -22,7 +22,7 @@ </method> </methods> <members> - <member name="data" type="PoolByteArray" setter="set_data" getter="get_data" default="PoolByteArray( )"> + <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray( )"> Contains the audio data in bytes. [b]Note:[/b] This property expects signed PCM8 data. To convert unsigned PCM8 to signed PCM8, subtract 128 from each byte. </member> diff --git a/doc/classes/CPUParticles.xml b/doc/classes/CPUParticles.xml index b9cc655784..6a6525e99a 100644 --- a/doc/classes/CPUParticles.xml +++ b/doc/classes/CPUParticles.xml @@ -171,13 +171,13 @@ <member name="emission_box_extents" type="Vector3" setter="set_emission_box_extents" getter="get_emission_box_extents"> The rectangle's extents if [member emission_shape] is set to [constant EMISSION_SHAPE_BOX]. </member> - <member name="emission_colors" type="PoolColorArray" setter="set_emission_colors" getter="get_emission_colors" default="PoolColorArray( )"> + <member name="emission_colors" type="PackedColorArray" setter="set_emission_colors" getter="get_emission_colors" default="PackedColorArray( )"> Sets the [Color]s to modulate particles by when using [constant EMISSION_SHAPE_POINTS] or [constant EMISSION_SHAPE_DIRECTED_POINTS]. </member> - <member name="emission_normals" type="PoolVector3Array" setter="set_emission_normals" getter="get_emission_normals"> + <member name="emission_normals" type="PackedVector3Array" setter="set_emission_normals" getter="get_emission_normals"> Sets the direction the particles will be emitted in when using [constant EMISSION_SHAPE_DIRECTED_POINTS]. </member> - <member name="emission_points" type="PoolVector3Array" setter="set_emission_points" getter="get_emission_points" default="PoolVector3Array( )"> + <member name="emission_points" type="PackedVector3Array" setter="set_emission_points" getter="get_emission_points" default="PackedVector3Array( )"> Sets the initial positions to spawn particles when using [constant EMISSION_SHAPE_POINTS] or [constant EMISSION_SHAPE_DIRECTED_POINTS]. </member> <member name="emission_shape" type="int" setter="set_emission_shape" getter="get_emission_shape" enum="CPUParticles.EmissionShape" default="0"> diff --git a/doc/classes/CPUParticles2D.xml b/doc/classes/CPUParticles2D.xml index 926b8e461c..799ba32075 100644 --- a/doc/classes/CPUParticles2D.xml +++ b/doc/classes/CPUParticles2D.xml @@ -169,13 +169,13 @@ <member name="draw_order" type="int" setter="set_draw_order" getter="get_draw_order" enum="CPUParticles2D.DrawOrder" default="0"> Particle draw order. Uses [enum DrawOrder] values. </member> - <member name="emission_colors" type="PoolColorArray" setter="set_emission_colors" getter="get_emission_colors"> + <member name="emission_colors" type="PackedColorArray" setter="set_emission_colors" getter="get_emission_colors"> Sets the [Color]s to modulate particles by when using [constant EMISSION_SHAPE_POINTS] or [constant EMISSION_SHAPE_DIRECTED_POINTS]. </member> - <member name="emission_normals" type="PoolVector2Array" setter="set_emission_normals" getter="get_emission_normals"> + <member name="emission_normals" type="PackedVector2Array" setter="set_emission_normals" getter="get_emission_normals"> Sets the direction the particles will be emitted in when using [constant EMISSION_SHAPE_DIRECTED_POINTS]. </member> - <member name="emission_points" type="PoolVector2Array" setter="set_emission_points" getter="get_emission_points"> + <member name="emission_points" type="PackedVector2Array" setter="set_emission_points" getter="get_emission_points"> Sets the initial positions to spawn particles when using [constant EMISSION_SHAPE_POINTS] or [constant EMISSION_SHAPE_DIRECTED_POINTS]. </member> <member name="emission_rect_extents" type="Vector2" setter="set_emission_rect_extents" getter="get_emission_rect_extents"> diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml index 7f50587e66..aed02e27e7 100644 --- a/doc/classes/CanvasItem.xml +++ b/doc/classes/CanvasItem.xml @@ -76,11 +76,11 @@ <method name="draw_colored_polygon"> <return type="void"> </return> - <argument index="0" name="points" type="PoolVector2Array"> + <argument index="0" name="points" type="PackedVector2Array"> </argument> <argument index="1" name="color" type="Color"> </argument> - <argument index="2" name="uvs" type="PoolVector2Array" default="PoolVector2Array( )"> + <argument index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array( )"> </argument> <argument index="3" name="texture" type="Texture2D" default="null"> </argument> @@ -88,7 +88,7 @@ </argument> <argument index="5" name="specular_map" type="Texture2D" default="null"> </argument> - <argument index="6" name="specular_shinness" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="6" name="specular_shininess" type="Color" default="Color( 1, 1, 1, 1 )"> </argument> <argument index="7" name="texture_filter" type="int" enum="CanvasItem.TextureFilter" default="0"> </argument> @@ -118,17 +118,17 @@ </return> <argument index="0" name="mesh" type="Mesh"> </argument> - <argument index="1" name="texture" type="Texture2D" default="null"> + <argument index="1" name="texture" type="Texture2D"> </argument> <argument index="2" name="normal_map" type="Texture2D" default="null"> </argument> - <argument index="3" name="specular_map" type="Texture2D" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="specular_map" type="Texture2D" default="null"> </argument> - <argument index="4" name="transform" type="Color" default="Transform2D( 1, 0, 0, 1, 0, 0 )"> + <argument index="4" name="specular_shininess" type="Color" default="Color( 1, 1, 1, 1 )"> </argument> - <argument index="5" name="modulate" type="Transform2D" default="Color( 1, 1, 1, 1 )"> + <argument index="5" name="transform" type="Transform2D" default="Transform2D( 1, 0, 0, 1, 0, 0 )"> </argument> - <argument index="6" name="specular_shinness" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="6" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> </argument> <argument index="7" name="texture_filter" type="int" enum="CanvasItem.TextureFilter" default="0"> </argument> @@ -141,7 +141,7 @@ <method name="draw_multiline"> <return type="void"> </return> - <argument index="0" name="points" type="PoolVector2Array"> + <argument index="0" name="points" type="PackedVector2Array"> </argument> <argument index="1" name="color" type="Color"> </argument> @@ -154,9 +154,9 @@ <method name="draw_multiline_colors"> <return type="void"> </return> - <argument index="0" name="points" type="PoolVector2Array"> + <argument index="0" name="points" type="PackedVector2Array"> </argument> - <argument index="1" name="colors" type="PoolColorArray"> + <argument index="1" name="colors" type="PackedColorArray"> </argument> <argument index="2" name="width" type="float" default="1.0"> </argument> @@ -169,13 +169,13 @@ </return> <argument index="0" name="multimesh" type="MultiMesh"> </argument> - <argument index="1" name="texture" type="Texture2D" default="null"> + <argument index="1" name="texture" type="Texture2D"> </argument> <argument index="2" name="normal_map" type="Texture2D" default="null"> </argument> <argument index="3" name="specular_map" type="Texture2D" default="null"> </argument> - <argument index="4" name="specular_shinness" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="4" name="specular_shininess" type="Color" default="Color( 1, 1, 1, 1 )"> </argument> <argument index="5" name="texture_filter" type="int" enum="CanvasItem.TextureFilter" default="0"> </argument> @@ -188,11 +188,11 @@ <method name="draw_polygon"> <return type="void"> </return> - <argument index="0" name="points" type="PoolVector2Array"> + <argument index="0" name="points" type="PackedVector2Array"> </argument> - <argument index="1" name="colors" type="PoolColorArray"> + <argument index="1" name="colors" type="PackedColorArray"> </argument> - <argument index="2" name="uvs" type="PoolVector2Array" default="PoolVector2Array( )"> + <argument index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array( )"> </argument> <argument index="3" name="texture" type="Texture2D" default="null"> </argument> @@ -200,7 +200,7 @@ </argument> <argument index="5" name="specular_map" type="Texture2D" default="null"> </argument> - <argument index="6" name="specular_shinness" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="6" name="specular_shininess" type="Color" default="Color( 1, 1, 1, 1 )"> </argument> <argument index="7" name="texture_filter" type="int" enum="CanvasItem.TextureFilter" default="0"> </argument> @@ -213,7 +213,7 @@ <method name="draw_polyline"> <return type="void"> </return> - <argument index="0" name="points" type="PoolVector2Array"> + <argument index="0" name="points" type="PackedVector2Array"> </argument> <argument index="1" name="color" type="Color"> </argument> @@ -226,9 +226,9 @@ <method name="draw_polyline_colors"> <return type="void"> </return> - <argument index="0" name="points" type="PoolVector2Array"> + <argument index="0" name="points" type="PackedVector2Array"> </argument> - <argument index="1" name="colors" type="PoolColorArray"> + <argument index="1" name="colors" type="PackedColorArray"> </argument> <argument index="2" name="width" type="float" default="1.0"> </argument> @@ -239,11 +239,11 @@ <method name="draw_primitive"> <return type="void"> </return> - <argument index="0" name="points" type="PoolVector2Array"> + <argument index="0" name="points" type="PackedVector2Array"> </argument> - <argument index="1" name="colors" type="PoolColorArray"> + <argument index="1" name="colors" type="PackedColorArray"> </argument> - <argument index="2" name="uvs" type="PoolVector2Array"> + <argument index="2" name="uvs" type="PackedVector2Array"> </argument> <argument index="3" name="texture" type="Texture2D" default="null"> </argument> @@ -253,7 +253,7 @@ </argument> <argument index="6" name="specular_map" type="Texture2D" default="null"> </argument> - <argument index="7" name="specular_shinness" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="7" name="specular_shininess" type="Color" default="Color( 1, 1, 1, 1 )"> </argument> <argument index="8" name="texture_filter" type="int" enum="CanvasItem.TextureFilter" default="0"> </argument> @@ -342,7 +342,7 @@ </argument> <argument index="4" name="specular_map" type="Texture2D" default="null"> </argument> - <argument index="5" name="specular_shinness" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="5" name="specular_shininess" type="Color" default="Color( 1, 1, 1, 1 )"> </argument> <argument index="6" name="texture_filter" type="int" enum="CanvasItem.TextureFilter" default="0"> </argument> @@ -369,7 +369,7 @@ </argument> <argument index="6" name="specular_map" type="Texture2D" default="null"> </argument> - <argument index="7" name="specular_shinness" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="7" name="specular_shininess" type="Color" default="Color( 1, 1, 1, 1 )"> </argument> <argument index="8" name="texture_filter" type="int" enum="CanvasItem.TextureFilter" default="0"> </argument> @@ -396,9 +396,9 @@ </argument> <argument index="6" name="specular_map" type="Texture2D" default="null"> </argument> - <argument index="7" name="clip_uv" type="Color" default="true"> + <argument index="7" name="specular_shininess" type="Color" default="Color( 1, 1, 1, 1 )"> </argument> - <argument index="8" name="specular_shinness" type="bool" default="Color( 1, 1, 1, 1 )"> + <argument index="8" name="clip_uv" type="bool" default="true"> </argument> <argument index="9" name="texture_filter" type="int" enum="CanvasItem.TextureFilter" default="0"> </argument> diff --git a/doc/classes/ClassDB.xml b/doc/classes/ClassDB.xml index 4d7ccb65e8..a0f13494af 100644 --- a/doc/classes/ClassDB.xml +++ b/doc/classes/ClassDB.xml @@ -48,7 +48,7 @@ </description> </method> <method name="class_get_integer_constant_list" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="class" type="String"> </argument> @@ -162,14 +162,14 @@ </description> </method> <method name="get_class_list" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Returns the names of all the classes available. </description> </method> <method name="get_inheriters_from_class" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="class" type="String"> </argument> diff --git a/doc/classes/CollisionPolygon.xml b/doc/classes/CollisionPolygon.xml index ac519d3817..8aceec17a8 100644 --- a/doc/classes/CollisionPolygon.xml +++ b/doc/classes/CollisionPolygon.xml @@ -17,7 +17,7 @@ <member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" default="false"> If [code]true[/code], no collision will be produced. </member> - <member name="polygon" type="PoolVector2Array" setter="set_polygon" getter="get_polygon" default="PoolVector2Array( )"> + <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( )"> Array of vertices which define the polygon. [b]Note:[/b] The returned value is a copy of the original. Methods which mutate the size or properties of the return value will not impact the original polygon. To change properties of the polygon, assign it to a temporary variable and make changes before reassigning the [code]polygon[/code] member. </member> diff --git a/doc/classes/CollisionPolygon2D.xml b/doc/classes/CollisionPolygon2D.xml index c4fd417918..e3135a4d0f 100644 --- a/doc/classes/CollisionPolygon2D.xml +++ b/doc/classes/CollisionPolygon2D.xml @@ -22,8 +22,8 @@ </member> <member name="one_way_collision_margin" type="float" setter="set_one_way_collision_margin" getter="get_one_way_collision_margin" default="1.0"> </member> - <member name="polygon" type="PoolVector2Array" setter="set_polygon" getter="get_polygon" default="PoolVector2Array( )"> - The polygon's list of vertices. The final point will be connected to the first. The returned value is a clone of the [PoolVector2Array], not a reference. + <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( )"> + The polygon's list of vertices. The final point will be connected to the first. The returned value is a clone of the [PackedVector2Array], not a reference. </member> </members> <constants> diff --git a/doc/classes/ColorPicker.xml b/doc/classes/ColorPicker.xml index d0c8e3f948..0805a87d18 100644 --- a/doc/classes/ColorPicker.xml +++ b/doc/classes/ColorPicker.xml @@ -29,7 +29,7 @@ </description> </method> <method name="get_presets" qualifiers="const"> - <return type="PoolColorArray"> + <return type="PackedColorArray"> </return> <description> Returns the list of colors in the presets of the color picker. diff --git a/doc/classes/ConcavePolygonShape.xml b/doc/classes/ConcavePolygonShape.xml index 3ae07ee52f..21f2f681b9 100644 --- a/doc/classes/ConcavePolygonShape.xml +++ b/doc/classes/ConcavePolygonShape.xml @@ -10,7 +10,7 @@ </tutorials> <methods> <method name="get_faces" qualifiers="const"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> <description> Returns the faces (an array of triangles). @@ -19,7 +19,7 @@ <method name="set_faces"> <return type="void"> </return> - <argument index="0" name="faces" type="PoolVector3Array"> + <argument index="0" name="faces" type="PackedVector3Array"> </argument> <description> Sets the faces (an array of triangles). diff --git a/doc/classes/ConcavePolygonShape2D.xml b/doc/classes/ConcavePolygonShape2D.xml index 6fb32436a8..9999d086da 100644 --- a/doc/classes/ConcavePolygonShape2D.xml +++ b/doc/classes/ConcavePolygonShape2D.xml @@ -12,7 +12,7 @@ <methods> </methods> <members> - <member name="segments" type="PoolVector2Array" setter="set_segments" getter="get_segments" default="PoolVector2Array( )"> + <member name="segments" type="PackedVector2Array" setter="set_segments" getter="get_segments" default="PackedVector2Array( )"> The array of points that make up the [ConcavePolygonShape2D]'s line segments. </member> </members> diff --git a/doc/classes/ConfigFile.xml b/doc/classes/ConfigFile.xml index ad36f1f1c3..00d98130f3 100644 --- a/doc/classes/ConfigFile.xml +++ b/doc/classes/ConfigFile.xml @@ -51,7 +51,7 @@ </description> </method> <method name="get_section_keys" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="section" type="String"> </argument> @@ -60,7 +60,7 @@ </description> </method> <method name="get_sections" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Returns an array of all defined section identifiers. @@ -114,7 +114,7 @@ </return> <argument index="0" name="path" type="String"> </argument> - <argument index="1" name="key" type="PoolByteArray"> + <argument index="1" name="key" type="PackedByteArray"> </argument> <description> </description> @@ -154,7 +154,7 @@ </return> <argument index="0" name="path" type="String"> </argument> - <argument index="1" name="key" type="PoolByteArray"> + <argument index="1" name="key" type="PackedByteArray"> </argument> <description> </description> diff --git a/doc/classes/ConvexPolygonShape.xml b/doc/classes/ConvexPolygonShape.xml index 544f304051..077bb57a03 100644 --- a/doc/classes/ConvexPolygonShape.xml +++ b/doc/classes/ConvexPolygonShape.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="points" type="PoolVector3Array" setter="set_points" getter="get_points" default="PoolVector3Array( )"> + <member name="points" type="PackedVector3Array" setter="set_points" getter="get_points" default="PackedVector3Array( )"> The list of 3D points forming the convex polygon shape. </member> </members> diff --git a/doc/classes/ConvexPolygonShape2D.xml b/doc/classes/ConvexPolygonShape2D.xml index e17048e061..cba446fff8 100644 --- a/doc/classes/ConvexPolygonShape2D.xml +++ b/doc/classes/ConvexPolygonShape2D.xml @@ -13,7 +13,7 @@ <method name="set_point_cloud"> <return type="void"> </return> - <argument index="0" name="point_cloud" type="PoolVector2Array"> + <argument index="0" name="point_cloud" type="PackedVector2Array"> </argument> <description> Based on the set of points provided, this creates and assigns the [member points] property using the convex hull algorithm. Removing all unneeded points. See [method Geometry.convex_hull_2d] for details. @@ -21,7 +21,7 @@ </method> </methods> <members> - <member name="points" type="PoolVector2Array" setter="set_points" getter="get_points" default="PoolVector2Array( )"> + <member name="points" type="PackedVector2Array" setter="set_points" getter="get_points" default="PackedVector2Array( )"> The polygon's list of vertices. Can be in either clockwise or counterclockwise order. </member> </members> diff --git a/doc/classes/Crypto.xml b/doc/classes/Crypto.xml index fb373145f9..10f1f18f0d 100644 --- a/doc/classes/Crypto.xml +++ b/doc/classes/Crypto.xml @@ -28,12 +28,12 @@ </tutorials> <methods> <method name="generate_random_bytes"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <argument index="0" name="size" type="int"> </argument> <description> - Generates a [PoolByteArray] of cryptographically secure random bytes with given [code]size[/code]. + Generates a [PackedByteArray] of cryptographically secure random bytes with given [code]size[/code]. </description> </method> <method name="generate_rsa"> diff --git a/doc/classes/Curve2D.xml b/doc/classes/Curve2D.xml index f6eacfb33b..8ac6258e97 100644 --- a/doc/classes/Curve2D.xml +++ b/doc/classes/Curve2D.xml @@ -41,10 +41,10 @@ </description> </method> <method name="get_baked_points" qualifiers="const"> - <return type="PoolVector2Array"> + <return type="PackedVector2Array"> </return> <description> - Returns the cache of points as a [PoolVector2Array]. + Returns the cache of points as a [PackedVector2Array]. </description> </method> <method name="get_closest_offset" qualifiers="const"> @@ -178,7 +178,7 @@ </description> </method> <method name="tessellate" qualifiers="const"> - <return type="PoolVector2Array"> + <return type="PackedVector2Array"> </return> <argument index="0" name="max_stages" type="int" default="5"> </argument> diff --git a/doc/classes/Curve3D.xml b/doc/classes/Curve3D.xml index 52b0052908..c5345c8025 100644 --- a/doc/classes/Curve3D.xml +++ b/doc/classes/Curve3D.xml @@ -41,24 +41,24 @@ </description> </method> <method name="get_baked_points" qualifiers="const"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> <description> - Returns the cache of points as a [PoolVector3Array]. + Returns the cache of points as a [PackedVector3Array]. </description> </method> <method name="get_baked_tilts" qualifiers="const"> - <return type="PoolRealArray"> + <return type="PackedRealArray"> </return> <description> - Returns the cache of tilts as a [PoolRealArray]. + Returns the cache of tilts as a [PackedRealArray]. </description> </method> <method name="get_baked_up_vectors" qualifiers="const"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> <description> - Returns the cache of up vectors as a [PoolVector3Array]. + Returns the cache of up vectors as a [PackedVector3Array]. If [member up_vector_enabled] is [code]false[/code], the cache will be empty. </description> </method> @@ -227,7 +227,7 @@ </description> </method> <method name="tessellate" qualifiers="const"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> <argument index="0" name="max_stages" type="int" default="5"> </argument> diff --git a/doc/classes/DTLSServer.xml b/doc/classes/DTLSServer.xml new file mode 100644 index 0000000000..8c05f30550 --- /dev/null +++ b/doc/classes/DTLSServer.xml @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="DTLSServer" inherits="Reference" version="4.0"> + <brief_description> + Helper class to implement a DTLS server. + </brief_description> + <description> + This class is used to store the state of a DTLS server. Upon [method setup] it converts connected [PacketPeerUDP] to [PacketPeerDTLS] accepting them via [method take_connection] as DTLS clients. Under the hood, this class is used to store the DTLS state and cookies of the server. The reason of why the state and cookies are needed is outside of the scope of this documentation. + Below a small example of how to use it: + [codeblock] + # server.gd + extends Node + + var dtls := DTLSServer.new() + var server := UDPServer.new() + var peers = [] + + func _ready(): + server.listen(4242) + var key = load("key.key") # Your private key. + var cert = load("cert.crt") # Your X509 certificate. + dtls.setup(key, cert) + + func _process(delta): + while server.is_connection_available(): + var peer : PacketPeerUDP = server.take_connection() + var dtls_peer : PacketPeerDTLS = dtls.take_connection(peer) + if dtls_peer.get_status() != PacketPeerDTLS.STATUS_HANDSHAKING: + continue # It is normal that 50% of the connections fails due to cookie exchange. + print("Peer connected!") + peers.append(dtls_peer) + for p in peers: + p.poll() # Must poll to update the state. + if p.get_status() == PacketPeerDTLS.STATUS_CONNECTED: + while p.get_available_packet_count() > 0: + print("Received message from client: %s" % p.get_packet().get_string_from_utf8()) + p.put_packet("Hello DTLS client".to_utf8()) + [/codeblock] + [codeblock] + # client.gd + extends Node + + var dtls := PacketPeerDTLS.new() + var udp := PacketPeerUDP.new() + var connected = false + + func _ready(): + udp.connect_to_host("127.0.0.1", 4242) + dtls.connect_to_peer(udp, false) # Use true in production for certificate validation! + + func _process(delta): + dtls.poll() + if dtls.get_status() == PacketPeerDTLS.STATUS_CONNECTED: + if !connected: + # Try to contact server + dtls.put_packet("The answer is... 42!".to_utf8()) + while dtls.get_available_packet_count() > 0: + print("Connected: %s" % dtls.get_packet().get_string_from_utf8()) + connected = true + [/codeblock] + </description> + <tutorials> + </tutorials> + <methods> + <method name="setup"> + <return type="int" enum="Error"> + </return> + <argument index="0" name="key" type="CryptoKey"> + </argument> + <argument index="1" name="certificate" type="X509Certificate"> + </argument> + <argument index="2" name="ca_chain" type="X509Certificate"> + </argument> + <description> + Setup the DTLS server to use the given [code]private_key[/code] and provide the given [code]certificate[/code] to clients. You can pass the optional [code]chain[/code] parameter to provide additional CA chain information along with the certificate. + </description> + </method> + <method name="take_connection"> + <return type="PacketPeerDTLS"> + </return> + <argument index="0" name="udp_peer" type="PacketPeerUDP"> + </argument> + <description> + Try to initiate the DTLS handshake with the given [code]udp_peer[/code] which must be already connected (see [method PacketPeerUDP.connect_to_host]). + [b]Note[/b]: You must check that the state of the return PacketPeerUDP is [constant PacketPeerDTLS.STATUS_HANDSHAKING], as it is normal that 50% of the new connections will be invalid due to cookie exchange. + </description> + </method> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/EditorExportPlugin.xml b/doc/classes/EditorExportPlugin.xml index 5de68cae71..da3840384e 100644 --- a/doc/classes/EditorExportPlugin.xml +++ b/doc/classes/EditorExportPlugin.xml @@ -10,7 +10,7 @@ <method name="_export_begin" qualifiers="virtual"> <return type="void"> </return> - <argument index="0" name="features" type="PoolStringArray"> + <argument index="0" name="features" type="PackedStringArray"> </argument> <argument index="1" name="is_debug" type="bool"> </argument> @@ -34,7 +34,7 @@ </argument> <argument index="1" name="type" type="String"> </argument> - <argument index="2" name="features" type="PoolStringArray"> + <argument index="2" name="features" type="PackedStringArray"> </argument> <description> </description> @@ -44,7 +44,7 @@ </return> <argument index="0" name="path" type="String"> </argument> - <argument index="1" name="file" type="PoolByteArray"> + <argument index="1" name="file" type="PackedByteArray"> </argument> <argument index="2" name="remap" type="bool"> </argument> @@ -96,7 +96,7 @@ </return> <argument index="0" name="path" type="String"> </argument> - <argument index="1" name="tags" type="PoolStringArray"> + <argument index="1" name="tags" type="PackedStringArray"> </argument> <description> </description> diff --git a/doc/classes/EditorFileDialog.xml b/doc/classes/EditorFileDialog.xml index 91adf6f2af..2afdfde064 100644 --- a/doc/classes/EditorFileDialog.xml +++ b/doc/classes/EditorFileDialog.xml @@ -84,7 +84,7 @@ </description> </signal> <signal name="files_selected"> - <argument index="0" name="paths" type="PoolStringArray"> + <argument index="0" name="paths" type="PackedStringArray"> </argument> <description> Emitted when multiple files are selected. diff --git a/doc/classes/EditorFileSystem.xml b/doc/classes/EditorFileSystem.xml index a05fbf2be7..a79c57e90f 100644 --- a/doc/classes/EditorFileSystem.xml +++ b/doc/classes/EditorFileSystem.xml @@ -85,14 +85,14 @@ </description> </signal> <signal name="resources_reimported"> - <argument index="0" name="resources" type="PoolStringArray"> + <argument index="0" name="resources" type="PackedStringArray"> </argument> <description> Remitted if a resource is reimported. </description> </signal> <signal name="resources_reload"> - <argument index="0" name="resources" type="PoolStringArray"> + <argument index="0" name="resources" type="PackedStringArray"> </argument> <description> </description> diff --git a/doc/classes/EditorInspectorPlugin.xml b/doc/classes/EditorInspectorPlugin.xml index eaddd9917c..3cc624f49b 100644 --- a/doc/classes/EditorInspectorPlugin.xml +++ b/doc/classes/EditorInspectorPlugin.xml @@ -40,7 +40,7 @@ </return> <argument index="0" name="label" type="String"> </argument> - <argument index="1" name="properties" type="PoolStringArray"> + <argument index="1" name="properties" type="PackedStringArray"> </argument> <argument index="2" name="editor" type="Control"> </argument> diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml index e441562051..d17fd0a661 100644 --- a/doc/classes/EditorPlugin.xml +++ b/doc/classes/EditorPlugin.xml @@ -253,7 +253,7 @@ </description> </method> <method name="get_breakpoints" qualifiers="virtual"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> This is for editors that edit script-based objects. You can return a list of breakpoints in the format ([code]script:line[/code]), for example: [code]res://path_to_script.gd:25[/code]. diff --git a/doc/classes/EditorProperty.xml b/doc/classes/EditorProperty.xml index b93274491a..338ebcd770 100644 --- a/doc/classes/EditorProperty.xml +++ b/doc/classes/EditorProperty.xml @@ -93,7 +93,7 @@ </members> <signals> <signal name="multiple_properties_changed"> - <argument index="0" name="properties" type="PoolStringArray"> + <argument index="0" name="properties" type="PackedStringArray"> </argument> <argument index="1" name="value" type="Array"> </argument> diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index 30fc1e0c7b..ace5f0f11b 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -50,7 +50,7 @@ </description> </method> <method name="get_favorites" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Gets the list of favorite files and directories for this project. @@ -76,7 +76,7 @@ </description> </method> <method name="get_recent_dirs" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Gets the list of recently visited folders in the file dialog for this project. @@ -126,7 +126,7 @@ <method name="set_favorites"> <return type="void"> </return> - <argument index="0" name="dirs" type="PoolStringArray"> + <argument index="0" name="dirs" type="PackedStringArray"> </argument> <description> Sets the list of favorite files and directories for this project. @@ -159,7 +159,7 @@ <method name="set_recent_dirs"> <return type="void"> </return> - <argument index="0" name="dirs" type="PoolStringArray"> + <argument index="0" name="dirs" type="PackedStringArray"> </argument> <description> Sets the list of recently visited folders in the file dialog for this project. diff --git a/doc/classes/EditorSpatialGizmo.xml b/doc/classes/EditorSpatialGizmo.xml index e7c5ca9c0f..b8c4daab07 100644 --- a/doc/classes/EditorSpatialGizmo.xml +++ b/doc/classes/EditorSpatialGizmo.xml @@ -12,7 +12,7 @@ <method name="add_collision_segments"> <return type="void"> </return> - <argument index="0" name="segments" type="PoolVector3Array"> + <argument index="0" name="segments" type="PackedVector3Array"> </argument> <description> </description> @@ -29,7 +29,7 @@ <method name="add_handles"> <return type="void"> </return> - <argument index="0" name="handles" type="PoolVector3Array"> + <argument index="0" name="handles" type="PackedVector3Array"> </argument> <argument index="1" name="material" type="Material"> </argument> @@ -45,7 +45,7 @@ <method name="add_lines"> <return type="void"> </return> - <argument index="0" name="lines" type="PoolVector3Array"> + <argument index="0" name="lines" type="PackedVector3Array"> </argument> <argument index="1" name="material" type="Material"> </argument> diff --git a/doc/classes/Expression.xml b/doc/classes/Expression.xml index b0a2802e43..fcd1aa43c0 100644 --- a/doc/classes/Expression.xml +++ b/doc/classes/Expression.xml @@ -59,7 +59,7 @@ </return> <argument index="0" name="expression" type="String"> </argument> - <argument index="1" name="input_names" type="PoolStringArray" default="PoolStringArray( )"> + <argument index="1" name="input_names" type="PackedStringArray" default="PackedStringArray( )"> </argument> <description> Parses the expression and returns an [enum Error] code. diff --git a/doc/classes/File.xml b/doc/classes/File.xml index 7fa87c2b60..e9477517cf 100644 --- a/doc/classes/File.xml +++ b/doc/classes/File.xml @@ -87,16 +87,16 @@ </description> </method> <method name="get_buffer" qualifiers="const"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <argument index="0" name="len" type="int"> </argument> <description> - Returns next [code]len[/code] bytes of the file as a [PoolByteArray]. + Returns next [code]len[/code] bytes of the file as a [PackedByteArray]. </description> </method> <method name="get_csv_line" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="delim" type="String" default="",""> </argument> @@ -252,7 +252,7 @@ </argument> <argument index="1" name="mode_flags" type="int" enum="File.ModeFlags"> </argument> - <argument index="2" name="key" type="PoolByteArray"> + <argument index="2" name="key" type="PackedByteArray"> </argument> <description> Opens an encrypted file in write or read mode. You need to pass a binary key to encrypt/decrypt it. @@ -329,7 +329,7 @@ <method name="store_buffer"> <return type="void"> </return> - <argument index="0" name="buffer" type="PoolByteArray"> + <argument index="0" name="buffer" type="PackedByteArray"> </argument> <description> Stores the given array of bytes in the file. @@ -338,12 +338,12 @@ <method name="store_csv_line"> <return type="void"> </return> - <argument index="0" name="values" type="PoolStringArray"> + <argument index="0" name="values" type="PackedStringArray"> </argument> <argument index="1" name="delim" type="String" default="",""> </argument> <description> - Store the given [PoolStringArray] in the file as a line formatted in the CSV (Comma-Separated Values) format. You can pass a different delimiter [code]delim[/code] to use other than the default [code]","[/code] (comma). This delimiter must be one-character long. + Store the given [PackedStringArray] in the file as a line formatted in the CSV (Comma-Separated Values) format. You can pass a different delimiter [code]delim[/code] to use other than the default [code]","[/code] (comma). This delimiter must be one-character long. Text will be encoded as UTF-8. </description> </method> diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index 37b5cec2c9..f2c65a8610 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -68,8 +68,8 @@ The currently selected file path of the file dialog. </member> <member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" override="true" default="false" /> - <member name="filters" type="PoolStringArray" setter="set_filters" getter="get_filters" default="PoolStringArray( )"> - The available file type filters. For example, this shows only [code].png[/code] and [code].gd[/code] files: [code]set_filters(PoolStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"]))[/code]. + <member name="filters" type="PackedStringArray" setter="set_filters" getter="get_filters" default="PackedStringArray( )"> + The available file type filters. For example, this shows only [code].png[/code] and [code].gd[/code] files: [code]set_filters(PackedStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"]))[/code]. </member> <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="FileDialog.Mode" default="4"> The dialog's open or save mode, which affects the selection behavior. See enum [code]Mode[/code] constants. @@ -98,7 +98,7 @@ </description> </signal> <signal name="files_selected"> - <argument index="0" name="paths" type="PoolStringArray"> + <argument index="0" name="paths" type="PackedStringArray"> </argument> <description> Emitted when the user selects multiple files. diff --git a/doc/classes/GIProbeData.xml b/doc/classes/GIProbeData.xml index d2918c24f7..3504d127b8 100644 --- a/doc/classes/GIProbeData.xml +++ b/doc/classes/GIProbeData.xml @@ -16,13 +16,13 @@ </argument> <argument index="2" name="octree_size" type="Vector3"> </argument> - <argument index="3" name="octree_cells" type="PoolByteArray"> + <argument index="3" name="octree_cells" type="PackedByteArray"> </argument> - <argument index="4" name="data_cells" type="PoolByteArray"> + <argument index="4" name="data_cells" type="PackedByteArray"> </argument> - <argument index="5" name="distance_field" type="PoolByteArray"> + <argument index="5" name="distance_field" type="PackedByteArray"> </argument> - <argument index="6" name="level_counts" type="PoolIntArray"> + <argument index="6" name="level_counts" type="PackedIntArray"> </argument> <description> </description> @@ -34,19 +34,19 @@ </description> </method> <method name="get_data_cells" qualifiers="const"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <description> </description> </method> <method name="get_level_counts" qualifiers="const"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <description> </description> </method> <method name="get_octree_cells" qualifiers="const"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <description> </description> diff --git a/doc/classes/Geometry.xml b/doc/classes/Geometry.xml index 739c860b28..9d4e0d0388 100644 --- a/doc/classes/Geometry.xml +++ b/doc/classes/Geometry.xml @@ -51,9 +51,9 @@ </description> </method> <method name="clip_polygon"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> - <argument index="0" name="points" type="PoolVector3Array"> + <argument index="0" name="points" type="PackedVector3Array"> </argument> <argument index="1" name="plane" type="Plane"> </argument> @@ -64,9 +64,9 @@ <method name="clip_polygons_2d"> <return type="Array"> </return> - <argument index="0" name="polygon_a" type="PoolVector2Array"> + <argument index="0" name="polygon_a" type="PackedVector2Array"> </argument> - <argument index="1" name="polygon_b" type="PoolVector2Array"> + <argument index="1" name="polygon_b" type="PackedVector2Array"> </argument> <description> Clips [code]polygon_a[/code] against [code]polygon_b[/code] and returns an array of clipped polygons. This performs [constant OPERATION_DIFFERENCE] between polygons. Returns an empty array if [code]polygon_b[/code] completely overlaps [code]polygon_a[/code]. @@ -76,18 +76,18 @@ <method name="clip_polyline_with_polygon_2d"> <return type="Array"> </return> - <argument index="0" name="polyline" type="PoolVector2Array"> + <argument index="0" name="polyline" type="PackedVector2Array"> </argument> - <argument index="1" name="polygon" type="PoolVector2Array"> + <argument index="1" name="polygon" type="PackedVector2Array"> </argument> <description> Clips [code]polyline[/code] against [code]polygon[/code] and returns an array of clipped polylines. This performs [constant OPERATION_DIFFERENCE] between the polyline and the polygon. This operation can be thought of as cutting a line with a closed shape. </description> </method> <method name="convex_hull_2d"> - <return type="PoolVector2Array"> + <return type="PackedVector2Array"> </return> - <argument index="0" name="points" type="PoolVector2Array"> + <argument index="0" name="points" type="PackedVector2Array"> </argument> <description> Given an array of [Vector2]s, returns the convex hull as a list of points in counterclockwise order. The last point is the same as the first one. @@ -96,9 +96,9 @@ <method name="exclude_polygons_2d"> <return type="Array"> </return> - <argument index="0" name="polygon_a" type="PoolVector2Array"> + <argument index="0" name="polygon_a" type="PackedVector2Array"> </argument> - <argument index="1" name="polygon_b" type="PoolVector2Array"> + <argument index="1" name="polygon_b" type="PackedVector2Array"> </argument> <description> Mutually excludes common area defined by intersection of [code]polygon_a[/code] and [code]polygon_b[/code] (see [method intersect_polygons_2d]) and returns an array of excluded polygons. This performs [constant OPERATION_XOR] between polygons. In other words, returns all but common area between polygons. @@ -158,7 +158,7 @@ </description> </method> <method name="get_closest_points_between_segments"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> <argument index="0" name="p1" type="Vector3"> </argument> @@ -169,11 +169,11 @@ <argument index="3" name="q2" type="Vector3"> </argument> <description> - Given the two 3D segments ([code]p1[/code], [code]p2[/code]) and ([code]q1[/code], [code]q2[/code]), finds those two points on the two segments that are closest to each other. Returns a [PoolVector3Array] that contains this point on ([code]p1[/code], [code]p2[/code]) as well the accompanying point on ([code]q1[/code], [code]q2[/code]). + Given the two 3D segments ([code]p1[/code], [code]p2[/code]) and ([code]q1[/code], [code]q2[/code]), finds those two points on the two segments that are closest to each other. Returns a [PackedVector3Array] that contains this point on ([code]p1[/code], [code]p2[/code]) as well the accompanying point on ([code]q1[/code], [code]q2[/code]). </description> </method> <method name="get_closest_points_between_segments_2d"> - <return type="PoolVector2Array"> + <return type="PackedVector2Array"> </return> <argument index="0" name="p1" type="Vector2"> </argument> @@ -184,7 +184,7 @@ <argument index="3" name="q2" type="Vector2"> </argument> <description> - Given the two 2D segments ([code]p1[/code], [code]p2[/code]) and ([code]q1[/code], [code]q2[/code]), finds those two points on the two segments that are closest to each other. Returns a [PoolVector2Array] that contains this point on ([code]p1[/code], [code]p2[/code]) as well the accompanying point on ([code]q1[/code], [code]q2[/code]). + Given the two 2D segments ([code]p1[/code], [code]p2[/code]) and ([code]q1[/code], [code]q2[/code]), finds those two points on the two segments that are closest to each other. Returns a [PackedVector2Array] that contains this point on ([code]p1[/code], [code]p2[/code]) as well the accompanying point on ([code]q1[/code], [code]q2[/code]). </description> </method> <method name="get_uv84_normal_bit"> @@ -199,9 +199,9 @@ <method name="intersect_polygons_2d"> <return type="Array"> </return> - <argument index="0" name="polygon_a" type="PoolVector2Array"> + <argument index="0" name="polygon_a" type="PackedVector2Array"> </argument> - <argument index="1" name="polygon_b" type="PoolVector2Array"> + <argument index="1" name="polygon_b" type="PackedVector2Array"> </argument> <description> Intersects [code]polygon_a[/code] with [code]polygon_b[/code] and returns an array of intersected polygons. This performs [constant OPERATION_INTERSECTION] between polygons. In other words, returns common area shared by polygons. Returns an empty array if no intersection occurs. @@ -211,9 +211,9 @@ <method name="intersect_polyline_with_polygon_2d"> <return type="Array"> </return> - <argument index="0" name="polyline" type="PoolVector2Array"> + <argument index="0" name="polyline" type="PackedVector2Array"> </argument> - <argument index="1" name="polygon" type="PoolVector2Array"> + <argument index="1" name="polygon" type="PackedVector2Array"> </argument> <description> Intersects [code]polyline[/code] with [code]polygon[/code] and returns an array of intersected polylines. This performs [constant OPERATION_INTERSECTION] between the polyline and the polygon. This operation can be thought of as chopping a line with a closed shape. @@ -237,7 +237,7 @@ </return> <argument index="0" name="point" type="Vector2"> </argument> - <argument index="1" name="polygon" type="PoolVector2Array"> + <argument index="1" name="polygon" type="PackedVector2Array"> </argument> <description> Returns [code]true[/code] if [code]point[/code] is inside [code]polygon[/code] or if it's located exactly [i]on[/i] polygon's boundary, otherwise returns [code]false[/code]. @@ -246,7 +246,7 @@ <method name="is_polygon_clockwise"> <return type="bool"> </return> - <argument index="0" name="polygon" type="PoolVector2Array"> + <argument index="0" name="polygon" type="PackedVector2Array"> </argument> <description> Returns [code]true[/code] if [code]polygon[/code]'s vertices are ordered in clockwise order, otherwise returns [code]false[/code]. @@ -271,7 +271,7 @@ <method name="make_atlas"> <return type="Dictionary"> </return> - <argument index="0" name="sizes" type="PoolVector2Array"> + <argument index="0" name="sizes" type="PackedVector2Array"> </argument> <description> Given an array of [Vector2]s representing tiles, builds an atlas. The returned dictionary has two keys: [code]points[/code] is a vector of [Vector2] that specifies the positions of each tile, [code]size[/code] contains the overall size of the whole atlas as [Vector2]. @@ -280,9 +280,9 @@ <method name="merge_polygons_2d"> <return type="Array"> </return> - <argument index="0" name="polygon_a" type="PoolVector2Array"> + <argument index="0" name="polygon_a" type="PackedVector2Array"> </argument> - <argument index="1" name="polygon_b" type="PoolVector2Array"> + <argument index="1" name="polygon_b" type="PackedVector2Array"> </argument> <description> Merges (combines) [code]polygon_a[/code] and [code]polygon_b[/code] and returns an array of merged polygons. This performs [constant OPERATION_UNION] between polygons. @@ -292,7 +292,7 @@ <method name="offset_polygon_2d"> <return type="Array"> </return> - <argument index="0" name="polygon" type="PoolVector2Array"> + <argument index="0" name="polygon" type="PackedVector2Array"> </argument> <argument index="1" name="delta" type="float"> </argument> @@ -307,7 +307,7 @@ <method name="offset_polyline_2d"> <return type="Array"> </return> - <argument index="0" name="polyline" type="PoolVector2Array"> + <argument index="0" name="polyline" type="PackedVector2Array"> </argument> <argument index="1" name="delta" type="float"> </argument> @@ -370,7 +370,7 @@ </description> </method> <method name="segment_intersects_convex"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> <argument index="0" name="from" type="Vector3"> </argument> @@ -379,11 +379,11 @@ <argument index="2" name="planes" type="Array"> </argument> <description> - Given a convex hull defined though the [Plane]s in the array [code]planes[/code], tests if the segment ([code]from[/code], [code]to[/code]) intersects with that hull. If an intersection is found, returns a [PoolVector3Array] containing the point the intersection and the hull's normal. If no intersecion is found, an the returned array is empty. + Given a convex hull defined though the [Plane]s in the array [code]planes[/code], tests if the segment ([code]from[/code], [code]to[/code]) intersects with that hull. If an intersection is found, returns a [PackedVector3Array] containing the point the intersection and the hull's normal. If no intersecion is found, an the returned array is empty. </description> </method> <method name="segment_intersects_cylinder"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> <argument index="0" name="from" type="Vector3"> </argument> @@ -394,7 +394,7 @@ <argument index="3" name="radius" type="float"> </argument> <description> - Checks if the segment ([code]from[/code], [code]to[/code]) intersects the cylinder with height [code]height[/code] that is centered at the origin and has radius [code]radius[/code]. If no, returns an empty [PoolVector3Array]. If an intersection takes place, the returned array contains the point of intersection and the cylinder's normal at the point of intersection. + Checks if the segment ([code]from[/code], [code]to[/code]) intersects the cylinder with height [code]height[/code] that is centered at the origin and has radius [code]radius[/code]. If no, returns an empty [PackedVector3Array]. If an intersection takes place, the returned array contains the point of intersection and the cylinder's normal at the point of intersection. </description> </method> <method name="segment_intersects_segment_2d"> @@ -413,7 +413,7 @@ </description> </method> <method name="segment_intersects_sphere"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> <argument index="0" name="from" type="Vector3"> </argument> @@ -424,7 +424,7 @@ <argument index="3" name="sphere_radius" type="float"> </argument> <description> - Checks if the segment ([code]from[/code], [code]to[/code]) intersects the sphere that is located at [code]sphere_position[/code] and has radius [code]sphere_radius[/code]. If no, returns an empty [PoolVector3Array]. If yes, returns a [PoolVector3Array] containing the point of intersection and the sphere's normal at the point of intersection. + Checks if the segment ([code]from[/code], [code]to[/code]) intersects the sphere that is located at [code]sphere_position[/code] and has radius [code]sphere_radius[/code]. If no, returns an empty [PackedVector3Array]. If yes, returns a [PackedVector3Array] containing the point of intersection and the sphere's normal at the point of intersection. </description> </method> <method name="segment_intersects_triangle"> @@ -445,21 +445,21 @@ </description> </method> <method name="triangulate_delaunay_2d"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> - <argument index="0" name="points" type="PoolVector2Array"> + <argument index="0" name="points" type="PackedVector2Array"> </argument> <description> - Triangulates the area specified by discrete set of [code]points[/code] such that no point is inside the circumcircle of any resulting triangle. Returns a [PoolIntArray] where each triangle consists of three consecutive point indices into [code]points[/code] (i.e. the returned array will have [code]n * 3[/code] elements, with [code]n[/code] being the number of found triangles). If the triangulation did not succeed, an empty [PoolIntArray] is returned. + Triangulates the area specified by discrete set of [code]points[/code] such that no point is inside the circumcircle of any resulting triangle. Returns a [PackedIntArray] where each triangle consists of three consecutive point indices into [code]points[/code] (i.e. the returned array will have [code]n * 3[/code] elements, with [code]n[/code] being the number of found triangles). If the triangulation did not succeed, an empty [PackedIntArray] is returned. </description> </method> <method name="triangulate_polygon"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> - <argument index="0" name="polygon" type="PoolVector2Array"> + <argument index="0" name="polygon" type="PackedVector2Array"> </argument> <description> - Triangulates the polygon specified by the points in [code]polygon[/code]. Returns a [PoolIntArray] where each triangle consists of three consecutive point indices into [code]polygon[/code] (i.e. the returned array will have [code]n * 3[/code] elements, with [code]n[/code] being the number of found triangles). If the triangulation did not succeed, an empty [PoolIntArray] is returned. + Triangulates the polygon specified by the points in [code]polygon[/code]. Returns a [PackedIntArray] where each triangle consists of three consecutive point indices into [code]polygon[/code] (i.e. the returned array will have [code]n * 3[/code] elements, with [code]n[/code] being the number of found triangles). If the triangulation did not succeed, an empty [PackedIntArray] is returned. </description> </method> </methods> diff --git a/doc/classes/Gradient.xml b/doc/classes/Gradient.xml index 3ce70045ef..12c87f9cff 100644 --- a/doc/classes/Gradient.xml +++ b/doc/classes/Gradient.xml @@ -87,11 +87,11 @@ </method> </methods> <members> - <member name="colors" type="PoolColorArray" setter="set_colors" getter="get_colors" default="PoolColorArray( 0, 0, 0, 1, 1, 1, 1, 1 )"> - Gradient's colors returned as a [PoolColorArray]. + <member name="colors" type="PackedColorArray" setter="set_colors" getter="get_colors" default="PackedColorArray( 0, 0, 0, 1, 1, 1, 1, 1 )"> + Gradient's colors returned as a [PackedColorArray]. </member> - <member name="offsets" type="PoolRealArray" setter="set_offsets" getter="get_offsets" default="PoolRealArray( 0, 1 )"> - Gradient's offsets returned as a [PoolRealArray]. + <member name="offsets" type="PackedRealArray" setter="set_offsets" getter="get_offsets" default="PackedRealArray( 0, 1 )"> + Gradient's offsets returned as a [PackedRealArray]. </member> </members> <constants> diff --git a/doc/classes/HTTPClient.xml b/doc/classes/HTTPClient.xml index bdcbb11ef0..76153ae041 100644 --- a/doc/classes/HTTPClient.xml +++ b/doc/classes/HTTPClient.xml @@ -55,7 +55,7 @@ </description> </method> <method name="get_response_headers"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Returns the response headers. @@ -124,7 +124,7 @@ </description> </method> <method name="read_response_body_chunk"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <description> Reads one chunk from the response. @@ -137,7 +137,7 @@ </argument> <argument index="1" name="url" type="String"> </argument> - <argument index="2" name="headers" type="PoolStringArray"> + <argument index="2" name="headers" type="PackedStringArray"> </argument> <argument index="3" name="body" type="String" default=""""> </argument> @@ -160,9 +160,9 @@ </argument> <argument index="1" name="url" type="String"> </argument> - <argument index="2" name="headers" type="PoolStringArray"> + <argument index="2" name="headers" type="PackedStringArray"> </argument> - <argument index="3" name="body" type="PoolByteArray"> + <argument index="3" name="body" type="PackedByteArray"> </argument> <description> Sends a raw request to the connected host. The URL parameter is just the part after the host, so for [code]http://somehost.com/index.php[/code], it is [code]index.php[/code]. diff --git a/doc/classes/HTTPRequest.xml b/doc/classes/HTTPRequest.xml index 313f21d8f9..53ca1fc6a9 100644 --- a/doc/classes/HTTPRequest.xml +++ b/doc/classes/HTTPRequest.xml @@ -96,7 +96,7 @@ </return> <argument index="0" name="url" type="String"> </argument> - <argument index="1" name="custom_headers" type="PoolStringArray" default="PoolStringArray( )"> + <argument index="1" name="custom_headers" type="PackedStringArray" default="PackedStringArray( )"> </argument> <argument index="2" name="ssl_validate_domain" type="bool" default="true"> </argument> @@ -136,9 +136,9 @@ </argument> <argument index="1" name="response_code" type="int"> </argument> - <argument index="2" name="headers" type="PoolStringArray"> + <argument index="2" name="headers" type="PackedStringArray"> </argument> - <argument index="3" name="body" type="PoolByteArray"> + <argument index="3" name="body" type="PackedByteArray"> </argument> <description> Emitted when a request is completed. diff --git a/doc/classes/HashingContext.xml b/doc/classes/HashingContext.xml index bc585df4a0..f8152c813e 100644 --- a/doc/classes/HashingContext.xml +++ b/doc/classes/HashingContext.xml @@ -33,7 +33,7 @@ </tutorials> <methods> <method name="finish"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <description> Closes the current context, and return the computed hash. @@ -51,7 +51,7 @@ <method name="update"> <return type="int" enum="Error"> </return> - <argument index="0" name="chunk" type="PoolByteArray"> + <argument index="0" name="chunk" type="PackedByteArray"> </argument> <description> Updates the computation with the given [code]chunk[/code] of data. diff --git a/doc/classes/HeightMapShape.xml b/doc/classes/HeightMapShape.xml index f94089066c..505961cd0c 100644 --- a/doc/classes/HeightMapShape.xml +++ b/doc/classes/HeightMapShape.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="map_data" type="PoolRealArray" setter="set_map_data" getter="get_map_data" default="PoolRealArray( 0, 0, 0, 0 )"> + <member name="map_data" type="PackedRealArray" setter="set_map_data" getter="get_map_data" default="PackedRealArray( 0, 0, 0, 0 )"> Height map data, pool array must be of [member map_width] * [member map_depth] size. </member> <member name="map_depth" type="int" setter="set_map_depth" getter="get_map_depth" default="2"> diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml index b4a46dd661..8bd2213194 100644 --- a/doc/classes/Image.xml +++ b/doc/classes/Image.xml @@ -150,7 +150,7 @@ </argument> <argument index="3" name="format" type="int" enum="Image.Format"> </argument> - <argument index="4" name="data" type="PoolByteArray"> + <argument index="4" name="data" type="PackedByteArray"> </argument> <description> Creates a new image of given size and format. See [enum Format] constants. Fills the image with the given raw data. If [code]use_mipmaps[/code] is [code]true[/code] then generate mipmaps for this image. See the [method generate_mipmaps]. @@ -236,7 +236,7 @@ </description> </method> <method name="get_data" qualifiers="const"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <description> Returns the image's raw data. @@ -273,7 +273,7 @@ <argument index="1" name="y" type="int"> </argument> <description> - Returns the color of the pixel at [code](x, y)[/code] if the image is locked. If the image is unlocked, it always returns a [Color] with the value [code](0, 0, 0, 1.0)[/code]. This is the same as [method get_pixelv], but two integer arguments instead of a Vector2 argument. + Returns the color of the pixel at [code](x, y)[/code]. This is the same as [method get_pixelv], but with two integer arguments instead of a [Vector2] argument. </description> </method> <method name="get_pixelv" qualifiers="const"> @@ -282,7 +282,7 @@ <argument index="0" name="src" type="Vector2"> </argument> <description> - Returns the color of the pixel at [code]src[/code] if the image is locked. If the image is unlocked, it always returns a [Color] with the value [code](0, 0, 0, 1.0)[/code]. This is the same as [method get_pixel], but with a Vector2 argument instead of two integer arguments. + Returns the color of the pixel at [code]src[/code]. This is the same as [method get_pixel], but with a [Vector2] argument instead of two integer arguments. </description> </method> <method name="get_rect" qualifiers="const"> @@ -355,7 +355,7 @@ <method name="load_jpg_from_buffer"> <return type="int" enum="Error"> </return> - <argument index="0" name="buffer" type="PoolByteArray"> + <argument index="0" name="buffer" type="PackedByteArray"> </argument> <description> Loads an image from the binary contents of a JPEG file. @@ -364,7 +364,7 @@ <method name="load_png_from_buffer"> <return type="int" enum="Error"> </return> - <argument index="0" name="buffer" type="PoolByteArray"> + <argument index="0" name="buffer" type="PackedByteArray"> </argument> <description> Loads an image from the binary contents of a PNG file. @@ -373,19 +373,12 @@ <method name="load_webp_from_buffer"> <return type="int" enum="Error"> </return> - <argument index="0" name="buffer" type="PoolByteArray"> + <argument index="0" name="buffer" type="PackedByteArray"> </argument> <description> Loads an image from the binary contents of a WebP file. </description> </method> - <method name="lock"> - <return type="void"> - </return> - <description> - Locks the data for reading and writing access. Sends an error to the console if the image is not locked when reading or writing a pixel. - </description> - </method> <method name="normalmap_to_xy"> <return type="void"> </return> @@ -459,14 +452,11 @@ <argument index="2" name="color" type="Color"> </argument> <description> - Sets the [Color] of the pixel at [code](x, y)[/code] if the image is locked. Example: + Sets the [Color] of the pixel at [code](x, y)[/code]. Example: [codeblock] var img = Image.new() img.create(img_width, img_height, false, Image.FORMAT_RGBA8) - img.lock() - img.set_pixel(x, y, color) # Works - img.unlock() - img.set_pixel(x, y, color) # Does not have an effect + img.set_pixel(x, y, color) [/codeblock] </description> </method> @@ -478,14 +468,11 @@ <argument index="1" name="color" type="Color"> </argument> <description> - Sets the [Color] of the pixel at [code](dst.x, dst.y)[/code] if the image is locked. Note that the [code]dst[/code] values must be integers. Example: + Sets the [Color] of the pixel at [code](dst.x, dst.y)[/code]. Note that the [code]dst[/code] values must be integers. Example: [codeblock] var img = Image.new() img.create(img_width, img_height, false, Image.FORMAT_RGBA8) - img.lock() - img.set_pixelv(Vector2(x, y), color) # Works - img.unlock() - img.set_pixelv(Vector2(x, y), color) # Does not have an effect + img.set_pixelv(Vector2(x, y), color) [/codeblock] </description> </method> @@ -503,16 +490,9 @@ Converts the raw data from the sRGB colorspace to a linear scale. </description> </method> - <method name="unlock"> - <return type="void"> - </return> - <description> - Unlocks the data and prevents changes. - </description> - </method> </methods> <members> - <member name="data" type="Dictionary" setter="_set_data" getter="_get_data" default="{"data": PoolByteArray( ),"format": "Lum8","height": 0,"mipmaps": false,"width": 0}"> + <member name="data" type="Dictionary" setter="_set_data" getter="_get_data" default="{"data": PackedByteArray( ),"format": "Lum8","height": 0,"mipmaps": false,"width": 0}"> Holds all of the image's color data in a given format. See [enum Format] constants. </member> </members> diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml index 1bc36abf66..d53fabaacb 100644 --- a/doc/classes/ItemList.xml +++ b/doc/classes/ItemList.xml @@ -142,7 +142,7 @@ </description> </method> <method name="get_selected_items"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <description> Returns an array with the indexes of the selected items. diff --git a/doc/classes/Line2D.xml b/doc/classes/Line2D.xml index bed5bbaea7..68cec3e624 100644 --- a/doc/classes/Line2D.xml +++ b/doc/classes/Line2D.xml @@ -84,7 +84,7 @@ <member name="joint_mode" type="int" setter="set_joint_mode" getter="get_joint_mode" enum="Line2D.LineJointMode" default="0"> The style for the points between the start and the end. </member> - <member name="points" type="PoolVector2Array" setter="set_points" getter="get_points" default="PoolVector2Array( )"> + <member name="points" type="PackedVector2Array" setter="set_points" getter="get_points" default="PackedVector2Array( )"> The points that form the lines. The line is drawn between every point set in this array. </member> <member name="round_precision" type="int" setter="set_round_precision" getter="get_round_precision" default="8"> diff --git a/doc/classes/MainLoop.xml b/doc/classes/MainLoop.xml index 2ae7eacdb6..b12d4d9978 100644 --- a/doc/classes/MainLoop.xml +++ b/doc/classes/MainLoop.xml @@ -46,7 +46,7 @@ <method name="_drop_files" qualifiers="virtual"> <return type="void"> </return> - <argument index="0" name="files" type="PoolStringArray"> + <argument index="0" name="files" type="PackedStringArray"> </argument> <argument index="1" name="from_screen" type="int"> </argument> diff --git a/doc/classes/Marshalls.xml b/doc/classes/Marshalls.xml index f9ca391f1c..6707068c5a 100644 --- a/doc/classes/Marshalls.xml +++ b/doc/classes/Marshalls.xml @@ -10,12 +10,12 @@ </tutorials> <methods> <method name="base64_to_raw"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <argument index="0" name="base64_str" type="String"> </argument> <description> - Returns a decoded [PoolByteArray] corresponding to the Base64-encoded string [code]base64_str[/code]. + Returns a decoded [PackedByteArray] corresponding to the Base64-encoded string [code]base64_str[/code]. </description> </method> <method name="base64_to_utf8"> @@ -42,10 +42,10 @@ <method name="raw_to_base64"> <return type="String"> </return> - <argument index="0" name="array" type="PoolByteArray"> + <argument index="0" name="array" type="PackedByteArray"> </argument> <description> - Returns a Base64-encoded string of a given [PoolByteArray]. + Returns a Base64-encoded string of a given [PackedByteArray]. </description> </method> <method name="utf8_to_base64"> diff --git a/doc/classes/Mesh.xml b/doc/classes/Mesh.xml index f2602dfc7f..dc7ffc8934 100644 --- a/doc/classes/Mesh.xml +++ b/doc/classes/Mesh.xml @@ -49,7 +49,7 @@ </description> </method> <method name="get_faces" qualifiers="const"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> <description> Returns all the vertices that make up the faces of the mesh. Each three vertices represent one triangle. diff --git a/doc/classes/MeshDataTool.xml b/doc/classes/MeshDataTool.xml index 5c6401521a..bdc9d20305 100644 --- a/doc/classes/MeshDataTool.xml +++ b/doc/classes/MeshDataTool.xml @@ -57,7 +57,7 @@ </description> </method> <method name="get_edge_faces" qualifiers="const"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="idx" type="int"> </argument> @@ -160,7 +160,7 @@ </description> </method> <method name="get_vertex_bones" qualifiers="const"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="idx" type="int"> </argument> @@ -185,7 +185,7 @@ </description> </method> <method name="get_vertex_edges" qualifiers="const"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="idx" type="int"> </argument> @@ -194,7 +194,7 @@ </description> </method> <method name="get_vertex_faces" qualifiers="const"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="idx" type="int"> </argument> @@ -248,7 +248,7 @@ </description> </method> <method name="get_vertex_weights" qualifiers="const"> - <return type="PoolRealArray"> + <return type="PackedRealArray"> </return> <argument index="0" name="idx" type="int"> </argument> @@ -303,7 +303,7 @@ </return> <argument index="0" name="idx" type="int"> </argument> - <argument index="1" name="bones" type="PoolIntArray"> + <argument index="1" name="bones" type="PackedIntArray"> </argument> <description> Sets the bones of the given vertex. @@ -380,7 +380,7 @@ </return> <argument index="0" name="idx" type="int"> </argument> - <argument index="1" name="weights" type="PoolRealArray"> + <argument index="1" name="weights" type="PackedRealArray"> </argument> <description> Sets the bone weights of the given vertex. diff --git a/doc/classes/MeshLibrary.xml b/doc/classes/MeshLibrary.xml index 3a3dd08caf..ec12a0ff42 100644 --- a/doc/classes/MeshLibrary.xml +++ b/doc/classes/MeshLibrary.xml @@ -36,7 +36,7 @@ </description> </method> <method name="get_item_list" qualifiers="const"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <description> Returns the list of item IDs in use. diff --git a/doc/classes/MonoGCHandle.xml b/doc/classes/MonoGCHandle.xml new file mode 100644 index 0000000000..1e33dd1359 --- /dev/null +++ b/doc/classes/MonoGCHandle.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="MonoGCHandle" inherits="Reference" version="4.0"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/MultiMesh.xml b/doc/classes/MultiMesh.xml index 8a4a192ed4..6831fc88df 100644 --- a/doc/classes/MultiMesh.xml +++ b/doc/classes/MultiMesh.xml @@ -105,11 +105,11 @@ </method> </methods> <members> - <member name="buffer" type="PoolRealArray" setter="set_buffer" getter="get_buffer" default="PoolRealArray( )"> + <member name="buffer" type="PackedRealArray" setter="set_buffer" getter="get_buffer" default="PackedRealArray( )"> </member> - <member name="color_array" type="PoolColorArray" setter="_set_color_array" getter="_get_color_array"> + <member name="color_array" type="PackedColorArray" setter="_set_color_array" getter="_get_color_array"> </member> - <member name="custom_data_array" type="PoolColorArray" setter="_set_custom_data_array" getter="_get_custom_data_array"> + <member name="custom_data_array" type="PackedColorArray" setter="_set_custom_data_array" getter="_get_custom_data_array"> </member> <member name="instance_count" type="int" setter="set_instance_count" getter="get_instance_count" default="0"> Number of instances that will get drawn. This clears and (re)sizes the buffers. By default, all instances are drawn but you can limit this with [member visible_instance_count]. @@ -117,9 +117,9 @@ <member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh"> Mesh to be drawn. </member> - <member name="transform_2d_array" type="PoolVector2Array" setter="_set_transform_2d_array" getter="_get_transform_2d_array"> + <member name="transform_2d_array" type="PackedVector2Array" setter="_set_transform_2d_array" getter="_get_transform_2d_array"> </member> - <member name="transform_array" type="PoolVector3Array" setter="_set_transform_array" getter="_get_transform_array"> + <member name="transform_array" type="PackedVector3Array" setter="_set_transform_array" getter="_get_transform_array"> </member> <member name="transform_format" type="int" setter="set_transform_format" getter="get_transform_format" enum="MultiMesh.TransformFormat" default="0"> Format of transform used to transform mesh, either 2D or 3D. diff --git a/doc/classes/MultiplayerAPI.xml b/doc/classes/MultiplayerAPI.xml index b82214b246..968357ea07 100644 --- a/doc/classes/MultiplayerAPI.xml +++ b/doc/classes/MultiplayerAPI.xml @@ -19,7 +19,7 @@ </description> </method> <method name="get_network_connected_peers" qualifiers="const"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <description> Returns the peer IDs of all connected peers of this MultiplayerAPI's [member network_peer]. @@ -65,7 +65,7 @@ <method name="send_bytes"> <return type="int" enum="Error"> </return> - <argument index="0" name="bytes" type="PoolByteArray"> + <argument index="0" name="bytes" type="PackedByteArray"> </argument> <argument index="1" name="id" type="int" default="0"> </argument> @@ -126,7 +126,7 @@ <signal name="network_peer_packet"> <argument index="0" name="id" type="int"> </argument> - <argument index="1" name="packet" type="PoolByteArray"> + <argument index="1" name="packet" type="PackedByteArray"> </argument> <description> Emitted when this MultiplayerAPI's [member network_peer] receive a [code]packet[/code] with custom data (see [method send_bytes]). ID is the peer ID of the peer that sent the packet. diff --git a/doc/classes/Navigation.xml b/doc/classes/Navigation.xml index be36be0429..d7da753c61 100644 --- a/doc/classes/Navigation.xml +++ b/doc/classes/Navigation.xml @@ -16,7 +16,7 @@ </description> </method> <method name="get_simple_path"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> <argument index="0" name="start" type="Vector3"> </argument> diff --git a/doc/classes/Navigation2D.xml b/doc/classes/Navigation2D.xml index 734469eaa9..9ef4a51ff0 100644 --- a/doc/classes/Navigation2D.xml +++ b/doc/classes/Navigation2D.xml @@ -16,7 +16,7 @@ </description> </method> <method name="get_simple_path"> - <return type="PoolVector2Array"> + <return type="PackedVector2Array"> </return> <argument index="0" name="start" type="Vector2"> </argument> diff --git a/doc/classes/Navigation2DServer.xml b/doc/classes/Navigation2DServer.xml index 3950e35697..67619d708d 100644 --- a/doc/classes/Navigation2DServer.xml +++ b/doc/classes/Navigation2DServer.xml @@ -174,7 +174,7 @@ </description> </method> <method name="map_get_path" qualifiers="const"> - <return type="PoolVector2Array"> + <return type="PackedVector2Array"> </return> <argument index="0" name="map" type="RID"> </argument> diff --git a/doc/classes/NavigationAgent.xml b/doc/classes/NavigationAgent.xml index dc759bc72b..f896bf6d15 100644 --- a/doc/classes/NavigationAgent.xml +++ b/doc/classes/NavigationAgent.xml @@ -24,7 +24,7 @@ </description> </method> <method name="get_nav_path" qualifiers="const"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> <description> Returns the path from start to finish in global coordinates. @@ -34,7 +34,7 @@ <return type="int"> </return> <description> - Returns which index the agent is currently on in the navigation path's [PoolVector3Array]. + Returns which index the agent is currently on in the navigation path's [PackedVector3Array]. </description> </method> <method name="get_navigation" qualifiers="const"> diff --git a/doc/classes/NavigationAgent2D.xml b/doc/classes/NavigationAgent2D.xml index 6f356e7e4c..116db76cc5 100644 --- a/doc/classes/NavigationAgent2D.xml +++ b/doc/classes/NavigationAgent2D.xml @@ -24,7 +24,7 @@ </description> </method> <method name="get_nav_path" qualifiers="const"> - <return type="PoolVector2Array"> + <return type="PackedVector2Array"> </return> <description> Returns the path from start to finish in global coordinates. @@ -34,7 +34,7 @@ <return type="int"> </return> <description> - Returns which index the agent is currently on in the navigation path's [PoolVector2Array]. + Returns which index the agent is currently on in the navigation path's [PackedVector2Array]. </description> </method> <method name="get_navigation" qualifiers="const"> diff --git a/doc/classes/NavigationMesh.xml b/doc/classes/NavigationMesh.xml index fb3babf4aa..5b7a188e5a 100644 --- a/doc/classes/NavigationMesh.xml +++ b/doc/classes/NavigationMesh.xml @@ -10,7 +10,7 @@ <method name="add_polygon"> <return type="void"> </return> - <argument index="0" name="polygon" type="PoolIntArray"> + <argument index="0" name="polygon" type="PackedIntArray"> </argument> <description> </description> @@ -38,7 +38,7 @@ </description> </method> <method name="get_polygon"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="idx" type="int"> </argument> @@ -52,7 +52,7 @@ </description> </method> <method name="get_vertices" qualifiers="const"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> <description> </description> @@ -70,7 +70,7 @@ <method name="set_vertices"> <return type="void"> </return> - <argument index="0" name="vertices" type="PoolVector3Array"> + <argument index="0" name="vertices" type="PackedVector3Array"> </argument> <description> </description> diff --git a/doc/classes/NavigationPolygon.xml b/doc/classes/NavigationPolygon.xml index 0157a6f3f7..908617fb91 100644 --- a/doc/classes/NavigationPolygon.xml +++ b/doc/classes/NavigationPolygon.xml @@ -8,7 +8,7 @@ Using [method add_outline]: [codeblock] var polygon = NavigationPolygon.new() - var outline = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)]) + var outline = PackedVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)]) polygon.add_outline(outline) polygon.make_polygons_from_outlines() $NavigationPolygonInstance.navpoly = polygon @@ -16,9 +16,9 @@ Using [method add_polygon] and indices of the vertices array. [codeblock] var polygon = NavigationPolygon.new() - var vertices = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)]) + var vertices = PackedVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)]) polygon.set_vertices(vertices) - var indices = PoolIntArray(0, 3, 1) + var indices = PackedIntArray(0, 3, 1) polygon.add_polygon(indices) $NavigationPolygonInstance.navpoly = polygon [/codeblock] @@ -29,27 +29,27 @@ <method name="add_outline"> <return type="void"> </return> - <argument index="0" name="outline" type="PoolVector2Array"> + <argument index="0" name="outline" type="PackedVector2Array"> </argument> <description> - Appends a [PoolVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use. + Appends a [PackedVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use. </description> </method> <method name="add_outline_at_index"> <return type="void"> </return> - <argument index="0" name="outline" type="PoolVector2Array"> + <argument index="0" name="outline" type="PackedVector2Array"> </argument> <argument index="1" name="index" type="int"> </argument> <description> - Adds a [PoolVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use. + Adds a [PackedVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use. </description> </method> <method name="add_polygon"> <return type="void"> </return> - <argument index="0" name="polygon" type="PoolIntArray"> + <argument index="0" name="polygon" type="PackedIntArray"> </argument> <description> Adds a polygon using the indices of the vertices you get when calling [method get_vertices]. @@ -70,12 +70,12 @@ </description> </method> <method name="get_outline" qualifiers="const"> - <return type="PoolVector2Array"> + <return type="PackedVector2Array"> </return> <argument index="0" name="idx" type="int"> </argument> <description> - Returns a [PoolVector2Array] containing the vertices of an outline that was created in the editor or by script. + Returns a [PackedVector2Array] containing the vertices of an outline that was created in the editor or by script. </description> </method> <method name="get_outline_count" qualifiers="const"> @@ -86,12 +86,12 @@ </description> </method> <method name="get_polygon"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="idx" type="int"> </argument> <description> - Returns a [PoolIntArray] containing the indices of the vertices of a created polygon. + Returns a [PackedIntArray] containing the indices of the vertices of a created polygon. </description> </method> <method name="get_polygon_count" qualifiers="const"> @@ -102,10 +102,10 @@ </description> </method> <method name="get_vertices" qualifiers="const"> - <return type="PoolVector2Array"> + <return type="PackedVector2Array"> </return> <description> - Returns a [PoolVector2Array] containing all the vertices being used to create the polygons. + Returns a [PackedVector2Array] containing all the vertices being used to create the polygons. </description> </method> <method name="make_polygons_from_outlines"> @@ -129,7 +129,7 @@ </return> <argument index="0" name="idx" type="int"> </argument> - <argument index="1" name="outline" type="PoolVector2Array"> + <argument index="1" name="outline" type="PackedVector2Array"> </argument> <description> Changes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update. @@ -138,7 +138,7 @@ <method name="set_vertices"> <return type="void"> </return> - <argument index="0" name="vertices" type="PoolVector2Array"> + <argument index="0" name="vertices" type="PackedVector2Array"> </argument> <description> Sets the vertices that can be then indexed to create polygons with the [method add_polygon] method. diff --git a/doc/classes/NavigationServer.xml b/doc/classes/NavigationServer.xml index 7553d700f8..ad7c56f361 100644 --- a/doc/classes/NavigationServer.xml +++ b/doc/classes/NavigationServer.xml @@ -174,7 +174,7 @@ </description> </method> <method name="map_get_path" qualifiers="const"> - <return type="PoolVector3Array"> + <return type="PackedVector3Array"> </return> <argument index="0" name="map" type="RID"> </argument> diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index d361ea83e6..6ce2d4bcbb 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -93,7 +93,7 @@ </return> <argument index="0" name="path" type="String"> </argument> - <argument index="1" name="arguments" type="PoolStringArray"> + <argument index="1" name="arguments" type="PackedStringArray"> </argument> <argument index="2" name="blocking" type="bool" default="true"> </argument> @@ -150,14 +150,14 @@ </description> </method> <method name="get_cmdline_args"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Returns the command line arguments passed to the engine. </description> </method> <method name="get_connected_midi_inputs"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Returns an array of MIDI device names. @@ -200,13 +200,6 @@ The returned Dictionary's values will be the same as [method get_datetime], with the exception of Daylight Savings Time as it cannot be determined from the epoch. </description> </method> - <method name="get_dynamic_memory_usage" qualifiers="const"> - <return type="int"> - </return> - <description> - Returns the total amount of dynamic memory used (only works in debug). - </description> - </method> <method name="get_environment" qualifiers="const"> <return type="String"> </return> @@ -224,7 +217,7 @@ </description> </method> <method name="get_granted_permissions" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> With this function you can get the list of dangerous permissions that have been granted to the Android application. @@ -734,7 +727,7 @@ <method name="print_resources_by_type"> <return type="void"> </return> - <argument index="0" name="types" type="PoolStringArray"> + <argument index="0" name="types" type="PackedStringArray"> </argument> <description> Shows the number of resources loaded by the game of the given types. diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml index 858bf5b635..5388d93b8d 100644 --- a/doc/classes/Object.xml +++ b/doc/classes/Object.xml @@ -251,10 +251,10 @@ </description> </method> <method name="get_meta_list" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> - Returns the object's metadata as a [PoolStringArray]. + Returns the object's metadata as a [PackedStringArray]. </description> </method> <method name="get_method_list" qualifiers="const"> @@ -273,7 +273,7 @@ </description> </method> <method name="get_script" qualifiers="const"> - <return type="Reference"> + <return type="Variant"> </return> <description> Returns the object's [Script] instance, or [code]null[/code] if none is assigned. @@ -456,7 +456,7 @@ <method name="set_script"> <return type="void"> </return> - <argument index="0" name="script" type="Reference"> + <argument index="0" name="script" type="Variant"> </argument> <description> Assigns a script to the object. Each object can have a single script assigned to it, which are used to extend its functionality. diff --git a/doc/classes/OccluderPolygon2D.xml b/doc/classes/OccluderPolygon2D.xml index 6cfef42204..8a59ef5cb4 100644 --- a/doc/classes/OccluderPolygon2D.xml +++ b/doc/classes/OccluderPolygon2D.xml @@ -17,7 +17,7 @@ <member name="cull_mode" type="int" setter="set_cull_mode" getter="get_cull_mode" enum="OccluderPolygon2D.CullMode" default="0"> The culling mode to use. </member> - <member name="polygon" type="PoolVector2Array" setter="set_polygon" getter="get_polygon" default="PoolVector2Array( )"> + <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( )"> A [Vector2] array with the index for polygon's vertices positions. [b]Note:[/b] The returned value is a copy of the underlying array, rather than a reference. </member> diff --git a/doc/classes/PoolByteArray.xml b/doc/classes/PackedByteArray.xml index 63a7037fb1..e9b86e93dd 100644 --- a/doc/classes/PoolByteArray.xml +++ b/doc/classes/PackedByteArray.xml @@ -1,22 +1,22 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PoolByteArray" version="4.0"> +<class name="PackedByteArray" version="4.0"> <brief_description> - A pooled [Array] of bytes. + A packed [Array] of bytes. </brief_description> <description> - An [Array] specifically designed to hold bytes. Optimized for memory usage, does not fragment the memory. + An [Array] specifically designed to hold bytes. Packs data tightly, so it saves memory for large array sizes. [b]Note:[/b] This type is passed by value and not by reference. </description> <tutorials> </tutorials> <methods> - <method name="PoolByteArray"> - <return type="PoolByteArray"> + <method name="PackedByteArray"> + <return type="PackedByteArray"> </return> <argument index="0" name="from" type="Array"> </argument> <description> - Constructs a new [PoolByteArray]. Optionally, you can pass in a generic [Array] that will be converted. + Constructs a new [PackedByteArray]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> @@ -27,30 +27,30 @@ </description> </method> <method name="append_array"> - <argument index="0" name="array" type="PoolByteArray"> + <argument index="0" name="array" type="PackedByteArray"> </argument> <description> - Appends a [PoolByteArray] at the end of this array. + Appends a [PackedByteArray] at the end of this array. </description> </method> <method name="compress"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <argument index="0" name="compression_mode" type="int" default="0"> </argument> <description> - Returns a new [PoolByteArray] with the data compressed. Set the compression mode using one of [enum File.CompressionMode]'s constants. + Returns a new [PackedByteArray] with the data compressed. Set the compression mode using one of [enum File.CompressionMode]'s constants. </description> </method> <method name="decompress"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <argument index="0" name="buffer_size" type="int"> </argument> <argument index="1" name="compression_mode" type="int" default="0"> </argument> <description> - Returns a new [PoolByteArray] with the data decompressed. Set [code]buffer_size[/code] to the size of the uncompressed data. Set the compression mode using one of [enum File.CompressionMode]'s constants. + Returns a new [PackedByteArray] with the data decompressed. Set [code]buffer_size[/code] to the size of the uncompressed data. Set the compression mode using one of [enum File.CompressionMode]'s constants. </description> </method> <method name="empty"> @@ -80,7 +80,7 @@ <description> Returns a hexadecimal representation of this array as a [String]. [codeblock] - var array = PoolByteArray([11, 46, 255]) + var array = PackedByteArray([11, 46, 255]) print(array.hex_encode()) # Prints: 0b2eff [/codeblock] </description> @@ -139,14 +139,14 @@ </description> </method> <method name="subarray"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <argument index="0" name="from" type="int"> </argument> <argument index="1" name="to" type="int"> </argument> <description> - Returns the slice of the [PoolByteArray] between indices (inclusive) as a new [PoolByteArray]. Any negative index is considered to be from the end of the array. + Returns the slice of the [PackedByteArray] between indices (inclusive) as a new [PackedByteArray]. Any negative index is considered to be from the end of the array. </description> </method> </methods> diff --git a/doc/classes/PoolColorArray.xml b/doc/classes/PackedColorArray.xml index d5599f821c..1d1614b081 100644 --- a/doc/classes/PoolColorArray.xml +++ b/doc/classes/PackedColorArray.xml @@ -1,22 +1,22 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PoolColorArray" version="4.0"> +<class name="PackedColorArray" version="4.0"> <brief_description> - A pooled [Array] of [Color]. + A packed [Array] of [Color]s. </brief_description> <description> - An [Array] specifically designed to hold [Color]. Optimized for memory usage, does not fragment the memory. + An [Array] specifically designed to hold [Color]. Packs data tightly, so it saves memory for large array sizes. [b]Note:[/b] This type is passed by value and not by reference. </description> <tutorials> </tutorials> <methods> - <method name="PoolColorArray"> - <return type="PoolColorArray"> + <method name="PackedColorArray"> + <return type="PackedColorArray"> </return> <argument index="0" name="from" type="Array"> </argument> <description> - Constructs a new [PoolColorArray]. Optionally, you can pass in a generic [Array] that will be converted. + Constructs a new [PackedColorArray]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> @@ -27,10 +27,10 @@ </description> </method> <method name="append_array"> - <argument index="0" name="array" type="PoolColorArray"> + <argument index="0" name="array" type="PackedColorArray"> </argument> <description> - Appends a [PoolColorArray] at the end of this array. + Appends a [PackedColorArray] at the end of this array. </description> </method> <method name="empty"> diff --git a/doc/classes/PackedDataContainer.xml b/doc/classes/PackedDataContainer.xml index 79c9fa8d9c..296f9d3373 100644 --- a/doc/classes/PackedDataContainer.xml +++ b/doc/classes/PackedDataContainer.xml @@ -23,7 +23,7 @@ </method> </methods> <members> - <member name="__data__" type="PoolByteArray" setter="_set_data" getter="_get_data" default="PoolByteArray( )"> + <member name="__data__" type="PackedByteArray" setter="_set_data" getter="_get_data" default="PackedByteArray( )"> </member> </members> <constants> diff --git a/doc/classes/PoolIntArray.xml b/doc/classes/PackedIntArray.xml index 54f0f46e11..536b4d9aaf 100644 --- a/doc/classes/PoolIntArray.xml +++ b/doc/classes/PackedIntArray.xml @@ -1,23 +1,23 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PoolIntArray" version="4.0"> +<class name="PackedIntArray" version="4.0"> <brief_description> - A pooled [Array] of integers ([int]). + A packed [Array] of integers ([int]). </brief_description> <description> - An [Array] specifically designed to hold integer values ([int]). Optimized for memory usage, does not fragment the memory. + An [Array] specifically designed to hold integer values ([int]). Packs data tightly, so it saves memory for large array sizes. [b]Note:[/b] This type is passed by value and not by reference. [b]Note:[/b] This type is limited to signed 32-bit integers, which means it can only take values in the interval [code][-2^31, 2^31 - 1][/code], i.e. [code][-2147483648, 2147483647][/code]. Exceeding those bounds will wrap around. In comparison, [int] uses signed 64-bit integers which can hold much larger values. </description> <tutorials> </tutorials> <methods> - <method name="PoolIntArray"> - <return type="PoolIntArray"> + <method name="PackedIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="from" type="Array"> </argument> <description> - Constructs a new [PoolIntArray]. Optionally, you can pass in a generic [Array] that will be converted. + Constructs a new [PackedIntArray]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> @@ -28,10 +28,10 @@ </description> </method> <method name="append_array"> - <argument index="0" name="array" type="PoolIntArray"> + <argument index="0" name="array" type="PackedIntArray"> </argument> <description> - Appends a [PoolIntArray] at the end of this array. + Appends a [PackedIntArray] at the end of this array. </description> </method> <method name="empty"> @@ -49,7 +49,7 @@ <argument index="1" name="integer" type="int"> </argument> <description> - Inserts a new int at a given position in the array. The position must be valid, or at the end of the array ([code]idx == size()[/code]). + Inserts a new integer at a given position in the array. The position must be valid, or at the end of the array ([code]idx == size()[/code]). </description> </method> <method name="invert"> @@ -84,7 +84,7 @@ <argument index="1" name="integer" type="int"> </argument> <description> - Changes the int at the given index. + Changes the integer at the given index. </description> </method> <method name="size"> diff --git a/doc/classes/PoolRealArray.xml b/doc/classes/PackedRealArray.xml index 6957e7282b..7a7415b279 100644 --- a/doc/classes/PoolRealArray.xml +++ b/doc/classes/PackedRealArray.xml @@ -1,22 +1,22 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PoolRealArray" version="4.0"> +<class name="PackedRealArray" version="4.0"> <brief_description> - A pooled [Array] of reals ([float]). + A packed [Array] of reals ([float]). </brief_description> <description> - An [Array] specifically designed to hold floating-point values ([float]). Optimized for memory usage, does not fragment the memory. + An [Array] specifically designed to hold floating-point values ([float]). Packs data tightly, so it saves memory for large array sizes. [b]Note:[/b] This type is passed by value and not by reference. </description> <tutorials> </tutorials> <methods> - <method name="PoolRealArray"> - <return type="PoolRealArray"> + <method name="PackedRealArray"> + <return type="PackedRealArray"> </return> <argument index="0" name="from" type="Array"> </argument> <description> - Constructs a new [PoolRealArray]. Optionally, you can pass in a generic [Array] that will be converted. + Constructs a new [PackedRealArray]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> @@ -27,10 +27,10 @@ </description> </method> <method name="append_array"> - <argument index="0" name="array" type="PoolRealArray"> + <argument index="0" name="array" type="PackedRealArray"> </argument> <description> - Appends a [PoolRealArray] at the end of this array. + Appends a [PackedRealArray] at the end of this array. </description> </method> <method name="empty"> diff --git a/doc/classes/PackedScene.xml b/doc/classes/PackedScene.xml index d13195bd5e..8efe1e2b4b 100644 --- a/doc/classes/PackedScene.xml +++ b/doc/classes/PackedScene.xml @@ -65,7 +65,7 @@ </method> </methods> <members> - <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" default="{"conn_count": 0,"conns": PoolIntArray( ),"editable_instances": [ ],"names": PoolStringArray( ),"node_count": 0,"node_paths": [ ],"nodes": PoolIntArray( ),"variants": [ ],"version": 2}"> + <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" default="{"conn_count": 0,"conns": PackedIntArray( ),"editable_instances": [ ],"names": PackedStringArray( ),"node_count": 0,"node_paths": [ ],"nodes": PackedIntArray( ),"variants": [ ],"version": 2}"> A dictionary representation of the scene contents. Available keys include "rnames" and "variants" for resources, "node_count", "nodes", "node_paths" for nodes, "editable_instances" for base scene children overrides, "conn_count" and "conns" for signal connections, and "version" for the format style of the PackedScene. </member> diff --git a/doc/classes/PoolStringArray.xml b/doc/classes/PackedStringArray.xml index b4fb7b31d4..8824f7f8a5 100644 --- a/doc/classes/PoolStringArray.xml +++ b/doc/classes/PackedStringArray.xml @@ -1,22 +1,22 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PoolStringArray" version="4.0"> +<class name="PackedStringArray" version="4.0"> <brief_description> - A pooled [Array] of [String]. + A packed [Array] of [String]s. </brief_description> <description> - An [Array] specifically designed to hold [String]s. Optimized for memory usage, does not fragment the memory. + An [Array] specifically designed to hold [String]s. Packs data tightly, so it saves memory for large array sizes. [b]Note:[/b] This type is passed by value and not by reference. </description> <tutorials> </tutorials> <methods> - <method name="PoolStringArray"> - <return type="PoolStringArray"> + <method name="PackedStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="from" type="Array"> </argument> <description> - Constructs a new [PoolStringArray]. Optionally, you can pass in a generic [Array] that will be converted. + Constructs a new [PackedStringArray]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> @@ -27,10 +27,10 @@ </description> </method> <method name="append_array"> - <argument index="0" name="array" type="PoolStringArray"> + <argument index="0" name="array" type="PackedStringArray"> </argument> <description> - Appends a [PoolStringArray] at the end of this array. + Appends a [PackedStringArray] at the end of this array. </description> </method> <method name="empty"> @@ -56,15 +56,6 @@ Reverses the order of the elements in the array. </description> </method> - <method name="join"> - <return type="String"> - </return> - <argument index="0" name="delimiter" type="String"> - </argument> - <description> - Returns a [String] with each element of the array joined with the given [code]delimiter[/code]. - </description> - </method> <method name="push_back"> <argument index="0" name="string" type="String"> </argument> diff --git a/doc/classes/PoolVector2Array.xml b/doc/classes/PackedVector2Array.xml index cb4536be5b..339296180b 100644 --- a/doc/classes/PoolVector2Array.xml +++ b/doc/classes/PackedVector2Array.xml @@ -1,22 +1,22 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PoolVector2Array" version="4.0"> +<class name="PackedVector2Array" version="4.0"> <brief_description> - A pooled [Array] of [Vector2]. + A packed [Array] of [Vector2]s. </brief_description> <description> - An [Array] specifically designed to hold [Vector2]. Optimized for memory usage, does not fragment the memory. + An [Array] specifically designed to hold [Vector2]. Packs data tightly, so it saves memory for large array sizes. [b]Note:[/b] This type is passed by value and not by reference. </description> <tutorials> </tutorials> <methods> - <method name="PoolVector2Array"> - <return type="PoolVector2Array"> + <method name="PackedVector2Array"> + <return type="PackedVector2Array"> </return> <argument index="0" name="from" type="Array"> </argument> <description> - Constructs a new [PoolVector2Array]. Optionally, you can pass in a generic [Array] that will be converted. + Constructs a new [PackedVector2Array]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> @@ -27,10 +27,10 @@ </description> </method> <method name="append_array"> - <argument index="0" name="array" type="PoolVector2Array"> + <argument index="0" name="array" type="PackedVector2Array"> </argument> <description> - Appends a [PoolVector2Array] at the end of this array. + Appends a [PackedVector2Array] at the end of this array. </description> </method> <method name="empty"> diff --git a/doc/classes/PoolVector3Array.xml b/doc/classes/PackedVector3Array.xml index 6c40de9bd8..2c5e2a63e3 100644 --- a/doc/classes/PoolVector3Array.xml +++ b/doc/classes/PackedVector3Array.xml @@ -1,22 +1,22 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PoolVector3Array" version="4.0"> +<class name="PackedVector3Array" version="4.0"> <brief_description> - A pooled [Array] of [Vector3]. + A packed [Array] of [Vector3]s. </brief_description> <description> - An [Array] specifically designed to hold [Vector3]. Optimized for memory usage, does not fragment the memory. + An [Array] specifically designed to hold [Vector3]. Packs data tightly, so it saves memory for large array sizes. [b]Note:[/b] This type is passed by value and not by reference. </description> <tutorials> </tutorials> <methods> - <method name="PoolVector3Array"> - <return type="PoolVector3Array"> + <method name="PackedVector3Array"> + <return type="PackedVector3Array"> </return> <argument index="0" name="from" type="Array"> </argument> <description> - Constructs a new [PoolVector3Array]. Optionally, you can pass in a generic [Array] that will be converted. + Constructs a new [PackedVector3Array]. Optionally, you can pass in a generic [Array] that will be converted. </description> </method> <method name="append"> @@ -27,10 +27,10 @@ </description> </method> <method name="append_array"> - <argument index="0" name="array" type="PoolVector3Array"> + <argument index="0" name="array" type="PackedVector3Array"> </argument> <description> - Appends a [PoolVector3Array] at the end of this array. + Appends a [PackedVector3Array] at the end of this array. </description> </method> <method name="empty"> diff --git a/doc/classes/PacketPeer.xml b/doc/classes/PacketPeer.xml index b721bc9df4..e3e2f63e14 100644 --- a/doc/classes/PacketPeer.xml +++ b/doc/classes/PacketPeer.xml @@ -17,7 +17,7 @@ </description> </method> <method name="get_packet"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <description> Gets a raw packet. @@ -43,7 +43,7 @@ <method name="put_packet"> <return type="int" enum="Error"> </return> - <argument index="0" name="buffer" type="PoolByteArray"> + <argument index="0" name="buffer" type="PackedByteArray"> </argument> <description> Sends a raw packet. diff --git a/doc/classes/PacketPeerDTLS.xml b/doc/classes/PacketPeerDTLS.xml new file mode 100644 index 0000000000..a9ba6dea00 --- /dev/null +++ b/doc/classes/PacketPeerDTLS.xml @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="PacketPeerDTLS" inherits="PacketPeer" version="4.0"> + <brief_description> + DTLS packet peer. + </brief_description> + <description> + This class represents a DTLS peer connection. It can be used to connect to a DTLS server, and is returned by [method DTLSServer.take_connection]. + </description> + <tutorials> + </tutorials> + <methods> + <method name="connect_to_peer"> + <return type="int" enum="Error"> + </return> + <argument index="0" name="packet_peer" type="PacketPeerUDP"> + </argument> + <argument index="1" name="validate_certs" type="bool" default="false"> + </argument> + <argument index="2" name="for_hostname" type="String" default=""""> + </argument> + <argument index="3" name="valid_certificate" type="X509Certificate" default="null"> + </argument> + <description> + Connects a [code]peer[/code] beginning the DTLS handshake using the underlying [PacketPeerUDP] which must be connected (see [method PacketPeerUDP.connect_to_host]). If [code]validate_certs[/code] is [code]true[/code], [PacketPeerDTLS] will validate that the certificate presented by the remote peer and match it with the [code]for_hostname[/code] argument. You can specify a custom [X509Certificate] to use for validation via the [code]valid_certificate[/code] argument. + </description> + </method> + <method name="disconnect_from_peer"> + <return type="void"> + </return> + <description> + Disconnects this peer, terminating the DTLS session. + </description> + </method> + <method name="get_status" qualifiers="const"> + <return type="int" enum="PacketPeerDTLS.Status"> + </return> + <description> + Returns the status of the connection. See [enum Status] for values. + </description> + </method> + <method name="poll"> + <return type="void"> + </return> + <description> + Poll the connection to check for incoming packets. Call this frequently to update the status and keep the connection working. + </description> + </method> + </methods> + <constants> + <constant name="STATUS_DISCONNECTED" value="0" enum="Status"> + A status representing a [PacketPeerDTLS] that is disconnected. + </constant> + <constant name="STATUS_HANDSHAKING" value="1" enum="Status"> + A status representing a [PacketPeerDTLS] that is currently performing the handshake with a remote peer. + </constant> + <constant name="STATUS_CONNECTED" value="2" enum="Status"> + A status representing a [PacketPeerDTLS] that is connected to a remote peer. + </constant> + <constant name="STATUS_ERROR" value="3" enum="Status"> + A status representing a [PacketPeerDTLS] in a generic error state. + </constant> + <constant name="STATUS_ERROR_HOSTNAME_MISMATCH" value="4" enum="Status"> + An error status that shows a mismatch in the DTLS certificate domain presented by the host and the domain requested for validation. + </constant> + </constants> +</class> diff --git a/doc/classes/PacketPeerUDP.xml b/doc/classes/PacketPeerUDP.xml index 81cd341ef7..aa5599a3fb 100644 --- a/doc/classes/PacketPeerUDP.xml +++ b/doc/classes/PacketPeerUDP.xml @@ -16,6 +16,18 @@ Closes the UDP socket the [PacketPeerUDP] is currently listening on. </description> </method> + <method name="connect_to_host"> + <return type="int" enum="Error"> + </return> + <argument index="0" name="host" type="String"> + </argument> + <argument index="1" name="port" type="int"> + </argument> + <description> + Calling this method connects this UDP peer to the given [code]host[/code]/[code]port[/code] pair. UDP is in reality connectionless, so this option only means that incoming packets from different addresses are automatically discarded, and that outgoing packets are always sent to the connected address (future calls to [method set_dest_address] are not allowed). This method does not send any data to the remote peer, to do that, use [method PacketPeer.put_var] or [method PacketPeer.put_packet] as usual. See also [UDPServer]. + Note: Connecting to the remote peer does not help to protect from malicious attacks like IP spoofing, etc. Think about using an encryption technique like SSL or DTLS if you feel like your application is transfering sensitive information. + </description> + </method> <method name="get_packet_ip" qualifiers="const"> <return type="String"> </return> @@ -30,6 +42,13 @@ Returns the port of the remote peer that sent the last packet(that was received with [method PacketPeer.get_packet] or [method PacketPeer.get_var]). </description> </method> + <method name="is_connected_to_host" qualifiers="const"> + <return type="bool"> + </return> + <description> + Returns [code]true[/code] if the UDP socket is open and has been connected to a remote address. See [method connect_to_host]. + </description> + </method> <method name="is_listening" qualifiers="const"> <return type="bool"> </return> diff --git a/doc/classes/Performance.xml b/doc/classes/Performance.xml index a7bf947011..378b165644 100644 --- a/doc/classes/Performance.xml +++ b/doc/classes/Performance.xml @@ -37,82 +37,76 @@ <constant name="MEMORY_STATIC" value="3" enum="Monitor"> Static memory currently used, in bytes. Not available in release builds. </constant> - <constant name="MEMORY_DYNAMIC" value="4" enum="Monitor"> - Dynamic memory currently used, in bytes. Not available in release builds. - </constant> - <constant name="MEMORY_STATIC_MAX" value="5" enum="Monitor"> + <constant name="MEMORY_STATIC_MAX" value="4" enum="Monitor"> Available static memory. Not available in release builds. </constant> - <constant name="MEMORY_DYNAMIC_MAX" value="6" enum="Monitor"> - Available dynamic memory. Not available in release builds. - </constant> - <constant name="MEMORY_MESSAGE_BUFFER_MAX" value="7" enum="Monitor"> + <constant name="MEMORY_MESSAGE_BUFFER_MAX" value="5" enum="Monitor"> Largest amount of memory the message queue buffer has used, in bytes. The message queue is used for deferred functions calls and notifications. </constant> - <constant name="OBJECT_COUNT" value="8" enum="Monitor"> + <constant name="OBJECT_COUNT" value="6" enum="Monitor"> Number of objects currently instanced (including nodes). </constant> - <constant name="OBJECT_RESOURCE_COUNT" value="9" enum="Monitor"> + <constant name="OBJECT_RESOURCE_COUNT" value="7" enum="Monitor"> Number of resources currently used. </constant> - <constant name="OBJECT_NODE_COUNT" value="10" enum="Monitor"> + <constant name="OBJECT_NODE_COUNT" value="8" enum="Monitor"> Number of nodes currently instanced in the scene tree. This also includes the root node. </constant> - <constant name="OBJECT_ORPHAN_NODE_COUNT" value="11" enum="Monitor"> + <constant name="OBJECT_ORPHAN_NODE_COUNT" value="9" enum="Monitor"> Number of orphan nodes, i.e. nodes which are not parented to a node of the scene tree. </constant> - <constant name="RENDER_OBJECTS_IN_FRAME" value="12" enum="Monitor"> + <constant name="RENDER_OBJECTS_IN_FRAME" value="10" enum="Monitor"> 3D objects drawn per frame. </constant> - <constant name="RENDER_VERTICES_IN_FRAME" value="13" enum="Monitor"> + <constant name="RENDER_VERTICES_IN_FRAME" value="11" enum="Monitor"> Vertices drawn per frame. 3D only. </constant> - <constant name="RENDER_MATERIAL_CHANGES_IN_FRAME" value="14" enum="Monitor"> + <constant name="RENDER_MATERIAL_CHANGES_IN_FRAME" value="12" enum="Monitor"> Material changes per frame. 3D only. </constant> - <constant name="RENDER_SHADER_CHANGES_IN_FRAME" value="15" enum="Monitor"> + <constant name="RENDER_SHADER_CHANGES_IN_FRAME" value="13" enum="Monitor"> Shader changes per frame. 3D only. </constant> - <constant name="RENDER_SURFACE_CHANGES_IN_FRAME" value="16" enum="Monitor"> + <constant name="RENDER_SURFACE_CHANGES_IN_FRAME" value="14" enum="Monitor"> Render surface changes per frame. 3D only. </constant> - <constant name="RENDER_DRAW_CALLS_IN_FRAME" value="17" enum="Monitor"> + <constant name="RENDER_DRAW_CALLS_IN_FRAME" value="15" enum="Monitor"> Draw calls per frame. 3D only. </constant> - <constant name="RENDER_VIDEO_MEM_USED" value="18" enum="Monitor"> + <constant name="RENDER_VIDEO_MEM_USED" value="16" enum="Monitor"> The amount of video memory used, i.e. texture and vertex memory combined. </constant> - <constant name="RENDER_TEXTURE_MEM_USED" value="19" enum="Monitor"> + <constant name="RENDER_TEXTURE_MEM_USED" value="17" enum="Monitor"> The amount of texture memory used. </constant> - <constant name="RENDER_VERTEX_MEM_USED" value="20" enum="Monitor"> + <constant name="RENDER_VERTEX_MEM_USED" value="18" enum="Monitor"> The amount of vertex memory used. </constant> - <constant name="RENDER_USAGE_VIDEO_MEM_TOTAL" value="21" enum="Monitor"> + <constant name="RENDER_USAGE_VIDEO_MEM_TOTAL" value="19" enum="Monitor"> Unimplemented in the GLES2 rendering backend, always returns 0. </constant> - <constant name="PHYSICS_2D_ACTIVE_OBJECTS" value="22" enum="Monitor"> + <constant name="PHYSICS_2D_ACTIVE_OBJECTS" value="20" enum="Monitor"> Number of active [RigidBody2D] nodes in the game. </constant> - <constant name="PHYSICS_2D_COLLISION_PAIRS" value="23" enum="Monitor"> + <constant name="PHYSICS_2D_COLLISION_PAIRS" value="21" enum="Monitor"> Number of collision pairs in the 2D physics engine. </constant> - <constant name="PHYSICS_2D_ISLAND_COUNT" value="24" enum="Monitor"> + <constant name="PHYSICS_2D_ISLAND_COUNT" value="22" enum="Monitor"> Number of islands in the 2D physics engine. </constant> - <constant name="PHYSICS_3D_ACTIVE_OBJECTS" value="25" enum="Monitor"> + <constant name="PHYSICS_3D_ACTIVE_OBJECTS" value="23" enum="Monitor"> Number of active [RigidBody] and [VehicleBody] nodes in the game. </constant> - <constant name="PHYSICS_3D_COLLISION_PAIRS" value="26" enum="Monitor"> + <constant name="PHYSICS_3D_COLLISION_PAIRS" value="24" enum="Monitor"> Number of collision pairs in the 3D physics engine. </constant> - <constant name="PHYSICS_3D_ISLAND_COUNT" value="27" enum="Monitor"> + <constant name="PHYSICS_3D_ISLAND_COUNT" value="25" enum="Monitor"> Number of islands in the 3D physics engine. </constant> - <constant name="AUDIO_OUTPUT_LATENCY" value="28" enum="Monitor"> + <constant name="AUDIO_OUTPUT_LATENCY" value="26" enum="Monitor"> Output latency of the [AudioServer]. </constant> - <constant name="MONITOR_MAX" value="29" enum="Monitor"> + <constant name="MONITOR_MAX" value="27" enum="Monitor"> Represents the size of the [enum Monitor] enum. </constant> </constants> diff --git a/doc/classes/Polygon2D.xml b/doc/classes/Polygon2D.xml index af4e8e1671..2a408e277a 100644 --- a/doc/classes/Polygon2D.xml +++ b/doc/classes/Polygon2D.xml @@ -14,7 +14,7 @@ </return> <argument index="0" name="path" type="NodePath"> </argument> - <argument index="1" name="weights" type="PoolRealArray"> + <argument index="1" name="weights" type="PackedRealArray"> </argument> <description> </description> @@ -48,7 +48,7 @@ </description> </method> <method name="get_bone_weights" qualifiers="const"> - <return type="PoolRealArray"> + <return type="PackedRealArray"> </return> <argument index="0" name="index" type="int"> </argument> @@ -70,7 +70,7 @@ </return> <argument index="0" name="index" type="int"> </argument> - <argument index="1" name="weights" type="PoolRealArray"> + <argument index="1" name="weights" type="PackedRealArray"> </argument> <description> </description> @@ -98,9 +98,9 @@ <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )"> The offset applied to each vertex. </member> - <member name="polygon" type="PoolVector2Array" setter="set_polygon" getter="get_polygon" default="PoolVector2Array( )"> + <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( )"> The polygon's list of vertices. The final point will be connected to the first. - [b]Note:[/b] This returns a copy of the [PoolVector2Array] rather than a reference. + [b]Note:[/b] This returns a copy of the [PackedVector2Array] rather than a reference. </member> <member name="polygons" type="Array" setter="set_polygons" getter="get_polygons" default="[ ]"> </member> @@ -127,10 +127,10 @@ <member name="texture_scale" type="Vector2" setter="set_texture_scale" getter="get_texture_scale" default="Vector2( 1, 1 )"> Amount to multiply the [code]uv[/code] coordinates when using a [code]texture[/code]. Larger values make the texture smaller, and vice versa. </member> - <member name="uv" type="PoolVector2Array" setter="set_uv" getter="get_uv" default="PoolVector2Array( )"> + <member name="uv" type="PackedVector2Array" setter="set_uv" getter="get_uv" default="PackedVector2Array( )"> Texture coordinates for each vertex of the polygon. There should be one [code]uv[/code] per polygon vertex. If there are fewer, undefined vertices will use [code](0, 0)[/code]. </member> - <member name="vertex_colors" type="PoolColorArray" setter="set_vertex_colors" getter="get_vertex_colors" default="PoolColorArray( )"> + <member name="vertex_colors" type="PackedColorArray" setter="set_vertex_colors" getter="get_vertex_colors" default="PackedColorArray( )"> Color for each vertex. Colors are interpolated between vertices, resulting in smooth gradients. There should be one per polygon vertex. If there are fewer, undefined vertices will use [code]color[/code]. </member> </members> diff --git a/doc/classes/PolygonPathFinder.xml b/doc/classes/PolygonPathFinder.xml index 28a0447f3d..0b535159a7 100644 --- a/doc/classes/PolygonPathFinder.xml +++ b/doc/classes/PolygonPathFinder.xml @@ -8,7 +8,7 @@ </tutorials> <methods> <method name="find_path"> - <return type="PoolVector2Array"> + <return type="PackedVector2Array"> </return> <argument index="0" name="from" type="Vector2"> </argument> @@ -32,7 +32,7 @@ </description> </method> <method name="get_intersections" qualifiers="const"> - <return type="PoolVector2Array"> + <return type="PackedVector2Array"> </return> <argument index="0" name="from" type="Vector2"> </argument> @@ -70,9 +70,9 @@ <method name="setup"> <return type="void"> </return> - <argument index="0" name="points" type="PoolVector2Array"> + <argument index="0" name="points" type="PackedVector2Array"> </argument> - <argument index="1" name="connections" type="PoolIntArray"> + <argument index="1" name="connections" type="PackedIntArray"> </argument> <description> </description> diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 0bedb3afe3..014ae95c4b 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -469,7 +469,7 @@ <member name="editor/script_templates_search_path" type="String" setter="" getter="" default=""res://script_templates""> Search path for project-specific script templates. Script templates will be search both in the editor-specific path and in this project-specific path. </member> - <member name="editor/search_in_file_extensions" type="PoolStringArray" setter="" getter="" default="PoolStringArray( "gd", "shader" )"> + <member name="editor/search_in_file_extensions" type="PackedStringArray" setter="" getter="" default="PackedStringArray( "gd", "shader" )"> Text-based file extensions to include in the script editor's "Find in Files" feature. You can add e.g. [code]tscn[/code] if you wish to also parse your scene files, especially if you use built-in scripts which are serialized in the scene files. </member> <member name="gui/common/default_scroll_deadzone" type="int" setter="" getter="" default="0"> @@ -815,6 +815,18 @@ <member name="memory/limits/multithreaded_server/rid_pool_prealloc" type="int" setter="" getter="" default="60"> This is used by servers when used in multi-threading mode (servers and visual). RIDs are preallocated to avoid stalling the server requesting them on threads. If servers get stalled too often when loading resources in a thread, increase this number. </member> + <member name="mono/debugger_agent/port" type="int" setter="" getter="" default="23685"> + </member> + <member name="mono/debugger_agent/wait_for_debugger" type="bool" setter="" getter="" default="false"> + </member> + <member name="mono/debugger_agent/wait_timeout" type="int" setter="" getter="" default="3000"> + </member> + <member name="mono/profiler/args" type="String" setter="" getter="" default=""log:calls,alloc,sample,output=output.mlpd""> + </member> + <member name="mono/profiler/enabled" type="bool" setter="" getter="" default="false"> + </member> + <member name="mono/unhandled_exception_policy" type="int" setter="" getter="" default="0"> + </member> <member name="network/limits/debugger_stdout/max_chars_per_second" type="int" setter="" getter="" default="2048"> Maximum amount of characters allowed to send as output from the debugger. Over this value, content is dropped. This helps not to stall the debugger connection. </member> diff --git a/doc/classes/ResourceFormatLoader.xml b/doc/classes/ResourceFormatLoader.xml index fc36f922e1..828f4cd5d1 100644 --- a/doc/classes/ResourceFormatLoader.xml +++ b/doc/classes/ResourceFormatLoader.xml @@ -24,7 +24,7 @@ </description> </method> <method name="get_recognized_extensions" qualifiers="virtual"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Gets the list of extensions for files this loader is able to read. diff --git a/doc/classes/ResourceFormatSaver.xml b/doc/classes/ResourceFormatSaver.xml index 369c158ce4..69f8b43898 100644 --- a/doc/classes/ResourceFormatSaver.xml +++ b/doc/classes/ResourceFormatSaver.xml @@ -11,7 +11,7 @@ </tutorials> <methods> <method name="get_recognized_extensions" qualifiers="virtual"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="resource" type="Resource"> </argument> diff --git a/doc/classes/ResourceLoader.xml b/doc/classes/ResourceLoader.xml index 85c9438d4f..d2a0ac22d6 100644 --- a/doc/classes/ResourceLoader.xml +++ b/doc/classes/ResourceLoader.xml @@ -24,7 +24,7 @@ </description> </method> <method name="get_dependencies"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="path" type="String"> </argument> @@ -33,7 +33,7 @@ </description> </method> <method name="get_recognized_extensions_for_type"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="type" type="String"> </argument> diff --git a/doc/classes/ResourcePreloader.xml b/doc/classes/ResourcePreloader.xml index 1e0dcaaea8..b1e8096c3a 100644 --- a/doc/classes/ResourcePreloader.xml +++ b/doc/classes/ResourcePreloader.xml @@ -31,7 +31,7 @@ </description> </method> <method name="get_resource_list" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Returns the list of resources inside the preloader. diff --git a/doc/classes/ResourceSaver.xml b/doc/classes/ResourceSaver.xml index 8c27b951f5..ecde5754f9 100644 --- a/doc/classes/ResourceSaver.xml +++ b/doc/classes/ResourceSaver.xml @@ -11,7 +11,7 @@ </tutorials> <methods> <method name="get_recognized_extensions"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="type" type="Resource"> </argument> diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml index 983f768b85..5f07133a27 100644 --- a/doc/classes/RichTextLabel.xml +++ b/doc/classes/RichTextLabel.xml @@ -113,7 +113,7 @@ <method name="parse_expressions_for_values"> <return type="Dictionary"> </return> - <argument index="0" name="expressions" type="PoolStringArray"> + <argument index="0" name="expressions" type="PackedStringArray"> </argument> <description> Parses BBCode parameter [code]expressions[/code] into a dictionary. diff --git a/doc/classes/SceneState.xml b/doc/classes/SceneState.xml index 7304e03bf6..2fcb831270 100644 --- a/doc/classes/SceneState.xml +++ b/doc/classes/SceneState.xml @@ -81,7 +81,7 @@ </description> </method> <method name="get_node_groups" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="idx" type="int"> </argument> diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml index 1499173d6b..b1d559986c 100644 --- a/doc/classes/SceneTree.xml +++ b/doc/classes/SceneTree.xml @@ -83,7 +83,7 @@ </description> </method> <method name="get_network_connected_peers" qualifiers="const"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <description> Returns the peer IDs of all connected peers of this [SceneTree]'s [member network_peer]. @@ -320,7 +320,7 @@ </description> </signal> <signal name="files_dropped"> - <argument index="0" name="files" type="PoolStringArray"> + <argument index="0" name="files" type="PackedStringArray"> </argument> <argument index="1" name="screen" type="int"> </argument> diff --git a/doc/classes/SpriteFrames.xml b/doc/classes/SpriteFrames.xml index fe4b888a3c..a4f24f0603 100644 --- a/doc/classes/SpriteFrames.xml +++ b/doc/classes/SpriteFrames.xml @@ -57,7 +57,7 @@ </description> </method> <method name="get_animation_names" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Returns an array containing the names associated to each animation. Values are placed in alphabetical order. diff --git a/doc/classes/StreamPeer.xml b/doc/classes/StreamPeer.xml index 31742199dd..a73d3c8212 100644 --- a/doc/classes/StreamPeer.xml +++ b/doc/classes/StreamPeer.xml @@ -171,7 +171,7 @@ <method name="put_data"> <return type="int" enum="Error"> </return> - <argument index="0" name="data" type="PoolByteArray"> + <argument index="0" name="data" type="PackedByteArray"> </argument> <description> Sends a chunk of data through the connection, blocking if necessary until the data is done sending. This function returns an [enum @GlobalScope.Error] code. @@ -198,7 +198,7 @@ <method name="put_partial_data"> <return type="Array"> </return> - <argument index="0" name="data" type="PoolByteArray"> + <argument index="0" name="data" type="PackedByteArray"> </argument> <description> Sends a chunk of data through the connection. If all the data could not be sent at once, only part of it will. This function returns two values, an [enum @GlobalScope.Error] code and an integer, describing how much data was actually sent. diff --git a/doc/classes/StreamPeerBuffer.xml b/doc/classes/StreamPeerBuffer.xml index 23e3890fdb..41cef9fb55 100644 --- a/doc/classes/StreamPeerBuffer.xml +++ b/doc/classes/StreamPeerBuffer.xml @@ -49,7 +49,7 @@ </method> </methods> <members> - <member name="data_array" type="PoolByteArray" setter="set_data_array" getter="get_data_array" default="PoolByteArray( )"> + <member name="data_array" type="PackedByteArray" setter="set_data_array" getter="get_data_array" default="PackedByteArray( )"> </member> </members> <constants> diff --git a/doc/classes/String.xml b/doc/classes/String.xml index cb80d04f24..fdf4e780de 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -166,64 +166,64 @@ <method name="String"> <return type="String"> </return> - <argument index="0" name="from" type="PoolByteArray"> + <argument index="0" name="from" type="PackedByteArray"> </argument> <description> - Constructs a new String from the given [PoolByteArray]. + Constructs a new String from the given [PackedByteArray]. </description> </method> <method name="String"> <return type="String"> </return> - <argument index="0" name="from" type="PoolIntArray"> + <argument index="0" name="from" type="PackedIntArray"> </argument> <description> - Constructs a new String from the given [PoolIntArray]. + Constructs a new String from the given [PackedIntArray]. </description> </method> <method name="String"> <return type="String"> </return> - <argument index="0" name="from" type="PoolRealArray"> + <argument index="0" name="from" type="PackedRealArray"> </argument> <description> - Constructs a new String from the given [PoolRealArray]. + Constructs a new String from the given [PackedRealArray]. </description> </method> <method name="String"> <return type="String"> </return> - <argument index="0" name="from" type="PoolStringArray"> + <argument index="0" name="from" type="PackedStringArray"> </argument> <description> - Constructs a new String from the given [PoolStringArray]. + Constructs a new String from the given [PackedStringArray]. </description> </method> <method name="String"> <return type="String"> </return> - <argument index="0" name="from" type="PoolVector2Array"> + <argument index="0" name="from" type="PackedVector2Array"> </argument> <description> - Constructs a new String from the given [PoolVector2Array]. + Constructs a new String from the given [PackedVector2Array]. </description> </method> <method name="String"> <return type="String"> </return> - <argument index="0" name="from" type="PoolVector3Array"> + <argument index="0" name="from" type="PackedVector3Array"> </argument> <description> - Constructs a new String from the given [PoolVector3Array]. + Constructs a new String from the given [PackedVector3Array]. </description> </method> <method name="String"> <return type="String"> </return> - <argument index="0" name="from" type="PoolColorArray"> + <argument index="0" name="from" type="PackedColorArray"> </argument> <description> - Constructs a new String from the given [PoolColorArray]. + Constructs a new String from the given [PackedColorArray]. </description> </method> <method name="begins_with"> @@ -236,7 +236,7 @@ </description> </method> <method name="bigrams"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Returns the bigrams (pairs of consecutive letters) of this string. @@ -597,7 +597,7 @@ </description> </method> <method name="md5_buffer"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <description> Returns the MD5 hash of the string as an array of bytes. @@ -732,7 +732,7 @@ </description> </method> <method name="rsplit"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="delimiter" type="String"> </argument> @@ -764,7 +764,7 @@ </description> </method> <method name="sha1_buffer"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <description> Returns the SHA-1 hash of the string as an array of bytes. @@ -778,7 +778,7 @@ </description> </method> <method name="sha256_buffer"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <description> Returns the SHA-256 hash of the string as an array of bytes. @@ -801,7 +801,7 @@ </description> </method> <method name="split"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="delimiter" type="String"> </argument> @@ -823,7 +823,7 @@ </description> </method> <method name="split_floats"> - <return type="PoolRealArray"> + <return type="PackedRealArray"> </return> <argument index="0" name="delimiter" type="String"> </argument> @@ -864,10 +864,10 @@ </description> </method> <method name="to_ascii"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <description> - Converts the String (which is a character array) to [PoolByteArray] (which is an array of bytes). The conversion is faster compared to [method to_utf8], as this method assumes that all the characters in the String are ASCII characters. + Converts the String (which is a character array) to [PackedByteArray] (which is an array of bytes). The conversion is faster compared to [method to_utf8], as this method assumes that all the characters in the String are ASCII characters. </description> </method> <method name="to_float"> @@ -899,10 +899,10 @@ </description> </method> <method name="to_utf8"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <description> - Converts the String (which is an array of characters) to [PoolByteArray] (which is an array of bytes). The conversion is a bit slower than [method to_ascii], but supports all UTF-8 characters. Therefore, you should prefer this function over [method to_ascii]. + Converts the String (which is an array of characters) to [PackedByteArray] (which is an array of bytes). The conversion is a bit slower than [method to_ascii], but supports all UTF-8 characters. Therefore, you should prefer this function over [method to_ascii]. </description> </method> <method name="trim_prefix"> diff --git a/doc/classes/SurfaceTool.xml b/doc/classes/SurfaceTool.xml index 23363fcad5..a265d16cd9 100644 --- a/doc/classes/SurfaceTool.xml +++ b/doc/classes/SurfaceTool.xml @@ -22,7 +22,7 @@ <method name="add_bones"> <return type="void"> </return> - <argument index="0" name="bones" type="PoolIntArray"> + <argument index="0" name="bones" type="PackedIntArray"> </argument> <description> Adds an array of bones for the next vertex to use. [code]bones[/code] must contain 4 integers. @@ -76,15 +76,15 @@ <method name="add_triangle_fan"> <return type="void"> </return> - <argument index="0" name="vertices" type="PoolVector3Array"> + <argument index="0" name="vertices" type="PackedVector3Array"> </argument> - <argument index="1" name="uvs" type="PoolVector2Array" default="PoolVector2Array( )"> + <argument index="1" name="uvs" type="PackedVector2Array" default="PackedVector2Array( )"> </argument> - <argument index="2" name="colors" type="PoolColorArray" default="PoolColorArray( )"> + <argument index="2" name="colors" type="PackedColorArray" default="PackedColorArray( )"> </argument> - <argument index="3" name="uv2s" type="PoolVector2Array" default="PoolVector2Array( )"> + <argument index="3" name="uv2s" type="PackedVector2Array" default="PackedVector2Array( )"> </argument> - <argument index="4" name="normals" type="PoolVector3Array" default="PoolVector3Array( )"> + <argument index="4" name="normals" type="PackedVector3Array" default="PackedVector3Array( )"> </argument> <argument index="5" name="tangents" type="Array" default="[ ]"> </argument> @@ -123,7 +123,7 @@ <method name="add_weights"> <return type="void"> </return> - <argument index="0" name="weights" type="PoolRealArray"> + <argument index="0" name="weights" type="PackedRealArray"> </argument> <description> Specifies weight values for next vertex to use. [code]weights[/code] must contain 4 values. diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index c4a05db3a7..2ab8b939c7 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -299,7 +299,7 @@ </description> </method> <method name="search" qualifiers="const"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="key" type="String"> </argument> @@ -311,7 +311,7 @@ </argument> <description> Perform a search inside the text. Search flags can be specified in the [enum SearchFlags] enum. - Returns an empty [code]PoolIntArray[/code] if no result was found. Otherwise, the result line and column can be accessed at indices specified in the [enum SearchResult] enum, e.g: + Returns an empty [code]PackedIntArray[/code] if no result was found. Otherwise, the result line and column can be accessed at indices specified in the [enum SearchResult] enum, e.g: [codeblock] var result = search(key, flags, line, column) if result.size() > 0: diff --git a/doc/classes/TextFile.xml b/doc/classes/TextFile.xml new file mode 100644 index 0000000000..1c2c2ff25c --- /dev/null +++ b/doc/classes/TextFile.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="TextFile" inherits="Resource" version="4.0"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/Theme.xml b/doc/classes/Theme.xml index d11cfc7aa2..45f49e7b31 100644 --- a/doc/classes/Theme.xml +++ b/doc/classes/Theme.xml @@ -101,12 +101,12 @@ </description> </method> <method name="get_color_list" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="type" type="String"> </argument> <description> - Returns all the [Color]s as a [PoolStringArray] filled with each [Color]'s name, for use in [method get_color], if the theme has [code]type[/code]. + Returns all the [Color]s as a [PackedStringArray] filled with each [Color]'s name, for use in [method get_color], if the theme has [code]type[/code]. </description> </method> <method name="get_constant" qualifiers="const"> @@ -121,12 +121,12 @@ </description> </method> <method name="get_constant_list" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="type" type="String"> </argument> <description> - Returns all the constants as a [PoolStringArray] filled with each constant's name, for use in [method get_constant], if the theme has [code]type[/code]. + Returns all the constants as a [PackedStringArray] filled with each constant's name, for use in [method get_constant], if the theme has [code]type[/code]. </description> </method> <method name="get_font" qualifiers="const"> @@ -141,12 +141,12 @@ </description> </method> <method name="get_font_list" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="type" type="String"> </argument> <description> - Returns all the [Font]s as a [PoolStringArray] filled with each [Font]'s name, for use in [method get_font], if the theme has [code]type[/code]. + Returns all the [Font]s as a [PackedStringArray] filled with each [Font]'s name, for use in [method get_font], if the theme has [code]type[/code]. </description> </method> <method name="get_icon" qualifiers="const"> @@ -161,12 +161,12 @@ </description> </method> <method name="get_icon_list" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="type" type="String"> </argument> <description> - Returns all the icons as a [PoolStringArray] filled with each [Texture2D]'s name, for use in [method get_icon], if the theme has [code]type[/code]. + Returns all the icons as a [PackedStringArray] filled with each [Texture2D]'s name, for use in [method get_icon], if the theme has [code]type[/code]. </description> </method> <method name="get_stylebox" qualifiers="const"> @@ -181,28 +181,28 @@ </description> </method> <method name="get_stylebox_list" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="type" type="String"> </argument> <description> - Returns all the [StyleBox]s as a [PoolStringArray] filled with each [StyleBox]'s name, for use in [method get_stylebox], if the theme has [code]type[/code]. + Returns all the [StyleBox]s as a [PackedStringArray] filled with each [StyleBox]'s name, for use in [method get_stylebox], if the theme has [code]type[/code]. </description> </method> <method name="get_stylebox_types" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> - Returns all the [StyleBox] types as a [PoolStringArray] filled with each [StyleBox]'s type, for use in [method get_stylebox] and/or [method get_stylebox_list], if the theme has [code]type[/code]. + Returns all the [StyleBox] types as a [PackedStringArray] filled with each [StyleBox]'s type, for use in [method get_stylebox] and/or [method get_stylebox_list], if the theme has [code]type[/code]. </description> </method> <method name="get_type_list" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <argument index="0" name="type" type="String"> </argument> <description> - Returns all the types in [code]type[/code] as a [PoolStringArray] for use in any of the [code]get_*[/code] functions, if the theme has [code]type[/code]. + Returns all the types in [code]type[/code] as a [PackedStringArray] for use in any of the [code]get_*[/code] functions, if the theme has [code]type[/code]. </description> </method> <method name="has_color" qualifiers="const"> diff --git a/doc/classes/Transform.xml b/doc/classes/Transform.xml index e9d7208f66..e4d367c344 100644 --- a/doc/classes/Transform.xml +++ b/doc/classes/Transform.xml @@ -154,7 +154,7 @@ <argument index="0" name="v" type="Variant"> </argument> <description> - Transforms the given [Vector3], [Plane], [AABB], or [PoolVector3Array] by this transform. + Transforms the given [Vector3], [Plane], [AABB], or [PackedVector3Array] by this transform. </description> </method> <method name="xform_inv"> @@ -163,7 +163,7 @@ <argument index="0" name="v" type="Variant"> </argument> <description> - Inverse-transforms the given [Vector3], [Plane], [AABB], or [PoolVector3Array] by this transform. + Inverse-transforms the given [Vector3], [Plane], [AABB], or [PackedVector3Array] by this transform. </description> </method> </methods> diff --git a/doc/classes/Transform2D.xml b/doc/classes/Transform2D.xml index 9719326f59..af93d4c654 100644 --- a/doc/classes/Transform2D.xml +++ b/doc/classes/Transform2D.xml @@ -156,7 +156,7 @@ <argument index="0" name="v" type="Variant"> </argument> <description> - Transforms the given [Vector2], [Rect2], or [PoolVector2Array] by this transform. + Transforms the given [Vector2], [Rect2], or [PackedVector2Array] by this transform. </description> </method> <method name="xform_inv"> @@ -165,7 +165,7 @@ <argument index="0" name="v" type="Variant"> </argument> <description> - Inverse-transforms the given [Vector2], [Rect2], or [PoolVector2Array] by this transform. + Inverse-transforms the given [Vector2], [Rect2], or [PackedVector2Array] by this transform. </description> </method> </methods> diff --git a/doc/classes/Translation.xml b/doc/classes/Translation.xml index f80e59f6f9..c0c5a3ffbd 100644 --- a/doc/classes/Translation.xml +++ b/doc/classes/Translation.xml @@ -48,7 +48,7 @@ </description> </method> <method name="get_message_list" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Returns all the messages (keys). diff --git a/doc/classes/UDPServer.xml b/doc/classes/UDPServer.xml new file mode 100644 index 0000000000..7f40edf61d --- /dev/null +++ b/doc/classes/UDPServer.xml @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="UDPServer" inherits="Reference" version="4.0"> + <brief_description> + Helper class to implement a UDP server. + </brief_description> + <description> + A simple server that opens a UDP socket and returns connected [PacketPeerUDP] upon receiving new packets. See also [method PacketPeerUDP.connect_to_host]. + Below a small example of how it can be used: + [codeblock] + # server.gd + extends Node + + var server := UDPServer.new() + var peers = [] + + func _ready(): + server.listen(4242) + + func _process(delta): + if server.is_connection_available(): + var peer : PacketPeerUDP = server.take_connection() + var pkt = peer.get_packet() + print("Accepted peer: %s:%s" % [peer.get_packet_ip(), peer.get_packet_port()]) + print("Received data: %s" % [pkt.get_string_from_utf8()]) + # Reply so it knows we received the message. + peer.put_packet(pkt) + # Keep a reference so we can keep contacting the remote peer. + peers.append(peer) + + for i in range(0, peers.size()): + pass # Do something with the connected peers. + + [/codeblock] + [codeblock] + # client.gd + extends Node + + var udp := PacketPeerUDP.new() + var connected = false + + func _ready(): + udp.connect_to_host("127.0.0.1", 4242) + + func _process(delta): + if !connected: + # Try to contact server + udp.put_packet("The answer is... 42!".to_utf8()) + if udp.get_available_packet_count() > 0: + print("Connected: %s" % udp.get_packet().get_string_from_utf8()) + connected = true + [/codeblock] + </description> + <tutorials> + </tutorials> + <methods> + <method name="is_connection_available" qualifiers="const"> + <return type="bool"> + </return> + <description> + Returns [code]true[/code] if a packet with a new address/port combination is received on the socket. + </description> + </method> + <method name="is_listening" qualifiers="const"> + <return type="bool"> + </return> + <description> + Returns [code]true[/code] if the socket is open and listening on a port. + </description> + </method> + <method name="listen"> + <return type="int" enum="Error"> + </return> + <argument index="0" name="port" type="int"> + </argument> + <argument index="1" name="bind_address" type="String" default=""*""> + </argument> + <description> + Starts the server by opening a UDP socket listening on the given port. You can optionally specify a [code]bind_address[/code] to only listen for packets sent to that address. See also [method PacketPeerUDP.listen]. + </description> + </method> + <method name="stop"> + <return type="void"> + </return> + <description> + Stops the server, closing the UDP socket if open. Will not disconnect any connected [PacketPeerUDP]. + </description> + </method> + <method name="take_connection"> + <return type="PacketPeerUDP"> + </return> + <description> + Returns a [PacketPeerUDP] connected to the address/port combination of the first packet in queue. Will return [code]null[/code] if no packet is in queue. See also [method PacketPeerUDP.connect_to_host]. + </description> + </method> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/VisualServer.xml b/doc/classes/VisualServer.xml index c51811397a..de8bb2c33f 100644 --- a/doc/classes/VisualServer.xml +++ b/doc/classes/VisualServer.xml @@ -540,7 +540,7 @@ </return> <argument index="0" name="occluder_polygon" type="RID"> </argument> - <argument index="1" name="shape" type="PoolVector2Array"> + <argument index="1" name="shape" type="PackedVector2Array"> </argument> <argument index="2" name="closed" type="bool"> </argument> @@ -553,7 +553,7 @@ </return> <argument index="0" name="occluder_polygon" type="RID"> </argument> - <argument index="1" name="shape" type="PoolVector2Array"> + <argument index="1" name="shape" type="PackedVector2Array"> </argument> <description> Sets the shape of the occluder polygon as lines. @@ -1564,7 +1564,7 @@ </description> </method> <method name="lightmap_capture_get_octree" qualifiers="const"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <argument index="0" name="capture" type="RID"> </argument> @@ -1617,7 +1617,7 @@ </return> <argument index="0" name="capture" type="RID"> </argument> - <argument index="1" name="octree" type="PoolByteArray"> + <argument index="1" name="octree" type="PackedByteArray"> </argument> <description> Sets the octree to be used by this lightmap capture. @@ -1902,7 +1902,7 @@ </argument> <argument index="2" name="offset" type="int"> </argument> - <argument index="3" name="data" type="PoolByteArray"> + <argument index="3" name="data" type="PackedByteArray"> </argument> <description> Updates a specific region of a vertex buffer for the specified surface. Warning: this function alters the vertex buffer directly with no safety mechanisms, you can easily corrupt your mesh. @@ -1943,7 +1943,7 @@ </description> </method> <method name="multimesh_get_buffer" qualifiers="const"> - <return type="PoolRealArray"> + <return type="PackedRealArray"> </return> <argument index="0" name="multimesh" type="RID"> </argument> @@ -2078,7 +2078,7 @@ </return> <argument index="0" name="multimesh" type="RID"> </argument> - <argument index="1" name="buffer" type="PoolRealArray"> + <argument index="1" name="buffer" type="PackedRealArray"> </argument> <description> </description> diff --git a/doc/classes/VisualShader.xml b/doc/classes/VisualShader.xml index 44e843f8a5..99ba665979 100644 --- a/doc/classes/VisualShader.xml +++ b/doc/classes/VisualShader.xml @@ -107,7 +107,7 @@ </description> </method> <method name="get_node_list" qualifiers="const"> - <return type="PoolIntArray"> + <return type="PackedIntArray"> </return> <argument index="0" name="type" type="int" enum="VisualShader.Type"> </argument> diff --git a/doc/classes/XMLParser.xml b/doc/classes/XMLParser.xml index 8140fde62d..2849ea62ab 100644 --- a/doc/classes/XMLParser.xml +++ b/doc/classes/XMLParser.xml @@ -115,7 +115,7 @@ <method name="open_buffer"> <return type="int" enum="Error"> </return> - <argument index="0" name="buffer" type="PoolByteArray"> + <argument index="0" name="buffer" type="PackedByteArray"> </argument> <description> Opens an XML raw buffer for parsing. This returns an error code. diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index 4eb4b32931..f7e412be63 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -544,14 +544,14 @@ Error NetSocketPosix::recv(uint8_t *p_buffer, int p_len, int &r_read) { return OK; } -Error NetSocketPosix::recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) { +Error NetSocketPosix::recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port, bool p_peek) { ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); struct sockaddr_storage from; socklen_t len = sizeof(struct sockaddr_storage); memset(&from, 0, len); - r_read = ::recvfrom(_sock, SOCK_BUF(p_buffer), p_len, 0, (struct sockaddr *)&from, &len); + r_read = ::recvfrom(_sock, SOCK_BUF(p_buffer), p_len, p_peek ? MSG_PEEK : 0, (struct sockaddr *)&from, &len); if (r_read < 0) { NetError err = _get_socket_error(); diff --git a/drivers/unix/net_socket_posix.h b/drivers/unix/net_socket_posix.h index 25ac6e2e56..0a19967265 100644 --- a/drivers/unix/net_socket_posix.h +++ b/drivers/unix/net_socket_posix.h @@ -81,7 +81,7 @@ public: virtual Error connect_to_host(IP_Address p_host, uint16_t p_port); virtual Error poll(PollType p_type, int timeout) const; virtual Error recv(uint8_t *p_buffer, int p_len, int &r_read); - virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port); + virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port, bool p_peek = false); virtual Error send(const uint8_t *p_buffer, int p_len, int &r_sent); virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port); virtual Ref<NetSocket> accept(IP_Address &r_ip, uint16_t &r_port); diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index ca488fc3a3..72acedb88f 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -30,8 +30,8 @@ #include "vulkan_context.h" #include "core/engine.h" -#include "core/print_string.h" #include "core/project_settings.h" +#include "core/ustring.h" #include "core/version.h" #include "vk_enum_string_helper.h" #include <stdio.h> @@ -46,94 +46,99 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanContext::_debug_messenger_callback(VkDebugU VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, void *pUserData) { - char prefix[64] = ""; - char *message = (char *)malloc(strlen(pCallbackData->pMessage) + 5000); - ERR_FAIL_COND_V(!message, false); //This error needs to be ignored because the AMD allocator will mix up memory types on IGP processors if (strstr(pCallbackData->pMessage, "Mapping an image with layout") != NULL && strstr(pCallbackData->pMessage, "can result in undefined behavior if this memory is used by the device") != NULL) { - free(message); return VK_FALSE; } // This needs to be ignored because Validator is wrong here if (strstr(pCallbackData->pMessage, "SPIR-V module not valid: Pointer operand") != NULL && strstr(pCallbackData->pMessage, "must be a memory object") != NULL) { - free(message); return VK_FALSE; } if (strstr(pCallbackData->pMessageIdName, "UNASSIGNED-CoreValidation-DrawState-ClearCmdBeforeDraw") != NULL) { - free(message); return VK_FALSE; } - if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) { - strcat(prefix, "VERBOSE : "); - } else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) { - strcat(prefix, "INFO : "); - } else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) { - strcat(prefix, "WARNING : "); - } else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) { - strcat(prefix, "ERROR : "); + String severity_string; + switch (messageSeverity) { + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: + severity_string = "VERBOSE : "; + break; + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: + severity_string = "INFO : "; + break; + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: + severity_string = "WARNING : "; + break; + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: + severity_string = "ERROR : "; + break; + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_FLAG_BITS_MAX_ENUM_EXT: + break; } - if (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT) { - strcat(prefix, "GENERAL"); - } else { - if (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT) { - strcat(prefix, "VALIDATION"); - //validation_error = 1; - } - if (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) { - if (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT) { - strcat(prefix, "|"); - } - strcat(prefix, "PERFORMANCE"); - } + String type_string; + switch (messageType) { + case (VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT): + type_string = "GENERAL"; + break; + case (VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT): + type_string = "VALIDATION"; + break; + case (VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT): + type_string = "PERFORMANCE"; + break; + case (VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT): + type_string = "VALIDATION|PERFORMANCE"; + break; } - sprintf(message, "%s - Message Id Number: %d | Message Id Name: %s\n\t%s\n", prefix, pCallbackData->messageIdNumber, - pCallbackData->pMessageIdName, pCallbackData->pMessage); - + String objects_string; if (pCallbackData->objectCount > 0) { - char tmp_message[500]; - sprintf(tmp_message, "\n\tObjects - %d\n", pCallbackData->objectCount); - strcat(message, tmp_message); + objects_string = "\n\tObjects - " + String::num_int64(pCallbackData->objectCount); for (uint32_t object = 0; object < pCallbackData->objectCount; ++object) { + objects_string += + "\n\t\tObject[" + String::num_int64(object) + "]" + + " - " + string_VkObjectType(pCallbackData->pObjects[object].objectType) + + ", Handle " + String::num_int64(pCallbackData->pObjects[object].objectHandle); if (NULL != pCallbackData->pObjects[object].pObjectName && strlen(pCallbackData->pObjects[object].pObjectName) > 0) { - sprintf(tmp_message, "\t\tObject[%d] - %s, Handle %p, Name \"%s\"\n", object, - string_VkObjectType(pCallbackData->pObjects[object].objectType), - (void *)(pCallbackData->pObjects[object].objectHandle), pCallbackData->pObjects[object].pObjectName); - } else { - sprintf(tmp_message, "\t\tObject[%d] - %s, Handle %p\n", object, - string_VkObjectType(pCallbackData->pObjects[object].objectType), - (void *)(pCallbackData->pObjects[object].objectHandle)); + objects_string += ", Name \"" + String(pCallbackData->pObjects[object].pObjectName) + "\""; } - strcat(message, tmp_message); } } + + String labels_string; if (pCallbackData->cmdBufLabelCount > 0) { - char tmp_message[500]; - sprintf(tmp_message, "\n\tCommand Buffer Labels - %d\n", pCallbackData->cmdBufLabelCount); - strcat(message, tmp_message); + labels_string = "\n\tCommand Buffer Labels - " + String::num_int64(pCallbackData->cmdBufLabelCount); for (uint32_t cmd_buf_label = 0; cmd_buf_label < pCallbackData->cmdBufLabelCount; ++cmd_buf_label) { - sprintf(tmp_message, "\t\tLabel[%d] - %s { %f, %f, %f, %f}\n", cmd_buf_label, - pCallbackData->pCmdBufLabels[cmd_buf_label].pLabelName, pCallbackData->pCmdBufLabels[cmd_buf_label].color[0], - pCallbackData->pCmdBufLabels[cmd_buf_label].color[1], pCallbackData->pCmdBufLabels[cmd_buf_label].color[2], - pCallbackData->pCmdBufLabels[cmd_buf_label].color[3]); - strcat(message, tmp_message); + labels_string += + "\n\t\tLabel[" + String::num_int64(cmd_buf_label) + "]" + + " - " + pCallbackData->pCmdBufLabels[cmd_buf_label].pLabelName + + "{ "; + for (int color_idx = 0; color_idx < 4; ++color_idx) { + labels_string += String::num(pCallbackData->pCmdBufLabels[cmd_buf_label].color[color_idx]); + if (color_idx < 3) { + labels_string += ", "; + } + } + labels_string += " }"; } } - ERR_PRINT(message); + String error_message(severity_string + type_string + + " - Message Id Number: " + String::num_int64(pCallbackData->messageIdNumber) + + " | Message Id Name: " + pCallbackData->pMessageIdName + + "\n\t" + pCallbackData->pMessage + + objects_string + labels_string); - free(message); + ERR_PRINT(error_message); - if (Engine::get_singleton()->is_abort_on_gpu_errors_enabled()) { - abort(); - } - // Don't bail out, but keep going. - return false; + CRASH_COND_MSG(Engine::get_singleton()->is_abort_on_gpu_errors_enabled(), + "Crashing, because abort on GPU errors is enabled."); + + return VK_FALSE; } VkBool32 VulkanContext::_check_layers(uint32_t check_count, const char **check_names, uint32_t layer_count, VkLayerProperties *layers) { diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 86b2642faa..4b8bf7f687 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -225,33 +225,26 @@ void EditorPropertyArray::update_property() { switch (array_type) { case Variant::ARRAY: { arrtype = "Array"; - } break; // arrays case Variant::PACKED_BYTE_ARRAY: { arrtype = "PackedByteArray"; - } break; case Variant::PACKED_INT_ARRAY: { arrtype = "PackedIntArray"; - } break; case Variant::PACKED_REAL_ARRAY: { - - arrtype = "PoolFloatArray"; + arrtype = "PackedRealArray"; } break; case Variant::PACKED_STRING_ARRAY: { - arrtype = "PackedStringArray"; } break; case Variant::PACKED_VECTOR2_ARRAY: { - arrtype = "PackedVector2Array"; } break; case Variant::PACKED_VECTOR3_ARRAY: { arrtype = "PackedVector3Array"; - } break; case Variant::PACKED_COLOR_ARRAY: { arrtype = "PackedColorArray"; diff --git a/modules/csg/doc_classes/CSGPolygon.xml b/modules/csg/doc_classes/CSGPolygon.xml index 64ae46c69a..02b2e8b03f 100644 --- a/modules/csg/doc_classes/CSGPolygon.xml +++ b/modules/csg/doc_classes/CSGPolygon.xml @@ -38,7 +38,7 @@ <member name="path_rotation" type="int" setter="set_path_rotation" getter="get_path_rotation" enum="CSGPolygon.PathRotation"> The method by which each slice is rotated along the path when [member mode] is [constant MODE_PATH]. </member> - <member name="polygon" type="PoolVector2Array" setter="set_polygon" getter="get_polygon" default="PoolVector2Array( 0, 0, 0, 1, 1, 1, 1, 0 )"> + <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( 0, 0, 0, 1, 1, 1, 1, 0 )"> Point array that defines the shape that we'll extrude. </member> <member name="smooth_faces" type="bool" setter="set_smooth_faces" getter="get_smooth_faces" default="false"> diff --git a/modules/enet/doc_classes/NetworkedMultiplayerENet.xml b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml index 76b3710e96..456bf649d2 100644 --- a/modules/enet/doc_classes/NetworkedMultiplayerENet.xml +++ b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml @@ -104,6 +104,24 @@ The IP used when creating a server. This is set to the wildcard [code]"*"[/code] by default, which binds to all available interfaces. The given IP needs to be in IPv4 or IPv6 address format, for example: [code]"192.168.1.1"[/code]. </description> </method> + <method name="set_dtls_certificate"> + <return type="void"> + </return> + <argument index="0" name="certificate" type="X509Certificate"> + </argument> + <description> + Configure the [X509Certificate] to use when [member use_dtls] is [code]true[/code]. For servers, you must also setup the [CryptoKey] via [method set_dtls_key]. + </description> + </method> + <method name="set_dtls_key"> + <return type="void"> + </return> + <argument index="0" name="key" type="CryptoKey"> + </argument> + <description> + Configure the [CryptoKey] to use when [member use_dtls] is [code]true[/code]. Remember to also call [method set_dtls_certificate] to setup your [X509Certificate]. + </description> + </method> </methods> <members> <member name="always_ordered" type="bool" setter="set_always_ordered" getter="is_always_ordered" default="false"> @@ -115,6 +133,9 @@ <member name="compression_mode" type="int" setter="set_compression_mode" getter="get_compression_mode" enum="NetworkedMultiplayerENet.CompressionMode" default="0"> The compression method used for network packets. These have different tradeoffs of compression speed versus bandwidth, you may need to test which one works best for your use case if you use compression at all. </member> + <member name="dtls_verify" type="bool" setter="set_dtls_verify_enabled" getter="is_dtls_verify_enabled" default="true"> + Enable or disable certiticate verification when [member use_dtls] [code]true[/code]. + </member> <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" /> <member name="server_relay" type="bool" setter="set_server_relay_enabled" getter="is_server_relay_enabled" default="true"> Enable or disable the server feature that notifies clients of other peers' connection/disconnection, and relays messages between them. When this option is [code]false[/code], clients won't be automatically notified of other peers and won't be able to send them packets through the server. @@ -123,6 +144,10 @@ Set the default channel to be used to transfer data. By default, this value is [code]-1[/code] which means that ENet will only use 2 channels, one for reliable and one for unreliable packets. Channel [code]0[/code] is reserved, and cannot be used. Setting this member to any value between [code]0[/code] and [member channel_count] (excluded) will force ENet to use that channel for sending data. </member> <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="NetworkedMultiplayerPeer.TransferMode" default="2" /> + <member name="use_dtls" type="bool" setter="set_dtls_enabled" getter="is_dtls_enabled" default="false"> + When enabled, the client or server created by this peer, will use [PacketPeerDTLS] instead of raw UDP sockets for communicating with the remote peer. This will make the communication encrypted with DTLS at the cost of higher resource usage and potentially larger packet size. + Note: When creating a DTLS server, make sure you setup the key/certificate pair via [method set_dtls_key] and [method set_dtls_certificate]. For DTLS clients, have a look at the [member dtls_verify] option, and configure the certificate accordingly via [method set_dtls_certificate]. + </member> </members> <constants> <constant name="COMPRESS_NONE" value="0" enum="CompressionMode"> diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index ca134824f7..406eb467f0 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -78,6 +78,7 @@ Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int ERR_FAIL_COND_V_MSG(p_max_clients < 1 || p_max_clients > 4095, ERR_INVALID_PARAMETER, "The number of clients must be set between 1 and 4095 (inclusive)."); ERR_FAIL_COND_V_MSG(p_in_bandwidth < 0, ERR_INVALID_PARAMETER, "The incoming bandwidth limit must be greater than or equal to 0 (0 disables the limit)."); ERR_FAIL_COND_V_MSG(p_out_bandwidth < 0, ERR_INVALID_PARAMETER, "The outgoing bandwidth limit must be greater than or equal to 0 (0 disables the limit)."); + ERR_FAIL_COND_V(dtls_enabled && (dtls_key.is_null() || dtls_cert.is_null()), ERR_INVALID_PARAMETER); ENetAddress address; memset(&address, 0, sizeof(address)); @@ -105,6 +106,11 @@ Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int p_out_bandwidth /* limit outgoing bandwidth if > 0 */); ERR_FAIL_COND_V_MSG(!host, ERR_CANT_CREATE, "Couldn't create an ENet multiplayer server."); +#ifdef GODOT_ENET + if (dtls_enabled) { + enet_host_dtls_server_setup(host, dtls_key.ptr(), dtls_cert.ptr()); + } +#endif _setup_compressor(); active = true; @@ -156,6 +162,11 @@ Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_por } ERR_FAIL_COND_V_MSG(!host, ERR_CANT_CREATE, "Couldn't create the ENet client host."); +#ifdef GODOT_ENET + if (dtls_enabled) { + enet_host_dtls_client_setup(host, dtls_cert.ptr(), dtls_verify, p_address.utf8().get_data()); + } +#endif _setup_compressor(); @@ -856,6 +867,12 @@ void NetworkedMultiplayerENet::_bind_methods() { ClassDB::bind_method(D_METHOD("set_compression_mode", "mode"), &NetworkedMultiplayerENet::set_compression_mode); ClassDB::bind_method(D_METHOD("get_compression_mode"), &NetworkedMultiplayerENet::get_compression_mode); ClassDB::bind_method(D_METHOD("set_bind_ip", "ip"), &NetworkedMultiplayerENet::set_bind_ip); + ClassDB::bind_method(D_METHOD("set_dtls_enabled", "enabled"), &NetworkedMultiplayerENet::set_dtls_enabled); + ClassDB::bind_method(D_METHOD("is_dtls_enabled"), &NetworkedMultiplayerENet::is_dtls_enabled); + ClassDB::bind_method(D_METHOD("set_dtls_key", "key"), &NetworkedMultiplayerENet::set_dtls_key); + ClassDB::bind_method(D_METHOD("set_dtls_certificate", "certificate"), &NetworkedMultiplayerENet::set_dtls_certificate); + ClassDB::bind_method(D_METHOD("set_dtls_verify_enabled", "enabled"), &NetworkedMultiplayerENet::set_dtls_verify_enabled); + ClassDB::bind_method(D_METHOD("is_dtls_verify_enabled"), &NetworkedMultiplayerENet::is_dtls_verify_enabled); ClassDB::bind_method(D_METHOD("get_peer_address", "id"), &NetworkedMultiplayerENet::get_peer_address); ClassDB::bind_method(D_METHOD("get_peer_port", "id"), &NetworkedMultiplayerENet::get_peer_port); @@ -875,6 +892,8 @@ void NetworkedMultiplayerENet::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_count"), "set_channel_count", "get_channel_count"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "always_ordered"), "set_always_ordered", "is_always_ordered"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "server_relay"), "set_server_relay_enabled", "is_server_relay_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dtls_verify"), "set_dtls_verify_enabled", "is_dtls_verify_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_dtls"), "set_dtls_enabled", "is_dtls_enabled"); BIND_ENUM_CONSTANT(COMPRESS_NONE); BIND_ENUM_CONSTANT(COMPRESS_RANGE_CODER); @@ -904,6 +923,9 @@ NetworkedMultiplayerENet::NetworkedMultiplayerENet() { enet_compressor.destroy = enet_compressor_destroy; bind_ip = IP_Address("*"); + + dtls_enabled = false; + dtls_verify = true; } NetworkedMultiplayerENet::~NetworkedMultiplayerENet() { @@ -920,3 +942,31 @@ void NetworkedMultiplayerENet::set_bind_ip(const IP_Address &p_ip) { bind_ip = p_ip; } + +void NetworkedMultiplayerENet::set_dtls_enabled(bool p_enabled) { + ERR_FAIL_COND(active); + dtls_enabled = p_enabled; +} + +bool NetworkedMultiplayerENet::is_dtls_enabled() const { + return dtls_enabled; +} + +void NetworkedMultiplayerENet::set_dtls_verify_enabled(bool p_enabled) { + ERR_FAIL_COND(active); + dtls_verify = p_enabled; +} + +bool NetworkedMultiplayerENet::is_dtls_verify_enabled() const { + return dtls_verify; +} + +void NetworkedMultiplayerENet::set_dtls_key(Ref<CryptoKey> p_key) { + ERR_FAIL_COND(active); + dtls_key = p_key; +} + +void NetworkedMultiplayerENet::set_dtls_certificate(Ref<X509Certificate> p_cert) { + ERR_FAIL_COND(active); + dtls_cert = p_cert; +} diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h index 11487b99a5..ff436ce2c0 100644 --- a/modules/enet/networked_multiplayer_enet.h +++ b/modules/enet/networked_multiplayer_enet.h @@ -31,6 +31,7 @@ #ifndef NETWORKED_MULTIPLAYER_ENET_H #define NETWORKED_MULTIPLAYER_ENET_H +#include "core/crypto/crypto.h" #include "core/io/compression.h" #include "core/io/networked_multiplayer_peer.h" @@ -111,6 +112,11 @@ private: IP_Address bind_ip; + bool dtls_enabled; + Ref<CryptoKey> dtls_key; + Ref<X509Certificate> dtls_cert; + bool dtls_verify; + protected: static void _bind_methods(); @@ -166,6 +172,12 @@ public: ~NetworkedMultiplayerENet(); void set_bind_ip(const IP_Address &p_ip); + void set_dtls_enabled(bool p_enabled); + bool is_dtls_enabled() const; + void set_dtls_verify_enabled(bool p_enabled); + bool is_dtls_verify_enabled() const; + void set_dtls_key(Ref<CryptoKey> p_key); + void set_dtls_certificate(Ref<X509Certificate> p_cert); }; VARIANT_ENUM_CAST(NetworkedMultiplayerENet::CompressionMode); diff --git a/modules/gdnative/doc_classes/GDNativeLibrary.xml b/modules/gdnative/doc_classes/GDNativeLibrary.xml index 820f126dd1..601e132d42 100644 --- a/modules/gdnative/doc_classes/GDNativeLibrary.xml +++ b/modules/gdnative/doc_classes/GDNativeLibrary.xml @@ -12,7 +12,7 @@ </tutorials> <methods> <method name="get_current_dependencies" qualifiers="const"> - <return type="PoolStringArray"> + <return type="PackedStringArray"> </return> <description> Returns paths to all dependency libraries for the current platform and architecture. diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 9fc8ad5573..cf76c09294 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -131,7 +131,7 @@ <method name="bytes2var"> <return type="Variant"> </return> - <argument index="0" name="bytes" type="PoolByteArray"> + <argument index="0" name="bytes" type="PackedByteArray"> </argument> <argument index="1" name="allow_objects" type="bool" default="false"> </argument> @@ -1245,7 +1245,7 @@ </description> </method> <method name="var2bytes"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <argument index="0" name="var" type="Variant"> </argument> diff --git a/modules/gdscript/doc_classes/GDScript.xml b/modules/gdscript/doc_classes/GDScript.xml index 5d0e93e117..62ccb93901 100644 --- a/modules/gdscript/doc_classes/GDScript.xml +++ b/modules/gdscript/doc_classes/GDScript.xml @@ -12,7 +12,7 @@ </tutorials> <methods> <method name="get_as_byte_code" qualifiers="const"> - <return type="PoolByteArray"> + <return type="PackedByteArray"> </return> <description> Returns byte code for the script source code. diff --git a/modules/mbedtls/dtls_server_mbedtls.cpp b/modules/mbedtls/dtls_server_mbedtls.cpp new file mode 100644 index 0000000000..c4ac69e9ab --- /dev/null +++ b/modules/mbedtls/dtls_server_mbedtls.cpp @@ -0,0 +1,78 @@ +/*************************************************************************/ +/* dtls_server_mbedtls.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "dtls_server_mbedtls.h" +#include "packet_peer_mbed_dtls.h" + +Error DTLSServerMbedTLS::setup(Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert, Ref<X509Certificate> p_ca_chain) { + ERR_FAIL_COND_V(_cookies->setup() != OK, ERR_ALREADY_IN_USE); + _key = p_key; + _cert = p_cert; + _ca_chain = p_ca_chain; + return OK; +} + +void DTLSServerMbedTLS::stop() { + _cookies->clear(); +} + +Ref<PacketPeerDTLS> DTLSServerMbedTLS::take_connection(Ref<PacketPeerUDP> p_udp_peer) { + Ref<PacketPeerMbedDTLS> out; + out.instance(); + + ERR_FAIL_COND_V(!out.is_valid(), out); + ERR_FAIL_COND_V(!p_udp_peer.is_valid(), out); + out->accept_peer(p_udp_peer, _key, _cert, _ca_chain, _cookies); + return out; +} + +DTLSServer *DTLSServerMbedTLS::_create_func() { + + return memnew(DTLSServerMbedTLS); +} + +void DTLSServerMbedTLS::initialize() { + + _create = _create_func; + available = true; +} + +void DTLSServerMbedTLS::finalize() { + _create = NULL; + available = false; +} + +DTLSServerMbedTLS::DTLSServerMbedTLS() { + _cookies.instance(); +} + +DTLSServerMbedTLS::~DTLSServerMbedTLS() { + stop(); +} diff --git a/modules/mbedtls/dtls_server_mbedtls.h b/modules/mbedtls/dtls_server_mbedtls.h new file mode 100644 index 0000000000..180ab7d84c --- /dev/null +++ b/modules/mbedtls/dtls_server_mbedtls.h @@ -0,0 +1,58 @@ +/*************************************************************************/ +/* dtls_server_mbedtls.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef MBED_DTLS_SERVER_H +#define MBED_DTLS_SERVER_H + +#include "core/io/dtls_server.h" +#include "ssl_context_mbedtls.h" + +class DTLSServerMbedTLS : public DTLSServer { + +private: + static DTLSServer *_create_func(); + Ref<CryptoKey> _key; + Ref<X509Certificate> _cert; + Ref<X509Certificate> _ca_chain; + Ref<CookieContextMbedTLS> _cookies; + +public: + static void initialize(); + static void finalize(); + + virtual Error setup(Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert, Ref<X509Certificate> p_ca_chain = Ref<X509Certificate>()); + virtual void stop(); + virtual Ref<PacketPeerDTLS> take_connection(Ref<PacketPeerUDP> p_peer); + + DTLSServerMbedTLS(); + ~DTLSServerMbedTLS(); +}; + +#endif // MBED_DTLS_SERVER_H diff --git a/modules/mbedtls/packet_peer_mbed_dtls.cpp b/modules/mbedtls/packet_peer_mbed_dtls.cpp new file mode 100755 index 0000000000..134bd54801 --- /dev/null +++ b/modules/mbedtls/packet_peer_mbed_dtls.cpp @@ -0,0 +1,297 @@ +/*************************************************************************/ +/* packet_peer_mbed_dtls.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "packet_peer_mbed_dtls.h" +#include "mbedtls/platform_util.h" + +#include "core/io/stream_peer_ssl.h" +#include "core/os/file_access.h" + +int PacketPeerMbedDTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) { + + if (buf == NULL || len <= 0) return 0; + + PacketPeerMbedDTLS *sp = (PacketPeerMbedDTLS *)ctx; + + ERR_FAIL_COND_V(sp == NULL, 0); + + Error err = sp->base->put_packet((const uint8_t *)buf, len); + if (err == ERR_BUSY) { + return MBEDTLS_ERR_SSL_WANT_WRITE; + } else if (err != OK) { + ERR_FAIL_V(MBEDTLS_ERR_SSL_INTERNAL_ERROR); + } + return len; +} + +int PacketPeerMbedDTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) { + + if (buf == NULL || len <= 0) return 0; + + PacketPeerMbedDTLS *sp = (PacketPeerMbedDTLS *)ctx; + + ERR_FAIL_COND_V(sp == NULL, 0); + + int pc = sp->base->get_available_packet_count(); + if (pc == 0) { + return MBEDTLS_ERR_SSL_WANT_READ; + } else if (pc < 0) { + ERR_FAIL_V(MBEDTLS_ERR_SSL_INTERNAL_ERROR); + } + + const uint8_t *buffer; + int buffer_size = 0; + Error err = sp->base->get_packet(&buffer, buffer_size); + if (err != OK) { + return MBEDTLS_ERR_SSL_INTERNAL_ERROR; + } + copymem(buf, buffer, buffer_size); + return buffer_size; +} + +void PacketPeerMbedDTLS::_cleanup() { + + ssl_ctx->clear(); + base = Ref<PacketPeer>(); + status = STATUS_DISCONNECTED; +} + +int PacketPeerMbedDTLS::_set_cookie() { + // Setup DTLS session cookie for this client + uint8_t client_id[18]; + IP_Address addr = base->get_packet_address(); + uint16_t port = base->get_packet_port(); + copymem(client_id, addr.get_ipv6(), 16); + copymem(&client_id[16], (uint8_t *)&port, 2); + return mbedtls_ssl_set_client_transport_id(ssl_ctx->get_context(), client_id, 18); +} + +Error PacketPeerMbedDTLS::_do_handshake() { + int ret = 0; + while ((ret = mbedtls_ssl_handshake(ssl_ctx->get_context())) != 0) { + if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) { + if (ret != MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED) { + ERR_PRINT("TLS handshake error: " + itos(ret)); + SSLContextMbedTLS::print_mbedtls_error(ret); + } + _cleanup(); + status = STATUS_ERROR; + return FAILED; + } + // Will retry via poll later + return OK; + } + + status = STATUS_CONNECTED; + return OK; +} + +Error PacketPeerMbedDTLS::connect_to_peer(Ref<PacketPeerUDP> p_base, bool p_validate_certs, const String &p_for_hostname, Ref<X509Certificate> p_ca_certs) { + + ERR_FAIL_COND_V(!p_base.is_valid() || !p_base->is_connected_to_host(), ERR_INVALID_PARAMETER); + + base = p_base; + int ret = 0; + int authmode = p_validate_certs ? MBEDTLS_SSL_VERIFY_REQUIRED : MBEDTLS_SSL_VERIFY_NONE; + + Error err = ssl_ctx->init_client(MBEDTLS_SSL_TRANSPORT_DATAGRAM, authmode, p_ca_certs); + ERR_FAIL_COND_V(err != OK, err); + + mbedtls_ssl_set_hostname(ssl_ctx->get_context(), p_for_hostname.utf8().get_data()); + mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, NULL); + mbedtls_ssl_set_timer_cb(ssl_ctx->get_context(), &timer, mbedtls_timing_set_delay, mbedtls_timing_get_delay); + + status = STATUS_HANDSHAKING; + + if ((ret = _do_handshake()) != OK) { + status = STATUS_ERROR_HOSTNAME_MISMATCH; + return FAILED; + } + + return OK; +} + +Error PacketPeerMbedDTLS::accept_peer(Ref<PacketPeerUDP> p_base, Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert, Ref<X509Certificate> p_ca_chain, Ref<CookieContextMbedTLS> p_cookies) { + + Error err = ssl_ctx->init_server(MBEDTLS_SSL_TRANSPORT_DATAGRAM, MBEDTLS_SSL_VERIFY_NONE, p_key, p_cert, p_cookies); + ERR_FAIL_COND_V(err != OK, err); + + base = p_base; + base->set_blocking_mode(false); + + mbedtls_ssl_session_reset(ssl_ctx->get_context()); + + int ret = _set_cookie(); + if (ret != 0) { + _cleanup(); + ERR_FAIL_V_MSG(FAILED, "Error setting DTLS client cookie"); + } + + mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, NULL); + mbedtls_ssl_set_timer_cb(ssl_ctx->get_context(), &timer, mbedtls_timing_set_delay, mbedtls_timing_get_delay); + + status = STATUS_HANDSHAKING; + + if ((ret = _do_handshake()) != OK) { + status = STATUS_ERROR; + return FAILED; + } + + return OK; +} + +Error PacketPeerMbedDTLS::put_packet(const uint8_t *p_buffer, int p_bytes) { + + ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED); + + if (p_bytes == 0) + return OK; + + int ret = mbedtls_ssl_write(ssl_ctx->get_context(), p_buffer, p_bytes); + if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) { + ret = 0; // non blocking io + } else if (ret <= 0) { + SSLContextMbedTLS::print_mbedtls_error(ret); + _cleanup(); + return ERR_CONNECTION_ERROR; + } + + return OK; +} + +Error PacketPeerMbedDTLS::get_packet(const uint8_t **r_buffer, int &r_bytes) { + + ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED); + + r_bytes = 0; + + int ret = mbedtls_ssl_read(ssl_ctx->get_context(), packet_buffer, PACKET_BUFFER_SIZE); + if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) { + ret = 0; // non blocking io + } else if (ret <= 0) { + if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { + // Also send close notify back + disconnect_from_peer(); + } else { + _cleanup(); + status = STATUS_ERROR; + SSLContextMbedTLS::print_mbedtls_error(ret); + } + return ERR_CONNECTION_ERROR; + } + *r_buffer = packet_buffer; + r_bytes = ret; + + return OK; +} + +void PacketPeerMbedDTLS::poll() { + + if (status == STATUS_HANDSHAKING) { + _do_handshake(); + return; + } else if (status != STATUS_CONNECTED) { + return; + } + + ERR_FAIL_COND(!base.is_valid()); + + int ret = mbedtls_ssl_read(ssl_ctx->get_context(), NULL, 0); + + if (ret < 0 && ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) { + if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { + // Also send close notify back + disconnect_from_peer(); + } else { + _cleanup(); + status = STATUS_ERROR; + SSLContextMbedTLS::print_mbedtls_error(ret); + } + } +} + +int PacketPeerMbedDTLS::get_available_packet_count() const { + + ERR_FAIL_COND_V(status != STATUS_CONNECTED, 0); + + return mbedtls_ssl_get_bytes_avail(&(ssl_ctx->ssl)) > 0 ? 1 : 0; +} + +int PacketPeerMbedDTLS::get_max_packet_size() const { + + return 488; // 512 (UDP in Godot) - 24 (DTLS header) +} + +PacketPeerMbedDTLS::PacketPeerMbedDTLS() { + + ssl_ctx.instance(); + status = STATUS_DISCONNECTED; +} + +PacketPeerMbedDTLS::~PacketPeerMbedDTLS() { + disconnect_from_peer(); +} + +void PacketPeerMbedDTLS::disconnect_from_peer() { + + if (status != STATUS_CONNECTED && status != STATUS_HANDSHAKING) + return; + + if (status == STATUS_CONNECTED) { + int ret = 0; + // Send SSL close notification, blocking, but ignore other errors. + do + ret = mbedtls_ssl_close_notify(ssl_ctx->get_context()); + while (ret == MBEDTLS_ERR_SSL_WANT_WRITE); + } + + _cleanup(); +} + +PacketPeerMbedDTLS::Status PacketPeerMbedDTLS::get_status() const { + + return status; +} + +PacketPeerDTLS *PacketPeerMbedDTLS::_create_func() { + + return memnew(PacketPeerMbedDTLS); +} + +void PacketPeerMbedDTLS::initialize_dtls() { + + _create = _create_func; + available = true; +} + +void PacketPeerMbedDTLS::finalize_dtls() { + _create = NULL; + available = false; +} diff --git a/modules/mbedtls/packet_peer_mbed_dtls.h b/modules/mbedtls/packet_peer_mbed_dtls.h new file mode 100755 index 0000000000..bd0856abe8 --- /dev/null +++ b/modules/mbedtls/packet_peer_mbed_dtls.h @@ -0,0 +1,88 @@ +/*************************************************************************/ +/* packet_peer_mbed_dtls.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef PACKET_PEER_MBED_DTLS_H +#define PACKET_PEER_MBED_DTLS_H + +#include "core/io/packet_peer_dtls.h" +#include "ssl_context_mbedtls.h" + +#include <mbedtls/timing.h> + +class PacketPeerMbedDTLS : public PacketPeerDTLS { +private: + enum { + PACKET_BUFFER_SIZE = 65536 + }; + + uint8_t packet_buffer[PACKET_BUFFER_SIZE]; + + Status status; + String hostname; + + Ref<PacketPeerUDP> base; + + static PacketPeerDTLS *_create_func(); + + static int bio_recv(void *ctx, unsigned char *buf, size_t len); + static int bio_send(void *ctx, const unsigned char *buf, size_t len); + void _cleanup(); + +protected: + Ref<SSLContextMbedTLS> ssl_ctx; + mbedtls_timing_delay_context timer; + + static void _bind_methods(); + + Error _do_handshake(); + int _set_cookie(); + +public: + virtual void poll(); + virtual Error accept_peer(Ref<PacketPeerUDP> p_base, Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert = Ref<X509Certificate>(), Ref<X509Certificate> p_ca_chain = Ref<X509Certificate>(), Ref<CookieContextMbedTLS> p_cookies = Ref<CookieContextMbedTLS>()); + virtual Error connect_to_peer(Ref<PacketPeerUDP> p_base, bool p_validate_certs = false, const String &p_for_hostname = String(), Ref<X509Certificate> p_ca_certs = Ref<X509Certificate>()); + virtual Status get_status() const; + + virtual void disconnect_from_peer(); + + virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size); + virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size); + + virtual int get_available_packet_count() const; + virtual int get_max_packet_size() const; + + static void initialize_dtls(); + static void finalize_dtls(); + + PacketPeerMbedDTLS(); + ~PacketPeerMbedDTLS(); +}; + +#endif // PACKET_PEER_MBED_DTLS_H diff --git a/modules/mbedtls/register_types.cpp b/modules/mbedtls/register_types.cpp index 8f9e2c370b..d39af7fe87 100755 --- a/modules/mbedtls/register_types.cpp +++ b/modules/mbedtls/register_types.cpp @@ -31,16 +31,22 @@ #include "register_types.h" #include "crypto_mbedtls.h" +#include "dtls_server_mbedtls.h" +#include "packet_peer_mbed_dtls.h" #include "stream_peer_mbedtls.h" void register_mbedtls_types() { CryptoMbedTLS::initialize_crypto(); StreamPeerMbedTLS::initialize_ssl(); + PacketPeerMbedDTLS::initialize_dtls(); + DTLSServerMbedTLS::initialize(); } void unregister_mbedtls_types() { + DTLSServerMbedTLS::finalize(); + PacketPeerMbedDTLS::finalize_dtls(); StreamPeerMbedTLS::finalize_ssl(); CryptoMbedTLS::finalize_crypto(); } diff --git a/modules/mbedtls/ssl_context_mbedtls.cpp b/modules/mbedtls/ssl_context_mbedtls.cpp index 82584e3494..52630bd98c 100644 --- a/modules/mbedtls/ssl_context_mbedtls.cpp +++ b/modules/mbedtls/ssl_context_mbedtls.cpp @@ -38,6 +38,53 @@ static void my_debug(void *ctx, int level, fflush(stdout); } +void SSLContextMbedTLS::print_mbedtls_error(int p_ret) { + printf("mbedtls error: returned -0x%x\n\n", -p_ret); + fflush(stdout); +} + +/// CookieContextMbedTLS + +Error CookieContextMbedTLS::setup() { + ERR_FAIL_COND_V_MSG(inited, ERR_ALREADY_IN_USE, "This cookie context is already in use"); + + mbedtls_ctr_drbg_init(&ctr_drbg); + mbedtls_entropy_init(&entropy); + mbedtls_ssl_cookie_init(&cookie_ctx); + inited = true; + + int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0); + if (ret != 0) { + clear(); // Never leave unusable resources around. + ERR_FAIL_V_MSG(FAILED, "mbedtls_ctr_drbg_seed returned an error " + itos(ret)); + } + + ret = mbedtls_ssl_cookie_setup(&cookie_ctx, mbedtls_ctr_drbg_random, &ctr_drbg); + if (ret != 0) { + clear(); + ERR_FAIL_V_MSG(FAILED, "mbedtls_ssl_cookie_setup returned an error " + itos(ret)); + } + return OK; +} + +void CookieContextMbedTLS::clear() { + if (!inited) + return; + mbedtls_ctr_drbg_free(&ctr_drbg); + mbedtls_entropy_free(&entropy); + mbedtls_ssl_cookie_free(&cookie_ctx); +} + +CookieContextMbedTLS::CookieContextMbedTLS() { + inited = false; +} + +CookieContextMbedTLS::~CookieContextMbedTLS() { + clear(); +} + +/// SSLContextMbedTLS + Error SSLContextMbedTLS::_setup(int p_endpoint, int p_transport, int p_authmode) { ERR_FAIL_COND_V_MSG(inited, ERR_ALREADY_IN_USE, "This SSL context is already active"); @@ -50,7 +97,7 @@ Error SSLContextMbedTLS::_setup(int p_endpoint, int p_transport, int p_authmode) int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0); if (ret != 0) { clear(); // Never leave unusable resources around. - ERR_FAIL_V_MSG(FAILED, "mbedtls_ctr_drbg_seed returned an error" + itos(ret)); + ERR_FAIL_V_MSG(FAILED, "mbedtls_ctr_drbg_seed returned an error " + itos(ret)); } ret = mbedtls_ssl_config_defaults(&conf, p_endpoint, p_transport, MBEDTLS_SSL_PRESET_DEFAULT); @@ -64,7 +111,7 @@ Error SSLContextMbedTLS::_setup(int p_endpoint, int p_transport, int p_authmode) return OK; } -Error SSLContextMbedTLS::init_server(int p_transport, int p_authmode, Ref<CryptoKeyMbedTLS> p_pkey, Ref<X509CertificateMbedTLS> p_cert) { +Error SSLContextMbedTLS::init_server(int p_transport, int p_authmode, Ref<CryptoKeyMbedTLS> p_pkey, Ref<X509CertificateMbedTLS> p_cert, Ref<CookieContextMbedTLS> p_cookies) { ERR_FAIL_COND_V(!p_pkey.is_valid(), ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(!p_cert.is_valid(), ERR_INVALID_PARAMETER); @@ -89,6 +136,15 @@ Error SSLContextMbedTLS::init_server(int p_transport, int p_authmode, Ref<Crypto if (certs->cert.next) { mbedtls_ssl_conf_ca_chain(&conf, certs->cert.next, NULL); } + // DTLS Cookies + if (p_transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) { + if (p_cookies.is_null() || !p_cookies->inited) { + clear(); + ERR_FAIL_V(ERR_BUG); + } + cookies = p_cookies; + mbedtls_ssl_conf_dtls_cookies(&conf, mbedtls_ssl_cookie_write, mbedtls_ssl_cookie_check, &(cookies->cookie_ctx)); + } mbedtls_ssl_setup(&ssl, &conf); return OK; } @@ -134,6 +190,7 @@ void SSLContextMbedTLS::clear() { if (pkey.is_valid()) pkey->unlock(); pkey = Ref<CryptoKeyMbedTLS>(); + cookies = Ref<CookieContextMbedTLS>(); inited = false; } diff --git a/modules/mbedtls/ssl_context_mbedtls.h b/modules/mbedtls/ssl_context_mbedtls.h index 01b8b3fd4d..d3e1f87a8e 100644 --- a/modules/mbedtls/ssl_context_mbedtls.h +++ b/modules/mbedtls/ssl_context_mbedtls.h @@ -42,6 +42,27 @@ #include <mbedtls/debug.h> #include <mbedtls/entropy.h> #include <mbedtls/ssl.h> +#include <mbedtls/ssl_cookie.h> + +class SSLContextMbedTLS; + +class CookieContextMbedTLS : public Reference { + + friend class SSLContextMbedTLS; + +protected: + bool inited; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_ssl_cookie_ctx cookie_ctx; + +public: + Error setup(); + void clear(); + + CookieContextMbedTLS(); + ~CookieContextMbedTLS(); +}; class SSLContextMbedTLS : public Reference { @@ -51,16 +72,19 @@ protected: static PackedByteArray _read_file(String p_path); public: + static void print_mbedtls_error(int p_ret); + Ref<X509CertificateMbedTLS> certs; mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; mbedtls_ssl_context ssl; mbedtls_ssl_config conf; + Ref<CookieContextMbedTLS> cookies; Ref<CryptoKeyMbedTLS> pkey; Error _setup(int p_endpoint, int p_transport, int p_authmode); - Error init_server(int p_transport, int p_authmode, Ref<CryptoKeyMbedTLS> p_pkey, Ref<X509CertificateMbedTLS> p_cert); + Error init_server(int p_transport, int p_authmode, Ref<CryptoKeyMbedTLS> p_pkey, Ref<X509CertificateMbedTLS> p_cert, Ref<CookieContextMbedTLS> p_cookies = Ref<CookieContextMbedTLS>()); Error init_client(int p_transport, int p_authmode, Ref<X509CertificateMbedTLS> p_valid_cas); void clear(); diff --git a/modules/mbedtls/stream_peer_mbedtls.cpp b/modules/mbedtls/stream_peer_mbedtls.cpp index f06327e0d5..03c5922267 100755 --- a/modules/mbedtls/stream_peer_mbedtls.cpp +++ b/modules/mbedtls/stream_peer_mbedtls.cpp @@ -33,11 +33,6 @@ #include "core/io/stream_peer_tcp.h" #include "core/os/file_access.h" -void _print_error(int ret) { - printf("mbedtls error: returned -0x%x\n\n", -ret); - fflush(stdout); -} - int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) { if (buf == NULL || len <= 0) return 0; @@ -89,7 +84,7 @@ Error StreamPeerMbedTLS::_do_handshake() { if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) { // An error occurred. ERR_PRINT("TLS handshake error: " + itos(ret)); - _print_error(ret); + SSLContextMbedTLS::print_mbedtls_error(ret); disconnect_from_stream(); status = STATUS_ERROR; return FAILED; @@ -188,7 +183,7 @@ Error StreamPeerMbedTLS::put_partial_data(const uint8_t *p_data, int p_bytes, in disconnect_from_stream(); return ERR_FILE_EOF; } else if (ret <= 0) { - _print_error(ret); + SSLContextMbedTLS::print_mbedtls_error(ret); disconnect_from_stream(); return ERR_CONNECTION_ERROR; } @@ -233,7 +228,7 @@ Error StreamPeerMbedTLS::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r disconnect_from_stream(); return ERR_FILE_EOF; } else if (ret <= 0) { - _print_error(ret); + SSLContextMbedTLS::print_mbedtls_error(ret); disconnect_from_stream(); return ERR_CONNECTION_ERROR; } @@ -264,7 +259,7 @@ void StreamPeerMbedTLS::poll() { disconnect_from_stream(); return; } else if (ret < 0) { - _print_error(ret); + SSLContextMbedTLS::print_mbedtls_error(ret); disconnect_from_stream(); return; } diff --git a/modules/mono/doc_classes/@C#.xml b/modules/mono/doc_classes/@C#.xml index 826c106d7e..83a7fbf02c 100644 --- a/modules/mono/doc_classes/@C#.xml +++ b/modules/mono/doc_classes/@C#.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="@C#" category="Core" version="3.2"> +<class name="@C#" version="4.0"> <brief_description> </brief_description> <description> diff --git a/modules/mono/doc_classes/CSharpScript.xml b/modules/mono/doc_classes/CSharpScript.xml index de2e246ea9..1eb3404f9e 100644 --- a/modules/mono/doc_classes/CSharpScript.xml +++ b/modules/mono/doc_classes/CSharpScript.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CSharpScript" inherits="Script" category="Core" version="3.2"> +<class name="CSharpScript" inherits="Script" version="4.0"> <brief_description> </brief_description> <description> @@ -8,7 +8,7 @@ </tutorials> <methods> <method name="new" qualifiers="vararg"> - <return type="Object"> + <return type="Variant"> </return> <description> </description> diff --git a/modules/mono/doc_classes/GodotSharp.xml b/modules/mono/doc_classes/GodotSharp.xml index 18556a84ba..19a08d2036 100644 --- a/modules/mono/doc_classes/GodotSharp.xml +++ b/modules/mono/doc_classes/GodotSharp.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GodotSharp" inherits="Object" category="Core" version="3.2"> +<class name="GodotSharp" inherits="Object" version="4.0"> <brief_description> </brief_description> <description> diff --git a/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs b/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs index 727581daab..f75fe239e3 100644 --- a/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs +++ b/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs @@ -41,7 +41,7 @@ namespace GodotTools public bool ErrorsVisible { get; set; } = true; public bool WarningsVisible { get; set; } = true; - public Texture IconTexture + public Texture2D IconTexture { get { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs index b85a00d869..099eacd7dd 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs @@ -981,7 +981,7 @@ namespace Godot } // <summary> - // Convert the String (which is a character array) to PoolByteArray (which is an array of bytes). The conversion is speeded up in comparison to to_utf8() with the assumption that all the characters the String contains are only ASCII characters. + // Convert the String (which is a character array) to PackedByteArray (which is an array of bytes). The conversion is speeded up in comparison to to_utf8() with the assumption that all the characters the String contains are only ASCII characters. // </summary> public static byte[] ToAscii(this string instance) { @@ -1021,7 +1021,7 @@ namespace Godot } // <summary> - // Convert the String (which is an array of characters) to PoolByteArray (which is an array of bytes). The conversion is a bit slower than to_ascii(), but supports all UTF-8 characters. Therefore, you should prefer this function over to_ascii(). + // Convert the String (which is an array of characters) to PackedByteArray (which is an array of bytes). The conversion is a bit slower than to_ascii(), but supports all UTF-8 characters. Therefore, you should prefer this function over to_ascii(). // </summary> public static byte[] ToUTF8(this string instance) { diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp index 02246b2f2f..8dfb5b7147 100644 --- a/modules/mono/glue/base_object_glue.cpp +++ b/modules/mono/glue/base_object_glue.cpp @@ -224,14 +224,9 @@ MonoString *godot_icall_Object_ToString(Object *p_ptr) { #ifdef DEBUG_ENABLED // Cannot happen in C#; would get an ObjectDisposedException instead. CRASH_COND(p_ptr == NULL); - - if (ScriptDebugger::get_singleton() && !Object::cast_to<Reference>(p_ptr)) { // Only if debugging! - // Cannot happen either in C#; the handle is nullified when the object is destroyed - CRASH_COND(!ObjectDB::instance_validate(p_ptr)); - } #endif - String result = "[" + p_ptr->get_class() + ":" + itos(p_ptr->get_instance_id()) + "]"; + String result = p_ptr->to_string(); return GDMonoMarshal::mono_string_from_godot(result); } diff --git a/modules/mono/glue/gd_glue.cpp b/modules/mono/glue/gd_glue.cpp index ce81ea391d..a6273a60ac 100644 --- a/modules/mono/glue/gd_glue.cpp +++ b/modules/mono/glue/gd_glue.cpp @@ -45,8 +45,7 @@ MonoObject *godot_icall_GD_bytes2var(MonoArray *p_bytes, MonoBoolean p_allow_objects) { Variant ret; PackedByteArray varr = GDMonoMarshal::mono_array_to_PackedByteArray(p_bytes); - const uint8_t *r = varr.ptr(); - Error err = decode_variant(ret, r.ptr(), varr.size(), NULL, p_allow_objects); + Error err = decode_variant(ret, varr.ptr(), varr.size(), NULL, p_allow_objects); if (err != OK) { ret = RTR("Not enough bytes for decoding bytes, or invalid format."); } @@ -67,7 +66,7 @@ int godot_icall_GD_hash(MonoObject *p_var) { } MonoObject *godot_icall_GD_instance_from_id(uint64_t p_instance_id) { - return GDMonoUtils::unmanaged_get_managed(ObjectDB::get_instance(p_instance_id)); + return GDMonoUtils::unmanaged_get_managed(ObjectDB::get_instance(ObjectID(p_instance_id))); } void godot_icall_GD_print(MonoArray *p_what) { @@ -263,10 +262,7 @@ MonoArray *godot_icall_GD_var2bytes(MonoObject *p_var, MonoBoolean p_full_object ERR_FAIL_COND_V_MSG(err != OK, NULL, "Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID)."); barr.resize(len); - { - uint8_t *w = barr.ptrw(); - encode_variant(var, w.ptr(), len, p_full_objects); - } + encode_variant(var, barr.ptrw(), len, p_full_objects); return GDMonoMarshal::PackedByteArray_to_mono_array(barr); } diff --git a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml index 38d3bd5468..8a1bb62e24 100644 --- a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml +++ b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="data" type="PoolByteArray" setter="set_data" getter="get_data" default="PoolByteArray( )"> + <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray( )"> Contains the audio data in bytes. </member> <member name="loop" type="bool" setter="set_loop" getter="has_loop" default="false"> diff --git a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml index 9f4846ee1f..ef4183e6f6 100644 --- a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml +++ b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml @@ -197,10 +197,10 @@ Deserialize a [Variant] from a string serialized using [constant VAR_TO_STR]. </constant> <constant name="VAR_TO_BYTES" value="61" enum="BuiltinFunc"> - Serialize a [Variant] to a [PoolByteArray]. + Serialize a [Variant] to a [PackedByteArray]. </constant> <constant name="BYTES_TO_VAR" value="62" enum="BuiltinFunc"> - Deserialize a [Variant] from a [PoolByteArray] serialized using [constant VAR_TO_BYTES]. + Deserialize a [Variant] from a [PackedByteArray] serialized using [constant VAR_TO_BYTES]. </constant> <constant name="COLORN" value="63" enum="BuiltinFunc"> Return the [Color] with the given name and alpha ranging from 0 to 1. diff --git a/modules/websocket/doc_classes/WebSocketClient.xml b/modules/websocket/doc_classes/WebSocketClient.xml index 2549321db3..45db49c913 100644 --- a/modules/websocket/doc_classes/WebSocketClient.xml +++ b/modules/websocket/doc_classes/WebSocketClient.xml @@ -17,11 +17,11 @@ </return> <argument index="0" name="url" type="String"> </argument> - <argument index="1" name="protocols" type="PoolStringArray" default="PoolStringArray( )"> + <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray( )"> </argument> <argument index="2" name="gd_mp_api" type="bool" default="false"> </argument> - <argument index="3" name="custom_headers" type="PoolStringArray" default="PoolStringArray( )"> + <argument index="3" name="custom_headers" type="PackedStringArray" default="PackedStringArray( )"> </argument> <description> Connects to the given URL requesting one of the given [code]protocols[/code] as sub-protocol. If the list empty (default), no sub-protocol will be requested. diff --git a/modules/websocket/doc_classes/WebSocketServer.xml b/modules/websocket/doc_classes/WebSocketServer.xml index f66e1bf54b..f7805209e2 100644 --- a/modules/websocket/doc_classes/WebSocketServer.xml +++ b/modules/websocket/doc_classes/WebSocketServer.xml @@ -63,7 +63,7 @@ </return> <argument index="0" name="port" type="int"> </argument> - <argument index="1" name="protocols" type="PoolStringArray" default="PoolStringArray( )"> + <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray( )"> </argument> <argument index="2" name="gd_mp_api" type="bool" default="false"> </argument> diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 5625a0085b..72cafb911b 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -1179,17 +1179,17 @@ void CanvasItem::_bind_methods() { ClassDB::bind_method(D_METHOD("draw_multiline_colors", "points", "colors", "width"), &CanvasItem::draw_multiline_colors, DEFVAL(1.0)); ClassDB::bind_method(D_METHOD("draw_rect", "rect", "color", "filled", "width"), &CanvasItem::draw_rect, DEFVAL(true), DEFVAL(1.0)); ClassDB::bind_method(D_METHOD("draw_circle", "position", "radius", "color"), &CanvasItem::draw_circle); - ClassDB::bind_method(D_METHOD("draw_texture", "texture", "position", "modulate", "normal_map", "specular_map", "specular_shinness", "texture_filter", "texture_repeat"), &CanvasItem::draw_texture, DEFVAL(Color(1, 1, 1, 1)), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); - ClassDB::bind_method(D_METHOD("draw_texture_rect", "texture", "rect", "tile", "modulate", "transpose", "normal_map", "specular_map", "specular_shinness", "texture_filter", "texture_repeat"), &CanvasItem::draw_texture_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); - ClassDB::bind_method(D_METHOD("draw_texture_rect_region", "texture", "rect", "src_rect", "modulate", "transpose", "normal_map", "specular_map", "clip_uv", "specular_shinness", "texture_filter", "texture_repeat"), &CanvasItem::draw_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(true), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); + ClassDB::bind_method(D_METHOD("draw_texture", "texture", "position", "modulate", "normal_map", "specular_map", "specular_shininess", "texture_filter", "texture_repeat"), &CanvasItem::draw_texture, DEFVAL(Color(1, 1, 1, 1)), DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); + ClassDB::bind_method(D_METHOD("draw_texture_rect", "texture", "rect", "tile", "modulate", "transpose", "normal_map", "specular_map", "specular_shininess", "texture_filter", "texture_repeat"), &CanvasItem::draw_texture_rect, DEFVAL(Color(1, 1, 1, 1)), DEFVAL(false), DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); + ClassDB::bind_method(D_METHOD("draw_texture_rect_region", "texture", "rect", "src_rect", "modulate", "transpose", "normal_map", "specular_map", "specular_shininess", "clip_uv", "texture_filter", "texture_repeat"), &CanvasItem::draw_texture_rect_region, DEFVAL(Color(1, 1, 1, 1)), DEFVAL(false), DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); ClassDB::bind_method(D_METHOD("draw_style_box", "style_box", "rect"), &CanvasItem::draw_style_box); - ClassDB::bind_method(D_METHOD("draw_primitive", "points", "colors", "uvs", "texture", "width", "normal_map", "specular_map", "specular_shinness", "texture_filter", "texture_repeat"), &CanvasItem::draw_primitive, DEFVAL(Variant()), DEFVAL(1.0), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); - ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture", "normal_map", "specular_map", "specular_shinness", "texture_filter", "texture_repeat"), &CanvasItem::draw_polygon, DEFVAL(PackedVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); - ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture", "normal_map", "specular_map", "specular_shinness", "texture_filter", "texture_repeat"), &CanvasItem::draw_colored_polygon, DEFVAL(PackedVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); - ClassDB::bind_method(D_METHOD("draw_string", "font", "position", "text", "modulate", "clip_w"), &CanvasItem::draw_string, DEFVAL(Color(1, 1, 1)), DEFVAL(-1)); - ClassDB::bind_method(D_METHOD("draw_char", "font", "position", "char", "next", "modulate"), &CanvasItem::draw_char, DEFVAL(Color(1, 1, 1))); - ClassDB::bind_method(D_METHOD("draw_mesh", "mesh", "texture", "normal_map", "specular_map", "transform", "modulate", "specular_shinness", "texture_filter", "texture_repeat"), &CanvasItem::draw_mesh, DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1)), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); - ClassDB::bind_method(D_METHOD("draw_multimesh", "multimesh", "texture", "normal_map", "specular_map", "specular_shinness", "texture_filter", "texture_repeat"), &CanvasItem::draw_multimesh, DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); + ClassDB::bind_method(D_METHOD("draw_primitive", "points", "colors", "uvs", "texture", "width", "normal_map", "specular_map", "specular_shininess", "texture_filter", "texture_repeat"), &CanvasItem::draw_primitive, DEFVAL(Ref<Texture2D>()), DEFVAL(1.0), DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); + ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture", "normal_map", "specular_map", "specular_shininess", "texture_filter", "texture_repeat"), &CanvasItem::draw_polygon, DEFVAL(PackedVector2Array()), DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); + ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture", "normal_map", "specular_map", "specular_shininess", "texture_filter", "texture_repeat"), &CanvasItem::draw_colored_polygon, DEFVAL(PackedVector2Array()), DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); + ClassDB::bind_method(D_METHOD("draw_string", "font", "position", "text", "modulate", "clip_w"), &CanvasItem::draw_string, DEFVAL(Color(1, 1, 1, 1)), DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("draw_char", "font", "position", "char", "next", "modulate"), &CanvasItem::draw_char, DEFVAL(Color(1, 1, 1, 1))); + ClassDB::bind_method(D_METHOD("draw_mesh", "mesh", "texture", "normal_map", "specular_map", "specular_shininess", "transform", "modulate", "texture_filter", "texture_repeat"), &CanvasItem::draw_mesh, DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); + ClassDB::bind_method(D_METHOD("draw_multimesh", "multimesh", "texture", "normal_map", "specular_map", "specular_shininess", "texture_filter", "texture_repeat"), &CanvasItem::draw_multimesh, DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(TEXTURE_FILTER_PARENT_NODE), DEFVAL(TEXTURE_REPEAT_PARENT_NODE)); ClassDB::bind_method(D_METHOD("draw_set_transform", "position", "rotation", "scale"), &CanvasItem::draw_set_transform); ClassDB::bind_method(D_METHOD("draw_set_transform_matrix", "xform"), &CanvasItem::draw_set_transform_matrix); diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 1b0359f6ec..822e679a86 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -339,8 +339,8 @@ public: void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture2D> p_texture = Ref<Texture2D>(), const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), TextureFilter p_texture_filter = TEXTURE_FILTER_PARENT_NODE, TextureRepeat p_texture_repeat = TEXTURE_REPEAT_PARENT_NODE); void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture2D> p_texture = Ref<Texture2D>(), const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), TextureFilter p_texture_filter = TEXTURE_FILTER_PARENT_NODE, TextureRepeat p_texture_repeat = TEXTURE_REPEAT_PARENT_NODE); - void draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), TextureFilter p_texture_filter = TEXTURE_FILTER_PARENT_NODE, TextureRepeat p_texture_repeat = TEXTURE_REPEAT_PARENT_NODE); - void draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), TextureFilter p_texture_filter = TEXTURE_FILTER_PARENT_NODE, TextureRepeat p_texture_repeat = TEXTURE_REPEAT_PARENT_NODE); + void draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), TextureFilter p_texture_filter = TEXTURE_FILTER_PARENT_NODE, TextureRepeat p_texture_repeat = TEXTURE_REPEAT_PARENT_NODE); + void draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), TextureFilter p_texture_filter = TEXTURE_FILTER_PARENT_NODE, TextureRepeat p_texture_repeat = TEXTURE_REPEAT_PARENT_NODE); void draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate = Color(1, 1, 1), int p_clip_w = -1); float draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, const String &p_next = "", const Color &p_modulate = Color(1, 1, 1)); diff --git a/scene/resources/text_file.h b/scene/resources/text_file.h index 76c80ba509..666c088d04 100644 --- a/scene/resources/text_file.h +++ b/scene/resources/text_file.h @@ -36,6 +36,8 @@ class TextFile : public Resource { + GDCLASS(TextFile, Resource); + private: String text; String path; diff --git a/thirdparty/enet/enet/enet.h b/thirdparty/enet/enet/enet.h index 966e3a465d..ac7552adb2 100644 --- a/thirdparty/enet/enet/enet.h +++ b/thirdparty/enet/enet/enet.h @@ -578,6 +578,8 @@ ENET_API void enet_host_channel_limit (ENetHost *, size_t); ENET_API void enet_host_bandwidth_limit (ENetHost *, enet_uint32, enet_uint32); extern void enet_host_bandwidth_throttle (ENetHost *); extern enet_uint32 enet_host_random_seed (void); +ENET_API void enet_host_dtls_server_setup (ENetHost *, void *, void *); +ENET_API void enet_host_dtls_client_setup (ENetHost *, void *, uint8_t, const char *); ENET_API int enet_peer_send (ENetPeer *, enet_uint8, ENetPacket *); ENET_API ENetPacket * enet_peer_receive (ENetPeer *, enet_uint8 * channelID); diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp index 72310fb9a2..9fefa53e77 100644 --- a/thirdparty/enet/godot.cpp +++ b/thirdparty/enet/godot.cpp @@ -32,13 +32,313 @@ @brief ENet Godot specific functions */ +#include "core/io/dtls_server.h" #include "core/io/ip.h" #include "core/io/net_socket.h" +#include "core/io/packet_peer_dtls.h" +#include "core/io/udp_server.h" #include "core/os/os.h" // This must be last for windows to compile (tested with MinGW) #include "enet/enet.h" +/// Abstract ENet interface for UDP/DTLS. +class ENetGodotSocket { + +public: + virtual Error bind(IP_Address p_ip, uint16_t p_port) = 0; + virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) = 0; + virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) = 0; + virtual int set_option(ENetSocketOption p_option, int p_value) = 0; + virtual void close() = 0; + virtual ~ENetGodotSocket(){}; +}; + +class ENetDTLSClient; +class ENetDTLSServer; + +/// NetSocket interface +class ENetUDP : public ENetGodotSocket { + + friend class ENetDTLSClient; + friend class ENetDTLSServer; + +private: + Ref<NetSocket> sock; + IP_Address address; + uint16_t port; + bool bound; + +public: + ENetUDP() { + sock = Ref<NetSocket>(NetSocket::create()); + IP::Type ip_type = IP::TYPE_ANY; + bound = false; + sock->open(NetSocket::TYPE_UDP, ip_type); + } + + ~ENetUDP() { + sock->close(); + } + + Error bind(IP_Address p_ip, uint16_t p_port) { + address = p_ip; + port = p_port; + bound = true; + return sock->bind(address, port); + } + + Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) { + return sock->sendto(p_buffer, p_len, r_sent, p_ip, p_port); + } + + Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) { + Error err = sock->poll(NetSocket::POLL_TYPE_IN, 0); + if (err != OK) + return err; + return sock->recvfrom(p_buffer, p_len, r_read, r_ip, r_port); + } + + int set_option(ENetSocketOption p_option, int p_value) { + switch (p_option) { + case ENET_SOCKOPT_NONBLOCK: { + sock->set_blocking_enabled(p_value ? false : true); + return 0; + } break; + + case ENET_SOCKOPT_BROADCAST: { + sock->set_broadcasting_enabled(p_value ? true : false); + return 0; + } break; + + case ENET_SOCKOPT_REUSEADDR: { + sock->set_reuse_address_enabled(p_value ? true : false); + return 0; + } break; + + case ENET_SOCKOPT_RCVBUF: { + return -1; + } break; + + case ENET_SOCKOPT_SNDBUF: { + return -1; + } break; + + case ENET_SOCKOPT_RCVTIMEO: { + return -1; + } break; + + case ENET_SOCKOPT_SNDTIMEO: { + return -1; + } break; + + case ENET_SOCKOPT_NODELAY: { + sock->set_tcp_no_delay_enabled(p_value ? true : false); + return 0; + } break; + } + + return -1; + } + + void close() { + sock->close(); + } +}; + +/// DTLS Client ENet interface +class ENetDTLSClient : public ENetGodotSocket { + + bool connected; + Ref<PacketPeerUDP> udp; + Ref<PacketPeerDTLS> dtls; + bool verify; + String for_hostname; + Ref<X509Certificate> cert; + +public: + ENetDTLSClient(ENetUDP *p_base, Ref<X509Certificate> p_cert, bool p_verify, String p_for_hostname) { + verify = p_verify; + for_hostname = p_for_hostname; + cert = p_cert; + udp.instance(); + dtls = Ref<PacketPeerDTLS>(PacketPeerDTLS::create()); + p_base->close(); + if (p_base->bound) { + bind(p_base->address, p_base->port); + } + connected = false; + } + + ~ENetDTLSClient() { + close(); + } + + Error bind(IP_Address p_ip, uint16_t p_port) { + return udp->listen(p_port, p_ip); + } + + Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) { + if (!connected) { + udp->connect_to_host(p_ip, p_port); + dtls->connect_to_peer(udp, verify, for_hostname, cert); + connected = true; + } + dtls->poll(); + if (dtls->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING) + return ERR_BUSY; + else if (dtls->get_status() != PacketPeerDTLS::STATUS_CONNECTED) + return FAILED; + r_sent = p_len; + return dtls->put_packet(p_buffer, p_len); + } + + Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) { + dtls->poll(); + if (dtls->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING) + return ERR_BUSY; + if (dtls->get_status() != PacketPeerDTLS::STATUS_CONNECTED) + return FAILED; + int pc = dtls->get_available_packet_count(); + if (pc == 0) + return ERR_BUSY; + else if (pc < 0) + return FAILED; + + const uint8_t *buffer; + Error err = dtls->get_packet(&buffer, r_read); + ERR_FAIL_COND_V(err != OK, err); + ERR_FAIL_COND_V(p_len < r_read, ERR_OUT_OF_MEMORY); + + copymem(p_buffer, buffer, r_read); + r_ip = udp->get_packet_address(); + r_port = udp->get_packet_port(); + return err; + } + + int set_option(ENetSocketOption p_option, int p_value) { + return -1; + } + + void close() { + dtls->disconnect_from_peer(); + udp->close(); + } +}; + +/// DTLSServer - ENet interface +class ENetDTLSServer : public ENetGodotSocket { + + Ref<DTLSServer> server; + Ref<UDPServer> udp_server; + Map<String, Ref<PacketPeerDTLS> > peers; + int last_service; + +public: + ENetDTLSServer(ENetUDP *p_base, Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert) { + last_service = 0; + udp_server.instance(); + p_base->close(); + if (p_base->bound) { + bind(p_base->address, p_base->port); + } + server = Ref<DTLSServer>(DTLSServer::create()); + server->setup(p_key, p_cert); + } + + ~ENetDTLSServer() { + close(); + } + + Error bind(IP_Address p_ip, uint16_t p_port) { + return udp_server->listen(p_port, p_ip); + } + + Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) { + String key = String(p_ip) + ":" + itos(p_port); + ERR_FAIL_COND_V(!peers.has(key), ERR_UNAVAILABLE); + Ref<PacketPeerDTLS> peer = peers[key]; + Error err = peer->put_packet(p_buffer, p_len); + if (err == OK) + r_sent = p_len; + else if (err == ERR_BUSY) + r_sent = 0; + else + r_sent = -1; + return err; + } + + Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) { + // TODO limits? Maybe we can better enforce allowed connections! + if (udp_server->is_connection_available()) { + Ref<PacketPeerUDP> udp = udp_server->take_connection(); + IP_Address peer_ip = udp->get_packet_address(); + int peer_port = udp->get_packet_port(); + Ref<PacketPeerDTLS> peer = server->take_connection(udp); + PacketPeerDTLS::Status status = peer->get_status(); + if (status == PacketPeerDTLS::STATUS_HANDSHAKING || status == PacketPeerDTLS::STATUS_CONNECTED) { + String key = String(peer_ip) + ":" + itos(peer_port); + peers[key] = peer; + } + } + + List<String> remove; + Error err = ERR_BUSY; + // TODO this needs to be fair! + for (Map<String, Ref<PacketPeerDTLS> >::Element *E = peers.front(); E; E = E->next()) { + Ref<PacketPeerDTLS> peer = E->get(); + peer->poll(); + + if (peer->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING) + continue; + else if (peer->get_status() != PacketPeerDTLS::STATUS_CONNECTED) { + // Peer disconnected, removing it. + remove.push_back(E->key()); + continue; + } + + if (peer->get_available_packet_count() > 0) { + const uint8_t *buffer; + err = peer->get_packet(&buffer, r_read); + if (err != OK || p_len < r_read) { + // Something wrong with this peer, removing it. + remove.push_back(E->key()); + err = FAILED; + continue; + } + + Vector<String> s = E->key().rsplit(":", false, 1); + ERR_CONTINUE(s.size() != 2); // BUG! + + copymem(p_buffer, buffer, r_read); + r_ip = s[0]; + r_port = s[1].to_int(); + break; // err = OK + } + } + + // Remove disconnected peers from map. + for (List<String>::Element *E = remove.front(); E; E = E->next()) { + peers.erase(E->get()); + } + + return err; // OK, ERR_BUSY, or possibly an error. + } + + int set_option(ENetSocketOption p_option, int p_value) { + return -1; + } + + void close() { + for (Map<String, Ref<PacketPeerDTLS> >::Element *E = peers.front(); E; E = E->next()) { + E->get()->disconnect_from_peer(); + } + peers.clear(); + udp_server->stop(); + server->stop(); + } +}; + static enet_uint32 timeBase = 0; int enet_initialize(void) { @@ -92,13 +392,23 @@ int enet_address_get_host(const ENetAddress *address, char *name, size_t nameLen ENetSocket enet_socket_create(ENetSocketType type) { - NetSocket *socket = NetSocket::create(); - IP::Type ip_type = IP::TYPE_ANY; - socket->open(NetSocket::TYPE_UDP, ip_type); + ENetUDP *socket = memnew(ENetUDP); return socket; } +void enet_host_dtls_server_setup(ENetHost *host, void *p_key, void *p_cert) { + ENetUDP *sock = (ENetUDP *)host->socket; + host->socket = memnew(ENetDTLSServer(sock, Ref<CryptoKey>((CryptoKey *)p_key), Ref<X509Certificate>((X509Certificate *)p_cert))); + memdelete(sock); +} + +void enet_host_dtls_client_setup(ENetHost *host, void *p_cert, uint8_t p_verify, const char *p_for_hostname) { + ENetUDP *sock = (ENetUDP *)host->socket; + host->socket = memnew(ENetDTLSClient(sock, Ref<X509Certificate>((X509Certificate *)p_cert), p_verify, String(p_for_hostname))); + memdelete(sock); +} + int enet_socket_bind(ENetSocket socket, const ENetAddress *address) { IP_Address ip; @@ -108,7 +418,7 @@ int enet_socket_bind(ENetSocket socket, const ENetAddress *address) { ip.set_ipv6(address->host); } - NetSocket *sock = (NetSocket *)socket; + ENetGodotSocket *sock = (ENetGodotSocket *)socket; if (sock->bind(ip, address->port) != OK) { return -1; } @@ -116,7 +426,7 @@ int enet_socket_bind(ENetSocket socket, const ENetAddress *address) { } void enet_socket_destroy(ENetSocket socket) { - NetSocket *sock = (NetSocket *)socket; + ENetGodotSocket *sock = (ENetGodotSocket *)socket; sock->close(); memdelete(sock); } @@ -125,7 +435,7 @@ int enet_socket_send(ENetSocket socket, const ENetAddress *address, const ENetBu ERR_FAIL_COND_V(address == NULL, -1); - NetSocket *sock = (NetSocket *)socket; + ENetGodotSocket *sock = (ENetGodotSocket *)socket; IP_Address dest; Error err; size_t i = 0; @@ -167,15 +477,7 @@ int enet_socket_receive(ENetSocket socket, ENetAddress *address, ENetBuffer *buf ERR_FAIL_COND_V(bufferCount != 1, -1); - NetSocket *sock = (NetSocket *)socket; - - Error ret = sock->poll(NetSocket::POLL_TYPE_IN, 0); - - if (ret == ERR_BUSY) - return 0; - - if (ret != OK) - return -1; + ENetGodotSocket *sock = (ENetGodotSocket *)socket; int read; IP_Address ip; @@ -215,47 +517,8 @@ int enet_socket_listen(ENetSocket socket, int backlog) { int enet_socket_set_option(ENetSocket socket, ENetSocketOption option, int value) { - NetSocket *sock = (NetSocket *)socket; - - switch (option) { - case ENET_SOCKOPT_NONBLOCK: { - sock->set_blocking_enabled(value ? false : true); - return 0; - } break; - - case ENET_SOCKOPT_BROADCAST: { - sock->set_broadcasting_enabled(value ? true : false); - return 0; - } break; - - case ENET_SOCKOPT_REUSEADDR: { - sock->set_reuse_address_enabled(value ? true : false); - return 0; - } break; - - case ENET_SOCKOPT_RCVBUF: { - return -1; - } break; - - case ENET_SOCKOPT_SNDBUF: { - return -1; - } break; - - case ENET_SOCKOPT_RCVTIMEO: { - return -1; - } break; - - case ENET_SOCKOPT_SNDTIMEO: { - return -1; - } break; - - case ENET_SOCKOPT_NODELAY: { - sock->set_tcp_no_delay_enabled(value ? true : false); - return 0; - } break; - } - - return -1; + ENetGodotSocket *sock = (ENetGodotSocket *)socket; + return sock->set_option(option, value); } int enet_socket_get_option(ENetSocket socket, ENetSocketOption option, int *value) { |