summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/SCsub2
-rw-r--r--core/bind/core_bind.cpp13
-rw-r--r--core/bind/core_bind.h1
-rw-r--r--core/class_db.cpp4
-rw-r--r--core/class_db.h4
-rw-r--r--core/engine.cpp1
-rw-r--r--core/engine.h2
-rw-r--r--core/image.cpp64
-rw-r--r--core/input_map.cpp2
-rw-r--r--core/io/marshalls.cpp6
-rw-r--r--core/io/resource_format_binary.cpp20
-rw-r--r--core/io/resource_saver.cpp1
-rw-r--r--core/io/stream_peer.cpp8
-rw-r--r--core/io/stream_peer_tcp.cpp12
-rw-r--r--core/io/stream_peer_tcp.h1
-rw-r--r--core/make_binders.py103
-rw-r--r--core/math/SCsub2
-rw-r--r--core/math/basis.cpp2
-rw-r--r--core/math/basis.h2
-rw-r--r--core/math/bsp_tree.cpp4
-rw-r--r--core/math/expression.cpp14
-rw-r--r--core/math/expression.h1
-rw-r--r--core/math/geometry.h32
-rw-r--r--core/math/math_funcs.h7
-rw-r--r--core/math/triangle_mesh.cpp4
-rw-r--r--core/math/vector3.h4
-rw-r--r--core/object.cpp9
-rw-r--r--core/object.h9
-rw-r--r--core/pool_allocator.cpp2
-rw-r--r--core/pool_vector.h12
-rw-r--r--core/project_settings.cpp6
-rw-r--r--core/project_settings.h6
-rw-r--r--core/register_core_types.cpp2
-rw-r--r--core/string_name.cpp3
-rw-r--r--core/ustring.cpp4
-rw-r--r--core/variant.cpp7
-rw-r--r--core/variant_call.cpp6
-rw-r--r--core/variant_op.cpp2
-rw-r--r--core/variant_parser.cpp2
39 files changed, 256 insertions, 130 deletions
diff --git a/core/SCsub b/core/SCsub
index bf1b34bebe..85e5f1b089 100644
--- a/core/SCsub
+++ b/core/SCsub
@@ -142,7 +142,7 @@ env.Depends("#core/io/certs_compressed.gen.h", ["#thirdparty/certs/ca-certificat
env.CommandNoCache("#core/io/certs_compressed.gen.h", "#thirdparty/certs/ca-certificates.crt", run_in_subprocess(core_builders.make_certs_header))
# Make binders
-env.CommandNoCache(['method_bind.gen.inc', 'method_bind_ext.gen.inc'], 'make_binders.py', run_in_subprocess(make_binders.run))
+env.CommandNoCache(['method_bind.gen.inc', 'method_bind_ext.gen.inc', 'method_bind_free_func.gen.inc'], 'make_binders.py', run_in_subprocess(make_binders.run))
# Authors
env.Depends('#core/authors.gen.h', "../AUTHORS.md")
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 1bf3425d50..b41b84ab1e 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -1932,13 +1932,15 @@ PoolVector<uint8_t> _File::get_buffer(int p_length) const {
ERR_FAIL_COND_V(p_length < 0, data);
if (p_length == 0)
return data;
+
Error err = data.resize(p_length);
ERR_FAIL_COND_V(err != OK, data);
+
PoolVector<uint8_t>::Write w = data.write();
int len = f->get_buffer(&w[0], p_length);
ERR_FAIL_COND_V(len < 0, PoolVector<uint8_t>());
- w = PoolVector<uint8_t>::Write();
+ w.release();
if (len < p_length)
data.resize(p_length);
@@ -2113,11 +2115,11 @@ void _File::store_var(const Variant &p_var, bool p_full_objects) {
PoolVector<uint8_t> buff;
buff.resize(len);
- PoolVector<uint8_t>::Write w = buff.write();
+ PoolVector<uint8_t>::Write w = buff.write();
err = encode_variant(p_var, &w[0], len, p_full_objects);
ERR_FAIL_COND(err != OK);
- w = PoolVector<uint8_t>::Write();
+ w.release();
store_32(len);
store_buffer(buff);
@@ -2939,6 +2941,10 @@ float _Engine::get_physics_jitter_fix() const {
return Engine::get_singleton()->get_physics_jitter_fix();
}
+float _Engine::get_physics_interpolation_fraction() const {
+ return Engine::get_singleton()->get_physics_interpolation_fraction();
+}
+
void _Engine::set_target_fps(int p_fps) {
Engine::get_singleton()->set_target_fps(p_fps);
}
@@ -3027,6 +3033,7 @@ void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_iterations_per_second"), &_Engine::get_iterations_per_second);
ClassDB::bind_method(D_METHOD("set_physics_jitter_fix", "physics_jitter_fix"), &_Engine::set_physics_jitter_fix);
ClassDB::bind_method(D_METHOD("get_physics_jitter_fix"), &_Engine::get_physics_jitter_fix);
+ ClassDB::bind_method(D_METHOD("get_physics_interpolation_fraction"), &_Engine::get_physics_interpolation_fraction);
ClassDB::bind_method(D_METHOD("set_target_fps", "target_fps"), &_Engine::set_target_fps);
ClassDB::bind_method(D_METHOD("get_target_fps"), &_Engine::get_target_fps);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 3be5a08752..f0f86e003f 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -746,6 +746,7 @@ public:
void set_physics_jitter_fix(float p_threshold);
float get_physics_jitter_fix() const;
+ float get_physics_interpolation_fraction() const;
void set_target_fps(int p_fps);
int get_target_fps() const;
diff --git a/core/class_db.cpp b/core/class_db.cpp
index 2cbf53ba0b..794d990083 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -1148,7 +1148,7 @@ Variant::Type ClassDB::get_property_type(const StringName &p_class, const String
return Variant::NIL;
}
-StringName ClassDB::get_property_setter(StringName p_class, const StringName p_property) {
+StringName ClassDB::get_property_setter(StringName p_class, const StringName &p_property) {
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
@@ -1165,7 +1165,7 @@ StringName ClassDB::get_property_setter(StringName p_class, const StringName p_p
return StringName();
}
-StringName ClassDB::get_property_getter(StringName p_class, const StringName p_property) {
+StringName ClassDB::get_property_getter(StringName p_class, const StringName &p_property) {
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
diff --git a/core/class_db.h b/core/class_db.h
index 237ae9b806..3d9a695f02 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -337,8 +337,8 @@ public:
static bool has_property(const StringName &p_class, const StringName &p_property, bool p_no_inheritance = false);
static int get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL);
static Variant::Type get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL);
- static StringName get_property_setter(StringName p_class, const StringName p_property);
- static StringName get_property_getter(StringName p_class, const StringName p_property);
+ static StringName get_property_setter(StringName p_class, const StringName &p_property);
+ static StringName get_property_getter(StringName p_class, const StringName &p_property);
static bool has_method(StringName p_class, StringName p_method, bool p_no_inheritance = false);
static void set_method_flags(StringName p_class, StringName p_method, int p_flags);
diff --git a/core/engine.cpp b/core/engine.cpp
index 2d8473fbd9..0dd0459403 100644
--- a/core/engine.cpp
+++ b/core/engine.cpp
@@ -227,6 +227,7 @@ Engine::Engine() {
frames_drawn = 0;
ips = 60;
physics_jitter_fix = 0.5;
+ _physics_interpolation_fraction = 0.0f;
_frame_delay = 0;
_fps = 1;
_target_fps = 0;
diff --git a/core/engine.h b/core/engine.h
index 15665fee29..192e8e67a0 100644
--- a/core/engine.h
+++ b/core/engine.h
@@ -63,6 +63,7 @@ private:
float _time_scale;
bool _pixel_snap;
uint64_t _physics_frames;
+ float _physics_interpolation_fraction;
uint64_t _idle_frames;
bool _in_physics;
@@ -95,6 +96,7 @@ public:
bool is_in_physics_frame() const { return _in_physics; }
uint64_t get_idle_frame_ticks() const { return _frame_ticks; }
float get_idle_frame_step() const { return _frame_step; }
+ float get_physics_interpolation_fraction() const { return _physics_interpolation_fraction; }
void set_time_scale(float p_scale);
float get_time_scale() const;
diff --git a/core/image.cpp b/core/image.cpp
index 18a3aae88f..10778eced6 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -240,27 +240,27 @@ int Image::get_format_block_size(Format p_format) {
case FORMAT_RGTC_RG: { //bc5 case case FORMAT_DXT1:
return 4;
- } break;
+ }
case FORMAT_PVRTC2:
case FORMAT_PVRTC2A: {
return 4;
- } break;
+ }
case FORMAT_PVRTC4A:
case FORMAT_PVRTC4: {
return 4;
- } break;
+ }
case FORMAT_ETC: {
return 4;
- } break;
+ }
case FORMAT_BPTC_RGBA:
case FORMAT_BPTC_RGBF:
case FORMAT_BPTC_RGBFU: {
return 4;
- } break;
+ }
case FORMAT_ETC2_R11: //etc2
case FORMAT_ETC2_R11S: //signed: NOT srgb.
case FORMAT_ETC2_RG11:
@@ -270,7 +270,7 @@ int Image::get_format_block_size(Format p_format) {
case FORMAT_ETC2_RGB8A1: {
return 4;
- } break;
+ }
default: {
}
}
@@ -495,8 +495,8 @@ void Image::convert(Format p_new_format) {
case FORMAT_RGBA8 | (FORMAT_RGB8 << 8): _convert<3, true, 3, false, false, false>(width, height, rptr, wptr); break;
}
- r = PoolVector<uint8_t>::Read();
- w = PoolVector<uint8_t>::Write();
+ r.release();
+ w.release();
bool gen_mipmaps = mipmaps;
@@ -852,7 +852,7 @@ static void _scale_lanczos(const uint8_t *__restrict p_src, uint8_t *__restrict
static void _overlay(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, float p_alpha, uint32_t p_width, uint32_t p_height, uint32_t p_pixel_size) {
- uint16_t alpha = CLAMP((uint16_t)(p_alpha * 256.0f), 0, 256);
+ uint16_t alpha = MIN((uint16_t)(p_alpha * 256.0f), 256);
for (uint32_t i = 0; i < p_width * p_height * p_pixel_size; i++) {
@@ -1091,8 +1091,8 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
} break;
}
- r = PoolVector<uint8_t>::Read();
- w = PoolVector<uint8_t>::Write();
+ r.release();
+ w.release();
if (interpolate_mipmaps) {
dst._copy_internals_from(dst2);
@@ -2394,7 +2394,7 @@ void Image::lock() {
void Image::unlock() {
- write_lock = PoolVector<uint8_t>::Write();
+ write_lock.release();
}
Color Image::get_pixelv(const Point2 &p_src) const {
@@ -2421,38 +2421,36 @@ Color Image::get_pixel(int p_x, int p_y) const {
case FORMAT_L8: {
float l = ptr[ofs] / 255.0;
return Color(l, l, l, 1);
- } break;
+ }
case FORMAT_LA8: {
float l = ptr[ofs * 2 + 0] / 255.0;
float a = ptr[ofs * 2 + 1] / 255.0;
return Color(l, l, l, a);
- } break;
+ }
case FORMAT_R8: {
float r = ptr[ofs] / 255.0;
return Color(r, 0, 0, 1);
- } break;
+ }
case FORMAT_RG8: {
float r = ptr[ofs * 2 + 0] / 255.0;
float g = ptr[ofs * 2 + 1] / 255.0;
return Color(r, g, 0, 1);
- } break;
+ }
case FORMAT_RGB8: {
float r = ptr[ofs * 3 + 0] / 255.0;
float g = ptr[ofs * 3 + 1] / 255.0;
float b = ptr[ofs * 3 + 2] / 255.0;
return Color(r, g, b, 1);
-
- } break;
+ }
case FORMAT_RGBA8: {
float r = ptr[ofs * 4 + 0] / 255.0;
float g = ptr[ofs * 4 + 1] / 255.0;
float b = ptr[ofs * 4 + 2] / 255.0;
float a = ptr[ofs * 4 + 3] / 255.0;
return Color(r, g, b, a);
-
- } break;
+ }
case FORMAT_RGBA4444: {
uint16_t u = ((uint16_t *)ptr)[ofs];
float r = (u & 0xF) / 15.0;
@@ -2460,8 +2458,7 @@ Color Image::get_pixel(int p_x, int p_y) const {
float b = ((u >> 8) & 0xF) / 15.0;
float a = ((u >> 12) & 0xF) / 15.0;
return Color(r, g, b, a);
-
- } break;
+ }
case FORMAT_RGBA5551: {
uint16_t u = ((uint16_t *)ptr)[ofs];
@@ -2470,25 +2467,25 @@ Color Image::get_pixel(int p_x, int p_y) const {
float b = ((u >> 10) & 0x1F) / 15.0;
float a = ((u >> 15) & 0x1) / 1.0;
return Color(r, g, b, a);
- } break;
+ }
case FORMAT_RF: {
float r = ((float *)ptr)[ofs];
return Color(r, 0, 0, 1);
- } break;
+ }
case FORMAT_RGF: {
float r = ((float *)ptr)[ofs * 2 + 0];
float g = ((float *)ptr)[ofs * 2 + 1];
return Color(r, g, 0, 1);
- } break;
+ }
case FORMAT_RGBF: {
float r = ((float *)ptr)[ofs * 3 + 0];
float g = ((float *)ptr)[ofs * 3 + 1];
float b = ((float *)ptr)[ofs * 3 + 2];
return Color(r, g, b, 1);
- } break;
+ }
case FORMAT_RGBAF: {
float r = ((float *)ptr)[ofs * 4 + 0];
@@ -2496,25 +2493,25 @@ Color Image::get_pixel(int p_x, int p_y) const {
float b = ((float *)ptr)[ofs * 4 + 2];
float a = ((float *)ptr)[ofs * 4 + 3];
return Color(r, g, b, a);
- } break;
+ }
case FORMAT_RH: {
uint16_t r = ((uint16_t *)ptr)[ofs];
return Color(Math::half_to_float(r), 0, 0, 1);
- } break;
+ }
case FORMAT_RGH: {
uint16_t r = ((uint16_t *)ptr)[ofs * 2 + 0];
uint16_t g = ((uint16_t *)ptr)[ofs * 2 + 1];
return Color(Math::half_to_float(r), Math::half_to_float(g), 0, 1);
- } break;
+ }
case FORMAT_RGBH: {
uint16_t r = ((uint16_t *)ptr)[ofs * 3 + 0];
uint16_t g = ((uint16_t *)ptr)[ofs * 3 + 1];
uint16_t b = ((uint16_t *)ptr)[ofs * 3 + 2];
return Color(Math::half_to_float(r), Math::half_to_float(g), Math::half_to_float(b), 1);
- } break;
+ }
case FORMAT_RGBAH: {
uint16_t r = ((uint16_t *)ptr)[ofs * 4 + 0];
@@ -2522,18 +2519,15 @@ Color Image::get_pixel(int p_x, int p_y) const {
uint16_t b = ((uint16_t *)ptr)[ofs * 4 + 2];
uint16_t a = ((uint16_t *)ptr)[ofs * 4 + 3];
return Color(Math::half_to_float(r), Math::half_to_float(g), Math::half_to_float(b), Math::half_to_float(a));
- } break;
+ }
case FORMAT_RGBE9995: {
return Color::from_rgbe9995(((uint32_t *)ptr)[ofs]);
-
- } break;
+ }
default: {
ERR_EXPLAIN("Can't get_pixel() on compressed image, sorry.");
ERR_FAIL_V(Color());
}
}
-
- return Color();
}
void Image::set_pixelv(const Point2 &p_dst, const Color &p_color) {
diff --git a/core/input_map.cpp b/core/input_map.cpp
index 04911787a8..165999f081 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -202,7 +202,7 @@ bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const Str
if (p_pressed != NULL)
*p_pressed = input_event_action->is_pressed();
if (p_strength != NULL)
- *p_strength = (*p_pressed) ? input_event_action->get_strength() : 0.0f;
+ *p_strength = (p_pressed != NULL && *p_pressed) ? input_event_action->get_strength() : 0.0f;
return input_event_action->get_action() == p_action;
}
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 17a3f52a65..dc5581ea01 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -558,8 +558,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
w[i] = buf[i];
}
-
- w = PoolVector<uint8_t>::Write();
}
r_variant = data;
@@ -590,8 +588,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
w[i] = decode_uint32(&buf[i * 4]);
}
-
- w = PoolVector<int>::Write();
}
r_variant = Variant(data);
if (r_len) {
@@ -618,8 +614,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
w[i] = decode_float(&buf[i * 4]);
}
-
- w = PoolVector<float>::Write();
}
r_variant = data;
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 688dfc21e5..38bef2768e 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -410,7 +410,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
PoolVector<uint8_t>::Write w = array.write();
f->get_buffer(w.ptr(), len);
_advance_padding(len);
- w = PoolVector<uint8_t>::Write();
+ w.release();
r_v = array;
} break;
@@ -432,7 +432,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
}
#endif
- w = PoolVector<int>::Write();
+ w.release();
r_v = array;
} break;
case VARIANT_REAL_ARRAY: {
@@ -454,7 +454,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
#endif
- w = PoolVector<real_t>::Write();
+ w.release();
r_v = array;
} break;
case VARIANT_STRING_ARRAY: {
@@ -465,7 +465,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
PoolVector<String>::Write w = array.write();
for (uint32_t i = 0; i < len; i++)
w[i] = get_unicode_string();
- w = PoolVector<String>::Write();
+ w.release();
r_v = array;
} break;
@@ -493,7 +493,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
ERR_EXPLAIN("Vector2 size is NOT 8!");
ERR_FAIL_V(ERR_UNAVAILABLE);
}
- w = PoolVector<Vector2>::Write();
+ w.release();
r_v = array;
} break;
@@ -521,7 +521,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
ERR_EXPLAIN("Vector3 size is NOT 12!");
ERR_FAIL_V(ERR_UNAVAILABLE);
}
- w = PoolVector<Vector3>::Write();
+ w.release();
r_v = array;
} break;
@@ -549,7 +549,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
ERR_EXPLAIN("Color size is NOT 16!");
ERR_FAIL_V(ERR_UNAVAILABLE);
}
- w = PoolVector<Color>::Write();
+ w.release();
r_v = array;
} break;
#ifndef DISABLE_DEPRECATED
@@ -584,7 +584,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
PoolVector<uint8_t>::Write w = imgdata.write();
f->get_buffer(w.ptr(), datalen);
_advance_padding(datalen);
- w = PoolVector<uint8_t>::Write();
+ w.release();
Ref<Image> image;
image.instance();
@@ -597,7 +597,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
data.resize(f->get_32());
PoolVector<uint8_t>::Write w = data.write();
f->get_buffer(w.ptr(), data.size());
- w = PoolVector<uint8_t>::Write();
+ w.release();
Ref<Image> image;
@@ -712,8 +712,8 @@ Error ResourceInteractiveLoaderBinary::poll() {
if (!obj) {
error = ERR_FILE_CORRUPT;
ERR_EXPLAIN(local_path + ":Resource of unrecognized type in file: " + t);
+ ERR_FAIL_V(ERR_FILE_CORRUPT);
}
- ERR_FAIL_COND_V(!obj, ERR_FILE_CORRUPT);
Resource *r = Object::cast_to<Resource>(obj);
if (!r) {
diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp
index 0cecca904d..e2c1c3402a 100644
--- a/core/io/resource_saver.cpp
+++ b/core/io/resource_saver.cpp
@@ -137,7 +137,6 @@ Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t
save_callback(p_resource, p_path);
return OK;
- } else {
}
}
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index 6ad24a5f3a..84b8554d54 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -79,7 +79,7 @@ Array StreamPeer::_get_data(int p_bytes) {
PoolVector<uint8_t>::Write w = data.write();
Error err = get_data(&w[0], p_bytes);
- w = PoolVector<uint8_t>::Write();
+ w.release();
ret.push_back(err);
ret.push_back(data);
return ret;
@@ -101,7 +101,7 @@ Array StreamPeer::_get_partial_data(int p_bytes) {
PoolVector<uint8_t>::Write w = data.write();
int received;
Error err = get_partial_data(&w[0], p_bytes, received);
- w = PoolVector<uint8_t>::Write();
+ w.release();
if (err != OK) {
data.resize(0);
@@ -369,7 +369,9 @@ Variant StreamPeer::get_var(bool p_allow_objects) {
ERR_FAIL_COND_V(err != OK, Variant());
Variant ret;
- decode_variant(ret, var.ptr(), len, NULL, p_allow_objects);
+ err = decode_variant(ret, var.ptr(), len, NULL, p_allow_objects);
+ ERR_FAIL_COND_V(err != OK, Variant());
+
return ret;
}
diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp
index a8dd263484..310bb12bc0 100644
--- a/core/io/stream_peer_tcp.cpp
+++ b/core/io/stream_peer_tcp.cpp
@@ -30,6 +30,8 @@
#include "stream_peer_tcp.h"
+#include "core/project_settings.h"
+
Error StreamPeerTCP::_poll_connection() {
ERR_FAIL_COND_V(status != STATUS_CONNECTING || !_sock.is_valid() || !_sock->is_open(), FAILED);
@@ -40,6 +42,12 @@ Error StreamPeerTCP::_poll_connection() {
status = STATUS_CONNECTED;
return OK;
} else if (err == ERR_BUSY) {
+ // Check for connect timeout
+ if (OS::get_singleton()->get_ticks_msec() > timeout) {
+ disconnect_from_host();
+ status = STATUS_ERROR;
+ return ERR_CONNECTION_ERROR;
+ }
// Still trying to connect
return OK;
}
@@ -54,6 +62,7 @@ void StreamPeerTCP::accept_socket(Ref<NetSocket> p_sock, IP_Address p_host, uint
_sock = p_sock;
_sock->set_blocking_enabled(false);
+ timeout = OS::get_singleton()->get_ticks_msec() + (((uint64_t)GLOBAL_GET("network/limits/tcp/connect_timeout_seconds")) * 1000);
status = STATUS_CONNECTING;
peer_host = p_host;
@@ -74,6 +83,7 @@ Error StreamPeerTCP::connect_to_host(const IP_Address &p_host, uint16_t p_port)
_sock->set_blocking_enabled(false);
+ timeout = OS::get_singleton()->get_ticks_msec() + (((uint64_t)GLOBAL_GET("network/limits/tcp/connect_timeout_seconds")) * 1000);
err = _sock->connect_to_host(p_host, p_port);
if (err == OK) {
@@ -281,6 +291,7 @@ void StreamPeerTCP::disconnect_from_host() {
if (_sock.is_valid() && _sock->is_open())
_sock->close();
+ timeout = 0;
status = STATUS_NONE;
peer_host = IP_Address();
peer_port = 0;
@@ -356,6 +367,7 @@ void StreamPeerTCP::_bind_methods() {
StreamPeerTCP::StreamPeerTCP() :
_sock(Ref<NetSocket>(NetSocket::create())),
+ timeout(0),
status(STATUS_NONE),
peer_port(0) {
}
diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h
index 1ca39375aa..321fb3a6c8 100644
--- a/core/io/stream_peer_tcp.h
+++ b/core/io/stream_peer_tcp.h
@@ -52,6 +52,7 @@ public:
protected:
Ref<NetSocket> _sock;
+ uint64_t timeout;
Status status;
IP_Address peer_host;
uint16_t peer_port;
diff --git a/core/make_binders.py b/core/make_binders.py
index 5c1c66cab6..24901c42a1 100644
--- a/core/make_binders.py
+++ b/core/make_binders.py
@@ -191,6 +191,96 @@ MethodBind* create_method_bind($ifret R$ $ifnoret void$ (T::*p_method)($arg, P@$
"""
+template_typed_free_func = """
+#ifdef TYPED_METHOD_BIND
+template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$>
+class FunctionBind$argc$$ifret R$$ifconst C$ : public MethodBind {
+public:
+
+ $ifret R$ $ifnoret void$ (*method) ($ifconst const$ T *$ifargs , $$arg, P@$);
+#ifdef DEBUG_METHODS_ENABLED
+ virtual Variant::Type _gen_argument_type(int p_arg) const { return _get_argument_type(p_arg); }
+ virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const {
+ $ifret if (p_arg==-1) return GetTypeInfo<R>::METADATA;$
+ $arg if (p_arg==(@-1)) return GetTypeInfo<P@>::METADATA;
+ $
+ return GodotTypeInfo::METADATA_NONE;
+ }
+ Variant::Type _get_argument_type(int p_argument) const {
+ $ifret if (p_argument==-1) return (Variant::Type)GetTypeInfo<R>::VARIANT_TYPE;$
+ $arg if (p_argument==(@-1)) return (Variant::Type)GetTypeInfo<P@>::VARIANT_TYPE;
+ $
+ return Variant::NIL;
+ }
+ virtual PropertyInfo _gen_argument_type_info(int p_argument) const {
+ $ifret if (p_argument==-1) return GetTypeInfo<R>::get_class_info();$
+ $arg if (p_argument==(@-1)) return GetTypeInfo<P@>::get_class_info();
+ $
+ return PropertyInfo();
+ }
+#endif
+ virtual String get_instance_class() const {
+ return T::get_class_static();
+ }
+
+ virtual Variant call(Object* p_object,const Variant** p_args,int p_arg_count, Variant::CallError& r_error) {
+
+ T *instance=Object::cast_to<T>(p_object);
+ r_error.error=Variant::CallError::CALL_OK;
+#ifdef DEBUG_METHODS_ENABLED
+
+ ERR_FAIL_COND_V(!instance,Variant());
+ if (p_arg_count>get_argument_count()) {
+ r_error.error=Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
+ r_error.argument=get_argument_count();
+ return Variant();
+
+ }
+ if (p_arg_count<(get_argument_count()-get_default_argument_count())) {
+
+ r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.argument=get_argument_count()-get_default_argument_count();
+ return Variant();
+ }
+ $arg CHECK_ARG(@);
+ $
+#endif
+ $ifret Variant ret = $(method)(instance$ifargs , $$arg, _VC(@)$);
+ $ifret return Variant(ret);$
+ $ifnoret return Variant();$
+ }
+
+#ifdef PTRCALL_ENABLED
+ virtual void ptrcall(Object*p_object,const void** p_args,void *r_ret) {
+
+ T *instance=Object::cast_to<T>(p_object);
+ $ifret PtrToArg<R>::encode( $ (method)(instance$ifargs , $$arg, PtrToArg<P@>::convert(p_args[@-1])$) $ifret ,r_ret)$ ;
+ }
+#endif
+ FunctionBind$argc$$ifret R$$ifconst C$ () {
+#ifdef DEBUG_METHODS_ENABLED
+ _set_const($ifconst true$$ifnoconst false$);
+ _generate_argument_types($argc$);
+#else
+ set_argument_count($argc$);
+#endif
+
+ $ifret _set_returns(true); $
+ };
+};
+
+template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$>
+MethodBind* create_method_bind($ifret R$ $ifnoret void$ (*p_method)($ifconst const$ T *$ifargs , $$arg, P@$) ) {
+
+ FunctionBind$argc$$ifret R$$ifconst C$<T $ifret ,R$ $ifargs ,$ $arg, P@$> * a = memnew( (FunctionBind$argc$$ifret R$$ifconst C$<T $ifret ,R$ $ifargs ,$ $arg, P@$>) );
+ a->method=p_method;
+ return a;
+}
+#endif
+"""
+
+
+
def make_version(template, nargs, argmax, const, ret):
intext = template
@@ -259,6 +349,9 @@ def run(target, source, env):
versions_ext = 6
text = ""
text_ext = ""
+ text_free_func = "#ifndef METHOD_BIND_FREE_FUNC_H\n#define METHOD_BIND_FREE_FUNC_H\n"
+ text_free_func += "\n//including this header file allows method binding to use free functions\n"
+ text_free_func += "//note that the free function must have a pointer to an instance of the class as its first parameter\n"
for i in range(0, versions + 1):
@@ -276,12 +369,22 @@ def run(target, source, env):
else:
text += t
+ text_free_func += make_version(template_typed_free_func, i, versions, False, False)
+ text_free_func += make_version(template_typed_free_func, i, versions, False, True)
+ text_free_func += make_version(template_typed_free_func, i, versions, True, False)
+ text_free_func += make_version(template_typed_free_func, i, versions, True, True)
+
+ text_free_func += "#endif"
+
with open(target[0], "w") as f:
f.write(text)
with open(target[1], "w") as f:
f.write(text_ext)
+ with open(target[2], "w") as f:
+ f.write(text_free_func)
+
if __name__ == '__main__':
from platform_methods import subprocess_main
diff --git a/core/math/SCsub b/core/math/SCsub
index aa98c34f79..0995298a4b 100644
--- a/core/math/SCsub
+++ b/core/math/SCsub
@@ -22,7 +22,7 @@ if not has_module:
env_thirdparty = env_math.Clone()
env_thirdparty.disable_warnings()
# Custom config file
- env_thirdparty.Append(CPPDEFINES=[('MBEDTLS_CONFIG_FILE', "thirdparty/mbedtls/include/godot_core_mbedtls_config.h")])
+ env_thirdparty.Append(CPPDEFINES=[('MBEDTLS_CONFIG_FILE', '\\"thirdparty/mbedtls/include/godot_core_mbedtls_config.h\\"')])
thirdparty_mbedtls_dir = "#thirdparty/mbedtls/library/"
thirdparty_mbedtls_sources = [
"aes.c",
diff --git a/core/math/basis.cpp b/core/math/basis.cpp
index 1540bc8fe1..400f342018 100644
--- a/core/math/basis.cpp
+++ b/core/math/basis.cpp
@@ -852,7 +852,7 @@ void Basis::set_quat_scale(const Quat &p_quat, const Vector3 &p_scale) {
rotate(p_quat);
}
-void Basis::set_diagonal(const Vector3 p_diag) {
+void Basis::set_diagonal(const Vector3 &p_diag) {
elements[0][0] = p_diag.x;
elements[0][1] = 0;
elements[0][2] = 0;
diff --git a/core/math/basis.h b/core/math/basis.h
index 75037c2c52..d3adad3d90 100644
--- a/core/math/basis.h
+++ b/core/math/basis.h
@@ -153,7 +153,7 @@ public:
int get_orthogonal_index() const;
void set_orthogonal_index(int p_index);
- void set_diagonal(const Vector3 p_diag);
+ void set_diagonal(const Vector3 &p_diag);
bool is_orthogonal() const;
bool is_diagonal() const;
diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp
index a12f9fee2e..cfa698282e 100644
--- a/core/math/bsp_tree.cpp
+++ b/core/math/bsp_tree.cpp
@@ -192,7 +192,7 @@ int BSP_Tree::get_points_inside(const Vector3 *p_points, int p_point_count) cons
#ifdef DEBUG_ENABLED
int plane_count = planes.size();
uint16_t plane = nodesptr[idx].plane;
- ERR_FAIL_INDEX_V(plane, plane_count, false);
+ ERR_FAIL_UNSIGNED_INDEX_V(plane, plane_count, false);
#endif
idx = planesptr[nodesptr[idx].plane].is_point_over(point) ? nodes[idx].over : nodes[idx].under;
@@ -258,7 +258,7 @@ bool BSP_Tree::point_is_inside(const Vector3 &p_point) const {
#ifdef DEBUG_ENABLED
int plane_count = planes.size();
uint16_t plane = nodesptr[idx].plane;
- ERR_FAIL_INDEX_V(plane, plane_count, false);
+ ERR_FAIL_UNSIGNED_INDEX_V(plane, plane_count, false);
#endif
bool over = planesptr[nodesptr[idx].plane].is_point_over(p_point);
diff --git a/core/math/expression.cpp b/core/math/expression.cpp
index b52658e2cf..25a40c70bf 100644
--- a/core/math/expression.cpp
+++ b/core/math/expression.cpp
@@ -52,6 +52,7 @@ const char *Expression::func_name[Expression::FUNC_MAX] = {
"sqrt",
"fmod",
"fposmod",
+ "posmod",
"floor",
"ceil",
"round",
@@ -175,6 +176,7 @@ int Expression::get_func_argument_count(BuiltinFunc p_func) {
case MATH_ATAN2:
case MATH_FMOD:
case MATH_FPOSMOD:
+ case MATH_POSMOD:
case MATH_POW:
case MATH_EASE:
case MATH_STEPIFY:
@@ -283,6 +285,12 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
VALIDATE_ARG_NUM(1);
*r_return = Math::fposmod((double)*p_inputs[0], (double)*p_inputs[1]);
} break;
+ case MATH_POSMOD: {
+
+ VALIDATE_ARG_NUM(0);
+ VALIDATE_ARG_NUM(1);
+ *r_return = Math::posmod((int)*p_inputs[0], (int)*p_inputs[1]);
+ } break;
case MATH_FLOOR: {
VALIDATE_ARG_NUM(0);
@@ -793,17 +801,13 @@ Error Expression::_get_token(Token &r_token) {
#define GET_CHAR() (str_ofs >= expression.length() ? 0 : expression[str_ofs++])
CharType cchar = GET_CHAR();
- if (cchar == 0) {
- r_token.type = TK_EOF;
- return OK;
- }
switch (cchar) {
case 0: {
r_token.type = TK_EOF;
return OK;
- } break;
+ };
case '{': {
r_token.type = TK_CURLY_BRACKET_OPEN;
diff --git a/core/math/expression.h b/core/math/expression.h
index 1113bb6587..03a2bb70e6 100644
--- a/core/math/expression.h
+++ b/core/math/expression.h
@@ -51,6 +51,7 @@ public:
MATH_SQRT,
MATH_FMOD,
MATH_FPOSMOD,
+ MATH_POSMOD,
MATH_FLOOR,
MATH_CEIL,
MATH_ROUND,
diff --git a/core/math/geometry.h b/core/math/geometry.h
index 0e144e491f..e4f3ff799e 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -455,16 +455,15 @@ public:
Vector3 p = p_point - p_segment[0];
Vector3 n = p_segment[1] - p_segment[0];
- real_t l = n.length();
- if (l < 1e-10)
+ real_t l2 = n.length_squared();
+ if (l2 < 1e-20)
return p_segment[0]; // both points are the same, just give any
- n /= l;
- real_t d = n.dot(p);
+ real_t d = n.dot(p) / l2;
if (d <= 0.0)
return p_segment[0]; // before first point
- else if (d >= l)
+ else if (d >= 1.0)
return p_segment[1]; // after first point
else
return p_segment[0] + n * d; // inside
@@ -474,12 +473,11 @@ public:
Vector3 p = p_point - p_segment[0];
Vector3 n = p_segment[1] - p_segment[0];
- real_t l = n.length();
- if (l < 1e-10)
+ real_t l2 = n.length_squared();
+ if (l2 < 1e-20)
return p_segment[0]; // both points are the same, just give any
- n /= l;
- real_t d = n.dot(p);
+ real_t d = n.dot(p) / l2;
return p_segment[0] + n * d; // inside
}
@@ -488,16 +486,15 @@ public:
Vector2 p = p_point - p_segment[0];
Vector2 n = p_segment[1] - p_segment[0];
- real_t l = n.length();
- if (l < 1e-10)
+ real_t l2 = n.length_squared();
+ if (l2 < 1e-20)
return p_segment[0]; // both points are the same, just give any
- n /= l;
- real_t d = n.dot(p);
+ real_t d = n.dot(p) / l2;
if (d <= 0.0)
return p_segment[0]; // before first point
- else if (d >= l)
+ else if (d >= 1.0)
return p_segment[1]; // after first point
else
return p_segment[0] + n * d; // inside
@@ -521,12 +518,11 @@ public:
Vector2 p = p_point - p_segment[0];
Vector2 n = p_segment[1] - p_segment[0];
- real_t l = n.length();
- if (l < 1e-10)
+ real_t l2 = n.length_squared();
+ if (l2 < 1e-20)
return p_segment[0]; // both points are the same, just give any
- n /= l;
- real_t d = n.dot(p);
+ real_t d = n.dot(p) / l2;
return p_segment[0] + n * d; // inside
}
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 0e3bd8a318..b6398712e4 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -198,6 +198,13 @@ public:
value += 0.0;
return value;
}
+ static _ALWAYS_INLINE_ int posmod(int p_x, int p_y) {
+ int value = p_x % p_y;
+ if ((value < 0 && p_y > 0) || (value > 0 && p_y < 0)) {
+ value += p_y;
+ }
+ return value;
+ }
static _ALWAYS_INLINE_ double deg2rad(double p_y) { return p_y * Math_PI / 180.0; }
static _ALWAYS_INLINE_ float deg2rad(float p_y) { return p_y * Math_PI / 180.0; }
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index 83784a1fa7..546981be44 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -182,7 +182,7 @@ void TriangleMesh::create(const PoolVector<Vector3> &p_faces) {
int max_alloc = fc;
_create_bvh(bw.ptr(), bwp.ptr(), 0, fc, 1, max_depth, max_alloc);
- bw = PoolVector<BVH>::Write(); //clearup
+ bw.release(); //clearup
bvh.resize(max_alloc); //resize back
valid = true;
@@ -751,7 +751,7 @@ PoolVector<Face3> TriangleMesh::get_faces() const {
}
}
- w = PoolVector<Face3>::Write();
+ w.release();
return faces;
}
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 811a207138..45bdfee487 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -219,10 +219,6 @@ Vector3 Vector3::linear_interpolate(const Vector3 &p_b, real_t p_t) const {
}
Vector3 Vector3::slerp(const Vector3 &p_b, real_t p_t) const {
-#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(!is_normalized(), Vector3());
-#endif
-
real_t theta = angle_to(p_b);
return rotated(cross(p_b).normalized(), theta * p_t);
}
diff --git a/core/object.cpp b/core/object.cpp
index 3367d6b6c3..67ab27c190 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -635,9 +635,12 @@ void Object::get_property_list(List<PropertyInfo> *p_list, bool p_reversed) cons
#endif
p_list->push_back(PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script", PROPERTY_USAGE_DEFAULT));
}
- if (!metadata.empty()) {
- p_list->push_back(PropertyInfo(Variant::DICTIONARY, "__meta__", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL));
- }
+
+#ifdef TOOLS_ENABLED
+ p_list->push_back(PropertyInfo(Variant::NIL, "Metadata", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
+#endif
+ p_list->push_back(PropertyInfo(Variant::DICTIONARY, "__meta__", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT));
+
if (script_instance && !p_reversed) {
p_list->push_back(PropertyInfo(Variant::NIL, "Script Variables", PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY));
script_instance->get_property_list(p_list);
diff --git a/core/object.h b/core/object.h
index 1e0b22c086..e6c5b7c5b9 100644
--- a/core/object.h
+++ b/core/object.h
@@ -179,6 +179,15 @@ struct PropertyInfo {
usage(PROPERTY_USAGE_DEFAULT) {
}
+ bool operator==(const PropertyInfo &p_info) const {
+ return ((type == p_info.type) &&
+ (name == p_info.name) &&
+ (class_name == p_info.class_name) &&
+ (hint == p_info.hint) &&
+ (hint_string == p_info.hint_string) &&
+ (usage == p_info.usage));
+ }
+
bool operator<(const PropertyInfo &p_info) const {
return name < p_info.name;
}
diff --git a/core/pool_allocator.cpp b/core/pool_allocator.cpp
index 094352b5cc..9b342ef913 100644
--- a/core/pool_allocator.cpp
+++ b/core/pool_allocator.cpp
@@ -611,7 +611,7 @@ PoolAllocator::PoolAllocator(void *p_mem, int p_size, int p_align, bool p_needs_
PoolAllocator::PoolAllocator(int p_align, int p_size, bool p_needs_locking, int p_max_entries) {
ERR_FAIL_COND(p_align < 1);
- mem_ptr = Memory::alloc_static(p_size + p_align, "PoolAllocator()");
+ mem_ptr = Memory::alloc_static(p_size + p_align, true);
uint8_t *mem8 = (uint8_t *)mem_ptr;
uint64_t ofs = (uint64_t)mem8;
if (ofs % p_align)
diff --git a/core/pool_vector.h b/core/pool_vector.h
index 338de966f6..3d28d86803 100644
--- a/core/pool_vector.h
+++ b/core/pool_vector.h
@@ -301,6 +301,10 @@ public:
virtual ~Access() {
_unref();
}
+
+ void release() {
+ _unref();
+ }
};
class Read : public Access {
@@ -454,7 +458,7 @@ public:
bool is_locked() const { return alloc && alloc->lock > 0; }
- inline const T operator[](int p_index) const;
+ inline T operator[](int p_index) const;
Error resize(int p_size);
@@ -484,9 +488,7 @@ T PoolVector<T>::get(int p_index) const {
template <class T>
void PoolVector<T>::set(int p_index, const T &p_val) {
- if (p_index < 0 || p_index >= size()) {
- ERR_FAIL_COND(p_index < 0 || p_index >= size());
- }
+ ERR_FAIL_INDEX(p_index, size());
Write w = write();
w[p_index] = p_val;
@@ -500,7 +502,7 @@ void PoolVector<T>::push_back(const T &p_val) {
}
template <class T>
-const T PoolVector<T>::operator[](int p_index) const {
+T PoolVector<T>::operator[](int p_index) const {
CRASH_BAD_INDEX(p_index, size());
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index 3597e2b818..c1d4967f55 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -487,7 +487,7 @@ void ProjectSettings::set_registering_order(bool p_enable) {
registering_order = p_enable;
}
-Error ProjectSettings::_load_settings_binary(const String p_path) {
+Error ProjectSettings::_load_settings_binary(const String &p_path) {
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -530,7 +530,7 @@ Error ProjectSettings::_load_settings_binary(const String p_path) {
return OK;
}
-Error ProjectSettings::_load_settings_text(const String p_path) {
+Error ProjectSettings::_load_settings_text(const String &p_path) {
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -593,7 +593,7 @@ Error ProjectSettings::_load_settings_text(const String p_path) {
}
}
-Error ProjectSettings::_load_settings_text_or_binary(const String p_text_path, const String p_bin_path) {
+Error ProjectSettings::_load_settings_text_or_binary(const String &p_text_path, const String &p_bin_path) {
// Attempt first to load the text-based project.godot file
Error err_text = _load_settings_text(p_text_path);
diff --git a/core/project_settings.h b/core/project_settings.h
index 0ff18ab3f5..d7651417d5 100644
--- a/core/project_settings.h
+++ b/core/project_settings.h
@@ -97,9 +97,9 @@ protected:
static ProjectSettings *singleton;
- Error _load_settings_text(const String p_path);
- Error _load_settings_binary(const String p_path);
- Error _load_settings_text_or_binary(const String p_text_path, const String p_bin_path);
+ Error _load_settings_text(const String &p_path);
+ Error _load_settings_binary(const String &p_path);
+ Error _load_settings_text_or_binary(const String &p_text_path, const String &p_bin_path);
Error _save_settings_text(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
Error _save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 11cd07042f..e442546124 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -207,6 +207,8 @@ void register_core_types() {
void register_core_settings() {
//since in register core types, globals may not e present
+ GLOBAL_DEF("network/limits/tcp/connect_timeout_seconds", (30));
+ ProjectSettings::get_singleton()->set_custom_property_info("network/limits/tcp/connect_timeout_seconds", PropertyInfo(Variant::INT, "network/limits/tcp/connect_timeout_seconds", PROPERTY_HINT_RANGE, "1,1800,1"));
GLOBAL_DEF_RST("network/limits/packet_peer_stream/max_buffer_po2", (16));
ProjectSettings::get_singleton()->set_custom_property_info("network/limits/packet_peer_stream/max_buffer_po2", PropertyInfo(Variant::INT, "network/limits/packet_peer_stream/max_buffer_po2", PROPERTY_HINT_RANGE, "0,64,1,or_greater"));
}
diff --git a/core/string_name.cpp b/core/string_name.cpp
index 10b71ad3ac..b1a8bfb849 100644
--- a/core/string_name.cpp
+++ b/core/string_name.cpp
@@ -205,7 +205,6 @@ StringName::StringName(const char *p_name) {
// exists
lock->unlock();
return;
- } else {
}
}
@@ -253,7 +252,6 @@ StringName::StringName(const StaticCString &p_static_string) {
// exists
lock->unlock();
return;
- } else {
}
}
@@ -301,7 +299,6 @@ StringName::StringName(const String &p_name) {
// exists
lock->unlock();
return;
- } else {
}
}
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 21ac304a1b..75e3b6f22e 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -778,7 +778,7 @@ Vector<String> String::split(const String &p_splitter, bool p_allow_empty, int p
if (p_allow_empty || (end > from)) {
if (p_maxsplit <= 0)
ret.push_back(substr(from, end - from));
- else if (p_maxsplit > 0) {
+ else {
// Put rest of the string and leave cycle.
if (p_maxsplit == ret.size()) {
@@ -3338,7 +3338,7 @@ String String::http_unescape() const {
if ((ord1 >= '0' && ord1 <= '9') || (ord1 >= 'A' && ord1 <= 'Z')) {
CharType ord2 = ord_at(i + 2);
if ((ord2 >= '0' && ord2 <= '9') || (ord2 >= 'A' && ord2 <= 'Z')) {
- char bytes[2] = { (char)ord1, (char)ord2 };
+ char bytes[3] = { (char)ord1, (char)ord2, 0 };
res += (char)strtol(bytes, NULL, 16);
i += 2;
}
diff --git a/core/variant.cpp b/core/variant.cpp
index 5b51a4e513..1574af5239 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -1834,8 +1834,6 @@ inline DA _convert_array_from_variant(const Variant &p_variant) {
return DA();
}
}
-
- return DA();
}
Variant::operator Array() const {
@@ -2299,7 +2297,7 @@ Variant::Variant(const Object *p_object) {
Variant::Variant(const Dictionary &p_dictionary) {
type = DICTIONARY;
- memnew_placement(_data._mem, (Dictionary)(p_dictionary));
+ memnew_placement(_data._mem, Dictionary(p_dictionary));
}
Variant::Variant(const Array &p_array) {
@@ -2418,9 +2416,6 @@ Variant::Variant(const PoolVector<Face3> &p_face_array) {
for (int j = 0; j < 3; j++)
w[i * 3 + j] = r[i].vertex[j];
}
-
- r = PoolVector<Face3>::Read();
- w = PoolVector<Vector3>::Write();
}
type = NIL;
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 4c3cbfa484..b637e745af 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -70,7 +70,7 @@ struct _VariantCall {
for (int i = 0; i < arg_count; i++) {
- if (!tptr[i] || tptr[i] == p_args[i]->type)
+ if (tptr[i] == Variant::NIL || tptr[i] == p_args[i]->type)
continue; // all good
if (!Variant::can_convert(p_args[i]->type, tptr[i])) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
@@ -319,7 +319,7 @@ struct _VariantCall {
retval.resize(len);
PoolByteArray::Write w = retval.write();
copymem(w.ptr(), charstr.ptr(), len);
- w = PoolVector<uint8_t>::Write();
+ w.release();
r_ret = retval;
}
@@ -334,7 +334,7 @@ struct _VariantCall {
retval.resize(len);
PoolByteArray::Write w = retval.write();
copymem(w.ptr(), charstr.ptr(), len);
- w = PoolVector<uint8_t>::Write();
+ w.release();
r_ret = retval;
}
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index d677c7776a..ea9e29e744 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -2613,7 +2613,7 @@ bool Variant::in(const Variant &p_index, bool *r_valid) const {
if (r_valid) {
*r_valid = false;
}
- return "Attempted get on stray pointer.";
+ return true; // Attempted get on stray pointer.
}
}
#endif
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index d5513bc2d7..07212ec669 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -1537,8 +1537,6 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
Token token;
get_token(p_stream, token, line, r_err_str);
Error err = parse_value(token, r_value, p_stream, line, r_err_str, p_res_parser);
- if (err) {
- }
return err;
}
} else if (c == '\n') {