diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/io/net_socket.h | 2 | ||||
-rw-r--r-- | core/io/packet_peer_udp.cpp | 11 | ||||
-rw-r--r-- | core/io/packet_peer_udp.h | 2 | ||||
-rw-r--r-- | core/math/geometry.cpp | 2 | ||||
-rw-r--r-- | core/math/geometry.h | 9 | ||||
-rw-r--r-- | core/variant_call.cpp | 51 | ||||
-rw-r--r-- | core/variant_op.cpp | 4 |
7 files changed, 43 insertions, 38 deletions
diff --git a/core/io/net_socket.h b/core/io/net_socket.h index 3bc1369487..914e243b65 100644 --- a/core/io/net_socket.h +++ b/core/io/net_socket.h @@ -69,7 +69,7 @@ public: virtual bool is_open() const = 0; virtual int get_available_bytes() const = 0; - virtual void set_broadcasting_enabled(bool p_enabled) = 0; + virtual Error set_broadcasting_enabled(bool p_enabled) = 0; // Returns OK if the socket option has been set successfully. virtual void set_blocking_enabled(bool p_enabled) = 0; virtual void set_ipv6_only_enabled(bool p_enabled) = 0; virtual void set_tcp_no_delay_enabled(bool p_enabled) = 0; diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp index 7e9471c053..80a070cf1c 100644 --- a/core/io/packet_peer_udp.cpp +++ b/core/io/packet_peer_udp.cpp @@ -37,6 +37,12 @@ void PacketPeerUDP::set_blocking_mode(bool p_enable) { blocking = p_enable; } +void PacketPeerUDP::set_broadcast_enabled(bool p_enabled) { + broadcast = p_enabled; + if (_sock.is_valid() && _sock->is_open()) + _sock->set_broadcasting_enabled(p_enabled); +} + Error PacketPeerUDP::join_multicast_group(IP_Address p_multi_address, String p_if_name) { ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE); @@ -47,6 +53,7 @@ Error PacketPeerUDP::join_multicast_group(IP_Address p_multi_address, String p_i Error err = _sock->open(NetSocket::TYPE_UDP, ip_type); ERR_FAIL_COND_V(err != OK, err); _sock->set_blocking_enabled(false); + _sock->set_broadcasting_enabled(broadcast); } return _sock->join_multicast_group(p_multi_address, p_if_name); } @@ -122,6 +129,7 @@ Error PacketPeerUDP::put_packet(const uint8_t *p_buffer, int p_buffer_size) { err = _sock->open(NetSocket::TYPE_UDP, ip_type); ERR_FAIL_COND_V(err != OK, err); _sock->set_blocking_enabled(false); + _sock->set_broadcasting_enabled(broadcast); } do { @@ -165,6 +173,7 @@ Error PacketPeerUDP::listen(int p_port, const IP_Address &p_bind_address, int p_ _sock->set_blocking_enabled(false); _sock->set_reuse_address_enabled(true); + _sock->set_broadcasting_enabled(broadcast); err = _sock->bind(p_bind_address, p_port); if (err != OK) { @@ -258,6 +267,7 @@ void PacketPeerUDP::_bind_methods() { 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); + ClassDB::bind_method(D_METHOD("set_broadcast_enabled", "enabled"), &PacketPeerUDP::set_broadcast_enabled); ClassDB::bind_method(D_METHOD("join_multicast_group", "multicast_address", "interface_name"), &PacketPeerUDP::join_multicast_group); ClassDB::bind_method(D_METHOD("leave_multicast_group", "multicast_address", "interface_name"), &PacketPeerUDP::leave_multicast_group); } @@ -267,6 +277,7 @@ PacketPeerUDP::PacketPeerUDP() : queue_count(0), peer_port(0), blocking(true), + broadcast(false), _sock(Ref<NetSocket>(NetSocket::create())) { rb.resize(16); } diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h index 068bd5cd5a..dc89e129dd 100644 --- a/core/io/packet_peer_udp.h +++ b/core/io/packet_peer_udp.h @@ -53,6 +53,7 @@ protected: IP_Address peer_addr; int peer_port; bool blocking; + bool broadcast; Ref<NetSocket> _sock; static void _bind_methods(); @@ -77,6 +78,7 @@ public: Error get_packet(const uint8_t **r_buffer, int &r_buffer_size); int get_available_packet_count() const; int get_max_packet_size() const; + void set_broadcast_enabled(bool p_enabled); Error join_multicast_group(IP_Address p_multi_address, String p_if_name); Error leave_multicast_group(IP_Address p_multi_address, String p_if_name); diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp index ada5107a2c..ee7feba19e 100644 --- a/core/math/geometry.cpp +++ b/core/math/geometry.cpp @@ -97,8 +97,6 @@ void Geometry::MeshData::optimize_vertices() { vertices = new_vertices; } -Vector<Vector<Vector2> > (*Geometry::_decompose_func)(const Vector<Vector2> &p_polygon) = NULL; - struct _FaceClassify { struct _Link { diff --git a/core/math/geometry.h b/core/math/geometry.h index 8b0a51c651..db4b82e8ce 100644 --- a/core/math/geometry.h +++ b/core/math/geometry.h @@ -853,15 +853,6 @@ public: return triangles; } - static Vector<Vector<Vector2> > (*_decompose_func)(const Vector<Vector2> &p_polygon); - static Vector<Vector<Vector2> > decompose_polygon(const Vector<Vector2> &p_polygon) { - - if (_decompose_func) - return _decompose_func(p_polygon); - - return Vector<Vector<Vector2> >(); - } - static bool is_polygon_clockwise(const Vector<Vector2> &p_polygon) { int c = p_polygon.size(); if (c < 3) diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 6e593a308d..8aae2d8490 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -1187,31 +1187,6 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i default: return Variant(); } - } else if (p_argcount > 1) { - - _VariantCall::ConstructFunc &c = _VariantCall::construct_funcs[p_type]; - - for (List<_VariantCall::ConstructData>::Element *E = c.constructors.front(); E; E = E->next()) { - const _VariantCall::ConstructData &cd = E->get(); - - if (cd.arg_count != p_argcount) - continue; - - //validate parameters - for (int i = 0; i < cd.arg_count; i++) { - if (!Variant::can_convert(p_args[i]->type, cd.arg_types[i])) { - r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; //no such constructor - r_error.argument = i; - r_error.expected = cd.arg_types[i]; - return Variant(); - } - } - - Variant v; - cd.func(v, p_args); - return v; - } - } else if (p_argcount == 1 && p_args[0]->type == p_type) { return *p_args[0]; //copy construct } else if (p_argcount == 1 && (!p_strict || Variant::can_convert(p_args[0]->type, p_type))) { @@ -1268,6 +1243,30 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i case POOL_COLOR_ARRAY: return (PoolColorArray(*p_args[0])); default: return Variant(); } + } else if (p_argcount >= 1) { + + _VariantCall::ConstructFunc &c = _VariantCall::construct_funcs[p_type]; + + for (List<_VariantCall::ConstructData>::Element *E = c.constructors.front(); E; E = E->next()) { + const _VariantCall::ConstructData &cd = E->get(); + + if (cd.arg_count != p_argcount) + continue; + + //validate parameters + for (int i = 0; i < cd.arg_count; i++) { + if (!Variant::can_convert(p_args[i]->type, cd.arg_types[i])) { + r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; //no such constructor + r_error.argument = i; + r_error.expected = cd.arg_types[i]; + return Variant(); + } + } + + Variant v; + cd.func(v, p_args); + return v; + } } r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; //no such constructor return Variant(); @@ -1951,7 +1950,7 @@ void register_variant_methods() { ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, orthonormalized, varray()); ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, rotated, VECTOR3, "axis", REAL, "phi", varray()); ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, scaled, VECTOR3, "scale", varray()); - ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, translated, VECTOR3, "ofs", varray()); + ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, translated, VECTOR3, "offset", varray()); ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, looking_at, VECTOR3, "target", VECTOR3, "up", varray()); ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, interpolate_with, TRANSFORM, "transform", REAL, "weight", varray()); ADDFUNC1R(TRANSFORM, BOOL, Transform, is_equal_approx, TRANSFORM, "transform", varray()); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index ea9e29e744..ae47397558 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -1118,6 +1118,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_SHIFT_LEFT, INT) { if (p_b.type != INT) _RETURN_FAIL; + if (p_b._data._int < 0 || p_b._data._int >= 64) + _RETURN_FAIL; _RETURN(p_a._data._int << p_b._data._int); } @@ -1129,6 +1131,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_SHIFT_RIGHT, INT) { if (p_b.type != INT) _RETURN_FAIL; + if (p_b._data._int < 0 || p_b._data._int >= 64) + _RETURN_FAIL; _RETURN(p_a._data._int >> p_b._data._int); } |