diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 7 | ||||
-rw-r--r-- | core/bind/core_bind.h | 2 | ||||
-rw-r--r-- | core/dictionary.cpp | 2 | ||||
-rw-r--r-- | core/io/stream_peer_tcp.cpp | 2 | ||||
-rw-r--r-- | core/math/math_funcs.h | 2 | ||||
-rw-r--r-- | core/object_type_db.cpp | 17 | ||||
-rw-r--r-- | core/object_type_db.h | 2 | ||||
-rw-r--r-- | core/register_core_types.cpp | 1 | ||||
-rw-r--r-- | core/variant_call.cpp | 6 | ||||
-rw-r--r-- | core/variant_op.cpp | 36 |
10 files changed, 55 insertions, 22 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index ef943b2f7a..54fa4214a4 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -12,9 +12,9 @@ Ref<ResourceInteractiveLoader> _ResourceLoader::load_interactive(const String& p return ResourceLoader::load_interactive(p_path,p_type_hint); } -RES _ResourceLoader::load(const String &p_path,const String& p_type_hint) { +RES _ResourceLoader::load(const String &p_path,const String& p_type_hint, bool p_no_cache) { - RES ret = ResourceLoader::load(p_path,p_type_hint); + RES ret = ResourceLoader::load(p_path,p_type_hint, p_no_cache); return ret; } @@ -59,7 +59,7 @@ void _ResourceLoader::_bind_methods() { ObjectTypeDB::bind_method(_MD("load_interactive:ResourceInteractiveLoader","path","type_hint"),&_ResourceLoader::load_interactive,DEFVAL("")); - ObjectTypeDB::bind_method(_MD("load:Resource","path","type_hint"),&_ResourceLoader::load,DEFVAL("")); + ObjectTypeDB::bind_method(_MD("load:Resource","path","type_hint", "p_no_cache"),&_ResourceLoader::load,DEFVAL(""), DEFVAL(false)); ObjectTypeDB::bind_method(_MD("get_recognized_extensions_for_type","type"),&_ResourceLoader::get_recognized_extensions_for_type); ObjectTypeDB::bind_method(_MD("set_abort_on_missing_resources","abort"),&_ResourceLoader::set_abort_on_missing_resources); ObjectTypeDB::bind_method(_MD("get_dependencies"),&_ResourceLoader::get_dependencies); @@ -1121,6 +1121,7 @@ String _File::get_as_text() const { text+=l+"\n"; l = get_line(); } + text+=l; return text; diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index a76b4aa81f..12a4ae86eb 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -21,7 +21,7 @@ public: static _ResourceLoader *get_singleton() { return singleton; } Ref<ResourceInteractiveLoader> load_interactive(const String& p_path,const String& p_type_hint=""); - RES load(const String &p_path,const String& p_type_hint=""); + RES load(const String &p_path,const String& p_type_hint="", bool p_no_cache = false); DVector<String> get_recognized_extensions_for_type(const String& p_type); void set_abort_on_missing_resources(bool p_abort); StringArray get_dependencies(const String& p_path); diff --git a/core/dictionary.cpp b/core/dictionary.cpp index 16ee397382..2d503bae50 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -186,10 +186,12 @@ Error Dictionary::parse_json(const String& p_json) { String errstr; int errline=0; + if (p_json != ""){ Error err = JSON::parse(p_json,*this,errstr,errline); if (err!=OK) { ERR_EXPLAIN("Error parsing JSON: "+errstr+" at line: "+itos(errline)); ERR_FAIL_COND_V(err!=OK,err); + } } return OK; diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp index 0e75e22767..f83c174084 100644 --- a/core/io/stream_peer_tcp.cpp +++ b/core/io/stream_peer_tcp.cpp @@ -32,7 +32,7 @@ StreamPeerTCP* (*StreamPeerTCP::_create)()=NULL; void StreamPeerTCP::_bind_methods() { - ObjectTypeDB::bind_method(_MD("connect","host","ip"),&StreamPeerTCP::connect); + ObjectTypeDB::bind_method(_MD("connect","host","port"),&StreamPeerTCP::connect); ObjectTypeDB::bind_method(_MD("is_connected"),&StreamPeerTCP::is_connected); ObjectTypeDB::bind_method(_MD("get_status"),&StreamPeerTCP::get_status); ObjectTypeDB::bind_method(_MD("get_connected_host"),&StreamPeerTCP::get_connected_host); diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 28a8413325..6d43ed8e64 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -136,7 +136,7 @@ public: static int b; -#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0603 // windows 8? +#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0603) || WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP // windows 8 phone? b = (int)((a>0.0f) ? (a + 0.5f):(a -0.5f)); #elif defined(_MSC_VER) && _MSC_VER < 1800 diff --git a/core/object_type_db.cpp b/core/object_type_db.cpp index 62244cbd4f..efd92542ce 100644 --- a/core/object_type_db.cpp +++ b/core/object_type_db.cpp @@ -805,12 +805,25 @@ void ObjectTypeDB::add_virtual_method(const StringName& p_type,const MethodInfo& } -void ObjectTypeDB::get_virtual_methods(const StringName& p_type,List<MethodInfo> * p_methods ) { +void ObjectTypeDB::get_virtual_methods(const StringName& p_type, List<MethodInfo> * p_methods , bool p_no_inheritance) { ERR_FAIL_COND(!types.has(p_type)); #ifdef DEBUG_METHODS_ENABLED - *p_methods=types[p_type].virtual_methods; + + TypeInfo *type=types.getptr(p_type); + TypeInfo *check=type; + while(check) { + + for(List<MethodInfo>::Element *E=check->virtual_methods.front();E;E=E->next()) { + p_methods->push_back(E->get()); + } + + if (p_no_inheritance) + return; + check=check->inherits_ptr; + } + #endif } diff --git a/core/object_type_db.h b/core/object_type_db.h index ae0644f9b3..f2ff194e28 100644 --- a/core/object_type_db.h +++ b/core/object_type_db.h @@ -468,7 +468,7 @@ public: static MethodBind *get_method(StringName p_type, StringName p_name); static void add_virtual_method(const StringName& p_type,const MethodInfo& p_method ); - static void get_virtual_methods(const StringName& p_type,List<MethodInfo> * p_methods ); + static void get_virtual_methods(const StringName& p_type,List<MethodInfo> * p_methods,bool p_no_inheritance=false ); static void bind_integer_constant(const StringName& p_type, const StringName &p_name, int p_constant); static void get_integer_constant_list(const StringName& p_type, List<String> *p_constants, bool p_no_inheritance=false); diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 2f16e31de6..4935136eeb 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -110,6 +110,7 @@ void register_core_types() { ObjectTypeDB::register_type<Reference>(); + ObjectTypeDB::register_type<WeakRef>(); ObjectTypeDB::register_type<ResourceImportMetadata>(); ObjectTypeDB::register_type<Resource>(); ObjectTypeDB::register_type<FuncRef>(); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 93a9e6475f..3f2800494d 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -757,6 +757,11 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var r_ret=Quat(*p_args[0],*p_args[1],*p_args[2],*p_args[3]); } + static void Quat_init2(Variant& r_ret,const Variant** p_args) { + + r_ret=Quat(((Vector3)(*p_args[0])),((float)(*p_args[1]))); + } + static void Color_init1(Variant& r_ret,const Variant** p_args) { r_ret=Color(*p_args[0],*p_args[1],*p_args[2],*p_args[3]); @@ -1509,6 +1514,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::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); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 9c489c5ef2..ec43b1275c 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -922,21 +922,31 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid) case REAL: { return; } break; case STRING: { - if (p_value.type!=Variant::STRING) + + if (p_index.type!=Variant::INT && p_index.type!=Variant::REAL) return; - if (p_index.get_type()==Variant::INT || p_index.get_type()==Variant::REAL) { - //string index - int idx=p_index; - String *str=reinterpret_cast<String*>(_data._mem); - if (idx >=0 && idx<str->length()) { - String chr = p_value; - *str = str->substr(0,idx-1)+chr+str->substr(idx+1,str->length()); - valid=true; - return; - } + int idx=p_index; + String *str=reinterpret_cast<String*>(_data._mem); + if (idx <0 || idx>=str->length()) + return; + + String chr; + if (p_value.type==Variant::INT || p_value.type==Variant::REAL) { + + chr = String::chr(p_value); + } else if (p_value.type==Variant::STRING) { + + chr = p_value; + } else { + return; } + *str = str->substr(0,idx-1)+chr+str->substr(idx+1,str->length()); + valid=true; + return; + + } break; case VECTOR2: { @@ -951,7 +961,7 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid) Vector2 *v=reinterpret_cast<Vector2*>(_data._mem); valid=true; - v[idx]=p_value; + (*v)[idx]=p_value; return; } } else if (p_index.get_type()==Variant::STRING) { @@ -1045,7 +1055,7 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid) Vector3 *v=reinterpret_cast<Vector3*>(_data._mem); valid=true; - v[idx]=p_value; + (*v)[idx]=p_value; return; } } else if (p_index.get_type()==Variant::STRING) { |