summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp8
-rw-r--r--core/bind/core_bind.h1
-rw-r--r--core/class_db.cpp2
-rw-r--r--core/color.h2
-rw-r--r--core/error_list.h8
-rw-r--r--core/error_macros.h36
-rw-r--r--core/global_constants.cpp52
-rw-r--r--core/image.cpp4
-rw-r--r--core/image.h2
-rw-r--r--core/input_map.cpp2
-rw-r--r--core/io/file_access_network.cpp1
-rw-r--r--core/io/http_client.cpp2
-rw-r--r--core/io/marshalls.cpp7
-rw-r--r--core/io/multiplayer_api.h2
-rw-r--r--core/io/pck_packer.cpp5
-rw-r--r--core/io/resource_format_binary.cpp4
-rw-r--r--core/io/stream_peer_tcp.cpp1
-rw-r--r--core/io/tcp_server.cpp6
-rw-r--r--core/math/expression.cpp2
-rw-r--r--core/math/random_number_generator.cpp3
-rw-r--r--core/math/triangle_mesh.h2
-rw-r--r--core/node_path.cpp10
-rw-r--r--core/object.cpp21
-rw-r--r--core/os/dir_access.cpp2
-rw-r--r--core/os/file_access.cpp6
-rw-r--r--core/os/input_event.cpp8
-rw-r--r--core/os/main_loop.cpp6
-rw-r--r--core/os/os.cpp3
-rw-r--r--core/pool_allocator.cpp7
-rw-r--r--core/project_settings.cpp2
-rw-r--r--core/safe_refcount.h6
-rw-r--r--core/undo_redo.cpp23
-rw-r--r--core/undo_redo.h3
-rw-r--r--core/ustring.cpp7
-rw-r--r--core/ustring.h2
-rw-r--r--core/variant.cpp2
-rw-r--r--core/variant.h24
37 files changed, 143 insertions, 141 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 8a898f3b53..44573a0d97 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -76,7 +76,7 @@ RES _ResourceLoader::load(const String &p_path, const String &p_type_hint, bool
if (err != OK) {
ERR_EXPLAIN("Error loading resource: '" + p_path + "'");
- ERR_FAIL_COND_V(err != OK, ret);
+ ERR_FAIL_V(ret);
}
return ret;
}
@@ -1524,6 +1524,11 @@ bool _Geometry::is_polygon_clockwise(const Vector<Vector2> &p_polygon) {
return Geometry::is_polygon_clockwise(p_polygon);
}
+bool _Geometry::is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon) {
+
+ return Geometry::is_point_in_polygon(p_point, p_polygon);
+}
+
Vector<int> _Geometry::triangulate_polygon(const Vector<Vector2> &p_polygon) {
return Geometry::triangulate_polygon(p_polygon);
@@ -1706,6 +1711,7 @@ void _Geometry::_bind_methods() {
ClassDB::bind_method(D_METHOD("point_is_inside_triangle", "point", "a", "b", "c"), &_Geometry::point_is_inside_triangle);
ClassDB::bind_method(D_METHOD("is_polygon_clockwise", "polygon"), &_Geometry::is_polygon_clockwise);
+ ClassDB::bind_method(D_METHOD("is_point_in_polygon", "point", "polygon"), &_Geometry::is_point_in_polygon);
ClassDB::bind_method(D_METHOD("triangulate_polygon", "polygon"), &_Geometry::triangulate_polygon);
ClassDB::bind_method(D_METHOD("triangulate_delaunay_2d", "points"), &_Geometry::triangulate_delaunay_2d);
ClassDB::bind_method(D_METHOD("convex_hull_2d", "points"), &_Geometry::convex_hull_2d);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 7d0c158f51..2885e7c0e0 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -408,6 +408,7 @@ public:
int get_uv84_normal_bit(const Vector3 &p_vector);
bool is_polygon_clockwise(const Vector<Vector2> &p_polygon);
+ bool is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon);
Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon);
Vector<int> triangulate_delaunay_2d(const Vector<Vector2> &p_points);
Vector<Point2> convex_hull_2d(const Vector<Point2> &p_points);
diff --git a/core/class_db.cpp b/core/class_db.cpp
index ec07ee98e2..c9527e3c8f 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -552,7 +552,7 @@ void ClassDB::_add_class2(const StringName &p_class, const StringName &p_inherit
OBJTYPE_WLOCK;
- StringName name = p_class;
+ const StringName &name = p_class;
ERR_FAIL_COND(classes.has(name));
diff --git a/core/color.h b/core/color.h
index b2148e1357..77f95b5dc9 100644
--- a/core/color.h
+++ b/core/color.h
@@ -195,7 +195,7 @@ struct Color {
static Color named(const String &p_name);
String to_html(bool p_alpha = true) const;
Color from_hsv(float p_h, float p_s, float p_v, float p_a) const;
- static Color from_rgbe9995(uint32_t p_color);
+ static Color from_rgbe9995(uint32_t p_rgbe);
_FORCE_INLINE_ bool operator<(const Color &p_color) const; //used in set keys
operator String() const;
diff --git a/core/error_list.h b/core/error_list.h
index 304861da4e..dc5a5e68dd 100644
--- a/core/error_list.h
+++ b/core/error_list.h
@@ -39,7 +39,7 @@
*/
enum Error {
- OK,
+ OK, // (0)
FAILED, ///< Generic fail error
ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable
ERR_UNCONFIGURED, ///< The object being used hasn't been properly set up yet
@@ -69,12 +69,12 @@ enum Error {
ERR_CONNECTION_ERROR,
ERR_CANT_ACQUIRE_RESOURCE,
ERR_CANT_FORK,
- ERR_INVALID_DATA, ///< Data passed is invalid (30)
+ ERR_INVALID_DATA, ///< Data passed is invalid (30)
ERR_INVALID_PARAMETER, ///< Parameter passed is invalid
ERR_ALREADY_EXISTS, ///< When adding, item already exists
- ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, it item does not exist
+ ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, if item does not exist
ERR_DATABASE_CANT_READ, ///< database is full
- ERR_DATABASE_CANT_WRITE, ///< database is full (35)
+ ERR_DATABASE_CANT_WRITE, ///< database is full (35)
ERR_COMPILATION_FAILED,
ERR_METHOD_NOT_FOUND,
ERR_LINK_FAILED,
diff --git a/core/error_macros.h b/core/error_macros.h
index f72e987e23..69874e280b 100644
--- a/core/error_macros.h
+++ b/core/error_macros.h
@@ -136,8 +136,8 @@ extern bool _err_error_exists;
if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
return; \
- } else \
- _err_error_exists = false; \
+ } \
+ _err_error_exists = false; \
} while (0); // (*)
/** An index has failed if m_index<0 or m_index >=m_size, the function exits.
@@ -150,8 +150,8 @@ extern bool _err_error_exists;
if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
return m_retval; \
- } else \
- _err_error_exists = false; \
+ } \
+ _err_error_exists = false; \
} while (0); // (*)
/** An index has failed if m_index >=m_size, the function exits.
@@ -164,8 +164,8 @@ extern bool _err_error_exists;
if (unlikely((m_index) >= (m_size))) { \
_err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
return m_retval; \
- } else \
- _err_error_exists = false; \
+ } \
+ _err_error_exists = false; \
} while (0); // (*)
/** Use this one if there is no sensible fallback, that is, the error is unrecoverable.
@@ -188,8 +188,8 @@ extern bool _err_error_exists;
if (unlikely(!m_param)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter ' " _STR(m_param) " ' is null."); \
return; \
- } else \
- _err_error_exists = false; \
+ } \
+ _err_error_exists = false; \
}
#define ERR_FAIL_NULL_V(m_param, m_retval) \
@@ -197,8 +197,8 @@ extern bool _err_error_exists;
if (unlikely(!m_param)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter ' " _STR(m_param) " ' is null."); \
return m_retval; \
- } else \
- _err_error_exists = false; \
+ } \
+ _err_error_exists = false; \
}
/** An error condition happened (m_cond tested true) (WARNING this is the opposite as assert().
@@ -210,8 +210,8 @@ extern bool _err_error_exists;
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true."); \
return; \
- } else \
- _err_error_exists = false; \
+ } \
+ _err_error_exists = false; \
}
/** Use this one if there is no sensible fallback, that is, the error is unrecoverable.
@@ -236,8 +236,8 @@ extern bool _err_error_exists;
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true. returned: " _STR(m_retval)); \
return m_retval; \
- } else \
- _err_error_exists = false; \
+ } \
+ _err_error_exists = false; \
}
/** An error condition happened (m_cond tested true) (WARNING this is the opposite as assert().
@@ -249,8 +249,8 @@ extern bool _err_error_exists;
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true. Continuing..:"); \
continue; \
- } else \
- _err_error_exists = false; \
+ } \
+ _err_error_exists = false; \
}
/** An error condition happened (m_cond tested true) (WARNING this is the opposite as assert().
@@ -262,8 +262,8 @@ extern bool _err_error_exists;
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true. Breaking..:"); \
break; \
- } else \
- _err_error_exists = false; \
+ } \
+ _err_error_exists = false; \
}
/** Print an error string and return
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index 671b3c545b..5bfdc8ab8f 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -486,47 +486,55 @@ void register_global_constants() {
// error list
- BIND_GLOBAL_ENUM_CONSTANT(OK);
- BIND_GLOBAL_ENUM_CONSTANT(FAILED); ///< Generic fail error
- BIND_GLOBAL_ENUM_CONSTANT(ERR_UNAVAILABLE); ///< What is requested is unsupported/unavailable
- BIND_GLOBAL_ENUM_CONSTANT(ERR_UNCONFIGURED); ///< The object being used hasn't been properly set up yet
- BIND_GLOBAL_ENUM_CONSTANT(ERR_UNAUTHORIZED); ///< Missing credentials for requested resource
- BIND_GLOBAL_ENUM_CONSTANT(ERR_PARAMETER_RANGE_ERROR); ///< Parameter given out of range
- BIND_GLOBAL_ENUM_CONSTANT(ERR_OUT_OF_MEMORY); ///< Out of memory
+ BIND_GLOBAL_ENUM_CONSTANT(OK); // (0)
+ BIND_GLOBAL_ENUM_CONSTANT(FAILED);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_UNAVAILABLE);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_UNCONFIGURED);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_UNAUTHORIZED);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_PARAMETER_RANGE_ERROR); // (5)
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_OUT_OF_MEMORY);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_NOT_FOUND);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_BAD_DRIVE);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_BAD_PATH);
- BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_NO_PERMISSION);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_NO_PERMISSION); // (10)
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_ALREADY_IN_USE);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_CANT_OPEN);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_CANT_WRITE);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_CANT_READ);
- BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_UNRECOGNIZED);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_UNRECOGNIZED); // (15)
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_CORRUPT);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_MISSING_DEPENDENCIES);
BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_EOF);
- BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_OPEN); ///< Can't open a resource/socket/file
- BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_CREATE);
- BIND_GLOBAL_ENUM_CONSTANT(ERR_PARSE_ERROR);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_OPEN);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_CREATE); // (20)
BIND_GLOBAL_ENUM_CONSTANT(ERR_QUERY_FAILED);
BIND_GLOBAL_ENUM_CONSTANT(ERR_ALREADY_IN_USE);
- BIND_GLOBAL_ENUM_CONSTANT(ERR_LOCKED); ///< resource is locked
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_LOCKED);
BIND_GLOBAL_ENUM_CONSTANT(ERR_TIMEOUT);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_CONNECT); // (25)
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_RESOLVE);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_CONNECTION_ERROR);
BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_ACQUIRE_RESOURCE);
- BIND_GLOBAL_ENUM_CONSTANT(ERR_INVALID_DATA); ///< Data passed is invalid
- BIND_GLOBAL_ENUM_CONSTANT(ERR_INVALID_PARAMETER); ///< Parameter passed is invalid
- BIND_GLOBAL_ENUM_CONSTANT(ERR_ALREADY_EXISTS); ///< When adding ), item already exists
- BIND_GLOBAL_ENUM_CONSTANT(ERR_DOES_NOT_EXIST); ///< When retrieving/erasing ), it item does not exist
- BIND_GLOBAL_ENUM_CONSTANT(ERR_DATABASE_CANT_READ); ///< database is full
- BIND_GLOBAL_ENUM_CONSTANT(ERR_DATABASE_CANT_WRITE); ///< database is full
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_FORK);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_INVALID_DATA); // (30)
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_INVALID_PARAMETER);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_ALREADY_EXISTS);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_DOES_NOT_EXIST);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_DATABASE_CANT_READ);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_DATABASE_CANT_WRITE); // (35)
BIND_GLOBAL_ENUM_CONSTANT(ERR_COMPILATION_FAILED);
BIND_GLOBAL_ENUM_CONSTANT(ERR_METHOD_NOT_FOUND);
BIND_GLOBAL_ENUM_CONSTANT(ERR_LINK_FAILED);
BIND_GLOBAL_ENUM_CONSTANT(ERR_SCRIPT_FAILED);
- BIND_GLOBAL_ENUM_CONSTANT(ERR_CYCLIC_LINK);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_CYCLIC_LINK); // (40)
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_INVALID_DECLARATION);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_DUPLICATE_SYMBOL);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_PARSE_ERROR);
BIND_GLOBAL_ENUM_CONSTANT(ERR_BUSY);
- BIND_GLOBAL_ENUM_CONSTANT(ERR_HELP); ///< user requested help!!
- BIND_GLOBAL_ENUM_CONSTANT(ERR_BUG); ///< a bug in the software certainly happened ), due to a double check failing or unexpected behavior.
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_SKIP); // (45)
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_HELP);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_BUG);
+ BIND_GLOBAL_ENUM_CONSTANT(ERR_PRINTER_ON_FIRE);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_NONE);
BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_RANGE);
diff --git a/core/image.cpp b/core/image.cpp
index c85d7f6bcc..dd8f2b9bac 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -2402,7 +2402,7 @@ Color Image::get_pixel(int p_x, int p_y) const {
#ifdef DEBUG_ENABLED
if (!ptr) {
ERR_EXPLAIN("Image must be locked with 'lock()' before using get_pixel()");
- ERR_FAIL_COND_V(!ptr, Color());
+ ERR_FAIL_V(Color());
}
ERR_FAIL_INDEX_V(p_x, width, Color());
@@ -2541,7 +2541,7 @@ void Image::set_pixel(int p_x, int p_y, const Color &p_color) {
#ifdef DEBUG_ENABLED
if (!ptr) {
ERR_EXPLAIN("Image must be locked with 'lock()' before using set_pixel()");
- ERR_FAIL_COND(!ptr);
+ ERR_FAIL();
}
ERR_FAIL_INDEX(p_x, width);
diff --git a/core/image.h b/core/image.h
index 752ef20208..cc796789cd 100644
--- a/core/image.h
+++ b/core/image.h
@@ -350,7 +350,7 @@ public:
Color get_pixelv(const Point2 &p_src) const;
Color get_pixel(int p_x, int p_y) const;
- void set_pixelv(const Point2 &p_dest, const Color &p_color);
+ void set_pixelv(const Point2 &p_dst, const Color &p_color);
void set_pixel(int p_x, int p_y, const Color &p_color);
void copy_internals_from(const Ref<Image> &p_image) {
diff --git a/core/input_map.cpp b/core/input_map.cpp
index 012c6a7c4f..04911787a8 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -194,7 +194,7 @@ bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const Str
Map<StringName, Action>::Element *E = input_map.find(p_action);
if (!E) {
ERR_EXPLAIN("Request for nonexistent InputMap action: " + String(p_action));
- ERR_FAIL_COND_V(!E, false);
+ ERR_FAIL_V(false);
}
Ref<InputEventAction> input_event_action = p_event;
diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp
index 5dd167c581..d1c7f5c334 100644
--- a/core/io/file_access_network.cpp
+++ b/core/io/file_access_network.cpp
@@ -435,7 +435,6 @@ int FileAccessNetwork::get_buffer(uint8_t *p_dst, int p_length) const {
_queue_page(page + j);
}
- buff = pages.write[page].buffer.ptrw();
//queue pages
buffer_mutex->unlock();
}
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 891fb7b0ca..c3626bfe31 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -775,7 +775,7 @@ Dictionary HTTPClient::_get_response_headers_as_dictionary() {
get_response_headers(&rh);
Dictionary ret;
for (const List<String>::Element *E = rh.front(); E; E = E->next()) {
- String s = E->get();
+ const String &s = E->get();
int sp = s.find(":");
if (sp == -1)
continue;
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 3c9c5bc2bb..17a3f52a65 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -683,8 +683,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (r_len)
(*r_len) += adv;
- len -= adv;
- buf += adv;
}
r_variant = varray;
@@ -721,8 +719,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (r_len)
(*r_len) += adv;
- len -= adv;
- buf += adv;
}
r_variant = varray;
@@ -760,8 +756,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (r_len)
(*r_len) += adv;
- len -= adv;
- buf += adv;
}
r_variant = carray;
@@ -1094,7 +1088,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
if (!obj) {
if (buf) {
encode_uint32(0, buf);
- buf += 4;
}
r_len += 4;
diff --git a/core/io/multiplayer_api.h b/core/io/multiplayer_api.h
index 779dd043bd..5258dde5d7 100644
--- a/core/io/multiplayer_api.h
+++ b/core/io/multiplayer_api.h
@@ -77,7 +77,7 @@ protected:
void _process_raw(int p_from, const uint8_t *p_packet, int p_packet_len);
void _send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p_set, const StringName &p_name, const Variant **p_arg, int p_argcount);
- bool _send_confirm_path(NodePath p_path, PathSentCache *psc, int p_from);
+ bool _send_confirm_path(NodePath p_path, PathSentCache *psc, int p_target);
public:
enum NetworkCommands {
diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp
index 8920bbfb81..55685a2d9a 100644
--- a/core/io/pck_packer.cpp
+++ b/core/io/pck_packer.cpp
@@ -109,10 +109,7 @@ Error PCKPacker::add_file(const String &p_file, const String &p_src) {
Error PCKPacker::flush(bool p_verbose) {
- if (!file) {
- ERR_FAIL_COND_V(!file, ERR_INVALID_PARAMETER);
- return ERR_INVALID_PARAMETER;
- };
+ ERR_FAIL_COND_V(!file, ERR_INVALID_PARAMETER);
// write the index
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index aef2dcfff3..688dfc21e5 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -720,7 +720,7 @@ Error ResourceInteractiveLoaderBinary::poll() {
error = ERR_FILE_CORRUPT;
memdelete(obj); //bye
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);
+ ERR_FAIL_V(ERR_FILE_CORRUPT);
}
RES res = RES(r);
@@ -1694,7 +1694,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant
int len = varray.size();
for (int i = 0; i < len; i++) {
- Variant v = varray.get(i);
+ const Variant &v = varray.get(i);
_find_resources(v);
}
diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp
index 45f3e46e35..bcdae343b8 100644
--- a/core/io/stream_peer_tcp.cpp
+++ b/core/io/stream_peer_tcp.cpp
@@ -352,7 +352,6 @@ void StreamPeerTCP::_bind_methods() {
StreamPeerTCP::StreamPeerTCP() :
_sock(Ref<NetSocket>(NetSocket::create())),
status(STATUS_NONE),
- peer_host(IP_Address()),
peer_port(0) {
}
diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp
index 6599c4eb5b..be87f47d50 100644
--- a/core/io/tcp_server.cpp
+++ b/core/io/tcp_server.cpp
@@ -83,11 +83,7 @@ bool TCP_Server::is_connection_available() const {
return false;
Error err = _sock->poll(NetSocket::POLL_TYPE_IN, 0);
- if (err != OK) {
- return false;
- }
-
- return true;
+ return (err == OK);
}
Ref<StreamPeerTCP> TCP_Server::take_connection() {
diff --git a/core/math/expression.cpp b/core/math/expression.cpp
index e484e9194d..b52658e2cf 100644
--- a/core/math/expression.cpp
+++ b/core/math/expression.cpp
@@ -1794,7 +1794,7 @@ Expression::ENode *Expression::_parse_expression() {
if (next_op == -1) {
_set_error("Yet another parser bug....");
- ERR_FAIL_COND_V(next_op == -1, NULL);
+ ERR_FAIL_V(NULL);
}
// OK! create operator..
diff --git a/core/math/random_number_generator.cpp b/core/math/random_number_generator.cpp
index 6add00c1d8..54a88d5cd8 100644
--- a/core/math/random_number_generator.cpp
+++ b/core/math/random_number_generator.cpp
@@ -30,8 +30,7 @@
#include "random_number_generator.h"
-RandomNumberGenerator::RandomNumberGenerator() :
- randbase() {}
+RandomNumberGenerator::RandomNumberGenerator() {}
void RandomNumberGenerator::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_seed", "seed"), &RandomNumberGenerator::set_seed);
diff --git a/core/math/triangle_mesh.h b/core/math/triangle_mesh.h
index ee7bf0f6b5..8b01080852 100644
--- a/core/math/triangle_mesh.h
+++ b/core/math/triangle_mesh.h
@@ -97,7 +97,7 @@ public:
PoolVector<Triangle> get_triangles() const { return triangles; }
PoolVector<Vector3> get_vertices() const { return vertices; }
- void get_indices(PoolVector<int> *p_triangles_indices) const;
+ void get_indices(PoolVector<int> *r_triangles_indices) const;
void create(const PoolVector<Vector3> &p_faces);
TriangleMesh();
diff --git a/core/node_path.cpp b/core/node_path.cpp
index 07ff765516..a4b7cbe2eb 100644
--- a/core/node_path.cpp
+++ b/core/node_path.cpp
@@ -357,7 +357,7 @@ NodePath::NodePath(const String &p_path) {
String path = p_path;
Vector<StringName> subpath;
- int absolute = (path[0] == '/') ? 1 : 0;
+ bool absolute = (path[0] == '/');
bool last_is_slash = true;
bool has_slashes = false;
int slices = 0;
@@ -387,7 +387,7 @@ NodePath::NodePath(const String &p_path) {
path = path.substr(0, subpath_pos);
}
- for (int i = absolute; i < path.length(); i++) {
+ for (int i = (int)absolute; i < path.length(); i++) {
if (path[i] == '/') {
@@ -407,7 +407,7 @@ NodePath::NodePath(const String &p_path) {
data = memnew(Data);
data->refcount.init();
- data->absolute = absolute ? true : false;
+ data->absolute = absolute;
data->has_slashes = has_slashes;
data->subpath = subpath;
data->hash_cache_valid = false;
@@ -416,10 +416,10 @@ NodePath::NodePath(const String &p_path) {
return;
data->path.resize(slices);
last_is_slash = true;
- int from = absolute;
+ int from = (int)absolute;
int slice = 0;
- for (int i = absolute; i < path.length() + 1; i++) {
+ for (int i = (int)absolute; i < path.length() + 1; i++) {
if (path[i] == '/' || path[i] == 0) {
diff --git a/core/object.cpp b/core/object.cpp
index 64f55f08a9..ee512ff23c 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -474,7 +474,6 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
if (r_valid)
*r_valid = false;
- return;
}
Variant Object::get(const StringName &p_name, bool *r_valid) const {
@@ -810,11 +809,7 @@ bool Object::has_method(const StringName &p_method) const {
MethodBind *method = ClassDB::get_method(get_class_name(), p_method);
- if (method) {
- return true;
- }
-
- return false;
+ return method != NULL;
}
Variant Object::getvar(const Variant &p_key, bool *r_valid) const {
@@ -1485,7 +1480,7 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str
return OK;
} else {
ERR_EXPLAIN("Signal '" + p_signal + "' is already connected to given method '" + p_to_method + "' in that object.");
- ERR_FAIL_COND_V(s->slot_map.has(target), ERR_INVALID_PARAMETER);
+ ERR_FAIL_V(ERR_INVALID_PARAMETER);
}
}
@@ -1542,11 +1537,11 @@ void Object::_disconnect(const StringName &p_signal, Object *p_to_object, const
Signal *s = signal_map.getptr(p_signal);
if (!s) {
ERR_EXPLAIN("Nonexistent signal: " + p_signal);
- ERR_FAIL_COND(!s);
+ ERR_FAIL();
}
if (s->lock > 0) {
ERR_EXPLAIN("Attempt to disconnect signal '" + p_signal + "' while emitting (locks: " + itos(s->lock) + ")");
- ERR_FAIL_COND(s->lock > 0);
+ ERR_FAIL();
}
Signal::Target target(p_to_object->get_instance_id(), p_to_method);
@@ -1689,7 +1684,7 @@ void Object::clear_internal_resource_paths() {
void Object::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_class"), &Object::get_class);
- ClassDB::bind_method(D_METHOD("is_class", "type"), &Object::is_class);
+ ClassDB::bind_method(D_METHOD("is_class", "class"), &Object::is_class);
ClassDB::bind_method(D_METHOD("set", "property", "value"), &Object::_set_bind);
ClassDB::bind_method(D_METHOD("get", "property"), &Object::_get_bind);
ClassDB::bind_method(D_METHOD("set_indexed", "property", "value"), &Object::_set_indexed_bind);
@@ -1709,14 +1704,8 @@ void Object::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_meta", "name"), &Object::has_meta);
ClassDB::bind_method(D_METHOD("get_meta_list"), &Object::_get_meta_list_bind);
- //todo reimplement this per language so all 5 arguments can be called
-
- //ClassDB::bind_method(D_METHOD("call","method","arg1","arg2","arg3","arg4"),&Object::_call_bind,DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()));
- //ClassDB::bind_method(D_METHOD("call_deferred","method","arg1","arg2","arg3","arg4"),&Object::_call_deferred_bind,DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()));
-
ClassDB::bind_method(D_METHOD("add_user_signal", "signal", "arguments"), &Object::_add_user_signal, DEFVAL(Array()));
ClassDB::bind_method(D_METHOD("has_user_signal", "signal"), &Object::_has_user_signal);
- //ClassDB::bind_method(D_METHOD("emit_signal","signal","arguments"),&Object::_emit_signal,DEFVAL(Array()));
{
MethodInfo mi;
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index d81c30f33a..1c57bfdf3d 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -373,7 +373,7 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag
if (current_is_dir())
dirs.push_back(n);
else {
- String rel_path = n;
+ const String &rel_path = n;
if (!n.is_rel_path()) {
list_dir_end();
return ERR_BUG;
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index 913caf6584..b5580b5c6e 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -601,7 +601,8 @@ Vector<uint8_t> FileAccess::get_file_as_array(const String &p_path, Error *r_err
if (r_error) { // if error requested, do not throw error
return Vector<uint8_t>();
}
- ERR_FAIL_COND_V(!f, Vector<uint8_t>());
+ ERR_EXPLAIN("Can't open file from path: " + String(p_path));
+ ERR_FAIL_V(Vector<uint8_t>());
}
Vector<uint8_t> data;
data.resize(f->get_len());
@@ -621,7 +622,8 @@ String FileAccess::get_file_as_string(const String &p_path, Error *r_error) {
if (r_error) {
return String();
}
- ERR_FAIL_COND_V(err != OK, String());
+ ERR_EXPLAIN("Can't get file as string from path: " + String(p_path));
+ ERR_FAIL_V(String());
}
String ret;
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 9c5066da3d..a40a50cfce 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -314,7 +314,7 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_pressed
if (p_pressed != NULL)
*p_pressed = key->is_pressed();
if (p_strength != NULL)
- *p_strength = (*p_pressed) ? 1.0f : 0.0f;
+ *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f;
}
return match;
}
@@ -483,7 +483,7 @@ bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event, bool *p
if (p_pressed != NULL)
*p_pressed = mb->is_pressed();
if (p_strength != NULL)
- *p_strength = (*p_pressed) ? 1.0f : 0.0f;
+ *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f;
}
return match;
@@ -795,7 +795,7 @@ bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event, bool *
if (p_pressed != NULL)
*p_pressed = jb->is_pressed();
if (p_strength != NULL)
- *p_strength = (*p_pressed) ? 1.0f : 0.0f;
+ *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f;
}
return match;
@@ -1041,7 +1041,7 @@ bool InputEventAction::action_match(const Ref<InputEvent> &p_event, bool *p_pres
if (p_pressed != NULL)
*p_pressed = act->pressed;
if (p_strength != NULL)
- *p_strength = (*p_pressed) ? 1.0f : 0.0f;
+ *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f;
}
return match;
}
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 895ce14ae9..9946ced2f3 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -44,9 +44,9 @@ void MainLoop::_bind_methods() {
BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
BIND_VMETHOD(MethodInfo("_input_text", PropertyInfo(Variant::STRING, "text")));
BIND_VMETHOD(MethodInfo("_initialize"));
- BIND_VMETHOD(MethodInfo("_iteration", PropertyInfo(Variant::REAL, "delta")));
- BIND_VMETHOD(MethodInfo("_idle", PropertyInfo(Variant::REAL, "delta")));
- BIND_VMETHOD(MethodInfo("_drop_files", PropertyInfo(Variant::POOL_STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "screen")));
+ BIND_VMETHOD(MethodInfo(Variant::BOOL, "_iteration", PropertyInfo(Variant::REAL, "delta")));
+ BIND_VMETHOD(MethodInfo(Variant::BOOL, "_idle", PropertyInfo(Variant::REAL, "delta")));
+ BIND_VMETHOD(MethodInfo("_drop_files", PropertyInfo(Variant::POOL_STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "from_screen")));
BIND_VMETHOD(MethodInfo("_finalize"));
BIND_CONSTANT(NOTIFICATION_WM_MOUSE_ENTER);
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 1a3c9ac5f8..027740c6a9 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -239,7 +239,8 @@ void OS::print_all_resources(String p_to_file) {
_OSPRF = FileAccess::open(p_to_file, FileAccess::WRITE, &err);
if (err != OK) {
_OSPRF = NULL;
- ERR_FAIL_COND(err != OK);
+ ERR_EXPLAIN("Can't print all resources to file: " + String(p_to_file));
+ ERR_FAIL();
}
}
diff --git a/core/pool_allocator.cpp b/core/pool_allocator.cpp
index 11a3be89bd..094352b5cc 100644
--- a/core/pool_allocator.cpp
+++ b/core/pool_allocator.cpp
@@ -206,8 +206,8 @@ PoolAllocator::ID PoolAllocator::alloc(int p_size) {
if (!find_hole(&new_entry_indices_pos, size_to_alloc)) {
mt_unlock();
- ERR_PRINT("memory can't be compacted further");
- return POOL_ALLOCATOR_INVALID_ID;
+ ERR_EXPLAIN("Memory can't be compacted further");
+ ERR_FAIL_V(POOL_ALLOCATOR_INVALID_ID);
}
}
@@ -217,7 +217,8 @@ PoolAllocator::ID PoolAllocator::alloc(int p_size) {
if (!found_free_entry) {
mt_unlock();
- ERR_FAIL_COND_V(!found_free_entry, POOL_ALLOCATOR_INVALID_ID);
+ ERR_EXPLAIN("No free entry found in PoolAllocator");
+ ERR_FAIL_V(POOL_ALLOCATOR_INVALID_ID);
}
/* move all entry indices up, make room for this one */
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index 0508806a35..983b2a2576 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -566,7 +566,7 @@ Error ProjectSettings::_load_settings_text(const String p_path) {
if (config_version > CONFIG_VERSION) {
memdelete(f);
ERR_EXPLAIN(vformat("Can't open project at '%s', its `config_version` (%d) is from a more recent and incompatible version of the engine. Expected config version: %d.", p_path, config_version, CONFIG_VERSION));
- ERR_FAIL_COND_V(config_version > CONFIG_VERSION, ERR_FILE_CANT_OPEN);
+ ERR_FAIL_V(ERR_FILE_CANT_OPEN);
}
} else {
if (section == String()) {
diff --git a/core/safe_refcount.h b/core/safe_refcount.h
index f6b8f80271..54f540b0c7 100644
--- a/core/safe_refcount.h
+++ b/core/safe_refcount.h
@@ -189,11 +189,7 @@ public:
_ALWAYS_INLINE_ bool unref() { // true if must be disposed of
- if (atomic_decrement(&count) == 0) {
- return true;
- }
-
- return false;
+ return atomic_decrement(&count) == 0;
}
_ALWAYS_INLINE_ uint32_t get() const { // nothrow
diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp
index f7ca6d3bde..f0c2b8eb9b 100644
--- a/core/undo_redo.cpp
+++ b/core/undo_redo.cpp
@@ -336,6 +336,7 @@ bool UndoRedo::redo() {
_process_operation_list(actions.write[current_action].do_ops.front());
version++;
+ emit_signal("version_changed");
return true;
}
@@ -348,6 +349,8 @@ bool UndoRedo::undo() {
_process_operation_list(actions.write[current_action].undo_ops.front());
current_action--;
version--;
+ emit_signal("version_changed");
+
return true;
}
@@ -359,18 +362,30 @@ void UndoRedo::clear_history(bool p_increase_version) {
while (actions.size())
_pop_history_tail();
- if (p_increase_version)
+ if (p_increase_version) {
version++;
+ emit_signal("version_changed");
+ }
}
String UndoRedo::get_current_action_name() const {
ERR_FAIL_COND_V(action_level > 0, "");
if (current_action < 0)
- return ""; //nothing to redo
+ return "";
return actions[current_action].name;
}
+bool UndoRedo::has_undo() {
+
+ return current_action >= 0;
+}
+
+bool UndoRedo::has_redo() {
+
+ return (current_action + 1) < actions.size();
+}
+
uint64_t UndoRedo::get_version() const {
return version;
@@ -523,10 +538,14 @@ void UndoRedo::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_undo_reference", "object"), &UndoRedo::add_undo_reference);
ClassDB::bind_method(D_METHOD("clear_history", "increase_version"), &UndoRedo::clear_history, DEFVAL(true));
ClassDB::bind_method(D_METHOD("get_current_action_name"), &UndoRedo::get_current_action_name);
+ ClassDB::bind_method(D_METHOD("has_undo"), &UndoRedo::has_undo);
+ ClassDB::bind_method(D_METHOD("has_redo"), &UndoRedo::has_redo);
ClassDB::bind_method(D_METHOD("get_version"), &UndoRedo::get_version);
ClassDB::bind_method(D_METHOD("redo"), &UndoRedo::redo);
ClassDB::bind_method(D_METHOD("undo"), &UndoRedo::undo);
+ ADD_SIGNAL(MethodInfo("version_changed"));
+
BIND_ENUM_CONSTANT(MERGE_DISABLE);
BIND_ENUM_CONSTANT(MERGE_ENDS);
BIND_ENUM_CONSTANT(MERGE_ALL);
diff --git a/core/undo_redo.h b/core/undo_redo.h
index e2cc6c659b..276d00d9af 100644
--- a/core/undo_redo.h
+++ b/core/undo_redo.h
@@ -118,6 +118,9 @@ public:
String get_current_action_name() const;
void clear_history(bool p_increase_version = true);
+ bool has_undo();
+ bool has_redo();
+
uint64_t get_version() const;
void set_commit_notify_callback(CommitNotifyCallback p_callback, void *p_ud);
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 686aa6f8e3..ff28fa420d 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -3799,11 +3799,7 @@ bool String::is_valid_filename() const {
return false;
}
- if (find(":") != -1 || find("/") != -1 || find("\\") != -1 || find("?") != -1 || find("*") != -1 || find("\"") != -1 || find("|") != -1 || find("%") != -1 || find("<") != -1 || find(">") != -1) {
- return false;
- } else {
- return true;
- }
+ return !(find(":") != -1 || find("/") != -1 || find("\\") != -1 || find("?") != -1 || find("*") != -1 || find("\"") != -1 || find("|") != -1 || find("%") != -1 || find("<") != -1 || find(">") != -1);
}
bool String::is_valid_ip_address() const {
@@ -3941,7 +3937,6 @@ String String::percent_decode() const {
uint8_t a = LOWERCASE(cs[i + 1]);
uint8_t b = LOWERCASE(cs[i + 2]);
- c = 0;
if (a >= '0' && a <= '9')
c = (a - '0') << 4;
else if (a >= 'a' && a <= 'f')
diff --git a/core/ustring.h b/core/ustring.h
index ecf934a26b..a32daabb91 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -404,8 +404,6 @@ _FORCE_INLINE_ bool is_str_less(const L *l_ptr, const R *r_ptr) {
l_ptr++;
r_ptr++;
}
-
- CRASH_COND(true); // unreachable
}
/* end of namespace */
diff --git a/core/variant.cpp b/core/variant.cpp
index 6eadf59fce..9306867ac7 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -709,7 +709,7 @@ bool Variant::is_zero() const {
// atomic types
case BOOL: {
- return _data._bool == false;
+ return !(_data._bool);
} break;
case INT: {
diff --git a/core/variant.h b/core/variant.h
index 5151262f27..a8e99c13f1 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -248,8 +248,8 @@ public:
Variant(unsigned short p_short);
Variant(signed char p_char); // real one
Variant(unsigned char p_char);
- Variant(int64_t p_char); // real one
- Variant(uint64_t p_char);
+ Variant(int64_t p_int); // real one
+ Variant(uint64_t p_int);
Variant(float p_float);
Variant(double p_double);
Variant(const String &p_string);
@@ -262,11 +262,11 @@ public:
Variant(const Plane &p_plane);
Variant(const ::AABB &p_aabb);
Variant(const Quat &p_quat);
- Variant(const Basis &p_transform);
+ Variant(const Basis &p_matrix);
Variant(const Transform2D &p_transform);
Variant(const Transform &p_transform);
Variant(const Color &p_color);
- Variant(const NodePath &p_path);
+ Variant(const NodePath &p_node_path);
Variant(const RefPtr &p_resource);
Variant(const RID &p_rid);
Variant(const Object *p_object);
@@ -283,17 +283,17 @@ public:
Variant(const PoolVector<Face3> &p_face_array);
Variant(const Vector<Variant> &p_array);
- Variant(const Vector<uint8_t> &p_raw_array);
- Variant(const Vector<int> &p_int_array);
- Variant(const Vector<real_t> &p_real_array);
- Variant(const Vector<String> &p_string_array);
- Variant(const Vector<StringName> &p_string_array);
- Variant(const Vector<Vector3> &p_vector3_array);
- Variant(const Vector<Color> &p_color_array);
+ Variant(const Vector<uint8_t> &p_array);
+ Variant(const Vector<int> &p_array);
+ Variant(const Vector<real_t> &p_array);
+ Variant(const Vector<String> &p_array);
+ Variant(const Vector<StringName> &p_array);
+ Variant(const Vector<Vector3> &p_array);
+ Variant(const Vector<Color> &p_array);
Variant(const Vector<Plane> &p_array); // helper
Variant(const Vector<RID> &p_array); // helper
Variant(const Vector<Vector2> &p_array); // helper
- Variant(const PoolVector<Vector2> &p_array); // helper
+ Variant(const PoolVector<Vector2> &p_vector2_array); // helper
Variant(const IP_Address &p_address);