summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/io/http_client.cpp8
-rw-r--r--core/io/http_client.h1
-rw-r--r--core/io/packet_peer.cpp1
-rw-r--r--core/math/camera_matrix.cpp4
-rw-r--r--core/math/face3.cpp2
-rw-r--r--core/project_settings.cpp4
-rw-r--r--core/typedefs.h3
-rw-r--r--core/ustring.cpp2
8 files changed, 22 insertions, 3 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 170bef4430..1904c70f42 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -98,6 +98,8 @@ Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl,
void HTTPClient::set_connection(const Ref<StreamPeer> &p_connection) {
+ ERR_FAIL_COND_MSG(p_connection.is_null(), "Connection is not a reference to a valid StreamPeer object.");
+
close();
connection = p_connection;
status = STATUS_CONNECTED;
@@ -713,6 +715,10 @@ void HTTPClient::set_read_chunk_size(int p_size) {
read_chunk_size = p_size;
}
+int HTTPClient::get_read_chunk_size() const {
+ return read_chunk_size;
+}
+
HTTPClient::HTTPClient() {
tcp_connection.instance();
@@ -816,6 +822,7 @@ void HTTPClient::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_response_body_length"), &HTTPClient::get_response_body_length);
ClassDB::bind_method(D_METHOD("read_response_body_chunk"), &HTTPClient::read_response_body_chunk);
ClassDB::bind_method(D_METHOD("set_read_chunk_size", "bytes"), &HTTPClient::set_read_chunk_size);
+ ClassDB::bind_method(D_METHOD("get_read_chunk_size"), &HTTPClient::get_read_chunk_size);
ClassDB::bind_method(D_METHOD("set_blocking_mode", "enabled"), &HTTPClient::set_blocking_mode);
ClassDB::bind_method(D_METHOD("is_blocking_mode_enabled"), &HTTPClient::is_blocking_mode_enabled);
@@ -827,6 +834,7 @@ void HTTPClient::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "blocking_mode_enabled"), "set_blocking_mode", "is_blocking_mode_enabled");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "connection", PROPERTY_HINT_RESOURCE_TYPE, "StreamPeer", 0), "set_connection", "get_connection");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "read_chunk_size", PROPERTY_HINT_RANGE, "256,16777216"), "set_read_chunk_size", "get_read_chunk_size");
BIND_ENUM_CONSTANT(METHOD_GET);
BIND_ENUM_CONSTANT(METHOD_HEAD);
diff --git a/core/io/http_client.h b/core/io/http_client.h
index 85ee1959a2..ce7fe0491b 100644
--- a/core/io/http_client.h
+++ b/core/io/http_client.h
@@ -220,6 +220,7 @@ public:
bool is_blocking_mode_enabled() const;
void set_read_chunk_size(int p_size);
+ int get_read_chunk_size() const;
Error poll();
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 821a04ebad..23dfc58385 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -279,6 +279,7 @@ Ref<StreamPeer> PacketPeerStream::get_stream_peer() const {
void PacketPeerStream::set_input_buffer_max_size(int p_max_size) {
+ ERR_FAIL_COND_MSG(p_max_size < 0, "Max size of input buffer size cannot be smaller than 0.");
//warning may lose packets
ERR_FAIL_COND_MSG(ring_buffer.data_left(), "Buffer in use, resizing would cause loss of data.");
ring_buffer.resize(nearest_shift(p_max_size + 4));
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 30c0cab909..b9b0f4ac54 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -183,6 +183,10 @@ void CameraMatrix::set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear
void CameraMatrix::set_frustum(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_near, real_t p_far) {
+ ERR_FAIL_COND(p_right <= p_left);
+ ERR_FAIL_COND(p_top <= p_bottom);
+ ERR_FAIL_COND(p_far <= p_near);
+
real_t *te = &matrix[0][0];
real_t x = 2 * p_near / (p_right - p_left);
real_t y = 2 * p_near / (p_top - p_bottom);
diff --git a/core/math/face3.cpp b/core/math/face3.cpp
index ab09142b2d..666d214f98 100644
--- a/core/math/face3.cpp
+++ b/core/math/face3.cpp
@@ -393,7 +393,7 @@ Vector3 Face3::get_closest_point_to(const Vector3 &p_point) const {
s = CLAMP(numer / denom, 0.f, 1.f);
t = 1 - s;
} else {
- s = CLAMP(-e / c, 0.f, 1.f);
+ s = CLAMP(-d / a, 0.f, 1.f);
t = 0.f;
}
} else {
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index 7704c7b377..067578e354 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -107,7 +107,7 @@ String ProjectSettings::localize_path(const String &p_path) const {
if (plocal == "") {
return "";
};
- return plocal + path.substr((sep + 1), path.size() - (sep + 1));
+ return plocal + path.substr(sep, path.size() - sep);
};
}
@@ -525,6 +525,8 @@ Error ProjectSettings::_load_settings_binary(const String &p_path) {
set(key, value);
}
+ f->close();
+ memdelete(f);
return OK;
}
diff --git a/core/typedefs.h b/core/typedefs.h
index 767a97ac38..42f34c73cb 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -174,6 +174,9 @@ inline void __swap_tmpl(T &x, T &y) {
static _FORCE_INLINE_ unsigned int next_power_of_2(unsigned int x) {
+ if (x == 0)
+ return 0;
+
--x;
x |= x >> 1;
x |= x >> 2;
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 0f82ca7e15..25930db201 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -1416,7 +1416,7 @@ bool String::parse_utf8(const char *p_utf8, int p_len) {
if (skip == 0) {
- uint8_t c = *ptrtmp;
+ uint8_t c = *ptrtmp >= 0 ? *ptrtmp : uint8_t(256 + *ptrtmp);
/* Determine the number of characters in sequence */
if ((c & 0x80) == 0)