diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/globals.cpp | 12 | ||||
-rw-r--r-- | core/image.cpp | 2 | ||||
-rw-r--r-- | core/io/http_client.cpp | 15 | ||||
-rw-r--r-- | core/io/http_client.h | 2 | ||||
-rw-r--r-- | core/io/resource_format_xml.cpp | 1 | ||||
-rw-r--r-- | core/math/math_2d.cpp | 4 | ||||
-rw-r--r-- | core/math/math_2d.h | 2 | ||||
-rw-r--r-- | core/ustring.cpp | 47 | ||||
-rw-r--r-- | core/ustring.h | 2 | ||||
-rw-r--r-- | core/variant_call.cpp | 4 |
10 files changed, 81 insertions, 10 deletions
diff --git a/core/globals.cpp b/core/globals.cpp index ffd4cf5d5e..aee708d0cd 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -332,6 +332,7 @@ Error Globals::setup(const String& p_path,const String & p_main_pack) { String candidate = d->get_current_dir(); String current_dir = d->get_current_dir(); + String exec_name = OS::get_singleton()->get_executable_path().get_file().basename(); bool found = false; bool first_time=true; @@ -339,7 +340,16 @@ Error Globals::setup(const String& p_path,const String & p_main_pack) { //try to load settings in ascending through dirs shape! //tries to open pack, but only first time - if (first_time && (_load_resource_pack(current_dir+"/data.pck") || _load_resource_pack(current_dir+"/data.pcz") )) { + if (first_time && (_load_resource_pack(current_dir+"/"+exec_name+".pck") || _load_resource_pack(current_dir+"/"+exec_name+".pcz") )) { + if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) { + + _load_settings("res://override.cfg"); + found=true; + + + } + break; + } else if (first_time && (_load_resource_pack(current_dir+"/data.pck") || _load_resource_pack(current_dir+"/data.pcz") )) { if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) { _load_settings("res://override.cfg"); diff --git a/core/image.cpp b/core/image.cpp index 06b7a78488..eadb7ecc8b 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -322,7 +322,7 @@ void Image::set_pallete(const DVector<uint8_t>& p_data) { DVector<uint8_t>::Write wp = data.write(); unsigned char *dst=wp.ptr() + pal_ofs; - DVector<uint8_t>::Read r = data.read(); + DVector<uint8_t>::Read r = p_data.read(); const unsigned char *src=r.ptr(); copymem(dst, src, len); diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 24012660d2..58092efd4b 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -579,7 +579,7 @@ Error HTTPClient::_get_http_data(uint8_t* p_buffer, int p_bytes,int &r_received) void HTTPClient::_bind_methods() { - ObjectTypeDB::bind_method(_MD("connect:Error","host","port","use_ssl"),&HTTPClient::connect,DEFVAL(false),DEFVAL(true)); + ObjectTypeDB::bind_method(_MD("connect:Error","host","port","use_ssl","verify_host"),&HTTPClient::connect,DEFVAL(false),DEFVAL(true)); ObjectTypeDB::bind_method(_MD("set_connection","connection:StreamPeer"),&HTTPClient::set_connection); ObjectTypeDB::bind_method(_MD("request","method","url","headers","body"),&HTTPClient::request,DEFVAL(String())); ObjectTypeDB::bind_method(_MD("send_body_text","body"),&HTTPClient::send_body_text); @@ -601,6 +601,8 @@ void HTTPClient::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_status"),&HTTPClient::get_status); ObjectTypeDB::bind_method(_MD("poll:Error"),&HTTPClient::poll); + ObjectTypeDB::bind_method(_MD("query_string_from_dict:String","fields"),&HTTPClient::query_string_from_dict); + BIND_CONSTANT( METHOD_GET ); BIND_CONSTANT( METHOD_HEAD ); @@ -689,6 +691,16 @@ void HTTPClient::set_read_chunk_size(int p_size) { read_chunk_size=p_size; } +String HTTPClient::query_string_from_dict(const Dictionary& p_dict) { + String query = ""; + Array keys = p_dict.keys(); + for (int i = 0; i < keys.size(); ++i) { + query += "&" + String(keys[i]).http_escape() + "=" + String(p_dict[keys[i]]).http_escape(); + } + query.erase(0, 1); + return query; +} + HTTPClient::HTTPClient(){ tcp_connection = StreamPeerTCP::create_ref(); @@ -710,4 +722,3 @@ HTTPClient::~HTTPClient(){ } - diff --git a/core/io/http_client.h b/core/io/http_client.h index 21281f38c5..b103dc43fc 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -192,6 +192,8 @@ public: Error poll(); + String query_string_from_dict(const Dictionary& p_dict); + HTTPClient(); ~HTTPClient(); }; diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index 66ae014dbc..48917a19ea 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -1955,7 +1955,6 @@ void ResourceFormatLoaderXML::get_recognized_extensions_for_type(const String& p if (ext=="res") continue; p_extensions->push_back("x"+ext); - p_extensions->push_back(ext); } p_extensions->push_back("xml"); diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp index 88717723ce..ce03f089e5 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -29,7 +29,7 @@ #include "math_2d.h" -real_t Vector2::atan2() const { +real_t Vector2::angle() const { return Math::atan2(x,y); } @@ -165,7 +165,7 @@ Vector2 Vector2::floor() const { Vector2 Vector2::rotated(float p_by) const { Vector2 v; - v.set_rotation(atan2()+p_by); + v.set_rotation(angle()+p_by); v*=length(); return v; } diff --git a/core/math/math_2d.h b/core/math/math_2d.h index 5e6cefd114..3d40e24091 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -133,7 +133,7 @@ struct Vector2 { bool operator<(const Vector2& p_vec2) const { return (x==p_vec2.x)?(y<p_vec2.y):(x<p_vec2.x); } bool operator<=(const Vector2& p_vec2) const { return (x==p_vec2.x)?(y<=p_vec2.y):(x<=p_vec2.x); } - real_t atan2() const; + real_t angle() const; void set_rotation(float p_radians) { diff --git a/core/ustring.cpp b/core/ustring.cpp index 7582376fe0..f3c89a7908 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -44,6 +44,11 @@ #include <stdlib.h> #include <stdio.h> #endif + +#if defined(MINGW_ENABLED) || defined(_MSC_VER) +#define snprintf _snprintf +#endif + /** STRING **/ const char *CharString::get_data() const { @@ -3079,6 +3084,48 @@ String String::world_wrap(int p_chars_per_line) const { return ret; } +String String::http_escape() const { + const CharString temp = utf8(); + String res; + for (int i = 0; i < length(); ++i) { + CharType ord = temp[i]; + if (ord == '.' || ord == '-' || ord == '_' || ord == '~' || + (ord >= 'a' && ord <= 'z') || + (ord >= 'A' && ord <= 'Z') || + (ord >= '0' && ord <= '9')) { + res += ord; + } else { + char h_Val[3]; + snprintf(h_Val, 3, "%.2X", ord); + res += "%"; + res += h_Val; + } + } + return res; +} + +String String::http_unescape() const { + String res; + for (int i = 0; i < length(); ++i) { + if (ord_at(i) == '%' && i+2 < length()) { + CharType ord1 = ord_at(i+1); + if ((ord1 >= '0' && ord1 <= '9') || (ord1 >= 'A' && ord1 <= 'Z')) { + CharType ord2 = ord_at(i+2); + if ((ord2 >= '0' && ord2 <= '9') || (ord2 >= 'A' && ord2 <= 'Z')) { + char bytes[2] = {ord1, ord2}; + res += (char)strtol(bytes, NULL, 16); + i+=2; + } + } else { + res += ord_at(i); + } + } else { + res += ord_at(i); + } + } + return String::utf8(res.ascii()); +} + String String::c_unescape() const { String escaped=*this; diff --git a/core/ustring.h b/core/ustring.h index fa25a07eb0..2f3c4bff4d 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -207,6 +207,8 @@ public: String xml_escape(bool p_escape_quotes=false) const; String xml_unescape() const; + String http_escape() const; + String http_unescape() const; String c_escape() const; String c_unescape() const; String world_wrap(int p_chars_per_line) const; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 7bbb18225d..51d683f1fe 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -333,7 +333,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(Vector2,dot); VCALL_LOCALMEM1R(Vector2,slide); VCALL_LOCALMEM1R(Vector2,reflect); - VCALL_LOCALMEM0R(Vector2,atan2); + VCALL_LOCALMEM0R(Vector2,angle); // VCALL_LOCALMEM1R(Vector2,cross); VCALL_LOCALMEM0R(Rect2,get_area); @@ -1297,7 +1297,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(VECTOR2,VECTOR2,Vector2,normalized,varray()); ADDFUNC0(VECTOR2,REAL,Vector2,length,varray()); - ADDFUNC0(VECTOR2,REAL,Vector2,atan2,varray()); + ADDFUNC0(VECTOR2,REAL,Vector2,angle,varray()); ADDFUNC0(VECTOR2,REAL,Vector2,length_squared,varray()); ADDFUNC1(VECTOR2,REAL,Vector2,distance_to,VECTOR2,"to",varray()); ADDFUNC1(VECTOR2,REAL,Vector2,distance_squared_to,VECTOR2,"to",varray()); |