summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp4
-rw-r--r--core/class_db.cpp6
-rw-r--r--core/hash_map.h90
-rw-r--r--core/helper/math_fieldwise.cpp2
-rw-r--r--core/helper/math_fieldwise.h2
-rw-r--r--core/image.cpp6
-rw-r--r--core/io/file_access_compressed.h10
-rw-r--r--core/io/file_access_encrypted.cpp4
-rw-r--r--core/io/file_access_encrypted.h2
-rw-r--r--core/io/file_access_network.cpp4
-rw-r--r--core/io/file_access_network.h4
-rw-r--r--core/io/marshalls.cpp10
-rw-r--r--core/io/resource_format_binary.cpp18
-rw-r--r--core/io/resource_format_binary.h2
-rw-r--r--core/io/resource_import.cpp2
-rw-r--r--core/io/resource_loader.cpp82
-rw-r--r--core/io/resource_loader.h6
-rw-r--r--core/io/translation_loader_po.cpp4
-rw-r--r--core/io/xml_parser.cpp2
-rw-r--r--core/io/xml_parser.h2
-rw-r--r--core/list.h4
-rw-r--r--core/math/a_star.h2
-rw-r--r--core/math/face3.cpp2
-rw-r--r--core/math/quick_hull.cpp10
-rw-r--r--core/method_bind.h2
-rw-r--r--core/ordered_hash_map.h315
-rw-r--r--core/os/os.cpp3
-rw-r--r--core/packed_data_container.cpp8
-rw-r--r--core/pair.h10
-rw-r--r--core/pool_allocator.cpp6
-rw-r--r--core/project_settings.cpp2
-rw-r--r--core/project_settings.h2
-rw-r--r--core/reference.h2
-rw-r--r--core/script_language.cpp1
-rw-r--r--core/ustring.cpp22
-rw-r--r--core/vmap.h6
-rw-r--r--core/vset.h7
37 files changed, 519 insertions, 147 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index abe8b9b715..0f217c8235 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -568,7 +568,7 @@ Dictionary _OS::get_time(bool utc) const {
}
/**
- * Get a epoch time value from a dictionary of time values
+ * Get an epoch time value from a dictionary of time values
* @p datetime must be populated with the following keys:
* day, hour, minute, month, second, year. (dst is ignored).
*
@@ -1705,7 +1705,7 @@ Variant _File::get_var() const {
ERR_FAIL_COND_V(!f, Variant());
uint32_t len = get_32();
PoolVector<uint8_t> buff = get_buffer(len);
- ERR_FAIL_COND_V(buff.size() != len, Variant());
+ ERR_FAIL_COND_V((uint32_t)buff.size() != len, Variant());
PoolVector<uint8_t>::Read r = buff.read();
diff --git a/core/class_db.cpp b/core/class_db.cpp
index 1cb287a143..f5ddd9c761 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -535,7 +535,11 @@ void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, b
minfo.return_val = method->get_return_info();
minfo.flags = method->get_hint_flags();
- minfo.default_arguments = method->get_default_arguments();
+
+ for (int i = 0; i < method->get_argument_count(); i++) {
+ if (method->has_default_argument(i))
+ minfo.default_arguments.push_back(method->get_default_argument(i));
+ }
p_methods->push_back(minfo);
}
diff --git a/core/hash_map.h b/core/hash_map.h
index b22c6378b0..37391a4c83 100644
--- a/core/hash_map.h
+++ b/core/hash_map.h
@@ -102,17 +102,31 @@ public:
}
};
-private:
- struct Entry {
+ struct Element {
+ private:
+ friend class HashMap;
uint32_t hash;
- Entry *next;
+ Element *next;
+ Element() { next = 0; }
Pair pair;
- Entry() { next = 0; }
+ public:
+ const TKey &key() const {
+ return pair.key;
+ }
+
+ TData &value() {
+ return pair.data;
+ }
+
+ const TData &value() const {
+ return pair.value();
+ }
};
- Entry **hash_table;
+private:
+ Element **hash_table;
uint8_t hash_table_power;
uint32_t elements;
@@ -120,7 +134,7 @@ private:
ERR_FAIL_COND(hash_table);
- hash_table = memnew_arr(Entry *, (1 << MIN_HASH_TABLE_POWER));
+ hash_table = memnew_arr(Element *, (1 << MIN_HASH_TABLE_POWER));
hash_table_power = MIN_HASH_TABLE_POWER;
elements = 0;
@@ -168,7 +182,7 @@ private:
if (new_hash_table_power == -1)
return;
- Entry **new_hash_table = memnew_arr(Entry *, (1 << new_hash_table_power));
+ Element **new_hash_table = memnew_arr(Element *, (1 << new_hash_table_power));
if (!new_hash_table) {
ERR_PRINT("Out of Memory");
@@ -184,7 +198,7 @@ private:
while (hash_table[i]) {
- Entry *se = hash_table[i];
+ Element *se = hash_table[i];
hash_table[i] = se->next;
int new_pos = se->hash & ((1 << new_hash_table_power) - 1);
se->next = new_hash_table[new_pos];
@@ -199,12 +213,12 @@ private:
}
/* I want to have only one function.. */
- _FORCE_INLINE_ const Entry *get_entry(const TKey &p_key) const {
+ _FORCE_INLINE_ const Element *get_element(const TKey &p_key) const {
uint32_t hash = Hasher::hash(p_key);
uint32_t index = hash & ((1 << hash_table_power) - 1);
- Entry *e = hash_table[index];
+ Element *e = hash_table[index];
while (e) {
@@ -221,10 +235,10 @@ private:
return NULL;
}
- Entry *create_entry(const TKey &p_key) {
+ Element *create_element(const TKey &p_key) {
- /* if entry doesn't exist, create it */
- Entry *e = memnew(Entry);
+ /* if element doesn't exist, create it */
+ Element *e = memnew(Element);
ERR_FAIL_COND_V(!e, NULL); /* out of memory */
uint32_t hash = Hasher::hash(p_key);
uint32_t index = hash & ((1 << hash_table_power) - 1);
@@ -248,7 +262,7 @@ private:
if (!p_t.hash_table || p_t.hash_table_power == 0)
return; /* not copying from empty table */
- hash_table = memnew_arr(Entry *, 1 << p_t.hash_table_power);
+ hash_table = memnew_arr(Element *, 1 << p_t.hash_table_power);
hash_table_power = p_t.hash_table_power;
elements = p_t.elements;
@@ -256,11 +270,11 @@ private:
hash_table[i] = NULL;
- const Entry *e = p_t.hash_table[i];
+ const Element *e = p_t.hash_table[i];
while (e) {
- Entry *le = memnew(Entry); /* local entry */
+ Element *le = memnew(Element); /* local element */
*le = *e; /* copy data */
@@ -274,30 +288,30 @@ private:
}
public:
- void set(const TKey &p_key, const TData &p_data) {
-
- set(Pair(p_key, p_data));
+ Element *set(const TKey &p_key, const TData &p_data) {
+ return set(Pair(p_key, p_data));
}
- void set(const Pair &p_pair) {
+ Element *set(const Pair &p_pair) {
- Entry *e = NULL;
+ Element *e = NULL;
if (!hash_table)
make_hash_table(); // if no table, make one
else
- e = const_cast<Entry *>(get_entry(p_pair.key));
+ e = const_cast<Element *>(get_element(p_pair.key));
/* if we made it up to here, the pair doesn't exist, create and assign */
if (!e) {
- e = create_entry(p_pair.key);
+ e = create_element(p_pair.key);
if (!e)
- return;
+ return NULL;
check_hash_table(); // perform mantenience routine
}
e->pair.data = p_pair.data;
+ return e;
}
bool has(const TKey &p_key) const {
@@ -335,7 +349,7 @@ public:
if (!hash_table)
return NULL;
- Entry *e = const_cast<Entry *>(get_entry(p_key));
+ Element *e = const_cast<Element *>(get_element(p_key));
if (e)
return &e->pair.data;
@@ -348,7 +362,7 @@ public:
if (!hash_table)
return NULL;
- const Entry *e = const_cast<Entry *>(get_entry(p_key));
+ const Element *e = const_cast<Element *>(get_element(p_key));
if (e)
return &e->pair.data;
@@ -370,7 +384,7 @@ public:
uint32_t hash = p_custom_hash;
uint32_t index = hash & ((1 << hash_table_power) - 1);
- Entry *e = hash_table[index];
+ Element *e = hash_table[index];
while (e) {
@@ -396,7 +410,7 @@ public:
uint32_t hash = p_custom_hash;
uint32_t index = hash & ((1 << hash_table_power) - 1);
- const Entry *e = hash_table[index];
+ const Element *e = hash_table[index];
while (e) {
@@ -425,8 +439,8 @@ public:
uint32_t hash = Hasher::hash(p_key);
uint32_t index = hash & ((1 << hash_table_power) - 1);
- Entry *e = hash_table[index];
- Entry *p = NULL;
+ Element *e = hash_table[index];
+ Element *p = NULL;
while (e) {
/* checking hash first avoids comparing key, which may take longer */
@@ -463,16 +477,16 @@ public:
}
inline TData &operator[](const TKey &p_key) { //assignment
- Entry *e = NULL;
+ Element *e = NULL;
if (!hash_table)
make_hash_table(); // if no table, make one
else
- e = const_cast<Entry *>(get_entry(p_key));
+ e = const_cast<Element *>(get_element(p_key));
/* if we made it up to here, the pair doesn't exist, create */
if (!e) {
- e = create_entry(p_key);
+ e = create_element(p_key);
CRASH_COND(!e);
check_hash_table(); // perform mantenience routine
}
@@ -510,14 +524,14 @@ public:
} else { /* get the next key */
- const Entry *e = get_entry(*p_key);
+ const Element *e = get_element(*p_key);
ERR_FAIL_COND_V(!e, NULL); /* invalid key supplied */
if (e->next) {
/* if there is a "next" in the list, return that */
return &e->next->pair.key;
} else {
- /* go to next entries */
+ /* go to next elements */
uint32_t index = e->hash & ((1 << hash_table_power) - 1);
index++;
for (int i = index; i < (1 << hash_table_power); i++) {
@@ -552,7 +566,7 @@ public:
while (hash_table[i]) {
- Entry *e = hash_table[i];
+ Element *e = hash_table[i];
hash_table[i] = e->next;
memdelete(e);
}
@@ -582,7 +596,7 @@ public:
return;
for (int i = 0; i < (1 << hash_table_power); i++) {
- Entry *e = hash_table[i];
+ Element *e = hash_table[i];
while (e) {
*p_pairs = &e->pair;
p_pairs++;
@@ -596,7 +610,7 @@ public:
return;
for (int i = 0; i < (1 << hash_table_power); i++) {
- Entry *e = hash_table[i];
+ Element *e = hash_table[i];
while (e) {
p_keys->push_back(e->pair.key);
e = e->next;
diff --git a/core/helper/math_fieldwise.cpp b/core/helper/math_fieldwise.cpp
index 2ce2a70866..228611f8b3 100644
--- a/core/helper/math_fieldwise.cpp
+++ b/core/helper/math_fieldwise.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* fieldwise.cpp */
+/* math_fieldwise.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
diff --git a/core/helper/math_fieldwise.h b/core/helper/math_fieldwise.h
index 4671703f41..400df040a4 100644
--- a/core/helper/math_fieldwise.h
+++ b/core/helper/math_fieldwise.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* fieldwise.h */
+/* math_fieldwise.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
diff --git a/core/image.cpp b/core/image.cpp
index bb1ce2cee3..4d1f32c360 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -1256,9 +1256,9 @@ void Image::create(const char **p_xpm) {
if (*line_ptr == '#') {
line_ptr++;
- uint8_t col_r;
- uint8_t col_g;
- uint8_t col_b;
+ uint8_t col_r = 0;
+ uint8_t col_g = 0;
+ uint8_t col_b = 0;
//uint8_t col_a=255;
for (int i = 0; i < 6; i++) {
diff --git a/core/io/file_access_compressed.h b/core/io/file_access_compressed.h
index 2fe1428752..ba84c9767c 100644
--- a/core/io/file_access_compressed.h
+++ b/core/io/file_access_compressed.h
@@ -37,11 +37,11 @@ class FileAccessCompressed : public FileAccess {
Compression::Mode cmode;
bool writing;
- int write_pos;
+ uint32_t write_pos;
uint8_t *write_ptr;
- int write_buffer_size;
- int write_max;
- int block_size;
+ uint32_t write_buffer_size;
+ uint32_t write_max;
+ uint32_t block_size;
mutable bool read_eof;
mutable bool at_end;
@@ -57,7 +57,7 @@ class FileAccessCompressed : public FileAccess {
mutable int read_block_size;
mutable int read_pos;
Vector<ReadBlock> read_blocks;
- int read_total;
+ uint32_t read_total;
String magic;
mutable Vector<uint8_t> buffer;
diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp
index cf82d04ac5..12503f3be4 100644
--- a/core/io/file_access_encrypted.cpp
+++ b/core/io/file_access_encrypted.cpp
@@ -73,14 +73,14 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8
length = p_base->get_64();
base = p_base->get_pos();
ERR_FAIL_COND_V(p_base->get_len() < base + length, ERR_FILE_CORRUPT);
- int ds = length;
+ uint32_t ds = length;
if (ds % 16) {
ds += 16 - (ds % 16);
}
data.resize(ds);
- int blen = p_base->get_buffer(data.ptr(), ds);
+ uint32_t blen = p_base->get_buffer(data.ptr(), ds);
ERR_FAIL_COND_V(blen != ds, ERR_FILE_CORRUPT);
aes256_context ctx;
diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h
index 3df2806a7a..74d00a5a8f 100644
--- a/core/io/file_access_encrypted.h
+++ b/core/io/file_access_encrypted.h
@@ -48,7 +48,7 @@ private:
size_t base;
size_t length;
Vector<uint8_t> data;
- mutable size_t pos;
+ mutable int pos;
mutable bool eofed;
public:
diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp
index be31076557..d8b8c8c200 100644
--- a/core/io/file_access_network.cpp
+++ b/core/io/file_access_network.cpp
@@ -244,14 +244,14 @@ FileAccessNetworkClient::~FileAccessNetworkClient() {
memdelete(sem);
}
-void FileAccessNetwork::_set_block(size_t p_offset, const Vector<uint8_t> &p_block) {
+void FileAccessNetwork::_set_block(int p_offset, const Vector<uint8_t> &p_block) {
int page = p_offset / page_size;
ERR_FAIL_INDEX(page, pages.size());
if (page < pages.size() - 1) {
ERR_FAIL_COND(p_block.size() != page_size);
} else {
- ERR_FAIL_COND((p_block.size() != (total_size % page_size)));
+ ERR_FAIL_COND((p_block.size() != (int)(total_size % page_size)));
}
buffer_mutex->lock();
diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h
index d6010cdbac..cd5046f007 100644
--- a/core/io/file_access_network.h
+++ b/core/io/file_access_network.h
@@ -97,7 +97,7 @@ class FileAccessNetwork : public FileAccess {
mutable int last_page;
mutable uint8_t *last_page_buff;
- uint32_t page_size;
+ int page_size;
int read_ahead;
int max_pages;
@@ -121,7 +121,7 @@ class FileAccessNetwork : public FileAccess {
friend class FileAccessNetworkClient;
void _queue_page(int p_page) const;
void _respond(size_t p_len, Error p_status);
- void _set_block(size_t p_offset, const Vector<uint8_t> &p_block);
+ void _set_block(int p_offset, const Vector<uint8_t> &p_block);
public:
enum Command {
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index af7db904e9..0834d6c321 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -333,14 +333,14 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
len -= 12;
buf += 12;
- int total = namecount + subnamecount;
+ uint32_t total = namecount + subnamecount;
if (flags & 2)
total++;
if (r_len)
(*r_len) += 12;
- for (int i = 0; i < total; i++) {
+ for (uint32_t i = 0; i < total; i++) {
ERR_FAIL_COND_V((int)len < 4, ERR_INVALID_DATA);
strlen = decode_uint32(buf);
@@ -566,7 +566,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (count) {
data.resize(count);
PoolVector<uint8_t>::Write w = data.write();
- for (int i = 0; i < count; i++) {
+ for (uint32_t i = 0; i < count; i++) {
w[i] = buf[i];
}
@@ -597,7 +597,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
//const int*rbuf=(const int*)buf;
data.resize(count);
PoolVector<int>::Write w = data.write();
- for (int i = 0; i < count; i++) {
+ for (uint32_t i = 0; i < count; i++) {
w[i] = decode_uint32(&buf[i * 4]);
}
@@ -624,7 +624,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
//const float*rbuf=(const float*)buf;
data.resize(count);
PoolVector<float>::Write w = data.write();
- for (int i = 0; i < count; i++) {
+ for (uint32_t i = 0; i < count; i++) {
w[i] = decode_float(&buf[i * 4]);
}
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 965d11e414..084d8ffcab 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -102,7 +102,7 @@ StringName ResourceInteractiveLoaderBinary::_get_string() {
uint32_t id = f->get_32();
if (id & 0x80000000) {
- uint32_t len = id & 0x7FFFFFFF;
+ int len = id & 0x7FFFFFFF;
if (len > str_buf.size()) {
str_buf.resize(len);
}
@@ -336,9 +336,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
} break;
case OBJECT_EXTERNAL_RESOURCE_INDEX: {
//new file format, just refers to an index in the external list
- uint32_t erindex = f->get_32();
+ int erindex = f->get_32();
- if (erindex >= external_resources.size()) {
+ if (erindex < 0 || erindex >= external_resources.size()) {
WARN_PRINT("Broken external resource! (index out of size");
r_v = Variant();
} else {
@@ -878,7 +878,7 @@ void ResourceInteractiveLoaderBinary::open(FileAccess *p_f) {
if (ver_format > FORMAT_VERSION || ver_major > VERSION_MAJOR) {
f->close();
- ERR_EXPLAIN("File Format '" + itos(FORMAT_VERSION) + "." + itos(ver_major) + "." + itos(ver_minor) + "' is too new! Please upgrade to a a new engine version: " + local_path);
+ ERR_EXPLAIN("File Format '" + itos(FORMAT_VERSION) + "." + itos(ver_major) + "." + itos(ver_minor) + "' is too new! Please upgrade to a new engine version: " + local_path);
ERR_FAIL();
}
@@ -1005,7 +1005,7 @@ ResourceInteractiveLoaderBinary::~ResourceInteractiveLoaderBinary() {
memdelete(f);
}
-Ref<ResourceInteractiveLoader> ResourceFormatLoaderBinary::load_interactive(const String &p_path, Error *r_error) {
+Ref<ResourceInteractiveLoader> ResourceFormatLoaderBinary::load_interactive(const String &p_path, const String &p_original_path, Error *r_error) {
if (r_error)
*r_error = ERR_FILE_CANT_OPEN;
@@ -1019,7 +1019,8 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderBinary::load_interactive(cons
}
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
- ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
+ String path = p_original_path != "" ? p_original_path : p_path;
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(path);
ria->res_path = ria->local_path;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
ria->open(f);
@@ -1116,6 +1117,9 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
memdelete(f);
}
ERR_FAIL_COND_V(!fw, ERR_CANT_CREATE);
+
+ uint8_t magic[4] = { 'R', 'S', 'R', 'C' };
+ fw->store_buffer(magic, 4);
}
bool big_endian = f->get_32();
@@ -1177,7 +1181,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
memdelete(f);
memdelete(fw);
- ERR_EXPLAIN("File Format '" + itos(FORMAT_VERSION) + "." + itos(ver_major) + "." + itos(ver_minor) + "' is too new! Please upgrade to a a new engine version: " + local_path);
+ ERR_EXPLAIN("File Format '" + itos(FORMAT_VERSION) + "." + itos(ver_major) + "." + itos(ver_minor) + "' is too new! Please upgrade to a new engine version: " + local_path);
ERR_FAIL_V(ERR_FILE_UNRECOGNIZED);
}
diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h
index 1bd0d333c6..ab77c2c9d3 100644
--- a/core/io/resource_format_binary.h
+++ b/core/io/resource_format_binary.h
@@ -101,7 +101,7 @@ public:
class ResourceFormatLoaderBinary : public ResourceFormatLoader {
public:
- virtual Ref<ResourceInteractiveLoader> load_interactive(const String &p_path, Error *r_error = NULL);
+ virtual Ref<ResourceInteractiveLoader> load_interactive(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const;
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp
index 69ff791a3a..be486a86a3 100644
--- a/core/io/resource_import.cpp
+++ b/core/io/resource_import.cpp
@@ -119,7 +119,7 @@ RES ResourceFormatImporter::load(const String &p_path, const String &p_original_
return RES();
}
- RES res = ResourceLoader::load(pat.path, pat.type, false, r_error);
+ RES res = ResourceLoader::_load(pat.path, p_path, pat.type, false, r_error);
#ifdef TOOLS_ENABLED
if (res.is_valid()) {
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 30ae9f5681..4f266df43e 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -109,10 +109,10 @@ public:
ResourceInteractiveLoaderDefault() {}
};
-Ref<ResourceInteractiveLoader> ResourceFormatLoader::load_interactive(const String &p_path, Error *r_error) {
+Ref<ResourceInteractiveLoader> ResourceFormatLoader::load_interactive(const String &p_path, const String &p_original_path, Error *r_error) {
//either this
- Ref<Resource> res = load(p_path, p_path, r_error);
+ Ref<Resource> res = load(p_path, p_original_path, r_error);
if (res.is_null())
return Ref<ResourceInteractiveLoader>();
@@ -126,7 +126,7 @@ RES ResourceFormatLoader::load(const String &p_path, const String &p_original_pa
String path = p_path;
//or this must be implemented
- Ref<ResourceInteractiveLoader> ril = load_interactive(p_path, r_error);
+ Ref<ResourceInteractiveLoader> ril = load_interactive(p_path, p_original_path, r_error);
if (!ril.is_valid())
return RES();
ril->set_local_path(p_original_path);
@@ -157,6 +157,34 @@ void ResourceFormatLoader::get_dependencies(const String &p_path, List<String> *
///////////////////////////////////
+RES ResourceLoader::_load(const String &p_path, const String &p_original_path, const String &p_type_hint, bool p_no_cache, Error *r_error) {
+
+ bool found = false;
+
+ // Try all loaders and pick the first match for the type hint
+ for (int i = 0; i < loader_count; i++) {
+
+ if (!loader[i]->recognize_path(p_path, p_type_hint)) {
+ continue;
+ }
+ found = true;
+ RES res = loader[i]->load(p_path, p_original_path != String() ? p_original_path : p_path, r_error);
+ if (res.is_null()) {
+ continue;
+ }
+
+ return res;
+ }
+
+ if (found) {
+ ERR_EXPLAIN("Failed loading resource: " + p_path);
+ } else {
+ ERR_EXPLAIN("No loader found for resource: " + p_path);
+ }
+ ERR_FAIL_V(RES());
+ return RES();
+}
+
RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p_no_cache, Error *r_error) {
if (r_error)
@@ -183,45 +211,29 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
if (OS::get_singleton()->is_stdout_verbose())
print_line("load resource: " + path);
- bool found = false;
- // Try all loaders and pick the first match for the type hint
- for (int i = 0; i < loader_count; i++) {
+ RES res = _load(path, local_path, p_type_hint, p_no_cache, r_error);
- if (!loader[i]->recognize_path(path, p_type_hint)) {
- continue;
- }
- found = true;
- RES res = loader[i]->load(path, path, r_error);
- if (res.is_null()) {
- continue;
- }
- if (!p_no_cache)
- res->set_path(local_path);
+ if (res.is_null()) {
+ return RES();
+ }
+ if (!p_no_cache)
+ res->set_path(local_path);
- if (xl_remapped)
- res->set_as_translation_remapped(true);
+ if (xl_remapped)
+ res->set_as_translation_remapped(true);
#ifdef TOOLS_ENABLED
- res->set_edited(false);
- if (timestamp_on_load) {
- uint64_t mt = FileAccess::get_modified_time(path);
- //printf("mt %s: %lli\n",remapped_path.utf8().get_data(),mt);
- res->set_last_modified_time(mt);
- }
-#endif
-
- return res;
+ res->set_edited(false);
+ if (timestamp_on_load) {
+ uint64_t mt = FileAccess::get_modified_time(path);
+ //printf("mt %s: %lli\n",remapped_path.utf8().get_data(),mt);
+ res->set_last_modified_time(mt);
}
+#endif
- if (found) {
- ERR_EXPLAIN("Failed loading resource: " + path);
- } else {
- ERR_EXPLAIN("No loader found for resource: " + path);
- }
- ERR_FAIL_V(RES());
- return RES();
+ return res;
}
Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_path, const String &p_type_hint, bool p_no_cache, Error *r_error) {
@@ -262,7 +274,7 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
if (!loader[i]->recognize_path(path, p_type_hint))
continue;
found = true;
- Ref<ResourceInteractiveLoader> ril = loader[i]->load_interactive(path, r_error);
+ Ref<ResourceInteractiveLoader> ril = loader[i]->load_interactive(path, local_path, r_error);
if (ril.is_null())
continue;
if (!p_no_cache)
diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h
index 91f0c939bf..a71a568569 100644
--- a/core/io/resource_loader.h
+++ b/core/io/resource_loader.h
@@ -57,7 +57,7 @@ public:
class ResourceFormatLoader {
public:
- virtual Ref<ResourceInteractiveLoader> load_interactive(const String &p_path, Error *r_error = NULL);
+ virtual Ref<ResourceInteractiveLoader> load_interactive(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const = 0;
virtual void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const;
@@ -96,6 +96,10 @@ class ResourceLoader {
static SelfList<Resource>::List remapped_list;
+ friend class ResourceFormatImporter;
+ //internal load function
+ static RES _load(const String &p_path, const String &p_original_path, const String &p_type_hint, bool p_no_cache, Error *r_error);
+
public:
static Ref<ResourceInteractiveLoader> load_interactive(const String &p_path, const String &p_type_hint = "", bool p_no_cache = false, Error *r_error = NULL);
static RES load(const String &p_path, const String &p_type_hint = "", bool p_no_cache = false, Error *r_error = NULL);
diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp
index 353eabea45..92af247823 100644
--- a/core/io/translation_loader_po.cpp
+++ b/core/io/translation_loader_po.cpp
@@ -51,8 +51,8 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S
Ref<Translation> translation = Ref<Translation>(memnew(Translation));
int line = 1;
- bool skip_this;
- bool skip_next;
+ bool skip_this = false;
+ bool skip_next = false;
while (true) {
diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp
index 62110bfe24..3a4be7cd13 100644
--- a/core/io/xml_parser.cpp
+++ b/core/io/xml_parser.cpp
@@ -385,7 +385,7 @@ void XMLParser::_bind_methods() {
Error XMLParser::read() {
// if not end reached, parse the node
- if (P && (P - data) < length - 1 && *P != 0) {
+ if (P && (P - data) < (int64_t)length - 1 && *P != 0) {
_parse_current_node();
return OK;
}
diff --git a/core/io/xml_parser.h b/core/io/xml_parser.h
index 28c57b567f..26616ed94a 100644
--- a/core/io/xml_parser.h
+++ b/core/io/xml_parser.h
@@ -67,7 +67,7 @@ public:
private:
char *data;
char *P;
- int length;
+ uint64_t length;
void unescape(String &p_str);
Vector<String> special_characters;
String node_name;
diff --git a/core/list.h b/core/list.h
index 0cad6038ff..a67287a9ab 100644
--- a/core/list.h
+++ b/core/list.h
@@ -180,7 +180,7 @@ private:
public:
/**
- * return an const iterator to the beginning of the list.
+ * return a const iterator to the beginning of the list.
*/
_FORCE_INLINE_ const Element *front() const {
@@ -195,7 +195,7 @@ public:
};
/**
- * return an const iterator to the last member of the list.
+ * return a const iterator to the last member of the list.
*/
_FORCE_INLINE_ const Element *back() const {
diff --git a/core/math/a_star.h b/core/math/a_star.h
index d2d2166719..75b860d0a4 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* a_star.h */
+/* a_star.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
diff --git a/core/math/face3.cpp b/core/math/face3.cpp
index 748faad28f..e1b172e491 100644
--- a/core/math/face3.cpp
+++ b/core/math/face3.cpp
@@ -296,7 +296,7 @@ void Face3::get_support(const Vector3 &p_normal, const Transform &p_transform, V
/** FIND SUPPORT VERTEX **/
int vert_support_idx = -1;
- real_t support_max;
+ real_t support_max = 0;
for (int i = 0; i < 3; i++) {
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index e9a383df40..e0137b6921 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -76,7 +76,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
int simplex[4];
{
- real_t max, min;
+ real_t max = 0, min = 0;
for (int i = 0; i < p_points.size(); i++) {
@@ -99,7 +99,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
//third vertex is one most further away from the line
{
- real_t maxd;
+ real_t maxd = 0;
Vector3 rel12 = p_points[simplex[0]] - p_points[simplex[1]];
for (int i = 0; i < p_points.size(); i++) {
@@ -121,7 +121,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
//fourth vertex is the one most further away from the plane
{
- real_t maxd;
+ real_t maxd = 0;
Plane p(p_points[simplex[0]], p_points[simplex[1]], p_points[simplex[2]]);
for (int i = 0; i < p_points.size(); i++) {
@@ -389,8 +389,8 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
for (int i = 0; i < f.indices.size(); i++) {
- uint32_t a = E->get().indices[i];
- uint32_t b = E->get().indices[(i + 1) % f.indices.size()];
+ int a = E->get().indices[i];
+ int b = E->get().indices[(i + 1) % f.indices.size()];
Edge e(a, b);
Map<Edge, RetFaceConnect>::Element *F = ret_edges.find(e);
diff --git a/core/method_bind.h b/core/method_bind.h
index 75f09b2cd9..3c43f86b54 100644
--- a/core/method_bind.h
+++ b/core/method_bind.h
@@ -369,7 +369,7 @@ MethodBind *create_vararg_method_bind(Variant (T::*p_method)(const Variant **, i
// tale of an amazing hack.. //
-// if you declare an nonexistent class..
+// if you declare a nonexistent class..
class __UnexistingClass;
#include "method_bind.gen.inc"
diff --git a/core/ordered_hash_map.h b/core/ordered_hash_map.h
new file mode 100644
index 0000000000..3e619d2b2e
--- /dev/null
+++ b/core/ordered_hash_map.h
@@ -0,0 +1,315 @@
+/*************************************************************************/
+/* ordered_hash_map.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef ORDERED_HASH_MAP_H
+#define ORDERED_HASH_MAP_H
+
+#include "hash_map.h"
+#include "list.h"
+#include "pair.h"
+
+/**
+ * A hash map which allows to iterate elements in insertion order.
+ * Insertion, lookup, deletion have O(1) complexity.
+ * The API aims to be consistent with Map rather than HashMap, because the
+ * former is more frequently used and is more coherent with the rest of the
+ * codebase.
+ * Deletion during iteration is safe and will preserve the order.
+ */
+template <class K, class V, class Hasher = HashMapHasherDefault, class Comparator = HashMapComparatorDefault<K>, uint8_t MIN_HASH_TABLE_POWER = 3, uint8_t RELATIONSHIP = 8>
+class OrderedHashMap {
+ typedef List<Pair<const K *, V> > InternalList;
+ typedef HashMap<K, typename InternalList::Element *, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP> InternalMap;
+
+ InternalList list;
+ InternalMap map;
+
+public:
+ class Element {
+ friend class OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>;
+
+ typename InternalList::Element *list_element;
+ typename InternalList::Element *next_element;
+ typename InternalList::Element *prev_element;
+
+ Element(typename InternalList::Element *p_element) {
+ list_element = p_element;
+
+ if (list_element) {
+ next_element = list_element->next();
+ prev_element = list_element->prev();
+ }
+ }
+
+ public:
+ _FORCE_INLINE_ Element()
+ : list_element(NULL), next_element(NULL), prev_element(NULL) {
+ }
+
+ Element next() const {
+ return Element(next_element);
+ }
+
+ Element prev() const {
+ return Element(prev_element);
+ }
+
+ Element(const Element &other)
+ : list_element(other.list_element),
+ prev_element(other.prev_element),
+ next_element(other.next_element) {
+ }
+
+ Element &operator=(const Element &other) {
+ list_element = other.list_element;
+ next_element = other.next_element;
+ prev_element = other.prev_element;
+ return *this;
+ }
+
+ friend bool operator==(const Element &, const Element &);
+ friend bool operator!=(const Element &, const Element &);
+
+ operator bool() const {
+ return (list_element != NULL);
+ }
+
+ const K &key() const {
+ CRASH_COND(!list_element);
+ return *(list_element->get().first);
+ };
+
+ V &value() {
+ CRASH_COND(!list_element);
+ return list_element->get().second;
+ };
+
+ const V &value() const {
+ CRASH_COND(!list_element);
+ return list_element->get().second;
+ };
+
+ V &get() {
+ CRASH_COND(!list_element);
+ return list_element->get().second;
+ };
+
+ const V &get() const {
+ CRASH_COND(!list_element);
+ return list_element->get().second;
+ };
+ };
+
+ class ConstElement {
+ friend class OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>;
+
+ const typename InternalList::Element *list_element;
+
+ ConstElement(const typename InternalList::Element *p_element)
+ : list_element(p_element) {
+ }
+
+ public:
+ _FORCE_INLINE_ ConstElement()
+ : list_element(NULL) {
+ }
+
+ ConstElement(const ConstElement &other)
+ : list_element(other.list_element) {
+ }
+
+ ConstElement &operator=(const ConstElement &other) {
+ list_element = other.list_element;
+ return *this;
+ }
+
+ ConstElement next() const {
+ return ConstElement(list_element ? list_element->next() : NULL);
+ }
+
+ ConstElement prev() const {
+ return ConstElement(list_element ? list_element->prev() : NULL);
+ }
+
+ friend bool operator==(const ConstElement &, const ConstElement &);
+ friend bool operator!=(const ConstElement &, const ConstElement &);
+
+ operator bool() const {
+ return (list_element != NULL);
+ }
+
+ const K &key() const {
+ CRASH_COND(!list_element);
+ return *(list_element->get().first);
+ };
+
+ const V &value() const {
+ CRASH_COND(!list_element);
+ return list_element->get().second;
+ };
+
+ const V &get() const {
+ CRASH_COND(!list_element);
+ return list_element->get().second;
+ };
+ };
+
+ ConstElement find(const K &p_key) const {
+ typename InternalList::Element **list_element = map.getptr(p_key);
+ if (list_element) {
+ return ConstElement(*list_element);
+ }
+ return ConstElement(NULL);
+ }
+
+ Element find(const K &p_key) {
+ typename InternalList::Element **list_element = map.getptr(p_key);
+ if (list_element) {
+ return Element(*list_element);
+ }
+ return Element(NULL);
+ }
+
+ Element insert(const K &p_key, const V &p_value) {
+ typename InternalList::Element **list_element = map.getptr(p_key);
+ if (list_element) {
+ (*list_element)->get().second = p_value;
+ return Element(*list_element);
+ }
+ typename InternalList::Element *new_element = list.push_back(Pair<const K *, V>(NULL, p_value));
+ typename InternalMap::Element *e = map.set(p_key, new_element);
+ new_element->get().first = &e->key();
+
+ return Element(new_element);
+ }
+
+ void erase(Element &p_element) {
+ map.erase(p_element.key());
+ list.erase(p_element.list_element);
+ p_element.list_element = NULL;
+ }
+
+ bool erase(const K &p_key) {
+ typename InternalList::Element **list_element = map.getptr(p_key);
+ if (list_element) {
+ list.erase(*list_element);
+ map.erase(p_key);
+ return true;
+ }
+ return false;
+ }
+
+ inline bool has(const K &p_key) const {
+ return map.has(p_key);
+ }
+
+ const V &operator[](const K &p_key) const {
+ ConstElement e = find(p_key);
+ CRASH_COND(!e);
+ return e.value();
+ }
+
+ V &operator[](const K &p_key) {
+ Element e = find(p_key);
+ if (!e) {
+ // consistent with Map behaviour
+ e = insert(p_key, V());
+ }
+ return e.value();
+ }
+
+ inline Element front() {
+ return Element(list.front());
+ }
+
+ inline Element back() {
+ return Element(list.back());
+ }
+
+ inline ConstElement front() const {
+ return ConstElement(list.front());
+ }
+
+ inline ConstElement back() const {
+ return ConstElement(list.back());
+ }
+
+ inline bool empty() const { return list.empty(); }
+ inline int size() const { return list.size(); }
+
+ void clear() {
+ map.clear();
+ list.clear();
+ }
+
+private:
+ void _copy_from(const OrderedHashMap &p_map) {
+ for (ConstElement E = p_map.front(); E; E = E.next()) {
+ insert(E.key(), E.value());
+ }
+ }
+
+public:
+ void operator=(const OrderedHashMap &p_map) {
+ _copy_from(p_map);
+ }
+
+ OrderedHashMap(const OrderedHashMap &p_map) {
+ _copy_from(p_map);
+ }
+
+ _FORCE_INLINE_ OrderedHashMap() {
+ }
+};
+
+template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP>
+bool operator==(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &first,
+ const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &second) {
+ return (first.list_element == second.list_element);
+}
+
+template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP>
+bool operator!=(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &first,
+ const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &second) {
+ return (first.list_element != second.list_element);
+}
+
+template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP>
+bool operator==(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &first,
+ const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &second) {
+ return (first.list_element == second.list_element);
+}
+
+template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP>
+bool operator!=(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &first,
+ const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &second) {
+ return (first.list_element != second.list_element);
+}
+
+#endif // ORDERED_HASH_MAP_H \ No newline at end of file
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 1292b7eeed..764f7fe6e6 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -64,12 +64,13 @@ void OS::debug_break(){
void OS::print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type) {
- const char *err_type;
+ const char *err_type = "**ERROR**";
switch (p_type) {
case ERR_ERROR: err_type = "**ERROR**"; break;
case ERR_WARNING: err_type = "**WARNING**"; break;
case ERR_SCRIPT: err_type = "**SCRIPT ERROR**"; break;
case ERR_SHADER: err_type = "**SHADER ERROR**"; break;
+ default: ERR_PRINT("Unknown error type"); break;
}
if (p_rationale && *p_rationale)
diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp
index 4040680c6d..ad8438e416 100644
--- a/core/packed_data_container.cpp
+++ b/core/packed_data_container.cpp
@@ -61,7 +61,7 @@ Variant PackedDataContainer::_iter_init_ofs(const Array &p_iter, uint32_t p_offs
Variant PackedDataContainer::_iter_next_ofs(const Array &p_iter, uint32_t p_offset) {
Array ref = p_iter;
- uint32_t size = _size(p_offset);
+ int size = _size(p_offset);
if (ref.size() != 1)
return false;
int pos = ref[0];
@@ -74,7 +74,7 @@ Variant PackedDataContainer::_iter_next_ofs(const Array &p_iter, uint32_t p_offs
Variant PackedDataContainer::_iter_get_ofs(const Variant &p_iter, uint32_t p_offset) {
- uint32_t size = _size(p_offset);
+ int size = _size(p_offset);
int pos = p_iter;
if (pos < 0 || pos >= size)
return Variant();
@@ -164,7 +164,7 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b
if (p_key.is_num()) {
int idx = p_key;
- uint32_t len = decode_uint32(r + 4);
+ int len = decode_uint32(r + 4);
if (idx < 0 || idx >= len) {
err = true;
return Variant();
@@ -183,7 +183,7 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b
uint32_t len = decode_uint32(r + 4);
bool found = false;
- for (int i = 0; i < len; i++) {
+ for (uint32_t i = 0; i < len; i++) {
uint32_t khash = decode_uint32(r + 8 + i * 12 + 0);
if (khash == hash) {
Variant key = _get_at_ofs(decode_uint32(r + 8 + i * 12 + 4), rd.ptr(), err);
diff --git a/core/pair.h b/core/pair.h
index f780c79c81..535c3355b6 100644
--- a/core/pair.h
+++ b/core/pair.h
@@ -44,6 +44,16 @@ struct Pair {
};
template <class F, class S>
+bool operator==(const Pair<F, S> &pair, const Pair<F, S> &other) {
+ return (pair.first == other.first) && (pair.second == other.second);
+}
+
+template <class F, class S>
+bool operator!=(const Pair<F, S> &pair, const Pair<F, S> &other) {
+ return (pair.first != other.first) || (pair.second != other.second);
+}
+
+template <class F, class S>
struct PairSort {
bool operator()(const Pair<F, S> &A, const Pair<F, S> &B) const {
diff --git a/core/pool_allocator.cpp b/core/pool_allocator.cpp
index c122d21545..c5f6d0dde0 100644
--- a/core/pool_allocator.cpp
+++ b/core/pool_allocator.cpp
@@ -339,9 +339,9 @@ Error PoolAllocator::resize(ID p_mem, int p_new_size) {
ERR_FAIL_COND_V(e->lock, ERR_ALREADY_IN_USE);
}
- int alloc_size = aligned(p_new_size);
+ uint32_t alloc_size = aligned(p_new_size);
- if (aligned(e->len) == alloc_size) {
+ if ((uint32_t)aligned(e->len) == alloc_size) {
e->len = p_new_size;
mt_unlock();
@@ -374,7 +374,7 @@ Error PoolAllocator::resize(ID p_mem, int p_new_size) {
}
//no need to move stuff around, it fits before the next block
- int next_pos;
+ uint32_t next_pos;
if (entry_indices_pos + 1 == entry_count) {
next_pos = pool_size; // - static_area_size;
} else {
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index ce1d7918db..a74917162b 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* globals.cpp */
+/* project_settings.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
diff --git a/core/project_settings.h b/core/project_settings.h
index 5c8907c74e..718ab2a011 100644
--- a/core/project_settings.h
+++ b/core/project_settings.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* globals.h */
+/* project_settings.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
diff --git a/core/reference.h b/core/reference.h
index 5fe8296314..ca3ae60418 100644
--- a/core/reference.h
+++ b/core/reference.h
@@ -62,7 +62,7 @@ public:
template <class T>
class Ref {
- T *reference;
+ T *reference = NULL;
void ref(const Ref &p_from) {
diff --git a/core/script_language.cpp b/core/script_language.cpp
index f2be15897e..bde80a30bc 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -55,7 +55,6 @@ void Script::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_source_code", "source"), &Script::set_source_code);
ClassDB::bind_method(D_METHOD("reload", "keep_state"), &Script::reload, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("has_method", "method_name"), &Script::has_method);
ClassDB::bind_method(D_METHOD("has_script_signal", "signal_name"), &Script::has_script_signal);
ClassDB::bind_method(D_METHOD("is_tool"), &Script::is_tool);
diff --git a/core/ustring.cpp b/core/ustring.cpp
index ee07c7b11b..8273ed144b 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -588,7 +588,7 @@ String String::camelcase_to_underscore(bool lowercase) const {
const char a = 'a', z = 'z';
int start_index = 0;
- for (size_t i = 1; i < this->size(); i++) {
+ for (int i = 1; i < this->size(); i++) {
bool is_upper = cstr[i] >= A && cstr[i] <= Z;
bool is_number = cstr[i] >= '0' && cstr[i] <= '9';
bool are_next_2_lower = false;
@@ -3655,12 +3655,12 @@ String String::sprintf(const Array &values, bool *error) const {
CharType *self = (CharType *)c_str();
bool in_format = false;
int value_index = 0;
- int min_chars;
- int min_decimals;
- bool in_decimals;
- bool pad_with_zeroes;
- bool left_justified;
- bool show_sign;
+ int min_chars = 0;
+ int min_decimals = 0;
+ bool in_decimals = false;
+ bool pad_with_zeroes = false;
+ bool left_justified = false;
+ bool show_sign = false;
*error = true;
@@ -3687,12 +3687,12 @@ String String::sprintf(const Array &values, bool *error) const {
}
int64_t value = values[value_index];
- int base;
+ int base = 16;
bool capitalize = false;
switch (c) {
case 'd': base = 10; break;
case 'o': base = 8; break;
- case 'x': base = 16; break;
+ case 'x': break;
case 'X':
base = 16;
capitalize = true;
@@ -3842,7 +3842,7 @@ String String::sprintf(const Array &values, bool *error) const {
}
break;
}
- case '.': { // Float separtor.
+ case '.': { // Float separator.
if (in_decimals) {
return "too many decimal points in format";
}
@@ -3851,7 +3851,7 @@ String String::sprintf(const Array &values, bool *error) const {
break;
}
- case '*': { // Dyanmic width, based on value.
+ case '*': { // Dynamic width, based on value.
if (value_index >= values.size()) {
return "not enough arguments for format string";
}
diff --git a/core/vmap.h b/core/vmap.h
index f0977341ec..8165a919b6 100644
--- a/core/vmap.h
+++ b/core/vmap.h
@@ -60,9 +60,13 @@ class VMap {
int low = 0;
int high = _data.size() - 1;
- int middle;
const _Pair *a = &_data[0];
+ int middle = 0;
+#if DEBUG_ENABLED
+ if (low > high)
+ ERR_PRINT("low > high, this may be a bug");
+#endif
while (low <= high) {
middle = (low + high) / 2;
diff --git a/core/vset.h b/core/vset.h
index 7b12ae0b25..67af6c1a4c 100644
--- a/core/vset.h
+++ b/core/vset.h
@@ -46,8 +46,13 @@ class VSet {
int low = 0;
int high = _data.size() - 1;
- int middle;
const T *a = &_data[0];
+ int middle = 0;
+
+#if DEBUG_ENABLED
+ if (low > high)
+ ERR_PRINT("low > high, this may be a bug");
+#endif
while (low <= high) {
middle = (low + high) / 2;