diff --git a/.gitattributes b/.gitattributes index f8959dd2d14e..03c6f96f80eb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,3 +8,4 @@ drivers/* linguist-vendored *.h eol=lf *.py eol=lf *.hpp eol=lf +*.xml eol=lf diff --git a/SConstruct b/SConstruct index 6045be54c7e0..c05a4332ab0f 100644 --- a/SConstruct +++ b/SConstruct @@ -72,6 +72,7 @@ env_base.AppendENVPath('PATH', os.getenv('PATH')) env_base.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH')) env_base.global_defaults = global_defaults env_base.android_maven_repos = [] +env_base.android_flat_dirs = [] env_base.android_dependencies = [] env_base.android_gradle_plugins = [] env_base.android_gradle_classpath = [] @@ -96,6 +97,7 @@ env_base.SetOption('implicit_cache', 1) env_base.__class__.android_add_maven_repository = methods.android_add_maven_repository +env_base.__class__.android_add_flat_dir = methods.android_add_flat_dir env_base.__class__.android_add_dependency = methods.android_add_dependency env_base.__class__.android_add_java_dir = methods.android_add_java_dir env_base.__class__.android_add_res_dir = methods.android_add_res_dir diff --git a/core/array.cpp b/core/array.cpp index 30184a002e81..171c11776c97 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -233,9 +233,10 @@ struct _ArrayVariantSort { } }; -void Array::sort() { +Array &Array::sort() { _p->array.sort_custom<_ArrayVariantSort>(); + return *this; } struct _ArrayVariantSortCustom { @@ -253,19 +254,21 @@ struct _ArrayVariantSortCustom { return res; } }; -void Array::sort_custom(Object *p_obj, const StringName &p_function) { +Array &Array::sort_custom(Object *p_obj, const StringName &p_function) { - ERR_FAIL_NULL(p_obj); + ERR_FAIL_NULL_V(p_obj, *this); SortArray avs; avs.compare.obj = p_obj; avs.compare.func = p_function; avs.sort(_p->array.ptr(), _p->array.size()); + return *this; } -void Array::invert() { +Array &Array::invert() { _p->array.invert(); + return *this; } void Array::push_front(const Variant &p_value) { diff --git a/core/array.h b/core/array.h index 8a647dd13bca..2c291031085f 100644 --- a/core/array.h +++ b/core/array.h @@ -68,9 +68,9 @@ class Array { Variant front() const; Variant back() const; - void sort(); - void sort_custom(Object *p_obj, const StringName &p_function); - void invert(); + Array &sort(); + Array &sort_custom(Object *p_obj, const StringName &p_function); + Array &invert(); int find(const Variant &p_value, int p_from = 0) const; int rfind(const Variant &p_value, int p_from = -1) const; diff --git a/core/class_db.cpp b/core/class_db.cpp index f5ddd9c76166..12310f615106 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -205,6 +205,7 @@ ClassDB::ClassInfo::ClassInfo() { creation_func = NULL; inherits_ptr = NULL; disabled = false; + exposed = false; } ClassDB::ClassInfo::~ClassInfo() { } @@ -1284,6 +1285,15 @@ bool ClassDB::is_class_enabled(StringName p_class) { return !ti->disabled; } +bool ClassDB::is_class_exposed(StringName p_class) { + + OBJTYPE_RLOCK; + + ClassInfo *ti = classes.getptr(p_class); + ERR_FAIL_COND_V(!ti, false); + return ti->exposed; +} + StringName ClassDB::get_category(const StringName &p_node) { ERR_FAIL_COND_V(!classes.has(p_node), StringName()); diff --git a/core/class_db.h b/core/class_db.h index f6b97748b045..5910a2ce01b5 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -127,6 +127,7 @@ class ClassDB { StringName inherits; StringName name; bool disabled; + bool exposed; Object *(*creation_func)(); ClassInfo(); ~ClassInfo(); @@ -168,6 +169,7 @@ class ClassDB { ClassInfo *t = classes.getptr(T::get_class_static()); ERR_FAIL_COND(!t); t->creation_func = &creator; + t->exposed = true; T::register_custom_data_to_otdb(); } @@ -176,6 +178,9 @@ class ClassDB { GLOBAL_LOCK_FUNCTION; T::initialize_class(); + ClassInfo *t = classes.getptr(T::get_class_static()); + ERR_FAIL_COND(!t); + t->exposed = true; //nothing } @@ -193,6 +198,7 @@ class ClassDB { ClassInfo *t = classes.getptr(T::get_class_static()); ERR_FAIL_COND(!t); t->creation_func = &_create_ptr_func; + t->exposed = true; T::register_custom_data_to_otdb(); } @@ -347,6 +353,8 @@ class ClassDB { static void set_class_enabled(StringName p_class, bool p_enable); static bool is_class_enabled(StringName p_class); + static bool is_class_exposed(StringName p_class); + static void add_resource_base_extension(const StringName &p_extension, const StringName &p_class); static void get_resource_base_extensions(List *p_extensions); static void get_extensions_for_type(const StringName &p_class, List *p_extensions); diff --git a/core/image.cpp b/core/image.cpp index c7f21d559919..943cbaf51d45 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -2474,6 +2474,7 @@ void Image::fix_alpha_edges() { if (rp[3] < alpha_threshold) continue; + closest_dist = dist; closest_color[0] = rp[0]; closest_color[1] = rp[1]; closest_color[2] = rp[2]; diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index c93e12f7dac1..e5da307153d0 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -62,12 +62,12 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vectorget_32(); - print_line("MAGIC: " + itos(magic)); ERR_FAIL_COND_V(magic != COMP_MAGIC, ERR_FILE_UNRECOGNIZED); + mode = Mode(p_base->get_32()); ERR_FAIL_INDEX_V(mode, MODE_MAX, ERR_FILE_CORRUPT); ERR_FAIL_COND_V(mode == 0, ERR_FILE_CORRUPT); - print_line("MODE: " + itos(mode)); + unsigned char md5d[16]; p_base->get_buffer(md5d, 16); length = p_base->get_64(); diff --git a/core/io/logger.cpp b/core/io/logger.cpp index b94007d31654..ad6371f1e130 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -33,6 +33,17 @@ #include "os/os.h" #include "print_string.h" +// va_copy was defined in the C99, but not in C++ standards before C++11. +// When you compile C++ without --std=c++ option, compilers still define +// va_copy, otherwise you have to use the internal version (__va_copy). +#if !defined(va_copy) +#if defined(__GNUC__) +#define va_copy(d, s) __va_copy(d, s) +#else +#define va_copy(d, s) ((d) = (s)) +#endif +#endif + bool Logger::should_log(bool p_err) { return (!p_err || _print_error_enabled) && (p_err || _print_line_enabled); } diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 0834d6c3214b..d388a622dead 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -1140,8 +1140,9 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo if (buf) { encode_uint32(0, buf); buf += 4; - r_len += 4; } + r_len += 4; + } else { _encode_string(obj->get_class(), buf, r_len); diff --git a/core/os/input.cpp b/core/os/input.cpp index a4b82299a77b..848b003d5e5f 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -58,6 +58,7 @@ void Input::_bind_methods() { ClassDB::bind_method(D_METHOD("is_action_just_released", "action"), &Input::is_action_just_released); ClassDB::bind_method(D_METHOD("add_joy_mapping", "mapping", "update_existing"), &Input::add_joy_mapping, DEFVAL(false)); ClassDB::bind_method(D_METHOD("remove_joy_mapping", "guid"), &Input::remove_joy_mapping); + ClassDB::bind_method(D_METHOD("joy_connection_changed", "device", "connected", "name", "guid"), &Input::joy_connection_changed); ClassDB::bind_method(D_METHOD("is_joy_known", "device"), &Input::is_joy_known); ClassDB::bind_method(D_METHOD("get_joy_axis", "device", "axis"), &Input::get_joy_axis); ClassDB::bind_method(D_METHOD("get_joy_name", "device"), &Input::get_joy_name); diff --git a/core/os/os.h b/core/os/os.h index 6fcfd713322b..48effe99da09 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -204,7 +204,7 @@ class OS { virtual String get_installed_templates_path() const { return ""; } virtual String get_executable_path() const; - virtual Error execute(const String &p_path, const List &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL) = 0; + virtual Error execute(const String &p_path, const List &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false) = 0; virtual Error kill(const ProcessID &p_pid) = 0; virtual int get_process_id() const; diff --git a/core/project_settings.cpp b/core/project_settings.cpp index ff2be87b0711..c4d1b199a0ff 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -261,7 +261,7 @@ bool ProjectSettings::_load_resource_pack(const String &p_pack) { return true; } -Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) { +Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bool p_upwards) { //If looking for files in network, just use network! @@ -270,11 +270,6 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) { if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) { _load_settings("res://override.cfg"); -#ifdef DEBUG_ENABLED - } else { - // when debug version of godot is used, provide some feedback to the developer - print_line("Couldn't open project over network"); -#endif } return OK; @@ -292,12 +287,6 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) { if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) { //load override from location of the main pack _load_settings(p_main_pack.get_base_dir().plus_file("override.cfg")); -#ifdef DEBUG_ENABLED - // when debug version of godot is used, provide some feedback to the developer - print_line("Successfully loaded " + p_main_pack + "/project.godot or project.binary"); - } else { - print_line("Couldn't load/find " + p_main_pack + "/project.godot or project.binary"); -#endif } return OK; @@ -315,18 +304,9 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) { if (_load_resource_pack(datapack_name)) { found = true; } else { -#ifdef DEBUG_ENABLED - // when debug version of godot is used, provide some feedback to the developer - print_line("Couldn't open " + datapack_name); -#endif datapack_name = filebase_name + ".pck"; if (_load_resource_pack(datapack_name)) { found = true; -#ifdef DEBUG_ENABLED - } else { - // when debug version of godot is used, provide some feedback to the developer - print_line("Couldn't open " + datapack_name); -#endif } } @@ -335,13 +315,6 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) { if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) { // load override from location of executable _load_settings(exec_path.get_base_dir().plus_file("override.cfg")); - -#ifdef DEBUG_ENABLED - // when debug version of godot is used, provide some feedback to the developer - print_line("Successfully loaded " + datapack_name + "/project.godot or project.binary"); - } else { - print_line("Couldn't load/find " + datapack_name + "/project.godot or project.binary"); -#endif } return OK; @@ -362,12 +335,6 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) { if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) { _load_settings("res://override.cfg"); -#ifdef DEBUG_ENABLED - // when debug version of godot is used, provide some feedback to the developer - print_line("Successfully loaded " + resource_path + "/project.godot or project.binary"); - } else { - print_line("Couldn't load/find " + resource_path + "/project.godot or project.binary"); -#endif } return OK; @@ -393,18 +360,16 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) { candidate = current_dir; found = true; break; -#ifdef DEBUG_ENABLED - // when debug version of godot is used, provide some feedback to the developer - print_line("Successfully loaded " + current_dir + "/project.godot or project.binary"); - } else { - print_line("Couldn't load/find " + current_dir + "/project.godot or project.binary"); -#endif } - d->change_dir(".."); - if (d->get_current_dir() == current_dir) - break; //not doing anything useful - current_dir = d->get_current_dir(); + if (p_upwards) { + d->change_dir(".."); + if (d->get_current_dir() == current_dir) + break; //not doing anything useful + current_dir = d->get_current_dir(); + } else { + break; + } } resource_path = candidate; @@ -667,8 +632,8 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Mapstore_line("; Engine configuration file."); file->store_line("; It's best edited using the editor UI and not directly,"); file->store_line("; since the parameters that go here are not all obvious."); - file->store_line("; "); - file->store_line("; Format: "); + file->store_line(";"); + file->store_line("; Format:"); file->store_line("; [section] ; section goes between []"); file->store_line("; param=value ; assign values to parameters"); file->store_line(""); diff --git a/core/project_settings.h b/core/project_settings.h index ea6034dc84ee..f75cad815f61 100644 --- a/core/project_settings.h +++ b/core/project_settings.h @@ -139,7 +139,7 @@ class ProjectSettings : public Object { void set_order(const String &p_name, int p_order); void set_builtin_order(const String &p_name); - Error setup(const String &p_path, const String &p_main_pack); + Error setup(const String &p_path, const String &p_main_pack, bool p_upwards = false); Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector &p_custom_features = Vector(), bool p_merge_with_current = true); Error save(); diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 0e34a3eea56c..c6d7cd44e8d9 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -40,6 +40,7 @@ #include "io/config_file.h" #include "io/http_client.h" #include "io/marshalls.h" +#include "io/networked_multiplayer_peer.h" #include "io/packet_peer.h" #include "io/packet_peer_udp.h" #include "io/pck_packer.h" @@ -109,6 +110,8 @@ void register_core_types() { ClassDB::register_class(); + ClassDB::register_virtual_class