summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.h2
-rw-r--r--core/class_db.h2
-rw-r--r--core/io/file_access_buffered.cpp12
-rw-r--r--core/io/file_access_buffered.h2
-rw-r--r--core/io/file_access_memory.h2
-rw-r--r--core/io/file_access_zip.cpp12
-rw-r--r--core/io/ip_address.h2
-rw-r--r--core/io/json.cpp60
-rw-r--r--core/io/marshalls.cpp183
-rw-r--r--core/io/marshalls.h2
-rw-r--r--core/io/packet_peer.cpp16
-rw-r--r--core/io/packet_peer.h5
-rw-r--r--core/io/packet_peer_udp.h2
-rw-r--r--core/io/resource_import.cpp46
-rw-r--r--core/io/resource_import.h1
-rw-r--r--core/io/stream_peer.cpp5
-rw-r--r--core/io/tcp_server.h2
-rw-r--r--core/math/math_2d.cpp16
-rw-r--r--core/math/math_2d.h40
-rw-r--r--core/math/octree.h12
-rw-r--r--core/math/plane.cpp4
-rw-r--r--core/math/plane.h4
-rw-r--r--core/math/rect3.h42
-rw-r--r--core/math/vector3.h22
-rw-r--r--core/method_bind.h1
-rw-r--r--core/method_ptrcall.h57
-rw-r--r--core/object.h2
-rw-r--r--core/os/file_access.cpp4
-rw-r--r--core/os/file_access.h2
-rw-r--r--core/os/input_event.cpp5
-rw-r--r--core/os/input_event.h1
-rw-r--r--core/os/keyboard.h2
-rw-r--r--core/pair.h2
-rw-r--r--core/project_settings.h2
-rw-r--r--core/resource.h2
-rw-r--r--core/script_debugger_remote.cpp36
-rw-r--r--core/ustring.cpp6
-rw-r--r--core/ustring.h8
-rw-r--r--core/variant_construct_string.cpp62
-rw-r--r--core/vector.h8
40 files changed, 471 insertions, 225 deletions
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index e18d663d85..61c80aaba3 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -458,7 +458,7 @@ protected:
public:
Error open(const String &p_path);
- Error list_dir_begin(bool p_skip_internal = false, bool p_skip_hidden = false); ///< This starts dir listing
+ Error list_dir_begin(bool p_skip_navigational = false, bool p_skip_hidden = false); ///< This starts dir listing
String get_next();
bool current_is_dir() const;
diff --git a/core/class_db.h b/core/class_db.h
index f73e082c52..4287c5990f 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -45,7 +45,7 @@ struct ParamHint {
String hint_text;
Variant default_val;
- ParamHint(const String &p_name = "", PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_text = "", Variant p_default_val = Variant())
+ ParamHint(const String &p_name = "", PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_text = "", const Variant &p_default_val = Variant())
: name(p_name),
hint(p_hint),
hint_text(p_hint_text),
diff --git a/core/io/file_access_buffered.cpp b/core/io/file_access_buffered.cpp
index 81adbbbaf7..126ec7575e 100644
--- a/core/io/file_access_buffered.cpp
+++ b/core/io/file_access_buffered.cpp
@@ -106,11 +106,11 @@ uint8_t FileAccessBuffered::get_8() const {
return byte;
};
-int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_elements) const {
+int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
ERR_FAIL_COND_V(!file.open, -1);
- if (p_elements > cache_size) {
+ if (p_length > cache_size) {
int total_read = 0;
@@ -122,12 +122,12 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_elements) const {
//memcpy(p_dest, read.ptr() + (file.offset - cache.offset), size);
memcpy(p_dest, cache.buffer.ptr() + (file.offset - cache.offset), size);
p_dest += size;
- p_elements -= size;
+ p_length -= size;
file.offset += size;
total_read += size;
};
- int err = read_data_block(file.offset, p_elements, p_dest);
+ int err = read_data_block(file.offset, p_length, p_dest);
if (err >= 0) {
total_read += err;
file.offset += err;
@@ -136,7 +136,7 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_elements) const {
return total_read;
};
- int to_read = p_elements;
+ int to_read = p_length;
int total_read = 0;
while (to_read > 0) {
@@ -161,7 +161,7 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_elements) const {
to_read -= r;
};
- return p_elements;
+ return p_length;
};
bool FileAccessBuffered::is_open() const {
diff --git a/core/io/file_access_buffered.h b/core/io/file_access_buffered.h
index c5bf120890..0ad2d0e929 100644
--- a/core/io/file_access_buffered.h
+++ b/core/io/file_access_buffered.h
@@ -81,7 +81,7 @@ public:
virtual bool eof_reached() const;
virtual uint8_t get_8() const;
- virtual int get_buffer(uint8_t *p_dst, int p_length) const; ///< get an array of bytes
+ virtual int get_buffer(uint8_t *p_dest, int p_length) const; ///< get an array of bytes
virtual bool is_open() const;
diff --git a/core/io/file_access_memory.h b/core/io/file_access_memory.h
index 8b6abe7e81..ea858c547e 100644
--- a/core/io/file_access_memory.h
+++ b/core/io/file_access_memory.h
@@ -62,7 +62,7 @@ public:
virtual Error get_error() const; ///< get last error
- virtual void store_8(uint8_t p_dest); ///< store a byte
+ virtual void store_8(uint8_t p_byte); ///< store a byte
virtual void store_buffer(const uint8_t *p_src, int p_length); ///< store an array of bytes
virtual bool file_exists(const String &p_name); ///< return true if a file exists
diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp
index a92014000d..d748d5c773 100644
--- a/core/io/file_access_zip.cpp
+++ b/core/io/file_access_zip.cpp
@@ -159,15 +159,15 @@ unzFile ZipArchive::get_file_handle(String p_file) const {
return pkg;
};
-bool ZipArchive::try_open_pack(const String &p_name) {
+bool ZipArchive::try_open_pack(const String &p_path) {
//printf("opening zip pack %ls, %i, %i\n", p_name.c_str(), p_name.extension().nocasecmp_to("zip"), p_name.extension().nocasecmp_to("pcz"));
- if (p_name.get_extension().nocasecmp_to("zip") != 0 && p_name.get_extension().nocasecmp_to("pcz") != 0)
+ if (p_path.get_extension().nocasecmp_to("zip") != 0 && p_path.get_extension().nocasecmp_to("pcz") != 0)
return false;
zlib_filefunc_def io;
- FileAccess *f = FileAccess::open(p_name, FileAccess::READ);
+ FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f)
return false;
io.opaque = f;
@@ -180,7 +180,7 @@ bool ZipArchive::try_open_pack(const String &p_name) {
io.zclose_file = godot_close;
io.zerror_file = godot_testerror;
- unzFile zfile = unzOpen2(p_name.utf8().get_data(), &io);
+ unzFile zfile = unzOpen2(p_path.utf8().get_data(), &io);
ERR_FAIL_COND_V(!zfile, false);
unz_global_info64 gi;
@@ -188,7 +188,7 @@ bool ZipArchive::try_open_pack(const String &p_name) {
ERR_FAIL_COND_V(err != UNZ_OK, false);
Package pkg;
- pkg.filename = p_name;
+ pkg.filename = p_path;
pkg.zfile = zfile;
packages.push_back(pkg);
int pkg_num = packages.size() - 1;
@@ -209,7 +209,7 @@ bool ZipArchive::try_open_pack(const String &p_name) {
files[fname] = f;
uint8_t md5[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- PackedData::get_singleton()->add_path(p_name, fname, 1, 0, md5, this);
+ PackedData::get_singleton()->add_path(p_path, fname, 1, 0, md5, this);
//printf("packed data add path %ls, %ls\n", p_name.c_str(), fname.c_str());
if ((i + 1) < gi.number_entry) {
diff --git a/core/io/ip_address.h b/core/io/ip_address.h
index ac58283605..da16622a9b 100644
--- a/core/io/ip_address.h
+++ b/core/io/ip_address.h
@@ -75,7 +75,7 @@ public:
void set_ipv4(const uint8_t *p_ip);
const uint8_t *get_ipv6() const;
- void set_ipv6(const uint8_t *buf);
+ void set_ipv6(const uint8_t *p_buf);
operator String() const;
IP_Address(const String &p_string);
diff --git a/core/io/json.cpp b/core/io/json.cpp
index 10fd60abf7..d537061c5b 100644
--- a/core/io/json.cpp
+++ b/core/io/json.cpp
@@ -94,15 +94,15 @@ String JSON::print(const Variant &p_var) {
return _print_var(p_var);
}
-Error JSON::_get_token(const CharType *p_str, int &idx, int p_len, Token &r_token, int &line, String &r_err_str) {
+Error JSON::_get_token(const CharType *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str) {
while (p_len > 0) {
- switch (p_str[idx]) {
+ switch (p_str[index]) {
case '\n': {
line++;
- idx++;
+ index++;
break;
};
case 0: {
@@ -112,54 +112,54 @@ Error JSON::_get_token(const CharType *p_str, int &idx, int p_len, Token &r_toke
case '{': {
r_token.type = TK_CURLY_BRACKET_OPEN;
- idx++;
+ index++;
return OK;
};
case '}': {
r_token.type = TK_CURLY_BRACKET_CLOSE;
- idx++;
+ index++;
return OK;
};
case '[': {
r_token.type = TK_BRACKET_OPEN;
- idx++;
+ index++;
return OK;
};
case ']': {
r_token.type = TK_BRACKET_CLOSE;
- idx++;
+ index++;
return OK;
};
case ':': {
r_token.type = TK_COLON;
- idx++;
+ index++;
return OK;
};
case ',': {
r_token.type = TK_COMMA;
- idx++;
+ index++;
return OK;
};
case '"': {
- idx++;
+ index++;
String str;
while (true) {
- if (p_str[idx] == 0) {
+ if (p_str[index] == 0) {
r_err_str = "Unterminated String";
return ERR_PARSE_ERROR;
- } else if (p_str[idx] == '"') {
- idx++;
+ } else if (p_str[index] == '"') {
+ index++;
break;
- } else if (p_str[idx] == '\\') {
+ } else if (p_str[index] == '\\') {
//escaped characters...
- idx++;
- CharType next = p_str[idx];
+ index++;
+ CharType next = p_str[index];
if (next == 0) {
r_err_str = "Unterminated String";
return ERR_PARSE_ERROR;
@@ -177,7 +177,7 @@ Error JSON::_get_token(const CharType *p_str, int &idx, int p_len, Token &r_toke
//hexnumbarh - oct is deprecated
for (int j = 0; j < 4; j++) {
- CharType c = p_str[idx + j + 1];
+ CharType c = p_str[index + j + 1];
if (c == 0) {
r_err_str = "Unterminated String";
return ERR_PARSE_ERROR;
@@ -204,7 +204,7 @@ Error JSON::_get_token(const CharType *p_str, int &idx, int p_len, Token &r_toke
res <<= 4;
res |= v;
}
- idx += 4; //will add at the end anyway
+ index += 4; //will add at the end anyway
} break;
//case '\"': res='\"'; break;
@@ -220,11 +220,11 @@ Error JSON::_get_token(const CharType *p_str, int &idx, int p_len, Token &r_toke
str += res;
} else {
- if (p_str[idx] == '\n')
+ if (p_str[index] == '\n')
line++;
- str += p_str[idx];
+ str += p_str[index];
}
- idx++;
+ index++;
}
r_token.type = TK_STRING;
@@ -234,28 +234,28 @@ Error JSON::_get_token(const CharType *p_str, int &idx, int p_len, Token &r_toke
} break;
default: {
- if (p_str[idx] <= 32) {
- idx++;
+ if (p_str[index] <= 32) {
+ index++;
break;
}
- if (p_str[idx] == '-' || (p_str[idx] >= '0' && p_str[idx] <= '9')) {
+ if (p_str[index] == '-' || (p_str[index] >= '0' && p_str[index] <= '9')) {
//a number
const CharType *rptr;
- double number = String::to_double(&p_str[idx], &rptr);
- idx += (rptr - &p_str[idx]);
+ double number = String::to_double(&p_str[index], &rptr);
+ index += (rptr - &p_str[index]);
r_token.type = TK_NUMBER;
r_token.value = number;
return OK;
- } else if ((p_str[idx] >= 'A' && p_str[idx] <= 'Z') || (p_str[idx] >= 'a' && p_str[idx] <= 'z')) {
+ } else if ((p_str[index] >= 'A' && p_str[index] <= 'Z') || (p_str[index] >= 'a' && p_str[index] <= 'z')) {
String id;
- while ((p_str[idx] >= 'A' && p_str[idx] <= 'Z') || (p_str[idx] >= 'a' && p_str[idx] <= 'z')) {
+ while ((p_str[index] >= 'A' && p_str[index] <= 'Z') || (p_str[index] >= 'a' && p_str[index] <= 'z')) {
- id += p_str[idx];
- idx++;
+ id += p_str[index];
+ index++;
}
r_token.type = TK_IDENTIFIER;
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 75dfd563dd..8eb40b61d7 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -30,12 +30,40 @@
#include "marshalls.h"
#include "os/keyboard.h"
#include "print_string.h"
+#include "reference.h"
#include <stdio.h>
#define ENCODE_MASK 0xFF
#define ENCODE_FLAG_64 1 << 16
-Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len) {
+static Error _decode_string(const uint8_t *&buf, int &len, int *r_len, String &r_string) {
+ ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
+
+ uint32_t strlen = decode_uint32(buf);
+ buf += 4;
+ len -= 4;
+ ERR_FAIL_COND_V((int)strlen > len, ERR_FILE_EOF);
+
+ String str;
+ str.parse_utf8((const char *)buf, strlen);
+ r_string = str;
+
+ //handle padding
+ if (strlen % 4) {
+ strlen += 4 - strlen % 4;
+ }
+
+ buf += strlen;
+ len -= strlen;
+
+ if (r_len) {
+ (*r_len) += 4 + strlen;
+ }
+
+ return OK;
+}
+
+Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len, bool p_allow_objects) {
const uint8_t *buf = p_buffer;
int len = p_len;
@@ -104,22 +132,12 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::STRING: {
- ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
- uint32_t strlen = decode_uint32(buf);
- buf += 4;
- len -= 4;
- ERR_FAIL_COND_V((int)strlen > len, ERR_INVALID_DATA);
-
String str;
- str.parse_utf8((const char *)buf, strlen);
+ Error err = _decode_string(buf, len, r_len, str);
+ if (err)
+ return err;
r_variant = str;
- if (r_len) {
- if (strlen % 4)
- (*r_len) += 4 - strlen % 4;
- (*r_len) += 4 + strlen;
- }
-
} break;
// math types
@@ -363,7 +381,59 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::OBJECT: {
- r_variant = (Object *)NULL;
+ ERR_FAIL_COND_V(!p_allow_objects, ERR_UNAUTHORIZED);
+
+ String str;
+ Error err = _decode_string(buf, len, r_len, str);
+ if (err)
+ return err;
+
+ if (str == String()) {
+ r_variant = (Object *)NULL;
+ } else {
+
+ Object *obj = ClassDB::instance(str);
+
+ ERR_FAIL_COND_V(!obj, ERR_UNAVAILABLE);
+ ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
+
+ int32_t count = decode_uint32(buf);
+ buf += 4;
+ len -= 4;
+ if (r_len) {
+ (*r_len) += 4;
+ }
+
+ for (int i = 0; i < count; i++) {
+
+ str = String();
+ err = _decode_string(buf, len, r_len, str);
+ if (err)
+ return err;
+
+ Variant value;
+ int used;
+ err = decode_variant(value, buf, len, &used, p_allow_objects);
+ if (err)
+ return err;
+
+ buf += used;
+ len -= used;
+ if (r_len) {
+ (*r_len) += used;
+ }
+
+ obj->set(str, value);
+ }
+
+ if (obj->cast_to<Reference>()) {
+ REF ref = REF(obj->cast_to<Reference>());
+ r_variant = ref;
+ } else {
+ r_variant = obj;
+ }
+ }
+
} break;
case Variant::DICTIONARY: {
@@ -386,7 +456,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
Variant key, value;
int used;
- Error err = decode_variant(key, buf, len, &used);
+ Error err = decode_variant(key, buf, len, &used, p_allow_objects);
ERR_FAIL_COND_V(err, err);
buf += used;
@@ -395,7 +465,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
(*r_len) += used;
}
- err = decode_variant(value, buf, len, &used);
+ err = decode_variant(value, buf, len, &used, p_allow_objects);
ERR_FAIL_COND_V(err, err);
buf += used;
@@ -430,7 +500,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
int used = 0;
Variant v;
- Error err = decode_variant(v, buf, len, &used);
+ Error err = decode_variant(v, buf, len, &used, p_allow_objects);
ERR_FAIL_COND_V(err, err);
buf += used;
len -= used;
@@ -691,6 +761,21 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
return OK;
}
+static void _encode_string(const String &p_string, uint8_t *&buf, int &r_len) {
+
+ CharString utf8 = p_string.utf8();
+
+ if (buf) {
+ encode_uint32(utf8.length(), buf);
+ buf += 4;
+ copymem(buf, utf8.get_data(), utf8.length());
+ }
+
+ r_len += 4 + utf8.length();
+ while (r_len % 4)
+ r_len++; //pad
+}
+
Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
uint8_t *buf = r_buffer;
@@ -831,17 +916,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
} break;
case Variant::STRING: {
- CharString utf8 = p_variant.operator String().utf8();
-
- if (buf) {
- encode_uint32(utf8.length(), buf);
- buf += 4;
- copymem(buf, utf8.get_data(), utf8.length());
- }
-
- r_len += 4 + utf8.length();
- while (r_len % 4)
- r_len++; //pad
+ _encode_string(p_variant, buf, r_len);
} break;
// math types
@@ -991,9 +1066,57 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
ERR_EXPLAIN("Can't marshallize resources");
ERR_FAIL_V(ERR_INVALID_DATA); //no, i'm sorry, no go
} break;*/
- case Variant::_RID:
+ case Variant::_RID: {
+
+ } break;
case Variant::OBJECT: {
+ Object *obj = p_variant;
+ if (!obj) {
+ if (buf) {
+ encode_uint32(0, buf);
+ buf += 4;
+ r_len += 4;
+ }
+ } else {
+ _encode_string(obj->get_class(), buf, r_len);
+
+ List<PropertyInfo> props;
+ obj->get_property_list(&props);
+
+ int pc = 0;
+ for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
+
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ continue;
+ pc++;
+ }
+
+ if (buf) {
+ encode_uint32(pc, buf);
+ buf += 4;
+ }
+
+ r_len += 4;
+
+ for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
+
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ continue;
+
+ _encode_string(E->get().name, buf, r_len);
+
+ int len;
+ Error err = encode_variant(obj->get(E->get().name), buf, len);
+ if (err)
+ return err;
+ ERR_FAIL_COND_V(len % 4, ERR_BUG);
+ r_len += len;
+ if (buf)
+ buf += len;
+ }
+ }
+
} break;
case Variant::DICTIONARY: {
diff --git a/core/io/marshalls.h b/core/io/marshalls.h
index eb2785aa4e..a6cc72b691 100644
--- a/core/io/marshalls.h
+++ b/core/io/marshalls.h
@@ -183,7 +183,7 @@ static inline double decode_double(const uint8_t *p_arr) {
return md.d;
}
-Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = NULL);
+Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = NULL, bool p_allow_objects=true);
Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len);
#endif
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index c028d7d197..f62ffd7183 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -35,9 +35,20 @@
PacketPeer::PacketPeer() {
+ allow_object_decoding = false;
last_get_error = OK;
}
+void PacketPeer::set_allow_object_decoding(bool p_enable) {
+
+ allow_object_decoding = p_enable;
+}
+
+bool PacketPeer::is_object_decoding_allowed() const {
+
+ return allow_object_decoding;
+}
+
Error PacketPeer::get_packet_buffer(PoolVector<uint8_t> &r_buffer) const {
const uint8_t *buffer;
@@ -75,7 +86,7 @@ Error PacketPeer::get_var(Variant &r_variant) const {
if (err)
return err;
- return decode_variant(r_variant, buffer, buffer_size);
+ return decode_variant(r_variant, buffer, buffer_size, NULL, allow_object_decoding);
}
Error PacketPeer::put_var(const Variant &p_packet) {
@@ -126,6 +137,9 @@ void PacketPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("put_packet", "buffer"), &PacketPeer::_put_packet);
ClassDB::bind_method(D_METHOD("get_packet_error"), &PacketPeer::_get_packet_error);
ClassDB::bind_method(D_METHOD("get_available_packet_count"), &PacketPeer::get_available_packet_count);
+
+ ClassDB::bind_method(D_METHOD("set_allow_object_decoding", "enable"), &PacketPeer::set_allow_object_decoding);
+ ClassDB::bind_method(D_METHOD("is_object_decoding_allowed"), &PacketPeer::is_object_decoding_allowed);
};
/***************/
diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h
index ed6b252d80..3bd6876aa7 100644
--- a/core/io/packet_peer.h
+++ b/core/io/packet_peer.h
@@ -48,6 +48,8 @@ class PacketPeer : public Reference {
mutable Error last_get_error;
+ bool allow_object_decoding;
+
public:
virtual int get_available_packet_count() const = 0;
virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) const = 0; ///< buffer is GONE after next get_packet
@@ -63,6 +65,9 @@ public:
virtual Error get_var(Variant &r_variant) const;
virtual Error put_var(const Variant &p_packet);
+ void set_allow_object_decoding(bool p_enable);
+ bool is_object_decoding_allowed() const;
+
PacketPeer();
~PacketPeer() {}
};
diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h
index a39eb6bcfd..007b810b67 100644
--- a/core/io/packet_peer_udp.h
+++ b/core/io/packet_peer_udp.h
@@ -49,7 +49,7 @@ protected:
public:
void set_blocking_mode(bool p_enable);
- virtual Error listen(int p_port, IP_Address p_bind_address = IP_Address("*"), int p_recv_buffer_size = 65536) = 0;
+ virtual Error listen(int p_port, const IP_Address &p_bind_address = IP_Address("*"), int p_recv_buffer_size = 65536) = 0;
virtual void close() = 0;
virtual Error wait() = 0;
virtual bool is_listening() const = 0;
diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp
index 61da4f3350..7033dbe5fb 100644
--- a/core/io/resource_import.cpp
+++ b/core/io/resource_import.cpp
@@ -199,6 +199,52 @@ String ResourceFormatImporter::get_internal_resource_path(const String &p_path)
return pat.path;
}
+void ResourceFormatImporter::get_internal_resource_path_list(const String &p_path, List<String> *r_paths) {
+
+ Error err;
+ FileAccess *f = FileAccess::open(p_path + ".import", FileAccess::READ, &err);
+
+ if (!f)
+ return;
+
+ VariantParser::StreamFile stream;
+ stream.f = f;
+
+ String assign;
+ Variant value;
+ VariantParser::Tag next_tag;
+
+ int lines = 0;
+ String error_text;
+ while (true) {
+
+ assign = Variant();
+ next_tag.fields.clear();
+ next_tag.name = String();
+
+ err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true);
+ if (err == ERR_FILE_EOF) {
+ memdelete(f);
+ return;
+ } else if (err != OK) {
+ ERR_PRINTS("ResourceFormatImporter::get_internal_resource_path_list - " + p_path + ".import:" + itos(lines) + " error: " + error_text);
+ memdelete(f);
+ return;
+ }
+
+ if (assign != String()) {
+ if (assign.begins_with("path.")) {
+ r_paths->push_back(value);
+ } else if (assign == "path") {
+ r_paths->push_back(value);
+ }
+ } else if (next_tag.name != "remap") {
+ break;
+ }
+ }
+ memdelete(f);
+}
+
String ResourceFormatImporter::get_resource_type(const String &p_path) const {
PathAndType pat;
diff --git a/core/io/resource_import.h b/core/io/resource_import.h
index d3f98cbc07..67fd870178 100644
--- a/core/io/resource_import.h
+++ b/core/io/resource_import.h
@@ -59,6 +59,7 @@ public:
virtual bool can_be_imported(const String &p_path) const;
String get_internal_resource_path(const String &p_path) const;
+ void get_internal_resource_path_list(const String &p_path, List<String> *r_paths);
void add_importer(const Ref<ResourceImporter> &p_importer) { importers.insert(p_importer); }
void remove_importer(const Ref<ResourceImporter> &p_importer) { importers.erase(p_importer); }
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index fdad7c7bdf..7042700d92 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -210,7 +210,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_u32(cs.length());
put_data((const uint8_t *)cs.get_data(), cs.length());
}
void StreamPeer::put_var(const Variant &p_variant) {
@@ -459,8 +459,9 @@ Error StreamPeerBuffer::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_
}
PoolVector<uint8_t>::Read r = data.read();
- copymem(p_buffer, r.ptr(), r_received);
+ copymem(p_buffer, r.ptr() + pointer, r_received);
+ pointer += r_received;
// FIXME: return what? OK or ERR_*
}
diff --git a/core/io/tcp_server.h b/core/io/tcp_server.h
index 4e7fa7cf3e..b4ff3246ad 100644
--- a/core/io/tcp_server.h
+++ b/core/io/tcp_server.h
@@ -45,7 +45,7 @@ protected:
static void _bind_methods();
public:
- virtual Error listen(uint16_t p_port, const IP_Address p_bind_address = IP_Address("*")) = 0;
+ virtual Error listen(uint16_t p_port, const IP_Address &p_bind_address = IP_Address("*")) = 0;
virtual bool is_connection_available() const = 0;
virtual Ref<StreamPeerTCP> take_connection() = 0;
diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp
index 52e240ed47..956cfe5258 100644
--- a/core/math/math_2d.cpp
+++ b/core/math/math_2d.cpp
@@ -281,22 +281,22 @@ Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, c
}
// slide returns the component of the vector along the given plane, specified by its normal vector.
-Vector2 Vector2::slide(const Vector2 &p_n) const {
+Vector2 Vector2::slide(const Vector2 &p_normal) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector2());
+ ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector2());
#endif
- return *this - p_n * this->dot(p_n);
+ return *this - p_normal * this->dot(p_normal);
}
-Vector2 Vector2::bounce(const Vector2 &p_n) const {
- return -reflect(p_n);
+Vector2 Vector2::bounce(const Vector2 &p_normal) const {
+ return -reflect(p_normal);
}
-Vector2 Vector2::reflect(const Vector2 &p_n) const {
+Vector2 Vector2::reflect(const Vector2 &p_normal) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector2());
+ ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector2());
#endif
- return 2.0 * p_n * this->dot(p_n) - *this;
+ return 2.0 * p_normal * this->dot(p_normal) - *this;
}
bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 *r_pos, Point2 *r_normal) const {
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index b679371e03..6fea6c8adb 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -43,6 +43,14 @@ enum Margin {
MARGIN_BOTTOM
};
+enum Corner {
+
+ CORNER_TOP_LEFT,
+ CORNER_TOP_RIGHT,
+ CORNER_BOTTOM_RIGHT,
+ CORNER_BOTTOM_LEFT
+};
+
enum Orientation {
HORIZONTAL,
@@ -107,9 +115,9 @@ struct Vector2 {
Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const;
Vector2 cubic_interpolate_soft(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const;
- Vector2 slide(const Vector2 &p_vec) const;
- Vector2 bounce(const Vector2 &p_vec) const;
- Vector2 reflect(const Vector2 &p_vec) const;
+ Vector2 slide(const Vector2 &p_normal) const;
+ Vector2 bounce(const Vector2 &p_normal) const;
+ Vector2 reflect(const Vector2 &p_normal) const;
Vector2 operator+(const Vector2 &p_v) const;
void operator+=(const Vector2 &p_v);
@@ -621,9 +629,9 @@ struct Transform2D {
void affine_invert();
Transform2D affine_inverse() const;
- void set_rotation(real_t p_phi);
+ void set_rotation(real_t p_rot);
real_t get_rotation() const;
- _FORCE_INLINE_ void set_rotation_and_scale(real_t p_phi, const Size2 &p_scale);
+ _FORCE_INLINE_ void set_rotation_and_scale(real_t p_rot, const Size2 &p_scale);
void rotate(real_t p_phi);
void scale(const Size2 &p_scale);
@@ -660,8 +668,8 @@ struct Transform2D {
_FORCE_INLINE_ Vector2 basis_xform_inv(const Vector2 &p_vec) const;
_FORCE_INLINE_ Vector2 xform(const Vector2 &p_vec) const;
_FORCE_INLINE_ Vector2 xform_inv(const Vector2 &p_vec) const;
- _FORCE_INLINE_ Rect2 xform(const Rect2 &p_vec) const;
- _FORCE_INLINE_ Rect2 xform_inv(const Rect2 &p_vec) const;
+ _FORCE_INLINE_ Rect2 xform(const Rect2 &p_rect) const;
+ _FORCE_INLINE_ Rect2 xform_inv(const Rect2 &p_rect) const;
operator String() const;
@@ -833,25 +841,25 @@ next4:
return true;
}
-Vector2 Transform2D::basis_xform(const Vector2 &v) const {
+Vector2 Transform2D::basis_xform(const Vector2 &p_vec) const {
return Vector2(
- tdotx(v),
- tdoty(v));
+ tdotx(p_vec),
+ tdoty(p_vec));
}
-Vector2 Transform2D::basis_xform_inv(const Vector2 &v) const {
+Vector2 Transform2D::basis_xform_inv(const Vector2 &p_vec) const {
return Vector2(
- elements[0].dot(v),
- elements[1].dot(v));
+ elements[0].dot(p_vec),
+ elements[1].dot(p_vec));
}
-Vector2 Transform2D::xform(const Vector2 &v) const {
+Vector2 Transform2D::xform(const Vector2 &p_vec) const {
return Vector2(
- tdotx(v),
- tdoty(v)) +
+ tdotx(p_vec),
+ tdoty(p_vec)) +
elements[2];
}
Vector2 Transform2D::xform_inv(const Vector2 &p_vec) const {
diff --git a/core/math/octree.h b/core/math/octree.h
index 010c1b18f7..2e37056030 100644
--- a/core/math/octree.h
+++ b/core/math/octree.h
@@ -351,7 +351,7 @@ private:
};
void _cull_convex(Octant *p_octant, _CullConvexData *p_cull);
- void _cull_AABB(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
+ void _cull_aabb(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
void _cull_segment(Octant *p_octant, const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
void _cull_point(Octant *p_octant, const Vector3 &p_point, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
@@ -380,7 +380,7 @@ public:
int get_subindex(OctreeElementID p_id) const;
int cull_convex(const Vector<Plane> &p_convex, T **p_result_array, int p_result_max, uint32_t p_mask = 0xFFFFFFFF);
- int cull_AABB(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
+ int cull_aabb(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
int cull_segment(const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
int cull_point(const Vector3 &p_point, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
@@ -1095,7 +1095,7 @@ void Octree<T, use_pairs, AL>::_cull_convex(Octant *p_octant, _CullConvexData *p
}
template <class T, bool use_pairs, class AL>
-void Octree<T, use_pairs, AL>::_cull_AABB(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
+void Octree<T, use_pairs, AL>::_cull_aabb(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
if (*p_result_idx == p_result_max)
return; //pointless
@@ -1160,7 +1160,7 @@ void Octree<T, use_pairs, AL>::_cull_AABB(Octant *p_octant, const Rect3 &p_aabb,
for (int i = 0; i < 8; i++) {
if (p_octant->children[i] && p_octant->children[i]->aabb.intersects_inclusive(p_aabb)) {
- _cull_AABB(p_octant->children[i], p_aabb, p_result_array, p_result_idx, p_result_max, p_subindex_array, p_mask);
+ _cull_aabb(p_octant->children[i], p_aabb, p_result_array, p_result_idx, p_result_max, p_subindex_array, p_mask);
}
}
}
@@ -1336,14 +1336,14 @@ int Octree<T, use_pairs, AL>::cull_convex(const Vector<Plane> &p_convex, T **p_r
}
template <class T, bool use_pairs, class AL>
-int Octree<T, use_pairs, AL>::cull_AABB(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
+int Octree<T, use_pairs, AL>::cull_aabb(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
if (!root)
return 0;
int result_count = 0;
pass++;
- _cull_AABB(root, p_aabb, p_result_array, &result_count, p_result_max, p_subindex_array, p_mask);
+ _cull_aabb(root, p_aabb, p_result_array, &result_count, p_result_max, p_subindex_array, p_mask);
return result_count;
}
diff --git a/core/math/plane.cpp b/core/math/plane.cpp
index f5e92866c4..17928d07c3 100644
--- a/core/math/plane.cpp
+++ b/core/math/plane.cpp
@@ -103,7 +103,7 @@ bool Plane::intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r
return true;
}
-bool Plane::intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersection) const {
+bool Plane::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection) const {
Vector3 segment = p_dir;
real_t den = normal.dot(segment);
@@ -128,7 +128,7 @@ bool Plane::intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersectio
return true;
}
-bool Plane::intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3 *p_intersection) const {
+bool Plane::intersects_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 *p_intersection) const {
Vector3 segment = p_begin - p_end;
real_t den = normal.dot(segment);
diff --git a/core/math/plane.h b/core/math/plane.h
index 92ebcd8024..73d584e553 100644
--- a/core/math/plane.h
+++ b/core/math/plane.h
@@ -56,8 +56,8 @@ public:
/* intersections */
bool intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result = 0) const;
- bool intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersection) const;
- bool intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3 *p_intersection) const;
+ bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection) const;
+ bool intersects_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 *p_intersection) const;
_FORCE_INLINE_ Vector3 project(const Vector3 &p_point) const {
diff --git a/core/math/rect3.h b/core/math/rect3.h
index e5d7462009..7c971f5ac7 100644
--- a/core/math/rect3.h
+++ b/core/math/rect3.h
@@ -72,9 +72,9 @@ public:
Rect3 intersection(const Rect3 &p_aabb) const; ///get box where two intersect, empty if no intersection occurs
bool intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip = NULL, Vector3 *r_normal = NULL) const;
bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip = NULL, Vector3 *r_normal = NULL) const;
- _FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &from, const Vector3 &p_dir, real_t t0, real_t t1) const;
+ _FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const;
- _FORCE_INLINE_ bool intersects_convex_shape(const Plane *p_plane, int p_plane_count) const;
+ _FORCE_INLINE_ bool intersects_convex_shape(const Plane *p_planes, int p_plane_count) const;
bool intersects_plane(const Plane &p_plane) const;
_FORCE_INLINE_ bool has_point(const Vector3 &p_point) const;
@@ -326,27 +326,27 @@ inline real_t Rect3::get_shortest_axis_size() const {
return max_size;
}
-bool Rect3::smits_intersect_ray(const Vector3 &from, const Vector3 &dir, real_t t0, real_t t1) const {
+bool Rect3::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const {
- real_t divx = 1.0 / dir.x;
- real_t divy = 1.0 / dir.y;
- real_t divz = 1.0 / dir.z;
+ real_t divx = 1.0 / p_dir.x;
+ real_t divy = 1.0 / p_dir.y;
+ real_t divz = 1.0 / p_dir.z;
Vector3 upbound = position + size;
real_t tmin, tmax, tymin, tymax, tzmin, tzmax;
- if (dir.x >= 0) {
- tmin = (position.x - from.x) * divx;
- tmax = (upbound.x - from.x) * divx;
+ if (p_dir.x >= 0) {
+ tmin = (position.x - p_from.x) * divx;
+ tmax = (upbound.x - p_from.x) * divx;
} else {
- tmin = (upbound.x - from.x) * divx;
- tmax = (position.x - from.x) * divx;
+ tmin = (upbound.x - p_from.x) * divx;
+ tmax = (position.x - p_from.x) * divx;
}
- if (dir.y >= 0) {
- tymin = (position.y - from.y) * divy;
- tymax = (upbound.y - from.y) * divy;
+ if (p_dir.y >= 0) {
+ tymin = (position.y - p_from.y) * divy;
+ tymax = (upbound.y - p_from.y) * divy;
} else {
- tymin = (upbound.y - from.y) * divy;
- tymax = (position.y - from.y) * divy;
+ tymin = (upbound.y - p_from.y) * divy;
+ tymax = (position.y - p_from.y) * divy;
}
if ((tmin > tymax) || (tymin > tmax))
return false;
@@ -354,12 +354,12 @@ bool Rect3::smits_intersect_ray(const Vector3 &from, const Vector3 &dir, real_t
tmin = tymin;
if (tymax < tmax)
tmax = tymax;
- if (dir.z >= 0) {
- tzmin = (position.z - from.z) * divz;
- tzmax = (upbound.z - from.z) * divz;
+ if (p_dir.z >= 0) {
+ tzmin = (position.z - p_from.z) * divz;
+ tzmax = (upbound.z - p_from.z) * divz;
} else {
- tzmin = (upbound.z - from.z) * divz;
- tzmax = (position.z - from.z) * divz;
+ tzmin = (upbound.z - p_from.z) * divz;
+ tzmax = (position.z - p_from.z) * divz;
}
if ((tmin > tzmax) || (tzmin > tmax))
return false;
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 6a7974681e..c58a86fbdb 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -108,9 +108,9 @@ struct Vector3 {
_FORCE_INLINE_ real_t angle_to(const Vector3 &p_b) const;
- _FORCE_INLINE_ Vector3 slide(const Vector3 &p_vec) const;
- _FORCE_INLINE_ Vector3 bounce(const Vector3 &p_vec) const;
- _FORCE_INLINE_ Vector3 reflect(const Vector3 &p_vec) const;
+ _FORCE_INLINE_ Vector3 slide(const Vector3 &p_normal) const;
+ _FORCE_INLINE_ Vector3 bounce(const Vector3 &p_normal) const;
+ _FORCE_INLINE_ Vector3 reflect(const Vector3 &p_normal) const;
/* Operators */
@@ -410,22 +410,22 @@ void Vector3::zero() {
}
// slide returns the component of the vector along the given plane, specified by its normal vector.
-Vector3 Vector3::slide(const Vector3 &p_n) const {
+Vector3 Vector3::slide(const Vector3 &p_normal) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector3());
+ ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector3());
#endif
- return *this - p_n * this->dot(p_n);
+ return *this - p_normal * this->dot(p_normal);
}
-Vector3 Vector3::bounce(const Vector3 &p_n) const {
- return -reflect(p_n);
+Vector3 Vector3::bounce(const Vector3 &p_normal) const {
+ return -reflect(p_normal);
}
-Vector3 Vector3::reflect(const Vector3 &p_n) const {
+Vector3 Vector3::reflect(const Vector3 &p_normal) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector3());
+ ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector3());
#endif
- return 2.0 * p_n * this->dot(p_n) - *this;
+ return 2.0 * p_normal * this->dot(p_normal) - *this;
}
#endif
diff --git a/core/method_bind.h b/core/method_bind.h
index 3b4ff96a19..9bf0323733 100644
--- a/core/method_bind.h
+++ b/core/method_bind.h
@@ -150,6 +150,7 @@ VARIANT_ENUM_CAST(Vector3::Axis);
VARIANT_ENUM_CAST(Error);
VARIANT_ENUM_CAST(wchar_t);
VARIANT_ENUM_CAST(Margin);
+VARIANT_ENUM_CAST(Corner);
VARIANT_ENUM_CAST(Orientation);
VARIANT_ENUM_CAST(HAlign);
VARIANT_ENUM_CAST(Variant::Type);
diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h
index ead58c23c8..d8755fd98b 100644
--- a/core/method_ptrcall.h
+++ b/core/method_ptrcall.h
@@ -80,6 +80,26 @@ struct PtrToArg {
} \
}
+#define MAKE_PTRARG_BY_REFERENCE(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(const 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(const m_type &p_val, void *p_ptr) { \
+ *((m_type *)p_ptr) = p_val; \
+ } \
+ }
+
MAKE_PTRARG(bool);
MAKE_PTRARGCONV(uint8_t, int64_t);
MAKE_PTRARGCONV(int8_t, int64_t);
@@ -95,14 +115,14 @@ MAKE_PTRARG(double);
MAKE_PTRARG(String);
MAKE_PTRARG(Vector2);
MAKE_PTRARG(Rect2);
-MAKE_PTRARG(Vector3);
+MAKE_PTRARG_BY_REFERENCE(Vector3);
MAKE_PTRARG(Transform2D);
-MAKE_PTRARG(Plane);
+MAKE_PTRARG_BY_REFERENCE(Plane);
MAKE_PTRARG(Quat);
-MAKE_PTRARG(Rect3);
-MAKE_PTRARG(Basis);
-MAKE_PTRARG(Transform);
-MAKE_PTRARG(Color);
+MAKE_PTRARG_BY_REFERENCE(Rect3);
+MAKE_PTRARG_BY_REFERENCE(Basis);
+MAKE_PTRARG_BY_REFERENCE(Transform);
+MAKE_PTRARG_BY_REFERENCE(Color);
MAKE_PTRARG(NodePath);
MAKE_PTRARG(RID);
MAKE_PTRARG(Dictionary);
@@ -114,7 +134,7 @@ MAKE_PTRARG(PoolStringArray);
MAKE_PTRARG(PoolVector2Array);
MAKE_PTRARG(PoolVector3Array);
MAKE_PTRARG(PoolColorArray);
-MAKE_PTRARG(Variant);
+MAKE_PTRARG_BY_REFERENCE(Variant);
//this is for Object
@@ -311,8 +331,29 @@ MAKE_DVECARR(Plane);
} \
}
+#define MAKE_STRINGCONV_BY_REFERENCE(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(const 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);
+MAKE_STRINGCONV_BY_REFERENCE(IP_Address);
template <>
struct PtrToArg<PoolVector<Face3> > {
diff --git a/core/object.h b/core/object.h
index 551c3c31b9..4648d9d90e 100644
--- a/core/object.h
+++ b/core/object.h
@@ -443,7 +443,7 @@ private:
mutable StringName _class_name;
mutable const StringName *_class_ptr;
- void _add_user_signal(const String &p_name, const Array &p_pargs = Array());
+ void _add_user_signal(const String &p_name, const Array &p_args = Array());
bool _has_user_signal(const StringName &p_name) const;
Variant _emit_signal(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
Array _get_signal_list() const;
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index 3bd5ac3f41..9d1fefc925 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -475,9 +475,9 @@ void FileAccess::store_buffer(const uint8_t *p_src, int p_length) {
store_8(p_src[i]);
}
-Vector<uint8_t> FileAccess::get_file_as_array(const String &p_file) {
+Vector<uint8_t> FileAccess::get_file_as_array(const String &p_path) {
- FileAccess *f = FileAccess::open(p_file, READ);
+ FileAccess *f = FileAccess::open(p_path, READ);
ERR_FAIL_COND_V(!f, Vector<uint8_t>());
Vector<uint8_t> data;
data.resize(f->get_len());
diff --git a/core/os/file_access.h b/core/os/file_access.h
index 6d3e491167..beed7551fb 100644
--- a/core/os/file_access.h
+++ b/core/os/file_access.h
@@ -129,7 +129,7 @@ public:
virtual void store_real(real_t p_real);
virtual void store_string(const String &p_string);
- virtual void store_line(const String &p_string);
+ virtual void store_line(const String &p_line);
virtual void store_pascal_string(const String &p_string);
virtual String get_pascal_string();
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index fe0e2c2524..cb38eb67b6 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -595,6 +595,11 @@ float InputEventJoypadMotion::get_axis_value() const {
return axis_value;
}
+bool InputEventJoypadMotion::is_pressed() const {
+
+ return Math::abs(axis_value) > 0.5f;
+}
+
bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event) const {
Ref<InputEventJoypadMotion> jm = p_event;
diff --git a/core/os/input_event.h b/core/os/input_event.h
index b120d4b840..d1fd7cc90f 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -348,6 +348,7 @@ public:
void set_axis_value(float p_value);
float get_axis_value() const;
+ virtual bool is_pressed() const;
virtual bool action_match(const Ref<InputEvent> &p_event) const;
virtual bool is_action_type() const { return true; }
diff --git a/core/os/keyboard.h b/core/os/keyboard.h
index 1ed93e3540..1ef26de183 100644
--- a/core/os/keyboard.h
+++ b/core/os/keyboard.h
@@ -324,7 +324,7 @@ enum KeyModifierMask {
};
String keycode_get_string(uint32_t p_code);
-bool keycode_has_unicode(uint32_t p_unicode);
+bool keycode_has_unicode(uint32_t p_keycode);
int find_keycode(const String &p_code);
int keycode_get_count();
int keycode_get_value_by_index(int p_index);
diff --git a/core/pair.h b/core/pair.h
index d4b1897537..d517339ddf 100644
--- a/core/pair.h
+++ b/core/pair.h
@@ -37,7 +37,7 @@ struct Pair {
S second;
Pair() {}
- Pair(F p_first, S p_second)
+ Pair(F p_first, const S &p_second)
: first(p_first),
second(p_second) {
}
diff --git a/core/project_settings.h b/core/project_settings.h
index c64bb393d1..cee3b3b5f3 100644
--- a/core/project_settings.h
+++ b/core/project_settings.h
@@ -158,7 +158,7 @@ public:
bool is_using_datapack() const;
- void set_registering_order(bool p_registering);
+ void set_registering_order(bool p_enable);
ProjectSettings();
~ProjectSettings();
diff --git a/core/resource.h b/core/resource.h
index 5a4e45da36..bbf233d53e 100644
--- a/core/resource.h
+++ b/core/resource.h
@@ -107,7 +107,7 @@ public:
int get_subindex() const;
virtual Ref<Resource> duplicate(bool p_subresources = false) const;
- Ref<Resource> duplicate_for_local_scene(Node *p_scene, Map<Ref<Resource>, Ref<Resource> > &remap_cache);
+ Ref<Resource> duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, Ref<Resource> > &remap_cache);
void set_local_to_scene(bool p_enable);
bool is_local_to_scene() const;
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 3628f2ecaf..44e86bca6a 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -429,9 +429,9 @@ void ScriptDebuggerRemote::_err_handler(void *ud, const char *p_func, const char
sdr->mutex->unlock();
}
-bool ScriptDebuggerRemote::_parse_live_edit(const Array &cmd) {
+bool ScriptDebuggerRemote::_parse_live_edit(const Array &p_command) {
- String cmdstr = cmd[0];
+ String cmdstr = p_command[0];
if (!live_edit_funcs || !cmdstr.begins_with("live_"))
return false;
@@ -441,7 +441,7 @@ bool ScriptDebuggerRemote::_parse_live_edit(const Array &cmd) {
if (!live_edit_funcs->root_func)
return true;
//print_line("root: "+Variant(cmd).get_construct_string());
- live_edit_funcs->root_func(live_edit_funcs->udata, cmd[1], cmd[2]);
+ live_edit_funcs->root_func(live_edit_funcs->udata, p_command[1], p_command[2]);
} else if (cmdstr == "live_node_path") {
@@ -449,75 +449,75 @@ bool ScriptDebuggerRemote::_parse_live_edit(const Array &cmd) {
return true;
//print_line("path: "+Variant(cmd).get_construct_string());
- live_edit_funcs->node_path_func(live_edit_funcs->udata, cmd[1], cmd[2]);
+ live_edit_funcs->node_path_func(live_edit_funcs->udata, p_command[1], p_command[2]);
} else if (cmdstr == "live_res_path") {
if (!live_edit_funcs->res_path_func)
return true;
- live_edit_funcs->res_path_func(live_edit_funcs->udata, cmd[1], cmd[2]);
+ live_edit_funcs->res_path_func(live_edit_funcs->udata, p_command[1], p_command[2]);
} else if (cmdstr == "live_node_prop_res") {
if (!live_edit_funcs->node_set_res_func)
return true;
- live_edit_funcs->node_set_res_func(live_edit_funcs->udata, cmd[1], cmd[2], cmd[3]);
+ live_edit_funcs->node_set_res_func(live_edit_funcs->udata, p_command[1], p_command[2], p_command[3]);
} else if (cmdstr == "live_node_prop") {
if (!live_edit_funcs->node_set_func)
return true;
- live_edit_funcs->node_set_func(live_edit_funcs->udata, cmd[1], cmd[2], cmd[3]);
+ live_edit_funcs->node_set_func(live_edit_funcs->udata, p_command[1], p_command[2], p_command[3]);
} else if (cmdstr == "live_res_prop_res") {
if (!live_edit_funcs->res_set_res_func)
return true;
- live_edit_funcs->res_set_res_func(live_edit_funcs->udata, cmd[1], cmd[2], cmd[3]);
+ live_edit_funcs->res_set_res_func(live_edit_funcs->udata, p_command[1], p_command[2], p_command[3]);
} else if (cmdstr == "live_res_prop") {
if (!live_edit_funcs->res_set_func)
return true;
- live_edit_funcs->res_set_func(live_edit_funcs->udata, cmd[1], cmd[2], cmd[3]);
+ live_edit_funcs->res_set_func(live_edit_funcs->udata, p_command[1], p_command[2], p_command[3]);
} else if (cmdstr == "live_node_call") {
if (!live_edit_funcs->node_call_func)
return true;
- live_edit_funcs->node_call_func(live_edit_funcs->udata, cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6], cmd[7]);
+ live_edit_funcs->node_call_func(live_edit_funcs->udata, p_command[1], p_command[2], p_command[3], p_command[4], p_command[5], p_command[6], p_command[7]);
} else if (cmdstr == "live_res_call") {
if (!live_edit_funcs->res_call_func)
return true;
- live_edit_funcs->res_call_func(live_edit_funcs->udata, cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6], cmd[7]);
+ live_edit_funcs->res_call_func(live_edit_funcs->udata, p_command[1], p_command[2], p_command[3], p_command[4], p_command[5], p_command[6], p_command[7]);
} else if (cmdstr == "live_create_node") {
- live_edit_funcs->tree_create_node_func(live_edit_funcs->udata, cmd[1], cmd[2], cmd[3]);
+ live_edit_funcs->tree_create_node_func(live_edit_funcs->udata, p_command[1], p_command[2], p_command[3]);
} else if (cmdstr == "live_instance_node") {
- live_edit_funcs->tree_instance_node_func(live_edit_funcs->udata, cmd[1], cmd[2], cmd[3]);
+ live_edit_funcs->tree_instance_node_func(live_edit_funcs->udata, p_command[1], p_command[2], p_command[3]);
} else if (cmdstr == "live_remove_node") {
- live_edit_funcs->tree_remove_node_func(live_edit_funcs->udata, cmd[1]);
+ live_edit_funcs->tree_remove_node_func(live_edit_funcs->udata, p_command[1]);
} else if (cmdstr == "live_remove_and_keep_node") {
- live_edit_funcs->tree_remove_and_keep_node_func(live_edit_funcs->udata, cmd[1], cmd[2]);
+ live_edit_funcs->tree_remove_and_keep_node_func(live_edit_funcs->udata, p_command[1], p_command[2]);
} else if (cmdstr == "live_restore_node") {
- live_edit_funcs->tree_restore_node_func(live_edit_funcs->udata, cmd[1], cmd[2], cmd[3]);
+ live_edit_funcs->tree_restore_node_func(live_edit_funcs->udata, p_command[1], p_command[2], p_command[3]);
} else if (cmdstr == "live_duplicate_node") {
- live_edit_funcs->tree_duplicate_node_func(live_edit_funcs->udata, cmd[1], cmd[2]);
+ live_edit_funcs->tree_duplicate_node_func(live_edit_funcs->udata, p_command[1], p_command[2]);
} else if (cmdstr == "live_reparent_node") {
- live_edit_funcs->tree_reparent_node_func(live_edit_funcs->udata, cmd[1], cmd[2], cmd[3], cmd[4]);
+ live_edit_funcs->tree_reparent_node_func(live_edit_funcs->udata, p_command[1], p_command[2], p_command[3], p_command[4]);
} else {
diff --git a/core/ustring.cpp b/core/ustring.cpp
index ab4528e495..0521966943 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -279,16 +279,16 @@ void String::operator=(const CharType *p_str) {
copy_from(p_str);
}
-bool String::operator==(const StrRange &p_range) const {
+bool String::operator==(const StrRange &p_str_range) const {
- int len = p_range.len;
+ int len = p_str_range.len;
if (length() != len)
return false;
if (empty())
return true;
- const CharType *c_str = p_range.c_str;
+ const CharType *c_str = p_str_range.c_str;
const CharType *dst = &operator[](0);
/* Compare char by char */
diff --git a/core/ustring.h b/core/ustring.h
index d00bfa59b5..1c61e12e85 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -78,7 +78,7 @@ public:
//String operator+(CharType p_char) const;
String &operator+=(const String &);
- String &operator+=(CharType p_str);
+ String &operator+=(CharType p_char);
String &operator+=(const char *p_str);
String &operator+=(const CharType *p_str);
@@ -156,7 +156,7 @@ public:
int get_slice_count(String p_splitter) const;
String get_slice(String p_splitter, int p_slice) const;
- String get_slicec(CharType splitter, int p_slice) const;
+ String get_slicec(CharType p_splitter, int p_slice) const;
Vector<String> split(const String &p_splitter, bool p_allow_empty = true) const;
Vector<String> split_spaces() const;
@@ -186,8 +186,8 @@ public:
bool parse_utf8(const char *p_utf8, int p_len = -1); //return true on error
static String utf8(const char *p_utf8, int p_len = -1);
- static uint32_t hash(const CharType *p_str, int p_len); /* hash the string */
- static uint32_t hash(const CharType *p_str); /* hash the string */
+ static uint32_t hash(const CharType *p_cstr, int p_len); /* hash the string */
+ static uint32_t hash(const CharType *p_cstr); /* hash the string */
static uint32_t hash(const char *p_cstr, int p_len); /* hash the string */
static uint32_t hash(const char *p_cstr); /* hash the string */
uint32_t hash() const; /* hash the string */
diff --git a/core/variant_construct_string.cpp b/core/variant_construct_string.cpp
index 45fe367ce6..fa8a393d08 100644
--- a/core/variant_construct_string.cpp
+++ b/core/variant_construct_string.cpp
@@ -66,7 +66,7 @@ class VariantConstruct {
static Error _get_token(const CharType *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str);
static Error _parse_value(Variant &value, Token &token, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str, Variant::ObjectConstruct *p_construct, void *p_ud);
static Error _parse_array(Array &array, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str, Variant::ObjectConstruct *p_construct, void *p_ud);
- static Error _parse_dict(Dictionary &object, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str, Variant::ObjectConstruct *p_construct, void *p_ud);
+ static Error _parse_dict(Dictionary &dict, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str, Variant::ObjectConstruct *p_construct, void *p_ud);
public:
static Error parse(const String &p_string, Variant &r_ret, String &r_err_str, int &r_err_line, Variant::ObjectConstruct *p_construct, void *p_ud);
@@ -85,15 +85,15 @@ const char *VariantConstruct::tk_name[TK_MAX] = {
"EOF",
};
-Error VariantConstruct::_get_token(const CharType *p_str, int &idx, int p_len, Token &r_token, int &line, String &r_err_str) {
+Error VariantConstruct::_get_token(const CharType *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str) {
while (true) {
- switch (p_str[idx]) {
+ switch (p_str[index]) {
case '\n': {
line++;
- idx++;
+ index++;
break;
};
case 0: {
@@ -103,54 +103,54 @@ Error VariantConstruct::_get_token(const CharType *p_str, int &idx, int p_len, T
case '{': {
r_token.type = TK_CURLY_BRACKET_OPEN;
- idx++;
+ index++;
return OK;
};
case '}': {
r_token.type = TK_CURLY_BRACKET_CLOSE;
- idx++;
+ index++;
return OK;
};
case '[': {
r_token.type = TK_BRACKET_OPEN;
- idx++;
+ index++;
return OK;
};
case ']': {
r_token.type = TK_BRACKET_CLOSE;
- idx++;
+ index++;
return OK;
};
case ':': {
r_token.type = TK_COLON;
- idx++;
+ index++;
return OK;
};
case ',': {
r_token.type = TK_COMMA;
- idx++;
+ index++;
return OK;
};
case '"': {
- idx++;
+ index++;
String str;
while (true) {
- if (p_str[idx] == 0) {
+ if (p_str[index] == 0) {
r_err_str = "Unterminated String";
return ERR_PARSE_ERROR;
- } else if (p_str[idx] == '"') {
- idx++;
+ } else if (p_str[index] == '"') {
+ index++;
break;
- } else if (p_str[idx] == '\\') {
+ } else if (p_str[index] == '\\') {
//escaped characters...
- idx++;
- CharType next = p_str[idx];
+ index++;
+ CharType next = p_str[index];
if (next == 0) {
r_err_str = "Unterminated String";
return ERR_PARSE_ERROR;
@@ -171,7 +171,7 @@ Error VariantConstruct::_get_token(const CharType *p_str, int &idx, int p_len, T
//hexnumbarh - oct is deprecated
for (int j = 0; j < 4; j++) {
- CharType c = p_str[idx + j + 1];
+ CharType c = p_str[index + j + 1];
if (c == 0) {
r_err_str = "Unterminated String";
return ERR_PARSE_ERROR;
@@ -198,7 +198,7 @@ Error VariantConstruct::_get_token(const CharType *p_str, int &idx, int p_len, T
res <<= 4;
res |= v;
}
- idx += 4; //will add at the end anyway
+ index += 4; //will add at the end anyway
} break;
default: {
@@ -211,11 +211,11 @@ Error VariantConstruct::_get_token(const CharType *p_str, int &idx, int p_len, T
str += res;
} else {
- if (p_str[idx] == '\n')
+ if (p_str[index] == '\n')
line++;
- str += p_str[idx];
+ str += p_str[index];
}
- idx++;
+ index++;
}
r_token.type = TK_STRING;
@@ -225,28 +225,28 @@ Error VariantConstruct::_get_token(const CharType *p_str, int &idx, int p_len, T
} break;
default: {
- if (p_str[idx] <= 32) {
- idx++;
+ if (p_str[index] <= 32) {
+ index++;
break;
}
- if (p_str[idx] == '-' || (p_str[idx] >= '0' && p_str[idx] <= '9')) {
+ if (p_str[index] == '-' || (p_str[index] >= '0' && p_str[index] <= '9')) {
//a number
const CharType *rptr;
- double number = String::to_double(&p_str[idx], &rptr);
- idx += (rptr - &p_str[idx]);
+ double number = String::to_double(&p_str[index], &rptr);
+ index += (rptr - &p_str[index]);
r_token.type = TK_NUMBER;
r_token.value = number;
return OK;
- } else if ((p_str[idx] >= 'A' && p_str[idx] <= 'Z') || (p_str[idx] >= 'a' && p_str[idx] <= 'z')) {
+ } else if ((p_str[index] >= 'A' && p_str[index] <= 'Z') || (p_str[index] >= 'a' && p_str[index] <= 'z')) {
String id;
- while ((p_str[idx] >= 'A' && p_str[idx] <= 'Z') || (p_str[idx] >= 'a' && p_str[idx] <= 'z')) {
+ while ((p_str[index] >= 'A' && p_str[index] <= 'Z') || (p_str[index] >= 'a' && p_str[index] <= 'z')) {
- id += p_str[idx];
- idx++;
+ id += p_str[index];
+ index++;
}
r_token.type = TK_IDENTIFIER;
diff --git a/core/vector.h b/core/vector.h
index 5eed8dce96..9f523c567c 100644
--- a/core/vector.h
+++ b/core/vector.h
@@ -117,7 +117,7 @@ public:
}
_FORCE_INLINE_ bool empty() const { return _ptr == 0; }
Error resize(int p_size);
- bool push_back(T p_elem);
+ bool push_back(const T &p_elem);
void remove(int p_index);
void erase(const T &p_val) {
@@ -129,7 +129,7 @@ public:
template <class T_val>
int find(const T_val &p_val, int p_from = 0) const;
- void set(int p_index, T p_elem);
+ void set(int p_index, const T &p_elem);
T get(int p_index) const;
inline T &operator[](int p_index) {
@@ -336,7 +336,7 @@ void Vector<T>::invert() {
}
template <class T>
-void Vector<T>::set(int p_index, T p_elem) {
+void Vector<T>::set(int p_index, const T &p_elem) {
operator[](p_index) = p_elem;
}
@@ -348,7 +348,7 @@ T Vector<T>::get(int p_index) const {
}
template <class T>
-bool Vector<T>::push_back(T p_elem) {
+bool Vector<T>::push_back(const T &p_elem) {
Error err = resize(size() + 1);
ERR_FAIL_COND_V(err, true)