summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/SCsub2
-rw-r--r--core/class_db.cpp4
-rw-r--r--core/class_db.h4
-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/vector3.h4
-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/ustring.cpp2
14 files changed, 133 insertions, 19 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/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/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/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/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/ustring.cpp b/core/ustring.cpp
index 706e8a3cc1..75e3b6f22e 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -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;
}