summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqarmin <mikrutrafal54@gmail.com>2019-07-01 12:59:42 +0200
committerqarmin <mikrutrafal54@gmail.com>2019-07-01 12:59:42 +0200
commit3c154eb93b3a098354bf6d18a9428826ec193f90 (patch)
treed9c8c44f13883ceadaefc95953f9cb077137b7c8
parenteaaff9da3178fa515a0f051fda932c1dd04d53db (diff)
Remove unnecessary code and add some error explanations
-rw-r--r--core/array.cpp18
-rw-r--r--core/bind/core_bind.cpp12
-rw-r--r--core/class_db.cpp4
-rw-r--r--core/color.cpp3
-rw-r--r--core/command_queue_mt.h2
-rw-r--r--core/engine.cpp6
-rw-r--r--core/hash_map.h11
-rw-r--r--core/image.cpp7
-rw-r--r--core/io/file_access_buffered.cpp64
-rw-r--r--core/io/file_access_buffered_fa.h5
-rw-r--r--core/io/http_client.cpp2
-rw-r--r--core/io/json.cpp2
-rw-r--r--core/io/pck_packer.cpp7
-rw-r--r--core/io/resource_importer.cpp5
-rw-r--r--core/io/resource_loader.cpp4
-rw-r--r--core/math/bsp_tree.cpp6
-rw-r--r--core/math/camera_matrix.cpp60
-rw-r--r--core/math/math_funcs.cpp2
-rw-r--r--core/math/random_number_generator.h2
-rw-r--r--core/object.cpp6
-rw-r--r--core/os/dir_access.cpp4
-rw-r--r--core/os/memory.h2
-rw-r--r--core/project_settings.cpp2
-rw-r--r--core/ustring.cpp6
-rw-r--r--core/variant.cpp20
-rw-r--r--core/variant_op.cpp3
-rw-r--r--core/variant_parser.cpp14
-rw-r--r--drivers/unix/net_socket_posix.cpp8
-rw-r--r--editor/animation_bezier_editor.cpp4
-rw-r--r--editor/animation_track_editor_plugins.cpp2
-rw-r--r--editor/create_dialog.cpp3
-rw-r--r--editor/editor_plugin.cpp2
-rw-r--r--editor/groups_editor.cpp2
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.h2
-rw-r--r--editor/plugins/curve_editor_plugin.cpp2
-rw-r--r--editor/plugins/path_2d_editor_plugin.h2
-rw-r--r--editor/plugins/script_editor_plugin.cpp2
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp7
-rw-r--r--editor/project_settings_editor.cpp4
-rw-r--r--editor/scene_tree_dock.cpp1
-rw-r--r--editor/spatial_editor_gizmos.cpp4
-rw-r--r--modules/gdscript/gdscript.cpp2
-rw-r--r--modules/gdscript/gdscript_compiler.cpp2
-rw-r--r--modules/mono/csharp_script.cpp2
-rw-r--r--scene/2d/navigation_2d.cpp1
-rw-r--r--scene/3d/audio_stream_player_3d.h2
-rw-r--r--scene/3d/navigation.cpp1
-rw-r--r--scene/gui/option_button.cpp2
48 files changed, 149 insertions, 187 deletions
diff --git a/core/array.cpp b/core/array.cpp
index 65934d6ec9..a334af2c04 100644
--- a/core/array.cpp
+++ b/core/array.cpp
@@ -133,12 +133,18 @@ void Array::erase(const Variant &p_value) {
}
Variant Array::front() const {
- ERR_FAIL_COND_V(_p->array.size() == 0, Variant());
+ if (_p->array.size() == 0) {
+ ERR_EXPLAIN("Can't take value from empty array");
+ ERR_FAIL_V(Variant());
+ }
return operator[](0);
}
Variant Array::back() const {
- ERR_FAIL_COND_V(_p->array.size() == 0, Variant());
+ if (_p->array.size() == 0) {
+ ERR_EXPLAIN("Can't take value from empty array");
+ ERR_FAIL_V(Variant());
+ }
return operator[](_p->array.size() - 1);
}
@@ -165,8 +171,8 @@ int Array::rfind(const Variant &p_value, int p_from) const {
if (_p->array[i] == p_value) {
return i;
- };
- };
+ }
+ }
return -1;
}
@@ -186,8 +192,8 @@ int Array::count(const Variant &p_value) const {
if (_p->array[i] == p_value) {
amount++;
- };
- };
+ }
+ }
return amount;
}
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 44573a0d97..76d351a470 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -149,8 +149,10 @@ _ResourceLoader::_ResourceLoader() {
}
Error _ResourceSaver::save(const String &p_path, const RES &p_resource, SaverFlags p_flags) {
-
- ERR_FAIL_COND_V(p_resource.is_null(), ERR_INVALID_PARAMETER);
+ if (p_resource.is_null()) {
+ ERR_EXPLAIN("Can't save empty resource to path: " + String(p_path))
+ ERR_FAIL_V(ERR_INVALID_PARAMETER);
+ }
return ResourceSaver::save(p_path, p_resource, p_flags);
}
@@ -246,11 +248,11 @@ PoolStringArray _OS::get_connected_midi_inputs() {
}
void _OS::open_midi_inputs() {
- return OS::get_singleton()->open_midi_inputs();
+ OS::get_singleton()->open_midi_inputs();
}
void _OS::close_midi_inputs() {
- return OS::get_singleton()->close_midi_inputs();
+ OS::get_singleton()->close_midi_inputs();
}
void _OS::set_video_mode(const Size2 &p_size, bool p_fullscreen, bool p_resizeable, int p_screen) {
@@ -2246,7 +2248,7 @@ bool _Directory::current_is_dir() const {
void _Directory::list_dir_end() {
ERR_FAIL_COND(!d);
- return d->list_dir_end();
+ d->list_dir_end();
}
int _Directory::get_drive_count() {
diff --git a/core/class_db.cpp b/core/class_db.cpp
index c9527e3c8f..12af4f0c06 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -920,7 +920,7 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
#ifdef DEBUG_METHODS_ENABLED
if (!mb_set) {
ERR_EXPLAIN("Invalid Setter: " + p_class + "::" + p_setter + " for property: " + p_pinfo.name);
- ERR_FAIL_COND(!mb_set);
+ ERR_FAIL();
} else {
int exp_args = 1 + (p_index >= 0 ? 1 : 0);
if (mb_set->get_argument_count() != exp_args) {
@@ -939,7 +939,7 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
if (!mb_get) {
ERR_EXPLAIN("Invalid Getter: " + p_class + "::" + p_getter + " for property: " + p_pinfo.name);
- ERR_FAIL_COND(!mb_get);
+ ERR_FAIL();
} else {
int exp_args = 0 + (p_index >= 0 ? 1 : 0);
diff --git a/core/color.cpp b/core/color.cpp
index 8959fce4e3..1843532124 100644
--- a/core/color.cpp
+++ b/core/color.cpp
@@ -388,9 +388,8 @@ bool Color::html_is_valid(const String &p_color) {
return false;
}
- int a = 255;
if (alpha) {
- a = _parse_col(color, 0);
+ int a = _parse_col(color, 0);
if (a < 0) {
return false;
}
diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h
index 798fa4394d..3789eda5db 100644
--- a/core/command_queue_mt.h
+++ b/core/command_queue_mt.h
@@ -346,7 +346,7 @@ class CommandQueueMT {
}
return NULL;
}
- } else if (write_ptr >= dealloc_ptr) {
+ } else {
// ahead of dealloc_ptr, check that there is room
if ((COMMAND_MEM_SIZE - write_ptr) < alloc_size + sizeof(uint32_t)) {
diff --git a/core/engine.cpp b/core/engine.cpp
index 50822244cf..2d8473fbd9 100644
--- a/core/engine.cpp
+++ b/core/engine.cpp
@@ -197,8 +197,10 @@ void Engine::add_singleton(const Singleton &p_singleton) {
Object *Engine::get_singleton_object(const String &p_name) const {
const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name);
- ERR_EXPLAIN("Failed to retrieve non-existent singleton '" + p_name + "'");
- ERR_FAIL_COND_V(!E, NULL);
+ if (!E) {
+ ERR_EXPLAIN("Failed to retrieve non-existent singleton '" + p_name + "'");
+ ERR_FAIL_V(NULL);
+ }
return E->get();
};
diff --git a/core/hash_map.h b/core/hash_map.h
index 31332991de..1513d7a65b 100644
--- a/core/hash_map.h
+++ b/core/hash_map.h
@@ -208,7 +208,10 @@ private:
/* if element doesn't exist, create it */
Element *e = memnew(Element);
- ERR_FAIL_COND_V(!e, NULL); /* out of memory */
+ if (!e) {
+ ERR_EXPLAIN("Out of memory");
+ ERR_FAIL_V(NULL);
+ }
uint32_t hash = Hasher::hash(p_key);
uint32_t index = hash & ((1 << hash_table_power) - 1);
e->next = hash_table[index];
@@ -495,8 +498,10 @@ public:
} else { /* get the next key */
const Element *e = get_element(*p_key);
- ERR_FAIL_COND_V(!e, NULL); /* invalid key supplied */
-
+ if (!e) {
+ ERR_EXPLAIN("Invalid key supplied")
+ ERR_FAIL_V(NULL);
+ }
if (e->next) {
/* if there is a "next" in the list, return that */
return &e->next->pair.key;
diff --git a/core/image.cpp b/core/image.cpp
index dd8f2b9bac..4da8f27e5f 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -1464,7 +1464,10 @@ Error Image::generate_mipmaps(bool p_renormalize) {
ERR_FAIL_V(ERR_UNAVAILABLE);
}
- ERR_FAIL_COND_V(width == 0 || height == 0, ERR_UNCONFIGURED);
+ if (width == 0 || height == 0) {
+ ERR_EXPLAIN("Cannot generate mipmaps with width or height equal to 0.");
+ ERR_FAIL_V(ERR_UNCONFIGURED);
+ }
int mmcount;
@@ -2532,7 +2535,7 @@ Color Image::get_pixel(int p_x, int p_y) const {
}
void Image::set_pixelv(const Point2 &p_dst, const Color &p_color) {
- return set_pixel(p_dst.x, p_dst.y, p_color);
+ set_pixel(p_dst.x, p_dst.y, p_color);
}
void Image::set_pixel(int p_x, int p_y, const Color &p_color) {
diff --git a/core/io/file_access_buffered.cpp b/core/io/file_access_buffered.cpp
index 93eaeb08c5..15523a49a9 100644
--- a/core/io/file_access_buffered.cpp
+++ b/core/io/file_access_buffered.cpp
@@ -35,79 +35,79 @@
Error FileAccessBuffered::set_error(Error p_error) const {
return (last_error = p_error);
-};
+}
void FileAccessBuffered::set_cache_size(int p_size) {
cache_size = p_size;
-};
+}
int FileAccessBuffered::get_cache_size() {
return cache_size;
-};
+}
int FileAccessBuffered::cache_data_left() const {
if (file.offset >= file.size) {
return 0;
- };
+ }
if (cache.offset == -1 || file.offset < cache.offset || file.offset >= cache.offset + cache.buffer.size()) {
return read_data_block(file.offset, cache_size);
+ }
- } else {
-
- return cache.buffer.size() - (file.offset - cache.offset);
- };
-
- return 0;
-};
+ return cache.buffer.size() - (file.offset - cache.offset);
+}
void FileAccessBuffered::seek(size_t p_position) {
file.offset = p_position;
-};
+}
void FileAccessBuffered::seek_end(int64_t p_position) {
file.offset = file.size + p_position;
-};
+}
size_t FileAccessBuffered::get_position() const {
return file.offset;
-};
+}
size_t FileAccessBuffered::get_len() const {
return file.size;
-};
+}
bool FileAccessBuffered::eof_reached() const {
return file.offset > file.size;
-};
+}
uint8_t FileAccessBuffered::get_8() const {
-
- ERR_FAIL_COND_V(!file.open, 0);
+ if (!file.open) {
+ ERR_EXPLAIN("Can't get data, when file is not opened.");
+ ERR_FAIL_V(0);
+ }
uint8_t byte = 0;
if (cache_data_left() >= 1) {
byte = cache.buffer[file.offset - cache.offset];
- };
+ }
++file.offset;
return byte;
-};
+}
int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
-
- ERR_FAIL_COND_V(!file.open, -1);
+ if (!file.open) {
+ ERR_EXPLAIN("Can't get buffer, when file is not opened.");
+ ERR_FAIL_V(-1);
+ }
if (p_length > cache_size) {
@@ -124,16 +124,16 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
p_length -= size;
file.offset += size;
total_read += size;
- };
+ }
int err = read_data_block(file.offset, p_length, p_dest);
if (err >= 0) {
total_read += err;
file.offset += err;
- };
+ }
return total_read;
- };
+ }
int to_read = p_length;
int total_read = 0;
@@ -143,10 +143,10 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
if (left == 0) {
file.offset += to_read;
return total_read;
- };
+ }
if (left < 0) {
return left;
- };
+ }
int r = MIN(left, to_read);
//PoolVector<uint8_t>::Read read = cache.buffer.read();
@@ -156,25 +156,25 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
file.offset += r;
total_read += r;
to_read -= r;
- };
+ }
return p_length;
-};
+}
bool FileAccessBuffered::is_open() const {
return file.open;
-};
+}
Error FileAccessBuffered::get_error() const {
return last_error;
-};
+}
FileAccessBuffered::FileAccessBuffered() {
cache_size = DEFAULT_CACHE_SIZE;
-};
+}
FileAccessBuffered::~FileAccessBuffered() {
}
diff --git a/core/io/file_access_buffered_fa.h b/core/io/file_access_buffered_fa.h
index 24b40cbce8..6e806e7b3f 100644
--- a/core/io/file_access_buffered_fa.h
+++ b/core/io/file_access_buffered_fa.h
@@ -40,7 +40,10 @@ class FileAccessBufferedFA : public FileAccessBuffered {
int read_data_block(int p_offset, int p_size, uint8_t *p_dest = 0) const {
- ERR_FAIL_COND_V(!f.is_open(), -1);
+ if (!f.is_open()) {
+ ERR_EXPLAIN("Can't read data block, when file is not opened.");
+ ERR_FAIL_V(-1);
+ }
((T *)&f)->seek(p_offset);
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index c3626bfe31..170bef4430 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -482,8 +482,6 @@ Error HTTPClient::poll() {
return OK;
}
}
- // Wait for response
- return OK;
} break;
case STATUS_DISCONNECTED: {
return ERR_UNCONFIGURED;
diff --git a/core/io/json.cpp b/core/io/json.cpp
index c211ca2ed4..4e729cb355 100644
--- a/core/io/json.cpp
+++ b/core/io/json.cpp
@@ -347,8 +347,6 @@ Error JSON::_parse_value(Variant &value, Token &token, const CharType *p_str, in
r_err_str = "Expected value, got " + String(tk_name[token.type]) + ".";
return ERR_PARSE_ERROR;
}
-
- return ERR_PARSE_ERROR;
}
Error JSON::_parse_array(Array &array, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str) {
diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp
index 55685a2d9a..c16d89d695 100644
--- a/core/io/pck_packer.cpp
+++ b/core/io/pck_packer.cpp
@@ -63,10 +63,11 @@ void PCKPacker::_bind_methods() {
Error PCKPacker::pck_start(const String &p_file, int p_alignment) {
file = FileAccess::open(p_file, FileAccess::WRITE);
- if (file == NULL) {
- return ERR_CANT_CREATE;
- };
+ if (!file) {
+ ERR_EXPLAIN("Can't open file to write: " + String(p_file));
+ ERR_FAIL_V(ERR_CANT_CREATE);
+ }
alignment = p_alignment;
diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp
index 4a58d37ca5..63d7ba547c 100644
--- a/core/io/resource_importer.cpp
+++ b/core/io/resource_importer.cpp
@@ -161,7 +161,8 @@ void ResourceFormatImporter::get_recognized_extensions(List<String> *p_extension
void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const {
if (p_type == "") {
- return get_recognized_extensions(p_extensions);
+ get_recognized_extensions(p_extensions);
+ return;
}
Set<String> found;
@@ -347,7 +348,7 @@ void ResourceFormatImporter::get_dependencies(const String &p_path, List<String>
return;
}
- return ResourceLoader::get_dependencies(pat.path, p_dependencies, p_add_types);
+ ResourceLoader::get_dependencies(pat.path, p_dependencies, p_add_types);
}
Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_name(const String &p_name) const {
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 56d3b8b133..a29b9d1ddb 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -207,8 +207,6 @@ RES ResourceFormatLoader::load(const String &p_path, const String &p_original_pa
ERR_FAIL_COND_V(err != OK, RES());
}
-
- return RES();
}
void ResourceFormatLoader::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
@@ -283,7 +281,6 @@ RES ResourceLoader::_load(const String &p_path, const String &p_original_path, c
ERR_EXPLAIN("No loader found for resource: " + p_path);
}
ERR_FAIL_V(RES());
- return RES();
}
bool ResourceLoader::_add_to_loading_map(const String &p_path) {
@@ -543,7 +540,6 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
ERR_EXPLAIN("No loader found for resource: " + path);
}
ERR_FAIL_V(Ref<ResourceInteractiveLoader>());
- return Ref<ResourceInteractiveLoader>();
}
void ResourceLoader::add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front) {
diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp
index d7e6e82cd9..a12f9fee2e 100644
--- a/core/math/bsp_tree.cpp
+++ b/core/math/bsp_tree.cpp
@@ -142,7 +142,7 @@ int BSP_Tree::_get_points_inside(int p_node, const Vector3 *p_points, int *p_ind
}
return _get_points_inside(node->over, p_points, p_indices, p_center, p_half_extents, p_indices_count);
- } else if (dist_min <= 0) { //all points behind plane
+ } else { //all points behind plane
if (node->under == UNDER_LEAF) {
@@ -150,8 +150,6 @@ int BSP_Tree::_get_points_inside(int p_node, const Vector3 *p_points, int *p_ind
}
return _get_points_inside(node->under, p_points, p_indices, p_center, p_half_extents, p_indices_count);
}
-
- return 0;
}
int BSP_Tree::get_points_inside(const Vector3 *p_points, int p_point_count) const {
@@ -271,8 +269,6 @@ bool BSP_Tree::point_is_inside(const Vector3 &p_point) const {
ERR_FAIL_COND_V(idx < MAX_NODES && idx >= node_count, false);
#endif
}
-
- return false;
}
static int _bsp_find_best_half_plane(const Face3 *p_faces, const Vector<int> &p_indices, real_t p_tolerance) {
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index f615cc8c65..8b3b6c82f3 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -507,21 +507,21 @@ void CameraMatrix::set_light_bias() {
real_t *m = &matrix[0][0];
- m[0] = 0.5,
- m[1] = 0.0,
- m[2] = 0.0,
- m[3] = 0.0,
- m[4] = 0.0,
- m[5] = 0.5,
- m[6] = 0.0,
- m[7] = 0.0,
- m[8] = 0.0,
- m[9] = 0.0,
- m[10] = 0.5,
- m[11] = 0.0,
- m[12] = 0.5,
- m[13] = 0.5,
- m[14] = 0.5,
+ m[0] = 0.5;
+ m[1] = 0.0;
+ m[2] = 0.0;
+ m[3] = 0.0;
+ m[4] = 0.0;
+ m[5] = 0.5;
+ m[6] = 0.0;
+ m[7] = 0.0;
+ m[8] = 0.0;
+ m[9] = 0.0;
+ m[10] = 0.5;
+ m[11] = 0.0;
+ m[12] = 0.5;
+ m[13] = 0.5;
+ m[14] = 0.5;
m[15] = 1.0;
}
@@ -529,21 +529,21 @@ void CameraMatrix::set_light_atlas_rect(const Rect2 &p_rect) {
real_t *m = &matrix[0][0];
- m[0] = p_rect.size.width,
- m[1] = 0.0,
- m[2] = 0.0,
- m[3] = 0.0,
- m[4] = 0.0,
- m[5] = p_rect.size.height,
- m[6] = 0.0,
- m[7] = 0.0,
- m[8] = 0.0,
- m[9] = 0.0,
- m[10] = 1.0,
- m[11] = 0.0,
- m[12] = p_rect.position.x,
- m[13] = p_rect.position.y,
- m[14] = 0.0,
+ m[0] = p_rect.size.width;
+ m[1] = 0.0;
+ m[2] = 0.0;
+ m[3] = 0.0;
+ m[4] = 0.0;
+ m[5] = p_rect.size.height;
+ m[6] = 0.0;
+ m[7] = 0.0;
+ m[8] = 0.0;
+ m[9] = 0.0;
+ m[10] = 1.0;
+ m[11] = 0.0;
+ m[12] = p_rect.position.x;
+ m[13] = p_rect.position.y;
+ m[14] = 0.0;
m[15] = 1.0;
}
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp
index 5b5fd8e283..7a2e74a413 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -161,8 +161,6 @@ uint32_t Math::larger_prime(uint32_t p_val) {
return primes[idx];
idx++;
}
-
- return 0;
}
double Math::random(double from, double to) {
diff --git a/core/math/random_number_generator.h b/core/math/random_number_generator.h
index a6182a4b33..9b54ea9b2e 100644
--- a/core/math/random_number_generator.h
+++ b/core/math/random_number_generator.h
@@ -47,7 +47,7 @@ public:
_FORCE_INLINE_ uint64_t get_seed() { return randbase.get_seed(); }
- _FORCE_INLINE_ void randomize() { return randbase.randomize(); }
+ _FORCE_INLINE_ void randomize() { randbase.randomize(); }
_FORCE_INLINE_ uint32_t randi() { return randbase.rand(); }
diff --git a/core/object.cpp b/core/object.cpp
index 5dbf36940e..a44d0cd471 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -742,13 +742,11 @@ void Object::call_multilevel(const StringName &p_method, const Variant **p_args,
if (Object::cast_to<Reference>(this)) {
ERR_EXPLAIN("Can't 'free' a reference.");
ERR_FAIL();
- return;
}
if (_lock_index.get() > 1) {
ERR_EXPLAIN("Object is locked and can't be freed.");
ERR_FAIL();
- return;
}
#endif
@@ -1467,7 +1465,7 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str
if (!signal_is_valid) {
ERR_EXPLAIN("In Object of type '" + String(get_class()) + "': Attempt to connect nonexistent signal '" + p_signal + "' to method '" + p_to_object->get_class() + "." + p_to_method + "'");
- ERR_FAIL_COND_V(!signal_is_valid, ERR_INVALID_PARAMETER);
+ ERR_FAIL_V(ERR_INVALID_PARAMETER);
}
signal_map[p_signal] = Signal();
s = &signal_map[p_signal];
@@ -1517,7 +1515,7 @@ bool Object::is_connected(const StringName &p_signal, Object *p_to_object, const
return false;
ERR_EXPLAIN("Nonexistent signal: " + p_signal);
- ERR_FAIL_COND_V(!s, false);
+ ERR_FAIL_V(false);
}
Signal::Target target(p_to_object->get_instance_id(), p_to_method);
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index 1c57bfdf3d..ad50218474 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -43,8 +43,6 @@ String DirAccess::_get_root_path() const {
case ACCESS_USERDATA: return OS::get_singleton()->get_user_data_dir();
default: return "";
}
-
- return "";
}
String DirAccess::_get_root_string() const {
@@ -54,8 +52,6 @@ String DirAccess::_get_root_string() const {
case ACCESS_USERDATA: return "user://";
default: return "";
}
-
- return "";
}
int DirAccess::get_current_drive() {
diff --git a/core/os/memory.h b/core/os/memory.h
index f3ca9fc614..e073b11e76 100644
--- a/core/os/memory.h
+++ b/core/os/memory.h
@@ -66,7 +66,7 @@ public:
class DefaultAllocator {
public:
_FORCE_INLINE_ static void *alloc(size_t p_memory) { return Memory::alloc_static(p_memory, false); }
- _FORCE_INLINE_ static void free(void *p_ptr) { return Memory::free_static(p_ptr, false); }
+ _FORCE_INLINE_ static void free(void *p_ptr) { Memory::free_static(p_ptr, false); }
};
void *operator new(size_t p_size, const char *p_description); ///< operator new that takes a description and uses MemoryStaticPool
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index 983b2a2576..fc1a74801d 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -863,8 +863,6 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust
ERR_EXPLAIN("Unknown config file format: " + p_path);
ERR_FAIL_V(ERR_FILE_UNRECOGNIZED);
}
-
- return OK;
}
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed) {
diff --git a/core/ustring.cpp b/core/ustring.cpp
index ff28fa420d..18c48b4dad 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -481,8 +481,6 @@ signed char String::nocasecmp_to(const String &p_str) const {
this_str++;
that_str++;
}
-
- return 0; //should never reach anyway
}
signed char String::casecmp_to(const String &p_str) const {
@@ -513,8 +511,6 @@ signed char String::casecmp_to(const String &p_str) const {
this_str++;
that_str++;
}
-
- return 0; //should never reach anyway
}
signed char String::naturalnocasecmp_to(const String &p_str) const {
@@ -731,8 +727,6 @@ String String::get_slicec(CharType p_splitter, int p_slice) const {
i++;
}
-
- return String(); //no find!
}
Vector<String> String::split_spaces() const {
diff --git a/core/variant.cpp b/core/variant.cpp
index 9306867ac7..5b51a4e513 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -1171,8 +1171,6 @@ Variant::operator signed int() const {
return 0;
}
}
-
- return 0;
}
Variant::operator unsigned int() const {
@@ -1188,8 +1186,6 @@ Variant::operator unsigned int() const {
return 0;
}
}
-
- return 0;
}
Variant::operator int64_t() const {
@@ -1206,8 +1202,6 @@ Variant::operator int64_t() const {
return 0;
}
}
-
- return 0;
}
/*
@@ -1244,8 +1238,6 @@ Variant::operator uint64_t() const {
return 0;
}
}
-
- return 0;
}
#ifdef NEED_LONG_INT
@@ -1300,8 +1292,6 @@ Variant::operator signed short() const {
return 0;
}
}
-
- return 0;
}
Variant::operator unsigned short() const {
@@ -1317,8 +1307,6 @@ Variant::operator unsigned short() const {
return 0;
}
}
-
- return 0;
}
Variant::operator signed char() const {
@@ -1334,8 +1322,6 @@ Variant::operator signed char() const {
return 0;
}
}
-
- return 0;
}
Variant::operator unsigned char() const {
@@ -1351,8 +1337,6 @@ Variant::operator unsigned char() const {
return 0;
}
}
-
- return 0;
}
Variant::operator CharType() const {
@@ -1374,8 +1358,6 @@ Variant::operator float() const {
return 0;
}
}
-
- return 0;
}
Variant::operator double() const {
@@ -1391,8 +1373,6 @@ Variant::operator double() const {
return 0;
}
}
-
- return true;
}
Variant::operator StringName() const {
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index f3c9bcaa7e..d677c7776a 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -2183,7 +2183,8 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
return;
}
- return obj->set(p_index, p_value, r_valid);
+ obj->set(p_index, p_value, r_valid);
+ return;
}
} break;
case DICTIONARY: {
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index d7371b0434..d5513bc2d7 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -436,8 +436,6 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String> &strings,
line++;
}
}
-
- return OK;
}
template <class T>
@@ -799,8 +797,6 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
}
}
- return OK;
-
} else if (id == "Resource" || id == "SubResource" || id == "ExtResource") {
get_token(p_stream, token, line, r_err_str);
@@ -864,8 +860,6 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return ERR_PARSE_ERROR;
}
}
-
- return OK;
#ifndef DISABLE_DEPRECATED
} else if (id == "InputEvent") {
@@ -1256,8 +1250,6 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
r_err_str = "Expected value, got " + String(tk_name[token.type]) + ".";
return ERR_PARSE_ERROR;
}
-
- return ERR_PARSE_ERROR;
}
Error VariantParser::_parse_array(Array &array, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser) {
@@ -1301,8 +1293,6 @@ Error VariantParser::_parse_array(Array &array, Stream *p_stream, int &line, Str
array.push_back(v);
need_comma = true;
}
-
- return OK;
}
Error VariantParser::_parse_dictionary(Dictionary &object, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser) {
@@ -1372,8 +1362,6 @@ Error VariantParser::_parse_dictionary(Dictionary &object, Stream *p_stream, int
at_key = true;
}
}
-
- return OK;
}
Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, ResourceParser *p_res_parser, bool p_simple_tag) {
@@ -1557,8 +1545,6 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
line++;
}
}
-
- return OK;
}
Error VariantParser::parse(Stream *p_stream, Variant &r_ret, String &r_err_str, int &r_err_line, ResourceParser *p_res_parser) {
diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp
index c10443acde..d5ffb7f614 100644
--- a/drivers/unix/net_socket_posix.cpp
+++ b/drivers/unix/net_socket_posix.cpp
@@ -683,10 +683,10 @@ Ref<NetSocket> NetSocketPosix::accept(IP_Address &r_ip, uint16_t &r_port) {
return Ref<NetSocket>(ns);
}
-Error NetSocketPosix::join_multicast_group(const IP_Address &p_ip, String p_if_name) {
- return _change_multicast_group(p_ip, p_if_name, true);
+Error NetSocketPosix::join_multicast_group(const IP_Address &p_multi_address, String p_if_name) {
+ return _change_multicast_group(p_multi_address, p_if_name, true);
}
-Error NetSocketPosix::leave_multicast_group(const IP_Address &p_ip, String p_if_name) {
- return _change_multicast_group(p_ip, p_if_name, false);
+Error NetSocketPosix::leave_multicast_group(const IP_Address &p_multi_address, String p_if_name) {
+ return _change_multicast_group(p_multi_address, p_if_name, false);
}
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp
index e524dffd43..14ea18f885 100644
--- a/editor/animation_bezier_editor.cpp
+++ b/editor/animation_bezier_editor.cpp
@@ -275,8 +275,6 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
int margin = 0;
{
- int ofs = 0;
-
NodePath path = animation->track_get_path(track);
Node *node = NULL;
@@ -290,6 +288,8 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
int h = font->get_height();
if (node) {
+ int ofs = 0;
+
Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
h = MAX(h, icon->get_height());
diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp
index 07dbc1fd81..226eef9c1e 100644
--- a/editor/animation_track_editor_plugins.cpp
+++ b/editor/animation_track_editor_plugins.cpp
@@ -1009,7 +1009,7 @@ void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant
}
}
- return AnimationTrackEdit::drop_data(p_point, p_data);
+ AnimationTrackEdit::drop_data(p_point, p_data);
}
void AnimationTrackEditTypeAudio::_gui_input(const Ref<InputEvent> &p_event) {
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index e84602b29f..c79f7c7484 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -308,8 +308,9 @@ void CreateDialog::_update_search() {
if (cpp_type && !ClassDB::can_instance(type))
continue; // can't create what can't be instanced
- bool skip = false;
if (cpp_type) {
+ bool skip = false;
+
for (Set<StringName>::Element *E = type_blacklist.front(); E && !skip; E = E->next()) {
if (ClassDB::is_parent_class(type, E->get()))
skip = true;
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 78c38af555..90d6c3a983 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -200,7 +200,7 @@ ScriptEditor *EditorInterface::get_script_editor() {
}
void EditorInterface::select_file(const String &p_file) {
- return EditorNode::get_singleton()->get_filesystem_dock()->select_file(p_file);
+ EditorNode::get_singleton()->get_filesystem_dock()->select_file(p_file);
}
String EditorInterface::get_selected_path() const {
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp
index 3cf3bbf0f2..51908c65a4 100644
--- a/editor/groups_editor.cpp
+++ b/editor/groups_editor.cpp
@@ -69,7 +69,7 @@ void GroupDialog::_load_nodes(Node *p_current) {
keep = false;
}
- TreeItem *node;
+ TreeItem *node = NULL;
NodePath path = scene_tree->get_edited_scene_root()->get_path_to(p_current);
if (keep && p_current->is_in_group(selected_group)) {
if (remove_filter->get_text().is_subsequence_ofi(String(p_current->get_name()))) {
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h
index 965e6c8827..10a1a6bd98 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.h
+++ b/editor/plugins/collision_shape_2d_editor_plugin.h
@@ -89,7 +89,7 @@ class CollisionShape2DEditorPlugin : public EditorPlugin {
public:
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return collision_shape_2d_editor->forward_canvas_gui_input(p_event); }
- virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { return collision_shape_2d_editor->forward_canvas_draw_over_viewport(p_overlay); }
+ virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { collision_shape_2d_editor->forward_canvas_draw_over_viewport(p_overlay); }
virtual String get_name() const { return "CollisionShape2D"; }
bool has_main_screen() const { return false; }
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index 3b1d728b8b..d2d2b8f130 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -156,9 +156,9 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
Vector2 mpos = mm.get_position();
if (_dragging && _curve_ref.is_valid()) {
- Curve &curve = **_curve_ref;
if (_selected_point != -1) {
+ Curve &curve = **_curve_ref;
if (!_has_undo_data) {
// Save full curve state before dragging points,
diff --git a/editor/plugins/path_2d_editor_plugin.h b/editor/plugins/path_2d_editor_plugin.h
index 4edd17d146..44472f7a81 100644
--- a/editor/plugins/path_2d_editor_plugin.h
+++ b/editor/plugins/path_2d_editor_plugin.h
@@ -123,7 +123,7 @@ class Path2DEditorPlugin : public EditorPlugin {
public:
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return path2d_editor->forward_gui_input(p_event); }
- virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { return path2d_editor->forward_canvas_draw_over_viewport(p_overlay); }
+ virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { path2d_editor->forward_canvas_draw_over_viewport(p_overlay); }
virtual String get_name() const { return "Path2D"; }
bool has_main_screen() const { return false; }
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 1b00889e9a..d999f3189e 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -3463,7 +3463,7 @@ void ScriptEditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
void ScriptEditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
- return script_editor->get_breakpoints(p_breakpoints);
+ script_editor->get_breakpoints(p_breakpoints);
}
void ScriptEditorPlugin::edited_scene_changed() {
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 4e15bd5116..8f58fbd6ab 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -192,8 +192,8 @@ void TextureRegionEditor::_region_draw() {
}
updating_scroll = false;
- float margins[4];
if (node_ninepatch || obj_styleBox.is_valid()) {
+ float margins[4];
if (node_ninepatch) {
margins[0] = node_ninepatch->get_patch_margin(MARGIN_TOP);
margins[1] = node_ninepatch->get_patch_margin(MARGIN_BOTTOM);
@@ -204,6 +204,11 @@ void TextureRegionEditor::_region_draw() {
margins[1] = obj_styleBox->get_margin_size(MARGIN_BOTTOM);
margins[2] = obj_styleBox->get_margin_size(MARGIN_LEFT);
margins[3] = obj_styleBox->get_margin_size(MARGIN_RIGHT);
+ } else {
+ margins[0] = 0;
+ margins[1] = 0;
+ margins[2] = 0;
+ margins[3] = 0;
}
Vector2 pos[4] = {
mtx.basis_xform(Vector2(0, margins[0])) + Vector2(0, endpoints[0].y - draw_ofs.y * draw_zoom),
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index df0dd8781e..4dc40a850f 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -257,7 +257,7 @@ void ProjectSettingsEditor::_device_input_add() {
Ref<InputEventJoypadMotion> jm;
jm.instance();
jm->set_axis(device_index->get_selected() >> 1);
- jm->set_axis_value(device_index->get_selected() & 1 ? 1 : -1);
+ jm->set_axis_value((device_index->get_selected() & 1) ? 1 : -1);
jm->set_device(_get_current_device());
for (int i = 0; i < events.size(); i++) {
@@ -483,7 +483,7 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
for (int i = 0; i < JOY_AXIS_MAX * 2; i++) {
String desc = _axis_names[i];
- device_index->add_item(TTR("Axis") + " " + itos(i / 2) + " " + (i & 1 ? "+" : "-") + desc);
+ device_index->add_item(TTR("Axis") + " " + itos(i / 2) + " " + ((i & 1) ? "+" : "-") + desc);
}
device_input->popup_centered_minsize(Size2(350, 95) * EDSCALE);
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index a15ae2efda..e5ce834d79 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -1493,7 +1493,6 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
if (p_nodes.find(validate) != -1) {
ERR_EXPLAIN("Selection changed at some point.. can't reparent");
ERR_FAIL();
- return;
}
validate = validate->get_parent();
}
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index fc4ff2ecfc..fe6d9dd8c7 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -147,7 +147,7 @@ void EditorSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p
}
ERR_FAIL_COND(!gizmo_plugin);
- return gizmo_plugin->set_handle(this, p_idx, p_camera, p_point);
+ gizmo_plugin->set_handle(this, p_idx, p_camera, p_point);
}
void EditorSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
@@ -158,7 +158,7 @@ void EditorSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool
}
ERR_FAIL_COND(!gizmo_plugin);
- return gizmo_plugin->commit_handle(this, p_idx, p_restore, p_cancel);
+ gizmo_plugin->commit_handle(this, p_idx, p_restore, p_cancel);
}
void EditorSpatialGizmo::set_spatial_node(Spatial *p_node) {
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 95f3c12806..bc28f7009e 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -332,7 +332,7 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
}
Variant::CallError unchecked_error;
- return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this), unchecked_error);
+ return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this) != NULL, unchecked_error);
}
PlaceHolderScriptInstance *GDScript::placeholder_instance_create(Object *p_this) {
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index caffe04700..4c976bd2e0 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -1259,8 +1259,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
ERR_FAIL_V(-1); //unreachable code
} break;
}
-
- ERR_FAIL_V(-1); //unreachable code
}
Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::BlockNode *p_block, int p_stack_level, int p_break_addr, int p_continue_addr) {
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 20b227bda1..9522eaee77 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -2701,7 +2701,7 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
}
Variant::CallError unchecked_error;
- return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this), unchecked_error);
+ return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this) != NULL, unchecked_error);
}
PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_this) {
diff --git a/scene/2d/navigation_2d.cpp b/scene/2d/navigation_2d.cpp
index 72b5f2fb12..f644db462b 100644
--- a/scene/2d/navigation_2d.cpp
+++ b/scene/2d/navigation_2d.cpp
@@ -92,7 +92,6 @@ void Navigation2D::_navpoly_link(int p_id) {
if (!valid) {
nm.polygons.pop_back();
ERR_CONTINUE(!valid);
- continue;
}
p.center = center / plen;
diff --git a/scene/3d/audio_stream_player_3d.h b/scene/3d/audio_stream_player_3d.h
index 7a652ed65f..93954e758a 100644
--- a/scene/3d/audio_stream_player_3d.h
+++ b/scene/3d/audio_stream_player_3d.h
@@ -71,7 +71,7 @@ private:
struct Output {
AudioFilterSW filter;
- AudioFilterSW::Processor filter_process[6];
+ AudioFilterSW::Processor filter_process[8];
AudioFrame vol[4];
float filter_gain;
float pitch_scale;
diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation.cpp
index 612d91c6e1..12d562c0c6 100644
--- a/scene/3d/navigation.cpp
+++ b/scene/3d/navigation.cpp
@@ -90,7 +90,6 @@ void Navigation::_navmesh_link(int p_id) {
if (!valid) {
nm.polygons.pop_back();
ERR_CONTINUE(!valid);
- continue;
}
p.center = center;
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 872402e9e1..58671655dc 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -282,7 +282,7 @@ void OptionButton::_set_items(const Array &p_items) {
void OptionButton::get_translatable_strings(List<String> *p_strings) const {
- return popup->get_translatable_strings(p_strings);
+ popup->get_translatable_strings(p_strings);
}
void OptionButton::_bind_methods() {