From 31ce3c5fd0300aac1e86bced1efc5f9ec94bdb6b Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 13 Mar 2014 22:57:24 -0300 Subject: [PATCH 01/35] -fix bug in cache for atlas import/export -fix some menus -fixed bug in out transition curves -detect and remove file:/// in collada -remove multiscript for now -remove dependencies on mouse in OS, moved to Input -avoid fscache from screwing up (fix might make it slower, but it works) -funcref was missing, it's there now --- core/bind/core_bind.cpp | 58 +- core/bind/core_bind.h | 9 + core/func_ref.cpp | 55 + core/func_ref.h | 23 + core/globals.cpp | 23 +- core/globals.h | 4 +- core/io/file_access_pack.cpp | 1 - core/io/marshalls.cpp | 148 +- core/io/resource_format_binary.cpp | 33 +- core/io/resource_format_binary.h | 2 +- core/io/resource_format_xml.cpp | 51 +- core/io/resource_format_xml.h | 5 +- core/io/resource_loader.cpp | 13 +- core/io/resource_loader.h | 1 + core/io/resource_saver.h | 3 - core/math/math_funcs.cpp | 11 +- core/os/file_access.cpp | 24 +- core/os/file_access.h | 3 + core/os/input.cpp | 7 + core/os/input.h | 2 + core/os/mutex.h | 2 +- core/os/os.cpp | 11 +- core/os/os.h | 4 +- core/register_core_types.cpp | 2 + core/ustring.cpp | 10 + core/ustring.h | 3 +- drivers/mpc/audio_stream_mpc.cpp | 2 +- drivers/openssl/stream_peer_ssl.cpp | 111 ++ drivers/openssl/stream_peer_ssl.h | 26 + drivers/vorbis/audio_stream_ogg_vorbis.cpp | 10 +- modules/gdscript/gd_functions.cpp | 41 +- modules/gdscript/gd_functions.h | 1 + modules/multiscript/SCsub | 7 - modules/multiscript/config.py | 11 - modules/multiscript/multi_script.cpp | 498 ------ modules/multiscript/multi_script.h | 158 -- modules/multiscript/register_types.cpp | 32 - modules/multiscript/register_types.h | 30 - platform/android/AndroidManifest.xml.template | 2 +- platform/android/SCsub | 4 +- ...er_android.cpp => audio_driver_opensl.cpp} | 77 +- ...driver_android.h => audio_driver_opensl.h} | 21 +- platform/android/detect.py | 11 +- platform/android/java/ant.properties | 8 +- .../java/src/com/android/godot/Godot.java | 44 +- .../java/src/com/android/godot/GodotIO.java | 42 +- .../java/src/com/android/godot/GodotLib.java | 6 +- platform/android/java_glue.cpp | 43 +- .../libs/apk_expansion/AndroidManifest.xml | 9 + platform/android/libs/apk_expansion/build.xml | 92 ++ .../libs/apk_expansion/proguard-project.txt | 20 + .../libs/apk_expansion/project.properties | 13 + .../notify_panel_notification_icon_bg.png | Bin 0 -> 1027 bytes .../notify_panel_notification_icon_bg.png | Bin 0 -> 1125 bytes .../status_bar_ongoing_event_progress_bar.xml | 104 ++ .../apk_expansion/res/values-v11/styles.xml | 6 + .../apk_expansion/res/values-v9/styles.xml | 5 + .../libs/apk_expansion/res/values/strings.xml | 41 + .../libs/apk_expansion/res/values/styles.xml | 25 + .../expansion/downloader/Constants.java | 236 +++ .../downloader/DownloadProgressInfo.java | 80 + .../DownloaderClientMarshaller.java | 277 ++++ .../DownloaderServiceMarshaller.java | 181 +++ .../vending/expansion/downloader/Helpers.java | 306 ++++ .../downloader/IDownloaderClient.java | 126 ++ .../downloader/IDownloaderService.java | 83 + .../vending/expansion/downloader/IStub.java | 41 + .../expansion/downloader/SystemFacade.java | 123 ++ .../downloader/impl/AndroidHttpClient.java | 536 +++++++ .../downloader/impl/CustomIntentService.java | 112 ++ .../impl/CustomNotificationFactory.java | 30 + .../downloader/impl/DownloadInfo.java | 92 ++ .../downloader/impl/DownloadNotification.java | 231 +++ .../downloader/impl/DownloadThread.java | 963 ++++++++++++ .../downloader/impl/DownloaderService.java | 1341 +++++++++++++++++ .../downloader/impl/DownloadsDB.java | 510 +++++++ .../downloader/impl/HttpDateTime.java | 200 +++ .../impl/V14CustomNotification.java | 101 ++ .../downloader/impl/V3CustomNotification.java | 116 ++ .../libs/play_licensing/AndroidManifest.xml | 24 + .../aidl/ILicenseResultListener.aidl | 23 + .../aidl/ILicensingService.aidl | 25 + .../android/libs/play_licensing/build.xml | 92 ++ .../libs/play_licensing/proguard-project.txt | 20 + .../libs/play_licensing/project.properties | 12 + .../vending/licensing/AESObfuscator.java | 110 ++ .../vending/licensing/APKExpansionPolicy.java | 397 +++++ .../vending/licensing/DeviceLimiter.java | 47 + .../licensing/ILicenseResultListener.java | 99 ++ .../vending/licensing/ILicensingService.java | 99 ++ .../vending/licensing/LicenseChecker.java | 351 +++++ .../licensing/LicenseCheckerCallback.java | 67 + .../vending/licensing/LicenseValidator.java | 224 +++ .../vending/licensing/NullDeviceLimiter.java | 32 + .../android/vending/licensing/Obfuscator.java | 48 + .../android/vending/licensing/Policy.java | 59 + .../licensing/PreferenceObfuscator.java | 77 + .../vending/licensing/ResponseData.java | 79 + .../licensing/ServerManagedPolicy.java | 276 ++++ .../vending/licensing/StrictPolicy.java | 63 + .../licensing/ValidationException.java | 33 + .../vending/licensing/util/Base64.java | 570 +++++++ .../util/Base64DecoderException.java | 32 + platform/android/os_android.cpp | 29 +- platform/android/os_android.h | 30 +- platform/android/project.properties.template | 2 +- platform/android/sign.sh | 2 +- platform/iphone/detect.py | 3 +- platform/iphone/game_center.h | 1 - platform/iphone/gl_view.h | 4 + platform/iphone/gl_view.mm | 60 + platform/iphone/godot_iphone.cpp | 2 + platform/iphone/os_iphone.cpp | 27 + platform/iphone/os_iphone.h | 5 + platform/iphone/view_controller.h | 2 + platform/iphone/view_controller.mm | 26 + platform/isim/detect.py | 1 + scene/2d/area_2d.cpp | 1 + scene/2d/camera_2d.cpp | 978 ++++++------ scene/2d/physics_body_2d.cpp | 4 +- scene/2d/visibility_notifier_2d.cpp | 4 +- scene/io/resource_format_image.cpp | 12 +- scene/resources/audio_stream_resampled.cpp | 1 - servers/visual/visual_server_wrap_mt.cpp | 11 +- servers/visual/visual_server_wrap_mt.h | 426 +++--- tools/collada/collada.cpp | 3 + tools/editor/editor_file_system.cpp | 4 +- tools/editor/editor_import_export.cpp | 88 +- tools/editor/editor_node.cpp | 6 +- .../io_plugins/editor_font_import_plugin.cpp | 43 + .../editor_texture_import_plugin.cpp | 18 +- tools/editor/project_export.cpp | 4 +- tools/editor/resources_dock.cpp | 2 - tools/editor/scene_tree_editor.cpp | 9 + tools/editor/scene_tree_editor.h | 2 + .../UserInterfaceState.xcuserstate | Bin 11866 -> 13553 bytes 136 files changed, 10784 insertions(+), 1578 deletions(-) create mode 100644 core/func_ref.cpp create mode 100644 core/func_ref.h create mode 100644 drivers/openssl/stream_peer_ssl.cpp create mode 100644 drivers/openssl/stream_peer_ssl.h delete mode 100644 modules/multiscript/SCsub delete mode 100644 modules/multiscript/config.py delete mode 100644 modules/multiscript/multi_script.cpp delete mode 100644 modules/multiscript/multi_script.h delete mode 100644 modules/multiscript/register_types.cpp delete mode 100644 modules/multiscript/register_types.h rename platform/android/{audio_driver_android.cpp => audio_driver_opensl.cpp} (88%) rename platform/android/{audio_driver_android.h => audio_driver_opensl.h} (92%) create mode 100644 platform/android/libs/apk_expansion/AndroidManifest.xml create mode 100644 platform/android/libs/apk_expansion/build.xml create mode 100644 platform/android/libs/apk_expansion/proguard-project.txt create mode 100644 platform/android/libs/apk_expansion/project.properties create mode 100644 platform/android/libs/apk_expansion/res/drawable-hdpi/notify_panel_notification_icon_bg.png create mode 100644 platform/android/libs/apk_expansion/res/drawable-mdpi/notify_panel_notification_icon_bg.png create mode 100644 platform/android/libs/apk_expansion/res/layout/status_bar_ongoing_event_progress_bar.xml create mode 100644 platform/android/libs/apk_expansion/res/values-v11/styles.xml create mode 100644 platform/android/libs/apk_expansion/res/values-v9/styles.xml create mode 100644 platform/android/libs/apk_expansion/res/values/strings.xml create mode 100644 platform/android/libs/apk_expansion/res/values/styles.xml create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/Constants.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/DownloadProgressInfo.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/DownloaderClientMarshaller.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/DownloaderServiceMarshaller.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/Helpers.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/IDownloaderClient.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/IDownloaderService.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/IStub.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/SystemFacade.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/impl/AndroidHttpClient.java create mode 100755 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/impl/CustomIntentService.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/impl/CustomNotificationFactory.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/impl/DownloadInfo.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/impl/DownloadThread.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/impl/DownloaderService.java create mode 100755 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/impl/DownloadsDB.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/impl/HttpDateTime.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/impl/V14CustomNotification.java create mode 100644 platform/android/libs/apk_expansion/src/com/google/android/vending/expansion/downloader/impl/V3CustomNotification.java create mode 100644 platform/android/libs/play_licensing/AndroidManifest.xml create mode 100644 platform/android/libs/play_licensing/aidl/ILicenseResultListener.aidl create mode 100644 platform/android/libs/play_licensing/aidl/ILicensingService.aidl create mode 100644 platform/android/libs/play_licensing/build.xml create mode 100644 platform/android/libs/play_licensing/proguard-project.txt create mode 100644 platform/android/libs/play_licensing/project.properties create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/AESObfuscator.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/APKExpansionPolicy.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/DeviceLimiter.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/ILicenseResultListener.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/ILicensingService.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/LicenseChecker.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/LicenseCheckerCallback.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/LicenseValidator.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/NullDeviceLimiter.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/Obfuscator.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/Policy.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/PreferenceObfuscator.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/ResponseData.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/ServerManagedPolicy.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/StrictPolicy.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/ValidationException.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/util/Base64.java create mode 100644 platform/android/libs/play_licensing/src/com/google/android/vending/licensing/util/Base64DecoderException.java diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 73f6f753b95..28906354abd 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -387,6 +387,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 +494,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 +523,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); @@ -550,7 +577,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 +597,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 +1018,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 +1132,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..0c80fb3fc4a 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -98,6 +98,11 @@ 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; @@ -166,6 +171,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 +286,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/marshalls.cpp b/core/io/marshalls.cpp index f5f9d344399..df951c759ad 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -264,26 +264,94 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * } r_variant=img; - if (r_len) + if (r_len) { + if (datalen%4) + (*r_len)+=4-datalen%4; + (*r_len)+=4*5+datalen; + } } break; case Variant::NODE_PATH: { - ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA); + ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA); uint32_t strlen = decode_uint32(buf); - buf+=4; - len-=4; - ERR_FAIL_COND_V((int)strlen>len,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(); @@ -1412,8 +1430,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 +1455,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 +1750,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 +1832,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 +1875,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 +1884,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/os/file_access.cpp b/core/os/file_access.cpp index 23250a7345c..31e7d19bae6 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -428,8 +428,30 @@ void FileAccess::store_string(const String& p_string) { CharString cs=p_string.utf8(); store_buffer((uint8_t*)&cs[0],cs.length()); - } + +void FileAccess::store_pascal_string(const String& p_string) { + + CharString cs = p_string.utf8(); + store_32(cs.length()); + store_buffer((uint8_t*)&cs[0], cs.length()); +}; + +String FileAccess::get_pascal_string() { + + uint32_t sl = get_32(); + CharString cs; + cs.resize(sl+1); + get_buffer((uint8_t*)cs.ptr(),sl); + cs[sl]=0; + + String ret; + ret.parse_utf8(cs.ptr()); + + return ret; +}; + + void FileAccess::store_line(const String& p_line) { store_string(p_line); diff --git a/core/os/file_access.h b/core/os/file_access.h index bcdae614870..793e971a4c7 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -125,6 +125,9 @@ public: virtual void store_string(const String& p_string); virtual void store_line(const String& p_string); + virtual void store_pascal_string(const String& p_string); + virtual String get_pascal_string(); + virtual void store_buffer(const uint8_t *p_src,int p_length); ///< store an array of bytes virtual bool file_exists(const String& p_name)=0; ///< return true if a file exists diff --git a/core/os/input.cpp b/core/os/input.cpp index 3266e4cc103..e732eac323e 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -56,6 +56,7 @@ void Input::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_accelerometer"),&Input::get_accelerometer); ObjectTypeDB::bind_method(_MD("get_mouse_pos"),&Input::get_mouse_pos); ObjectTypeDB::bind_method(_MD("get_mouse_speed"),&Input::get_mouse_speed); + ObjectTypeDB::bind_method(_MD("get_mouse_button_mask"),&Input::get_mouse_button_mask); ObjectTypeDB::bind_method(_MD("set_mouse_mode","mode"),&Input::set_mouse_mode); ObjectTypeDB::bind_method(_MD("get_mouse_mode"),&Input::get_mouse_mode); @@ -280,6 +281,12 @@ Point2 InputDefault::get_mouse_speed() const { return mouse_speed_track.speed; } +int InputDefault::get_mouse_button_mask() const { + + OS::get_singleton()->get_mouse_button_state(); +} + + void InputDefault::iteration(float p_step) { diff --git a/core/os/input.h b/core/os/input.h index 5987d6ef6c5..cc51dbf42f9 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -64,6 +64,7 @@ public: virtual Point2 get_mouse_pos() const=0; virtual Point2 get_mouse_speed() const=0; + virtual int get_mouse_button_mask() const=0; virtual Vector3 get_accelerometer()=0; @@ -120,6 +121,7 @@ public: virtual Point2 get_mouse_pos() const; virtual Point2 get_mouse_speed() const; + virtual int get_mouse_button_mask() const; void parse_input_event(const InputEvent& p_event); void set_accelerometer(const Vector3& p_accel); diff --git a/core/os/mutex.h b/core/os/mutex.h index 512180d6c78..241d70e2323 100644 --- a/core/os/mutex.h +++ b/core/os/mutex.h @@ -50,7 +50,7 @@ public: virtual void lock()=0; ///< Lock the mutex, block if locked by someone else virtual void unlock()=0; ///< Unlock the mutex, let other threads continue - virtual Error try_lock()=0; ///< Attempt to lock the mutex, true on success, false means it can't lock. + virtual Error try_lock()=0; ///< Attempt to lock the mutex, OK on success, ERROR means it can't lock. static Mutex * create(bool p_recursive=true); ///< Create a mutex diff --git a/core/os/os.cpp b/core/os/os.cpp index 141d5f2b589..c9a5cb1af84 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -430,7 +430,7 @@ Error OS::native_video_play(String p_path) { return FAILED; }; -bool OS::native_video_is_playing() { +bool OS::native_video_is_playing() const { return false; }; @@ -447,6 +447,15 @@ void OS::set_mouse_mode(MouseMode p_mode) { } +bool OS::can_use_threads() const { + +#ifdef NO_THREADS + return false; +#else + return true; +#endif +} + OS::MouseMode OS::get_mouse_mode() const{ return MOUSE_MODE_VISIBLE; diff --git a/core/os/os.h b/core/os/os.h index d77d9bee7fe..c790b386352 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -316,10 +316,12 @@ public: virtual String get_unique_ID() const; virtual Error native_video_play(String p_path); - virtual bool native_video_is_playing(); + virtual bool native_video_is_playing() const; virtual void native_video_pause(); virtual void native_video_stop(); + virtual bool can_use_threads() const; + virtual Error dialog_show(String p_title, String p_description, Vector p_buttons, Object* p_obj, String p_callback); virtual Error dialog_input_text(String p_title, String p_description, String p_partial, Object* p_obj, String p_callback); diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 6d107f97e7b..7e7ce3479f7 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -49,6 +49,7 @@ #include "core/io/xml_parser.h" #include "io/http_client.h" #include "packed_data_container.h" +#include "func_ref.h" #ifdef XML_ENABLED static ResourceFormatSaverXML *resource_saver_xml=NULL; @@ -135,6 +136,7 @@ void register_core_types() { ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); + ObjectTypeDB::register_type(); ObjectTypeDB::register_virtual_type(); ObjectTypeDB::register_create_type(); ObjectTypeDB::register_create_type(); diff --git a/core/ustring.cpp b/core/ustring.cpp index b0f06c6ab67..f53829fe214 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -31,6 +31,7 @@ #include "os/memory.h" #include "print_string.h" #include "math_funcs.h" +#include "io/md5.h" #include "ucaps.h" #include "color.h" #define MAX_DIGITS 6 @@ -2264,6 +2265,15 @@ uint64_t String::hash64() const { } +String String::md5_text() const { + + CharString cs=utf8(); + MD5_CTX ctx; + MD5Init(&ctx); + MD5Update(&ctx,(unsigned char*)cs.ptr(),cs.length()); + MD5Final(&ctx); + return String::md5(ctx.digest); +} String String::insert(int p_at_pos,String p_string) const { diff --git a/core/ustring.h b/core/ustring.h index 007565c8253..13db00f07f0 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -181,7 +181,8 @@ public: static uint32_t hash(const char* p_cstr,int p_len); /* hash the string */ static uint32_t hash(const char* p_cstr); /* hash the string */ uint32_t hash() const; /* hash the string */ - uint64_t hash64() const; /* hash the string */ + uint64_t hash64() const; /* hash the string */ + String md5_text() const; inline bool empty() const { return length() == 0; } diff --git a/drivers/mpc/audio_stream_mpc.cpp b/drivers/mpc/audio_stream_mpc.cpp index 91912c89489..e1f9aacf5ff 100644 --- a/drivers/mpc/audio_stream_mpc.cpp +++ b/drivers/mpc/audio_stream_mpc.cpp @@ -140,7 +140,7 @@ mpc_bool_t AudioStreamMPC::_mpc_canseek(mpc_reader *p_reader) { bool AudioStreamMPC::_can_mix() const { - return active && !paused; + return /*active &&*/ !paused; } diff --git a/drivers/openssl/stream_peer_ssl.cpp b/drivers/openssl/stream_peer_ssl.cpp new file mode 100644 index 00000000000..aaedd7dde98 --- /dev/null +++ b/drivers/openssl/stream_peer_ssl.cpp @@ -0,0 +1,111 @@ +#include "stream_peer_ssl.h" + + +int StreamPeerSSL::bio_create( BIO *b ) { + b->init = 1; + b->num = 0; + b->ptr = NULL; + b->flags = 0; + return 1; +} + +int StreamPeerSSL::bio_destroy( BIO *b ) { + + if ( b == NULL ) return 0; + b->ptr = NULL; /* sb_tls_remove() will free it */ + b->init = 0; + b->flags = 0; + return 1; +} + +int StreamPeerSSL::bio_read( BIO *b, char *buf, int len ) { + + if ( buf == NULL || len <= 0 ) return 0; + + StreamPeerSSL * sp = (StreamPeerSSL*)b->ptr; + + if (sp->base.is_null()) + return 0; + + + + BIO_clear_retry_flags( b ); + + Error err; + int ret=0; + if (sp->block) { + err = sp->base->get_data((const uint8_t*)buf,len); + if (err==OK) + ret=len; + } else { + + err = sp->base->get_partial_data((const uint8_t*)buf,len,ret); + if (err==OK && ret!=len) { + BIO_set_retry_write( b ); + } + + } + + return ret; +} + +int StreamPeerSSL::bio_write( BIO *b, const char *buf, int len ) { + + if ( buf == NULL || len <= 0 ) return 0; + + StreamPeerSSL * sp = (StreamPeerSSL*)b->ptr; + + if (sp->base.is_null()) + return 0; + + BIO_clear_retry_flags( b ); + + Error err; + int wrote=0; + if (sp->block) { + err = sp->base->put_data((const uint8_t*)buf,len); + if (err==OK) + wrote=len; + } else { + + err = sp->base->put_partial_data((const uint8_t*)buf,len,wrote); + if (err==OK && wrote!=len) { + BIO_set_retry_write( b ); + } + + } + + return wrote; +} + +long StreamPeerSSL::bio_ctrl( BIO *b, int cmd, long num, void *ptr ) { + if ( cmd == BIO_CTRL_FLUSH ) { + /* The OpenSSL library needs this */ + return 1; + } + return 0; +} + +int StreamPeerSSL::bio_gets( BIO *b, char *buf, int len ) { + return -1; +} + +int StreamPeerSSL::bio_puts( BIO *b, const char *str ) { + return StreamPeerSSL::bio_write( b, str, strlen( str ) ); +} + +BIO_METHOD StreamPeerSSL::bio_methods = +{ + ( 100 | 0x400 ), /* it's a source/sink BIO */ + "sockbuf glue", + StreamPeerSSL::bio_write, + StreamPeerSSL::bio_read, + StreamPeerSSL::bio_puts, + StreamPeerSSL::bio_gets, + StreamPeerSSL::bio_ctrl, + StreamPeerSSL::bio_create, + StreamPeerSSL::bio_destroy +}; + +StreamPeerSSL::StreamPeerSSL() { +} diff --git a/drivers/openssl/stream_peer_ssl.h b/drivers/openssl/stream_peer_ssl.h new file mode 100644 index 00000000000..a126f6122cb --- /dev/null +++ b/drivers/openssl/stream_peer_ssl.h @@ -0,0 +1,26 @@ +#ifndef STREAM_PEER_SSL_H +#define STREAM_PEER_SSL_H + +#include "io/stream_peer.h" + +class StreamPeerSSL : public StreamPeer { + + OBJ_TYPE(StreamPeerSSL,StreamPeer); + + Ref base; + bool block; + static BIO_METHOD bio_methods; + + static int bio_create( BIO *b ); + static int bio_destroy( BIO *b ); + static int bio_read( BIO *b, char *buf, int len ); + static int bio_write( BIO *b, const char *buf, int len ); + static long bio_ctrl( BIO *b, int cmd, long num, void *ptr ); + static int bio_gets( BIO *b, char *buf, int len ); + static int bio_puts( BIO *b, const char *str ); + +public: + StreamPeerSSL(); +}; + +#endif // STREAM_PEER_SSL_H diff --git a/drivers/vorbis/audio_stream_ogg_vorbis.cpp b/drivers/vorbis/audio_stream_ogg_vorbis.cpp index 0964a22c947..d9b7b1d1614 100644 --- a/drivers/vorbis/audio_stream_ogg_vorbis.cpp +++ b/drivers/vorbis/audio_stream_ogg_vorbis.cpp @@ -97,7 +97,7 @@ long AudioStreamOGGVorbis::_ov_tell_func(void *_f) { bool AudioStreamOGGVorbis::_can_mix() const { - return playing && !paused; + return /*playing &&*/ !paused; } @@ -125,6 +125,8 @@ void AudioStreamOGGVorbis::update() { if (ret<0) { playing = false; + setting_up=false; + ERR_EXPLAIN("Error reading OGG Vorbis File: "+file); ERR_BREAK(ret<0); } else if (ret==0) { // end of song, reload? @@ -135,7 +137,8 @@ void AudioStreamOGGVorbis::update() { if (!has_loop()) { - playing=false; + playing=false; + setting_up=false; repeats=1; return; } @@ -145,6 +148,7 @@ void AudioStreamOGGVorbis::update() { int errv = ov_open_callbacks(f,&vf,NULL,0,_ov_callbacks); if (errv!=0) { playing=false; + setting_up=false; return; // :( } @@ -179,6 +183,8 @@ void AudioStreamOGGVorbis::play() { playing=false; setting_up=true; update(); + if (!setting_up) + return; setting_up=false; playing=true; } diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index 2930d9322c7..c099c3f33cc 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -31,6 +31,7 @@ #include "object_type_db.h" #include "reference.h" #include "gd_script.h" +#include "func_ref.h" #include "os/os.h" const char *GDFunctions::get_func_name(Function p_func) { @@ -80,6 +81,7 @@ const char *GDFunctions::get_func_name(Function p_func) { "clamp", "nearest_po2", "weakref", + "funcref", "convert", "typeof", "str", @@ -451,6 +453,36 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va + } break; + case FUNC_FUNCREF: { + VALIDATE_ARG_COUNT(2); + if (p_args[0]->get_type()!=Variant::OBJECT) { + + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=0; + r_error.expected=Variant::OBJECT; + r_ret=Variant(); + return; + + } + if (p_args[1]->get_type()!=Variant::STRING && p_args[1]->get_type()!=Variant::NODE_PATH) { + + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=1; + r_error.expected=Variant::STRING; + r_ret=Variant(); + return; + + } + + Ref fr = memnew( FuncRef); + + Object *obj = *p_args[0]; + fr->set_instance(*p_args[0]); + fr->set_function(*p_args[1]); + + r_ret=fr; + } break; case TYPE_CONVERT: { VALIDATE_ARG_COUNT(2); @@ -678,7 +710,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va } r_ret=ResourceLoader::load(*p_args[0]); - } + } break; case INST2DICT: { VALIDATE_ARG_COUNT(1); @@ -1129,6 +1161,13 @@ MethodInfo GDFunctions::get_info(Function p_func) { mi.return_val.type=Variant::OBJECT; return mi; + } break; + case FUNC_FUNCREF: { + + MethodInfo mi("funcref",PropertyInfo(Variant::OBJECT,"instance"),PropertyInfo(Variant::STRING,"funcname")); + mi.return_val.type=Variant::OBJECT; + return mi; + } break; case TYPE_CONVERT: { diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h index 2ab397d18a1..9255e5e2c51 100644 --- a/modules/gdscript/gd_functions.h +++ b/modules/gdscript/gd_functions.h @@ -77,6 +77,7 @@ public: LOGIC_CLAMP, LOGIC_NEAREST_PO2, OBJ_WEAKREF, + FUNC_FUNCREF, TYPE_CONVERT, TYPE_OF, TEXT_STR, diff --git a/modules/multiscript/SCsub b/modules/multiscript/SCsub deleted file mode 100644 index d20da72b727..00000000000 --- a/modules/multiscript/SCsub +++ /dev/null @@ -1,7 +0,0 @@ -Import('env') - -env.add_source_files(env.modules_sources,"*.cpp") - -Export('env') - - diff --git a/modules/multiscript/config.py b/modules/multiscript/config.py deleted file mode 100644 index f9bd7da08d3..00000000000 --- a/modules/multiscript/config.py +++ /dev/null @@ -1,11 +0,0 @@ - - -def can_build(platform): - return True - - -def configure(env): - pass - - - diff --git a/modules/multiscript/multi_script.cpp b/modules/multiscript/multi_script.cpp deleted file mode 100644 index 1924cf2a6e5..00000000000 --- a/modules/multiscript/multi_script.cpp +++ /dev/null @@ -1,498 +0,0 @@ -/*************************************************************************/ -/* multi_script.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "multi_script.h" - -bool MultiScriptInstance::set(const StringName& p_name, const Variant& p_value) { - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for(int i=0;iset(p_name,p_value); - if (found) - return true; - } - - if (String(p_name).begins_with("script_")) { - bool valid; - owner->set(p_name,p_value,&valid); - return valid; - } - return false; - -} - -bool MultiScriptInstance::get(const StringName& p_name, Variant &r_ret) const{ - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for(int i=0;iget(p_name,r_ret); - if (found) - return true; - } - if (String(p_name).begins_with("script_")) { - bool valid; - r_ret=owner->get(p_name,&valid); - return valid; - } - return false; - -} -void MultiScriptInstance::get_property_list(List *p_properties) const{ - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - - Set existing; - - for(int i=0;i pl; - sarr[i]->get_property_list(&pl); - - for(List::Element *E=pl.front();E;E=E->next()) { - - if (existing.has(E->get().name)) - continue; - - p_properties->push_back(E->get()); - existing.insert(E->get().name); - } - } - - p_properties->push_back( PropertyInfo(Variant::NIL,"Scripts",PROPERTY_HINT_NONE,String(),PROPERTY_USAGE_CATEGORY) ); - - for(int i=0;iscripts.size();i++) { - - p_properties->push_back( PropertyInfo(Variant::OBJECT,"script_"+String::chr('a'+i),PROPERTY_HINT_RESOURCE_TYPE,"Script",PROPERTY_USAGE_EDITOR) ); - - } - - if (owner->scripts.size()<25) { - - p_properties->push_back( PropertyInfo(Variant::OBJECT,"script_"+String::chr('a'+(owner->scripts.size())),PROPERTY_HINT_RESOURCE_TYPE,"Script",PROPERTY_USAGE_EDITOR) ); - } - -} - -void MultiScriptInstance::get_method_list(List *p_list) const{ - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - - Set existing; - - for(int i=0;i ml; - sarr[i]->get_method_list(&ml); - - for(List::Element *E=ml.front();E;E=E->next()) { - - if (existing.has(E->get().name)) - continue; - - p_list->push_back(E->get()); - existing.insert(E->get().name); - } - } - -} -bool MultiScriptInstance::has_method(const StringName& p_method) const{ - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for(int i=0;ihas_method(p_method)) - return true; - } - - return false; - -} - -Variant MultiScriptInstance::call(const StringName& p_method,const Variant** p_args,int p_argcount,Variant::CallError &r_error) { - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for(int i=0;icall(p_method,p_args,p_argcount,r_error); - if (r_error.error==Variant::CallError::CALL_OK) - return r; - else if (r_error.error!=Variant::CallError::CALL_ERROR_INVALID_METHOD) - return r; - } - - r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD; - return Variant(); - -} - -void MultiScriptInstance::call_multilevel(const StringName& p_method,const Variant** p_args,int p_argcount){ - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for(int i=0;icall_multilevel(p_method,p_args,p_argcount); - } - - -} -void MultiScriptInstance::notification(int p_notification){ - - ScriptInstance **sarr = instances.ptr(); - int sc = instances.size(); - - for(int i=0;inotification(p_notification); - } - -} - - -Ref