summaryrefslogtreecommitdiff
path: root/core/io
diff options
context:
space:
mode:
Diffstat (limited to 'core/io')
-rw-r--r--core/io/config_file.cpp6
-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_compressed.cpp20
-rw-r--r--core/io/file_access_memory.h2
-rw-r--r--core/io/file_access_pack.cpp7
-rw-r--r--core/io/file_access_zip.cpp12
-rw-r--r--core/io/http_client.cpp10
-rw-r--r--core/io/ip_address.h2
-rw-r--r--core/io/json.cpp60
-rw-r--r--core/io/marshalls.cpp251
-rw-r--r--core/io/marshalls.h21
-rw-r--r--core/io/packet_peer.cpp46
-rw-r--r--core/io/packet_peer.h7
-rw-r--r--core/io/packet_peer_udp.cpp4
-rw-r--r--core/io/packet_peer_udp.h2
-rw-r--r--core/io/resource_format_binary.cpp6
-rw-r--r--core/io/resource_format_binary.h8
-rw-r--r--core/io/resource_import.cpp46
-rw-r--r--core/io/resource_import.h7
-rw-r--r--core/io/resource_loader.cpp2
-rw-r--r--core/io/stream_peer.cpp11
-rw-r--r--core/io/stream_peer_ssl.cpp4
-rw-r--r--core/io/tcp_server.cpp2
-rw-r--r--core/io/tcp_server.h2
25 files changed, 415 insertions, 137 deletions
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp
index 4067899068..edd090adf2 100644
--- a/core/io/config_file.cpp
+++ b/core/io/config_file.cpp
@@ -205,7 +205,7 @@ Error ConfigFile::load(const String &p_path) {
void ConfigFile::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_value", "section", "key", "value"), &ConfigFile::set_value);
- ClassDB::bind_method(D_METHOD("get_value:Variant", "section", "key", "default"), &ConfigFile::get_value, DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("get_value", "section", "key", "default"), &ConfigFile::get_value, DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("has_section", "section"), &ConfigFile::has_section);
ClassDB::bind_method(D_METHOD("has_section_key", "section", "key"), &ConfigFile::has_section_key);
@@ -215,8 +215,8 @@ void ConfigFile::_bind_methods() {
ClassDB::bind_method(D_METHOD("erase_section", "section"), &ConfigFile::erase_section);
- ClassDB::bind_method(D_METHOD("load:Error", "path"), &ConfigFile::load);
- ClassDB::bind_method(D_METHOD("save:Error", "path"), &ConfigFile::save);
+ ClassDB::bind_method(D_METHOD("load", "path"), &ConfigFile::load);
+ ClassDB::bind_method(D_METHOD("save", "path"), &ConfigFile::save);
}
ConfigFile::ConfigFile() {
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_compressed.cpp b/core/io/file_access_compressed.cpp
index 4e802579c6..34bce3f04f 100644
--- a/core/io/file_access_compressed.cpp
+++ b/core/io/file_access_compressed.cpp
@@ -43,16 +43,16 @@ void FileAccessCompressed::configure(const String &p_magic, Compression::Mode p_
block_size = p_block_size;
}
-#define WRITE_FIT(m_bytes) \
- { \
- if (write_pos + (m_bytes) > write_max) { \
- write_max = write_pos + (m_bytes); \
- } \
- if (write_max > write_buffer_size) { \
- write_buffer_size = nearest_power_of_2(write_max); \
- buffer.resize(write_buffer_size); \
- write_ptr = buffer.ptr(); \
- } \
+#define WRITE_FIT(m_bytes) \
+ { \
+ if (write_pos + (m_bytes) > write_max) { \
+ write_max = write_pos + (m_bytes); \
+ } \
+ if (write_max > write_buffer_size) { \
+ write_buffer_size = next_power_of_2(write_max); \
+ buffer.resize(write_buffer_size); \
+ write_ptr = buffer.ptr(); \
+ } \
}
Error FileAccessCompressed::open_after_magic(FileAccess *p_base) {
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_pack.cpp b/core/io/file_access_pack.cpp
index 79aa39521f..c3bcfc840b 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -308,10 +308,9 @@ bool FileAccessPack::file_exists(const String &p_name) {
return false;
}
-FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file) {
-
- pf = p_file;
- f = FileAccess::open(pf.pack, FileAccess::READ);
+FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file)
+ : pf(p_file),
+ f(FileAccess::open(pf.pack, FileAccess::READ)) {
if (!f) {
ERR_EXPLAIN("Can't open pack-referenced file: " + String(pf.pack));
ERR_FAIL_COND(!f);
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/http_client.cpp b/core/io/http_client.cpp
index 0c84a5213f..4d5b88cfa1 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -624,9 +624,9 @@ Error HTTPClient::_get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received
void HTTPClient::_bind_methods() {
- ClassDB::bind_method(D_METHOD("connect_to_host:Error", "host", "port", "use_ssl", "verify_host"), &HTTPClient::connect_to_host, DEFVAL(false), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("set_connection", "connection:StreamPeer"), &HTTPClient::set_connection);
- ClassDB::bind_method(D_METHOD("get_connection:StreamPeer"), &HTTPClient::get_connection);
+ ClassDB::bind_method(D_METHOD("connect_to_host", "host", "port", "use_ssl", "verify_host"), &HTTPClient::connect_to_host, DEFVAL(false), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("set_connection", "connection"), &HTTPClient::set_connection);
+ ClassDB::bind_method(D_METHOD("get_connection"), &HTTPClient::get_connection);
ClassDB::bind_method(D_METHOD("request_raw", "method", "url", "headers", "body"), &HTTPClient::request_raw);
ClassDB::bind_method(D_METHOD("request", "method", "url", "headers", "body"), &HTTPClient::request, DEFVAL(String()));
ClassDB::bind_method(D_METHOD("send_body_text", "body"), &HTTPClient::send_body_text);
@@ -646,9 +646,9 @@ void HTTPClient::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_blocking_mode_enabled"), &HTTPClient::is_blocking_mode_enabled);
ClassDB::bind_method(D_METHOD("get_status"), &HTTPClient::get_status);
- ClassDB::bind_method(D_METHOD("poll:Error"), &HTTPClient::poll);
+ ClassDB::bind_method(D_METHOD("poll"), &HTTPClient::poll);
- ClassDB::bind_method(D_METHOD("query_string_from_dict:String", "fields"), &HTTPClient::query_string_from_dict);
+ ClassDB::bind_method(D_METHOD("query_string_from_dict", "fields"), &HTTPClient::query_string_from_dict);
BIND_CONSTANT(METHOD_GET);
BIND_CONSTANT(METHOD_HEAD);
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..c5d59f786d 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -30,12 +30,60 @@
#include "marshalls.h"
#include "os/keyboard.h"
#include "print_string.h"
+#include "reference.h"
#include <stdio.h>
+void EncodedObjectAsID::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_object_id", "id"), &EncodedObjectAsID::set_object_id);
+ ClassDB::bind_method(D_METHOD("get_object_id"), &EncodedObjectAsID::get_object_id);
+}
+
+void EncodedObjectAsID::set_object_id(ObjectID p_id) {
+ id = p_id;
+}
+
+ObjectID EncodedObjectAsID::get_object_id() const {
+
+ return id;
+}
+
+EncodedObjectAsID::EncodedObjectAsID() {
+
+ id = 0;
+}
+
#define ENCODE_MASK 0xFF
#define ENCODE_FLAG_64 1 << 16
+#define ENCODE_FLAG_OBJECT_AS_ID 1 << 16
+
+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);
-Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len) {
+ 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 +152,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 +401,77 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::OBJECT: {
- r_variant = (Object *)NULL;
+ if (type & ENCODE_FLAG_OBJECT_AS_ID) {
+ //this _is_ allowed
+ ObjectID val = decode_uint64(buf);
+ if (r_len)
+ (*r_len) += 8;
+
+ if (val == 0) {
+ r_variant = (Object *)NULL;
+ } else {
+ Ref<EncodedObjectAsID> obj_as_id;
+ obj_as_id.instance();
+ obj_as_id->set_object_id(val);
+
+ r_variant = obj_as_id;
+ }
+
+ } else {
+ 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 +494,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 +503,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 +538,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,7 +799,22 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
return OK;
}
-Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
+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, bool p_object_as_id) {
uint8_t *buf = r_buffer;
@@ -715,6 +838,11 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
flags |= ENCODE_FLAG_64; //always encode real as double
}
} break;
+ case Variant::OBJECT: {
+ if (p_object_as_id) {
+ flags |= ENCODE_FLAG_OBJECT_AS_ID;
+ }
+ } break;
}
if (buf) {
@@ -831,17 +959,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 +1109,74 @@ 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: {
+ if (p_object_as_id) {
+
+ if (buf) {
+
+ Object *obj = p_variant;
+ ObjectID id = 0;
+ if (obj && ObjectDB::instance_validate(obj)) {
+ id = obj->get_instance_id();
+ }
+
+ encode_uint64(id, buf);
+ }
+
+ r_len += 8;
+
+ } else {
+ 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, p_object_as_id);
+ if (err)
+ return err;
+ ERR_FAIL_COND_V(len % 4, ERR_BUG);
+ r_len += len;
+ if (buf)
+ buf += len;
+ }
+ }
+ }
+
} break;
case Variant::DICTIONARY: {
@@ -1024,12 +1207,12 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
r_len++; //pad
*/
int len;
- encode_variant(E->get(), buf, len);
+ encode_variant(E->get(), buf, len, p_object_as_id);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
if (buf)
buf += len;
- encode_variant(d[E->get()], buf, len);
+ encode_variant(d[E->get()], buf, len, p_object_as_id);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
if (buf)
@@ -1051,7 +1234,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
for (int i = 0; i < v.size(); i++) {
int len;
- encode_variant(v.get(i), buf, len);
+ encode_variant(v.get(i), buf, len, p_object_as_id);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
if (buf)
diff --git a/core/io/marshalls.h b/core/io/marshalls.h
index eb2785aa4e..234ae3b183 100644
--- a/core/io/marshalls.h
+++ b/core/io/marshalls.h
@@ -32,8 +32,8 @@
#include "typedefs.h"
+#include "reference.h"
#include "variant.h"
-
/**
* Miscellaneous helpers for marshalling data types, and encoding
* in an endian independent way
@@ -183,7 +183,22 @@ 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 encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len);
+class EncodedObjectAsID : public Reference {
+ GDCLASS(EncodedObjectAsID, Reference);
+
+ ObjectID id;
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_object_id(ObjectID p_id);
+ ObjectID get_object_id() const;
+
+ EncodedObjectAsID();
+};
+
+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, bool p_object_as_id = false);
#endif
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 40082cc481..ca00b8b480 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,13 +86,13 @@ 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) {
int len;
- Error err = encode_variant(p_packet, NULL, len); // compute len first
+ Error err = encode_variant(p_packet, NULL, len, !allow_object_decoding); // compute len first
if (err)
return err;
@@ -90,7 +101,7 @@ Error PacketPeer::put_var(const Variant &p_packet) {
uint8_t *buf = (uint8_t *)alloca(len);
ERR_FAIL_COND_V(!buf, ERR_OUT_OF_MEMORY);
- err = encode_variant(p_packet, buf, len);
+ err = encode_variant(p_packet, buf, len, !allow_object_decoding);
ERR_FAIL_COND_V(err, err);
return put_packet(buf, len);
@@ -120,12 +131,15 @@ Error PacketPeer::_get_packet_error() const {
void PacketPeer::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_var:Variant"), &PacketPeer::_bnd_get_var);
- ClassDB::bind_method(D_METHOD("put_var", "var:Variant"), &PacketPeer::put_var);
+ ClassDB::bind_method(D_METHOD("get_var"), &PacketPeer::_bnd_get_var);
+ ClassDB::bind_method(D_METHOD("put_var", "var"), &PacketPeer::put_var);
ClassDB::bind_method(D_METHOD("get_packet"), &PacketPeer::_get_packet);
- ClassDB::bind_method(D_METHOD("put_packet:Error", "buffer"), &PacketPeer::_put_packet);
- ClassDB::bind_method(D_METHOD("get_packet_error:Error"), &PacketPeer::_get_packet_error);
+ 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);
};
/***************/
@@ -138,9 +152,11 @@ void PacketPeerStream::_set_stream_peer(REF p_peer) {
void PacketPeerStream::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_stream_peer", "peer:StreamPeer"), &PacketPeerStream::_set_stream_peer);
+ ClassDB::bind_method(D_METHOD("set_stream_peer", "peer"), &PacketPeerStream::_set_stream_peer);
ClassDB::bind_method(D_METHOD("set_input_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_input_buffer_max_size);
ClassDB::bind_method(D_METHOD("set_output_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_output_buffer_max_size);
+ ClassDB::bind_method(D_METHOD("get_input_buffer_max_size"), &PacketPeerStream::get_input_buffer_max_size);
+ ClassDB::bind_method(D_METHOD("get_output_buffer_max_size"), &PacketPeerStream::get_output_buffer_max_size);
}
Error PacketPeerStream::_poll_buffer() const {
@@ -251,12 +267,22 @@ void PacketPeerStream::set_input_buffer_max_size(int p_max_size) {
ERR_EXPLAIN("Buffer in use, resizing would cause loss of data");
ERR_FAIL_COND(ring_buffer.data_left());
ring_buffer.resize(nearest_shift(p_max_size + 4));
- input_buffer.resize(nearest_power_of_2(p_max_size + 4));
+ input_buffer.resize(next_power_of_2(p_max_size + 4));
+}
+
+int PacketPeerStream::get_input_buffer_max_size() const {
+
+ return input_buffer.size() - 4;
}
void PacketPeerStream::set_output_buffer_max_size(int p_max_size) {
- output_buffer.resize(nearest_power_of_2(p_max_size + 4));
+ output_buffer.resize(next_power_of_2(p_max_size + 4));
+}
+
+int PacketPeerStream::get_output_buffer_max_size() const {
+
+ return output_buffer.size() - 4;
}
PacketPeerStream::PacketPeerStream() {
diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h
index ed6b252d80..597119f7f4 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() {}
};
@@ -93,7 +98,9 @@ public:
void set_stream_peer(const Ref<StreamPeer> &p_peer);
void set_input_buffer_max_size(int p_max_size);
+ int get_input_buffer_max_size() const;
void set_output_buffer_max_size(int p_max_size);
+ int get_output_buffer_max_size() const;
PacketPeerStream();
};
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
index 8bc3241cc5..d1729819a8 100644
--- a/core/io/packet_peer_udp.cpp
+++ b/core/io/packet_peer_udp.cpp
@@ -59,9 +59,9 @@ Error PacketPeerUDP::_set_dest_address(const String &p_address, int p_port) {
void PacketPeerUDP::_bind_methods() {
- ClassDB::bind_method(D_METHOD("listen:Error", "port", "bind_address", "recv_buf_size"), &PacketPeerUDP::listen, DEFVAL("*"), DEFVAL(65536));
+ ClassDB::bind_method(D_METHOD("listen", "port", "bind_address", "recv_buf_size"), &PacketPeerUDP::listen, DEFVAL("*"), DEFVAL(65536));
ClassDB::bind_method(D_METHOD("close"), &PacketPeerUDP::close);
- ClassDB::bind_method(D_METHOD("wait:Error"), &PacketPeerUDP::wait);
+ ClassDB::bind_method(D_METHOD("wait"), &PacketPeerUDP::wait);
ClassDB::bind_method(D_METHOD("is_listening"), &PacketPeerUDP::is_listening);
ClassDB::bind_method(D_METHOD("get_packet_ip"), &PacketPeerUDP::_get_packet_ip);
//ClassDB::bind_method(D_METHOD("get_packet_address"),&PacketPeerUDP::_get_packet_address);
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_format_binary.cpp b/core/io/resource_format_binary.cpp
index 9aa16ed7e7..fd8928b8a0 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -717,7 +717,7 @@ Error ResourceInteractiveLoaderBinary::poll() {
if (!r) {
error = ERR_FILE_CORRUPT;
memdelete(obj); //bye
- ERR_EXPLAIN(local_path + ":Resoucre type in resource field not a resource, type is: " + obj->get_class());
+ ERR_EXPLAIN(local_path + ":Resource type in resource field not a resource, type is: " + obj->get_class());
ERR_FAIL_COND_V(!r, ERR_FILE_CORRUPT);
}
@@ -901,7 +901,7 @@ void ResourceInteractiveLoaderBinary::open(FileAccess *p_f) {
uint32_t ext_resources_size = f->get_32();
for (uint32_t i = 0; i < ext_resources_size; i++) {
- ExtResoucre er;
+ ExtResource er;
er.type = get_unicode_string();
er.path = get_unicode_string();
external_resources.push_back(er);
@@ -926,7 +926,7 @@ void ResourceInteractiveLoaderBinary::open(FileAccess *p_f) {
for (uint32_t i = 0; i < int_resources_size; i++) {
- IntResoucre ir;
+ IntResource ir;
ir.path = get_unicode_string();
ir.offset = f->get_64();
internal_resources.push_back(ir);
diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h
index 5da5a0fc37..1c66344e3e 100644
--- a/core/io/resource_format_binary.h
+++ b/core/io/resource_format_binary.h
@@ -56,19 +56,19 @@ class ResourceInteractiveLoaderBinary : public ResourceInteractiveLoader {
StringName _get_string();
- struct ExtResoucre {
+ struct ExtResource {
String path;
String type;
};
- Vector<ExtResoucre> external_resources;
+ Vector<ExtResource> external_resources;
- struct IntResoucre {
+ struct IntResource {
String path;
uint64_t offset;
};
- Vector<IntResoucre> internal_resources;
+ Vector<IntResource> internal_resources;
String get_unicode_string();
void _advance_padding(uint32_t p_len);
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 9d2a5180dc..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); }
@@ -85,9 +86,9 @@ public:
PropertyInfo option;
Variant default_value;
- ImportOption(const PropertyInfo &p_info, const Variant &p_default) {
- option = p_info;
- default_value = p_default;
+ ImportOption(const PropertyInfo &p_info, const Variant &p_default)
+ : option(p_info),
+ default_value(p_default) {
}
ImportOption() {}
};
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 9b89fa3399..5347cd6ee1 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -84,7 +84,7 @@ void ResourceLoader::get_recognized_extensions_for_type(const String &p_type, Li
void ResourceInteractiveLoader::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_resource:Resource"), &ResourceInteractiveLoader::get_resource);
+ ClassDB::bind_method(D_METHOD("get_resource"), &ResourceInteractiveLoader::get_resource);
ClassDB::bind_method(D_METHOD("poll"), &ResourceInteractiveLoader::poll);
ClassDB::bind_method(D_METHOD("wait"), &ResourceInteractiveLoader::wait);
ClassDB::bind_method(D_METHOD("get_stage"), &ResourceInteractiveLoader::get_stage);
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index 0dbcb3cf56..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) {
@@ -385,7 +385,7 @@ void StreamPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("put_float", "val"), &StreamPeer::put_float);
ClassDB::bind_method(D_METHOD("put_double", "val"), &StreamPeer::put_double);
ClassDB::bind_method(D_METHOD("put_utf8_string", "val"), &StreamPeer::put_utf8_string);
- ClassDB::bind_method(D_METHOD("put_var", "val:Variant"), &StreamPeer::put_var);
+ ClassDB::bind_method(D_METHOD("put_var", "val"), &StreamPeer::put_var);
ClassDB::bind_method(D_METHOD("get_8"), &StreamPeer::get_8);
ClassDB::bind_method(D_METHOD("get_u8"), &StreamPeer::get_u8);
@@ -399,7 +399,7 @@ void StreamPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_double"), &StreamPeer::get_double);
ClassDB::bind_method(D_METHOD("get_string", "bytes"), &StreamPeer::get_string);
ClassDB::bind_method(D_METHOD("get_utf8_string", "bytes"), &StreamPeer::get_utf8_string);
- ClassDB::bind_method(D_METHOD("get_var:Variant"), &StreamPeer::get_var);
+ ClassDB::bind_method(D_METHOD("get_var"), &StreamPeer::get_var);
}
////////////////////////////////
@@ -412,7 +412,7 @@ void StreamPeerBuffer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_data_array", "data"), &StreamPeerBuffer::set_data_array);
ClassDB::bind_method(D_METHOD("get_data_array"), &StreamPeerBuffer::get_data_array);
ClassDB::bind_method(D_METHOD("clear"), &StreamPeerBuffer::clear);
- ClassDB::bind_method(D_METHOD("duplicate:StreamPeerBuffer"), &StreamPeerBuffer::duplicate);
+ ClassDB::bind_method(D_METHOD("duplicate"), &StreamPeerBuffer::duplicate);
}
Error StreamPeerBuffer::put_data(const uint8_t *p_data, int p_bytes) {
@@ -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/stream_peer_ssl.cpp b/core/io/stream_peer_ssl.cpp
index 57cffd073a..ef3c264375 100644
--- a/core/io/stream_peer_ssl.cpp
+++ b/core/io/stream_peer_ssl.cpp
@@ -51,8 +51,8 @@ bool StreamPeerSSL::is_available() {
void StreamPeerSSL::_bind_methods() {
- ClassDB::bind_method(D_METHOD("accept_stream:Error", "stream:StreamPeer"), &StreamPeerSSL::accept_stream);
- ClassDB::bind_method(D_METHOD("connect_to_stream:Error", "stream:StreamPeer", "validate_certs", "for_hostname"), &StreamPeerSSL::connect_to_stream, DEFVAL(false), DEFVAL(String()));
+ ClassDB::bind_method(D_METHOD("accept_stream", "stream"), &StreamPeerSSL::accept_stream);
+ ClassDB::bind_method(D_METHOD("connect_to_stream", "stream", "validate_certs", "for_hostname"), &StreamPeerSSL::connect_to_stream, DEFVAL(false), DEFVAL(String()));
ClassDB::bind_method(D_METHOD("get_status"), &StreamPeerSSL::get_status);
ClassDB::bind_method(D_METHOD("disconnect_from_stream"), &StreamPeerSSL::disconnect_from_stream);
BIND_CONSTANT(STATUS_DISCONNECTED);
diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp
index 4c891188ee..29a80ecc19 100644
--- a/core/io/tcp_server.cpp
+++ b/core/io/tcp_server.cpp
@@ -49,7 +49,7 @@ void TCP_Server::_bind_methods() {
ClassDB::bind_method(D_METHOD("listen", "port", "bind_address"), &TCP_Server::listen, DEFVAL("*"));
ClassDB::bind_method(D_METHOD("is_connection_available"), &TCP_Server::is_connection_available);
- ClassDB::bind_method(D_METHOD("take_connection:StreamPeerTCP"), &TCP_Server::take_connection);
+ ClassDB::bind_method(D_METHOD("take_connection"), &TCP_Server::take_connection);
ClassDB::bind_method(D_METHOD("stop"), &TCP_Server::stop);
}
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;