summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp7
-rw-r--r--core/image.cpp19
-rw-r--r--core/io/http_client.cpp1
-rw-r--r--core/object.cpp18
-rw-r--r--core/os/input.cpp2
-rw-r--r--core/os/input.h2
-rw-r--r--core/reference.cpp14
-rw-r--r--core/script_language.h7
-rw-r--r--core/variant_parser.cpp15
9 files changed, 70 insertions, 15 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index bc08c64d05..ace7e7c7b7 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -1566,7 +1566,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";
@@ -1574,6 +1579,8 @@ String _File::get_as_text() const {
}
text+=l;
+ f->seek(original_pos);
+
return text;
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/io/http_client.cpp b/core/io/http_client.cpp
index 3520680118..0dfae6584b 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -76,6 +76,7 @@ void HTTPClient::set_connection(const Ref<StreamPeer>& p_connection){
close();
connection=p_connection;
+ status=STATUS_CONNECTED;
}
diff --git a/core/object.cpp b/core/object.cpp
index 34d6d8487a..99d4a1f46a 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1320,14 +1320,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;
diff --git a/core/os/input.cpp b/core/os/input.cpp
index 005a248aac..dacddc0928 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -61,7 +61,7 @@ void Input::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_joy_guid","device"),&Input::get_joy_guid);
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);
+ 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);
diff --git a/core/os/input.h b/core/os/input.h
index 6364d597b0..fa2cef5467 100644
--- a/core/os/input.h
+++ b/core/os/input.h
@@ -70,7 +70,7 @@ public:
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;
+ 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;
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/script_language.h b/core/script_language.h
index 478ebd88ed..bde4d619ab 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -129,6 +129,13 @@ public:
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; }
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index 886bea2910..dce873a306 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -1775,7 +1775,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;