summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/array.cpp53
-rw-r--r--core/array.h6
-rw-r--r--core/balloon_allocator.h35
-rw-r--r--core/bind/core_bind.cpp151
-rw-r--r--core/bind/core_bind.h41
-rw-r--r--core/command_queue_mt.h126
-rw-r--r--core/dictionary.cpp28
-rw-r--r--core/dictionary.h3
-rw-r--r--core/dvector.h13
-rw-r--r--core/event_queue.cpp2
-rw-r--r--core/fpstr.cpp28
-rw-r--r--core/fpstr.h28
-rw-r--r--core/func_ref.cpp30
-rw-r--r--core/func_ref.h28
-rw-r--r--core/global_constants.cpp15
-rw-r--r--core/globals.cpp35
-rw-r--r--core/globals.h3
-rw-r--r--core/helper/value_evaluator.h2
-rw-r--r--core/hq2x.cpp4
-rw-r--r--core/image.cpp19
-rw-r--r--core/image_quantize.cpp5
-rw-r--r--core/input_map.cpp96
-rw-r--r--core/input_map.h11
-rw-r--r--core/io/LICENSE-InfoZip.txt60
-rw-r--r--core/io/LICENSE-MiniZip.txt32
-rw-r--r--core/io/compression.cpp23
-rw-r--r--core/io/compression.h2
-rw-r--r--core/io/file_access_encrypted.cpp28
-rw-r--r--core/io/file_access_encrypted.h28
-rw-r--r--core/io/file_access_memory.cpp6
-rw-r--r--core/io/http_client.cpp3
-rw-r--r--core/io/http_client.h3
-rw-r--r--core/io/image_loader.cpp3
-rw-r--r--core/io/ioapi.c2
-rw-r--r--core/io/ioapi.h2
-rw-r--r--core/io/marshalls.cpp3
-rw-r--r--core/io/networked_multiplayer_peer.cpp41
-rw-r--r--core/io/networked_multiplayer_peer.h54
-rw-r--r--core/io/packet_peer.cpp2
-rw-r--r--core/io/packet_peer_udp.cpp28
-rw-r--r--core/io/packet_peer_udp.h28
-rw-r--r--core/io/resource_format_binary.cpp45
-rw-r--r--core/io/resource_format_xml.cpp6
-rw-r--r--core/io/resource_loader.cpp19
-rw-r--r--core/io/resource_loader.h2
-rw-r--r--core/io/resource_saver.cpp14
-rw-r--r--core/io/resource_saver.h2
-rw-r--r--core/io/sha-README.md5
-rw-r--r--core/io/sha256.c245
-rw-r--r--core/io/sha256.h50
-rw-r--r--core/io/stream_peer.cpp145
-rw-r--r--core/io/stream_peer.h36
-rw-r--r--core/io/stream_peer_ssl.cpp28
-rw-r--r--core/io/stream_peer_ssl.h28
-rw-r--r--core/io/translation_loader_po.cpp3
-rw-r--r--core/io/unzip.c19
-rw-r--r--core/io/unzip.h2
-rw-r--r--core/io/zip.c2
-rw-r--r--core/io/zip.h2
-rw-r--r--core/io/zip_io.h7
-rw-r--r--core/make_binders.py25
-rw-r--r--core/math/bezier_curve.cpp29
-rw-r--r--core/math/bezier_curve.h35
-rw-r--r--core/math/bsp_tree.h27
-rw-r--r--core/math/face3.h2
-rw-r--r--core/math/geometry.cpp14
-rw-r--r--core/math/math_2d.h17
-rw-r--r--core/math/math_defs.cpp30
-rw-r--r--core/math/math_funcs.cpp36
-rw-r--r--core/math/math_funcs.h2
-rw-r--r--core/math/quat.cpp2
-rw-r--r--core/math/triangle_mesh.cpp14
-rw-r--r--core/math/vector3.h13
-rw-r--r--core/message_queue.cpp2
-rw-r--r--core/method_bind.cpp7
-rw-r--r--core/method_bind.h48
-rw-r--r--core/method_ptrcall.h354
-rw-r--r--core/multi_bucket_array.h42
-rw-r--r--core/object.cpp168
-rw-r--r--core/object.h23
-rw-r--r--core/object_type_db.cpp21
-rw-r--r--core/object_type_db.h12
-rw-r--r--core/os/dir_access.cpp134
-rw-r--r--core/os/dir_access.h2
-rw-r--r--core/os/file_access.cpp35
-rw-r--r--core/os/file_access.h9
-rw-r--r--core/os/input.cpp8
-rw-r--r--core/os/input.h25
-rw-r--r--core/os/input_event.cpp109
-rw-r--r--core/os/input_event.h4
-rw-r--r--core/os/keyboard.cpp21
-rw-r--r--core/os/keyboard.h3
-rw-r--r--core/os/os.cpp49
-rw-r--r--core/os/os.h21
-rw-r--r--core/os/thread.h7
-rw-r--r--core/pair.cpp29
-rw-r--r--core/path_db.cpp12
-rw-r--r--core/path_db.h2
-rw-r--r--core/path_remap.cpp19
-rw-r--r--core/pool_allocator.cpp1
-rw-r--r--core/print_string.cpp3
-rw-r--r--core/reference.cpp14
-rw-r--r--core/reference.h56
-rw-r--r--core/register_core_types.cpp1
-rw-r--r--core/res_ptr.cpp90
-rw-r--r--core/res_ptr.h63
-rw-r--r--core/resource.cpp36
-rw-r--r--core/resource.h2
-rw-r--r--core/script_debugger_debugger.cpp28
-rw-r--r--core/script_language.cpp43
-rw-r--r--core/script_language.h51
-rw-r--r--core/string_db.cpp6
-rw-r--r--core/translation.cpp450
-rw-r--r--core/typedefs.h1
-rw-r--r--core/ucaps.h28
-rw-r--r--core/undo_redo.cpp61
-rw-r--r--core/undo_redo.h12
-rw-r--r--core/ustring.cpp142
-rw-r--r--core/ustring.h14
-rw-r--r--core/variant.cpp66
-rw-r--r--core/variant.h14
-rw-r--r--core/variant_call.cpp305
-rw-r--r--core/variant_call_bind.h40
-rw-r--r--core/variant_construct_string.cpp29
-rw-r--r--core/variant_op.cpp364
-rw-r--r--core/variant_parser.cpp126
-rw-r--r--core/variant_parser.h28
-rw-r--r--core/vector.h10
-rw-r--r--core/vmap.cpp30
-rw-r--r--core/vset.cpp28
130 files changed, 3984 insertions, 1340 deletions
diff --git a/core/array.cpp b/core/array.cpp
index fef0fcbb40..23792f90fc 100644
--- a/core/array.cpp
+++ b/core/array.cpp
@@ -150,9 +150,58 @@ void Array::erase(const Variant& p_value) {
_p->array.erase(p_value);
}
-int Array::find(const Variant& p_value) const {
+int Array::find(const Variant& p_value, int p_from) const {
- return _p->array.find(p_value);
+ return _p->array.find(p_value, p_from);
+}
+
+int Array::rfind(const Variant& p_value, int p_from) const {
+
+ if (_p->array.size() == 0)
+ return -1;
+
+ if (p_from < 0) {
+ // Relative offset from the end
+ p_from = _p->array.size() + p_from;
+ }
+ if (p_from < 0 || p_from >= _p->array.size()) {
+ // Limit to array boundaries
+ p_from = _p->array.size() - 1;
+ }
+
+ for (int i=p_from; i>=0; i--) {
+
+ if(_p->array[i] == p_value){
+ return i;
+ };
+ };
+
+ return -1;
+}
+
+int Array::find_last(const Variant& p_value) const {
+
+ return rfind(p_value);
+}
+
+int Array::count(const Variant& p_value) const {
+
+ if(_p->array.size() == 0)
+ return 0;
+
+ int amount=0;
+ for (int i=0; i<_p->array.size(); i++) {
+
+ if(_p->array[i] == p_value){
+ amount++;
+ };
+ };
+
+ return amount;
+}
+
+bool Array::has(const Variant& p_value) const {
+ return _p->array.find(p_value, 0) != -1;
}
void Array::remove(int p_pos) {
diff --git a/core/array.h b/core/array.h
index ecb91b69dc..dfc902525c 100644
--- a/core/array.h
+++ b/core/array.h
@@ -71,7 +71,11 @@ public:
void sort_custom(Object *p_obj,const StringName& p_function);
void invert();
- int find(const Variant& p_value) const;
+ int find(const Variant& p_value, int p_from=0) const;
+ int rfind(const Variant& p_value, int p_from=-1) const;
+ int find_last(const Variant& p_value) const;
+ int count(const Variant& p_value) const;
+ bool has(const Variant& p_value) const;
void erase(const Variant& p_value);
diff --git a/core/balloon_allocator.h b/core/balloon_allocator.h
deleted file mode 100644
index eb6632bb37..0000000000
--- a/core/balloon_allocator.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*************************************************************************/
-/* balloon_allocator.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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. */
-/*************************************************************************/
-#ifndef BALLOON_ALLOCATOR_H
-#define BALLOON_ALLOCATOR_H
-
-#include "os/memory.h"
-
-#include "allocators.h"
-#endif // BALLOON_ALLOCATOR_H
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index addc26525e..4e815d044d 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* core_bind.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 "core_bind.h"
#include "os/os.h"
#include "geometry.h"
@@ -407,6 +435,18 @@ String _OS::get_locale() const {
return OS::get_singleton()->get_locale();
}
+String _OS::get_latin_keyboard_variant() const {
+ switch( OS::get_singleton()->get_latin_keyboard_variant() ) {
+ case OS::LATIN_KEYBOARD_QWERTY: return "QWERTY";
+ case OS::LATIN_KEYBOARD_QWERTZ: return "QWERTZ";
+ case OS::LATIN_KEYBOARD_AZERTY: return "AZERTY";
+ case OS::LATIN_KEYBOARD_QZERTY: return "QZERTY";
+ case OS::LATIN_KEYBOARD_DVORAK: return "DVORAK";
+ case OS::LATIN_KEYBOARD_NEO : return "NEO";
+ default: return "ERROR";
+ }
+}
+
String _OS::get_model_name() const {
return OS::get_singleton()->get_model_name();
@@ -436,6 +476,15 @@ Error _OS::set_thread_name(const String& p_name) {
return Thread::set_name(p_name);
};
+void _OS::set_use_vsync(bool p_enable) {
+ OS::get_singleton()->set_use_vsync(p_enable);
+}
+
+bool _OS::is_vsnc_enabled() const {
+
+ return OS::get_singleton()->is_vsnc_enabled();
+}
+
/*
enum Weekday {
@@ -808,7 +857,6 @@ void _OS::print_all_textures_by_size() {
for(List<_OSCoreBindImg>::Element *E=imgs.front();E;E=E->next()) {
- print_line(E->get().path+" - "+String::humanize_size(E->get().vram)+" ("+E->get().size+") - total:"+String::humanize_size(total) );
total-=E->get().vram;
}
}
@@ -842,23 +890,21 @@ void _OS::print_resources_by_type(const Vector<String>& p_types) {
type_count[r->get_type()]++;
-
- print_line(r->get_type()+": "+r->get_path());
-
- List<String> metas;
- r->get_meta_list(&metas);
- for (List<String>::Element* me = metas.front(); me; me = me->next()) {
- print_line(" "+String(me->get()) + ": " + r->get_meta(me->get()));
- };
}
- for(Map<String,int>::Element *E=type_count.front();E;E=E->next()) {
+};
- print_line(E->key()+" count: "+itos(E->get()));
- }
+bool _OS::has_virtual_keyboard() const {
+ return OS::get_singleton()->has_virtual_keyboard();
+}
-};
+void _OS::show_virtual_keyboard(const String& p_existing_text) {
+ OS::get_singleton()->show_virtual_keyboard(p_existing_text, Rect2());
+}
+void _OS::hide_virtual_keyboard() {
+ OS::get_singleton()->hide_virtual_keyboard();
+}
void _OS::print_all_resources(const String& p_to_file ) {
@@ -909,6 +955,11 @@ void _OS::native_video_stop() {
OS::get_singleton()->native_video_stop();
};
+void _OS::request_attention() {
+
+ OS::get_singleton()->request_attention();
+}
+
bool _OS::is_debug_build() const {
#ifdef DEBUG_ENABLED
@@ -967,6 +1018,11 @@ void _OS::alert(const String& p_alert,const String& p_title) {
OS::get_singleton()->alert(p_alert,p_title);
}
+Dictionary _OS::get_engine_version() const {
+
+ return OS::get_singleton()->get_engine_version();
+}
+
_OS *_OS::singleton=NULL;
void _OS::_bind_methods() {
@@ -1002,6 +1058,7 @@ void _OS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("is_window_minimized"),&_OS::is_window_minimized);
ObjectTypeDB::bind_method(_MD("set_window_maximized", "enabled"),&_OS::set_window_maximized);
ObjectTypeDB::bind_method(_MD("is_window_maximized"),&_OS::is_window_maximized);
+ ObjectTypeDB::bind_method(_MD("request_attention"), &_OS::request_attention);
ObjectTypeDB::bind_method(_MD("set_borderless_window", "borderless"), &_OS::set_borderless_window);
ObjectTypeDB::bind_method(_MD("get_borderless_window"), &_OS::get_borderless_window);
@@ -1060,6 +1117,7 @@ void _OS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_ticks_msec"),&_OS::get_ticks_msec);
ObjectTypeDB::bind_method(_MD("get_splash_tick_msec"),&_OS::get_splash_tick_msec);
ObjectTypeDB::bind_method(_MD("get_locale"),&_OS::get_locale);
+ ObjectTypeDB::bind_method(_MD("get_latin_keyboard_variant"),&_OS::get_latin_keyboard_variant);
ObjectTypeDB::bind_method(_MD("get_model_name"),&_OS::get_model_name);
ObjectTypeDB::bind_method(_MD("get_custom_level"),&_OS::get_custom_level);
@@ -1076,6 +1134,9 @@ void _OS::_bind_methods() {
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);
+ ObjectTypeDB::bind_method(_MD("has_virtual_keyboard"),&_OS::has_virtual_keyboard);
+ ObjectTypeDB::bind_method(_MD("show_virtual_keyboard", "existing_text"),&_OS::show_virtual_keyboard,DEFVAL(""));
+ ObjectTypeDB::bind_method(_MD("hide_virtual_keyboard"),&_OS::hide_virtual_keyboard);
ObjectTypeDB::bind_method(_MD("print_resources_in_use","short"),&_OS::print_resources_in_use,DEFVAL(false));
ObjectTypeDB::bind_method(_MD("print_all_resources","tofile"),&_OS::print_all_resources,DEFVAL(""));
@@ -1110,6 +1171,10 @@ void _OS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_thread_name","name"),&_OS::set_thread_name);
+ ObjectTypeDB::bind_method(_MD("set_use_vsync","enable"),&_OS::set_use_vsync);
+ ObjectTypeDB::bind_method(_MD("is_vsnc_enabled"),&_OS::is_vsnc_enabled);
+
+ ObjectTypeDB::bind_method(_MD("get_engine_version"),&_OS::get_engine_version);
BIND_CONSTANT( DAY_SUNDAY );
BIND_CONSTANT( DAY_MONDAY );
@@ -1527,7 +1592,12 @@ DVector<uint8_t> _File::get_buffer(int p_length) const{
String _File::get_as_text() const {
+ ERR_FAIL_COND_V(!f, String());
+
String text;
+ size_t original_pos = f->get_pos();
+ f->seek(0);
+
String l = get_line();
while(!eof_reached()) {
text+=l+"\n";
@@ -1535,6 +1605,8 @@ String _File::get_as_text() const {
}
text+=l;
+ f->seek(original_pos);
+
return text;
@@ -1547,6 +1619,12 @@ String _File::get_md5(const String& p_path) const {
}
+String _File::get_sha256(const String& p_path) const {
+
+ return FileAccess::get_sha256(p_path);
+
+}
+
String _File::get_line() const{
@@ -1737,6 +1815,7 @@ void _File::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_line"),&_File::get_line);
ObjectTypeDB::bind_method(_MD("get_as_text"),&_File::get_as_text);
ObjectTypeDB::bind_method(_MD("get_md5","path"),&_File::get_md5);
+ ObjectTypeDB::bind_method(_MD("get_sha256","path"),&_File::get_sha256);
ObjectTypeDB::bind_method(_MD("get_endian_swap"),&_File::get_endian_swap);
ObjectTypeDB::bind_method(_MD("set_endian_swap","enable"),&_File::set_endian_swap);
ObjectTypeDB::bind_method(_MD("get_error:Error"),&_File::get_error);
@@ -1845,29 +1924,57 @@ String _Directory::get_current_dir() {
Error _Directory::make_dir(String p_dir){
ERR_FAIL_COND_V(!d,ERR_UNCONFIGURED);
+ if (!p_dir.is_rel_path()) {
+ DirAccess *d = DirAccess::create_for_path(p_dir);
+ Error err = d->make_dir(p_dir);
+ memdelete(d);
+ return err;
+
+ }
return d->make_dir(p_dir);
}
Error _Directory::make_dir_recursive(String p_dir){
ERR_FAIL_COND_V(!d,ERR_UNCONFIGURED);
+ if (!p_dir.is_rel_path()) {
+ DirAccess *d = DirAccess::create_for_path(p_dir);
+ Error err = d->make_dir_recursive(p_dir);
+ memdelete(d);
+ return err;
+
+ }
return d->make_dir_recursive(p_dir);
}
bool _Directory::file_exists(String p_file){
ERR_FAIL_COND_V(!d,false);
+
+ if (!p_file.is_rel_path()) {
+ return FileAccess::exists(p_file);
+ }
+
return d->file_exists(p_file);
}
bool _Directory::dir_exists(String p_dir) {
ERR_FAIL_COND_V(!d,false);
- return d->dir_exists(p_dir);
+ if (!p_dir.is_rel_path()) {
+
+ DirAccess *d = DirAccess::create_for_path(p_dir);
+ bool exists = d->dir_exists(p_dir);
+ memdelete(d);
+ return exists;
+
+ } else {
+ return d->dir_exists(p_dir);
+ }
}
int _Directory::get_space_left(){
ERR_FAIL_COND_V(!d,0);
- return d->get_space_left();
+ return d->get_space_left()/1024*1024; //return value in megabytes, given binding is int
}
Error _Directory::copy(String p_from,String p_to){
@@ -1878,12 +1985,26 @@ Error _Directory::copy(String p_from,String p_to){
Error _Directory::rename(String p_from, String p_to){
ERR_FAIL_COND_V(!d,ERR_UNCONFIGURED);
+ if (!p_from.is_rel_path()) {
+ DirAccess *d = DirAccess::create_for_path(p_from);
+ Error err = d->rename(p_from,p_to);
+ memdelete(d);
+ return err;
+ }
+
return d->rename(p_from,p_to);
}
Error _Directory::remove(String p_name){
ERR_FAIL_COND_V(!d,ERR_UNCONFIGURED);
+ if (!p_name.is_rel_path()) {
+ DirAccess *d = DirAccess::create_for_path(p_name);
+ Error err = d->remove(p_name);
+ memdelete(d);
+ return err;
+ }
+
return d->remove(p_name);
}
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index af89536c45..14203ae863 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* core_bind.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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. */
+/*************************************************************************/
#ifndef CORE_BIND_H
#define CORE_BIND_H
@@ -130,6 +158,7 @@ public:
virtual bool is_window_minimized() const;
virtual void set_window_maximized(bool p_enabled);
virtual bool is_window_maximized() const;
+ virtual void request_attention();
virtual void set_borderless_window(bool p_borderless);
virtual bool get_borderless_window() const;
@@ -164,6 +193,8 @@ public:
Vector<String> get_cmdline_args();
String get_locale() const;
+ String get_latin_keyboard_variant() const;
+
String get_model_name() const;
MainLoop *get_main_loop() const;
@@ -174,6 +205,10 @@ public:
void dump_memory_to_file(const String& p_file);
void dump_resources_to_file(const String& p_file);
+ bool has_virtual_keyboard() const;
+ void show_virtual_keyboard(const String& p_existing_text="");
+ void hide_virtual_keyboard();
+
void print_resources_in_use(bool p_short=false);
void print_all_resources(const String& p_to_file);
void print_all_textures_by_size();
@@ -282,6 +317,11 @@ public:
Error set_thread_name(const String& p_name);
+ void set_use_vsync(bool p_enable);
+ bool is_vsnc_enabled() const;
+
+ Dictionary get_engine_version() const;
+
static _OS *get_singleton() { return singleton; }
_OS();
@@ -377,6 +417,7 @@ public:
String get_line() const;
String get_as_text() const;
String get_md5(const String& p_path) const;
+ String get_sha256(const String& p_path) const;
/**< use this for files WRITTEN in _big_ endian machines (ie, amiga/mac)
* It's not about the current CPU type but file formats.
diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h
index b1e0066c35..409543bf25 100644
--- a/core/command_queue_mt.h
+++ b/core/command_queue_mt.h
@@ -152,6 +152,23 @@ class CommandQueueMT {
virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7); }
};
+ template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7,class P8>
+ struct Command8 : public CommandBase {
+
+ T*instance;
+ M method;
+ typename GetSimpleTypeT<P1>::type_t p1;
+ typename GetSimpleTypeT<P2>::type_t p2;
+ typename GetSimpleTypeT<P3>::type_t p3;
+ typename GetSimpleTypeT<P4>::type_t p4;
+ typename GetSimpleTypeT<P5>::type_t p5;
+ typename GetSimpleTypeT<P6>::type_t p6;
+ typename GetSimpleTypeT<P7>::type_t p7;
+ typename GetSimpleTypeT<P8>::type_t p8;
+
+ virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7,p8); }
+ };
+
/* comands that return */
template<class T,class M,class R>
@@ -270,6 +287,25 @@ class CommandQueueMT {
virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6,p7); sync->sem->post(); sync->in_use=false; ; }
};
+ template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7,class P8,class R>
+ struct CommandRet8 : public CommandBase {
+
+ T*instance;
+ M method;
+ typename GetSimpleTypeT<P1>::type_t p1;
+ typename GetSimpleTypeT<P2>::type_t p2;
+ typename GetSimpleTypeT<P3>::type_t p3;
+ typename GetSimpleTypeT<P4>::type_t p4;
+ typename GetSimpleTypeT<P5>::type_t p5;
+ typename GetSimpleTypeT<P6>::type_t p6;
+ typename GetSimpleTypeT<P7>::type_t p7;
+ typename GetSimpleTypeT<P8>::type_t p8;
+ R* ret;
+ SyncSemaphore *sync;
+
+ virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6,p7,p8); sync->sem->post(); sync->in_use=false; ; }
+ };
+
/** commands that don't return but sync */
/* comands that return */
@@ -390,6 +426,25 @@ class CommandQueueMT {
virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7); sync->sem->post(); sync->in_use=false; ; }
};
+ template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7,class P8>
+ struct CommandSync8 : public CommandBase {
+
+ T*instance;
+ M method;
+ typename GetSimpleTypeT<P1>::type_t p1;
+ typename GetSimpleTypeT<P2>::type_t p2;
+ typename GetSimpleTypeT<P3>::type_t p3;
+ typename GetSimpleTypeT<P4>::type_t p4;
+ typename GetSimpleTypeT<P5>::type_t p5;
+ typename GetSimpleTypeT<P6>::type_t p6;
+ typename GetSimpleTypeT<P7>::type_t p7;
+ typename GetSimpleTypeT<P8>::type_t p8;
+
+ SyncSemaphore *sync;
+
+ virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7,p8); sync->sem->post(); sync->in_use=false; ; }
+ };
+
/***** BASE *******/
enum {
@@ -639,6 +694,27 @@ public:
if (sync) sync->post();
}
+
+ template<class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7,class P8>
+ void push( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8 ) {
+
+ Command8<T,M,P1,P2,P3,P4,P5,P6,P7,P8> * cmd = allocate_and_lock< Command8<T,M,P1,P2,P3,P4,P5,P6,P7,P8> >();
+
+ cmd->instance=p_instance;
+ cmd->method=p_method;
+ cmd->p1=p1;
+ cmd->p2=p2;
+ cmd->p3=p3;
+ cmd->p4=p4;
+ cmd->p5=p5;
+ cmd->p6=p6;
+ cmd->p7=p7;
+ cmd->p8=p8;
+
+ unlock();
+
+ if (sync) sync->post();
+ }
/*** PUSH AND RET COMMANDS ***/
@@ -806,6 +882,31 @@ public:
ss->sem->wait();
}
+ template<class T, class M, class P1, class P2, class P3, class P4, class P5, class P6,class P7,class P8,class R>
+ void push_and_ret( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,P7 p7,P8 p8, R* r_ret ) {
+
+ CommandRet8<T,M,P1,P2,P3,P4,P5,P6,P7,P8,R> * cmd = allocate_and_lock< CommandRet8<T,M,P1,P2,P3,P4,P5,P6,P7,P8,R> >();
+
+ cmd->instance=p_instance;
+ cmd->method=p_method;
+ cmd->p1=p1;
+ cmd->p2=p2;
+ cmd->p3=p3;
+ cmd->p4=p4;
+ cmd->p5=p5;
+ cmd->p6=p6;
+ cmd->p7=p7;
+ cmd->p8=p8;
+ cmd->ret=r_ret;
+ SyncSemaphore *ss=_alloc_sync_sem();
+ cmd->sync=ss;
+
+ unlock();
+
+ if (sync) sync->post();
+ ss->sem->wait();
+ }
+
template<class T, class M>
void push_and_sync( T * p_instance, M p_method) {
@@ -971,6 +1072,31 @@ public:
ss->sem->wait();
}
+ template<class T, class M, class P1, class P2, class P3, class P4, class P5, class P6,class P7,class P8>
+ void push_and_sync( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,P7 p7,P8 p8) {
+
+ CommandSync8<T,M,P1,P2,P3,P4,P5,P6,P7,P8> * cmd = allocate_and_lock< CommandSync8<T,M,P1,P2,P3,P4,P5,P6,P7,P8> >();
+
+ cmd->instance=p_instance;
+ cmd->method=p_method;
+ cmd->p1=p1;
+ cmd->p2=p2;
+ cmd->p3=p3;
+ cmd->p4=p4;
+ cmd->p5=p5;
+ cmd->p6=p6;
+ cmd->p7=p7;
+ cmd->p8=p8;
+
+ SyncSemaphore *ss=_alloc_sync_sem();
+ cmd->sync=ss;
+
+ unlock();
+
+ if (sync) sync->post();
+ ss->sem->wait();
+ }
+
void wait_and_flush_one() {
ERR_FAIL_COND(!sync);
sync->wait();
diff --git a/core/dictionary.cpp b/core/dictionary.cpp
index 75c8531251..6770b798f1 100644
--- a/core/dictionary.cpp
+++ b/core/dictionary.cpp
@@ -199,6 +199,18 @@ Array Dictionary::keys() const {
}
+Array Dictionary::values() const {
+
+ Array varr;
+ varr.resize(size());
+ const Variant *key=NULL;
+ int i=0;
+ while((key=next(key))){
+ varr[i++] = _p->variant_map[*key];
+ }
+ return varr;
+}
+
const Variant* Dictionary::next(const Variant* p_key) const {
return _p->variant_map.next(p_key);
@@ -220,6 +232,20 @@ Error Dictionary::parse_json(const String& p_json) {
return OK;
}
+Dictionary Dictionary::copy() const {
+
+ Dictionary n(is_shared());
+
+ List<Variant> keys;
+ get_key_list(&keys);
+
+ for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
+ n[E->get()]=operator[](E->get());
+ }
+
+ return n;
+}
+
String Dictionary::to_json() const {
return JSON::print(*this);
@@ -250,5 +276,3 @@ Dictionary::~Dictionary() {
_unref();
}
-
-
diff --git a/core/dictionary.h b/core/dictionary.h
index c854e95ee6..6a5f4e20e6 100644
--- a/core/dictionary.h
+++ b/core/dictionary.h
@@ -81,6 +81,9 @@ public:
const Variant* next(const Variant* p_key=NULL) const;
Array keys() const;
+ Array values() const;
+
+ Dictionary copy() const;
Dictionary(const Dictionary& p_from);
Dictionary(bool p_shared=false);
diff --git a/core/dvector.h b/core/dvector.h
index fbb1fc4824..a5519ed604 100644
--- a/core/dvector.h
+++ b/core/dvector.h
@@ -285,6 +285,7 @@ public:
Error resize(int p_size);
+ void invert();
void operator=(const DVector& p_dvector) { reference(p_dvector); }
DVector() {}
@@ -424,6 +425,18 @@ Error DVector<T>::resize(int p_size) {
return OK;
}
+template<class T>
+void DVector<T>::invert() {
+ T temp;
+ Write w = write();
+ int s = size();
+ int half_s = s/2;
+ for(int i=0;i<half_s;i++) {
+ temp = w[i];
+ w[i] = w[s-i-1];
+ w[s-i-1] = temp;
+ }
+}
#endif
diff --git a/core/event_queue.cpp b/core/event_queue.cpp
index 53638c5431..958ef41132 100644
--- a/core/event_queue.cpp
+++ b/core/event_queue.cpp
@@ -92,7 +92,7 @@ Error EventQueue::push_call(uint32_t p_instance_ID, const StringName& p_method,
*v=p_arg5;
}
- if (buffer_max_used>buffer_end);
+ if (buffer_end > buffer_max_used)
buffer_max_used=buffer_end;
return OK;
diff --git a/core/fpstr.cpp b/core/fpstr.cpp
deleted file mode 100644
index 76046d0b99..0000000000
--- a/core/fpstr.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*************************************************************************/
-/* fpstr.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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. */
-/*************************************************************************/
diff --git a/core/fpstr.h b/core/fpstr.h
deleted file mode 100644
index d3d02733b3..0000000000
--- a/core/fpstr.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*************************************************************************/
-/* fpstr.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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. */
-/*************************************************************************/
diff --git a/core/func_ref.cpp b/core/func_ref.cpp
index 66962710bd..644d8b5b63 100644
--- a/core/func_ref.cpp
+++ b/core/func_ref.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* func_ref.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 "func_ref.h"
Variant FuncRef::call_func(const Variant** p_args, int p_argcount, Variant::CallError& r_error) {
@@ -37,7 +65,7 @@ void FuncRef::_bind_methods() {
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_native_method(METHOD_FLAGS_DEFAULT,"call_func:Variant",&FuncRef::call_func,mi,defargs);
}
diff --git a/core/func_ref.h b/core/func_ref.h
index 28d0e737be..140dcd6b1c 100644
--- a/core/func_ref.h
+++ b/core/func_ref.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* func_ref.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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. */
+/*************************************************************************/
#ifndef FUNC_REF_H
#define FUNC_REF_H
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index 3cf4ff8f83..2594be63ac 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -478,7 +478,22 @@ static _GlobalConstant _global_constants[]={
BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORAGE ),
BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_EDITOR ),
BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_NETWORK ),
+
+ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_EDITOR_HELPER ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_CHECKABLE ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_CHECKED ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_INTERNATIONALIZED ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_BUNDLE ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_CATEGORY ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORE_IF_NONZERO ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORE_IF_NONONE ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_NO_INSTANCE_STATE ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_RESTART_IF_CHANGED ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_SCRIPT_VARIABLE ),
+
BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_DEFAULT ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_DEFAULT_INTL ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_NOEDITOR ),
BIND_GLOBAL_CONSTANT( METHOD_FLAG_NORMAL ),
BIND_GLOBAL_CONSTANT( METHOD_FLAG_EDITOR ),
diff --git a/core/globals.cpp b/core/globals.cpp
index 9e7b357d73..b822f52f15 100644
--- a/core/globals.cpp
+++ b/core/globals.cpp
@@ -1332,17 +1332,18 @@ Variant _GLOBAL_DEF( const String& p_var, const Variant& p_default) {
void Globals::add_singleton(const Singleton &p_singleton) {
singletons.push_back(p_singleton);
+ singleton_ptrs[p_singleton.name]=p_singleton.ptr;
}
Object* Globals::get_singleton_object(const String& p_name) const {
- for(const List<Singleton>::Element *E=singletons.front();E;E=E->next()) {
- if (E->get().name == p_name) {
- return E->get().ptr;
- };
- };
- return NULL;
+ const Map<StringName,Object*>::Element *E=singleton_ptrs.find(p_name);
+ if (!E)
+ return NULL;
+ else
+ return E->get();
+
};
bool Globals::has_singleton(const String& p_name) const {
@@ -1375,6 +1376,25 @@ Vector<String> Globals::get_optimizer_presets() const {
}
+void Globals::_add_property_info_bind(const Dictionary& p_info) {
+
+ ERR_FAIL_COND(!p_info.has("name"));
+ ERR_FAIL_COND(!p_info.has("type"));
+
+ PropertyInfo pinfo;
+ pinfo.name = p_info["name"];
+ ERR_FAIL_COND(!props.has(pinfo.name));
+ pinfo.type = Variant::Type(p_info["type"].operator int());
+ ERR_FAIL_INDEX(pinfo.type, Variant::VARIANT_MAX);
+
+ if (p_info.has("hint"))
+ pinfo.hint = PropertyHint(p_info["hint"].operator int());
+ if (p_info.has("hint_string"))
+ pinfo.hint_string = p_info["hint_string"];
+
+ set_custom_property_info(pinfo.name, pinfo);
+}
+
void Globals::set_custom_property_info(const String& p_prop,const PropertyInfo& p_info) {
ERR_FAIL_COND(!props.has(p_prop));
@@ -1399,6 +1419,7 @@ void Globals::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_order","name"),&Globals::get_order);
ObjectTypeDB::bind_method(_MD("set_persisting","name","enable"),&Globals::set_persisting);
ObjectTypeDB::bind_method(_MD("is_persisting","name"),&Globals::is_persisting);
+ ObjectTypeDB::bind_method(_MD("add_property_info", "hint"),&Globals::_add_property_info_bind);
ObjectTypeDB::bind_method(_MD("clear","name"),&Globals::clear);
ObjectTypeDB::bind_method(_MD("localize_path","path"),&Globals::localize_path);
ObjectTypeDB::bind_method(_MD("globalize_path","path"),&Globals::globalize_path);
@@ -1429,7 +1450,7 @@ Globals::Globals() {
set("application/name","" );
set("application/main_scene","");
- custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"scn,res,xscn,xml,tscn");
+ custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"tscn,scn,xscn,xml,res");
set("application/disable_stdout",false);
set("application/use_shared_user_dir",true);
diff --git a/core/globals.h b/core/globals.h
index 68bb859ace..5e0bdb0e54 100644
--- a/core/globals.h
+++ b/core/globals.h
@@ -91,11 +91,14 @@ protected:
Error _save_settings_binary(const String& p_file,const Map<String,List<String> > &props,const CustomMap& p_custom=CustomMap());
List<Singleton> singletons;
+ Map<StringName,Object*> singleton_ptrs;
Error _save_custom_bnd(const String& p_file);
bool _load_resource_pack(const String& p_pack);
+ void _add_property_info_bind(const Dictionary& p_info);
+
protected:
static void _bind_methods();
diff --git a/core/helper/value_evaluator.h b/core/helper/value_evaluator.h
index a03602bc61..461c505ee7 100644
--- a/core/helper/value_evaluator.h
+++ b/core/helper/value_evaluator.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 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 */
diff --git a/core/hq2x.cpp b/core/hq2x.cpp
index 6495c77b2a..7ebb505d64 100644
--- a/core/hq2x.cpp
+++ b/core/hq2x.cpp
@@ -91,7 +91,7 @@ _FORCE_INLINE_ static bool isDifferent(
#define HQX_MIX_2(C0,C1,W0,W1) \
((((C0 & MASK_RB) * W0 + (C1 & MASK_RB) * W1) / (W0 + W1)) & MASK_RB) | \
((((C0 & MASK_G) * W0 + (C1 & MASK_G) * W1) / (W0 + W1)) & MASK_G) | \
- (((((C0 & MASK_A) >> 8) * W0 + ((C1 & MASK_A) >> 8) * W1) / (W0 + W1)) << 8) & MASK_A
+ ((((((C0 & MASK_A) >> 8) * W0 + ((C1 & MASK_A) >> 8) * W1) / (W0 + W1)) << 8) & MASK_A)
/**
* @brief Mixes three colors using the given weights.
@@ -99,7 +99,7 @@ _FORCE_INLINE_ static bool isDifferent(
#define HQX_MIX_3(C0,C1,C2,W0,W1,W2) \
((((C0 & MASK_RB) * W0 + (C1 & MASK_RB) * W1 + (C2 & MASK_RB) * W2) / (W0 + W1 + W2)) & MASK_RB) | \
((((C0 & MASK_G) * W0 + (C1 & MASK_G) * W1 + (C2 & MASK_G) * W2) / (W0 + W1 + W2)) & MASK_G) | \
- (((((C0 & MASK_A) >> 8) * W0 + ((C1 & MASK_A) >> 8) * W1 + ((C2 & MASK_A) >> 8) * W2) / (W0 + W1 + W2)) << 8) & MASK_A
+ ((((((C0 & MASK_A) >> 8) * W0 + ((C1 & MASK_A) >> 8) * W1 + ((C2 & MASK_A) >> 8) * W2) / (W0 + W1 + W2)) << 8) & MASK_A)
#define MIX_00_4 *output = w[4];
diff --git a/core/image.cpp b/core/image.cpp
index 57496683ef..d6ac3f28ea 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -1735,8 +1735,17 @@ Error Image::_decompress_bc() {
print_line("decompressing bc");
+ int wd=width,ht=height;
+ if (wd%4!=0) {
+ wd+=4-(wd%4);
+ }
+ if (ht%4!=0) {
+ ht+=4-(ht%4);
+ }
+
+
int mm;
- int size = _get_dst_image_size(width,height,FORMAT_RGBA,mm,mipmaps);
+ int size = _get_dst_image_size(wd,ht,FORMAT_RGBA,mm,mipmaps);
DVector<uint8_t> newdata;
newdata.resize(size);
@@ -1746,7 +1755,8 @@ Error Image::_decompress_bc() {
int rofs=0;
int wofs=0;
- int wd=width,ht=height;
+
+ //print_line("width: "+itos(wd)+" height: "+itos(ht));
for(int i=0;i<=mm;i++) {
@@ -2051,6 +2061,11 @@ Error Image::_decompress_bc() {
data=newdata;
format=FORMAT_RGBA;
+ if (wd!=width || ht!=height) {
+ //todo, crop
+ width=wd;
+ height=ht;
+ }
return OK;
}
diff --git a/core/image_quantize.cpp b/core/image_quantize.cpp
index b8d4658fda..f6fe7a88a0 100644
--- a/core/image_quantize.cpp
+++ b/core/image_quantize.cpp
@@ -59,7 +59,6 @@ int Image::MCBlock::get_longest_axis_index() const {
for(int i=0;i<4;i++) {
int d = max_color.color.col[i]-min_color.color.col[i];
- //printf(" ai:%i - %i\n",i,d);
if (d>max_dist) {
max_index=i;
max_dist=d;
@@ -71,13 +70,11 @@ int Image::MCBlock::get_longest_axis_index() const {
int Image::MCBlock::get_longest_axis_length() const {
int max_dist=-1;
- int max_index=0;
for(int i=0;i<4;i++) {
int d = max_color.color.col[i]-min_color.color.col[i];
if (d>max_dist) {
- max_index=i;
max_dist=d;
}
}
@@ -117,8 +114,6 @@ void Image::MCBlock::shrink() {
void Image::quantize() {
- Image::Format orig_format=format;
-
bool has_alpha = detect_alpha()!=ALPHA_NONE;
bool quantize_fast=OS::get_singleton()->has_environment("QUANTIZE_FAST");
diff --git a/core/input_map.cpp b/core/input_map.cpp
index 17e98902a1..3a0f9596f5 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -28,6 +28,7 @@
/*************************************************************************/
#include "input_map.h"
#include "globals.h"
+#include "os/keyboard.h"
InputMap *InputMap::singleton=NULL;
@@ -36,6 +37,7 @@ void InputMap::_bind_methods() {
ObjectTypeDB::bind_method(_MD("has_action","action"),&InputMap::has_action);
ObjectTypeDB::bind_method(_MD("get_action_id","action"),&InputMap::get_action_id);
ObjectTypeDB::bind_method(_MD("get_action_from_id","id"),&InputMap::get_action_from_id);
+ ObjectTypeDB::bind_method(_MD("get_actions"),&InputMap::_get_actions);
ObjectTypeDB::bind_method(_MD("add_action","action"),&InputMap::add_action);
ObjectTypeDB::bind_method(_MD("erase_action","action"),&InputMap::erase_action);
@@ -75,6 +77,35 @@ StringName InputMap::get_action_from_id(int p_id) const {
return input_id_map[p_id];
}
+Array InputMap::_get_actions() {
+
+ Array ret;
+ List<StringName> actions = get_actions();
+ if(actions.empty())
+ return ret;
+
+ for(const List<StringName>::Element *E=actions.front();E;E=E->next()) {
+
+ ret.push_back(E->get());
+ }
+
+ return ret;
+}
+
+List<StringName> InputMap::get_actions() const {
+
+ List<StringName> actions = List<StringName>();
+ if(input_map.empty()){
+ return actions;
+ }
+
+ for (Map<StringName, Action>::Element *E=input_map.front();E;E=E->next()) {
+ actions.push_back(E->key());
+ }
+
+ return actions;
+}
+
List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const InputEvent& p_event) const {
for (List<InputEvent>::Element *E=p_list.front();E;E=E->next()) {
@@ -259,6 +290,10 @@ bool InputMap::event_is_joy_motion_action_pressed(const InputEvent& p_event) con
}
+const Map<StringName, InputMap::Action>& InputMap::get_action_map() const {
+ return input_map;
+}
+
void InputMap::load_from_globals() {
input_map.clear();;
@@ -291,6 +326,67 @@ void InputMap::load_from_globals() {
}
+void InputMap::load_default() {
+
+ InputEvent key;
+ key.type=InputEvent::KEY;
+
+ add_action("ui_accept");
+ key.key.scancode=KEY_RETURN;
+ action_add_event("ui_accept",key);
+ key.key.scancode=KEY_ENTER;
+ action_add_event("ui_accept",key);
+ key.key.scancode=KEY_SPACE;
+ action_add_event("ui_accept",key);
+
+ add_action("ui_select");
+ key.key.scancode=KEY_SPACE;
+ action_add_event("ui_select",key);
+
+ add_action("ui_cancel");
+ key.key.scancode=KEY_ESCAPE;
+ action_add_event("ui_cancel",key);
+
+ add_action("ui_focus_next");
+ key.key.scancode=KEY_TAB;
+ action_add_event("ui_focus_next",key);
+
+ add_action("ui_focus_prev");
+ key.key.scancode=KEY_TAB;
+ key.key.mod.shift=true;
+ action_add_event("ui_focus_prev",key);
+ key.key.mod.shift=false;
+
+ add_action("ui_left");
+ key.key.scancode=KEY_LEFT;
+ action_add_event("ui_left",key);
+
+ add_action("ui_right");
+ key.key.scancode=KEY_RIGHT;
+ action_add_event("ui_right",key);
+
+ add_action("ui_up");
+ key.key.scancode=KEY_UP;
+ action_add_event("ui_up",key);
+
+ add_action("ui_down");
+ key.key.scancode=KEY_DOWN;
+ action_add_event("ui_down",key);
+
+
+ add_action("ui_page_up");
+ key.key.scancode=KEY_PAGEUP;
+ action_add_event("ui_page_up",key);
+
+ add_action("ui_page_down");
+ key.key.scancode=KEY_PAGEDOWN;
+ action_add_event("ui_page_down",key);
+
+// set("display/orientation", "landscape");
+
+
+}
+
InputMap::InputMap() {
ERR_FAIL_COND(singleton);
diff --git a/core/input_map.h b/core/input_map.h
index 5cd1e41922..a224765d8c 100644
--- a/core/input_map.h
+++ b/core/input_map.h
@@ -35,18 +35,21 @@
class InputMap : public Object {
OBJ_TYPE( InputMap, Object );
- static InputMap *singleton;
-
+public:
struct Action {
int id;
List<InputEvent> inputs;
};
+private:
+ static InputMap *singleton;
+
mutable Map<StringName, Action> input_map;
mutable Map<int,StringName> input_id_map;
List<InputEvent>::Element *_find_event(List<InputEvent> &p_list,const InputEvent& p_event) const;
Array _get_action_list(const StringName& p_action);
+ Array _get_actions();
protected:
@@ -59,6 +62,7 @@ public:
bool has_action(const StringName& p_action) const;
int get_action_id(const StringName& p_action) const;
StringName get_action_from_id(int p_id) const;
+ List<StringName> get_actions() const;
void add_action(const StringName& p_action);
void erase_action(const StringName& p_action);
@@ -70,8 +74,9 @@ public:
bool event_is_action(const InputEvent& p_event, const StringName& p_action) const;
bool event_is_joy_motion_action_pressed(const InputEvent& p_event) const;
-
+ const Map<StringName, Action>& get_action_map() const;
void load_from_globals();
+ void load_default();
InputMap();
};
diff --git a/core/io/LICENSE-InfoZip.txt b/core/io/LICENSE-InfoZip.txt
new file mode 100644
index 0000000000..bcfe47e978
--- /dev/null
+++ b/core/io/LICENSE-InfoZip.txt
@@ -0,0 +1,60 @@
+This is version 2007-Mar-4 of the Info-ZIP license.
+The definitive version of this document should be available at
+ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely and
+a copy at http://www.info-zip.org/pub/infozip/license.html.
+
+
+Copyright (c) 1990-2007 Info-ZIP. All rights reserved.
+
+For the purposes of this copyright and license, "Info-ZIP" is defined as
+the following set of individuals:
+
+ Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois,
+ Jean-loup Gailly, Hunter Goatley, Ed Gordon, Ian Gorman, Chris Herborth,
+ Dirk Haase, Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz,
+ David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko,
+ Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs,
+ Kai Uwe Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda,
+ Christian Spieler, Cosmin Truta, Antoine Verheijen, Paul von Behren,
+ Rich Wales, Mike White.
+
+This software is provided "as is," without warranty of any kind, express
+or implied. In no event shall Info-ZIP or its contributors be held liable
+for any direct, indirect, incidental, special or consequential damages
+arising out of the use of or inability to use this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the above disclaimer and the following restrictions:
+
+ 1. Redistributions of source code (in whole or in part) must retain
+ the above copyright notice, definition, disclaimer, and this list
+ of conditions.
+
+ 2. Redistributions in binary form (compiled executables and libraries)
+ must reproduce the above copyright notice, definition, disclaimer,
+ and this list of conditions in documentation and/or other materials
+ provided with the distribution. The sole exception to this condition
+ is redistribution of a standard UnZipSFX binary (including SFXWiz) as
+ part of a self-extracting archive; that is permitted without inclusion
+ of this license, as long as the normal SFX banner has not been removed
+ from the binary or disabled.
+
+ 3. Altered versions--including, but not limited to, ports to new operating
+ systems, existing ports with new graphical interfaces, versions with
+ modified or added functionality, and dynamic, shared, or static library
+ versions not from Info-ZIP--must be plainly marked as such and must not
+ be misrepresented as being the original source or, if binaries,
+ compiled from the original source. Such altered versions also must not
+ be misrepresented as being Info-ZIP releases--including, but not
+ limited to, labeling of the altered versions with the names "Info-ZIP"
+ (or any variation thereof, including, but not limited to, different
+ capitalizations), "Pocket UnZip," "WiZ" or "MacZip" without the
+ explicit permission of Info-ZIP. Such altered versions are further
+ prohibited from misrepresentative use of the Zip-Bugs or Info-ZIP
+ e-mail addresses or the Info-ZIP URL(s), such as to imply Info-ZIP
+ will provide support for the altered versions.
+
+ 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip,"
+ "UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its
+ own source and binary releases.
diff --git a/core/io/LICENSE-MiniZip.txt b/core/io/LICENSE-MiniZip.txt
new file mode 100644
index 0000000000..0e8950f86f
--- /dev/null
+++ b/core/io/LICENSE-MiniZip.txt
@@ -0,0 +1,32 @@
+Credits
+
+ Gilles Vollant - Original MiniZip author
+ Even Rouault - ZIP64 unzip Support
+ Daniel Borca - BZip Compression method support in unzip
+ Mathias Svensson - ZIP64 zip support
+ Mathias Svensson - BZip Compression method support in zip
+
+ This version has been modified for Godot Engine
+
+
+License
+----------------------------------------------------------------------------
+ Condition of use and distribution are the same than zlib :
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+----------------------------------------------------------------------------
diff --git a/core/io/compression.cpp b/core/io/compression.cpp
index a17e358cbb..ca44d24911 100644
--- a/core/io/compression.cpp
+++ b/core/io/compression.cpp
@@ -60,6 +60,10 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,M
strm.avail_in=p_src_size;
int aout = deflateBound(&strm,p_src_size);;
+ /*if (aout>p_src_size) {
+ deflateEnd(&strm);
+ return -1;
+ }*/
strm.avail_out=aout;
strm.next_in=(Bytef*)p_src;
strm.next_out=p_dst;
@@ -107,19 +111,21 @@ int Compression::get_max_compressed_buffer_size(int p_src_size,Mode p_mode){
-void Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p_src, int p_src_size,Mode p_mode){
+int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p_src, int p_src_size,Mode p_mode){
switch(p_mode) {
case MODE_FASTLZ: {
+ int ret_size=0;
+
if (p_dst_max_size<16) {
uint8_t dst[16];
- fastlz_decompress(p_src,p_src_size,dst,16);
+ ret_size = fastlz_decompress(p_src,p_src_size,dst,16);
copymem(p_dst,dst,p_dst_max_size);
} else {
- fastlz_decompress(p_src,p_src_size,p_dst,p_dst_max_size);
+ ret_size = fastlz_decompress(p_src,p_src_size,p_dst,p_dst_max_size);
}
- return;
+ return ret_size;
} break;
case MODE_DEFLATE: {
@@ -130,7 +136,7 @@ void Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *
strm.avail_in= 0;
strm.next_in=Z_NULL;
int err = inflateInit(&strm);
- ERR_FAIL_COND(err!=Z_OK);
+ ERR_FAIL_COND_V(err!=Z_OK,-1);
strm.avail_in=p_src_size;
strm.avail_out=p_dst_max_size;
@@ -138,11 +144,12 @@ void Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *
strm.next_out=p_dst;
err = inflate(&strm,Z_FINISH);
+ int total = strm.total_out;
inflateEnd(&strm);
- ERR_FAIL_COND(err!=Z_STREAM_END);
- return;
+ ERR_FAIL_COND_V(err!=Z_STREAM_END,-1);
+ return total;
} break;
}
- ERR_FAIL();
+ ERR_FAIL_V(-1);
}
diff --git a/core/io/compression.h b/core/io/compression.h
index 07a293c940..e0a4d31a51 100644
--- a/core/io/compression.h
+++ b/core/io/compression.h
@@ -43,7 +43,7 @@ public:
static int compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,Mode p_mode=MODE_FASTLZ);
static int get_max_compressed_buffer_size(int p_src_size,Mode p_mode=MODE_FASTLZ);
- static void decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p_src, int p_src_size,Mode p_mode=MODE_FASTLZ);
+ static int decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p_src, int p_src_size,Mode p_mode=MODE_FASTLZ);
Compression();
};
diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp
index 65b1ca5207..4d4b4d8ee7 100644
--- a/core/io/file_access_encrypted.cpp
+++ b/core/io/file_access_encrypted.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* file_access_encrypted.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 "file_access_encrypted.h"
#include "aes256.h"
#include "md5.h"
diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h
index 3bdcc2dfd0..34926faadf 100644
--- a/core/io/file_access_encrypted.h
+++ b/core/io/file_access_encrypted.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* file_access_encrypted.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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. */
+/*************************************************************************/
#ifndef FILE_ACCESS_ENCRYPTED_H
#define FILE_ACCESS_ENCRYPTED_H
diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp
index 7db3499505..11a425001e 100644
--- a/core/io/file_access_memory.cpp
+++ b/core/io/file_access_memory.cpp
@@ -46,7 +46,7 @@ void FileAccessMemory::register_file(String p_name, Vector<uint8_t> p_data) {
name = Globals::get_singleton()->globalize_path(p_name);
else
name = p_name;
- name = DirAccess::normalize_path(name);
+ //name = DirAccess::normalize_path(name);
(*files)[name] = p_data;
}
@@ -68,7 +68,7 @@ FileAccess* FileAccessMemory::create() {
bool FileAccessMemory::file_exists(const String& p_name) {
String name = fix_path(p_name);
- name = DirAccess::normalize_path(name);
+// name = DirAccess::normalize_path(name);
return files && (files->find(name) != NULL);
}
@@ -87,7 +87,7 @@ Error FileAccessMemory::_open(const String& p_path, int p_mode_flags) {
ERR_FAIL_COND_V(!files, ERR_FILE_NOT_FOUND);
String name = fix_path(p_path);
- name = DirAccess::normalize_path(name);
+// name = DirAccess::normalize_path(name);
Map<String, Vector<uint8_t> >::Element* E = files->find(name);
ERR_FAIL_COND_V(!E, ERR_FILE_NOT_FOUND);
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 3520680118..2a831dd992 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -29,8 +29,6 @@
#include "http_client.h"
#include "io/stream_peer_ssl.h"
-VARIANT_ENUM_CAST(HTTPClient::Status);
-
Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl,bool p_verify_host){
@@ -76,6 +74,7 @@ void HTTPClient::set_connection(const Ref<StreamPeer>& p_connection){
close();
connection=p_connection;
+ status=STATUS_CONNECTED;
}
diff --git a/core/io/http_client.h b/core/io/http_client.h
index a9cfb1ed73..32d2e72101 100644
--- a/core/io/http_client.h
+++ b/core/io/http_client.h
@@ -40,7 +40,7 @@ class HTTPClient : public Reference {
OBJ_TYPE(HTTPClient,Reference);
public:
- enum RespondeCode {
+ enum ResponseCode {
// 1xx informational
RESPONSE_CONTINUE = 100,
@@ -201,5 +201,6 @@ public:
};
VARIANT_ENUM_CAST(HTTPClient::Method);
+VARIANT_ENUM_CAST(HTTPClient::Status);
#endif // HTTP_CLIENT_H
diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp
index 05bad97e90..ac6c00dc61 100644
--- a/core/io/image_loader.cpp
+++ b/core/io/image_loader.cpp
@@ -51,7 +51,7 @@ Error ImageLoader::load_image(String p_file,Image *p_image, FileAccess *p_custom
Error err;
f=FileAccess::open(p_file,FileAccess::READ,&err);
if (!f) {
- print_line("ERROR OPENING FILE: "+p_file);
+ ERR_PRINTS("Error opening file: "+p_file);
return err;
}
}
@@ -76,7 +76,6 @@ Error ImageLoader::load_image(String p_file,Image *p_image, FileAccess *p_custom
}
- print_line("NO LOADER?");
if (!p_custom)
memdelete(f);
diff --git a/core/io/ioapi.c b/core/io/ioapi.c
index 8818199f0b..d6063a5fe6 100644
--- a/core/io/ioapi.c
+++ b/core/io/ioapi.c
@@ -6,7 +6,7 @@
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read MiniZip_info.txt
+ For more info read LICENSE-MiniZip.txt
*/
diff --git a/core/io/ioapi.h b/core/io/ioapi.h
index 24bf612617..cb6cb7e766 100644
--- a/core/io/ioapi.h
+++ b/core/io/ioapi.h
@@ -5,7 +5,7 @@
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read MiniZip_info.txt
+ For more info read LICENSE-MiniZip.txt
Changes
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 60617e1237..c9bd38c654 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -685,7 +685,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
if (count) {
varray.resize(count);
DVector<Vector2>::Write w = varray.write();
- const float *r = (const float*)buf;
for(int i=0;i<(int)count;i++) {
@@ -724,7 +723,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
if (count) {
varray.resize(count);
DVector<Vector3>::Write w = varray.write();
- const float *r = (const float*)buf;
for(int i=0;i<(int)count;i++) {
@@ -764,7 +762,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
if (count) {
carray.resize(count);
DVector<Color>::Write w = carray.write();
- const float *r = (const float*)buf;
for(int i=0;i<(int)count;i++) {
diff --git a/core/io/networked_multiplayer_peer.cpp b/core/io/networked_multiplayer_peer.cpp
new file mode 100644
index 0000000000..47e5f3729c
--- /dev/null
+++ b/core/io/networked_multiplayer_peer.cpp
@@ -0,0 +1,41 @@
+#include "networked_multiplayer_peer.h"
+
+
+void NetworkedMultiplayerPeer::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("set_transfer_mode","mode"), &NetworkedMultiplayerPeer::set_transfer_mode );
+ ObjectTypeDB::bind_method(_MD("set_target_peer","id"), &NetworkedMultiplayerPeer::set_target_peer );
+
+ ObjectTypeDB::bind_method(_MD("get_packet_peer"), &NetworkedMultiplayerPeer::get_packet_peer );
+
+ ObjectTypeDB::bind_method(_MD("poll"), &NetworkedMultiplayerPeer::poll );
+
+ ObjectTypeDB::bind_method(_MD("get_connection_status"), &NetworkedMultiplayerPeer::get_connection_status );
+ ObjectTypeDB::bind_method(_MD("get_unique_id"), &NetworkedMultiplayerPeer::get_unique_id );
+
+ ObjectTypeDB::bind_method(_MD("set_refuse_new_connections","enable"), &NetworkedMultiplayerPeer::set_refuse_new_connections );
+ ObjectTypeDB::bind_method(_MD("is_refusing_new_connections"), &NetworkedMultiplayerPeer::is_refusing_new_connections );
+
+ BIND_CONSTANT( TRANSFER_MODE_UNRELIABLE );
+ BIND_CONSTANT( TRANSFER_MODE_UNRELIABLE_ORDERED );
+ BIND_CONSTANT( TRANSFER_MODE_RELIABLE );
+
+ BIND_CONSTANT( CONNECTION_DISCONNECTED );
+ BIND_CONSTANT( CONNECTION_CONNECTING );
+ BIND_CONSTANT( CONNECTION_CONNECTED );
+
+ BIND_CONSTANT( TARGET_PEER_BROADCAST );
+ BIND_CONSTANT( TARGET_PEER_SERVER );
+
+
+ ADD_SIGNAL( MethodInfo("peer_connected",PropertyInfo(Variant::INT,"id")));
+ ADD_SIGNAL( MethodInfo("peer_disconnected",PropertyInfo(Variant::INT,"id")));
+ ADD_SIGNAL( MethodInfo("server_disconnected"));
+ ADD_SIGNAL( MethodInfo("connection_succeeded") );
+ ADD_SIGNAL( MethodInfo("connection_failed") );
+}
+
+NetworkedMultiplayerPeer::NetworkedMultiplayerPeer() {
+
+
+}
diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h
new file mode 100644
index 0000000000..485200a9a9
--- /dev/null
+++ b/core/io/networked_multiplayer_peer.h
@@ -0,0 +1,54 @@
+#ifndef NETWORKED_MULTIPLAYER_PEER_H
+#define NETWORKED_MULTIPLAYER_PEER_H
+
+#include "io/packet_peer.h"
+
+class NetworkedMultiplayerPeer : public PacketPeer {
+
+ OBJ_TYPE(NetworkedMultiplayerPeer,PacketPeer);
+
+protected:
+ static void _bind_methods();
+public:
+
+ enum {
+ TARGET_PEER_BROADCAST=0,
+ TARGET_PEER_SERVER=1
+ };
+ enum TransferMode {
+ TRANSFER_MODE_UNRELIABLE,
+ TRANSFER_MODE_UNRELIABLE_ORDERED,
+ TRANSFER_MODE_RELIABLE,
+ };
+
+ enum ConnectionStatus {
+ CONNECTION_DISCONNECTED,
+ CONNECTION_CONNECTING,
+ CONNECTION_CONNECTED,
+ };
+
+
+ virtual void set_transfer_mode(TransferMode p_mode)=0;
+ virtual void set_target_peer(int p_peer_id)=0;
+
+ virtual int get_packet_peer() const=0;
+
+ virtual bool is_server() const=0;
+
+ virtual void poll()=0;
+
+ virtual int get_unique_id() const=0;
+
+ virtual void set_refuse_new_connections(bool p_enable)=0;
+ virtual bool is_refusing_new_connections() const=0;
+
+
+ virtual ConnectionStatus get_connection_status() const=0;
+
+ NetworkedMultiplayerPeer();
+};
+
+VARIANT_ENUM_CAST( NetworkedMultiplayerPeer::TransferMode )
+VARIANT_ENUM_CAST( NetworkedMultiplayerPeer::ConnectionStatus )
+
+#endif // NetworkedMultiplayerPeer_H
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 22b8bc0b39..8e96697ac9 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -126,7 +126,7 @@ Error PacketPeer::_get_packet_error() const {
void PacketPeer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_var"),&PacketPeer::_bnd_get_var);
+ ObjectTypeDB::bind_method(_MD("get_var:Variant"),&PacketPeer::_bnd_get_var);
ObjectTypeDB::bind_method(_MD("put_var", "var:Variant"),&PacketPeer::put_var);
ObjectTypeDB::bind_method(_MD("get_packet"),&PacketPeer::_get_packet);
ObjectTypeDB::bind_method(_MD("put_packet:Error", "buffer"),&PacketPeer::_put_packet);
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
index 83217ffc41..efc619e414 100644
--- a/core/io/packet_peer_udp.cpp
+++ b/core/io/packet_peer_udp.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* packet_peer_udp.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 "packet_peer_udp.h"
#include "io/ip.h"
diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h
index 73ff487b19..70d92834fc 100644
--- a/core/io/packet_peer_udp.h
+++ b/core/io/packet_peer_udp.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* packet_peer_udp.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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. */
+/*************************************************************************/
#ifndef PACKET_PEER_UDP_H
#define PACKET_PEER_UDP_H
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 58f3a4df2b..0544fd6ba8 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -447,13 +447,17 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
} break;
case VARIANT_INPUT_EVENT: {
+ InputEvent ev;
+ ev.type=f->get_32(); //will only work for null though.
+ r_v=ev;
+
} break;
case VARIANT_DICTIONARY: {
- uint32_t len=f->get_32();
- Dictionary d(len&0x80000000); //last bit means shared
- len&=0x7FFFFFFF;
- for(uint32_t i=0;i<len;i++) {
+ uint32_t len=f->get_32();
+ Dictionary d(len&0x80000000); //last bit means shared
+ len&=0x7FFFFFFF;
+ for(uint32_t i=0;i<len;i++) {
Variant key;
Error err = parse_variant(key);
ERR_FAIL_COND_V(err,ERR_FILE_CORRUPT);
@@ -466,11 +470,11 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
} break;
case VARIANT_ARRAY: {
- uint32_t len=f->get_32();
- Array a(len&0x80000000); //last bit means shared
- len&=0x7FFFFFFF;
+ uint32_t len=f->get_32();
+ Array a(len&0x80000000); //last bit means shared
+ len&=0x7FFFFFFF;
a.resize(len);
- for(uint32_t i=0;i<len;i++) {
+ for(uint32_t i=0;i<len;i++) {
Variant val;
Error err = parse_variant(val);
ERR_FAIL_COND_V(err,ERR_FILE_CORRUPT);
@@ -1105,14 +1109,9 @@ void ResourceFormatLoaderBinary::get_recognized_extensions_for_type(const String
for(List<String>::Element *E=extensions.front();E;E=E->next()) {
String ext = E->get().to_lower();
- if (ext=="res")
- continue;
-// p_extensions->push_back("x"+ext);
p_extensions->push_back(ext);
}
- p_extensions->push_back("res");
-
}
void ResourceFormatLoaderBinary::get_recognized_extensions(List<String> *p_extensions) const{
@@ -1122,12 +1121,9 @@ void ResourceFormatLoaderBinary::get_recognized_extensions(List<String> *p_exten
for(List<String>::Element *E=extensions.front();E;E=E->next()) {
String ext = E->get().to_lower();
- if (ext=="res")
- continue;
p_extensions->push_back(ext);
}
- p_extensions->push_back("res");
}
bool ResourceFormatLoaderBinary::handles_type(const String& p_type) const{
@@ -1733,7 +1729,9 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property,
case Variant::INPUT_EVENT: {
f->store_32(VARIANT_INPUT_EVENT);
- WARN_PRINT("Can't save InputEvent (maybe it could..)");
+ InputEvent event=p_property;
+ f->store_32(0); //event type none, nothing else suported for now.
+
} break;
case Variant::DICTIONARY: {
@@ -2177,6 +2175,9 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
if (takeover_paths) {
r->set_path(p_path+"::"+itos(r->get_subindex()),true);
}
+#ifdef TOOLS_ENABLED
+ r->set_edited(false);
+#endif
} else {
save_unicode_string(r->get_path()); //actual external
}
@@ -2270,16 +2271,8 @@ bool ResourceFormatSaverBinary::recognize(const RES& p_resource) const {
void ResourceFormatSaverBinary::get_recognized_extensions(const RES& p_resource,List<String> *p_extensions) const {
-
- //here comes the sun, lalalala
String base = p_resource->get_base_extension().to_lower();
- if (base!="res") {
-
- p_extensions->push_back(base);
- }
-
- p_extensions->push_back("res");
-
+ p_extensions->push_back(base);
}
diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp
index a42a922baf..44fbaf02ac 100644
--- a/core/io/resource_format_xml.cpp
+++ b/core/io/resource_format_xml.cpp
@@ -1862,8 +1862,6 @@ void ResourceInteractiveLoaderXML::open(FileAccess *p_f) {
}
int major = version.get_slicec('.',0).to_int();
- int minor = version.get_slicec('.',1).to_int();
-
if (major>VERSION_MAJOR) {
error=ERR_FILE_UNRECOGNIZED;
@@ -2802,6 +2800,10 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res
if (takeover_paths) {
res->set_path(p_path+"::"+itos(idx),true);
}
+#ifdef TOOLS_ENABLED
+ res->set_edited(false);
+#endif
+
}
write_string("\n",false);
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index b547dc0e85..08b4139047 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -319,7 +319,11 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
if (OS::get_singleton()->is_stdout_verbose())
print_line("load resource: "+local_path+" (cached)");
- return RES( ResourceCache::get(local_path ) );
+ Ref<Resource> res_cached = ResourceCache::get(local_path);
+ Ref<ResourceInteractiveLoaderDefault> ril = Ref<ResourceInteractiveLoaderDefault>(memnew(ResourceInteractiveLoaderDefault));
+
+ ril->resource = res_cached;
+ return ril;
}
if (OS::get_singleton()->is_stdout_verbose())
@@ -356,10 +360,18 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
}
-void ResourceLoader::add_resource_format_loader(ResourceFormatLoader *p_format_loader) {
+void ResourceLoader::add_resource_format_loader(ResourceFormatLoader *p_format_loader, bool p_at_front) {
ERR_FAIL_COND( loader_count >= MAX_LOADERS );
- loader[loader_count++]=p_format_loader;
+ if (p_at_front) {
+ for(int i=loader_count;i>0;i--) {
+ loader[i]=loader[i-1];
+ }
+ loader[0]=p_format_loader;
+ loader_count++;
+ } else {
+ loader[loader_count++]=p_format_loader;
+ }
}
void ResourceLoader::get_dependencies(const String& p_path, List<String> *p_dependencies, bool p_add_types) {
@@ -439,7 +451,6 @@ String ResourceLoader::get_resource_type(const String &p_path) {
String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
String extension=remapped_path.extension();
- bool found=false;
for (int i=0;i<loader_count;i++) {
String result = loader[i]->get_resource_type(local_path);
diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h
index 6404e6cb13..f976a43d91 100644
--- a/core/io/resource_loader.h
+++ b/core/io/resource_loader.h
@@ -102,7 +102,7 @@ public:
static Ref<ResourceImportMetadata> load_import_metadata(const String &p_path);
static void get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions);
- static void add_resource_format_loader(ResourceFormatLoader *p_format_loader);
+ static void add_resource_format_loader(ResourceFormatLoader *p_format_loader,bool p_at_front=false);
static String get_resource_type(const String &p_path);
static void get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types=false);
static Error rename_dependencies(const String &p_path,const Map<String,String>& p_map);
diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp
index 8d78ecabbf..2ead405440 100644
--- a/core/io/resource_saver.cpp
+++ b/core/io/resource_saver.cpp
@@ -116,10 +116,20 @@ void ResourceSaver::get_recognized_extensions(const RES& p_resource,List<String>
}
-void ResourceSaver::add_resource_format_saver(ResourceFormatSaver *p_format_saver) {
+void ResourceSaver::add_resource_format_saver(ResourceFormatSaver *p_format_saver, bool p_at_front) {
ERR_FAIL_COND( saver_count >= MAX_SAVERS );
- saver[saver_count++]=p_format_saver;
+
+ if (p_at_front) {
+ for(int i=saver_count;i>0;i--) {
+ saver[i]=saver[i-1];
+ }
+ saver[0]=p_format_saver;
+ saver_count++;
+ } else {
+ saver[saver_count++]=p_format_saver;
+ }
+
}
diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h
index 97500c46f4..b05ae23afc 100644
--- a/core/io/resource_saver.h
+++ b/core/io/resource_saver.h
@@ -80,7 +80,7 @@ public:
static Error save(const String &p_path,const RES& p_resource,uint32_t p_flags=0);
static void get_recognized_extensions(const RES& p_resource,List<String> *p_extensions);
- static void add_resource_format_saver(ResourceFormatSaver *p_format_saver);
+ static void add_resource_format_saver(ResourceFormatSaver *p_format_saver,bool p_at_front=false);
static void set_timestamp_on_save(bool p_timestamp) { timestamp_on_save=p_timestamp; }
static void set_save_callback(ResourceSavedCallback p_callback);
diff --git a/core/io/sha-README.md b/core/io/sha-README.md
new file mode 100644
index 0000000000..27a73cffe7
--- /dev/null
+++ b/core/io/sha-README.md
@@ -0,0 +1,5 @@
+SHA256
+======
+
+SHA-256 implementation to compliment a portable byte-oriented AES-256
+implementation in C at http://www.literatecode.com/aes256
diff --git a/core/io/sha256.c b/core/io/sha256.c
new file mode 100644
index 0000000000..68a4339af9
--- /dev/null
+++ b/core/io/sha256.c
@@ -0,0 +1,245 @@
+/*
+* SHA-256 implementation.
+*
+* Copyright (c) 2010 Ilya O. Levin, http://www.literatecode.com
+*
+* Permission to use, copy, modify, and distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+#define SWAP_BYTES
+// #define USE_STD_MEMCPY
+// #define SELF_TEST
+
+#ifdef USE_STD_MEMCPY
+#include <string.h>
+#endif
+#include "sha256.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RL(x,n) (((x) << n) | ((x) >> (32 - n)))
+#define RR(x,n) (((x) >> n) | ((x) << (32 - n)))
+
+#define S0(x) (RR((x), 2) ^ RR((x),13) ^ RR((x),22))
+#define S1(x) (RR((x), 6) ^ RR((x),11) ^ RR((x),25))
+#define G0(x) (RR((x), 7) ^ RR((x),18) ^ ((x) >> 3))
+#define G1(x) (RR((x),17) ^ RR((x),19) ^ ((x) >> 10))
+
+#ifdef SWAP_BYTES
+#define BSWP(x,y) _bswapw((uint32_t *)(x), (uint32_t)(y))
+#else
+#define BSWP(p,n)
+#endif
+#ifdef USE_STD_MEMCPY
+#define MEMCP(x,y,z) memcpy((x),(y),(z))
+#else
+#define MEMCP(x,y,z) _memcp((x),(y),(z))
+#endif
+
+#ifndef __cdecl
+#define __cdecl
+#endif
+
+static const uint32_t K[64] = {
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+};
+
+/* -------------------------------------------------------------------------- */
+static void _bswapw(uint32_t *p, uint32_t i)
+{
+ while (i--) p[i] = (RR(p[i],24) & 0x00ff00ff) | (RR(p[i],8) & 0xff00ff00);
+
+} /* _bswapw */
+
+/* -------------------------------------------------------------------------- */
+#ifndef USE_STD_MEMCPY
+void * __cdecl _memcp (void *d, const void *s, uint32_t sz)
+{
+ void *rv = d;
+
+ while (sz--) *(char *)d = *(char *)s, d = (char *)d + 1, s = (char *)s + 1;
+
+ return(rv);
+} /* _memcp */
+#endif
+
+/* -------------------------------------------------------------------------- */
+static void _rtrf(uint32_t *b, uint32_t *p, uint32_t i, uint32_t j)
+{
+ #define B(x, y) b[(x-y) & 7]
+ #define P(x, y) p[(x+y) & 15]
+
+ B(7,i) += (j ? (p[i & 15] += G1(P(i,14)) + P(i,9) + G0(P(i,1))) : p[i & 15])
+ + K[i+j] + S1(B(4,i))
+ + (B(6,i) ^ (B(4,i) & (B(5,i) ^ B(6,i))));
+ B(3,i) += B(7,i);
+ B(7,i) += S0(B(0,i)) + ( (B(0,i) & B(1,i)) | (B(2,i) & (B(0,i) ^ B(1,i))) );
+
+ #undef P
+ #undef B
+} /* _rtrf */
+
+/* -------------------------------------------------------------------------- */
+static void _hash(sha256_context *ctx)
+{
+ uint32_t b[8], *p, j;
+
+ b[0] = ctx->hash[0]; b[1] = ctx->hash[1]; b[2] = ctx->hash[2];
+ b[3] = ctx->hash[3]; b[4] = ctx->hash[4]; b[5] = ctx->hash[5];
+ b[6] = ctx->hash[6]; b[7] = ctx->hash[7];
+
+ for (p = ctx->buf, j = 0; j < 64; j += 16)
+ _rtrf(b, p, 0, j), _rtrf(b, p, 1, j), _rtrf(b, p, 2, j),
+ _rtrf(b, p, 3, j), _rtrf(b, p, 4, j), _rtrf(b, p, 5, j),
+ _rtrf(b, p, 6, j), _rtrf(b, p, 7, j), _rtrf(b, p, 8, j),
+ _rtrf(b, p, 9, j), _rtrf(b, p, 10, j), _rtrf(b, p, 11, j),
+ _rtrf(b, p, 12, j), _rtrf(b, p, 13, j), _rtrf(b, p, 14, j),
+ _rtrf(b, p, 15, j);
+
+ ctx->hash[0] += b[0]; ctx->hash[1] += b[1]; ctx->hash[2] += b[2];
+ ctx->hash[3] += b[3]; ctx->hash[4] += b[4]; ctx->hash[5] += b[5];
+ ctx->hash[6] += b[6]; ctx->hash[7] += b[7];
+
+} /* _hash */
+
+/* -------------------------------------------------------------------------- */
+void sha256_init(sha256_context ctx[1])
+{
+ ctx->len[0] = ctx->len[1] = 0;
+ ctx->hash[0] = 0x6a09e667; ctx->hash[1] = 0xbb67ae85;
+ ctx->hash[2] = 0x3c6ef372; ctx->hash[3] = 0xa54ff53a;
+ ctx->hash[4] = 0x510e527f; ctx->hash[5] = 0x9b05688c;
+ ctx->hash[6] = 0x1f83d9ab; ctx->hash[7] = 0x5be0cd19;
+
+} /* sha256_init */
+
+/* -------------------------------------------------------------------------- */
+void sha256_hash(sha256_context *ctx, uint8_t *dat, uint32_t sz)
+{
+ register uint32_t i = ctx->len[0] & 63, l, j;
+
+ if ((ctx->len[0] += sz) < sz) ++(ctx->len[1]);
+
+ for (j = 0, l = 64-i; sz >= l; j += l, sz -= l, l = 64, i = 0)
+ {
+ MEMCP(&ctx->buf[i], &dat[j], l);
+ BSWP(ctx->buf, 16 );
+ _hash(ctx);
+ }
+ MEMCP(&ctx->buf[i], &dat[j], sz);
+
+} /* _hash */
+
+/* -------------------------------------------------------------------------- */
+void sha256_done(sha256_context *ctx, uint8_t *buf)
+{
+ uint32_t i = (uint32_t)(ctx->len[0] & 63), j = ((~i) & 3) << 3;
+
+ BSWP(ctx->buf, (i + 3) >> 2);
+
+ ctx->buf[i >> 2] &= 0xffffff80 << j; /* add padding */
+ ctx->buf[i >> 2] |= 0x00000080 << j;
+
+ if (i < 56) i = (i >> 2) + 1;
+ else ctx->buf[15] ^= (i < 60) ? ctx->buf[15] : 0, _hash(ctx), i = 0;
+
+ while (i < 14) ctx->buf[i++] = 0;
+
+ ctx->buf[14] = (ctx->len[1] << 3)|(ctx->len[0] >> 29); /* add length */
+ ctx->buf[15] = ctx->len[0] << 3;
+
+ _hash(ctx);
+
+ for (i = 0; i < 32; i++)
+ ctx->buf[i % 16] = 0, /* may remove this line in case of a DIY cleanup */
+ buf[i] = (uint8_t)(ctx->hash[i >> 2] >> ((~i & 3) << 3));
+
+} /* sha256_done */
+
+
+#ifdef SELF_TEST
+#pragma warning (push, 0)
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#pragma warning(pop)
+
+char *buf[] = {
+ "",
+ "e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855",
+
+ "abc",
+ "ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad",
+
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ "248d6a61 d20638b8 e5c02693 0c3e6039 a33ce459 64ff2167 f6ecedd4 19db06c1",
+
+ "The quick brown fox jumps over the lazy dog",
+ "d7a8fbb3 07d78094 69ca9abc b0082e4f 8d5651e4 6d3cdb76 2d02d0bf 37c9e592",
+
+ "The quick brown fox jumps over the lazy cog", /* avalanche effect test */
+ "e4c4d8f3 bf76b692 de791a17 3e053211 50f7a345 b46484fe 427f6acc 7ecc81be",
+
+ "bhn5bjmoniertqea40wro2upyflkydsibsk8ylkmgbvwi420t44cq034eou1szc1k0mk46oeb7ktzmlxqkbte2sy",
+ "9085df2f 02e0cc45 5928d0f5 1b27b4bf 1d9cd260 a66ed1fd a11b0a3f f5756d99"
+};
+
+int main(int argc, char *argv[])
+{
+ sha256_context ctx;
+ uint8_t hv[32];
+ uint32_t i, j;
+
+ for (j = 0; j < (sizeof(buf)/sizeof(buf[0])); j += 2)
+ {
+ sha256_init(&ctx);
+ sha256_hash(&ctx, (uint8_t *)buf[j], (uint32_t)strlen(buf[j]));
+ sha256_done(&ctx, hv);
+ printf("input = %s\ndigest: %s\nresult: ", buf[j], buf[j+1]);
+ for (i = 0; i < 32; i++) printf("%02x%s", hv[i], ((i%4)==3)?" ":"");
+ printf("\n\n");
+ }
+
+ for (j = 1; j < (uint32_t)argc; j++)
+ {
+ printf("argv[%d]: %s\nresult: ", (int)j, argv[j]);
+ sha256_init(&ctx);
+ sha256_hash(&ctx, (uint8_t *)argv[j], (uint32_t)strlen(argv[j]));
+ sha256_done(&ctx, hv);
+ for (i = 0; i < 32; i++) printf("%02x%s", hv[i], ((i%4)==3)?" ":"");
+ printf("\n\n");
+ }
+
+ return 0;
+} /* main */
+#endif
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/core/io/sha256.h b/core/io/sha256.h
new file mode 100644
index 0000000000..e19e56b4cc
--- /dev/null
+++ b/core/io/sha256.h
@@ -0,0 +1,50 @@
+/*
+* SHA-256 implementation.
+*
+* Copyright (c) 2010 Ilya O. Levin, http://www.literatecode.com
+*
+* Permission to use, copy, modify, and distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+#ifdef _MSC_VER
+#ifndef uint8_t
+typedef unsigned __int8 uint8_t;
+#endif
+#ifndef uint32_t
+typedef unsigned __int32 uint32_t;
+#endif
+#ifndef uint64_t
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#endif
+#else
+#include <stdint.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct {
+ uint32_t buf[16];
+ uint32_t hash[8];
+ uint32_t len[2];
+ } sha256_context;
+
+ void sha256_init(sha256_context *);
+ void sha256_hash(sha256_context *, uint8_t * /* data */, uint32_t /* len */);
+ void sha256_done(sha256_context *, uint8_t * /* hash */);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index 2a9dff86f8..baaeacaf18 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -222,6 +222,7 @@ void StreamPeer::put_double(double p_val){
void StreamPeer::put_utf8_string(const String& p_string) {
CharString cs=p_string.utf8();
+ put_u32(p_string.length());
put_data((const uint8_t*)cs.get_data(),cs.length());
}
@@ -348,8 +349,10 @@ String StreamPeer::get_string(int p_bytes){
ERR_FAIL_COND_V(p_bytes<0,String());
Vector<char> buf;
- buf.resize(p_bytes+1);
- get_data((uint8_t*)&buf[0],p_bytes);
+ Error err = buf.resize(p_bytes+1);
+ ERR_FAIL_COND_V(err!=OK,String());
+ err = get_data((uint8_t*)&buf[0],p_bytes);
+ ERR_FAIL_COND_V(err!=OK,String());
buf[p_bytes]=0;
return buf.ptr();
@@ -357,11 +360,12 @@ String StreamPeer::get_string(int p_bytes){
String StreamPeer::get_utf8_string(int p_bytes){
ERR_FAIL_COND_V(p_bytes<0,String());
- ERR_FAIL_COND_V(p_bytes<0,String());
Vector<uint8_t> buf;
- buf.resize(p_bytes);
- get_data(buf.ptr(),p_bytes);
+ Error err = buf.resize(p_bytes);
+ ERR_FAIL_COND_V(err!=OK,String());
+ err = get_data(buf.ptr(),p_bytes);
+ ERR_FAIL_COND_V(err!=OK,String());
String ret;
ret.parse_utf8((const char*)buf.ptr(),buf.size());
@@ -372,8 +376,10 @@ Variant StreamPeer::get_var(){
int len = get_32();
Vector<uint8_t> var;
- var.resize(len);
- get_data(var.ptr(),len);
+ Error err = var.resize(len);
+ ERR_FAIL_COND_V(err!=OK,Variant());
+ err = get_data(var.ptr(),len);
+ ERR_FAIL_COND_V(err!=OK,Variant());
Variant ret;
decode_variant(ret,var.ptr(),len);
@@ -421,3 +427,128 @@ void StreamPeer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_utf8_string","bytes"),&StreamPeer::get_utf8_string);
ObjectTypeDB::bind_method(_MD("get_var:Variant"),&StreamPeer::get_var);
}
+////////////////////////////////
+
+
+void StreamPeerBuffer::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("seek","pos"),&StreamPeerBuffer::seek);
+ ObjectTypeDB::bind_method(_MD("get_size"),&StreamPeerBuffer::get_size);
+ ObjectTypeDB::bind_method(_MD("get_pos"),&StreamPeerBuffer::get_pos);
+ ObjectTypeDB::bind_method(_MD("resize","size"),&StreamPeerBuffer::resize);
+ ObjectTypeDB::bind_method(_MD("set_data_array","data"),&StreamPeerBuffer::set_data_array);
+ ObjectTypeDB::bind_method(_MD("get_data_array"),&StreamPeerBuffer::get_data_array);
+ ObjectTypeDB::bind_method(_MD("clear"),&StreamPeerBuffer::clear);
+ ObjectTypeDB::bind_method(_MD("duplicate:StreamPeerBuffer"),&StreamPeerBuffer::duplicate);
+
+}
+
+
+Error StreamPeerBuffer::put_data(const uint8_t* p_data,int p_bytes) {
+
+ if (p_bytes<=0)
+ return OK;
+
+ if (pointer+p_bytes > data.size()) {
+ data.resize(pointer+p_bytes);
+
+ }
+
+ DVector<uint8_t>::Write w = data.write();
+ copymem(&w[pointer],p_data,p_bytes);
+
+ pointer+=p_bytes;
+ return OK;
+}
+
+Error StreamPeerBuffer::put_partial_data(const uint8_t* p_data,int p_bytes, int &r_sent){
+
+ r_sent=p_bytes;
+ return put_data(p_data,p_bytes);
+}
+
+Error StreamPeerBuffer::get_data(uint8_t* p_buffer, int p_bytes){
+
+ int recv;
+ get_partial_data(p_buffer,p_bytes,recv);
+ if (recv!=p_bytes)
+ return ERR_INVALID_PARAMETER;
+
+ return OK;
+
+}
+Error StreamPeerBuffer::get_partial_data(uint8_t* p_buffer, int p_bytes,int &r_received){
+
+
+ if (pointer+p_bytes > data.size()) {
+ r_received=data.size()-pointer;
+ if (r_received<=0) {
+ r_received=0;
+ return OK; //you got 0
+ }
+ } else {
+ r_received=p_bytes;
+ }
+
+ DVector<uint8_t>::Read r = data.read();
+ copymem(p_buffer,r.ptr(),r_received);
+}
+
+int StreamPeerBuffer::get_available_bytes() const {
+
+ return data.size()-pointer;
+}
+
+void StreamPeerBuffer::seek(int p_pos){
+
+ ERR_FAIL_COND(p_pos < 0);
+ ERR_FAIL_COND(p_pos > data.size());
+ pointer=p_pos;
+}
+int StreamPeerBuffer::get_size() const{
+
+ return data.size();
+}
+
+int StreamPeerBuffer::get_pos() const {
+
+ return pointer;
+}
+
+void StreamPeerBuffer::resize(int p_size){
+
+ data.resize(p_size);
+}
+
+void StreamPeerBuffer::set_data_array(const DVector<uint8_t> & p_data){
+
+ data=p_data;
+ pointer=0;
+}
+
+DVector<uint8_t> StreamPeerBuffer::get_data_array() const{
+
+ return data;
+}
+
+
+void StreamPeerBuffer::clear() {
+
+ data.resize(0);
+ pointer=0;
+}
+
+
+Ref<StreamPeerBuffer> StreamPeerBuffer::duplicate() const {
+
+ Ref<StreamPeerBuffer> spb;
+ spb.instance();
+ spb->data=data;
+ return spb;
+}
+
+
+StreamPeerBuffer::StreamPeerBuffer() {
+
+ pointer=0;
+}
diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h
index 970e6695a5..f28e6f594d 100644
--- a/core/io/stream_peer.h
+++ b/core/io/stream_peer.h
@@ -91,4 +91,40 @@ public:
StreamPeer() { big_endian=false; }
};
+
+class StreamPeerBuffer : public StreamPeer {
+
+ OBJ_TYPE(StreamPeerBuffer,StreamPeer);
+
+ DVector<uint8_t> data;
+ int pointer;
+protected:
+
+ static void _bind_methods();
+public:
+ Error put_data(const uint8_t* p_data,int p_bytes);
+ Error put_partial_data(const uint8_t* p_data,int p_bytes, int &r_sent);
+
+ Error get_data(uint8_t* p_buffer, int p_bytes);
+ Error get_partial_data(uint8_t* p_buffer, int p_bytes,int &r_received);
+
+ virtual int get_available_bytes() const;
+
+ void seek(int p_pos);
+ int get_size() const;
+ int get_pos() const;
+ void resize(int p_size);
+
+
+ void set_data_array(const DVector<uint8_t> & p_data);
+ DVector<uint8_t> get_data_array() const;
+
+ void clear();
+
+ Ref<StreamPeerBuffer> duplicate() const;
+
+ StreamPeerBuffer();
+};
+
+
#endif // STREAM_PEER_H
diff --git a/core/io/stream_peer_ssl.cpp b/core/io/stream_peer_ssl.cpp
index 2114993783..a58be84225 100644
--- a/core/io/stream_peer_ssl.cpp
+++ b/core/io/stream_peer_ssl.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* stream_peer_ssl.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 "stream_peer_ssl.h"
diff --git a/core/io/stream_peer_ssl.h b/core/io/stream_peer_ssl.h
index 4b1c8e93bb..3435a9a445 100644
--- a/core/io/stream_peer_ssl.h
+++ b/core/io/stream_peer_ssl.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* stream_peer_ssl.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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. */
+/*************************************************************************/
#ifndef STREAM_PEER_SSL_H
#define STREAM_PEER_SSL_H
diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp
index 4ddb276a27..a22c57b941 100644
--- a/core/io/translation_loader_po.cpp
+++ b/core/io/translation_loader_po.cpp
@@ -47,7 +47,6 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
String msg_id;
String msg_str;
String config;
- int msg_line=0;
if (r_error)
*r_error=ERR_FILE_CORRUPT;
@@ -97,7 +96,6 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
status=STATUS_READING_ID;
msg_id="";
msg_str="";
- msg_line=line;
}
if (l.begins_with("msgstr")) {
@@ -111,7 +109,6 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
l=l.substr(6,l.length()).strip_edges();
status=STATUS_READING_STRING;
- msg_line=line;
}
if (l=="" || l.begins_with("#")) {
diff --git a/core/io/unzip.c b/core/io/unzip.c
index b438021ad7..7aa0a86d13 100644
--- a/core/io/unzip.c
+++ b/core/io/unzip.c
@@ -10,7 +10,7 @@
Modifications for Zip64 support on both zip and unzip
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read MiniZip_info.txt
+ For more info read LICENSE-MiniZip.txt
------------------------------------------------------------------------------------
@@ -1031,10 +1031,19 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
if (lSeek!=0)
{
- if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
- lSeek=0;
- else
- err=UNZ_ERRNO;
+ if (lSeek<0) {
+ // WORKAROUND for backwards seeking
+ z_off_t pos = ZTELL64(s->z_filefunc, s->filestream);
+ if (ZSEEK64(s->z_filefunc, s->filestream,pos+lSeek,ZLIB_FILEFUNC_SEEK_SET)==0)
+ lSeek=0;
+ else
+ err=UNZ_ERRNO;
+ } else {
+ if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+ lSeek=0;
+ else
+ err=UNZ_ERRNO;
+ }
}
while(acc < file_info.size_file_extra)
diff --git a/core/io/unzip.h b/core/io/unzip.h
index cb3d239eac..f67c3b2fa8 100644
--- a/core/io/unzip.h
+++ b/core/io/unzip.h
@@ -10,7 +10,7 @@
Modifications for Zip64 support on both zip and unzip
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read MiniZip_info.txt
+ For more info read LICENSE-MiniZip.txt
---------------------------------------------------------------------------------
diff --git a/core/io/zip.c b/core/io/zip.c
index c4ab93ab81..44c79195d9 100644
--- a/core/io/zip.c
+++ b/core/io/zip.c
@@ -7,7 +7,7 @@
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read MiniZip_info.txt
+ For more info read LICENSE-MiniZip.txt
Changes
Oct-2009 - Mathias Svensson - Remove old C style function prototypes
diff --git a/core/io/zip.h b/core/io/zip.h
index 85f93568c9..37478b34c0 100644
--- a/core/io/zip.h
+++ b/core/io/zip.h
@@ -6,7 +6,7 @@
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read MiniZip_info.txt
+ For more info read LICENSE-MiniZip.txt
---------------------------------------------------------------------------
diff --git a/core/io/zip_io.h b/core/io/zip_io.h
index 355003d947..0668c47d97 100644
--- a/core/io/zip_io.h
+++ b/core/io/zip_io.h
@@ -39,11 +39,14 @@ static void* zipio_open(void* data, const char* p_fname, int mode) {
FileAccess *&f = *(FileAccess**)data;
+ String fname;
+ fname.parse_utf8(p_fname);
+
if (mode & ZLIB_FILEFUNC_MODE_WRITE) {
- f = FileAccess::open(p_fname,FileAccess::WRITE);
+ f = FileAccess::open(fname,FileAccess::WRITE);
} else {
- f = FileAccess::open(p_fname,FileAccess::READ);
+ f = FileAccess::open(fname,FileAccess::READ);
}
if (!f)
diff --git a/core/make_binders.py b/core/make_binders.py
index 93371dc0a3..7584722965 100644
--- a/core/make_binders.py
+++ b/core/make_binders.py
@@ -48,7 +48,13 @@ public:
$ifnoret return Variant();$
}
+#ifdef PTRCALL_ENABLED
+ virtual void ptrcall(Object*p_object,const void** p_args,void *r_ret) {
+ T *instance=p_object->cast_to<T>();
+ $ifret PtrToArg<R>::encode( $ (instance->*method)($arg, PtrToArg<P@>::convert(p_args[@-1])$) $ifret ,r_ret)$ ;
+ }
+#endif
MethodBind$argc$$ifret R$$ifconst C$ () {
#ifdef DEBUG_METHODS_ENABLED
_set_const($ifconst true$$ifnoconst false$);
@@ -56,6 +62,8 @@ public:
#else
set_argument_count($argc$);
#endif
+
+ $ifret _set_returns(true); $
};
};
@@ -121,7 +129,12 @@ public:
$ifret return Variant(ret);$
$ifnoret return Variant();$
}
-
+#ifdef PTRCALL_ENABLED
+ virtual void ptrcall(Object*p_object,const void** p_args,void *r_ret) {
+ __UnexistingClass *instance = (__UnexistingClass*)p_object;
+ $ifret PtrToArg<R>::encode( $ (instance->*method)($arg, PtrToArg<P@>::convert(p_args[@-1])$) $ifret ,r_ret) $ ;
+ }
+#endif
MethodBind$argc$$ifret R$$ifconst C$ () {
#ifdef DEBUG_METHODS_ENABLED
_set_const($ifconst true$$ifnoconst false$);
@@ -129,6 +142,9 @@ public:
#else
set_argument_count($argc$);
#endif
+ $ifret _set_returns(true); $
+
+
};
};
@@ -243,10 +259,3 @@ def run(target, source, env):
f=open(target[1].path,"w")
f.write(text_ext)
f.close()
-
-
-
-
-
-
-
diff --git a/core/math/bezier_curve.cpp b/core/math/bezier_curve.cpp
deleted file mode 100644
index 37cf16504c..0000000000
--- a/core/math/bezier_curve.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/*************************************************************************/
-/* bezier_curve.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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 "bezier_curve.h"
diff --git a/core/math/bezier_curve.h b/core/math/bezier_curve.h
deleted file mode 100644
index 25df9dfda8..0000000000
--- a/core/math/bezier_curve.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*************************************************************************/
-/* bezier_curve.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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. */
-/*************************************************************************/
-#ifndef BEZIER_CURVE_H
-#define BEZIER_CURVE_H
-
-
-
-
-#endif // BEZIER_CURVE_H
diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h
index 2bfc26b51e..6c36d80e3e 100644
--- a/core/math/bsp_tree.h
+++ b/core/math/bsp_tree.h
@@ -34,8 +34,8 @@
#include "face3.h"
#include "vector.h"
#include "dvector.h"
-
#include "variant.h"
+#include "method_ptrcall.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -138,4 +138,29 @@ bool BSP_Tree::convex_is_inside(const T& p_convex) const {
}
+#ifdef PTRCALL_ENABLED
+
+
+template<>
+struct PtrToArg<BSP_Tree> {
+ _FORCE_INLINE_ static BSP_Tree convert(const void* p_ptr) {
+ BSP_Tree s( Variant( *reinterpret_cast<const Dictionary*>(p_ptr) ) );
+ return s;
+ }
+ _FORCE_INLINE_ static void encode(BSP_Tree p_val,void* p_ptr) {
+ Dictionary *d = reinterpret_cast<Dictionary*>(p_ptr);
+ *d=Variant(p_val);
+ }
+};
+
+template<>
+struct PtrToArg<const BSP_Tree&> {
+ _FORCE_INLINE_ static BSP_Tree convert(const void* p_ptr) {
+ BSP_Tree s( Variant( *reinterpret_cast<const Dictionary*>(p_ptr) ) );
+ return s;
+ }
+};
+
+#endif
+
#endif
diff --git a/core/math/face3.h b/core/math/face3.h
index bc34be9935..3a81da74db 100644
--- a/core/math/face3.h
+++ b/core/math/face3.h
@@ -264,4 +264,6 @@ bool Face3::intersects_aabb2(const AABB& p_aabb) const {
}
+//this sucks...
+
#endif // FACE3_H
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp
index 5b767212f5..790903eff5 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry.cpp
@@ -629,7 +629,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro
// create and initialize cells to zero
- print_line("Wrapper: Initializing Cells");
+ //print_line("Wrapper: Initializing Cells");
uint8_t ***cell_status=memnew_arr(uint8_t**,div_x);
for(int i=0;i<div_x;i++) {
@@ -648,7 +648,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro
}
// plot faces into cells
- print_line("Wrapper (1/6): Plotting Faces");
+ //print_line("Wrapper (1/6): Plotting Faces");
for (int i=0;i<face_count;i++) {
@@ -663,7 +663,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro
// determine which cells connect to the outside by traversing the outside and recursively flood-fill marking
- print_line("Wrapper (2/6) Flood Filling");
+ //print_line("Wrapper (2/6): Flood Filling");
for (int i=0;i<div_x;i++) {
@@ -694,7 +694,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro
// build faces for the inside-outside cell divisors
- print_line("Wrapper (3/6): Building Faces");
+ //print_line("Wrapper (3/6): Building Faces");
DVector<Face3> wrapped_faces;
@@ -709,7 +709,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro
}
}
- print_line("Wrapper (4/6): Transforming Back Vertices");
+ //print_line("Wrapper (4/6): Transforming Back Vertices");
// transform face vertices to global coords
@@ -728,7 +728,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro
}
// clean up grid
- print_line("Wrapper (5/6): Grid Cleanup");
+ //print_line("Wrapper (5/6): Grid Cleanup");
for(int i=0;i<div_x;i++) {
@@ -744,7 +744,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro
if (p_error)
*p_error=voxelsize.length();
- print_line("Wrapper (6/6): Finished.");
+ //print_line("Wrapper (6/6): Finished.");
return wrapped_faces;
}
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index ad4655b8f7..90aae9fe50 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -157,7 +157,7 @@ struct Vector2 {
float get_aspect() const { return width/height; }
- operator String() const { return String::num(x)+","+String::num(y); }
+ operator String() const { return String::num(x)+", "+String::num(y); }
_FORCE_INLINE_ Vector2(float p_x,float p_y) { x=p_x; y=p_y; }
_FORCE_INLINE_ Vector2() { x=0; y=0; }
@@ -356,7 +356,7 @@ struct Rect2 {
}
- operator String() const { return String(pos)+","+String(size); }
+ operator String() const { return String(pos)+", "+String(size); }
Rect2() {}
Rect2( float p_x, float p_y, float p_width, float p_height) { pos=Point2(p_x,p_y); size=Size2( p_width, p_height ); }
@@ -409,7 +409,7 @@ struct Point2i {
float get_aspect() const { return width/(float)height; }
- operator String() const { return String::num(x)+","+String::num(y); }
+ operator String() const { return String::num(x)+", "+String::num(y); }
operator Vector2() const { return Vector2(x,y); }
inline Point2i(const Vector2& p_vec2) { x=(int)p_vec2.x; y=(int)p_vec2.y; }
@@ -540,7 +540,7 @@ struct Rect2i {
}
- operator String() const { return String(pos)+","+String(size); }
+ operator String() const { return String(pos)+", "+String(size); }
operator Rect2() const { return Rect2(pos,size); }
Rect2i(const Rect2& p_r2) { pos=p_r2.pos; size=p_r2.size; }
@@ -618,6 +618,15 @@ struct Matrix32 {
operator String() const;
+ Matrix32(real_t xx, real_t xy, real_t yx, real_t yy, real_t ox, real_t oy) {
+
+ elements[0][0] = xx;
+ elements[0][1] = xy;
+ elements[1][0] = yx;
+ elements[1][1] = yy;
+ elements[2][0] = ox;
+ elements[2][1] = oy;
+ }
Matrix32(real_t p_rot, const Vector2& p_pos);
Matrix32() { elements[0][0]=1.0; elements[1][1]=1.0; }
diff --git a/core/math/math_defs.cpp b/core/math/math_defs.cpp
deleted file mode 100644
index 70963bd71d..0000000000
--- a/core/math/math_defs.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/*************************************************************************/
-/* math_defs.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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 "math_defs.h"
-
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp
index 0fbd031214..64615fe6b4 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -206,25 +206,29 @@ double Math::ceil(double p_x) {
return ::ceil(p_x);
}
-int Math::decimals(double p_step) {
-
- int max=4;
- double llimit = Math::pow(0.1,max);
- double ulimit = 1.0-llimit;
- int i=0;
- while( max) {
-
- float d = absf(p_step) - Math::floor(absf(p_step));
+int Math::step_decimals(double p_step) {
+
+ static const int maxn=9;
+ static const double sd[maxn]={
+ 0.9999, // somehow compensate for floating point error
+ 0.09999,
+ 0.009999,
+ 0.0009999,
+ 0.00009999,
+ 0.000009999,
+ 0.0000009999,
+ 0.00000009999,
+ 0.000000009999
+ };
- if (d<llimit || d>ulimit)
- break;
- p_step*=10.0;
- max--;
- i++;
+ double as=absf(p_step);
+ for(int i=0;i<maxn;i++) {
+ if (as>=sd[i]) {
+ return i;
+ }
}
- return i;
-
+ return maxn;
}
double Math::ease(double p_x, double p_c) {
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 2e1b9c989e..fc76d96b2e 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -66,7 +66,7 @@ public:
static double floor(double p_x);
static double ceil(double p_x);
static double ease(double p_x, double p_c);
- static int decimals(double p_step);
+ static int step_decimals(double p_step);
static double stepify(double p_value,double p_step);
static void seed(uint32_t x=0);
static void randomize();
diff --git a/core/math/quat.cpp b/core/math/quat.cpp
index c6c12129b3..73124e5e8e 100644
--- a/core/math/quat.cpp
+++ b/core/math/quat.cpp
@@ -252,7 +252,7 @@ Quat Quat::cubic_slerp(const Quat& q, const Quat& prep, const Quat& postq,const
Quat::operator String() const {
- return String::num(x)+","+String::num(y)+","+ String::num(z)+","+ String::num(w);
+ return String::num(x)+", "+String::num(y)+", "+ String::num(z)+", "+ String::num(w);
}
Quat::Quat(const Vector3& axis, const real_t& angle) {
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index adb9861092..7aea32a8a0 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -195,9 +195,6 @@ Vector3 TriangleMesh::get_area_normal(const AABB& p_aabb) const {
int n_count=0;
Vector3 n;
- //for(int i=0;i<max_depth;i++)
- // stack[i]=0;
-
int level=0;
DVector<Triangle>::Read trianglesr = triangles.read();
@@ -205,7 +202,6 @@ Vector3 TriangleMesh::get_area_normal(const AABB& p_aabb) const {
DVector<BVH>::Read bvhr=bvh.read();
const Triangle *triangleptr=trianglesr.ptr();
- const Vector3 *vertexptr=verticesr.ptr();
int pos=bvh.size()-1;
const BVH *bvhptr = bvhr.ptr();
@@ -301,14 +297,7 @@ bool TriangleMesh::intersect_segment(const Vector3& p_begin,const Vector3& p_end
real_t d=1e10;
bool inters=false;
- //for(int i=0;i<max_depth;i++)
- // stack[i]=0;
-
int level=0;
- //AABB ray_aabb;
- //ray_aabb.pos=p_begin;
- //ray_aabb.expand_to(p_end);
-
DVector<Triangle>::Read trianglesr = triangles.read();
DVector<Vector3>::Read verticesr=vertices.read();
@@ -431,9 +420,6 @@ bool TriangleMesh::intersect_ray(const Vector3& p_begin,const Vector3& p_dir,Vec
real_t d=1e20;
bool inters=false;
- //for(int i=0;i<max_depth;i++)
- // stack[i]=0;
-
int level=0;
DVector<Triangle>::Read trianglesr = triangles.read();
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 528c4d37b3..910446023a 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -44,18 +44,6 @@ struct Vector3 {
};
union {
-
-#ifdef USE_QUAD_VECTORS
-
- struct {
- real_t x;
- real_t y;
- real_t z;
- real_t _unused;
- };
- real_t coord[4];
-#else
-
struct {
real_t x;
real_t y;
@@ -63,7 +51,6 @@ struct Vector3 {
};
real_t coord[3];
-#endif
};
_FORCE_INLINE_ const real_t& operator[](int p_axis) const {
diff --git a/core/message_queue.cpp b/core/message_queue.cpp
index c69021f4f0..f3daa46c3d 100644
--- a/core/message_queue.cpp
+++ b/core/message_queue.cpp
@@ -320,7 +320,7 @@ void MessageQueue::_call_function(Object* p_target, const StringName& p_func, co
void MessageQueue::flush() {
- if (buffer_max_used<buffer_end); {
+ if (buffer_end > buffer_max_used) {
buffer_max_used=buffer_end;
//statistics();
}
diff --git a/core/method_bind.cpp b/core/method_bind.cpp
index b41fa33887..a99d0af636 100644
--- a/core/method_bind.cpp
+++ b/core/method_bind.cpp
@@ -64,6 +64,12 @@ void MethodBind::_set_const(bool p_const) {
_const=p_const;
}
+void MethodBind::_set_returns(bool p_returns) {
+
+ _returns=p_returns;
+}
+
+
StringName MethodBind::get_name() const {
return name;
}
@@ -118,6 +124,7 @@ MethodBind::MethodBind() {
argument_types=NULL;
#endif
_const=false;
+ _returns=false;
}
MethodBind::~MethodBind() {
diff --git a/core/method_bind.h b/core/method_bind.h
index 48848c5848..072953743c 100644
--- a/core/method_bind.h
+++ b/core/method_bind.h
@@ -33,6 +33,7 @@
#include "variant.h"
#include "object.h"
#include <stdio.h>
+#include "method_ptrcall.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -85,6 +86,32 @@ struct VariantCaster<const T&> {
(VariantCaster<P##m_idx>::cast( (m_idx-1)>=p_arg_count?get_default_argument(m_idx-1):*p_args[m_idx-1] ))
//SIMPLE_NUMERIC_TYPE is used to avoid a warning on Variant::get_type_for
+
+#ifdef PTRCALL_ENABLED
+
+
+#define VARIANT_ENUM_CAST( m_enum ) \
+SIMPLE_NUMERIC_TYPE( m_enum );\
+template<> \
+struct VariantCaster<m_enum> {\
+\
+ static _FORCE_INLINE_ m_enum cast(const Variant& p_variant) {\
+ return (m_enum)p_variant.operator int();\
+ }\
+};\
+template<>\
+struct PtrToArg< m_enum > {\
+ _FORCE_INLINE_ static m_enum convert(const void* p_ptr) {\
+ return m_enum(*reinterpret_cast<const int*>(p_ptr));\
+ }\
+ _FORCE_INLINE_ static void encode(m_enum p_val,const void* p_ptr) {\
+ *(int*)p_ptr=p_val;\
+ }\
+};
+
+#else
+
+
#define VARIANT_ENUM_CAST( m_enum ) \
SIMPLE_NUMERIC_TYPE( m_enum );\
template<> \
@@ -96,6 +123,9 @@ struct VariantCaster<m_enum> {\
};
+#endif
+
+
#define CHECK_ARG(m_arg)\
if ((m_arg-1)<p_arg_count) {\
Variant::Type argtype=get_argument_type(m_arg-1);\
@@ -124,6 +154,9 @@ VARIANT_ENUM_CAST( wchar_t );
VARIANT_ENUM_CAST( Margin );
VARIANT_ENUM_CAST( Orientation );
VARIANT_ENUM_CAST( HAlign );
+VARIANT_ENUM_CAST( Variant::Type );
+VARIANT_ENUM_CAST( Variant::Operator );
+VARIANT_ENUM_CAST( InputEvent::Type );
class MethodBind {
@@ -140,11 +173,13 @@ class MethodBind {
StringName ret_type;
#endif
bool _const;
+ bool _returns;
protected:
void _set_const(bool p_const);
+ void _set_returns(bool p_returns);
#ifdef DEBUG_METHODS_ENABLED
virtual Variant::Type _gen_argument_type(int p_arg) const=0;
void _generate_argument_types(int p_count);
@@ -222,10 +257,16 @@ public:
}
#endif
virtual Variant call(Object* p_object,const Variant** p_args,int p_arg_count, Variant::CallError& r_error)=0;
+
+#ifdef PTRCALL_ENABLED
+ virtual void ptrcall(Object* p_object,const void** p_args,void* r_ret)=0;
+#endif
+
StringName get_name() const;
void set_name(const StringName& p_name);
_FORCE_INLINE_ int get_method_id() const { return method_id; }
_FORCE_INLINE_ bool is_const() const { return _const; }
+ _FORCE_INLINE_ bool has_return() const { return _returns; }
void set_default_arguments(const Vector<Variant>& p_defargs);
@@ -277,11 +318,16 @@ public:
#endif
}
+#ifdef PTRCALL_ENABLED
+ virtual void ptrcall(Object* p_object,const void** p_args,void* r_ret) {} //todo
+#endif
+
+
void set_method(NativeCall p_method) { call_method=p_method; }
virtual bool is_const() const { return false; }
virtual String get_instance_type() const { return T::get_type_static(); }
- MethodBindNative() { call_method=NULL; }
+ MethodBindNative() { call_method=NULL; _set_returns(true);}
};
diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h
new file mode 100644
index 0000000000..e38d59fd8f
--- /dev/null
+++ b/core/method_ptrcall.h
@@ -0,0 +1,354 @@
+#ifndef METHOD_PTRCALL_H
+#define METHOD_PTRCALL_H
+
+#include "typedefs.h"
+#include "math_2d.h"
+#include "variant.h"
+
+#ifdef PTRCALL_ENABLED
+
+template<class T>
+struct PtrToArg {
+
+};
+
+#define MAKE_PTRARG(m_type) \
+template<>\
+struct PtrToArg<m_type> {\
+ _FORCE_INLINE_ static m_type convert(const void* p_ptr) {\
+ return *reinterpret_cast<const m_type*>(p_ptr);\
+ }\
+ _FORCE_INLINE_ static void encode(m_type p_val, void* p_ptr) {\
+ *((m_type*)p_ptr)=p_val;\
+ }\
+};\
+template<>\
+struct PtrToArg<const m_type&> {\
+ _FORCE_INLINE_ static m_type convert(const void* p_ptr) {\
+ return *reinterpret_cast<const m_type*>(p_ptr);\
+ }\
+ _FORCE_INLINE_ static void encode(m_type p_val, void* p_ptr) {\
+ *((m_type*)p_ptr)=p_val;\
+ }\
+}
+
+
+#define MAKE_PTRARGR(m_type,m_ret) \
+template<>\
+struct PtrToArg<m_type> {\
+ _FORCE_INLINE_ static m_type convert(const void* p_ptr) {\
+ return *reinterpret_cast<const m_type*>(p_ptr);\
+ }\
+ _FORCE_INLINE_ static void encode(m_type p_val, void* p_ptr) {\
+ *((m_ret*)p_ptr)=p_val;\
+ }\
+};\
+template<>\
+struct PtrToArg<const m_type&> {\
+ _FORCE_INLINE_ static m_type convert(const void* p_ptr) {\
+ return *reinterpret_cast<const m_type*>(p_ptr);\
+ }\
+ _FORCE_INLINE_ static void encode(m_type p_val, void* p_ptr) {\
+ *((m_ret*)p_ptr)=p_val;\
+ }\
+}
+
+
+
+MAKE_PTRARG(bool);
+MAKE_PTRARGR(uint8_t,int);
+MAKE_PTRARGR(int8_t,int);
+MAKE_PTRARGR(uint16_t,int);
+MAKE_PTRARGR(int16_t,int);
+MAKE_PTRARGR(uint32_t,int);
+MAKE_PTRARGR(int32_t,int);
+MAKE_PTRARGR(int64_t,int);
+MAKE_PTRARGR(uint64_t,int);
+MAKE_PTRARG(float);
+MAKE_PTRARGR(double,float);
+
+MAKE_PTRARG(String);
+MAKE_PTRARG(Vector2);
+MAKE_PTRARG(Rect2);
+MAKE_PTRARG(Vector3);
+MAKE_PTRARG(Matrix32);
+MAKE_PTRARG(Plane);
+MAKE_PTRARG(Quat);
+MAKE_PTRARG(AABB);
+MAKE_PTRARG(Matrix3);
+MAKE_PTRARG(Transform);
+MAKE_PTRARG(Color);
+MAKE_PTRARG(Image);
+MAKE_PTRARG(NodePath);
+MAKE_PTRARG(RID);
+MAKE_PTRARG(InputEvent);
+MAKE_PTRARG(Dictionary);
+MAKE_PTRARG(Array);
+MAKE_PTRARG(ByteArray);
+MAKE_PTRARG(IntArray);
+MAKE_PTRARG(RealArray);
+MAKE_PTRARG(StringArray);
+MAKE_PTRARG(Vector2Array);
+MAKE_PTRARG(Vector3Array);
+MAKE_PTRARG(ColorArray);
+MAKE_PTRARG(Variant);
+
+
+//this is for Object
+
+template<class T>
+struct PtrToArg< T* > {
+
+ _FORCE_INLINE_ static T* convert(const void* p_ptr) {
+
+ return const_cast<T*>(reinterpret_cast<const T*>(p_ptr));
+ }
+
+ _FORCE_INLINE_ static void encode(T* p_var, void* p_ptr) {
+
+ *((T**)p_ptr)=p_var;
+ }
+
+};
+
+template<class T>
+struct PtrToArg< const T* > {
+
+ _FORCE_INLINE_ static const T* convert(const void* p_ptr) {
+
+ return reinterpret_cast<const T*>(p_ptr);
+ }
+
+ _FORCE_INLINE_ static void encode(T* p_var, void* p_ptr) {
+
+ *((T**)p_ptr)=p_var;
+ }
+
+};
+
+
+//this is for the special cases used by Variant
+
+#define MAKE_VECARG(m_type) \
+template<>\
+struct PtrToArg<Vector<m_type> > {\
+ _FORCE_INLINE_ static Vector<m_type> convert(const void* p_ptr) {\
+ const DVector<m_type> *dvs = reinterpret_cast<const DVector<m_type> *>(p_ptr);\
+ Vector<m_type> ret;\
+ int len = dvs->size();\
+ ret.resize(len);\
+ {\
+ DVector<m_type>::Read r=dvs->read();\
+ for(int i=0;i<len;i++) {\
+ ret[i]=r[i];\
+ }\
+ } \
+ return ret;\
+ }\
+ _FORCE_INLINE_ static void encode(Vector<m_type> p_vec, void* p_ptr) {\
+ DVector<m_type> *dv = reinterpret_cast<DVector<m_type> *>(p_ptr);\
+ int len=p_vec.size();\
+ dv->resize(len);\
+ {\
+ DVector<m_type>::Write w=dv->write();\
+ for(int i=0;i<len;i++) {\
+ w[i]=p_vec[i];\
+ }\
+ } \
+ }\
+};\
+template<>\
+struct PtrToArg<const Vector<m_type>& > {\
+ _FORCE_INLINE_ static Vector<m_type> convert(const void* p_ptr) {\
+ const DVector<m_type> *dvs = reinterpret_cast<const DVector<m_type> *>(p_ptr);\
+ Vector<m_type> ret;\
+ int len = dvs->size();\
+ ret.resize(len);\
+ {\
+ DVector<m_type>::Read r=dvs->read();\
+ for(int i=0;i<len;i++) {\
+ ret[i]=r[i];\
+ }\
+ } \
+ return ret;\
+ }\
+}
+
+MAKE_VECARG(String);
+MAKE_VECARG(uint8_t);
+MAKE_VECARG(int);
+MAKE_VECARG(float);
+MAKE_VECARG(Vector2);
+MAKE_VECARG(Vector3);
+MAKE_VECARG(Color);
+
+//for stuff that gets converted to Array vectors
+#define MAKE_VECARR(m_type) \
+template<>\
+struct PtrToArg<Vector<m_type> > {\
+ _FORCE_INLINE_ static Vector<m_type> convert(const void* p_ptr) {\
+ const Array *arr = reinterpret_cast<const Array *>(p_ptr);\
+ Vector<m_type> ret;\
+ int len = arr->size();\
+ ret.resize(len);\
+ for(int i=0;i<len;i++) {\
+ ret[i]=(*arr)[i];\
+ }\
+ return ret;\
+ }\
+ _FORCE_INLINE_ static void encode(Vector<m_type> p_vec, void* p_ptr) {\
+ Array *arr = reinterpret_cast<Array *>(p_ptr);\
+ int len = p_vec.size();\
+ arr->resize(len);\
+ for(int i=0;i<len;i++) {\
+ (*arr)[i]=p_vec[i];\
+ }\
+ } \
+};\
+template<>\
+struct PtrToArg<const Vector<m_type>& > {\
+ _FORCE_INLINE_ static Vector<m_type> convert(const void* p_ptr) {\
+ const Array *arr = reinterpret_cast<const Array *>(p_ptr);\
+ Vector<m_type> ret;\
+ int len = arr->size();\
+ ret.resize(len);\
+ for(int i=0;i<len;i++) {\
+ ret[i]=(*arr)[i];\
+ }\
+ return ret;\
+ }\
+}
+
+
+MAKE_VECARR(Variant);
+MAKE_VECARR(RID);
+MAKE_VECARR(Plane);
+
+#define MAKE_DVECARR(m_type) \
+template<>\
+struct PtrToArg<DVector<m_type> > {\
+ _FORCE_INLINE_ static DVector<m_type> convert(const void* p_ptr) {\
+ const Array *arr = reinterpret_cast<const Array *>(p_ptr);\
+ DVector<m_type> ret;\
+ int len = arr->size();\
+ ret.resize(len);\
+ {\
+ DVector<m_type>::Write w=ret.write();\
+ for(int i=0;i<len;i++) {\
+ w[i]=(*arr)[i];\
+ }\
+ }\
+ return ret;\
+ }\
+ _FORCE_INLINE_ static void encode(DVector<m_type> p_vec, void* p_ptr) {\
+ Array *arr = reinterpret_cast<Array *>(p_ptr);\
+ int len = p_vec.size();\
+ arr->resize(len);\
+ {\
+ DVector<m_type>::Read r=p_vec.read();\
+ for(int i=0;i<len;i++) {\
+ (*arr)[i]=r[i];\
+ }\
+ }\
+ } \
+};\
+template<>\
+struct PtrToArg<const DVector<m_type>& > {\
+ _FORCE_INLINE_ static DVector<m_type> convert(const void* p_ptr) {\
+ const Array *arr = reinterpret_cast<const Array *>(p_ptr);\
+ DVector<m_type> ret;\
+ int len = arr->size();\
+ ret.resize(len);\
+ {\
+ DVector<m_type>::Write w=ret.write();\
+ for(int i=0;i<len;i++) {\
+ w[i]=(*arr)[i];\
+ }\
+ }\
+ return ret;\
+ }\
+}
+
+MAKE_DVECARR(Plane);
+//for special case StringName
+
+#define MAKE_STRINGCONV(m_type) \
+template<>\
+struct PtrToArg<m_type> {\
+ _FORCE_INLINE_ static m_type convert(const void* p_ptr) {\
+ m_type s = *reinterpret_cast<const String*>(p_ptr);\
+ return s;\
+ }\
+ _FORCE_INLINE_ static void encode(m_type p_vec, void* p_ptr) {\
+ String *arr = reinterpret_cast<String *>(p_ptr);\
+ *arr=p_vec;\
+ }\
+};\
+\
+template<>\
+struct PtrToArg<const m_type&> {\
+ _FORCE_INLINE_ static m_type convert(const void* p_ptr) {\
+ m_type s = *reinterpret_cast<const String*>(p_ptr);\
+ return s;\
+ }\
+}
+
+MAKE_STRINGCONV(StringName);
+MAKE_STRINGCONV(IP_Address);
+
+template<>
+struct PtrToArg<DVector<Face3> > {
+ _FORCE_INLINE_ static DVector<Face3> convert(const void* p_ptr) {
+ const DVector<Vector3> *dvs = reinterpret_cast<const DVector<Vector3> *>(p_ptr);
+ DVector<Face3> ret;
+ int len = dvs->size()/3;
+ ret.resize(len);
+ {
+ DVector<Vector3>::Read r=dvs->read();
+ DVector<Face3>::Write w=ret.write();
+ for(int i=0;i<len;i++) {
+ w[i].vertex[0]=r[i*3+0];
+ w[i].vertex[1]=r[i*3+1];
+ w[i].vertex[2]=r[i*3+2];
+ }
+ }
+ return ret;
+ }
+ _FORCE_INLINE_ static void encode(DVector<Face3> p_vec, void* p_ptr) {\
+ DVector<Vector3> *arr = reinterpret_cast<DVector<Vector3> *>(p_ptr);\
+ int len = p_vec.size();\
+ arr->resize(len*3);\
+ {\
+ DVector<Face3>::Read r=p_vec.read();\
+ DVector<Vector3>::Write w=arr->write();\
+ for(int i=0;i<len;i++) {\
+ w[i*3+0]=r[i].vertex[0];\
+ w[i*3+1]=r[i].vertex[1];\
+ w[i*3+2]=r[i].vertex[2];\
+ }\
+ }\
+ } \
+};
+template<>
+struct PtrToArg<const DVector<Face3>& > {
+ _FORCE_INLINE_ static DVector<Face3> convert(const void* p_ptr) {
+ const DVector<Vector3> *dvs = reinterpret_cast<const DVector<Vector3> *>(p_ptr);
+ DVector<Face3> ret;
+ int len = dvs->size()/3;
+ ret.resize(len);
+ {
+ DVector<Vector3>::Read r=dvs->read();
+ DVector<Face3>::Write w=ret.write();
+ for(int i=0;i<len;i++) {
+ w[i].vertex[0]=r[i*3+0];
+ w[i].vertex[1]=r[i*3+1];
+ w[i].vertex[2]=r[i*3+2];
+ }
+ }
+ return ret;
+ }
+};
+
+
+#endif // METHOD_PTRCALL_H
+#endif
diff --git a/core/multi_bucket_array.h b/core/multi_bucket_array.h
deleted file mode 100644
index 98033e40f6..0000000000
--- a/core/multi_bucket_array.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*************************************************************************/
-/* multi_bucket_array.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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. */
-/*************************************************************************/
-#ifndef MULTI_BUCKET_ARRAY_H
-#define MULTI_BUCKET_ARRAY_H
-
-
-template<class T>
-class MultiBucketArray {
-
-
-
-};
-
-
-
-#endif // MULTI_BUCKET_ARRAY_H
diff --git a/core/object.cpp b/core/object.cpp
index d7878fd623..b036efa501 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -59,30 +59,112 @@ struct _ObjectDebugLock {
#endif
+
+PropertyInfo::operator Dictionary() const {
+
+ Dictionary d;
+ d["name"]=name;
+ d["type"]=type;
+ d["hint"]=hint;
+ d["hint_string"]=hint_string;
+ d["usage"]=usage;
+ return d;
+
+}
+
+PropertyInfo PropertyInfo::from_dict(const Dictionary& p_dict) {
+
+ PropertyInfo pi;
+
+ if (p_dict.has("type"))
+ pi.type=Variant::Type(int(p_dict["type"]));
+
+ if (p_dict.has("name"))
+ pi.name=p_dict["name"];
+
+ if (p_dict.has("hint"))
+ pi.hint=PropertyHint(int(p_dict["hint"]));
+
+ if (p_dict.has("hint_string"))
+
+ pi.hint_string=p_dict["hint_string"];
+
+ if (p_dict.has("usage"))
+ pi.usage=p_dict["usage"];
+
+ return pi;
+}
+
+
Array convert_property_list(const List<PropertyInfo> * p_list) {
Array va;
for (const List<PropertyInfo>::Element *E=p_list->front();E;E=E->next()) {
- const PropertyInfo &pi = E->get();
- Dictionary d;
- d["name"]=pi.name;
- d["type"]=pi.type;
- d["hint"]=pi.hint;
- d["hint_string"]=pi.hint_string;
- d["usage"]=pi.usage;
- va.push_back(d);
+
+ va.push_back(Dictionary(E->get()));
}
return va;
}
+MethodInfo::operator Dictionary() const {
+
+
+ Dictionary d;
+ d["name"]=name;
+ d["args"]=convert_property_list(&arguments);
+ Array da;
+ for(int i=0;i<default_arguments.size();i++)
+ da.push_back(default_arguments[i]);
+ d["default_args"]=da;
+ d["flags"]=flags;
+ d["id"]=id;
+ Dictionary r = return_val;
+ d["return"]=r;
+ return d;
+
+}
+
MethodInfo::MethodInfo() {
id=0;
flags=METHOD_FLAG_NORMAL;
}
+MethodInfo MethodInfo::from_dict(const Dictionary& p_dict) {
+
+ MethodInfo mi;
+
+ if (p_dict.has("name"))
+ mi.name=p_dict["name"];
+ Array args;
+ if (p_dict.has("args")) {
+ args=p_dict["args"];
+ }
+
+ for(int i=0;i<args.size();i++) {
+ Dictionary d = args[i];
+ mi.arguments.push_back(PropertyInfo::from_dict(d));
+ }
+ Array defargs;
+ if (p_dict.has("default_args")) {
+ defargs=p_dict["default_args"];
+ }
+ for(int i=0;i<defargs.size();i++) {
+ mi.default_arguments.push_back(defargs[i]);
+ }
+
+ if (p_dict.has("return")) {
+ mi.return_val=PropertyInfo::from_dict(p_dict["return"]);
+ }
+
+ if (p_dict.has("flags"))
+ mi.flags=p_dict["flags"];
+
+ return mi;
+}
+
MethodInfo::MethodInfo(const String& p_name) {
id=0;
@@ -1012,25 +1094,6 @@ Array Object::_get_property_list_bind() const {
}
-static Dictionary _get_dict_from_method(const MethodInfo &mi) {
-
- Dictionary d;
- d["name"]=mi.name;
- d["args"]=convert_property_list(&mi.arguments);
- Array da;
- for(int i=0;i<mi.default_arguments.size();i++)
- da.push_back(mi.default_arguments[i]);
- d["default_args"]=da;
- d["flags"]=mi.flags;
- d["id"]=mi.id;
- Dictionary r;
- r["type"]=mi.return_val.type;
- r["hint"]=mi.return_val.hint;
- r["hint_string"]=mi.return_val.hint_string;
- d["return_type"]=r;
- return d;
-
-}
Array Object::_get_method_list_bind() const {
@@ -1040,7 +1103,7 @@ Array Object::_get_method_list_bind() const {
for(List<MethodInfo>::Element *E=ml.front();E;E=E->next()) {
- Dictionary d = _get_dict_from_method(E->get());
+ Dictionary d = E->get();
//va.push_back(d);
ret.push_back(d);
}
@@ -1305,7 +1368,7 @@ Array Object::_get_signal_list() const{
Array ret;
for (List<MethodInfo>::Element *E=signal_list.front();E;E=E->next()) {
- ret.push_back(_get_dict_from_method(E->get()));
+ ret.push_back(Dictionary(E->get()));
}
return ret;
@@ -1320,14 +1383,16 @@ Array Object::_get_signal_connection_list(const String& p_signal) const{
for (List<Connection>::Element *E=conns.front();E;E=E->next()) {
Connection &c=E->get();
- Dictionary rc;
- rc["signal"]=c.signal;
- rc["method"]=c.method;
- rc["source"]=c.source;
- rc["target"]=c.target;
- rc["binds"]=c.binds;
- rc["flags"]=c.flags;
- ret.push_back(rc);
+ if (c.signal == p_signal){
+ Dictionary rc;
+ rc["signal"]=c.signal;
+ rc["method"]=c.method;
+ rc["source"]=c.source;
+ rc["target"]=c.target;
+ rc["binds"]=c.binds;
+ rc["flags"]=c.flags;
+ ret.push_back(rc);
+ }
}
return ret;
@@ -1383,6 +1448,31 @@ void Object::get_signal_connection_list(const StringName& p_signal,List<Connecti
}
+bool Object::has_persistent_signal_connections() const {
+
+ const StringName *S=NULL;
+
+ while((S=signal_map.next(S))) {
+
+ const Signal *s=&signal_map[*S];
+
+ for(int i=0;i<s->slot_map.size();i++) {
+
+ if (s->slot_map.getv(i).conn.flags&CONNECT_PERSIST)
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void Object::get_signals_connected_to_this(List<Connection> *p_connections) const {
+
+ for (const List<Connection>::Element *E=connections.front();E;E=E->next()) {
+ p_connections->push_back(E->get());
+ }
+}
+
Error Object::connect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method,const Vector<Variant>& p_binds,uint32_t p_flags) {
@@ -1468,7 +1558,7 @@ void Object::disconnect(const StringName& p_signal, Object *p_to_object, const S
ERR_EXPLAIN("Disconnecting nonexistent signal '"+p_signal+"', slot: "+itos(target._id)+":"+target.method);
ERR_FAIL();
}
- int prev = p_to_object->connections.size();
+
p_to_object->connections.erase(s->slot_map[target].cE);
s->slot_map.erase(target);
@@ -1624,7 +1714,7 @@ void Object::_bind_methods() {
}
- ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"call",&Object::_call_bind,mi,defargs);
+ ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"call:Variant",&Object::_call_bind,mi,defargs);
}
{
diff --git a/core/object.h b/core/object.h
index f4a2472e88..ac3fc51b3e 100644
--- a/core/object.h
+++ b/core/object.h
@@ -68,6 +68,16 @@ enum PropertyHint {
PROPERTY_HINT_IMAGE_COMPRESS_LOSSY,
PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS,
PROPERTY_HINT_OBJECT_ID,
+ PROPERTY_HINT_TYPE_STRING, ///< a type string, the hint is the base type to choose
+ PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE, ///< so something else can provide this (used in scripts)
+ PROPERTY_HINT_METHOD_OF_VARIANT_TYPE, ///< a method of a type
+ PROPERTY_HINT_METHOD_OF_BASE_TYPE, ///< a method of a base type
+ PROPERTY_HINT_METHOD_OF_INSTANCE, ///< a method of an instance
+ PROPERTY_HINT_METHOD_OF_SCRIPT, ///< a method of a script & base
+ PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE, ///< a property of a type
+ PROPERTY_HINT_PROPERTY_OF_BASE_TYPE, ///< a property of a base type
+ PROPERTY_HINT_PROPERTY_OF_INSTANCE, ///< a property of an instance
+ PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base
PROPERTY_HINT_MAX,
};
@@ -86,6 +96,9 @@ enum PropertyUsageFlags {
PROPERTY_USAGE_STORE_IF_NONONE=1024, //only store if false
PROPERTY_USAGE_NO_INSTANCE_STATE=2048,
PROPERTY_USAGE_RESTART_IF_CHANGED=4096,
+ PROPERTY_USAGE_SCRIPT_VARIABLE=8192,
+ PROPERTY_USAGE_STORE_IF_NULL=16384,
+ PROPERTY_USAGE_ANIMATE_AS_TRIGGER=32768,
PROPERTY_USAGE_DEFAULT=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK,
PROPERTY_USAGE_DEFAULT_INTL=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK|PROPERTY_USAGE_INTERNATIONALIZED,
@@ -113,6 +126,11 @@ struct PropertyInfo {
_FORCE_INLINE_ PropertyInfo added_usage(int p_fl) const { PropertyInfo pi=*this; pi.usage|=p_fl; return pi; }
+
+ operator Dictionary() const;
+
+ static PropertyInfo from_dict(const Dictionary& p_dict);
+
PropertyInfo() { type=Variant::NIL; hint=PROPERTY_HINT_NONE; usage = PROPERTY_USAGE_DEFAULT; }
PropertyInfo( Variant::Type p_type, const String p_name, PropertyHint p_hint=PROPERTY_HINT_NONE, const String& p_hint_string="",uint32_t p_usage=PROPERTY_USAGE_DEFAULT) {
type=p_type; name=p_name; hint=p_hint; hint_string=p_hint_string; usage=p_usage;
@@ -137,6 +155,9 @@ struct MethodInfo {
inline bool operator<(const MethodInfo& p_method) const { return id==p_method.id?(name < p_method.name):(id<p_method.id); }
+ operator Dictionary() const;
+
+ static MethodInfo from_dict(const Dictionary& p_dict);
MethodInfo();
MethodInfo(const String& p_name);
MethodInfo(const String& p_name, const PropertyInfo& p_param1);
@@ -604,6 +625,8 @@ public:
void get_signal_list(List<MethodInfo> *p_signals ) const;
void get_signal_connection_list(const StringName& p_signal,List<Connection> *p_connections) const;
void get_all_signal_connections(List<Connection> *p_connections) const;
+ bool has_persistent_signal_connections() const;
+ void get_signals_connected_to_this(List<Connection> *p_connections) const;
Error connect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method,const Vector<Variant>& p_binds=Vector<Variant>(),uint32_t p_flags=0);
void disconnect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method);
diff --git a/core/object_type_db.cpp b/core/object_type_db.cpp
index 5f97df39a6..b6a69e3bd4 100644
--- a/core/object_type_db.cpp
+++ b/core/object_type_db.cpp
@@ -549,6 +549,23 @@ bool ObjectTypeDB::has_signal(StringName p_type,StringName p_signal) {
return false;
}
+bool ObjectTypeDB::get_signal(StringName p_type,StringName p_signal,MethodInfo *r_signal) {
+
+ TypeInfo *type=types.getptr(p_type);
+ TypeInfo *check=type;
+ while(check) {
+ if (check->signal_map.has(p_signal)) {
+ if (r_signal) {
+ *r_signal=check->signal_map[p_signal];
+ }
+ return true;
+ }
+ check=check->inherits_ptr;
+ }
+
+ return false;
+}
+
void ObjectTypeDB::add_property(StringName p_type,const PropertyInfo& p_pinfo, const StringName& p_setter, const StringName& p_getter, int p_index) {
@@ -625,7 +642,7 @@ void ObjectTypeDB::get_property_list(StringName p_type, List<PropertyInfo> *p_li
TypeInfo *check=type;
while(check) {
- for(List<PropertyInfo>::Element *E=type->property_list.front();E;E=E->next()) {
+ for(List<PropertyInfo>::Element *E=check->property_list.front();E;E=E->next()) {
if (p_validator) {
@@ -828,7 +845,7 @@ MethodBind* ObjectTypeDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind , c
TypeInfo *type=types.getptr(instance_type);
if (!type) {
- print_line("couldn't bind method "+mdname+" for instance: "+instance_type);
+ ERR_PRINTS("Couldn't bind method '"+mdname+"' for instance: "+instance_type);
memdelete(p_bind);
ERR_FAIL_COND_V(!type,NULL);
}
diff --git a/core/object_type_db.h b/core/object_type_db.h
index 8313091acd..3fcd38aa31 100644
--- a/core/object_type_db.h
+++ b/core/object_type_db.h
@@ -415,7 +415,7 @@ public:
#endif
template<class M>
- static MethodBind* bind_native_method(uint32_t p_flags, const StringName& p_name, M p_method,const MethodInfo& p_info=MethodInfo(),const Vector<Variant>& p_default_args=Vector<Variant>()) {
+ static MethodBind* bind_native_method(uint32_t p_flags, StringName p_name, M p_method,const MethodInfo& p_info=MethodInfo(),const Vector<Variant>& p_default_args=Vector<Variant>()) {
GLOBAL_LOCK_FUNCTION;
@@ -423,6 +423,13 @@ public:
MethodBind *bind = create_native_method_bind(p_method,p_info);
ERR_FAIL_COND_V(!bind,NULL);
+
+ String rettype;
+ if (p_name.operator String().find(":")!=-1) {
+ rettype = p_name.operator String().get_slice(":",1);
+ p_name = p_name.operator String().get_slice(":",0);
+ }
+
bind->set_name(p_name);
bind->set_default_arguments(p_default_args);
@@ -442,6 +449,8 @@ public:
}
type->method_map[p_name]=bind;
#ifdef DEBUG_METHODS_ENABLED
+ if (!rettype.empty())
+ bind->set_return_type(rettype);
type->method_order.push_back(p_name);
#endif
@@ -453,6 +462,7 @@ public:
static void add_signal(StringName p_type,const MethodInfo& p_signal);
static bool has_signal(StringName p_type,StringName p_signal);
+ static bool get_signal(StringName p_type,StringName p_signal,MethodInfo *r_signal);
static void get_signal_list(StringName p_type,List<MethodInfo> *p_signals,bool p_no_inheritance=false);
static void add_property(StringName p_type,const PropertyInfo& p_pinfo, const StringName& p_setter, const StringName& p_getter, int p_index=-1);
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index 9a7135913a..c2402183fd 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -143,118 +143,52 @@ Error DirAccess::make_dir_recursive(String p_dir) {
};
String full_dir;
- Globals* g = Globals::get_singleton();
- if (!p_dir.is_abs_path()) {
- //append current
+ if (p_dir.is_rel_path()) {
+ //append current
+ full_dir=get_current_dir().plus_file(p_dir);
- String cur = normalize_path(g->globalize_path(get_current_dir()));
- if (cur[cur.length()-1] != '/') {
- cur = cur + "/";
- };
-
- full_dir=(cur+"/"+p_dir).simplify_path();
} else {
- //validate and use given
- String dir = normalize_path(g->globalize_path(p_dir));
- if (dir.length() < 1) {
- return OK;
- };
- if (dir[dir.length()-1] != '/') {
- dir = dir + "/";
- };
- full_dir=dir;
+ full_dir=p_dir;
}
- //int slices = full_dir.get_slice_count("/");
-
- int pos = 0;
- while (pos < full_dir.length()) {
-
- int n = full_dir.find("/", pos);
- if (n < 0) {
- n = full_dir.length();
- };
- pos = n + 1;
-
- if (pos > 1) {
- String to_create = full_dir.substr(0, pos -1);
- //print_line("MKDIR: "+to_create);
- Error err = make_dir(to_create);
- if (err != OK && err != ERR_ALREADY_EXISTS) {
-
- ERR_FAIL_V(err);
- };
- };
- };
-
- return OK;
-};
-
-
-String DirAccess::normalize_path(const String &p_path) {
-
- static const int max_depth = 64;
- int pos_stack[max_depth];
- int curr = 0;
-
- int pos = 0;
- String cur_dir;
-
- do {
+ full_dir=full_dir.replace("\\","/");
- if (curr >= max_depth) {
-
- ERR_PRINT("Directory depth too deep.");
- return "";
- };
-
- int start = pos;
-
- int next = p_path.find("/", pos);
- if (next < 0) {
- next = p_path.length() - 1;
- };
-
- pos = next + 1;
+ //int slices = full_dir.get_slice_count("/");
- cur_dir = p_path.substr(start, next - start);
+ String base;
- if (cur_dir == "" || cur_dir == ".") {
- continue;
- };
- if (cur_dir == "..") {
+ if (full_dir.begins_with("res://"))
+ base="res://";
+ else if (full_dir.begins_with("user://"))
+ base="user://";
+ else if (full_dir.begins_with("/"))
+ base="/";
+ else if (full_dir.find(":/")!=-1) {
+ base=full_dir.substr(0,full_dir.find(":/")+2);
+ } else {
+ ERR_FAIL_V(ERR_INVALID_PARAMETER);
+ }
- if (curr > 0) { // pop a dir
- curr -= 2;
- };
- continue;
- };
+ full_dir=full_dir.replace_first(base,"").simplify_path();
- pos_stack[curr++] = start;
- pos_stack[curr++] = next;
+ Vector<String> subdirs=full_dir.split("/");
- } while (pos < p_path.length());
+ String curpath=base;
+ for(int i=0;i<subdirs.size();i++) {
- String path;
- if (p_path[0] == '/') {
- path = "/";
- };
+ curpath=curpath.plus_file(subdirs[i]);
+ Error err = make_dir(curpath);
+ if (err != OK && err != ERR_ALREADY_EXISTS) {
- int i=0;
- while (i < curr) {
-
- int start = pos_stack[i++];
+ ERR_FAIL_V(err);
+ }
+ }
- while ( ((i+1)<curr) && (pos_stack[i] == pos_stack[i+1]) ) {
+ return OK;
+}
- ++i;
- };
- path = path + p_path.substr(start, (pos_stack[i++] - start) + 1);
- };
- return path;
-};
String DirAccess::get_next(bool* p_is_dir) {
@@ -276,9 +210,9 @@ String DirAccess::fix_path(String p_path) const {
String resource_path = Globals::get_singleton()->get_resource_path();
if (resource_path != "") {
- return p_path.replace("res:/",resource_path);
+ return p_path.replace_first("res:/",resource_path);
};
- return p_path.replace("res://", "");
+ return p_path.replace_first("res://", "");
}
}
@@ -292,9 +226,9 @@ String DirAccess::fix_path(String p_path) const {
String data_dir=OS::get_singleton()->get_data_dir();
if (data_dir != "") {
- return p_path.replace("user:/",data_dir);
+ return p_path.replace_first("user:/",data_dir);
};
- return p_path.replace("user://", "");
+ return p_path.replace_first("user://", "");
}
} break;
diff --git a/core/os/dir_access.h b/core/os/dir_access.h
index 7a850ddc6d..83288b7c91 100644
--- a/core/os/dir_access.h
+++ b/core/os/dir_access.h
@@ -72,8 +72,6 @@ protected:
public:
- static String normalize_path(const String& p_path);
-
virtual bool list_dir_begin()=0; ///< This starts dir listing
virtual String get_next(bool* p_is_dir); // compatibility
virtual String get_next()=0;
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index a3ee9395de..2f1693c044 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -31,10 +31,13 @@
#include "os/os.h"
#include "core/io/marshalls.h"
#include "io/md5.h"
+#include "io/sha256.h"
#include "core/io/file_access_pack.h"
FileAccess::CreateFunc FileAccess::create_func[ACCESS_MAX]={0,0};
+FileAccess::FileCloseFailNotify FileAccess::close_fail_notify=NULL;
+
bool FileAccess::backup_save=false;
@@ -515,6 +518,38 @@ String FileAccess::get_md5(const String& p_file) {
}
+String FileAccess::get_sha256(const String& p_file) {
+
+ FileAccess *f=FileAccess::open(p_file,READ);
+ if (!f)
+ return String();
+
+ sha256_context sha256;
+ sha256_init(&sha256);
+
+ unsigned char step[32768];
+
+ while(true) {
+
+ int br = f->get_buffer(step,32768);
+ if (br>0) {
+
+ sha256_hash(&sha256,step,br);
+ }
+ if (br < 4096)
+ break;
+
+ }
+
+ unsigned char hash[32];
+
+ sha256_done(&sha256, hash);
+
+ memdelete(f);
+ return String::hex_encode_buffer(hash, 32);
+
+}
+
FileAccess::FileAccess() {
endian_swap=false;
diff --git a/core/os/file_access.h b/core/os/file_access.h
index 2c894c94eb..5178c469bc 100644
--- a/core/os/file_access.h
+++ b/core/os/file_access.h
@@ -47,6 +47,8 @@ public:
ACCESS_MAX
};
+ typedef void (*FileCloseFailNotify)(const String&);
+
typedef FileAccess*(*CreateFunc)();
bool endian_swap;
bool real_is_double;
@@ -56,7 +58,7 @@ protected:
virtual Error _open(const String& p_path, int p_mode_flags)=0; ///< open a file
virtual uint64_t _get_modified_time(const String& p_file)=0;
-
+ static FileCloseFailNotify close_fail_notify;
private:
static bool backup_save;
@@ -69,8 +71,12 @@ private:
return memnew( T );
}
+
+
public:
+ static void set_file_close_fail_notify_callback(FileCloseFailNotify p_cbk) { close_fail_notify=p_cbk; }
+
virtual void _set_access_type(AccessType p_access);
enum ModeFlags {
@@ -147,6 +153,7 @@ public:
static bool is_backup_save_enabled() { return backup_save; };
static String get_md5(const String& p_file);
+ static String get_sha256(const String& p_file);
static Vector<uint8_t> get_file_as_array(const String& p_path);
diff --git a/core/os/input.cpp b/core/os/input.cpp
index a766ef87fc..401ab7ffe2 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -53,14 +53,22 @@ void Input::_bind_methods() {
ObjectTypeDB::bind_method(_MD("is_mouse_button_pressed","button"),&Input::is_mouse_button_pressed);
ObjectTypeDB::bind_method(_MD("is_joy_button_pressed","device","button"),&Input::is_joy_button_pressed);
ObjectTypeDB::bind_method(_MD("is_action_pressed","action"),&Input::is_action_pressed);
+ ObjectTypeDB::bind_method(_MD("is_action_just_pressed","action"),&Input::is_action_just_pressed);
+ ObjectTypeDB::bind_method(_MD("is_action_just_released","action"),&Input::is_action_just_released);
ObjectTypeDB::bind_method(_MD("add_joy_mapping","mapping", "update_existing"),&Input::add_joy_mapping, DEFVAL(false));
ObjectTypeDB::bind_method(_MD("remove_joy_mapping","guid"),&Input::remove_joy_mapping);
ObjectTypeDB::bind_method(_MD("is_joy_known","device"),&Input::is_joy_known);
ObjectTypeDB::bind_method(_MD("get_joy_axis","device","axis"),&Input::get_joy_axis);
ObjectTypeDB::bind_method(_MD("get_joy_name","device"),&Input::get_joy_name);
ObjectTypeDB::bind_method(_MD("get_joy_guid","device"),&Input::get_joy_guid);
+ ObjectTypeDB::bind_method(_MD("get_connected_joysticks"),&Input::get_connected_joysticks);
+ ObjectTypeDB::bind_method(_MD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength);
+ ObjectTypeDB::bind_method(_MD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration);
+ ObjectTypeDB::bind_method(_MD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("stop_joy_vibration", "device"), &Input::stop_joy_vibration);
ObjectTypeDB::bind_method(_MD("get_accelerometer"),&Input::get_accelerometer);
ObjectTypeDB::bind_method(_MD("get_magnetometer"),&Input::get_magnetometer);
+ ObjectTypeDB::bind_method(_MD("get_gyroscope"),&Input::get_gyroscope);
//ObjectTypeDB::bind_method(_MD("get_mouse_pos"),&Input::get_mouse_pos); - this is not the function you want
ObjectTypeDB::bind_method(_MD("get_mouse_speed"),&Input::get_mouse_speed);
ObjectTypeDB::bind_method(_MD("get_mouse_button_mask"),&Input::get_mouse_button_mask);
diff --git a/core/os/input.h b/core/os/input.h
index 46edb30aa1..665fb4ad99 100644
--- a/core/os/input.h
+++ b/core/os/input.h
@@ -55,18 +55,26 @@ public:
static Input *get_singleton();
- virtual bool is_key_pressed(int p_scancode)=0;
- virtual bool is_mouse_button_pressed(int p_button)=0;
- virtual bool is_joy_button_pressed(int p_device, int p_button)=0;
- virtual bool is_action_pressed(const StringName& p_action)=0;
-
- virtual float get_joy_axis(int p_device,int p_axis)=0;
+ virtual bool is_key_pressed(int p_scancode) const=0;
+ virtual bool is_mouse_button_pressed(int p_button) const=0;
+ virtual bool is_joy_button_pressed(int p_device, int p_button) const=0;
+ virtual bool is_action_pressed(const StringName& p_action) const=0;
+ virtual bool is_action_just_pressed(const StringName& p_action) const=0;
+ virtual bool is_action_just_released(const StringName& p_action) const=0;
+
+ virtual float get_joy_axis(int p_device,int p_axis) const=0;
virtual String get_joy_name(int p_idx)=0;
+ virtual Array get_connected_joysticks()=0;
virtual void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid)=0;
virtual void add_joy_mapping(String p_mapping, bool p_update_existing=false)=0;
virtual void remove_joy_mapping(String p_guid)=0;
virtual bool is_joy_known(int p_device)=0;
virtual String get_joy_guid(int p_device) const=0;
+ virtual Vector2 get_joy_vibration_strength(int p_device)=0;
+ virtual float get_joy_vibration_duration(int p_device)=0;
+ virtual uint64_t get_joy_vibration_timestamp(int p_device)=0;
+ virtual void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration=0)=0;
+ virtual void stop_joy_vibration(int p_device)=0;
virtual Point2 get_mouse_pos() const=0;
virtual Point2 get_mouse_speed() const=0;
@@ -74,8 +82,9 @@ public:
virtual void warp_mouse_pos(const Vector2& p_to)=0;
- virtual Vector3 get_accelerometer()=0;
- virtual Vector3 get_magnetometer()=0;
+ virtual Vector3 get_accelerometer() const=0;
+ virtual Vector3 get_magnetometer() const=0;
+ virtual Vector3 get_gyroscope() const=0;
virtual void action_press(const StringName& p_action)=0;
virtual void action_release(const StringName& p_action)=0;
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 2d47645a66..9d920724e1 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -34,8 +34,56 @@
*/
bool InputEvent::operator==(const InputEvent &p_event) const {
+ if (type != p_event.type){
+ return false;
+ }
+
+ switch(type) {
+ case NONE:
+ return true;
+ case KEY:
+ return key.unicode == p_event.key.unicode
+ && key.scancode == p_event.key.scancode
+ && key.echo == p_event.key.echo
+ && key.pressed == p_event.key.pressed
+ && key.mod == p_event.key.mod;
+ case MOUSE_MOTION:
+ return mouse_motion.x == p_event.mouse_motion.x
+ && mouse_motion.y == p_event.mouse_motion.y
+ && mouse_motion.relative_x == p_event.mouse_motion.relative_y
+ && mouse_motion.button_mask == p_event.mouse_motion.button_mask
+ && key.mod == p_event.key.mod;
+ case MOUSE_BUTTON:
+ return mouse_button.pressed == p_event.mouse_button.pressed
+ && mouse_button.x == p_event.mouse_button.x
+ && mouse_button.y == p_event.mouse_button.y
+ && mouse_button.button_index == p_event.mouse_button.button_index
+ && mouse_button.button_mask == p_event.mouse_button.button_mask
+ && key.mod == p_event.key.mod;
+ case JOYSTICK_MOTION:
+ return joy_motion.axis == p_event.joy_motion.axis
+ && joy_motion.axis_value == p_event.joy_motion.axis_value;
+ case JOYSTICK_BUTTON:
+ return joy_button.pressed == p_event.joy_button.pressed
+ && joy_button.button_index == p_event.joy_button.button_index
+ && joy_button.pressure == p_event.joy_button.pressure;
+ case SCREEN_TOUCH:
+ return screen_touch.pressed == p_event.screen_touch.pressed
+ && screen_touch.index == p_event.screen_touch.index
+ && screen_touch.x == p_event.screen_touch.x
+ && screen_touch.y == p_event.screen_touch.y;
+ case SCREEN_DRAG:
+ return screen_drag.index == p_event.screen_drag.index
+ && screen_drag.x == p_event.screen_drag.x
+ && screen_drag.y == p_event.screen_drag.y;
+ case ACTION:
+ return action.action == p_event.action.action
+ && action.pressed == p_event.action.pressed;
+ default:
+ ERR_PRINT("No logic to compare InputEvents of this type, this shouldn't happen.");
+ }
- return true;
+ return false;
}
InputEvent::operator String() const {
@@ -199,3 +247,62 @@ uint32_t InputEventKey::get_scancode_with_modifiers() const {
return sc;
}
+
+InputEvent InputEvent::xform_by(const Matrix32& p_xform) const {
+
+
+ InputEvent ev=*this;
+
+ switch(ev.type) {
+
+ case InputEvent::MOUSE_BUTTON: {
+
+ Vector2 g = p_xform.xform(Vector2(ev.mouse_button.global_x,ev.mouse_button.global_y));
+ Vector2 l = p_xform.xform(Vector2(ev.mouse_button.x,ev.mouse_button.y));
+ ev.mouse_button.x=l.x;
+ ev.mouse_button.y=l.y;
+ ev.mouse_button.global_x=g.x;
+ ev.mouse_button.global_y=g.y;
+
+ } break;
+ case InputEvent::MOUSE_MOTION: {
+
+ Vector2 g = p_xform.xform(Vector2(ev.mouse_motion.global_x,ev.mouse_motion.global_y));
+ Vector2 l = p_xform.xform(Vector2(ev.mouse_motion.x,ev.mouse_motion.y));
+ Vector2 r = p_xform.basis_xform(Vector2(ev.mouse_motion.relative_x,ev.mouse_motion.relative_y));
+ Vector2 s = p_xform.basis_xform(Vector2(ev.mouse_motion.speed_x,ev.mouse_motion.speed_y));
+ ev.mouse_motion.x=l.x;
+ ev.mouse_motion.y=l.y;
+ ev.mouse_motion.global_x=g.x;
+ ev.mouse_motion.global_y=g.y;
+ ev.mouse_motion.relative_x=r.x;
+ ev.mouse_motion.relative_y=r.y;
+ ev.mouse_motion.speed_x=s.x;
+ ev.mouse_motion.speed_y=s.y;
+
+ } break;
+ case InputEvent::SCREEN_TOUCH: {
+
+
+ Vector2 t = p_xform.xform(Vector2(ev.screen_touch.x,ev.screen_touch.y));
+ ev.screen_touch.x=t.x;
+ ev.screen_touch.y=t.y;
+
+ } break;
+ case InputEvent::SCREEN_DRAG: {
+
+
+ Vector2 t = p_xform.xform(Vector2(ev.screen_drag.x,ev.screen_drag.y));
+ Vector2 r = p_xform.basis_xform(Vector2(ev.screen_drag.relative_x,ev.screen_drag.relative_y));
+ Vector2 s = p_xform.basis_xform(Vector2(ev.screen_drag.speed_x,ev.screen_drag.speed_y));
+ ev.screen_drag.x=t.x;
+ ev.screen_drag.y=t.y;
+ ev.screen_drag.relative_x=r.x;
+ ev.screen_drag.relative_y=r.y;
+ ev.screen_drag.speed_x=s.x;
+ ev.screen_drag.speed_y=s.y;
+ } break;
+ }
+
+ return ev;
+}
diff --git a/core/os/input_event.h b/core/os/input_event.h
index 0588374790..1c4f1dcf96 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -33,7 +33,7 @@
#include "typedefs.h"
#include "os/copymem.h"
#include "ustring.h"
-
+#include "math_2d.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -297,6 +297,8 @@ struct InputEvent {
bool is_echo() const;
void set_as_action(const String& p_action, bool p_pressed);
+
+ InputEvent xform_by(const Matrix32& p_xform) const;
bool operator==(const InputEvent &p_event) const;
operator String() const;
InputEvent() { zeromem(this,sizeof(InputEvent)); }
diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp
index 4c0a074a07..9710638234 100644
--- a/core/os/keyboard.cpp
+++ b/core/os/keyboard.cpp
@@ -429,6 +429,27 @@ static const _KeyCodeReplace _keycode_replace_neo[]={
{0,0}
};
+int keycode_get_count() {
+
+ const _KeyCodeText *kct =&_keycodes[0];
+
+ int count=0;
+ while(kct->text) {
+
+ count++;
+ kct++;
+ }
+ return count;
+}
+
+int keycode_get_value_by_index(int p_index) {
+ return _keycodes[p_index].code;
+}
+
+const char* keycode_get_name_by_index(int p_index) {
+ return _keycodes[p_index].text;
+}
+
int latin_keyboard_keycode_convert(int p_keycode) {
diff --git a/core/os/keyboard.h b/core/os/keyboard.h
index 80472acc09..fd52d331c8 100644
--- a/core/os/keyboard.h
+++ b/core/os/keyboard.h
@@ -328,6 +328,9 @@ enum KeyModifierMask {
String keycode_get_string(uint32_t p_code);
bool keycode_has_unicode(uint32_t p_unicode);
int find_keycode(const String& p_code);
+int keycode_get_count();
+int keycode_get_value_by_index(int p_index);
+const char* keycode_get_name_by_index(int p_index);
int latin_keyboard_keycode_convert(int p_keycode);
#endif
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 6910b368d3..ee32476234 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -32,6 +32,8 @@
#include "dir_access.h"
#include "globals.h"
#include "input.h"
+// For get_engine_version, could be removed if it's moved to a new Engine singleton
+#include "version.h"
OS* OS::singleton=NULL;
@@ -207,18 +209,15 @@ bool OS::has_virtual_keyboard() const {
return false;
}
-void OS::show_virtual_keyboard(const String& p_existing_text,const Rect2& p_screen_rect) {
-
+void OS::show_virtual_keyboard(const String& p_existing_text,const Rect2& p_screen_rect) {
}
void OS::hide_virtual_keyboard(){
-
}
-
void OS::print_all_resources(String p_to_file) {
ERR_FAIL_COND(p_to_file!="" && _OSPRF);
@@ -306,6 +305,15 @@ String OS::get_system_dir(SystemDir p_dir) const {
return ".";
}
+String OS::get_safe_application_name() const {
+ String an = Globals::get_singleton()->get("application/name");
+ Vector<String> invalid_char = String("\\ / : * ? \" < > |").split(" ");
+ for (int i=0;i<invalid_char.size();i++) {
+ an = an.replace(invalid_char[i],"-");
+ }
+ return an;
+}
+
String OS::get_data_dir() const {
return ".";
@@ -530,6 +538,36 @@ String OS::get_joy_guid(int p_device) const {
void OS::set_context(int p_context) {
}
+void OS::set_use_vsync(bool p_enable) {
+
+}
+
+bool OS::is_vsnc_enabled() const{
+
+ return true;
+}
+
+Dictionary OS::get_engine_version() const {
+
+ Dictionary dict;
+ dict["major"] = _MKSTR(VERSION_MAJOR);
+ dict["minor"] = _MKSTR(VERSION_MINOR);
+#ifdef VERSION_PATCH
+ dict["patch"] = _MKSTR(VERSION_PATCH);
+#else
+ dict["patch"] = "";
+#endif
+ dict["status"] = _MKSTR(VERSION_STATUS);
+ dict["revision"] = _MKSTR(VERSION_REVISION);
+
+ String stringver = String(dict["major"]) + "." + String(dict["minor"]);
+ if (dict["patch"] != "")
+ stringver += "." + String(dict["patch"]);
+ stringver += "-" + String(dict["status"]) + " (" + String(dict["revision"]) + ")";
+ dict["string"] = stringver;
+
+ return dict;
+}
OS::OS() {
last_error=NULL;
@@ -549,6 +587,9 @@ OS::OS() {
_time_scale=1.0;
_pixel_snap=false;
_allow_hidpi=true;
+ _fixed_frames=0;
+ _idle_frames=0;
+ _in_fixed=false;
Math::seed(1234567);
}
diff --git a/core/os/os.h b/core/os/os.h
index 76dd235d24..8e9293b3c8 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -62,6 +62,10 @@ class OS {
bool _pixel_snap;
bool _allow_hidpi;
+ uint64_t _fixed_frames;
+ uint64_t _idle_frames;
+ bool _in_fixed;
+
char *last_error;
public:
@@ -174,6 +178,7 @@ public:
virtual bool is_window_minimized() const { return false; }
virtual void set_window_maximized(bool p_enabled) {}
virtual bool is_window_maximized() const { return true; }
+ virtual void request_attention() { }
virtual void set_borderless_window(int p_borderless) {}
virtual bool get_borderless_window() { return 0; }
@@ -186,14 +191,14 @@ public:
virtual void set_target_fps(int p_fps);
virtual float get_target_fps() const;
- virtual float get_frames_per_second() const { return _fps; };
+ virtual float get_frames_per_second() const { return _fps; }
virtual void set_keep_screen_on(bool p_enabled);
virtual bool is_keep_screen_on() const;
virtual void set_low_processor_usage_mode(bool p_enabled);
virtual bool is_in_low_processor_usage_mode() const;
- virtual String get_installed_templates_path() const { return ""; };
+ virtual String get_installed_templates_path() const { return ""; }
virtual String get_executable_path() const;
virtual Error execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id=NULL,String* r_pipe=NULL,int *r_exitcode=NULL)=0;
virtual Error kill(const ProcessID& p_pid)=0;
@@ -281,6 +286,10 @@ public:
uint64_t get_frames_drawn();
+ uint64_t get_fixed_frames() const { return _fixed_frames; }
+ uint64_t get_idle_frames() const { return _idle_frames; }
+ bool is_in_fixed_frame() const { return _in_fixed; }
+
bool is_stdout_verbose() const;
enum CursorShape {
@@ -326,6 +335,7 @@ public:
virtual String get_locale() const;
+ String get_safe_application_name() const;
virtual String get_data_dir() const;
virtual String get_resource_dir() const;
@@ -362,7 +372,7 @@ public:
virtual void set_screen_orientation(ScreenOrientation p_orientation);
ScreenOrientation get_screen_orientation() const;
- virtual void move_window_to_foreground() {};
+ virtual void move_window_to_foreground() {}
virtual void debug_break();
@@ -419,6 +429,11 @@ public:
virtual void set_context(int p_context);
+ virtual void set_use_vsync(bool p_enable);
+ virtual bool is_vsnc_enabled() const;
+
+ Dictionary get_engine_version() const;
+
bool is_hidpi_allowed() const { return _allow_hidpi; }
OS();
virtual ~OS();
diff --git a/core/os/thread.h b/core/os/thread.h
index 7349b83dbc..5f0ec707f2 100644
--- a/core/os/thread.h
+++ b/core/os/thread.h
@@ -39,6 +39,8 @@
typedef void (*ThreadCreateCallback)(void *p_userdata);
+
+
class Thread {
public:
@@ -65,15 +67,14 @@ protected:
static void (*wait_to_finish_func)(Thread*);
static Error (*set_name_func)(const String&);
- friend class Main;
+ friend class Main;
- static ID _main_thread_id;
+ static ID _main_thread_id;
Thread();
public:
-
virtual ID get_ID() const=0;
static Error set_name(const String &p_name);
diff --git a/core/pair.cpp b/core/pair.cpp
deleted file mode 100644
index 14bb2d7775..0000000000
--- a/core/pair.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/*************************************************************************/
-/* pair.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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 "pair.h"
diff --git a/core/path_db.cpp b/core/path_db.cpp
index 7545088978..132cc83a35 100644
--- a/core/path_db.cpp
+++ b/core/path_db.cpp
@@ -53,6 +53,12 @@ uint32_t NodePath::hash() const {
}
+void NodePath::prepend_period() {
+
+ if (data->path.size() && data->path[0].operator String()!=".") {
+ data->path.insert(0,".");
+ }
+}
bool NodePath::is_absolute() const {
@@ -329,7 +335,6 @@ NodePath::NodePath(const String& p_path) {
Vector<StringName> subpath;
int absolute=(path[0]=='/')?1:0;;
- bool valid=false;
bool last_is_slash=true;
int slices=0;
int subpath_pos=path.find(":");
@@ -358,6 +363,7 @@ NodePath::NodePath(const String& p_path) {
from=i+1;
}
+
}
path=path.substr(0,subpath_pos);
@@ -373,9 +379,10 @@ NodePath::NodePath(const String& p_path) {
if (last_is_slash)
slices++;
- valid=true;
last_is_slash=false;
}
+
+
}
if (slices==0 && !absolute && !property)
@@ -409,6 +416,7 @@ NodePath::NodePath(const String& p_path) {
} else {
last_is_slash=false;
}
+
}
diff --git a/core/path_db.h b/core/path_db.h
index 63adb42955..3a550fe1d0 100644
--- a/core/path_db.h
+++ b/core/path_db.h
@@ -72,6 +72,8 @@ public:
NodePath rel_path_to(const NodePath& p_np) const;
+ void prepend_period();
+
StringName get_property() const;
NodePath get_parent() const;
diff --git a/core/path_remap.cpp b/core/path_remap.cpp
index d4cb883f41..8f189187f2 100644
--- a/core/path_remap.cpp
+++ b/core/path_remap.cpp
@@ -59,12 +59,20 @@ String PathRemap::get_remap(const String& p_from) const {
return p_from;
} else {
+ const RemapData *ptr2=NULL;
+
String locale = TranslationServer::get_singleton()->get_locale();
if (ptr->locale.has(locale)) {
if (OS::get_singleton()->is_stdout_verbose())
print_line("remap found: "+p_from+" -> "+ptr->locale[locale]);
- return ptr->locale[locale];
+
+ ptr2=remap.getptr(ptr->locale[locale]);
+
+ if (ptr2 && ptr2->always!=String()) //may have atlas or export remap too
+ return ptr2->always;
+ else
+ return ptr->locale[locale];
}
int p = locale.find("_");
@@ -73,7 +81,14 @@ String PathRemap::get_remap(const String& p_from) const {
if (ptr->locale.has(locale)) {
if (OS::get_singleton()->is_stdout_verbose())
print_line("remap found: "+p_from+" -> "+ptr->locale[locale]);
- return ptr->locale[locale];
+
+ ptr2=remap.getptr(ptr->locale[locale]);
+
+ if (ptr2 && ptr2->always!=String()) //may have atlas or export remap too
+ return ptr2->always;
+ else
+ return ptr->locale[locale];
+
}
}
diff --git a/core/pool_allocator.cpp b/core/pool_allocator.cpp
index 849fd75f50..9f5fcf5f50 100644
--- a/core/pool_allocator.cpp
+++ b/core/pool_allocator.cpp
@@ -372,7 +372,6 @@ Error PoolAllocator::resize(ID p_mem,int p_new_size) {
}
//p_new_size = align(p_new_size)
- int _total = pool_size; // - static_area_size;
int _free = free_mem; // - static_area_size;
if ((_free + aligned(e->len)) - alloc_size < 0) {
diff --git a/core/print_string.cpp b/core/print_string.cpp
index 6e57822e94..b6154f1cf6 100644
--- a/core/print_string.cpp
+++ b/core/print_string.cpp
@@ -44,18 +44,15 @@ void add_print_handler(PrintHandlerList *p_handler) {
void remove_print_handler(PrintHandlerList *p_handler) {
- OS::get_singleton()->print("pre-removing print handler...\n");
_global_lock();
PrintHandlerList *prev = NULL;
PrintHandlerList *l = print_handler_list;
- OS::get_singleton()->print("removing print handler...\n");
while(l) {
if (l==p_handler) {
- OS::get_singleton()->print("found\n");
if (prev)
prev->next=l->next;
else
diff --git a/core/reference.cpp b/core/reference.cpp
index 90bafd0a9c..34f36a5735 100644
--- a/core/reference.cpp
+++ b/core/reference.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "reference.h"
-
+#include "script_language.h"
bool Reference::init_ref() {
@@ -66,11 +66,21 @@ int Reference::reference_get_count() const {
void Reference::reference(){
refcount.ref();
+ if (get_script_instance()) {
+ get_script_instance()->refcount_incremented();
+ }
}
bool Reference::unreference(){
- return refcount.unref();
+ bool die = refcount.unref();
+
+ if (get_script_instance()) {
+ die = die && get_script_instance()->refcount_decremented();
+ }
+
+ return die;
+
}
Reference::Reference() {
diff --git a/core/reference.h b/core/reference.h
index 8bfbf19ab6..89e9627b77 100644
--- a/core/reference.h
+++ b/core/reference.h
@@ -329,6 +329,62 @@ public:
WeakRef();
};
+#ifdef PTRCALL_ENABLED
+
+template<class T>
+struct PtrToArg< Ref<T> > {
+
+ _FORCE_INLINE_ static Ref<T> convert(const void* p_ptr) {
+
+ return Ref<T>(reinterpret_cast<const T*>(p_ptr));
+ }
+
+ _FORCE_INLINE_ static void encode(Ref<T> p_val,const void* p_ptr) {
+
+ *(Ref<Reference>*)p_ptr=p_val;
+ }
+
+};
+
+
+template<class T>
+struct PtrToArg< const Ref<T>& > {
+
+ _FORCE_INLINE_ static Ref<T> convert(const void* p_ptr) {
+
+ return Ref<T>(reinterpret_cast<const T*>(p_ptr));
+ }
+
+};
+//this is for RefPtr
+
+template<>
+struct PtrToArg< RefPtr > {
+
+ _FORCE_INLINE_ static RefPtr convert(const void* p_ptr) {
+
+ return Ref<Reference>(reinterpret_cast<const Reference*>(p_ptr)).get_ref_ptr();
+ }
+
+ _FORCE_INLINE_ static void encode(RefPtr p_val,const void* p_ptr) {
+
+ Ref<Reference> r = p_val;
+ *(Ref<Reference>*)p_ptr=r;
+ }
+
+};
+
+template<>
+struct PtrToArg< const RefPtr& > {
+
+ _FORCE_INLINE_ static RefPtr convert(const void* p_ptr) {
+
+ return Ref<Reference>(reinterpret_cast<const Reference*>(p_ptr)).get_ref_ptr();
+ }
+
+};
+
+#endif
#endif // REFERENCE_H
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 97bd5f2a32..3de26573f4 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -118,6 +118,7 @@ void register_core_types() {
ObjectTypeDB::register_type<Resource>();
ObjectTypeDB::register_type<FuncRef>();
ObjectTypeDB::register_virtual_type<StreamPeer>();
+ ObjectTypeDB::register_type<StreamPeerBuffer>();
ObjectTypeDB::register_create_type<StreamPeerTCP>();
ObjectTypeDB::register_create_type<TCP_Server>();
ObjectTypeDB::register_create_type<PacketPeerUDP>();
diff --git a/core/res_ptr.cpp b/core/res_ptr.cpp
deleted file mode 100644
index 2fada627e7..0000000000
--- a/core/res_ptr.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*************************************************************************/
-/* res_ptr.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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. */
-/*************************************************************************/
-#if 0
-#include "ref_ptr.h"
-#include "resource.h"
-#include "stdio.h"
-
-void RefPtr::operator=(const RefPtr& p_other) {
-
- Ref<Resource> *ref = reinterpret_cast<Ref<Resource>*>( &data[0] );
- Ref<Resource> *ref_other = reinterpret_cast<Ref<Resource>*>( const_cast<char*>(&p_other.data[0]) );
-
- *ref = *ref_other;
-}
-
-bool RefPtr::operator==(const RefPtr& p_other) const {
-
- Ref<Resource> *ref = reinterpret_cast<Ref<Resource>*>( &data[0] );
- Ref<Resource> *ref_other = reinterpret_cast<Ref<Resource>*>( const_cast<char*>(&p_other.data[0]) );
-
- return *ref == *ref_other;
-}
-
-RefPtr::RefPtr(const RefPtr& p_other) {
-
- memnew_placement(&data[0],Ref<Resource>);
-
- Ref<Resource> *ref = reinterpret_cast<Ref<Resource>*>( &data[0] );
- Ref<Resource> *ref_other = reinterpret_cast<Ref<Resource>*>( const_cast<char*>(&p_other.data[0]) );
-
- *ref = *ref_other;
-}
-
-bool RefPtr::is_null() const {
-
- Ref<Resource> *ref = reinterpret_cast<Ref<Resource>*>( &data[0] );
- return ref->is_null();
-
-
-}
-
-RID RefPtr::get_rid() const {
-
- Ref<Resource> *ref = reinterpret_cast<Ref<Resource>*>( &data[0] );
- if (ref->is_null())
- return RID();
- return (*ref)->get_rid();
-}
-
-RefPtr::RefPtr() {
-
- ERR_FAIL_COND(sizeof(Ref<Resource>)>DATASIZE);
- memnew_placement(&data[0],Ref<Resource>);
-}
-
-
-RefPtr::~RefPtr() {
-
- Ref<Resource> *ref = reinterpret_cast<Ref<Resource>*>( &data[0] );
- ref->~Ref<Resource>();
-}
-
-
-#endif
diff --git a/core/res_ptr.h b/core/res_ptr.h
deleted file mode 100644
index 54b74bb113..0000000000
--- a/core/res_ptr.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*************************************************************************/
-/* res_ptr.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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. */
-/*************************************************************************/
-#ifndef RES_PTR_H
-#define RES_PTR_H
-
-#if 0
-/**
- @author Juan Linietsky <reduzio@gmail.com>
- * This class exists to workaround a limitation in C++ but keep the design OK.
- * It's basically an opaque container of a Resource reference, so Variant can use it.
-*/
-
-#include "rid.h"
-
-class ResBase;
-
-class RefPtr {
-friend class ResBase;
- enum {
-
- DATASIZE=sizeof(void*)*4
- };
-
- mutable char data[DATASIZE]; // too much probably, virtual class + pointer
-public:
-
- bool is_null() const;
- void operator=(const RefPtr& p_other);
- bool operator==(const RefPtr& p_other) const;
- RID get_rid() const;
- RefPtr(const RefPtr& p_other);
- RefPtr();
- ~RefPtr();
-
-};
-#endif
-#endif
diff --git a/core/resource.cpp b/core/resource.cpp
index b7a5bad4b8..e8d4069779 100644
--- a/core/resource.cpp
+++ b/core/resource.cpp
@@ -30,7 +30,7 @@
#include "core_string_names.h"
#include <stdio.h>
#include "os/file_access.h"
-
+#include "io/resource_loader.h"
void ResourceImportMetadata::set_editor(const String& p_editor) {
@@ -95,10 +95,9 @@ bool ResourceImportMetadata::has_option(const String& p_key) const {
return options.has(p_key);
}
+
Variant ResourceImportMetadata::get_option(const String& p_key) const {
- if (!options.has(p_key))
- print_line(p_key);
ERR_FAIL_COND_V(!options.has(p_key),Variant());
return options[p_key];
@@ -133,6 +132,7 @@ void ResourceImportMetadata::_bind_methods() {
ObjectTypeDB::bind_method(_MD("add_source","path","md5"),&ResourceImportMetadata::add_source, "");
ObjectTypeDB::bind_method(_MD("get_source_path","idx"),&ResourceImportMetadata::get_source_path);
ObjectTypeDB::bind_method(_MD("get_source_md5","idx"),&ResourceImportMetadata::get_source_md5);
+ ObjectTypeDB::bind_method(_MD("set_source_md5","idx", "md5"),&ResourceImportMetadata::set_source_md5);
ObjectTypeDB::bind_method(_MD("remove_source","idx"),&ResourceImportMetadata::remove_source);
ObjectTypeDB::bind_method(_MD("get_source_count"),&ResourceImportMetadata::get_source_count);
ObjectTypeDB::bind_method(_MD("set_option","key","value"),&ResourceImportMetadata::set_option);
@@ -217,14 +217,36 @@ String Resource::get_name() const {
return name;
}
-bool Resource::can_reload_from_file() {
+bool Resource::editor_can_reload_from_file() {
- return false;
+ return true; //by default yes
}
void Resource::reload_from_file() {
+ String path=get_path();
+ if (!path.is_resource_file())
+ return;
+
+ Ref<Resource> s = ResourceLoader::load(path,get_type(),true);
+
+ if (!s.is_valid())
+ return;
+
+ List<PropertyInfo> pi;
+ s->get_property_list(&pi);
+
+ for (List<PropertyInfo>::Element *E=pi.front();E;E=E->next()) {
+
+ if (!(E->get().usage&PROPERTY_USAGE_STORAGE))
+ continue;
+ if (E->get().name=="resource/path")
+ continue; //do not change path
+
+ set(E->get().name,s->get(E->get().name));
+
+ }
}
@@ -464,8 +486,6 @@ void ResourceCache::dump(const char* p_file,bool p_short) {
if (!p_short) {
if (f)
f->store_line(r->get_type()+": "+r->get_path());
- else
- print_line(r->get_type()+": "+r->get_path());
}
}
@@ -473,8 +493,6 @@ void ResourceCache::dump(const char* p_file,bool p_short) {
if (f)
f->store_line(E->key()+" count: "+itos(E->get()));
- else
- print_line(E->key()+" count: "+itos(E->get()));
}
if (f) {
f->close();
diff --git a/core/resource.h b/core/resource.h
index 958414f62b..0673a4e89d 100644
--- a/core/resource.h
+++ b/core/resource.h
@@ -121,7 +121,7 @@ protected:
void _take_over_path(const String& p_path);
public:
- virtual bool can_reload_from_file();
+ virtual bool editor_can_reload_from_file();
virtual void reload_from_file();
void register_owner(Object *p_owner);
diff --git a/core/script_debugger_debugger.cpp b/core/script_debugger_debugger.cpp
deleted file mode 100644
index 71ad33f5ed..0000000000
--- a/core/script_debugger_debugger.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*************************************************************************/
-/* script_debugger_debugger.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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. */
-/*************************************************************************/
diff --git a/core/script_language.cpp b/core/script_language.cpp
index b3116a0297..fa1d01d3eb 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -32,7 +32,8 @@ ScriptLanguage *ScriptServer::_languages[MAX_LANGUAGES];
int ScriptServer::_language_count=0;
bool ScriptServer::scripting_enabled=true;
-
+bool ScriptServer::reload_scripts_on_save=false;
+ScriptEditRequestFunction ScriptServer::edit_request_func=NULL;
void Script::_notification( int p_what) {
@@ -85,6 +86,20 @@ void ScriptServer::register_language(ScriptLanguage *p_language) {
_languages[_language_count++]=p_language;
}
+void ScriptServer::unregister_language(ScriptLanguage *p_language) {
+
+
+ for(int i=0;i<_language_count;i++) {
+ if (_languages[i]==p_language) {
+ _language_count--;
+ if (i<_language_count) {
+ SWAP(_languages[i],_languages[_language_count]);
+ }
+ return;
+ }
+ }
+}
+
void ScriptServer::init_languages() {
for(int i=0;i<_language_count;i++) {
@@ -92,6 +107,32 @@ void ScriptServer::init_languages() {
}
}
+void ScriptServer::set_reload_scripts_on_save(bool p_enable) {
+
+ reload_scripts_on_save=p_enable;
+}
+
+bool ScriptServer::is_reload_scripts_on_save_enabled() {
+
+ return reload_scripts_on_save;
+}
+
+void ScriptServer::thread_enter() {
+
+ for(int i=0;i<_language_count;i++) {
+ _languages[i]->thread_enter();
+ }
+}
+
+void ScriptServer::thread_exit() {
+
+ for(int i=0;i<_language_count;i++) {
+ _languages[i]->thread_exit();
+ }
+
+}
+
+
void ScriptInstance::get_property_state(List<Pair<StringName, Variant> > &state) {
List<PropertyInfo> pinfo;
diff --git a/core/script_language.h b/core/script_language.h
index d8b4c61b6c..1b037e908c 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -38,6 +38,8 @@
class ScriptLanguage;
+typedef void (*ScriptEditRequestFunction)(const String& p_path);
+
class ScriptServer {
enum {
@@ -47,13 +49,23 @@ class ScriptServer {
static ScriptLanguage *_languages[MAX_LANGUAGES];
static int _language_count;
static bool scripting_enabled;
+ static bool reload_scripts_on_save;
public:
+ static ScriptEditRequestFunction edit_request_func;
+
static void set_scripting_enabled(bool p_enabled);
static bool is_scripting_enabled();
static int get_language_count();
static ScriptLanguage *get_language(int p_idx);
static void register_language(ScriptLanguage *p_language);
+ static void unregister_language(ScriptLanguage *p_language);
+
+ static void set_reload_scripts_on_save(bool p_enable);
+ static bool is_reload_scripts_on_save_enabled();
+
+ static void thread_enter();
+ static void thread_exit();
static void init_languages();
};
@@ -70,6 +82,7 @@ class Script : public Resource {
protected:
+ virtual bool editor_can_reload_from_file() { return false; } // this is handled by editor better
void _notification( int p_what);
static void _bind_methods();
@@ -79,6 +92,8 @@ public:
virtual bool can_instance() const=0;
+ virtual Ref<Script> get_base_script() const=0; //for script inheritance
+
virtual StringName get_instance_base_type() const=0; // this may not work in all scripts, will return empty if so
virtual ScriptInstance* instance_create(Object *p_this)=0;
virtual bool instance_has(const Object *p_this) const=0;
@@ -89,6 +104,9 @@ public:
virtual void set_source_code(const String& p_code)=0;
virtual Error reload(bool p_keep_state=false)=0;
+ virtual bool has_method(const StringName& p_method) const=0;
+ virtual MethodInfo get_method_info(const StringName& p_method) const=0;
+
virtual bool is_tool() const=0;
virtual String get_node_type() const=0;
@@ -101,6 +119,8 @@ public:
virtual bool get_property_default_value(const StringName& p_property,Variant& r_value) const=0;
virtual void update_exports() {} //editor tool
+ virtual void get_script_method_list(List<MethodInfo> *p_list) const=0;
+ virtual void get_script_property_list(List<PropertyInfo> *p_list) const=0;
Script() {}
@@ -108,6 +128,8 @@ public:
class ScriptInstance {
public:
+
+
virtual bool set(const StringName& p_name, const Variant& p_value)=0;
virtual bool get(const StringName& p_name, Variant &r_ret) const=0;
virtual void get_property_list(List<PropertyInfo> *p_properties) const=0;
@@ -124,11 +146,28 @@ public:
virtual void call_multilevel_reversed(const StringName& p_method,const Variant** p_args,int p_argcount);
virtual void notification(int p_notification)=0;
+ //this is used by script languages that keep a reference counter of their own
+ //you can make make Ref<> not die when it reaches zero, so deleting the reference
+ //depends entirely from the script
+
+ virtual void refcount_incremented() {}
+ virtual bool refcount_decremented() { return true; } //return true if it can die
virtual Ref<Script> get_script() const=0;
virtual bool is_placeholder() const { return false; }
+ enum RPCMode {
+ RPC_MODE_DISABLED,
+ RPC_MODE_REMOTE,
+ RPC_MODE_SYNC,
+ RPC_MODE_MASTER,
+ RPC_MODE_SLAVE,
+ };
+
+ virtual RPCMode get_rpc_mode(const StringName& p_method) const=0;
+ virtual RPCMode get_rset_mode(const StringName& p_variable) const=0;
+
virtual ScriptLanguage *get_language()=0;
virtual ~ScriptInstance();
};
@@ -162,7 +201,7 @@ public:
virtual void get_reserved_words(List<String> *p_words) const=0;
virtual void get_comment_delimiters(List<String> *p_delimiters) const=0;
virtual void get_string_delimiters(List<String> *p_delimiters) const=0;
- virtual String get_template(const String& p_class_name, const String& p_base_class_name) const=0;
+ virtual Ref<Script> get_template(const String& p_class_name, const String& p_base_class_name) const=0;
virtual bool validate(const String& p_script, int &r_line_error,int &r_col_error,String& r_test_error, const String& p_path="",List<String> *r_functions=NULL) const=0;
virtual Script *create_script() const=0;
virtual bool has_named_classes() const=0;
@@ -172,6 +211,12 @@ public:
virtual void auto_indent_code(String& p_code,int p_from_line,int p_to_line) const=0;
virtual void add_global_constant(const StringName& p_variable,const Variant& p_value)=0;
+ /* MULTITHREAD FUNCTIONS */
+
+ //some VMs need to be notified of thread creation/exiting to allocate a stack
+ virtual void thread_enter() {}
+ virtual void thread_exit() {}
+
/* DEBUGGER FUNCTIONS */
virtual String debug_get_error() const=0;
@@ -192,6 +237,7 @@ public:
virtual Vector<StackInfo> debug_get_current_stack_info() { return Vector<StackInfo>(); }
virtual void reload_all_scripts()=0;
+ virtual void reload_tool_script(const Ref<Script>& p_script,bool p_soft_reload)=0;
/* LOADER FUNCTIONS */
virtual void get_recognized_extensions(List<String> *p_extensions) const=0;
@@ -253,6 +299,9 @@ public:
virtual bool is_placeholder() const { return true; }
+ virtual RPCMode get_rpc_mode(const StringName& p_method) const { return RPC_MODE_DISABLED; }
+ virtual RPCMode get_rset_mode(const StringName& p_variable) const { return RPC_MODE_DISABLED; }
+
PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script,Object *p_owner);
~PlaceHolderScriptInstance();
diff --git a/core/string_db.cpp b/core/string_db.cpp
index 9a693f88e9..bf92c4eac4 100644
--- a/core/string_db.cpp
+++ b/core/string_db.cpp
@@ -183,7 +183,8 @@ StringName::StringName(const char *p_name) {
ERR_FAIL_COND(!configured);
- ERR_FAIL_COND( !p_name || !p_name[0]);
+ if (!p_name || p_name[0]==0)
+ return; //empty, ignore
_global_lock();
@@ -288,6 +289,9 @@ StringName::StringName(const String& p_name) {
ERR_FAIL_COND(!configured);
+ if (p_name==String())
+ return;
+
_global_lock();
uint32_t hash = p_name.hash();
diff --git a/core/translation.cpp b/core/translation.cpp
index ee0ef2ea09..4592d00598 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -32,11 +32,23 @@
#include "os/os.h"
static const char* locale_list[]={
+"aa", // Afar
+"aa_DJ", // Afar (Djibouti)
+"aa_ER", // Afar (Eritrea)
+"aa_ET", // Afar (Ethiopia)
+"af", // Afrikaans
+"af_ZA", // Afrikaans (South Africa)
+"agr_PE", // Aguaruna (Peru)
+"ak_GH", // Akan (Ghana)
+"am_ET", // Amharic (Ethiopia)
+"an_ES", // Aragonese (Spain)
+"anp_IN", // Angika (India)
"ar", // Arabic
"ar_AE", // Arabic (United Arab Emirates)
"ar_BH", // Arabic (Bahrain)
"ar_DZ", // Arabic (Algeria)
"ar_EG", // Arabic (Egypt)
+"ar_IN", // Arabic (India)
"ar_IQ", // Arabic (Iraq)
"ar_JO", // Arabic (Jordan)
"ar_KW", // Arabic (Kuwait)
@@ -47,45 +59,91 @@ static const char* locale_list[]={
"ar_QA", // Arabic (Qatar)
"ar_SA", // Arabic (Saudi Arabia)
"ar_SD", // Arabic (Sudan)
+"ar_SS", // Arabic (South Soudan)
"ar_SY", // Arabic (Syria)
"ar_TN", // Arabic (Tunisia)
"ar_YE", // Arabic (Yemen)
+"as_IN", // Assamese (India)
+"ast_ES", // Asturian (Spain)
+"ayc_PE", // Southern Aymara (Peru)
+"ay_PE", // Aymara (Peru)
+"az_AZ", // Azerbaijani (Azerbaijan)
"be", // Belarusian
"be_BY", // Belarusian (Belarus)
+"bem_ZM", // Bemba (Zambia)
+"ber_DZ", // Berber languages (Algeria)
+"ber_MA", // Berber languages (Morocco)
"bg", // Bulgarian
"bg_BG", // Bulgarian (Bulgaria)
+"bhb_IN", // Bhili (India)
+"bho_IN", // Bhojpuri (India)
+"bi_TV", // Bislama (Tuvalu)
+"bn", // Bengali
+"bn_BD", // Bengali (Bangladesh)
+"bn_IN", // Bengali (India)
+"bo", // Tibetan
+"bo_CN", // Tibetan (China)
+"bo_IN", // Tibetan (India)
+"br_FR", // Breton (France)
+"brx_IN", // Bodo (India)
+"bs_BA", // Bosnian (Bosnia and Herzegovina)
+"byn_ER", // Bilin (Eritrea)
"ca", // Catalan
+"ca_AD", // Catalan (Andorra)
"ca_ES", // Catalan (Spain)
+"ca_FR", // Catalan (France)
+"ca_IT", // Catalan (Italy)
+"ce_RU", // Chechen (Russia)
+"chr_US", // Cherokee (United States)
+"cmn_TW", // Mandarin Chinese (Taiwan)
+"crh_UA", // Crimean Tatar (Ukraine)
+"csb_PL", // Kashubian (Poland)
"cs", // Czech
"cs_CZ", // Czech (Czech Republic)
+"cv_RU", // Chuvash (Russia)
+"cy_GB", // Welsh (United Kingdom)
"da", // Danish
"da_DK", // Danish (Denmark)
"de", // German
"de_AT", // German (Austria)
+"de_BE", // German (Belgium)
"de_CH", // German (Switzerland)
"de_DE", // German (Germany)
+"de_IT", // German (Italy)
"de_LU", // German (Luxembourg)
+"doi_IN", // Dogri (India)
+"dv_MV", // Dhivehi (Maldives)
+"dz_BT", // Dzongkha (Bhutan)
"el", // Greek
"el_CY", // Greek (Cyprus)
"el_GR", // Greek (Greece)
"en", // English
+"en_AG", // English (Antigua and Barbuda)
"en_AU", // English (Australia)
+"en_BW", // English (Botswana)
"en_CA", // English (Canada)
+"en_DK", // English (Denmark)
"en_GB", // English (United Kingdom)
+"en_HK", // English (Hong Kong)
"en_IE", // English (Ireland)
+"en_IL", // English (Israel)
"en_IN", // English (India)
-"en_MT", // English (Malta)
+"en_NG", // English (Nigeria)
"en_NZ", // English (New Zealand)
"en_PH", // English (Philippines)
"en_SG", // English (Singapore)
"en_US", // English (United States)
"en_ZA", // English (South Africa)
+"en_ZM", // English (Zambia)
+"en_ZW", // English (Zimbabwe)
+"eo", // Esperanto
"es", // Spanish
"es_AR", // Spanish (Argentina)
"es_BO", // Spanish (Bolivia)
"es_CL", // Spanish (Chile)
"es_CO", // Spanish (Colombia)
"es_CR", // Spanish (Costa Rica)
+"es_CU", // Spanish (Cuba)
"es_DO", // Spanish (Dominican Republic)
"es_EC", // Spanish (Ecuador)
"es_ES", // Spanish (Spain)
@@ -103,97 +161,252 @@ static const char* locale_list[]={
"es_VE", // Spanish (Venezuela)
"et", // Estonian
"et_EE", // Estonian (Estonia)
+"eu", // Basque
+"eu_ES", // Basque (Spain)
+"fa", // Persian
+"fa_IR", // Persian (Iran)
+"ff_SN", // Fulah (Senegal)
"fi", // Finnish
"fi_FI", // Finnish (Finland)
+"fil_PH", // Filipino (Philippines)
+"fo_FO", // Faroese (Faroe Islands)
"fr", // French
"fr_BE", // French (Belgium)
"fr_CA", // French (Canada)
"fr_CH", // French (Switzerland)
"fr_FR", // French (France)
"fr_LU", // French (Luxembourg)
+"fur_IT", // Friulian (Italy)
+"fy_DE", // Western Frisian (Germany)
+"fy_NL", // Western Frisian (Netherlands)
"ga", // Irish
"ga_IE", // Irish (Ireland)
-"hi", // Hindi (India)
+"gd_GB", // Scottish Gaelic (United Kingdom)
+"gez_ER", // Geez (Eritrea)
+"gez_ET", // Geez (Ethiopia)
+"gl_ES", // Galician (Spain)
+"gu_IN", // Gujarati (India)
+"gv_GB", // Manx (United Kingdom)
+"hak_TW", // Hakka Chinese (Taiwan)
+"ha_NG", // Hausa (Nigeria)
+"he", // Hebrew
+"he_IL", // Hebrew (Israel)
+"hi", // Hindi
"hi_IN", // Hindi (India)
+"hne_IN", // Chhattisgarhi (India)
"hr", // Croatian
"hr_HR", // Croatian (Croatia)
+"hsb_DE", // Upper Sorbian (Germany)
+"ht_HT", // Haitian (Haiti)
"hu", // Hungarian
"hu_HU", // Hungarian (Hungary)
-"in", // Indonesian
-"in_ID", // Indonesian (Indonesia)
+"hus_MX", // Huastec (Mexico)
+"hy_AM", // Armenian (Armenia)
+"ia_FR", // Interlingua (France)
+"id", // Indonesian
+"id_ID", // Indonesian (Indonesia)
+"ig_NG", // Igbo (Nigeria)
+"ik_CA", // Inupiaq (Canada)
"is", // Icelandic
"is_IS", // Icelandic (Iceland)
"it", // Italian
"it_CH", // Italian (Switzerland)
"it_IT", // Italian (Italy)
-"iw", // Hebrew
-"iw_IL", // Hebrew (Israel)
+"iu_CA", // Inuktitut (Canada)
"ja", // Japanese
"ja_JP", // Japanese (Japan)
-"ja_JP_JP", // Japanese (Japan,JP)
+"kab_DZ", // Kabyle (Algeria)
+"ka_GE", // Georgian (Georgia)
+"kk_KZ", // Kazakh (Kazakhstan)
+"kl_GL", // Kalaallisut (Greenland)
+"km_KH", // Central Khmer (Cambodia)
+"kn_IN", // Kannada (India)
+"kok_IN", // Konkani (India)
"ko", // Korean
"ko_KR", // Korean (South Korea)
+"ks_IN", // Kashmiri (India)
+"ku", // Kurdish
+"ku_TR", // Kurdish (Turkey)
+"kw_GB", // Cornish (United Kingdom)
+"ky_KG", // Kirghiz (Kyrgyzstan)
+"lb_LU", // Luxembourgish (Luxembourg)
+"lg_UG", // Ganda (Uganda)
+"li_BE", // Limburgan (Belgium)
+"li_NL", // Limburgan (Netherlands)
+"lij_IT", // Ligurian (Italy)
+"ln_CD", // Lingala (Congo)
+"lo_LA", // Lao (Laos)
"lt", // Lithuanian
"lt_LT", // Lithuanian (Lithuania)
"lv", // Latvian
"lv_LV", // Latvian (Latvia)
+"lzh_TW", // Literary Chinese (Taiwan)
+"mag_IN", // Magahi (India)
+"mai_IN", // Maithili (India)
+"mg_MG", // Malagasy (Madagascar)
+"mh_MH", // Marshallese (Marshall Islands)
+"mhr_RU", // Eastern Mari (Russia)
+"mi_NZ", // Maori (New Zealand)
+"miq_NI", // Mískito (Nicaragua)
"mk", // Macedonian
"mk_MK", // Macedonian (Macedonia)
+"ml_IN", // Malayalam (India)
+"mni_IN", // Manipuri (India)
+"mn_MN", // Mongolian (Mongolia)
+"mr_IN", // Marathi (India)
"ms", // Malay
"ms_MY", // Malay (Malaysia)
"mt", // Maltese
"mt_MT", // Maltese (Malta)
+"my_MM", // Burmese (Myanmar)
+"myv_RU", // Erzya (Russia)
+"nah_MX", // Nahuatl languages (Mexico)
+"nan_TW", // Min Nan Chinese (Taiwan)
+"nb", // Norwegian Bokmål
+"nb_NO", // Norwegian Bokmål (Norway)
+"nds_DE", // Low German (Germany)
+"nds_NL", // Low German (Netherlands)
+"ne_NP", // Nepali (Nepal)
+"nhn_MX", // Central Nahuatl (Mexico)
+"niu_NU", // Niuean (Niue)
+"niu_NZ", // Niuean (New Zealand)
"nl", // Dutch
+"nl_AW", // Dutch (Aruba)
"nl_BE", // Dutch (Belgium)
"nl_NL", // Dutch (Netherlands)
-"no", // Norwegian
-"no_NO", // Norwegian (Norway)
-"no_NO_NY", // Norwegian (Norway,Nynorsk)
+"nn", // Norwegian Nynorsk
+"nn_NO", // Norwegian Nynorsk (Norway)
+"nr_ZA", // South Ndebele (South Africa)
+"nso_ZA", // Pedi (South Africa)
+"oc_FR", // Occitan (France)
+"om", // Oromo
+"om_ET", // Oromo (Ethiopia)
+"om_KE", // Oromo (Kenya)
+"or_IN", // Oriya (India)
+"os_RU", // Ossetian (Russia)
+"pa_IN", // Panjabi (India)
+"pap", // Papiamento
+"pap_AN", // Papiamento (Netherlands Antilles)
+"pap_AW", // Papiamento (Aruba)
+"pap_CW", // Papiamento (Curaçao)
+"pa_PK", // Panjabi (Pakistan)
"pl", // Polish
"pl_PL", // Polish (Poland)
+"ps_AF", // Pushto (Afghanistan)
"pt", // Portuguese
"pt_BR", // Portuguese (Brazil)
"pt_PT", // Portuguese (Portugal)
+"quy_PE", // Ayacucho Quechua (Peru)
+"quz_PE", // Cusco Quechua (Peru)
+"raj_IN", // Rajasthani (India)
"ro", // Romanian
"ro_RO", // Romanian (Romania)
"ru", // Russian
"ru_RU", // Russian (Russia)
+"ru_UA", // Russian (Ukraine)
+"rw_RW", // Kinyarwanda (Rwanda)
+"sa_IN", // Sanskrit (India)
+"sat_IN", // Santali (India)
+"sc_IT", // Sardinian (Italy)
+"sd_IN", // Sindhi (India)
+"se_NO", // Northern Sami (Norway)
+"sgs_LT", // Samogitian (Lithuania)
+"shs_CA", // Shuswap (Canada)
+"sid_ET", // Sidamo (Ethiopia)
+"si_LK", // Sinhala (Sri Lanka)
"sk", // Slovak
"sk_SK", // Slovak (Slovakia)
"sl", // Slovenian
"sl_SI", // Slovenian (Slovenia)
+"so", // Somali
+"so_DJ", // Somali (Djibouti)
+"so_ET", // Somali (Ethiopia)
+"so_KE", // Somali (Kenya)
+"so_SO", // Somali (Somalia)
+"son_ML", // Songhai languages (Mali)
"sq", // Albanian
"sq_AL", // Albanian (Albania)
+"sq_KV", // Albanian (Kosovo)
+"sq_MK", // Albanian (Macedonia)
"sr", // Serbian
-"sr_BA", // Serbian (Bosnia and Herzegovina)
-"sr_CS", // Serbian (Serbia and Montenegro)
"sr_ME", // Serbian (Montenegro)
"sr_RS", // Serbian (Serbia)
+"ss_ZA", // Swati (South Africa)
+"st_ZA", // Southern Sotho (South Africa)
"sv", // Swedish
+"sv_FI", // Swedish (Finland)
"sv_SE", // Swedish (Sweden)
+"sw_KE", // Swahili (Kenya)
+"sw_TZ", // Swahili (Tanzania)
+"szl_PL", // Silesian (Poland)
+"ta", // Tamil
+"ta_IN", // Tamil (India)
+"ta_LK", // Tamil (Sri Lanka)
+"tcy_IN", // Tulu (India)
+"te_IN", // Telugu (India)
+"tg_TJ", // Tajik (Tajikistan)
+"the_NP", // Chitwania Tharu (Nepal)
"th", // Thai
"th_TH", // Thai (Thailand)
-"th_TH_TH", // Thai (Thailand,TH)
+"ti", // Tigrinya
+"ti_ER", // Tigrinya (Eritrea)
+"ti_ET", // Tigrinya (Ethiopia)
+"tig_ER", // Tigre (Eritrea)
+"tk_TM", // Turkmen (Turkmenistan)
+"tl_PH", // Tagalog (Philippines)
+"tn_ZA", // Tswana (South Africa)
"tr", // Turkish
+"tr_CY", // Turkish (Cyprus)
"tr_TR", // Turkish (Turkey)
+"ts_ZA", // Tsonga (South Africa)
+"tt_RU", // Tatar (Russia)
+"ug_CN", // Uighur (China)
"uk", // Ukrainian
"uk_UA", // Ukrainian (Ukraine)
+"unm_US", // Unami (United States)
+"ur", // Urdu
+"ur_IN", // Urdu (India)
+"ur_PK", // Urdu (Pakistan)
+"uz", // Uzbek
+"uz_UZ", // Uzbek (Uzbekistan)
+"ve_ZA", // Venda (South Africa)
"vi", // Vietnamese
"vi_VN", // Vietnamese (Vietnam)
+"wa_BE", // Walloon (Belgium)
+"wae_CH", // Walser (Switzerland)
+"wal_ET", // Wolaytta (Ethiopia)
+"wo_SN", // Wolof (Senegal)
+"xh_ZA", // Xhosa (South Africa)
+"yi_US", // Yiddish (United States)
+"yo_NG", // Yoruba (Nigeria)
+"yue_HK", // Yue Chinese (Hong Kong)
"zh", // Chinese
"zh_CN", // Chinese (China)
"zh_HK", // Chinese (Hong Kong)
"zh_SG", // Chinese (Singapore)
"zh_TW", // Chinese (Taiwan)
+"zu_ZA", // Zulu (South Africa)
0
};
static const char* locale_names[]={
+"Afar",
+"Afar (Djibouti)",
+"Afar (Eritrea)",
+"Afar (Ethiopia)",
+"Afrikaans",
+"Afrikaans (South Africa)",
+"Aguaruna (Peru)",
+"Akan (Ghana)",
+"Amharic (Ethiopia)",
+"Aragonese (Spain)",
+"Angika (India)",
"Arabic",
"Arabic (United Arab Emirates)",
"Arabic (Bahrain)",
"Arabic (Algeria)",
"Arabic (Egypt)",
+"Arabic (India)",
"Arabic (Iraq)",
"Arabic (Jordan)",
"Arabic (Kuwait)",
@@ -204,45 +417,91 @@ static const char* locale_names[]={
"Arabic (Qatar)",
"Arabic (Saudi Arabia)",
"Arabic (Sudan)",
+"Arabic (South Soudan)",
"Arabic (Syria)",
"Arabic (Tunisia)",
"Arabic (Yemen)",
+"Assamese (India)",
+"Asturian (Spain)",
+"Southern Aymara (Peru)",
+"Aymara (Peru)",
+"Azerbaijani (Azerbaijan)",
"Belarusian",
"Belarusian (Belarus)",
+"Bemba (Zambia)",
+"Berber languages (Algeria)",
+"Berber languages (Morocco)",
"Bulgarian",
"Bulgarian (Bulgaria)",
+"Bhili (India)",
+"Bhojpuri (India)",
+"Bislama (Tuvalu)",
+"Bengali",
+"Bengali (Bangladesh)",
+"Bengali (India)",
+"Tibetan",
+"Tibetan (China)",
+"Tibetan (India)",
+"Breton (France)",
+"Bodo (India)",
+"Bosnian (Bosnia and Herzegovina)",
+"Bilin (Eritrea)",
"Catalan",
+"Catalan (Andorra)",
"Catalan (Spain)",
+"Catalan (France)",
+"Catalan (Italy)",
+"Chechen (Russia)",
+"Cherokee (United States)",
+"Mandarin Chinese (Taiwan)",
+"Crimean Tatar (Ukraine)",
+"Kashubian (Poland)",
"Czech",
"Czech (Czech Republic)",
+"Chuvash (Russia)",
+"Welsh (United Kingdom)",
"Danish",
"Danish (Denmark)",
"German",
"German (Austria)",
+"German (Belgium)",
"German (Switzerland)",
"German (Germany)",
+"German (Italy)",
"German (Luxembourg)",
+"Dogri (India)",
+"Dhivehi (Maldives)",
+"Dzongkha (Bhutan)",
"Greek",
"Greek (Cyprus)",
"Greek (Greece)",
"English",
+"English (Antigua and Barbuda)",
"English (Australia)",
+"English (Botswana)",
"English (Canada)",
+"English (Denmark)",
"English (United Kingdom)",
+"English (Hong Kong)",
"English (Ireland)",
+"English (Israel)",
"English (India)",
-"English (Malta)",
+"English (Nigeria)",
"English (New Zealand)",
"English (Philippines)",
"English (Singapore)",
"English (United States)",
"English (South Africa)",
+"English (Zambia)",
+"English (Zimbabwe)",
+"Esperanto",
"Spanish",
"Spanish (Argentina)",
"Spanish (Bolivia)",
"Spanish (Chile)",
"Spanish (Colombia)",
"Spanish (Costa Rica)",
+"Spanish (Cuba)",
"Spanish (Dominican Republic)",
"Spanish (Ecuador)",
"Spanish (Spain)",
@@ -260,88 +519,231 @@ static const char* locale_names[]={
"Spanish (Venezuela)",
"Estonian",
"Estonian (Estonia)",
+"Basque",
+"Basque (Spain)",
+"Persian",
+"Persian (Iran)",
+"Fulah (Senegal)",
"Finnish",
"Finnish (Finland)",
+"Filipino (Philippines)",
+"Faroese (Faroe Islands)",
"French",
"French (Belgium)",
"French (Canada)",
"French (Switzerland)",
"French (France)",
"French (Luxembourg)",
+"Friulian (Italy)",
+"Western Frisian (Germany)",
+"Western Frisian (Netherlands)",
"Irish",
"Irish (Ireland)",
+"Scottish Gaelic (United Kingdom)",
+"Geez (Eritrea)",
+"Geez (Ethiopia)",
+"Galician (Spain)",
+"Gujarati (India)",
+"Manx (United Kingdom)",
+"Hakka Chinese (Taiwan)",
+"Hausa (Nigeria)",
+"Hebrew",
+"Hebrew (Israel)",
+"Hindi",
"Hindi (India)",
-"Hindi (India)",
+"Chhattisgarhi (India)",
"Croatian",
"Croatian (Croatia)",
+"Upper Sorbian (Germany)",
+"Haitian (Haiti)",
"Hungarian",
"Hungarian (Hungary)",
+"Huastec (Mexico)",
+"Armenian (Armenia)",
+"Interlingua (France)",
"Indonesian",
"Indonesian (Indonesia)",
+"Igbo (Nigeria)",
+"Inupiaq (Canada)",
"Icelandic",
"Icelandic (Iceland)",
"Italian",
"Italian (Switzerland)",
"Italian (Italy)",
-"Hebrew",
-"Hebrew (Israel)",
+"Inuktitut (Canada)",
"Japanese",
"Japanese (Japan)",
-"Japanese (Japan JP)",
+"Kabyle (Algeria)",
+"Georgian (Georgia)",
+"Kazakh (Kazakhstan)",
+"Kalaallisut (Greenland)",
+"Central Khmer (Cambodia)",
+"Kannada (India)",
+"Konkani (India)",
"Korean",
"Korean (South Korea)",
+"Kashmiri (India)",
+"Kurdish",
+"Kurdish (Turkey)",
+"Cornish (United Kingdom)",
+"Kirghiz (Kyrgyzstan)",
+"Luxembourgish (Luxembourg)",
+"Ganda (Uganda)",
+"Limburgan (Belgium)",
+"Limburgan (Netherlands)",
+"Ligurian (Italy)",
+"Lingala (Congo)",
+"Lao (Laos)",
"Lithuanian",
"Lithuanian (Lithuania)",
"Latvian",
"Latvian (Latvia)",
+"Literary Chinese (Taiwan)",
+"Magahi (India)",
+"Maithili (India)",
+"Malagasy (Madagascar)",
+"Marshallese (Marshall Islands)",
+"Eastern Mari (Russia)",
+"Maori (New Zealand)",
+"Mískito (Nicaragua)",
"Macedonian",
"Macedonian (Macedonia)",
+"Malayalam (India)",
+"Manipuri (India)",
+"Mongolian (Mongolia)",
+"Marathi (India)",
"Malay",
"Malay (Malaysia)",
"Maltese",
"Maltese (Malta)",
+"Burmese (Myanmar)",
+"Erzya (Russia)",
+"Nahuatl languages (Mexico)",
+"Min Nan Chinese (Taiwan)",
+"Norwegian Bokmål",
+"Norwegian Bokmål (Norway)",
+"Low German (Germany)",
+"Low German (Netherlands)",
+"Nepali (Nepal)",
+"Central Nahuatl (Mexico)",
+"Niuean (Niue)",
+"Niuean (New Zealand)",
"Dutch",
+"Dutch (Aruba)",
"Dutch (Belgium)",
"Dutch (Netherlands)",
-"Norwegian",
-"Norwegian (Norway)",
-"Norwegian (Norway Nynorsk)",
+"Norwegian Nynorsk",
+"Norwegian Nynorsk (Norway)",
+"South Ndebele (South Africa)",
+"Pedi (South Africa)",
+"Occitan (France)",
+"Oromo",
+"Oromo (Ethiopia)",
+"Oromo (Kenya)",
+"Oriya (India)",
+"Ossetian (Russia)",
+"Panjabi (India)",
+"Papiamento",
+"Papiamento (Netherlands Antilles)",
+"Papiamento (Aruba)",
+"Papiamento (Curaçao)",
+"Panjabi (Pakistan)",
"Polish",
"Polish (Poland)",
+"Pushto (Afghanistan)",
"Portuguese",
"Portuguese (Brazil)",
"Portuguese (Portugal)",
+"Ayacucho Quechua (Peru)",
+"Cusco Quechua (Peru)",
+"Rajasthani (India)",
"Romanian",
"Romanian (Romania)",
"Russian",
"Russian (Russia)",
+"Russian (Ukraine)",
+"Kinyarwanda (Rwanda)",
+"Sanskrit (India)",
+"Santali (India)",
+"Sardinian (Italy)",
+"Sindhi (India)",
+"Northern Sami (Norway)",
+"Samogitian (Lithuania)",
+"Shuswap (Canada)",
+"Sidamo (Ethiopia)",
+"Sinhala (Sri Lanka)",
"Slovak",
"Slovak (Slovakia)",
"Slovenian",
"Slovenian (Slovenia)",
+"Somali",
+"Somali (Djibouti)",
+"Somali (Ethiopia)",
+"Somali (Kenya)",
+"Somali (Somalia)",
+"Songhai languages (Mali)",
"Albanian",
"Albanian (Albania)",
+"Albanian (Kosovo)",
+"Albanian (Macedonia)",
"Serbian",
-"Serbian (Bosnia and Herzegovina)",
-"Serbian (Serbia and Montenegro)",
"Serbian (Montenegro)",
"Serbian (Serbia)",
+"Swati (South Africa)",
+"Southern Sotho (South Africa)",
"Swedish",
+"Swedish (Finland)",
"Swedish (Sweden)",
+"Swahili (Kenya)",
+"Swahili (Tanzania)",
+"Silesian (Poland)",
+"Tamil",
+"Tamil (India)",
+"Tamil (Sri Lanka)",
+"Tulu (India)",
+"Telugu (India)",
+"Tajik (Tajikistan)",
+"Chitwania Tharu (Nepal)",
"Thai",
"Thai (Thailand)",
-"Thai (Thailand TH)",
+"Tigrinya",
+"Tigrinya (Eritrea)",
+"Tigrinya (Ethiopia)",
+"Tigre (Eritrea)",
+"Turkmen (Turkmenistan)",
+"Tagalog (Philippines)",
+"Tswana (South Africa)",
"Turkish",
+"Turkish (Cyprus)",
"Turkish (Turkey)",
+"Tsonga (South Africa)",
+"Tatar (Russia)",
+"Uighur (China)",
"Ukrainian",
"Ukrainian (Ukraine)",
+"Unami (United States)",
+"Urdu",
+"Urdu (India)",
+"Urdu (Pakistan)",
+"Uzbek",
+"Uzbek (Uzbekistan)",
+"Venda (South Africa)",
"Vietnamese",
"Vietnamese (Vietnam)",
+"Walloon (Belgium)",
+"Walser (Switzerland)",
+"Wolaytta (Ethiopia)",
+"Wolof (Senegal)",
+"Xhosa (South Africa)",
+"Yiddish (United States)",
+"Yoruba (Nigeria)",
+"Yue Chinese (Hong Kong)",
"Chinese",
"Chinese (China)",
"Chinese (Hong Kong)",
"Chinese (Singapore)",
"Chinese (Taiwan)",
+"Zulu (South Africa)",
0
};
diff --git a/core/typedefs.h b/core/typedefs.h
index 6f9bb58958..30a75e66da 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -296,5 +296,6 @@ struct _GlobalLock {
#define __STR(m_index) __STRX(m_index)
+
#endif /* typedefs.h */
diff --git a/core/ucaps.h b/core/ucaps.h
index 9c07828006..cf42e96b4f 100644
--- a/core/ucaps.h
+++ b/core/ucaps.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* ucaps.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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. */
+/*************************************************************************/
#ifndef UCAPS_H
#define UCAPS_H
diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp
index d6d32ccaef..99740b365c 100644
--- a/core/undo_redo.cpp
+++ b/core/undo_redo.cpp
@@ -52,26 +52,46 @@ void UndoRedo::_discard_redo() {
}
-
-void UndoRedo::create_action(const String& p_name,bool p_mergeable) {
+void UndoRedo::create_action(const String& p_name,MergeMode p_mode) {
if (action_level==0) {
_discard_redo();
- if (p_mergeable && actions.size() && actions[actions.size()-1].name==p_name) {
- //old will replace new (it's mergeable after all)
- // should check references though!
+ // Check if the merge operation is valid
+ if (p_mode!=MERGE_DISABLE && actions.size() && actions[actions.size()-1].name==p_name) {
+
current_action=actions.size()-2;
- actions[current_action+1].do_ops.clear();
- //actions[current_action+1].undo_ops.clear(); - no, this is kept
- merging=true;
+
+ if (p_mode==MERGE_ENDS) {
+
+ // Clear all do ops from last action, and delete all object references
+ List<Operation>::Element *E=actions[current_action+1].do_ops.front();
+
+ while (E) {
+
+ if (E->get().type==Operation::TYPE_REFERENCE) {
+
+ Object *obj=ObjectDB::get_instance(E->get().object);
+
+ if (obj)
+ memdelete(obj);
+ }
+
+ E=E->next();
+ actions[current_action+1].do_ops.pop_front();
+ }
+ }
+
+ merge_mode=p_mode;
} else {
+
Action new_action;
new_action.name=p_name;
actions.push_back(new_action);
- merging=false;
+
+ merge_mode=MERGE_DISABLE;
}
}
@@ -102,8 +122,10 @@ void UndoRedo::add_undo_method(Object *p_object,const String& p_method,VARIANT_A
VARIANT_ARGPTRS
ERR_FAIL_COND(action_level<=0);
ERR_FAIL_COND((current_action+1)>=actions.size());
- if (merging)
- return; //- no undo if merging
+
+ // No undo if the merge mode is MERGE_ENDS
+ if (merge_mode==MERGE_ENDS)
+ return;
Operation undo_op;
undo_op.object=p_object->get_instance_ID();
@@ -139,6 +161,10 @@ void UndoRedo::add_undo_property(Object *p_object,const String& p_property,const
ERR_FAIL_COND(action_level<=0);
ERR_FAIL_COND((current_action+1)>=actions.size());
+ // No undo if the merge mode is MERGE_ENDS
+ if (merge_mode==MERGE_ENDS)
+ return;
+
Operation undo_op;
undo_op.object=p_object->get_instance_ID();
if (p_object->cast_to<Resource>())
@@ -167,6 +193,11 @@ void UndoRedo::add_undo_reference(Object *p_object) {
ERR_FAIL_COND(action_level<=0);
ERR_FAIL_COND((current_action+1)>=actions.size());
+
+ // No undo if the merge mode is MERGE_ENDS
+ if (merge_mode==MERGE_ENDS)
+ return;
+
Operation undo_op;
undo_op.object=p_object->get_instance_ID();
if (p_object->cast_to<Resource>())
@@ -352,7 +383,7 @@ UndoRedo::UndoRedo() {
action_level=0;
current_action=-1;
max_steps=-1;
- merging=true;
+ merge_mode=MERGE_DISABLE;
callback=NULL;
callback_ud=NULL;
@@ -448,7 +479,7 @@ Variant UndoRedo::_add_undo_method(const Variant** p_args, int p_argcount, Varia
void UndoRedo::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("create_action","name","mergeable"),&UndoRedo::create_action, DEFVAL(false) );
+ ObjectTypeDB::bind_method(_MD("create_action","name","merge_mode"),&UndoRedo::create_action, DEFVAL(MERGE_DISABLE) );
ObjectTypeDB::bind_method(_MD("commit_action"),&UndoRedo::commit_action);
//ObjectTypeDB::bind_method(_MD("add_do_method","p_object", "p_method", "VARIANT_ARG_LIST"),&UndoRedo::add_do_method);
@@ -489,4 +520,8 @@ void UndoRedo::_bind_methods() {
ObjectTypeDB::bind_method(_MD("clear_history"),&UndoRedo::clear_history);
ObjectTypeDB::bind_method(_MD("get_current_action_name"),&UndoRedo::get_current_action_name);
ObjectTypeDB::bind_method(_MD("get_version"),&UndoRedo::get_version);
+
+ BIND_CONSTANT(MERGE_DISABLE);
+ BIND_CONSTANT(MERGE_ENDS);
+ BIND_CONSTANT(MERGE_ALL);
}
diff --git a/core/undo_redo.h b/core/undo_redo.h
index 7f63ba9ed6..208eb6ed5e 100644
--- a/core/undo_redo.h
+++ b/core/undo_redo.h
@@ -41,6 +41,12 @@ class UndoRedo : public Object {
OBJ_SAVE_TYPE( UndoRedo );
public:
+ enum MergeMode {
+ MERGE_DISABLE,
+ MERGE_ENDS,
+ MERGE_ALL
+ };
+
typedef void (*CommitNotifyCallback)(void *p_ud,const String& p_name);
Variant _add_do_method(const Variant** p_args, int p_argcount, Variant::CallError& r_error);
Variant _add_undo_method(const Variant** p_args, int p_argcount, Variant::CallError& r_error);
@@ -76,7 +82,7 @@ private:
int current_action;
int action_level;
int max_steps;
- bool merging;
+ MergeMode merge_mode;
uint64_t version;
void _pop_history_tail();
@@ -98,7 +104,7 @@ protected:
public:
- void create_action(const String& p_name="",bool p_mergeable=false);
+ void create_action(const String& p_name="",MergeMode p_mode=MERGE_DISABLE);
void add_do_method(Object *p_object,const String& p_method,VARIANT_ARG_LIST);
void add_undo_method(Object *p_object,const String& p_method,VARIANT_ARG_LIST);
@@ -128,4 +134,6 @@ public:
~UndoRedo();
};
+VARIANT_ENUM_CAST( UndoRedo::MergeMode );
+
#endif // UNDO_REDO_H
diff --git a/core/ustring.cpp b/core/ustring.cpp
index a039ba11cd..0d887210c3 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -32,6 +32,7 @@
#include "print_string.h"
#include "math_funcs.h"
#include "io/md5.h"
+#include "io/sha256.h"
#include "ucaps.h"
#include "color.h"
#include "variant.h"
@@ -256,13 +257,10 @@ bool String::operator==(const StrRange &p_range) const {
return true;
const CharType *c_str=p_range.c_str;
-
- int l=length();
-
- const CharType *dst = p_range.c_str;
+ const CharType *dst = &operator[](0);
/* Compare char by char */
- for (int i=0;i<l;i++) {
+ for (int i=0;i<len;i++) {
if (c_str[i]!=dst[i])
return false;
@@ -849,21 +847,23 @@ const CharType * String::c_str() const {
}
String String::md5(const uint8_t *p_md5) {
+ return String::hex_encode_buffer(p_md5, 16);
+}
- String ret;
+String String::hex_encode_buffer(const uint8_t *p_buffer, int p_len) {
+ static const char hex[16]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
- for(int i=0;i<16;i++) {
+ String ret;
+ char v[2]={0,0};
- static const char hex[16]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
- char v[2]={0,0};
- v[0]=hex[p_md5[i]>>4];
+ for(int i=0;i<p_len;i++) {
+ v[0]=hex[p_buffer[i]>>4];
ret+=v;
- v[0]=hex[p_md5[i]&0xF];
+ v[0]=hex[p_buffer[i]&0xF];
ret+=v;
}
return ret;
-
}
String String::chr(CharType p_char) {
@@ -2389,6 +2389,16 @@ String String::md5_text() const {
return String::md5(ctx.digest);
}
+String String::sha256_text() const {
+ CharString cs=utf8();
+ unsigned char hash[32];
+ sha256_context ctx;
+ sha256_init(&ctx);
+ sha256_hash(&ctx,(unsigned char*)cs.ptr(),cs.length());
+ sha256_done(&ctx, hash);
+ return String::hex_encode_buffer(hash, 32);
+}
+
Vector<uint8_t> String::md5_buffer() const {
CharString cs=utf8();
@@ -2406,6 +2416,23 @@ Vector<uint8_t> String::md5_buffer() const {
return ret;
};
+Vector<uint8_t> String::sha256_buffer() const {
+ CharString cs = utf8();
+ unsigned char hash[32];
+ sha256_context ctx;
+ sha256_init(&ctx);
+ sha256_hash(&ctx, (unsigned char*)cs.ptr(), cs.length());
+ sha256_done(&ctx, hash);
+
+ Vector<uint8_t> ret;
+ ret.resize(32);
+ for (int i = 0; i < 32; i++) {
+ ret[i] = hash[i];
+ }
+
+ return ret;
+}
+
String String::insert(int p_at_pos,String p_string) const {
@@ -2752,6 +2779,94 @@ bool String::begins_with(const char* p_string) const {
}
+bool String::is_subsequence_of(const String& p_string) const {
+
+ return _base_is_subsequence_of(p_string, false);
+}
+
+bool String::is_subsequence_ofi(const String& p_string) const {
+
+ return _base_is_subsequence_of(p_string, true);
+}
+
+bool String::_base_is_subsequence_of(const String& p_string, bool case_insensitive) const {
+
+ int len=length();
+ if (len == 0) {
+ // Technically an empty string is subsequence of any string
+ return true;
+ }
+
+ if (len > p_string.length()) {
+ return false;
+ }
+
+ const CharType *src = &operator[](0);
+ const CharType *tgt = &p_string[0];
+
+ for (;*src && *tgt;tgt++) {
+ bool match = false;
+ if (case_insensitive) {
+ CharType srcc = _find_lower(*src);
+ CharType tgtc = _find_lower(*tgt);
+ match = srcc == tgtc;
+ } else {
+ match = *src == *tgt;
+ }
+ if (match) {
+ src++;
+ if(!*src) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+Vector<String> String::bigrams() const {
+ int n_pairs = length() - 1;
+ Vector<String> b;
+ if(n_pairs <= 0) {
+ return b;
+ }
+ b.resize(n_pairs);
+ for(int i = 0; i < n_pairs; i++) {
+ b[i] = substr(i,2);
+ }
+ return b;
+}
+
+// Similarity according to Sorensen-Dice coefficient
+float String::similarity(const String& p_string) const {
+ if(operator==(p_string)) {
+ // Equal strings are totally similar
+ return 1.0f;
+ }
+ if (length() < 2 || p_string.length() < 2) {
+ // No way to calculate similarity without a single bigram
+ return 0.0f;
+ }
+
+ Vector<String> src_bigrams = bigrams();
+ Vector<String> tgt_bigrams = p_string.bigrams();
+
+ int src_size = src_bigrams.size();
+ int tgt_size = tgt_bigrams.size();
+
+ float sum = src_size + tgt_size;
+ float inter = 0;
+ for (int i = 0; i < src_size; i++) {
+ for (int j = 0; j < tgt_size; j++) {
+ if (src_bigrams[i] == tgt_bigrams[j]) {
+ inter++;
+ break;
+ }
+ }
+ }
+
+ return (2.0f * inter)/sum;
+}
static bool _wildcard_match(const CharType* p_pattern, const CharType* p_string,bool p_case_sensitive) {
switch (*p_pattern) {
@@ -3376,7 +3491,7 @@ bool String::is_valid_integer() const {
return false;
int from=0;
- if (operator[](0)=='+' || operator[](0)=='-')
+ if (len!=1 && (operator[](0)=='+' || operator[](0)=='-'))
from++;
for(int i=from;i<len;i++) {
@@ -3721,7 +3836,6 @@ String String::lpad(int min_length, const String& character) const {
String String::sprintf(const Array& values, bool* error) const {
String formatted;
CharType* self = (CharType*)c_str();
- int num_items = values.size();
bool in_format = false;
int value_index = 0;
int min_chars;
diff --git a/core/ustring.h b/core/ustring.h
index e03f74f506..bb57b11d88 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -46,11 +46,9 @@ public:
operator const char*() {return get_data();};
};
-#ifndef CHARTYPE_16BITS
+
typedef wchar_t CharType;
-#else
-typedef wchar_t uint16_t;
-#endif
+
struct StrRange {
@@ -66,6 +64,7 @@ class String : public Vector<CharType> {
void copy_from(const char *p_cstr);
void copy_from(const CharType* p_cstr, int p_clip_to=-1);
void copy_from(const CharType& p_char);
+ bool _base_is_subsequence_of(const String& p_string, bool case_insensitive) const;
public:
@@ -122,6 +121,10 @@ public:
bool begins_with(const String& p_string) const;
bool begins_with(const char* p_string) const;
bool ends_with(const String& p_string) const;
+ bool is_subsequence_of(const String& p_string) const;
+ bool is_subsequence_ofi(const String& p_string) const;
+ Vector<String> bigrams() const;
+ float similarity(const String& p_string) const;
String replace_first(String p_key,String p_with) const;
String replace(String p_key,String p_with) const;
String replacen(String p_key,String p_with) const;
@@ -137,6 +140,7 @@ public:
static String num_int64(int64_t p_num,int base=10,bool capitalize_hex=false);
static String chr(CharType p_char);
static String md5(const uint8_t *p_md5);
+ static String hex_encode_buffer(const uint8_t *p_buffer, int p_len);
bool is_numeric() const;
double to_double() const;
float to_float() const;
@@ -190,7 +194,9 @@ public:
uint32_t hash() const; /* hash the string */
uint64_t hash64() const; /* hash the string */
String md5_text() const;
+ String sha256_text() const;
Vector<uint8_t> md5_buffer() const;
+ Vector<uint8_t> sha256_buffer() const;
inline bool empty() const { return length() == 0; }
diff --git a/core/variant.cpp b/core/variant.cpp
index 38f5e69cc0..a78c07d819 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -1445,12 +1445,12 @@ Variant::operator unsigned char() const {
return 0;
}
-#ifndef CHARTYPE_16BITS
+
Variant::operator CharType() const {
return operator unsigned int();
}
-#endif
+
Variant::operator float() const {
@@ -1515,15 +1515,43 @@ Variant::operator String() const {
case INT: return String::num(_data._int);
case REAL: return String::num(_data._real);
case STRING: return *reinterpret_cast<const String*>(_data._mem);
- case VECTOR2: return operator Vector2();
- case RECT2: return operator Rect2();
- case MATRIX32: return operator Matrix32();
- case VECTOR3: return operator Vector3();
+ case VECTOR2: return "("+operator Vector2()+")";
+ case RECT2: return "("+operator Rect2()+")";
+ case MATRIX32: {
+
+ Matrix32 mat32 = operator Matrix32();
+ return "("+Variant(mat32.elements[0]).operator String()+", "+Variant(mat32.elements[1]).operator String()+", "+Variant(mat32.elements[2]).operator String()+")";
+ } break;
+ case VECTOR3: return "("+operator Vector3()+")";
case PLANE: return operator Plane();
//case QUAT:
case _AABB: return operator AABB();
- case QUAT: return operator Quat();
- case MATRIX3: return operator Matrix3();
+ case QUAT: return "("+operator Quat()+")";
+ case MATRIX3: {
+
+ Matrix3 mat3 = operator Matrix3();
+
+ String mtx("(");
+ for (int i=0;i<3;i++) {
+
+ if (i!=0)
+ mtx+=", ";
+
+ mtx+="(";
+
+ for (int j=0;j<3;j++) {
+
+ if (j!=0)
+ mtx+=", ";
+
+ mtx+=Variant( mat3.elements[i][j] ).operator String();
+ }
+
+ mtx+=")";
+ }
+
+ return mtx+")";
+ } break;
case TRANSFORM: return operator Transform();
case NODE_PATH: return operator NodePath();
case INPUT_EVENT: return operator InputEvent();
@@ -1559,72 +1587,78 @@ Variant::operator String() const {
case VECTOR2_ARRAY: {
DVector<Vector2> vec = operator DVector<Vector2>();
- String str;
+ String str("[");
for(int i=0;i<vec.size();i++) {
if (i>0)
str+=", ";
str=str+Variant( vec[i] );
}
+ str += "]";
return str;
} break;
case VECTOR3_ARRAY: {
DVector<Vector3> vec = operator DVector<Vector3>();
- String str;
+ String str("[");
for(int i=0;i<vec.size();i++) {
if (i>0)
str+=", ";
str=str+Variant( vec[i] );
}
+ str += "]";
return str;
} break;
case STRING_ARRAY: {
DVector<String> vec = operator DVector<String>();
- String str;
+ String str("[");
for(int i=0;i<vec.size();i++) {
if (i>0)
str+=", ";
str=str+vec[i];
}
+ str += "]";
return str;
} break;
case INT_ARRAY: {
DVector<int> vec = operator DVector<int>();
- String str;
+ String str("[");
for(int i=0;i<vec.size();i++) {
if (i>0)
str+=", ";
str=str+itos(vec[i]);
}
+ str += "]";
return str;
} break;
case REAL_ARRAY: {
DVector<real_t> vec = operator DVector<real_t>();
- String str;
+ String str("[");
for(int i=0;i<vec.size();i++) {
if (i>0)
str+=", ";
str=str+rtos(vec[i]);
}
+ str += "]";
return str;
} break;
case ARRAY: {
Array arr = operator Array();
- String str;
+ String str("[");
for (int i=0; i<arr.size(); i++) {
if (i)
str+=", ";
str += String(arr[i]);
};
+ str += "]";
return str;
} break;
@@ -3029,9 +3063,9 @@ String Variant::get_call_error_text(Object* p_base, const StringName& p_method,c
int errorarg=ce.argument;
err_text="Cannot convert argument "+itos(errorarg+1)+" from "+Variant::get_type_name(p_argptrs[errorarg]->get_type())+" to "+Variant::get_type_name(ce.expected)+".";
} else if (ce.error==Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS) {
- err_text="Expected "+itos(ce.argument)+" arguments.";
+ err_text="Method expected "+itos(ce.argument)+" arguments, but called with "+itos(p_argcount)+".";
} else if (ce.error==Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS) {
- err_text="Expected "+itos(ce.argument)+" arguments.";
+ err_text="Method expected "+itos(ce.argument)+" arguments, but called with "+itos(p_argcount)+".";
} else if (ce.error==Variant::CallError::CALL_ERROR_INVALID_METHOD) {
err_text="Method not found.";
} else if (ce.error==Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL) {
diff --git a/core/variant.h b/core/variant.h
index b95223ecfb..90be593bd9 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -151,11 +151,7 @@ private:
InputEvent *_input_event;
Image *_image;
void *_ptr; //generic pointer
-#ifdef USE_QUAD_VECTORS
- uint8_t _mem[sizeof(ObjData) > (sizeof(real_t)*5) ? sizeof(ObjData) : (sizeof(real_t)*5)]; // plane uses an extra real
-#else
uint8_t _mem[sizeof(ObjData) > (sizeof(real_t)*4) ? sizeof(ObjData) : (sizeof(real_t)*4)];
-#endif
} _data;
@@ -202,9 +198,8 @@ public:
operator unsigned long() const;
#endif
-#ifndef CHARTYPE_16BITS
+
operator CharType() const;
-#endif
operator float() const;
operator double() const;
operator String() const;
@@ -390,6 +385,7 @@ public:
Type expected;
};
+ void call_ptr(const StringName& p_method,const Variant** p_args,int p_argcount,Variant* r_ret,CallError &r_error);
Variant call(const StringName& p_method,const Variant** p_args,int p_argcount,CallError &r_error);
Variant call(const StringName& p_method,const Variant& p_arg1=Variant(),const Variant& p_arg2=Variant(),const Variant& p_arg3=Variant(),const Variant& p_arg4=Variant(),const Variant& p_arg5=Variant());
@@ -399,6 +395,10 @@ public:
void get_method_list(List<MethodInfo> *p_list) const;
bool has_method(const StringName& p_method) const;
+ static Vector<Variant::Type> get_method_argument_types(Variant::Type p_type,const StringName& p_method);
+ static Vector<Variant> get_method_default_arguments(Variant::Type p_type,const StringName& p_method);
+ static Variant::Type get_method_return_type(Variant::Type p_type,const StringName& p_method,bool* r_has_return=NULL);
+ static Vector<StringName> get_method_argument_names(Variant::Type p_type,const StringName& p_method);
void set_named(const StringName& p_index, const Variant& p_value, bool *r_valid=NULL);
Variant get_named(const StringName& p_index, bool *r_valid=NULL) const;
@@ -426,7 +426,7 @@ public:
static void get_constructor_list(Variant::Type p_type, List<MethodInfo> *p_list);
static void get_numeric_constants_for_type(Variant::Type p_type, List<StringName> *p_constants);
static bool has_numeric_constant(Variant::Type p_type, const StringName& p_value);
- static int get_numeric_constant_value(Variant::Type p_type, const StringName& p_value);
+ static int get_numeric_constant_value(Variant::Type p_type, const StringName& p_value,bool *r_valid=NULL);
typedef String (*ObjectDeConstruct)(const Variant& p_object,void *ud);
typedef void (*ObjectConstruct)(const String& p_text,void *ud,Variant& r_value);
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 4be763a511..e7e71e8251 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -54,10 +54,10 @@ struct _VariantCall {
int arg_count;
Vector<Variant> default_args;
Vector<Variant::Type> arg_types;
-
-#ifdef DEBUG_ENABLED
Vector<StringName> arg_names;
Variant::Type return_type;
+
+#ifdef DEBUG_ENABLED
bool returns;
#endif
VariantFunc func;
@@ -247,6 +247,10 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1R(String,matchn);
VCALL_LOCALMEM1R(String,begins_with);
VCALL_LOCALMEM1R(String,ends_with);
+ VCALL_LOCALMEM1R(String,is_subsequence_of);
+ VCALL_LOCALMEM1R(String,is_subsequence_ofi);
+ VCALL_LOCALMEM0R(String,bigrams);
+ VCALL_LOCALMEM1R(String,similarity);
VCALL_LOCALMEM2R(String,replace);
VCALL_LOCALMEM2R(String,replacen);
VCALL_LOCALMEM2R(String,insert);
@@ -262,10 +266,12 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM0R(String,basename);
VCALL_LOCALMEM1R(String,plus_file);
VCALL_LOCALMEM1R(String,ord_at);
- //VCALL_LOCALMEM2R(String,erase);
+ VCALL_LOCALMEM2(String,erase);
VCALL_LOCALMEM0R(String,hash);
VCALL_LOCALMEM0R(String,md5_text);
+ VCALL_LOCALMEM0R(String,sha256_text);
VCALL_LOCALMEM0R(String,md5_buffer);
+ VCALL_LOCALMEM0R(String,sha256_buffer);
VCALL_LOCALMEM0R(String,empty);
VCALL_LOCALMEM0R(String,is_abs_path);
VCALL_LOCALMEM0R(String,is_rel_path);
@@ -339,6 +345,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1R(Vector2,reflect);
VCALL_LOCALMEM0R(Vector2,angle);
// VCALL_LOCALMEM1R(Vector2,cross);
+ VCALL_LOCALMEM0R(Vector2,abs);
VCALL_LOCALMEM0R(Rect2,get_area);
VCALL_LOCALMEM1R(Rect2,intersects);
@@ -445,6 +452,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(Dictionary,erase);
VCALL_LOCALMEM0R(Dictionary,hash);
VCALL_LOCALMEM0R(Dictionary,keys);
+ VCALL_LOCALMEM0R(Dictionary,values);
VCALL_LOCALMEM1R(Dictionary,parse_json);
VCALL_LOCALMEM0R(Dictionary,to_json);
@@ -462,7 +470,11 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(Array,resize);
VCALL_LOCALMEM2(Array,insert);
VCALL_LOCALMEM1(Array,remove);
- VCALL_LOCALMEM1R(Array,find);
+ VCALL_LOCALMEM2R(Array,find);
+ VCALL_LOCALMEM2R(Array,rfind);
+ VCALL_LOCALMEM1R(Array,find_last);
+ VCALL_LOCALMEM1R(Array,count);
+ VCALL_LOCALMEM1R(Array,has);
VCALL_LOCALMEM1(Array,erase);
VCALL_LOCALMEM0(Array,sort);
VCALL_LOCALMEM2(Array,sort_custom);
@@ -501,56 +513,77 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1R(ByteArray,get);
VCALL_LOCALMEM1(ByteArray,push_back);
VCALL_LOCALMEM1(ByteArray,resize);
+ VCALL_LOCALMEM2R(ByteArray,insert);
+ VCALL_LOCALMEM1(ByteArray,remove);
VCALL_LOCALMEM1(ByteArray,append);
VCALL_LOCALMEM1(ByteArray,append_array);
+ VCALL_LOCALMEM0(ByteArray,invert);
VCALL_LOCALMEM0R(IntArray,size);
VCALL_LOCALMEM2(IntArray,set);
VCALL_LOCALMEM1R(IntArray,get);
VCALL_LOCALMEM1(IntArray,push_back);
VCALL_LOCALMEM1(IntArray,resize);
+ VCALL_LOCALMEM2R(IntArray,insert);
+ VCALL_LOCALMEM1(IntArray,remove);
VCALL_LOCALMEM1(IntArray,append);
VCALL_LOCALMEM1(IntArray,append_array);
+ VCALL_LOCALMEM0(IntArray,invert);
VCALL_LOCALMEM0R(RealArray,size);
VCALL_LOCALMEM2(RealArray,set);
VCALL_LOCALMEM1R(RealArray,get);
VCALL_LOCALMEM1(RealArray,push_back);
VCALL_LOCALMEM1(RealArray,resize);
+ VCALL_LOCALMEM2R(RealArray,insert);
+ VCALL_LOCALMEM1(RealArray,remove);
VCALL_LOCALMEM1(RealArray,append);
VCALL_LOCALMEM1(RealArray,append_array);
+ VCALL_LOCALMEM0(RealArray,invert);
VCALL_LOCALMEM0R(StringArray,size);
VCALL_LOCALMEM2(StringArray,set);
VCALL_LOCALMEM1R(StringArray,get);
VCALL_LOCALMEM1(StringArray,push_back);
VCALL_LOCALMEM1(StringArray,resize);
+ VCALL_LOCALMEM2R(StringArray,insert);
+ VCALL_LOCALMEM1(StringArray,remove);
VCALL_LOCALMEM1(StringArray,append);
VCALL_LOCALMEM1(StringArray,append_array);
+ VCALL_LOCALMEM0(StringArray,invert);
VCALL_LOCALMEM0R(Vector2Array,size);
VCALL_LOCALMEM2(Vector2Array,set);
VCALL_LOCALMEM1R(Vector2Array,get);
VCALL_LOCALMEM1(Vector2Array,push_back);
VCALL_LOCALMEM1(Vector2Array,resize);
+ VCALL_LOCALMEM2R(Vector2Array,insert);
+ VCALL_LOCALMEM1(Vector2Array,remove);
VCALL_LOCALMEM1(Vector2Array,append);
VCALL_LOCALMEM1(Vector2Array,append_array);
+ VCALL_LOCALMEM0(Vector2Array,invert);
VCALL_LOCALMEM0R(Vector3Array,size);
VCALL_LOCALMEM2(Vector3Array,set);
VCALL_LOCALMEM1R(Vector3Array,get);
VCALL_LOCALMEM1(Vector3Array,push_back);
VCALL_LOCALMEM1(Vector3Array,resize);
+ VCALL_LOCALMEM2R(Vector3Array,insert);
+ VCALL_LOCALMEM1(Vector3Array,remove);
VCALL_LOCALMEM1(Vector3Array,append);
VCALL_LOCALMEM1(Vector3Array,append_array);
+ VCALL_LOCALMEM0(Vector3Array,invert);
VCALL_LOCALMEM0R(ColorArray,size);
VCALL_LOCALMEM2(ColorArray,set);
VCALL_LOCALMEM1R(ColorArray,get);
VCALL_LOCALMEM1(ColorArray,push_back);
VCALL_LOCALMEM1(ColorArray,resize);
+ VCALL_LOCALMEM2R(ColorArray,insert);
+ VCALL_LOCALMEM1(ColorArray,remove);
VCALL_LOCALMEM1(ColorArray,append);
VCALL_LOCALMEM1(ColorArray,append_array);
+ VCALL_LOCALMEM0(ColorArray,invert);
#define VCALL_PTR0(m_type,m_method)\
static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(); }
@@ -915,10 +948,22 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
struct ConstantData {
Map<StringName,int> value;
+#ifdef DEBUG_ENABLED
+ List<StringName> value_ordered;
+#endif
};
static ConstantData* constant_data;
+ static void add_constant(int p_type, StringName p_constant_name, int p_constant_value) {
+
+ constant_data[p_type].value[p_constant_name] = p_constant_value;
+#ifdef DEBUG_ENABLED
+ constant_data[p_type].value_ordered.push_back(p_constant_name);
+#endif
+
+ }
+
};
_VariantCall::TypeFunc* _VariantCall::type_funcs=NULL;
@@ -929,26 +974,32 @@ _VariantCall::ConstantData* _VariantCall::constant_data=NULL;
Variant Variant::call(const StringName& p_method,const Variant** p_args,int p_argcount,CallError &r_error) {
Variant ret;
+ call_ptr(p_method,p_args,p_argcount,&ret,r_error);
+ return ret;
+}
+
+void Variant::call_ptr(const StringName& p_method,const Variant** p_args,int p_argcount,Variant* r_ret,CallError &r_error) {
+ Variant ret;
if (type==Variant::OBJECT) {
//call object
Object *obj = _get_obj().obj;
if (!obj) {
r_error.error=CallError::CALL_ERROR_INSTANCE_IS_NULL;
- return ret;
+ return;
}
#ifdef DEBUG_ENABLED
if (ScriptDebugger::get_singleton() && _get_obj().ref.is_null()) {
//only if debugging!
if (!ObjectDB::instance_validate(obj)) {
r_error.error=CallError::CALL_ERROR_INSTANCE_IS_NULL;
- return ret;
+ return;
}
}
#endif
- return _get_obj().obj->call(p_method,p_args,p_argcount,r_error);
+ ret=_get_obj().obj->call(p_method,p_args,p_argcount,r_error);
//else if (type==Variant::METHOD) {
@@ -960,14 +1011,15 @@ Variant Variant::call(const StringName& p_method,const Variant** p_args,int p_ar
#ifdef DEBUG_ENABLED
if (!E) {
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
- return Variant();
+ return;
}
#endif
_VariantCall::FuncData& funcdata = E->get();
funcdata.call(ret,*this,p_args,p_argcount,r_error);
}
- return ret;
+ if (r_error.error==Variant::CallError::CALL_OK && r_ret)
+ *r_ret=ret;
}
#define VCALL(m_type,m_method) _VariantCall::_call_##m_type##_##m_method
@@ -1121,6 +1173,56 @@ bool Variant::has_method(const StringName& p_method) const {
}
+Vector<Variant::Type> Variant::get_method_argument_types(Variant::Type p_type,const StringName& p_method) {
+
+ const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type];
+
+ const Map<StringName,_VariantCall::FuncData>::Element *E = fd.functions.find(p_method);
+ if (!E)
+ return Vector<Variant::Type>();
+
+ return E->get().arg_types;
+}
+
+Vector<StringName> Variant::get_method_argument_names(Variant::Type p_type,const StringName& p_method) {
+
+
+ const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type];
+
+ const Map<StringName,_VariantCall::FuncData>::Element *E = fd.functions.find(p_method);
+ if (!E)
+ return Vector<StringName>();
+
+ return E->get().arg_names;
+
+}
+
+Variant::Type Variant::get_method_return_type(Variant::Type p_type,const StringName& p_method,bool* r_has_return) {
+
+ const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type];
+
+ const Map<StringName,_VariantCall::FuncData>::Element *E = fd.functions.find(p_method);
+ if (!E)
+ return Variant::NIL;
+
+ if (r_has_return)
+ *r_has_return=E->get().return_type;
+
+ return E->get().return_type;
+}
+
+Vector<Variant> Variant::get_method_default_arguments(Variant::Type p_type,const StringName& p_method) {
+
+ const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type];
+
+ const Map<StringName,_VariantCall::FuncData>::Element *E = fd.functions.find(p_method);
+ if (!E)
+ return Vector<Variant>();
+
+ return E->get().default_args;
+
+}
+
void Variant::get_method_list(List<MethodInfo> *p_list) const {
@@ -1202,9 +1304,15 @@ void Variant::get_numeric_constants_for_type(Variant::Type p_type, List<StringNa
_VariantCall::ConstantData& cd = _VariantCall::constant_data[p_type];
+#ifdef DEBUG_ENABLED
+ for(List<StringName>::Element *E=cd.value_ordered.front();E;E=E->next()) {
+
+ p_constants->push_back(E->get());
+#else
for(Map<StringName,int>::Element *E=cd.value.front();E;E=E->next()) {
p_constants->push_back(E->key());
+#endif
}
}
@@ -1216,14 +1324,22 @@ bool Variant::has_numeric_constant(Variant::Type p_type, const StringName& p_val
return cd.value.has(p_value);
}
-int Variant::get_numeric_constant_value(Variant::Type p_type, const StringName& p_value) {
+int Variant::get_numeric_constant_value(Variant::Type p_type, const StringName& p_value, bool *r_valid) {
+
+ if (r_valid)
+ *r_valid=false;
ERR_FAIL_INDEX_V(p_type,Variant::VARIANT_MAX,0);
_VariantCall::ConstantData& cd = _VariantCall::constant_data[p_type];
Map<StringName,int>::Element *E = cd.value.find(p_value);
- ERR_FAIL_COND_V(!E,0);
+ if (!E) {
+ return -1;
+ }
+ if (r_valid)
+ *r_valid=true;
+
return E->get();
}
@@ -1264,6 +1380,10 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(STRING,BOOL,String,matchn,STRING,"expr",varray());
ADDFUNC1(STRING,BOOL,String,begins_with,STRING,"text",varray());
ADDFUNC1(STRING,BOOL,String,ends_with,STRING,"text",varray());
+ ADDFUNC1(STRING,BOOL,String,is_subsequence_of,STRING,"text",varray());
+ ADDFUNC1(STRING,BOOL,String,is_subsequence_ofi,STRING,"text",varray());
+ ADDFUNC0(STRING,STRING_ARRAY,String,bigrams,varray());
+ ADDFUNC1(STRING,REAL,String,similarity,STRING,"text",varray());
ADDFUNC2(STRING,STRING,String,replace,STRING,"what",STRING,"forwhat",varray());
ADDFUNC2(STRING,STRING,String,replacen,STRING,"what",STRING,"forwhat",varray());
@@ -1281,11 +1401,13 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(STRING,STRING,String,extension,varray());
ADDFUNC0(STRING,STRING,String,basename,varray());
ADDFUNC1(STRING,STRING,String,plus_file,STRING,"file",varray());
- ADDFUNC1(STRING,STRING,String,ord_at,INT,"at",varray());
-// ADDFUNC2(STRING,String,erase,INT,INT,varray());
+ ADDFUNC1(STRING,INT,String,ord_at,INT,"at",varray());
+ ADDFUNC2(STRING,NIL,String,erase,INT,"pos",INT,"chars", varray());
ADDFUNC0(STRING,INT,String,hash,varray());
ADDFUNC0(STRING,STRING,String,md5_text,varray());
+ ADDFUNC0(STRING,STRING,String,sha256_text,varray());
ADDFUNC0(STRING,RAW_ARRAY,String,md5_buffer,varray());
+ ADDFUNC0(STRING,RAW_ARRAY,String,sha256_buffer,varray());
ADDFUNC0(STRING,BOOL,String,empty,varray());
ADDFUNC0(STRING,BOOL,String,is_abs_path,varray());
ADDFUNC0(STRING,BOOL,String,is_rel_path,varray());
@@ -1333,6 +1455,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(VECTOR2,VECTOR2,Vector2,slide,VECTOR2,"vec",varray());
ADDFUNC1(VECTOR2,VECTOR2,Vector2,reflect,VECTOR2,"vec",varray());
//ADDFUNC1(VECTOR2,REAL,Vector2,cross,VECTOR2,"with",varray());
+ ADDFUNC0(VECTOR2,VECTOR2,Vector2,abs,varray());
ADDFUNC0(RECT2,REAL,Rect2,get_area,varray());
ADDFUNC1(RECT2,BOOL,Rect2,intersects,RECT2,"b",varray());
@@ -1427,11 +1550,12 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(DICTIONARY,INT,Dictionary,size,varray());
ADDFUNC0(DICTIONARY,BOOL,Dictionary,empty,varray());
ADDFUNC0(DICTIONARY,NIL,Dictionary,clear,varray());
- ADDFUNC1(DICTIONARY,BOOL,Dictionary,has,NIL,"value",varray());
- ADDFUNC1(DICTIONARY,BOOL,Dictionary,has_all,ARRAY,"values",varray());
- ADDFUNC1(DICTIONARY,NIL,Dictionary,erase,NIL,"value",varray());
+ ADDFUNC1(DICTIONARY,BOOL,Dictionary,has,NIL,"key",varray());
+ ADDFUNC1(DICTIONARY,BOOL,Dictionary,has_all,ARRAY,"keys",varray());
+ ADDFUNC1(DICTIONARY,NIL,Dictionary,erase,NIL,"key",varray());
ADDFUNC0(DICTIONARY,INT,Dictionary,hash,varray());
ADDFUNC0(DICTIONARY,ARRAY,Dictionary,keys,varray());
+ ADDFUNC0(DICTIONARY,ARRAY,Dictionary,values,varray());
ADDFUNC1(DICTIONARY,INT,Dictionary,parse_json,STRING,"json",varray());
ADDFUNC0(DICTIONARY,STRING,Dictionary,to_json,varray());
@@ -1447,7 +1571,11 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC2(ARRAY,NIL,Array,insert,INT,"pos",NIL,"value",varray());
ADDFUNC1(ARRAY,NIL,Array,remove,INT,"pos",varray());
ADDFUNC1(ARRAY,NIL,Array,erase,NIL,"value",varray());
- ADDFUNC1(ARRAY,INT,Array,find,NIL,"value",varray());
+ ADDFUNC2(ARRAY,INT,Array,find,NIL,"what",INT,"from",varray(0));
+ ADDFUNC2(ARRAY,INT,Array,rfind,NIL,"what",INT,"from",varray(-1));
+ ADDFUNC1(ARRAY,INT,Array,find_last,NIL,"value",varray());
+ ADDFUNC1(ARRAY,INT,Array,count,NIL,"value",varray());
+ ADDFUNC1(ARRAY,BOOL,Array,has,NIL,"value",varray());
ADDFUNC0(ARRAY,NIL,Array,pop_back,varray());
ADDFUNC0(ARRAY,NIL,Array,pop_front,varray());
ADDFUNC0(ARRAY,NIL,Array,sort,varray());
@@ -1457,9 +1585,13 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(RAW_ARRAY,INT,ByteArray,size,varray());
ADDFUNC2(RAW_ARRAY,NIL,ByteArray,set,INT,"idx",INT,"byte",varray());
- //ADDFUNC1(RAW_ARRAY,INT,ByteArray,get,INT,"idx",varray());
ADDFUNC1(RAW_ARRAY,NIL,ByteArray,push_back,INT,"byte",varray());
+ ADDFUNC1(RAW_ARRAY,NIL,ByteArray,append,INT,"byte",varray());
+ ADDFUNC1(RAW_ARRAY,NIL,ByteArray,append_array,RAW_ARRAY,"array",varray());
+ ADDFUNC1(RAW_ARRAY,NIL,ByteArray,remove,INT,"idx",varray());
+ ADDFUNC2(RAW_ARRAY,INT,ByteArray,insert,INT,"idx",INT,"byte",varray());
ADDFUNC1(RAW_ARRAY,NIL,ByteArray,resize,INT,"idx",varray());
+ ADDFUNC0(RAW_ARRAY,NIL,ByteArray,invert,varray());
ADDFUNC0(RAW_ARRAY,STRING,ByteArray,get_string_from_ascii,varray());
ADDFUNC0(RAW_ARRAY,STRING,ByteArray,get_string_from_utf8,varray());
@@ -1467,39 +1599,63 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(INT_ARRAY,INT,IntArray,size,varray());
ADDFUNC2(INT_ARRAY,NIL,IntArray,set,INT,"idx",INT,"integer",varray());
- //ADDFUNC1(INT_ARRAY,INT,IntArray,get,INT,"idx",varray());
ADDFUNC1(INT_ARRAY,NIL,IntArray,push_back,INT,"integer",varray());
+ ADDFUNC1(INT_ARRAY,NIL,IntArray,append,INT,"integer",varray());
+ ADDFUNC1(INT_ARRAY,NIL,IntArray,append_array,INT_ARRAY,"array",varray());
+ ADDFUNC1(INT_ARRAY,NIL,IntArray,remove,INT,"idx",varray());
+ ADDFUNC2(INT_ARRAY,INT,IntArray,insert,INT,"idx",INT,"integer",varray());
ADDFUNC1(INT_ARRAY,NIL,IntArray,resize,INT,"idx",varray());
+ ADDFUNC0(INT_ARRAY,NIL,IntArray,invert,varray());
ADDFUNC0(REAL_ARRAY,INT,RealArray,size,varray());
ADDFUNC2(REAL_ARRAY,NIL,RealArray,set,INT,"idx",REAL,"value",varray());
- //ADDFUNC1(REAL_ARRAY,REAL,RealArray,get,INT,"idx",varray());
ADDFUNC1(REAL_ARRAY,NIL,RealArray,push_back,REAL,"value",varray());
+ ADDFUNC1(REAL_ARRAY,NIL,RealArray,append,REAL,"value",varray());
+ ADDFUNC1(REAL_ARRAY,NIL,RealArray,append_array,REAL_ARRAY,"array",varray());
+ ADDFUNC1(REAL_ARRAY,NIL,RealArray,remove,INT,"idx",varray());
+ ADDFUNC2(REAL_ARRAY,INT,RealArray,insert,INT,"idx",REAL,"value",varray());
ADDFUNC1(REAL_ARRAY,NIL,RealArray,resize,INT,"idx",varray());
+ ADDFUNC0(REAL_ARRAY,NIL,RealArray,invert,varray());
ADDFUNC0(STRING_ARRAY,INT,StringArray,size,varray());
ADDFUNC2(STRING_ARRAY,NIL,StringArray,set,INT,"idx",STRING,"string",varray());
- //ADDFUNC1(STRING_ARRAY,STRING,StringArray,get,INT,"idx",varray());
ADDFUNC1(STRING_ARRAY,NIL,StringArray,push_back,STRING,"string",varray());
+ ADDFUNC1(STRING_ARRAY,NIL,StringArray,append,STRING,"string",varray());
+ ADDFUNC1(STRING_ARRAY,NIL,StringArray,append_array,STRING_ARRAY,"array",varray());
+ ADDFUNC1(STRING_ARRAY,NIL,StringArray,remove,INT,"idx",varray());
+ ADDFUNC2(STRING_ARRAY,INT,StringArray,insert,INT,"idx",STRING,"string",varray());
ADDFUNC1(STRING_ARRAY,NIL,StringArray,resize,INT,"idx",varray());
+ ADDFUNC0(STRING_ARRAY,NIL,StringArray,invert,varray());
ADDFUNC0(VECTOR2_ARRAY,INT,Vector2Array,size,varray());
ADDFUNC2(VECTOR2_ARRAY,NIL,Vector2Array,set,INT,"idx",VECTOR2,"vector2",varray());
- //ADDFUNC1(VECTOR2_ARRAY,VECTOR2,Vector2Array,get,INT,"idx",varray());
ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,push_back,VECTOR2,"vector2",varray());
+ ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,append,VECTOR2,"vector2",varray());
+ ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,append_array,VECTOR2_ARRAY,"array",varray());
+ ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,remove,INT,"idx",varray());
+ ADDFUNC2(VECTOR2_ARRAY,INT,Vector2Array,insert,INT,"idx",VECTOR2,"vector2",varray());
ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,resize,INT,"idx",varray());
+ ADDFUNC0(VECTOR2_ARRAY,NIL,Vector2Array,invert,varray());
ADDFUNC0(VECTOR3_ARRAY,INT,Vector3Array,size,varray());
ADDFUNC2(VECTOR3_ARRAY,NIL,Vector3Array,set,INT,"idx",VECTOR3,"vector3",varray());
- //ADDFUNC1(VECTOR3_ARRAY,VECTOR3,Vector3Array,get,INT,"idx",varray());
ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,push_back,VECTOR3,"vector3",varray());
+ ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,append,VECTOR3,"vector3",varray());
+ ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,append_array,VECTOR3_ARRAY,"array",varray());
+ ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,remove,INT,"idx",varray());
+ ADDFUNC2(VECTOR3_ARRAY,INT,Vector3Array,insert,INT,"idx",VECTOR3,"vector3",varray());
ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,resize,INT,"idx",varray());
+ ADDFUNC0(VECTOR3_ARRAY,NIL,Vector3Array,invert,varray());
ADDFUNC0(COLOR_ARRAY,INT,ColorArray,size,varray());
ADDFUNC2(COLOR_ARRAY,NIL,ColorArray,set,INT,"idx",COLOR,"color",varray());
- //ADDFUNC1(COLOR_ARRAY,COLOR,ColorArray,get,INT,"idx",varray());
ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,push_back,COLOR,"color",varray());
+ ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,append,COLOR,"color",varray());
+ ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,append_array,COLOR_ARRAY,"array",varray());
+ ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,remove,INT,"idx",varray());
+ ADDFUNC2(COLOR_ARRAY,INT,ColorArray,insert,INT,"idx",COLOR,"color",varray());
ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,resize,INT,"idx",varray());
+ ADDFUNC0(COLOR_ARRAY,NIL,ColorArray,invert,varray());
//pointerbased
@@ -1571,10 +1727,10 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(INPUT_EVENT,BOOL,InputEvent,is_pressed,varray());
ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action,STRING,"action",varray());
- ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action_pressed,STRING,"is_action_pressed",varray());
- ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action_released,STRING,"is_action_released",varray());
+ ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action_pressed,STRING,"action",varray());
+ ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action_released,STRING,"action",varray());
ADDFUNC0(INPUT_EVENT,BOOL,InputEvent,is_echo,varray());
- ADDFUNC2(INPUT_EVENT,NIL,InputEvent,set_as_action,STRING,"action",BOOL,"pressed",varray());
+ ADDFUNC2(INPUT_EVENT,NIL,InputEvent,set_as_action,STRING,"action",BOOL,"pressed",varray());
/* REGISTER CONSTRUCTORS */
@@ -1593,7 +1749,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
_VariantCall::add_constructor(_VariantCall::Plane_init3,Variant::PLANE,"normal",Variant::VECTOR3,"d",Variant::REAL);
_VariantCall::add_constructor(_VariantCall::Quat_init1,Variant::QUAT,"x",Variant::REAL,"y",Variant::REAL,"z",Variant::REAL,"w",Variant::REAL);
- _VariantCall::add_constructor(_VariantCall::Quat_init2,Variant::QUAT,"axis",Variant::VECTOR3,"angle",Variant::REAL);
+ _VariantCall::add_constructor(_VariantCall::Quat_init2,Variant::QUAT,"axis",Variant::VECTOR3,"angle",Variant::REAL);
_VariantCall::add_constructor(_VariantCall::Color_init1,Variant::COLOR,"r",Variant::REAL,"g",Variant::REAL,"b",Variant::REAL,"a",Variant::REAL);
_VariantCall::add_constructor(_VariantCall::Color_init2,Variant::COLOR,"r",Variant::REAL,"g",Variant::REAL,"b",Variant::REAL);
@@ -1610,51 +1766,54 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
/* REGISTER CONSTANTS */
- _VariantCall::constant_data[Variant::VECTOR3].value["AXIS_X"]=Vector3::AXIS_X;
- _VariantCall::constant_data[Variant::VECTOR3].value["AXIS_Y"]=Vector3::AXIS_Y;
- _VariantCall::constant_data[Variant::VECTOR3].value["AXIS_Z"]=Vector3::AXIS_Z;
-
- _VariantCall::constant_data[Variant::INPUT_EVENT].value["NONE"]=InputEvent::NONE;
- _VariantCall::constant_data[Variant::INPUT_EVENT].value["KEY"]=InputEvent::KEY;
- _VariantCall::constant_data[Variant::INPUT_EVENT].value["MOUSE_MOTION"]=InputEvent::MOUSE_MOTION;
- _VariantCall::constant_data[Variant::INPUT_EVENT].value["MOUSE_BUTTON"]=InputEvent::MOUSE_BUTTON;
- _VariantCall::constant_data[Variant::INPUT_EVENT].value["JOYSTICK_MOTION"]=InputEvent::JOYSTICK_MOTION;
- _VariantCall::constant_data[Variant::INPUT_EVENT].value["JOYSTICK_BUTTON"]=InputEvent::JOYSTICK_BUTTON;
- _VariantCall::constant_data[Variant::INPUT_EVENT].value["SCREEN_TOUCH"]=InputEvent::SCREEN_TOUCH;
- _VariantCall::constant_data[Variant::INPUT_EVENT].value["SCREEN_DRAG"]=InputEvent::SCREEN_DRAG;
- _VariantCall::constant_data[Variant::INPUT_EVENT].value["ACTION"]=InputEvent::ACTION;
-
- _VariantCall::constant_data[Variant::IMAGE].value["COMPRESS_BC"]=Image::COMPRESS_BC;
- _VariantCall::constant_data[Variant::IMAGE].value["COMPRESS_PVRTC2"]=Image::COMPRESS_PVRTC2;
- _VariantCall::constant_data[Variant::IMAGE].value["COMPRESS_PVRTC4"]=Image::COMPRESS_PVRTC4;
- _VariantCall::constant_data[Variant::IMAGE].value["COMPRESS_ETC"]=Image::COMPRESS_ETC;
-
-
-
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_GRAYSCALE"]=Image::FORMAT_GRAYSCALE;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_INTENSITY"]=Image::FORMAT_INTENSITY;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_GRAYSCALE_ALPHA"]=Image::FORMAT_GRAYSCALE_ALPHA;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_RGB"]=Image::FORMAT_RGB;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_RGBA"]=Image::FORMAT_RGBA;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_INDEXED"]=Image::FORMAT_INDEXED;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_INDEXED_ALPHA"]=Image::FORMAT_INDEXED_ALPHA;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_YUV_422"]=Image::FORMAT_YUV_422;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_YUV_444"]=Image::FORMAT_YUV_444;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC1"]=Image::FORMAT_BC1;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC2"]=Image::FORMAT_BC2;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC3"]=Image::FORMAT_BC3;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC4"]=Image::FORMAT_BC4;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC5"]=Image::FORMAT_BC5;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC2"]=Image::FORMAT_PVRTC2;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC2_ALPHA"]=Image::FORMAT_PVRTC2_ALPHA;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC4"]=Image::FORMAT_PVRTC4;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC4_ALPHA"]=Image::FORMAT_PVRTC4_ALPHA;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ETC"]=Image::FORMAT_ETC;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC"]=Image::FORMAT_ATC;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC_ALPHA_EXPLICIT"]=Image::FORMAT_ATC_ALPHA_EXPLICIT;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC_ALPHA_INTERPOLATED"]=Image::FORMAT_ATC_ALPHA_INTERPOLATED;
- _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_CUSTOM"]=Image::FORMAT_CUSTOM;
-
+ _VariantCall::add_constant(Variant::VECTOR3,"AXIS_X",Vector3::AXIS_X);
+ _VariantCall::add_constant(Variant::VECTOR3,"AXIS_Y",Vector3::AXIS_Y);
+ _VariantCall::add_constant(Variant::VECTOR3,"AXIS_Z",Vector3::AXIS_Z);
+
+
+ _VariantCall::add_constant(Variant::INPUT_EVENT,"NONE",InputEvent::NONE);
+ _VariantCall::add_constant(Variant::INPUT_EVENT,"KEY",InputEvent::KEY);
+ _VariantCall::add_constant(Variant::INPUT_EVENT,"MOUSE_MOTION",InputEvent::MOUSE_MOTION);
+ _VariantCall::add_constant(Variant::INPUT_EVENT,"MOUSE_BUTTON",InputEvent::MOUSE_BUTTON);
+ _VariantCall::add_constant(Variant::INPUT_EVENT,"JOYSTICK_MOTION",InputEvent::JOYSTICK_MOTION);
+ _VariantCall::add_constant(Variant::INPUT_EVENT,"JOYSTICK_BUTTON",InputEvent::JOYSTICK_BUTTON);
+ _VariantCall::add_constant(Variant::INPUT_EVENT,"SCREEN_TOUCH",InputEvent::SCREEN_TOUCH);
+ _VariantCall::add_constant(Variant::INPUT_EVENT,"SCREEN_DRAG",InputEvent::SCREEN_DRAG);
+ _VariantCall::add_constant(Variant::INPUT_EVENT,"ACTION",InputEvent::ACTION);
+
+
+ _VariantCall::add_constant(Variant::IMAGE,"COMPRESS_BC",Image::COMPRESS_BC);
+ _VariantCall::add_constant(Variant::IMAGE,"COMPRESS_PVRTC2",Image::COMPRESS_PVRTC2);
+ _VariantCall::add_constant(Variant::IMAGE,"COMPRESS_PVRTC4",Image::COMPRESS_PVRTC4);
+ _VariantCall::add_constant(Variant::IMAGE,"COMPRESS_ETC",Image::COMPRESS_ETC);
+
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_GRAYSCALE",Image::FORMAT_GRAYSCALE);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_INTENSITY",Image::FORMAT_INTENSITY);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_GRAYSCALE_ALPHA",Image::FORMAT_GRAYSCALE_ALPHA);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_RGB",Image::FORMAT_RGB);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_RGBA",Image::FORMAT_RGBA);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_INDEXED",Image::FORMAT_INDEXED);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_INDEXED_ALPHA",Image::FORMAT_INDEXED_ALPHA);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_YUV_422",Image::FORMAT_YUV_422);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_YUV_444",Image::FORMAT_YUV_444);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_BC1",Image::FORMAT_BC1);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_BC2",Image::FORMAT_BC2);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_BC3",Image::FORMAT_BC3);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_BC4",Image::FORMAT_BC4);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_BC5",Image::FORMAT_BC5);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_PVRTC2",Image::FORMAT_PVRTC2);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_PVRTC2_ALPHA",Image::FORMAT_PVRTC2_ALPHA);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_PVRTC4",Image::FORMAT_PVRTC4);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_PVRTC4_ALPHA",Image::FORMAT_PVRTC4_ALPHA);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_ETC",Image::FORMAT_ETC);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_ATC",Image::FORMAT_ATC);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_ATC_ALPHA_EXPLICIT",Image::FORMAT_ATC_ALPHA_EXPLICIT);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_ATC_ALPHA_INTERPOLATED",Image::FORMAT_ATC_ALPHA_INTERPOLATED);
+ _VariantCall::add_constant(Variant::IMAGE,"FORMAT_CUSTOM",Image::FORMAT_CUSTOM);
+
+ _VariantCall::add_constant(Variant::IMAGE,"INTERPOLATE_NEAREST",Image::INTERPOLATE_NEAREST);
+ _VariantCall::add_constant(Variant::IMAGE,"INTERPOLATE_BILINEAR",Image::INTERPOLATE_BILINEAR);
+ _VariantCall::add_constant(Variant::IMAGE,"INTERPOLATE_CUBIC",Image::INTERPOLATE_CUBIC);
}
void unregister_variant_methods() {
diff --git a/core/variant_call_bind.h b/core/variant_call_bind.h
deleted file mode 100644
index 54954540b0..0000000000
--- a/core/variant_call_bind.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*************************************************************************/
-/* variant_call_bind.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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. */
-/*************************************************************************/
-#ifndef VARIANT_CALL_BIND_H
-#define VARIANT_CALL_BIND_H
-
-
-#include "variant.h"
-
-
-
-
-
-
-#endif // VARIANT_CALL_BIND_H
diff --git a/core/variant_construct_string.cpp b/core/variant_construct_string.cpp
index 0308fd3180..6395501603 100644
--- a/core/variant_construct_string.cpp
+++ b/core/variant_construct_string.cpp
@@ -1,4 +1,31 @@
-
+/*************************************************************************/
+/* variant_construct_string.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 "variant.h"
class VariantConstruct {
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 6065094da7..fd64b58bd5 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -477,7 +477,7 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
DEFAULT_OP_FAIL(MATRIX32);
DEFAULT_OP_LOCALMEM(+,VECTOR3,Vector3);
DEFAULT_OP_FAIL(PLANE);
- DEFAULT_OP_FAIL(QUAT);
+ DEFAULT_OP_LOCALMEM(+, QUAT, Quat);
DEFAULT_OP_FAIL(_AABB);
DEFAULT_OP_FAIL(MATRIX3);
DEFAULT_OP_FAIL(TRANSFORM);
@@ -535,7 +535,7 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
DEFAULT_OP_FAIL(MATRIX32);
DEFAULT_OP_LOCALMEM(-,VECTOR3,Vector3);
DEFAULT_OP_FAIL(PLANE);
- DEFAULT_OP_FAIL(QUAT);
+ DEFAULT_OP_LOCALMEM(-, QUAT, Quat);
DEFAULT_OP_FAIL(_AABB);
DEFAULT_OP_FAIL(MATRIX3);
DEFAULT_OP_FAIL(TRANSFORM);
@@ -597,6 +597,10 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
_RETURN( *reinterpret_cast<const Quat*>(p_a._data._mem) * *reinterpret_cast<const Quat*>(p_b._data._mem) );
} break;
+ case REAL: {
+ _RETURN( *reinterpret_cast<const Quat*>(p_a._data._mem) * p_b._data._real);
+ } break;
+ default: {}
};
r_valid=false;
return;
@@ -615,6 +619,7 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
_RETURN( *p_a._data._matrix3 * *p_b._data._matrix3 );
};
+ default: {}
} ;
r_valid=false;
return;
@@ -632,6 +637,7 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
_RETURN( *p_a._data._transform * *p_b._data._transform );
};
+ default: {}
} ;
r_valid=false;
return;
@@ -699,7 +705,13 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
DEFAULT_OP_FAIL(MATRIX32);
DEFAULT_OP_LOCALMEM_NUM(/,VECTOR3,Vector3);
DEFAULT_OP_FAIL(PLANE);
- DEFAULT_OP_FAIL(QUAT);
+ case QUAT: {
+ if (p_b.type != REAL) {
+ r_valid = false;
+ return;
+ }
+ _RETURN( *reinterpret_cast<const Quat*>(p_a._data._mem) / p_b._data._real);
+ } break;
DEFAULT_OP_FAIL(_AABB);
DEFAULT_OP_FAIL(MATRIX3);
DEFAULT_OP_FAIL(TRANSFORM);
@@ -861,7 +873,6 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
} break;
//logic
case OP_AND: {
-
bool l = p_a.booleanize(r_valid);
if (!r_valid)
return;
@@ -969,6 +980,30 @@ Variant Variant::get_named(const StringName& p_index, bool *r_valid) const {
return get(p_index.operator String(),r_valid);
}
+
+#define DEFAULT_OP_ARRAY_CMD(m_name, m_type, skip_test, cmd)\
+ case m_name: {\
+ skip_test;\
+\
+ if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {\
+ int index = p_index;\
+ m_type *arr=reinterpret_cast<m_type* >(_data._mem);\
+\
+ if (index<0)\
+ index += arr->size();\
+ if (index>=0 && index<arr->size()) {\
+ valid=true;\
+ cmd;\
+ }\
+ }\
+ } break;
+
+#define DEFAULT_OP_DVECTOR_SET(m_name, dv_type, skip_cond)\
+ DEFAULT_OP_ARRAY_CMD(m_name, DVector<dv_type>, if(skip_cond) return;, arr->set(index, p_value);return)
+
+#define DEFAULT_OP_DVECTOR_GET(m_name, dv_type)\
+ DEFAULT_OP_ARRAY_CMD(m_name, const DVector<dv_type>, ;, return arr->get(index))
+
void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid) {
static bool _dummy=false;
@@ -989,7 +1024,10 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
int idx=p_index;
String *str=reinterpret_cast<String*>(_data._mem);
- if (idx <0 || idx>=str->length())
+ int len = str->length();
+ if (idx<0)
+ idx += len;
+ if (idx<0 || idx>=len)
return;
String chr;
@@ -1003,7 +1041,7 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
return;
}
- *str = str->substr(0,idx)+chr+str->substr(idx+1,str->length());
+ *str = str->substr(0,idx)+chr+str->substr(idx+1, len);
valid=true;
return;
@@ -1018,6 +1056,8 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
// scalar index
int idx=p_index;
+ if (idx<0)
+ idx += 2;
if (idx>=0 && idx<2) {
Vector2 *v=reinterpret_cast<Vector2*>(_data._mem);
@@ -1076,6 +1116,8 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
int index = p_index;
+ if (index<0)
+ index += 3;
if (index>=0 && index<3) {
Matrix32 *v=_data._matrix32;
@@ -1112,6 +1154,8 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
//scalar index
int idx=p_index;
+ if (idx<0)
+ idx += 3;
if (idx>=0 && idx<3) {
Vector3 *v=reinterpret_cast<Vector3*>(_data._mem);
@@ -1246,6 +1290,8 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
int index = p_index;
+ if (index<0)
+ index += 3;
if (index>=0 && index<3) {
Matrix3 *v=_data._matrix3;
@@ -1284,6 +1330,8 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
int index = p_index;
+ if (index<0)
+ index += 4;
if (index>=0 && index<4) {
Transform *v=_data._transform;
valid=true;
@@ -1372,6 +1420,8 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
} else if (p_index.get_type()==Variant::INT) {
int idx = p_index;
+ if (idx<0)
+ idx += 4;
if (idx>=0 || idx<4) {
Color *v=reinterpret_cast<Color*>(_data._mem);
(*v)[idx]=p_value;
@@ -1786,145 +1836,14 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
valid=true; //always valid, i guess? should this really be ok?
return;
} break; // 20
- case ARRAY: {
-
-
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- Array *arr=reinterpret_cast<Array* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- (*arr)[index]=p_value;
- return;
- }
- }
-
- } break;
- case RAW_ARRAY: {
-
- if (p_value.type!=Variant::REAL && p_value.type!=Variant::INT)
- return;
-
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- DVector<uint8_t> *arr=reinterpret_cast<DVector<uint8_t>* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- arr->set(index,p_value);
- return;
- }
- }
-
- } break;
- case INT_ARRAY: {
- if (p_value.type!=Variant::REAL && p_value.type!=Variant::INT)
- return;
-
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- DVector<int> *arr=reinterpret_cast<DVector<int>* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- arr->set(index,p_value);
- return;
- }
- }
- } break;
- case REAL_ARRAY: {
-
- if (p_value.type!=Variant::REAL && p_value.type!=Variant::INT)
- return;
-
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- DVector<real_t> *arr=reinterpret_cast<DVector<real_t>* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- arr->set(index,p_value);
- return;
- }
- }
-
- } break;
- case STRING_ARRAY: {
-
- if (p_value.type!=Variant::STRING)
- return;
-
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- DVector<String> *arr=reinterpret_cast<DVector<String>* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- arr->set(index,p_value);
- return;
- }
- }
-
- } break; //25
- case VECTOR2_ARRAY: {
-
- if (p_value.type!=Variant::VECTOR2)
- return;
-
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- DVector<Vector2> *arr=reinterpret_cast<DVector<Vector2>* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- arr->set(index,p_value);
- return;
- }
- }
-
- } break;
- case VECTOR3_ARRAY: {
-
- if (p_value.type!=Variant::VECTOR3)
- return;
-
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- DVector<Vector3> *arr=reinterpret_cast<DVector<Vector3>* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- arr->set(index,p_value);
- return;
- }
- }
-
- } break;
- case COLOR_ARRAY: {
-
- if (p_value.type!=Variant::COLOR)
- return;
-
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- DVector<Color> *arr=reinterpret_cast<DVector<Color>* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- arr->set(index,p_value);
- return;
- }
- }
- } break;
+ DEFAULT_OP_ARRAY_CMD(ARRAY, Array, ;, (*arr)[index]=p_value;return)
+ DEFAULT_OP_DVECTOR_SET(RAW_ARRAY, uint8_t, p_value.type != Variant::REAL && p_value.type != Variant::INT)
+ DEFAULT_OP_DVECTOR_SET(INT_ARRAY, int, p_value.type != Variant::REAL && p_value.type != Variant::INT)
+ DEFAULT_OP_DVECTOR_SET(REAL_ARRAY, real_t, p_value.type != Variant::REAL && p_value.type != Variant::INT)
+ DEFAULT_OP_DVECTOR_SET(STRING_ARRAY, String, p_value.type != Variant::STRING) // 25
+ DEFAULT_OP_DVECTOR_SET(VECTOR2_ARRAY, Vector2, p_value.type != Variant::VECTOR2)
+ DEFAULT_OP_DVECTOR_SET(VECTOR3_ARRAY, Vector3, p_value.type != Variant::VECTOR3)
+ DEFAULT_OP_DVECTOR_SET(COLOR_ARRAY, Color, p_value.type != Variant::COLOR)
default: return;
}
@@ -1950,6 +1869,8 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const {
int idx=p_index;
const String *str=reinterpret_cast<const String*>(_data._mem);
+ if (idx<0)
+ idx += str->length();
if (idx >=0 && idx<str->length()) {
valid=true;
@@ -1963,6 +1884,8 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const {
if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
// scalar index
int idx=p_index;
+ if (idx<0)
+ idx += 2;
if (idx>=0 && idx<2) {
const Vector2 *v=reinterpret_cast<const Vector2*>(_data._mem);
@@ -2008,6 +1931,8 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const {
if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
//scalar index
int idx=p_index;
+ if (idx<0)
+ idx += 3;
if (idx>=0 && idx<3) {
const Vector3 *v=reinterpret_cast<const Vector3*>(_data._mem);
@@ -2038,6 +1963,8 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const {
int index = p_index;
+ if (index<0)
+ index += 3;
if (index>=0 && index<3) {
const Matrix32 *v=_data._matrix32;
@@ -2133,7 +2060,8 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const {
if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
int index = p_index;
-
+ if (index<0)
+ index += 3;
if (index>=0 && index<3) {
const Matrix3 *v=_data._matrix3;
@@ -2163,7 +2091,8 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const {
if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
int index = p_index;
-
+ if (index<0)
+ index += 4;
if (index>=0 && index<4) {
const Transform *v=_data._transform;
valid=true;
@@ -2227,6 +2156,8 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const {
} else if (p_index.get_type()==Variant::INT) {
int idx = p_index;
+ if (idx<0)
+ idx += 4;
if (idx>=0 || idx<4) {
const Color *v=reinterpret_cast<const Color*>(_data._mem);
valid=true;
@@ -2489,110 +2420,14 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const {
return *res;
}
} break; // 20
- case ARRAY: {
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- const Array *arr=reinterpret_cast<const Array* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- return (*arr)[index];
- }
- }
-
- } break;
- case RAW_ARRAY: {
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- const DVector<uint8_t> *arr=reinterpret_cast<const DVector<uint8_t>* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- return arr->get(index);
- }
- }
-
- } break;
- case INT_ARRAY: {
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- const DVector<int> *arr=reinterpret_cast<const DVector<int>* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- return arr->get(index);
- }
- }
- } break;
- case REAL_ARRAY: {
-
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- const DVector<real_t> *arr=reinterpret_cast<const DVector<real_t>* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- return arr->get(index);
- }
- }
-
- } break;
- case STRING_ARRAY: {
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- const DVector<String> *arr=reinterpret_cast<const DVector<String>* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- return arr->get(index);
- }
- }
-
- } break; //25
- case VECTOR2_ARRAY: {
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- const DVector<Vector2> *arr=reinterpret_cast<const DVector<Vector2>* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- return arr->get(index);
- }
- }
-
- } break;
- case VECTOR3_ARRAY: {
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- const DVector<Vector3> *arr=reinterpret_cast<const DVector<Vector3>* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- return arr->get(index);
- }
- }
-
- } break;
- case COLOR_ARRAY: {
-
- if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) {
-
- int index = p_index;
- const DVector<Color> *arr=reinterpret_cast<const DVector<Color>* >(_data._mem);
-
- if (index >=0 && index <arr->size()) {
- valid=true;
- return arr->get(index);
- }
- }
- } break;
+ DEFAULT_OP_ARRAY_CMD(ARRAY, const Array, ;, return (*arr)[index])
+ DEFAULT_OP_DVECTOR_GET(RAW_ARRAY, uint8_t)
+ DEFAULT_OP_DVECTOR_GET(INT_ARRAY, int)
+ DEFAULT_OP_DVECTOR_GET(REAL_ARRAY, real_t)
+ DEFAULT_OP_DVECTOR_GET(STRING_ARRAY, String)
+ DEFAULT_OP_DVECTOR_GET(VECTOR2_ARRAY, Vector2)
+ DEFAULT_OP_DVECTOR_GET(VECTOR3_ARRAY, Vector3)
+ DEFAULT_OP_DVECTOR_GET(COLOR_ARRAY, Color)
default: return Variant();
}
@@ -3079,6 +2914,14 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const {
return ret;
} break;
+ case STRING: {
+
+ const String *str=reinterpret_cast<const String*>(_data._mem);
+ if (str->empty())
+ return false;
+ r_iter = 0;
+ return true;
+ } break;
case DICTIONARY: {
const Dictionary *dic=reinterpret_cast<const Dictionary*>(_data._mem);
@@ -3154,6 +2997,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const {
return true;
} break;
+ default: {}
}
@@ -3196,6 +3040,17 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const {
return ret;
} break;
+
+ case STRING: {
+
+ const String *str=reinterpret_cast<const String*>(_data._mem);
+ int idx = r_iter;
+ idx++;
+ if (idx >= str->length())
+ return false;
+ r_iter = idx;
+ return true;
+ } break;
case DICTIONARY: {
const Dictionary *dic=reinterpret_cast<const Dictionary*>(_data._mem);
@@ -3286,6 +3141,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const {
r_iter=idx;
return true;
} break;
+ default: {}
}
@@ -3326,6 +3182,11 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const {
return ret;
} break;
+ case STRING: {
+
+ const String *str=reinterpret_cast<const String*>(_data._mem);
+ return str->substr(r_iter,1);
+ } break;
case DICTIONARY: {
return r_iter; //iterator is the same as the key
@@ -3423,6 +3284,7 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const {
#endif
return arr->get(idx);
} break;
+ default: {}
}
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index 8bd1fddfad..023605a952 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* variant_parser.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 "variant_parser.h"
#include "io/resource_loader.h"
#include "os/keyboard.h"
@@ -1205,7 +1233,9 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
}
get_token(p_stream,token,line,r_err_str);
- if (token.type!=TK_STRING) {
+ if (token.type==TK_PARENTHESIS_CLOSE) {
+ break;
+ } else if (token.type!=TK_STRING) {
r_err_str="Expected string";
return ERR_PARSE_ERROR;
}
@@ -1747,7 +1777,20 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
}
if (c>32) {
- if (c!='=') {
+ if (c=='"') { //quoted
+ p_stream->saved='"';
+ Token tk;
+ Error err = get_token(p_stream,tk,line,r_err_str);
+ if (err)
+ return err;
+ if (tk.type!=TK_STRING) {
+ r_err_str="Error reading quoted string";
+ return err;
+ }
+
+ what=tk.value;
+
+ } else if (c!='=') {
what+=String::chr(c);
} else {
r_assign=what;
@@ -1789,6 +1832,14 @@ Error VariantParser::parse(Stream *p_stream, Variant& r_ret, String &r_err_str,
//////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
+static String rtosfix(double p_value) {
+
+
+ if (p_value==0.0)
+ return "0"; //avoid negative zero (-0) being written, which may annoy git, svn, etc. for changes when they don't exist.
+ else
+ return rtoss(p_value);
+}
Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_string_func, void *p_store_string_ud,EncodeResourceFunc p_encode_res_func,void* p_encode_res_ud) {
@@ -1807,7 +1858,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
} break;
case Variant::REAL: {
- String s = rtoss(p_variant.operator real_t());
+ String s = rtosfix(p_variant.operator real_t());
if (s.find(".")==-1 && s.find("e")==-1)
s+=".0";
p_store_string_func(p_store_string_ud, s );
@@ -1822,35 +1873,35 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
case Variant::VECTOR2: {
Vector2 v = p_variant;
- p_store_string_func(p_store_string_ud,"Vector2( "+rtoss(v.x) +", "+rtoss(v.y)+" )" );
+ p_store_string_func(p_store_string_ud,"Vector2( "+rtosfix(v.x) +", "+rtosfix(v.y)+" )" );
} break;
case Variant::RECT2: {
Rect2 aabb = p_variant;
- p_store_string_func(p_store_string_ud,"Rect2( "+rtoss(aabb.pos.x) +", "+rtoss(aabb.pos.y) +", "+rtoss(aabb.size.x) +", "+rtoss(aabb.size.y)+" )" );
+ p_store_string_func(p_store_string_ud,"Rect2( "+rtosfix(aabb.pos.x) +", "+rtosfix(aabb.pos.y) +", "+rtosfix(aabb.size.x) +", "+rtosfix(aabb.size.y)+" )" );
} break;
case Variant::VECTOR3: {
Vector3 v = p_variant;
- p_store_string_func(p_store_string_ud,"Vector3( "+rtoss(v.x) +", "+rtoss(v.y)+", "+rtoss(v.z)+" )");
+ p_store_string_func(p_store_string_ud,"Vector3( "+rtosfix(v.x) +", "+rtosfix(v.y)+", "+rtosfix(v.z)+" )");
} break;
case Variant::PLANE: {
Plane p = p_variant;
- p_store_string_func(p_store_string_ud,"Plane( "+rtoss(p.normal.x) +", "+rtoss(p.normal.y)+", "+rtoss(p.normal.z)+", "+rtoss(p.d)+" )" );
+ p_store_string_func(p_store_string_ud,"Plane( "+rtosfix(p.normal.x) +", "+rtosfix(p.normal.y)+", "+rtosfix(p.normal.z)+", "+rtosfix(p.d)+" )" );
} break;
case Variant::_AABB: {
AABB aabb = p_variant;
- p_store_string_func(p_store_string_ud,"AABB( "+rtoss(aabb.pos.x) +", "+rtoss(aabb.pos.y) +", "+rtoss(aabb.pos.z) +", "+rtoss(aabb.size.x) +", "+rtoss(aabb.size.y) +", "+rtoss(aabb.size.z)+" )" );
+ p_store_string_func(p_store_string_ud,"AABB( "+rtosfix(aabb.pos.x) +", "+rtosfix(aabb.pos.y) +", "+rtosfix(aabb.pos.z) +", "+rtosfix(aabb.size.x) +", "+rtosfix(aabb.size.y) +", "+rtosfix(aabb.size.z)+" )" );
} break;
case Variant::QUAT: {
Quat quat = p_variant;
- p_store_string_func(p_store_string_ud,"Quat( "+rtoss(quat.x)+", "+rtoss(quat.y)+", "+rtoss(quat.z)+", "+rtoss(quat.w)+" )");
+ p_store_string_func(p_store_string_ud,"Quat( "+rtosfix(quat.x)+", "+rtosfix(quat.y)+", "+rtosfix(quat.z)+", "+rtosfix(quat.w)+" )");
} break;
case Variant::MATRIX32: {
@@ -1862,7 +1913,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
if (i!=0 || j!=0)
s+=", ";
- s+=rtoss( m3.elements[i][j] );
+ s+=rtosfix( m3.elements[i][j] );
}
}
@@ -1878,7 +1929,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
if (i!=0 || j!=0)
s+=", ";
- s+=rtoss( m3.elements[i][j] );
+ s+=rtosfix( m3.elements[i][j] );
}
}
@@ -1895,11 +1946,11 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
if (i!=0 || j!=0)
s+=", ";
- s+=rtoss( m3.elements[i][j] );
+ s+=rtosfix( m3.elements[i][j] );
}
}
- s=s+", "+rtoss(t.origin.x) +", "+rtoss(t.origin.y)+", "+rtoss(t.origin.z);
+ s=s+", "+rtosfix(t.origin.x) +", "+rtosfix(t.origin.y)+", "+rtosfix(t.origin.z);
p_store_string_func(p_store_string_ud,s+" )");
} break;
@@ -1908,7 +1959,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
case Variant::COLOR: {
Color c = p_variant;
- p_store_string_func(p_store_string_ud,"Color( "+rtoss(c.r) +", "+rtoss(c.g)+", "+rtoss(c.b)+", "+rtoss(c.a)+" )");
+ p_store_string_func(p_store_string_ud,"Color( "+rtosfix(c.r) +", "+rtosfix(c.g)+", "+rtosfix(c.b)+", "+rtosfix(c.a)+" )");
} break;
case Variant::IMAGE: {
@@ -2011,7 +2062,44 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
} break;
case Variant::INPUT_EVENT: {
- p_store_string_func(p_store_string_ud,"InputEvent()"); //will be added later
+ String str="InputEvent(";
+
+ InputEvent ev=p_variant;
+ switch(ev.type) {
+ case InputEvent::KEY: {
+
+ str+="KEY,"+itos(ev.key.scancode);
+ String mod;
+ if (ev.key.mod.alt)
+ mod+="A";
+ if (ev.key.mod.shift)
+ mod+="S";
+ if (ev.key.mod.control)
+ mod+="C";
+ if (ev.key.mod.meta)
+ mod+="M";
+
+ if (mod!=String())
+ str+=","+mod;
+ } break;
+ case InputEvent::MOUSE_BUTTON: {
+
+ str+="MBUTTON,"+itos(ev.mouse_button.button_index);
+ } break;
+ case InputEvent::JOYSTICK_BUTTON: {
+ str+="JBUTTON,"+itos(ev.joy_button.button_index);
+
+ } break;
+ case InputEvent::JOYSTICK_MOTION: {
+ str+="JAXIS,"+itos(ev.joy_motion.axis)+","+itos(ev.joy_motion.axis_value);
+ } break;
+ default: {}
+ }
+
+ str+=")";
+
+ p_store_string_func(p_store_string_ud,str); //will be added later
+
} break;
case Variant::DICTIONARY: {
@@ -2106,7 +2194,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
if (i>0)
p_store_string_func(p_store_string_ud,", ");
- p_store_string_func(p_store_string_ud,rtoss(ptr[i]));
+ p_store_string_func(p_store_string_ud,rtosfix(ptr[i]));
}
p_store_string_func(p_store_string_ud," )");
@@ -2147,7 +2235,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
if (i>0)
p_store_string_func(p_store_string_ud,", ");
- p_store_string_func(p_store_string_ud,rtoss(ptr[i].x)+", "+rtoss(ptr[i].y) );
+ p_store_string_func(p_store_string_ud,rtosfix(ptr[i].x)+", "+rtosfix(ptr[i].y) );
}
p_store_string_func(p_store_string_ud," )");
@@ -2165,7 +2253,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
if (i>0)
p_store_string_func(p_store_string_ud,", ");
- p_store_string_func(p_store_string_ud,rtoss(ptr[i].x)+", "+rtoss(ptr[i].y)+", "+rtoss(ptr[i].z) );
+ p_store_string_func(p_store_string_ud,rtosfix(ptr[i].x)+", "+rtosfix(ptr[i].y)+", "+rtosfix(ptr[i].z) );
}
p_store_string_func(p_store_string_ud," )");
@@ -2185,7 +2273,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
if (i>0)
p_store_string_func(p_store_string_ud,", ");
- p_store_string_func(p_store_string_ud,rtoss(ptr[i].r)+", "+rtoss(ptr[i].g)+", "+rtoss(ptr[i].b)+", "+rtoss(ptr[i].a) );
+ p_store_string_func(p_store_string_ud,rtosfix(ptr[i].r)+", "+rtosfix(ptr[i].g)+", "+rtosfix(ptr[i].b)+", "+rtosfix(ptr[i].a) );
}
p_store_string_func(p_store_string_ud," )");
diff --git a/core/variant_parser.h b/core/variant_parser.h
index 00f6910b29..5857820efa 100644
--- a/core/variant_parser.h
+++ b/core/variant_parser.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* variant_parser.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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. */
+/*************************************************************************/
#ifndef VARIANT_PARSER_H
#define VARIANT_PARSER_H
diff --git a/core/vector.h b/core/vector.h
index 87248ccf68..cafb4a4aa3 100644
--- a/core/vector.h
+++ b/core/vector.h
@@ -120,7 +120,7 @@ public:
template <class T_val>
- int find(const T_val& p_val) const;
+ int find(const T_val& p_val, int p_from=0) const;
void set(int p_index,T p_elem);
T get(int p_index) const;
@@ -238,13 +238,13 @@ void Vector<T>::_copy_on_write() {
}
template<class T> template<class T_val>
-int Vector<T>::find(const T_val &p_val) const {
+int Vector<T>::find(const T_val &p_val, int p_from) const {
int ret = -1;
- if (size() == 0)
+ if (p_from < 0 || size() == 0)
return ret;
- for (int i=0; i<size(); i++) {
+ for (int i=p_from; i<size(); i++) {
if (operator[](i) == p_val) {
ret = i;
@@ -253,7 +253,7 @@ int Vector<T>::find(const T_val &p_val) const {
};
return ret;
-};
+}
template<class T>
Error Vector<T>::resize(int p_size) {
diff --git a/core/vmap.cpp b/core/vmap.cpp
deleted file mode 100644
index e94198257a..0000000000
--- a/core/vmap.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/*************************************************************************/
-/* vmap.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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 "vmap.h"
-
diff --git a/core/vset.cpp b/core/vset.cpp
deleted file mode 100644
index cefafeb073..0000000000
--- a/core/vset.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*************************************************************************/
-/* vset.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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. */
-/*************************************************************************/