diff --git a/.gitignore b/.gitignore index 9cf3ab38b0f..055418a0553 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ core/version.h core/method_bind.inc core/global_defaults.cpp tools/editor/register_exporters.cpp +tools/editor/doc_data_compressed.h -fpic # Android specific diff --git a/SConstruct b/SConstruct index a9739ca604c..129b32f5f93 100644 --- a/SConstruct +++ b/SConstruct @@ -11,7 +11,7 @@ import multiprocessing # Enable aggresive compile mode if building on a multi core box # only is we have not set the number of jobs already or we do # not want it -if ARGUMENTS.get('spawn_jobs', 'yes') == 'yes' and \ +if ARGUMENTS.get('spawn_jobs', 'no') == 'yes' and \ int(GetOption('num_jobs')) <= 1: NUM_JOBS = multiprocessing.cpu_count() if NUM_JOBS > 1: diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 73f6f753b95..e3360a23d20 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -199,6 +199,14 @@ int _OS::get_iterations_per_second() const { } +void _OS::set_target_fps(int p_fps) { + OS::get_singleton()->set_target_fps(p_fps); +} + +float _OS::get_target_fps() const { + return OS::get_singleton()->get_target_fps(); +} + void _OS::set_low_processor_usage_mode(bool p_enabled) { OS::get_singleton()->set_low_processor_usage_mode(p_enabled); @@ -238,6 +246,12 @@ Error _OS::kill(int p_pid) { return OS::get_singleton()->kill(p_pid); } +int _OS::get_process_ID() const { + + return OS::get_singleton()->get_process_ID(); +}; + + bool _OS::has_environment(const String& p_var) const { return OS::get_singleton()->has_environment(p_var); @@ -387,6 +401,12 @@ uint32_t _OS::get_ticks_msec() const { return OS::get_singleton()->get_ticks_msec(); } + +bool _OS::can_use_threads() const { + + return OS::get_singleton()->can_use_threads(); +} + bool _OS::can_draw() const { return OS::get_singleton()->can_draw(); @@ -488,6 +508,27 @@ float _OS::get_frames_per_second() const { return OS::get_singleton()->get_frames_per_second(); } +Error _OS::native_video_play(String p_path) { + + return OS::get_singleton()->native_video_play(p_path); +}; + +bool _OS::native_video_is_playing() { + + return OS::get_singleton()->native_video_is_playing(); +}; + +void _OS::native_video_pause() { + + OS::get_singleton()->native_video_pause(); +}; + +void _OS::native_video_stop() { + + OS::get_singleton()->native_video_stop(); +}; + + String _OS::get_custom_level() const { return OS::get_singleton()->get_custom_level(); @@ -496,7 +537,7 @@ _OS *_OS::singleton=NULL; void _OS::_bind_methods() { - ObjectTypeDB::bind_method(_MD("get_mouse_pos"),&_OS::get_mouse_pos); + //ObjectTypeDB::bind_method(_MD("get_mouse_pos"),&_OS::get_mouse_pos); //ObjectTypeDB::bind_method(_MD("is_mouse_grab_enabled"),&_OS::is_mouse_grab_enabled); ObjectTypeDB::bind_method(_MD("set_clipboard","clipboard"),&_OS::set_clipboard); @@ -510,6 +551,8 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second); ObjectTypeDB::bind_method(_MD("get_iterations_per_second"),&_OS::get_iterations_per_second); + ObjectTypeDB::bind_method(_MD("set_target_fps","target_fps"),&_OS::set_target_fps); + ObjectTypeDB::bind_method(_MD("get_target_fps"),&_OS::get_target_fps); ObjectTypeDB::bind_method(_MD("has_touchscreen_ui_hint"),&_OS::has_touchscreen_ui_hint); @@ -524,6 +567,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("execute","path","arguments","blocking"),&_OS::execute); ObjectTypeDB::bind_method(_MD("kill","pid"),&_OS::kill); ObjectTypeDB::bind_method(_MD("shell_open","uri"),&_OS::shell_open); + ObjectTypeDB::bind_method(_MD("get_process_ID"),&_OS::get_process_ID); ObjectTypeDB::bind_method(_MD("get_environment","environment"),&_OS::get_environment); ObjectTypeDB::bind_method(_MD("has_environment","environment"),&_OS::has_environment); @@ -550,7 +594,9 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_frames_drawn"),&_OS::get_frames_drawn); ObjectTypeDB::bind_method(_MD("is_stdout_verbose"),&_OS::is_stdout_verbose); - ObjectTypeDB::bind_method(_MD("get_mouse_button_state"),&_OS::get_mouse_button_state); + ObjectTypeDB::bind_method(_MD("can_use_threads"),&_OS::can_use_threads); + + //ObjectTypeDB::bind_method(_MD("get_mouse_button_state"),&_OS::get_mouse_button_state); ObjectTypeDB::bind_method(_MD("dump_memory_to_file","file"),&_OS::dump_memory_to_file); ObjectTypeDB::bind_method(_MD("dump_resources_to_file","file"),&_OS::dump_resources_to_file); @@ -568,6 +614,12 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("print_all_textures_by_size"),&_OS::print_all_textures_by_size); + ObjectTypeDB::bind_method(_MD("native_video_play"),&_OS::native_video_play); + ObjectTypeDB::bind_method(_MD("native_video_is_playing"),&_OS::native_video_is_playing); + ObjectTypeDB::bind_method(_MD("native_video_stop"),&_OS::native_video_stop); + ObjectTypeDB::bind_method(_MD("native_video_pause"),&_OS::native_video_pause); + + BIND_CONSTANT( DAY_SUNDAY ); BIND_CONSTANT( DAY_MONDAY ); BIND_CONSTANT( DAY_TUESDAY ); @@ -983,8 +1035,22 @@ void _File::store_string(const String& p_string){ f->store_string(p_string); } -void _File::store_line(const String& p_string){ +void _File::store_pascal_string(const String& p_string) { + + ERR_FAIL_COND(!f); + + f->store_pascal_string(p_string); +}; + +String _File::get_pascal_string() { + + ERR_FAIL_COND_V(!f, ""); + + return f->get_pascal_string(); +}; + +void _File::store_line(const String& p_string){ ERR_FAIL_COND(!f); f->store_line(p_string); @@ -1083,6 +1149,9 @@ void _File::_bind_methods() { ObjectTypeDB::bind_method(_MD("store_string","string"),&_File::store_string); ObjectTypeDB::bind_method(_MD("store_var","value"),&_File::store_var); + ObjectTypeDB::bind_method(_MD("store_pascal_string","string"),&_File::store_pascal_string); + ObjectTypeDB::bind_method(_MD("get_pascal_string"),&_File::get_pascal_string); + ObjectTypeDB::bind_method(_MD("file_exists","path"),&_File::file_exists); BIND_CONSTANT( READ ); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 9545fc65fb8..0084726547d 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -98,9 +98,17 @@ public: bool is_video_mode_resizable(int p_screen=0) const; Array get_fullscreen_mode_list(int p_screen=0) const; + Error native_video_play(String p_path); + bool native_video_is_playing(); + void native_video_pause(); + void native_video_stop(); + void set_iterations_per_second(int p_ips); int get_iterations_per_second() const; + void set_target_fps(int p_fps); + float get_target_fps() const; + void set_low_processor_usage_mode(bool p_enabled); bool is_in_low_processor_usage_mode() const; @@ -109,6 +117,8 @@ public: Error kill(int p_pid); Error shell_open(String p_uri); + int get_process_ID() const; + bool has_environment(const String& p_var) const; String get_environment(const String& p_var) const; @@ -166,6 +176,7 @@ public: void delay_msec(uint32_t p_msec) const; uint32_t get_ticks_msec() const; + bool can_use_threads() const; bool can_draw() const; @@ -280,6 +291,9 @@ public: void store_string(const String& p_string); void store_line(const String& p_string); + virtual void store_pascal_string(const String& p_string); + virtual String get_pascal_string(); + Vector get_csv_line() const; diff --git a/core/func_ref.cpp b/core/func_ref.cpp new file mode 100644 index 00000000000..0e43112de88 --- /dev/null +++ b/core/func_ref.cpp @@ -0,0 +1,55 @@ +#include "func_ref.h" + +Variant FuncRef::call_func(const Variant** p_args, int p_argcount, Variant::CallError& r_error) { + + if (id==0) { + r_error.error=Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL; + return Variant(); + } + Object* obj = ObjectDB::get_instance(id); + + if (!obj) { + r_error.error=Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL; + return Variant(); + } + + return obj->call(function,p_args,p_argcount,r_error); + +} + +void FuncRef::set_instance(Object *p_obj){ + + ERR_FAIL_NULL(p_obj); + id=p_obj->get_instance_ID(); +} +void FuncRef::set_function(const StringName& p_func){ + + function=p_func; +} + +void FuncRef::_bind_methods() { + + { + MethodInfo mi; + mi.name="call"; + mi.arguments.push_back( PropertyInfo( Variant::STRING, "method")); + Vector defargs; + for(int i=0;i<10;i++) { + mi.arguments.push_back( PropertyInfo( Variant::NIL, "arg"+itos(i))); + defargs.push_back(Variant()); + } + ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"call_func",&FuncRef::call_func,mi,defargs); + + } + + ObjectTypeDB::bind_method(_MD("set_instance","instance"),&FuncRef::set_instance); + ObjectTypeDB::bind_method(_MD("set_function","name"),&FuncRef::set_function); + +} + + +FuncRef::FuncRef(){ + + id=0; +} + diff --git a/core/func_ref.h b/core/func_ref.h new file mode 100644 index 00000000000..28d0e737be5 --- /dev/null +++ b/core/func_ref.h @@ -0,0 +1,23 @@ +#ifndef FUNC_REF_H +#define FUNC_REF_H + +#include "reference.h" + +class FuncRef : public Reference{ + + OBJ_TYPE(FuncRef,Reference); + ObjectID id; + StringName function; + +protected: + + static void _bind_methods(); +public: + + Variant call_func(const Variant** p_args, int p_argcount, Variant::CallError& r_error); + void set_instance(Object *p_obj); + void set_function(const StringName& p_func); + FuncRef(); +}; + +#endif // FUNC_REF_H diff --git a/core/globals.cpp b/core/globals.cpp index 997e2a2d85c..7df76808278 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -166,10 +166,9 @@ bool Globals::_get(const StringName& p_name,Variant &r_ret) const { _THREAD_SAFE_METHOD_ - const VariantContainer *v=props.getptr(p_name); - if (!v) + if (!props.has(p_name)) return false; - r_ret=v->variant; + r_ret=props[p_name].variant; return true; } @@ -188,18 +187,17 @@ void Globals::_get_property_list(List *p_list) const { _THREAD_SAFE_METHOD_ - const String *k=NULL; Set<_VCSort> vclist; - while ((k=props.next(k))) { + for(Map::Element *E=props.front();E;E=E->next()) { - const VariantContainer *v=props.getptr(*k); + const VariantContainer *v=&E->get(); if (v->hide_from_editor) continue; _VCSort vc; - vc.name=*k; + vc.name=E->key(); vc.order=v->order; vc.type=v->variant.get_type(); if (vc.name.begins_with("input/") || vc.name.begins_with("import/") || vc.name.begins_with("export/") || vc.name.begins_with("/remap") || vc.name.begins_with("/locale") || vc.name.begins_with("/autoload")) @@ -1138,24 +1136,23 @@ Error Globals::save_custom(const String& p_path,const CustomMap& p_custom,const ERR_FAIL_COND_V(p_path=="",ERR_INVALID_PARAMETER); - const String *k=NULL; Set<_VCSort> vclist; - while ((k=props.next(k))) { + for(Map::Element *G=props.front();G;G=G->next()) { - const VariantContainer *v=props.getptr(*k); + const VariantContainer *v=&G->get(); if (v->hide_from_editor) continue; - if (p_custom.has(*k)) + if (p_custom.has(G->key())) continue; bool discard=false; for(const Set::Element *E=p_ignore_masks.front();E;E=E->next()) { - if ( (*k).match(E->get())) { + if ( String(G->key()).match(E->get())) { discard=true; break; } @@ -1165,7 +1162,7 @@ Error Globals::save_custom(const String& p_path,const CustomMap& p_custom,const continue; _VCSort vc; - vc.name=*k; + vc.name=G->key();//*k; vc.order=v->order; vc.type=v->variant.get_type(); vc.flags=PROPERTY_USAGE_CHECKABLE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_STORAGE; diff --git a/core/globals.h b/core/globals.h index 08d9f08088b..b8dc3f93675 100644 --- a/core/globals.h +++ b/core/globals.h @@ -65,9 +65,9 @@ protected: }; int last_order; - HashMap props; + Map props; String resource_path; - HashMap custom_prop_info; + Map custom_prop_info; bool disable_platform_override; bool using_datapack; diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index edecbb6a3e0..45e6990ad2a 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -172,7 +172,6 @@ bool PackedSourcePCK::try_open_pack(const String& p_path) { uint64_t size = f->get_64(); uint8_t md5[16]; f->get_buffer(md5,16); - PackedData::get_singleton()->add_path(p_path, path, ofs, size, md5,this); }; diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 1b53ee61048..f9da846844d 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -97,8 +97,16 @@ Error HTTPClient::request( Method p_method, const String& p_url, const Vector0; for(int i=0;ilen,ERR_INVALID_DATA); + + if (strlen&0x80000000) { + //new format + ERR_FAIL_COND_V(len<12,ERR_INVALID_DATA); + Vector names; + Vector subnames; + bool absolute; + StringName prop; + + int i=0; + uint32_t namecount=strlen&=0x7FFFFFFF; + uint32_t subnamecount = decode_uint32(buf+4); + uint32_t flags = decode_uint32(buf+8); + + len-=12; + buf+=12; + + int total=namecount+subnamecount; + if (flags&2) + total++; + + if (r_len) + (*r_len)+=12; - String str; - str.parse_utf8((const char*)buf,strlen); + for(int i=0;ilen,ERR_INVALID_DATA); + + String str; + str.parse_utf8((const char*)buf,strlen); + + + if (ilen,ERR_INVALID_DATA); + + + String str; + str.parse_utf8((const char*)buf,strlen); + + r_variant=NodePath(str); + + if (r_len) + (*r_len)+=4+strlen; + } } break; /*case Variant::RESOURCE: { @@ -713,7 +781,59 @@ Error encode_variant(const Variant& p_variant, uint8_t *r_buffer, int &r_len) { r_len+=4; } break; - case Variant::NODE_PATH: + case Variant::NODE_PATH: { + + NodePath np=p_variant; + if (buf) { + encode_uint32(uint32_t(np.get_name_count())|0x80000000,buf); //for compatibility with the old format + encode_uint32(np.get_subname_count(),buf+4); + uint32_t flags=0; + if (np.is_absolute()) + flags|=1; + if (np.get_property()!=StringName()) + flags|=2; + + encode_uint32(flags,buf+8); + + buf+=12; + } + + r_len+=12; + + int total = np.get_name_count()+np.get_subname_count(); + if (np.get_property()!=StringName()) + total++; + + for(int i=0;ipush_back(external_resources[i].path); + String dep=external_resources[i].path; + if (dep.ends_with("*")) { + dep=ResourceLoader::guess_full_filename(dep,external_resources[i].type); + } + + p_dependencies->push_back(dep); } } @@ -892,6 +897,19 @@ void ResourceInteractiveLoaderBinary::open(FileAccess *p_f) { } + //see if the exporter has different set of external resources for more efficient loading + String preload_depts = "deps/"+res_path.md5_text(); + if (Globals::get_singleton()->has(preload_depts)) { + external_resources.clear(); + //ignore external resources and use these + NodePath depts=Globals::get_singleton()->get(preload_depts); + external_resources.resize(depts.get_name_count()); + for(int i=0;iget_32(); @@ -931,6 +949,7 @@ String ResourceInteractiveLoaderBinary::recognize(FileAccess *p_f) { } else if (header[0]!='R' || header[1]!='S' || header[2]!='R' || header[3]!='C') { //not normal + error=ERR_FILE_UNRECOGNIZED; return ""; } @@ -1412,8 +1431,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property, f->store_32(OBJECT_EXTERNAL_RESOURCE); save_unicode_string(res->get_save_type()); String path=relative_paths?local_path.path_to_file(res->get_path()):res->get_path(); - if (no_extensions) - path=path.basename()+".*"; save_unicode_string(path); } else { @@ -1439,7 +1456,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property, f->store_32(VARIANT_DICTIONARY); Dictionary d = p_property; - f->store_32(uint32_t(d.size())|(d.is_shared()?0x80000000:0)); + f->store_32(uint32_t(d.size())|(d.is_shared()?0x80000000:0)); List keys; d.get_key_list(&keys); @@ -1734,7 +1751,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_ skip_editor=p_flags&ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES; bundle_resources=p_flags&ResourceSaver::FLAG_BUNDLE_RESOURCES; big_endian=p_flags&ResourceSaver::FLAG_SAVE_BIG_ENDIAN; - no_extensions=p_flags&ResourceSaver::FLAG_NO_EXTENSION; + local_path=p_path.get_base_dir(); //bin_meta_idx = get_string_index("__bin_meta__"); //is often used, so create @@ -1816,8 +1833,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_ save_unicode_string(E->get()->get_save_type()); String path = E->get()->get_path(); - if (no_extensions) - path=path.basename()+".*"; save_unicode_string(path); } // save internal resource table @@ -1861,6 +1876,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_ } f->seek_end(); + print_line("SAVING: "+p_path); if (p_resource->get_import_metadata().is_valid()) { uint64_t md_pos = f->get_pos(); Ref imd=p_resource->get_import_metadata(); @@ -1869,6 +1885,8 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_ for(int i=0;iget_source_count();i++) { save_unicode_string(imd->get_source_path(i)); save_unicode_string(imd->get_source_md5(i)); + print_line("SAVE PATH: "+imd->get_source_path(i)); + print_line("SAVE MD5: "+imd->get_source_md5(i)); } List options; imd->get_options(&options); diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 006148f5a8d..bd33fee82ce 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -120,7 +120,7 @@ class ResourceFormatSaverBinaryInstance { String local_path; - bool no_extensions; + bool relative_paths; bool bundle_resources; bool skip_editor; diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index fc5aecfd990..f3c0f1cb8b1 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -1357,6 +1357,31 @@ Error ResourceInteractiveLoaderXML::poll() { if (error!=OK) return error; + if (ext_resources.size()) { + + error=ERR_FILE_CORRUPT; + String path=ext_resources.front()->get(); + + RES res = ResourceLoader::load(path); + + if (res.is_null()) { + + if (ResourceLoader::get_abort_on_missing_resources()) { + ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": editor exported unexisting resource at: "+path); + ERR_FAIL_V(error); + } else { + ResourceLoader::notify_load_error("Resource Not Found: "+path); + } + } else { + + resource_cache.push_back(res); + } + + error=OK; + ext_resources.pop_front(); + resource_current++; + return error; + } bool exit; Tag *tag = parse_tag(&exit); @@ -1528,7 +1553,7 @@ int ResourceInteractiveLoaderXML::get_stage() const { } int ResourceInteractiveLoaderXML::get_stage_count() const { - return resources_total; + return resources_total+ext_resources.size(); } ResourceInteractiveLoaderXML::~ResourceInteractiveLoaderXML() { @@ -1573,6 +1598,12 @@ void ResourceInteractiveLoaderXML::get_dependencies(FileAccess *f,List * path=Globals::get_singleton()->localize_path(local_path.get_base_dir()+"/"+path); } + if (path.ends_with("*")) { + ERR_FAIL_COND(!tag->args.has("type")); + String type = tag->args["type"]; + path = ResourceLoader::guess_full_filename(path,type); + } + p_dependencies->push_back(path); Error err = close_tag("ext_resource"); @@ -1642,6 +1673,19 @@ void ResourceInteractiveLoaderXML::open(FileAccess *p_f) { } + String preload_depts = "deps/"+local_path.md5_text(); + if (Globals::get_singleton()->has(preload_depts)) { + ext_resources.clear(); + //ignore external resources and use these + NodePath depts=Globals::get_singleton()->get(preload_depts); + + for(int i=0;iget_path().length() && res->get_path().find("::")==-1) { //external resource String path=relative_paths?local_path.path_to_file(res->get_path()):res->get_path(); - if (no_extension) - path=path.basename()+".*"; escape(path); params+=" path=\""+path+"\""; } else { @@ -2458,7 +2500,6 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res relative_paths=p_flags&ResourceSaver::FLAG_RELATIVE_PATHS; skip_editor=p_flags&ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES; bundle_resources=p_flags&ResourceSaver::FLAG_BUNDLE_RESOURCES; - no_extension=p_flags&ResourceSaver::FLAG_NO_EXTENSION; depth=0; // save resources @@ -2475,8 +2516,6 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res write_tabs(); String p = E->get()->get_path(); - if (no_extension) - p=p.basename()+".*"; enter_tag("ext_resource","path=\""+p+"\" type=\""+E->get()->get_save_type()+"\""); //bundled exit_tag("ext_resource"); //bundled diff --git a/core/io/resource_format_xml.h b/core/io/resource_format_xml.h index 05313ffbd7c..7874431a387 100644 --- a/core/io/resource_format_xml.h +++ b/core/io/resource_format_xml.h @@ -50,6 +50,10 @@ class ResourceInteractiveLoaderXML : public ResourceInteractiveLoader { _FORCE_INLINE_ Error _parse_array_element(Vector &buff,bool p_number_only,FileAccess *f,bool *end); + + + List ext_resources; + int resources_total; int resource_current; String resource_type; @@ -113,7 +117,6 @@ class ResourceFormatSaverXMLInstance { - bool no_extension; bool relative_paths; bool bundle_resources; bool skip_editor; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 5ee48bae252..d2610d5d4f0 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -166,7 +166,7 @@ RES ResourceLoader::load(const String &p_path,const String& p_type_hint,bool p_n String remapped_path = PathRemap::get_singleton()->get_remap(local_path); if (OS::get_singleton()->is_stdout_verbose()) - print_line("load resource: "); + print_line("load resource: "+remapped_path); String extension=remapped_path.extension(); bool found=false; @@ -233,6 +233,10 @@ Ref ResourceLoader::load_import_metadata(const String &p String ResourceLoader::find_complete_path(const String& p_path,const String& p_type) { + //this is an old vestige when the engine saved files without extension. + //remains here for compatibility with old projects and only because it + //can be sometimes nice to open files using .* from a script and have it guess + //the right extension. String local_path = p_path; if (local_path.ends_with("*")) { @@ -353,6 +357,13 @@ void ResourceLoader::get_dependencies(const String& p_path,List *p_depen } } +String ResourceLoader::guess_full_filename(const String &p_path,const String& p_type) { + + String local_path = Globals::get_singleton()->localize_path(p_path); + + return find_complete_path(local_path,p_type); + +} String ResourceLoader::get_resource_type(const String &p_path) { diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 70b1a795820..ab231587853 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -102,6 +102,7 @@ public: static String get_resource_type(const String &p_path); static void get_dependencies(const String& p_path,List *p_dependencies); + static String guess_full_filename(const String &p_path,const String& p_type); static void set_timestamp_on_load(bool p_timestamp) { timestamp_on_load=p_timestamp; } diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h index 4b794247e0c..fd4575c8726 100644 --- a/core/io/resource_saver.h +++ b/core/io/resource_saver.h @@ -74,9 +74,6 @@ public: FLAG_OMIT_EDITOR_PROPERTIES=8, FLAG_SAVE_BIG_ENDIAN=16, FLAG_COMPRESS=32, - FLAG_NO_EXTENSION=64, - - }; diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp index 5d3887d72c2..92236a374f9 100644 --- a/core/math/math_funcs.cpp +++ b/core/math/math_funcs.cpp @@ -220,9 +220,16 @@ int Math::decimals(double p_step) { double Math::ease(double p_x, double p_c) { + if (p_x<0) + p_x=0; + else if (p_x>1.0) + p_x=1.0; if (p_c>0) { - - return Math::pow(p_x,p_c); + if (p_c<1.0) { + return 1.0-Math::pow(1.0-p_x,1.0/p_c); + } else { + return Math::pow(p_x,p_c); + } } else if (p_c<0) { //inout ease diff --git a/core/message_queue.cpp b/core/message_queue.cpp index a9c49fbef2f..dbf6217dc2d 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -378,11 +378,12 @@ void MessageQueue::flush() { } } - message->~Message(); read_pos+=sizeof(Message); if (message->type!=TYPE_NOTIFICATION) read_pos+=sizeof(Variant)*message->args; + message->~Message(); + _THREAD_SAFE_UNLOCK_ } diff --git a/core/object.cpp b/core/object.cpp index 692010b1b70..b40f4ec1512 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -33,6 +33,30 @@ #include "message_queue.h" #include "core_string_names.h" #include "translation.h" + +#ifdef DEBUG_ENABLED + +struct _ObjectDebugLock { + + Object *obj; + + _ObjectDebugLock(Object *p_obj) { + obj=p_obj; + obj->_lock_index.ref(); + } + ~_ObjectDebugLock() { + obj->_lock_index.unref(); + } +}; + +#define OBJ_DEBUG_LOCK _ObjectDebugLock _debug_lock(this); + +#else + +#define OBJ_DEBUG_LOCK + +#endif + Array convert_property_list(const List * p_list) { Array va; @@ -562,13 +586,22 @@ void Object::call_multilevel(const StringName& p_method,const Variant** p_args,i ERR_FAIL(); return; } + + + if (_lock_index.get()>1) { + ERR_EXPLAIN("Object is locked and can't be freed."); + ERR_FAIL(); + return; + } #endif + //must be here, must be before everything, memdelete(this); return; } //Variant ret; + OBJ_DEBUG_LOCK Variant::CallError error; @@ -594,6 +627,7 @@ void Object::call_multilevel_reversed(const StringName& p_method,const Variant** MethodBind *method=ObjectTypeDB::get_method(get_type_name(),p_method); Variant::CallError error; + OBJ_DEBUG_LOCK if (method) { @@ -813,6 +847,15 @@ Variant Object::call(const StringName& p_method,const Variant** p_args,int p_arg ERR_EXPLAIN("Can't 'free' a reference."); ERR_FAIL_V(Variant()); } + + if (_lock_index.get()>1) { + r_error.argument=0; + r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD; + ERR_EXPLAIN("Object is locked and can't be freed."); + ERR_FAIL_V(Variant()); + + } + #endif //must be here, must be before everything, memdelete(this); @@ -821,7 +864,7 @@ Variant Object::call(const StringName& p_method,const Variant** p_args,int p_arg } Variant ret; - + OBJ_DEBUG_LOCK if (script_instance) { ret = script_instance->call(p_method,p_args,p_argcount,r_error); //force jumptable @@ -902,7 +945,7 @@ void Object::set_script(const RefPtr& p_script) { Ref