summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp3
-rw-r--r--core/bind/core_bind.h1
-rw-r--r--core/cowdata.h5
-rw-r--r--core/dictionary.cpp5
-rw-r--r--core/dictionary.h1
-rw-r--r--core/dvector.h4
-rw-r--r--core/hash_map.h4
-rw-r--r--core/image.cpp17
-rw-r--r--core/io/image_loader.cpp1
-rw-r--r--core/io/logger.cpp4
-rw-r--r--core/io/marshalls.cpp5
-rw-r--r--core/io/multiplayer_api.cpp4
-rw-r--r--core/io/resource_format_binary.cpp2
-rw-r--r--core/io/resource_loader.cpp2
-rw-r--r--core/io/resource_loader.h4
-rw-r--r--core/math/face3.cpp9
-rw-r--r--core/math/math_funcs.h2
-rw-r--r--core/math/matrix3.cpp20
-rw-r--r--core/math/quat.cpp18
-rw-r--r--core/math/quat.h2
-rw-r--r--core/math/vector2.cpp4
-rw-r--r--core/math/vector2.h2
-rw-r--r--core/math/vector3.h6
-rw-r--r--core/oa_hash_map.h4
-rw-r--r--core/os/input.cpp2
-rw-r--r--core/os/memory.cpp2
-rw-r--r--core/os/rw_lock.h4
-rw-r--r--core/rid.h1
-rw-r--r--core/script_debugger_remote.cpp25
-rw-r--r--core/ustring.cpp19
-rw-r--r--core/variant.cpp2
-rw-r--r--core/variant_call.cpp2
-rw-r--r--core/variant_op.cpp12
33 files changed, 123 insertions, 75 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 57654e96dc..a3ff4bf13e 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -180,6 +180,7 @@ void _ResourceSaver::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_OMIT_EDITOR_PROPERTIES);
BIND_ENUM_CONSTANT(FLAG_SAVE_BIG_ENDIAN);
BIND_ENUM_CONSTANT(FLAG_COMPRESS);
+ BIND_ENUM_CONSTANT(FLAG_REPLACE_SUBRESOURCE_PATHS);
}
_ResourceSaver::_ResourceSaver() {
@@ -2487,7 +2488,7 @@ _Thread::~_Thread() {
if (active) {
ERR_EXPLAIN("Reference to a Thread object object was lost while the thread is still running...");
}
- ERR_FAIL_COND(active == true);
+ ERR_FAIL_COND(active);
}
/////////////////////////////////////
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 3a913e01ed..79403879ac 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -80,6 +80,7 @@ public:
FLAG_OMIT_EDITOR_PROPERTIES = 8,
FLAG_SAVE_BIG_ENDIAN = 16,
FLAG_COMPRESS = 32,
+ FLAG_REPLACE_SUBRESOURCE_PATHS = 64,
};
static _ResourceSaver *get_singleton() { return singleton; }
diff --git a/core/cowdata.h b/core/cowdata.h
index 9e75d4ed55..54ece4c856 100644
--- a/core/cowdata.h
+++ b/core/cowdata.h
@@ -87,7 +87,10 @@ private:
#if defined(_add_overflow) && defined(_mul_overflow)
size_t o;
size_t p;
- if (_mul_overflow(p_elements, sizeof(T), &o)) return false;
+ if (_mul_overflow(p_elements, sizeof(T), &o)) {
+ *out = 0;
+ return false;
+ }
*out = next_power_of_2(o);
if (_add_overflow(o, static_cast<size_t>(32), &p)) return false; //no longer allocated here
return true;
diff --git a/core/dictionary.cpp b/core/dictionary.cpp
index ba32606819..ccbdff3816 100644
--- a/core/dictionary.cpp
+++ b/core/dictionary.cpp
@@ -145,6 +145,11 @@ bool Dictionary::operator==(const Dictionary &p_dictionary) const {
return _p == p_dictionary._p;
}
+bool Dictionary::operator!=(const Dictionary &p_dictionary) const {
+
+ return _p != p_dictionary._p;
+}
+
void Dictionary::_ref(const Dictionary &p_from) const {
//make a copy first (thread safe)
diff --git a/core/dictionary.h b/core/dictionary.h
index 9950fb6361..d3b98c2f63 100644
--- a/core/dictionary.h
+++ b/core/dictionary.h
@@ -69,6 +69,7 @@ public:
bool erase(const Variant &p_key);
bool operator==(const Dictionary &p_dictionary) const;
+ bool operator!=(const Dictionary &p_dictionary) const;
uint32_t hash() const;
void operator=(const Dictionary &p_dictionary);
diff --git a/core/dvector.h b/core/dvector.h
index 0d0848a19a..2830c57ec0 100644
--- a/core/dvector.h
+++ b/core/dvector.h
@@ -149,7 +149,7 @@ class PoolVector {
}
}
- if (old_alloc->refcount.unref() == true) {
+ if (old_alloc->refcount.unref()) {
//this should never happen but..
#ifdef DEBUG_ENABLED
@@ -209,7 +209,7 @@ class PoolVector {
if (!alloc)
return;
- if (alloc->refcount.unref() == false) {
+ if (!alloc->refcount.unref()) {
alloc = NULL;
return;
}
diff --git a/core/hash_map.h b/core/hash_map.h
index 8620edba73..3869cd3c36 100644
--- a/core/hash_map.h
+++ b/core/hash_map.h
@@ -150,7 +150,7 @@ private:
if (new_hash_table_power == -1)
return;
- Element **new_hash_table = memnew_arr(Element *, (1 << new_hash_table_power));
+ Element **new_hash_table = memnew_arr(Element *, ((uint64_t)1 << new_hash_table_power));
if (!new_hash_table) {
ERR_PRINT("Out of Memory");
@@ -230,7 +230,7 @@ private:
if (!p_t.hash_table || p_t.hash_table_power == 0)
return; /* not copying from empty table */
- hash_table = memnew_arr(Element *, 1 << p_t.hash_table_power);
+ hash_table = memnew_arr(Element *, (uint64_t)1 << p_t.hash_table_power);
hash_table_power = p_t.hash_table_power;
elements = p_t.elements;
diff --git a/core/image.cpp b/core/image.cpp
index e90ed96499..172f5e517a 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -780,9 +780,9 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
// Setup mipmap-aware scaling
Image dst2;
- int mip1;
- int mip2;
- float mip1_weight;
+ int mip1 = 0;
+ int mip2 = 0;
+ float mip1_weight = 0;
if (mipmap_aware) {
float avg_scale = ((float)p_width / width + (float)p_height / height) * 0.5f;
if (avg_scale >= 1.0f) {
@@ -1198,7 +1198,9 @@ void Image::expand_x2_hq2x() {
if (current != FORMAT_RGBA8)
convert(current);
- if (used_mipmaps) {
+ // FIXME: This is likely meant to use "used_mipmaps" as defined above, but if we do,
+ // we end up with a regression: GH-22747
+ if (mipmaps) {
generate_mipmaps();
}
}
@@ -1471,7 +1473,8 @@ void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_forma
void Image::create(const char **p_xpm) {
- int size_width, size_height;
+ int size_width = 0;
+ int size_height = 0;
int pixelchars = 0;
mipmaps = false;
bool has_alpha = false;
@@ -1487,8 +1490,8 @@ void Image::create(const char **p_xpm) {
int line = 0;
HashMap<String, Color> colormap;
- int colormap_size;
- uint32_t pixel_size;
+ int colormap_size = 0;
+ uint32_t pixel_size = 0;
PoolVector<uint8_t>::Write w;
while (status != DONE) {
diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp
index f202320043..3ae9ff676c 100644
--- a/core/io/image_loader.cpp
+++ b/core/io/image_loader.cpp
@@ -118,7 +118,6 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String &p_origin
if (r_error) {
*r_error = ERR_CANT_OPEN;
}
- memdelete(f);
return RES();
}
diff --git a/core/io/logger.cpp b/core/io/logger.cpp
index 051c02ab32..01755c8ee9 100644
--- a/core/io/logger.cpp
+++ b/core/io/logger.cpp
@@ -45,6 +45,10 @@
#endif
#endif
+#if defined(MINGW_ENABLED) || defined(_MSC_VER)
+#define sprintf sprintf_s
+#endif
+
bool Logger::should_log(bool p_err) {
return (!p_err || _print_error_enabled) && (p_err || _print_line_enabled);
}
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index ec430d41a9..6338cee39d 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -850,17 +850,16 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::INT: {
- int64_t val = p_variant;
if (flags & ENCODE_FLAG_64) {
//64 bits
if (buf) {
- encode_uint64(val, buf);
+ encode_uint64(p_variant.operator int64_t(), buf);
}
r_len += 8;
} else {
if (buf) {
- encode_uint32(int32_t(val), buf);
+ encode_uint32(p_variant.operator int32_t(), buf);
}
r_len += 4;
diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp
index 17b77bc535..b3f0a76a80 100644
--- a/core/io/multiplayer_api.cpp
+++ b/core/io/multiplayer_api.cpp
@@ -416,7 +416,7 @@ bool MultiplayerAPI::_send_confirm_path(NodePath p_path, PathSentCache *psc, int
Map<int, bool>::Element *F = psc->confirmed_peers.find(E->get());
- if (!F || F->get() == false) {
+ if (!F || !F->get()) {
// Path was not cached, or was cached but is unconfirmed.
if (!F) {
// Not cached at all, take note.
@@ -578,7 +578,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p
network_peer->set_target_peer(E->get()); // To this one specifically.
- if (F->get() == true) {
+ if (F->get()) {
// This one confirmed path, so use id.
encode_uint32(psc->id, &(packet_cache.write[1]));
network_peer->put_packet(packet_cache.ptr(), ofs);
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index e5741014a4..aa73d7bc5c 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -1309,7 +1309,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
case Variant::INT: {
int64_t val = p_property;
- if (val > 0x7FFFFFFF || val < -0x80000000) {
+ if (val > 0x7FFFFFFF || val < -(int64_t)0x80000000) {
f->store_32(VARIANT_INT64);
f->store_64(val);
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 8c56d55e85..d156a9f4bd 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -647,3 +647,5 @@ bool ResourceLoader::timestamp_on_load = false;
SelfList<Resource>::List ResourceLoader::remapped_list;
HashMap<String, Vector<String> > ResourceLoader::translation_remaps;
HashMap<String, String> ResourceLoader::path_remaps;
+
+ResourceLoaderImport ResourceLoader::import = NULL;
diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h
index de0981350d..96bc6fa8dd 100644
--- a/core/io/resource_loader.h
+++ b/core/io/resource_loader.h
@@ -77,6 +77,8 @@ public:
typedef void (*ResourceLoadErrorNotify)(void *p_ud, const String &p_text);
typedef void (*DependencyErrorNotify)(void *p_ud, const String &p_loading, const String &p_which, const String &p_type);
+typedef Error (*ResourceLoaderImport)(const String &p_path);
+
class ResourceLoader {
enum {
@@ -147,6 +149,8 @@ public:
static void reload_translation_remaps();
static void load_translation_remaps();
static void clear_translation_remaps();
+
+ static ResourceLoaderImport import;
};
#endif
diff --git a/core/math/face3.cpp b/core/math/face3.cpp
index aa46fde7f7..8366137131 100644
--- a/core/math/face3.cpp
+++ b/core/math/face3.cpp
@@ -202,11 +202,12 @@ bool Face3::intersects_aabb(const AABB &p_aabb) const {
{ \
real_t aabb_min = p_aabb.position.m_ax; \
real_t aabb_max = p_aabb.position.m_ax + p_aabb.size.m_ax; \
- real_t tri_min, tri_max; \
- for (int i = 0; i < 3; i++) { \
- if (i == 0 || vertex[i].m_ax > tri_max) \
+ real_t tri_min = vertex[0].m_ax; \
+ real_t tri_max = vertex[0].m_ax; \
+ for (int i = 1; i < 3; i++) { \
+ if (vertex[i].m_ax > tri_max) \
tri_max = vertex[i].m_ax; \
- if (i == 0 || vertex[i].m_ax < tri_min) \
+ if (vertex[i].m_ax < tri_min) \
tri_min = vertex[i].m_ax; \
} \
\
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 472baf0484..9a486a49d0 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -46,7 +46,7 @@ class Math {
public:
Math() {} // useless to instance
- static const uint64_t RANDOM_MAX = 4294967295;
+ static const uint64_t RANDOM_MAX = 0xFFFFFFFF;
static _ALWAYS_INLINE_ double sin(double p_x) { return ::sin(p_x); }
static _ALWAYS_INLINE_ float sin(float p_x) { return ::sinf(p_x); }
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index fca54b1556..925a7b3f1e 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -299,14 +299,14 @@ Vector3 Basis::rotref_posscale_decomposition(Basis &rotref) const {
ERR_FAIL_COND_V(determinant() == 0, Vector3());
Basis m = transposed() * (*this);
- ERR_FAIL_COND_V(m.is_diagonal() == false, Vector3());
+ ERR_FAIL_COND_V(!m.is_diagonal(), Vector3());
#endif
Vector3 scale = get_scale();
Basis inv_scale = Basis().scaled(scale.inverse()); // this will also absorb the sign of scale
rotref = (*this) * inv_scale;
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(rotref.is_orthogonal() == false, Vector3());
+ ERR_FAIL_COND_V(!rotref.is_orthogonal(), Vector3());
#endif
return scale.abs();
}
@@ -430,7 +430,7 @@ Vector3 Basis::get_euler_xyz() const {
Vector3 euler;
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_rotation() == false, euler);
+ ERR_FAIL_COND_V(!is_rotation(), euler);
#endif
real_t sy = elements[0][2];
if (sy < 1.0) {
@@ -497,7 +497,7 @@ Vector3 Basis::get_euler_yxz() const {
Vector3 euler;
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_rotation() == false, euler);
+ ERR_FAIL_COND_V(!is_rotation(), euler);
#endif
real_t m12 = elements[1][2];
@@ -556,7 +556,7 @@ bool Basis::is_equal_approx(const Basis &a, const Basis &b) const {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
- if (Math::is_equal_approx(a.elements[i][j], b.elements[i][j]) == false)
+ if (!Math::is_equal_approx(a.elements[i][j], b.elements[i][j]))
return false;
}
}
@@ -600,7 +600,7 @@ Basis::operator String() const {
Quat Basis::get_quat() const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_rotation() == false, Quat());
+ ERR_FAIL_COND_V(!is_rotation(), Quat());
#endif
real_t trace = elements[0][0] + elements[1][1] + elements[2][2];
real_t temp[4];
@@ -697,7 +697,7 @@ void Basis::set_orthogonal_index(int p_index) {
void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND(is_rotation() == false);
+ ERR_FAIL_COND(!is_rotation());
#endif
real_t angle, x, y, z; // variables for result
real_t epsilon = 0.01; // margin to allow for rounding errors
@@ -785,7 +785,7 @@ void Basis::set_quat(const Quat &p_quat) {
void Basis::set_axis_angle(const Vector3 &p_axis, real_t p_phi) {
// Rotation matrix from axis and angle, see https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_angle
#ifdef MATH_CHECKS
- ERR_FAIL_COND(p_axis.is_normalized() == false);
+ ERR_FAIL_COND(!p_axis.is_normalized());
#endif
Vector3 axis_sq(p_axis.x * p_axis.x, p_axis.y * p_axis.y, p_axis.z * p_axis.z);
@@ -837,8 +837,8 @@ void Basis::set_diagonal(const Vector3 p_diag) {
Basis Basis::slerp(const Basis &target, const real_t &t) const {
// TODO: implement this directly without using quaternions to make it more efficient
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_rotation() == false, Basis());
- ERR_FAIL_COND_V(target.is_rotation() == false, Basis());
+ ERR_FAIL_COND_V(!is_rotation(), Basis());
+ ERR_FAIL_COND_V(!target.is_rotation(), Basis());
#endif
Quat from(*this);
diff --git a/core/math/quat.cpp b/core/math/quat.cpp
index d660ce4553..791e84f089 100644
--- a/core/math/quat.cpp
+++ b/core/math/quat.cpp
@@ -100,7 +100,7 @@ void Quat::set_euler_yxz(const Vector3 &p_euler) {
// This implementation uses YXZ convention (Z is the first rotation).
Vector3 Quat::get_euler_yxz() const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, Vector3(0, 0, 0));
+ ERR_FAIL_COND_V(!is_normalized(), Vector3(0, 0, 0));
#endif
Basis m(*this);
return m.get_euler_yxz();
@@ -140,15 +140,15 @@ bool Quat::is_normalized() const {
Quat Quat::inverse() const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, Quat());
+ ERR_FAIL_COND_V(!is_normalized(), Quat());
#endif
return Quat(-x, -y, -z, w);
}
Quat Quat::slerp(const Quat &q, const real_t &t) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, Quat());
- ERR_FAIL_COND_V(q.is_normalized() == false, Quat());
+ ERR_FAIL_COND_V(!is_normalized(), Quat());
+ ERR_FAIL_COND_V(!q.is_normalized(), Quat());
#endif
Quat to1;
real_t omega, cosom, sinom, scale0, scale1;
@@ -194,8 +194,8 @@ Quat Quat::slerp(const Quat &q, const real_t &t) const {
Quat Quat::slerpni(const Quat &q, const real_t &t) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, Quat());
- ERR_FAIL_COND_V(q.is_normalized() == false, Quat());
+ ERR_FAIL_COND_V(!is_normalized(), Quat());
+ ERR_FAIL_COND_V(!q.is_normalized(), Quat());
#endif
const Quat &from = *this;
@@ -216,8 +216,8 @@ Quat Quat::slerpni(const Quat &q, const real_t &t) const {
Quat Quat::cubic_slerp(const Quat &q, const Quat &prep, const Quat &postq, const real_t &t) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, Quat());
- ERR_FAIL_COND_V(q.is_normalized() == false, Quat());
+ ERR_FAIL_COND_V(!is_normalized(), Quat());
+ ERR_FAIL_COND_V(!q.is_normalized(), Quat());
#endif
//the only way to do slerp :|
real_t t2 = (1.0 - t) * t * 2;
@@ -233,7 +233,7 @@ Quat::operator String() const {
void Quat::set_axis_angle(const Vector3 &axis, const real_t &angle) {
#ifdef MATH_CHECKS
- ERR_FAIL_COND(axis.is_normalized() == false);
+ ERR_FAIL_COND(!axis.is_normalized());
#endif
real_t d = axis.length();
if (d == 0)
diff --git a/core/math/quat.h b/core/math/quat.h
index 10d3846c87..c4f9b3a732 100644
--- a/core/math/quat.h
+++ b/core/math/quat.h
@@ -87,7 +87,7 @@ public:
_FORCE_INLINE_ Vector3 xform(const Vector3 &v) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, v);
+ ERR_FAIL_COND_V(!is_normalized(), v);
#endif
Vector3 u(x, y, z);
Vector3 uv = u.cross(v);
diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp
index 84c9f0fca6..7c6f056f09 100644
--- a/core/math/vector2.cpp
+++ b/core/math/vector2.cpp
@@ -167,7 +167,7 @@ Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, c
// slide returns the component of the vector along the given plane, specified by its normal vector.
Vector2 Vector2::slide(const Vector2 &p_normal) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector2());
+ ERR_FAIL_COND_V(!p_normal.is_normalized(), Vector2());
#endif
return *this - p_normal * this->dot(p_normal);
}
@@ -178,7 +178,7 @@ Vector2 Vector2::bounce(const Vector2 &p_normal) const {
Vector2 Vector2::reflect(const Vector2 &p_normal) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector2());
+ ERR_FAIL_COND_V(!p_normal.is_normalized(), Vector2());
#endif
return 2.0 * p_normal * this->dot(p_normal) - *this;
}
diff --git a/core/math/vector2.h b/core/math/vector2.h
index df49484aaf..e5e555597d 100644
--- a/core/math/vector2.h
+++ b/core/math/vector2.h
@@ -230,7 +230,7 @@ Vector2 Vector2::linear_interpolate(const Vector2 &p_b, real_t p_t) const {
Vector2 Vector2::slerp(const Vector2 &p_b, real_t p_t) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, Vector2());
+ ERR_FAIL_COND_V(!is_normalized(), Vector2());
#endif
real_t theta = angle_to(p_b);
return rotated(theta * p_t);
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 5302832eeb..16feba6a0c 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -218,7 +218,7 @@ Vector3 Vector3::linear_interpolate(const Vector3 &p_b, real_t p_t) const {
Vector3 Vector3::slerp(const Vector3 &p_b, real_t p_t) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(is_normalized() == false, Vector3());
+ ERR_FAIL_COND_V(!is_normalized(), Vector3());
#endif
real_t theta = angle_to(p_b);
@@ -430,7 +430,7 @@ void Vector3::zero() {
// slide returns the component of the vector along the given plane, specified by its normal vector.
Vector3 Vector3::slide(const Vector3 &p_normal) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector3());
+ ERR_FAIL_COND_V(!p_normal.is_normalized(), Vector3());
#endif
return *this - p_normal * this->dot(p_normal);
}
@@ -441,7 +441,7 @@ Vector3 Vector3::bounce(const Vector3 &p_normal) const {
Vector3 Vector3::reflect(const Vector3 &p_normal) const {
#ifdef MATH_CHECKS
- ERR_FAIL_COND_V(p_normal.is_normalized() == false, Vector3());
+ ERR_FAIL_COND_V(!p_normal.is_normalized(), Vector3());
#endif
return 2.0 * p_normal * this->dot(p_normal) - *this;
}
diff --git a/core/oa_hash_map.h b/core/oa_hash_map.h
index 3705762d6c..9840442519 100644
--- a/core/oa_hash_map.h
+++ b/core/oa_hash_map.h
@@ -125,7 +125,7 @@ private:
while (42) {
if (hashes[pos] == EMPTY_HASH) {
- _construct(pos, hash, p_key, p_value);
+ _construct(pos, hash, key, value);
return;
}
@@ -136,7 +136,7 @@ private:
if (hashes[pos] & DELETED_HASH_BIT) {
// we found a place where we can fit in!
- _construct(pos, hash, p_key, p_value);
+ _construct(pos, hash, key, value);
return;
}
diff --git a/core/os/input.cpp b/core/os/input.cpp
index 6830df7e81..4cd1f0b24a 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -42,7 +42,7 @@ Input *Input::get_singleton() {
}
void Input::set_mouse_mode(MouseMode p_mode) {
- ERR_FAIL_INDEX(p_mode, 4);
+ ERR_FAIL_INDEX((int)p_mode, 4);
OS::get_singleton()->set_mouse_mode((OS::MouseMode)p_mode);
}
diff --git a/core/os/memory.cpp b/core/os/memory.cpp
index 041371a6e2..f25e40ef78 100644
--- a/core/os/memory.cpp
+++ b/core/os/memory.cpp
@@ -172,9 +172,9 @@ void Memory::free_static(void *p_ptr, bool p_pad_align) {
if (prepad) {
mem -= PAD_ALIGN;
- uint64_t *s = (uint64_t *)mem;
#ifdef DEBUG_ENABLED
+ uint64_t *s = (uint64_t *)mem;
atomic_sub(&mem_usage, *s);
#endif
diff --git a/core/os/rw_lock.h b/core/os/rw_lock.h
index 8d1029723b..4333d9a016 100644
--- a/core/os/rw_lock.h
+++ b/core/os/rw_lock.h
@@ -57,9 +57,7 @@ class RWLockRead {
public:
RWLockRead(const RWLock *p_lock) {
- if (p_lock) {
- lock = const_cast<RWLock *>(p_lock);
- }
+ lock = const_cast<RWLock *>(p_lock);
if (lock) lock->read_lock();
}
~RWLockRead() {
diff --git a/core/rid.h b/core/rid.h
index fbb3e443fc..81d5b45d21 100644
--- a/core/rid.h
+++ b/core/rid.h
@@ -118,7 +118,6 @@ protected:
p_rid._data->_owner = NULL;
}
-#
#endif
public:
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 388e3b77a3..3e984fae32 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -578,8 +578,14 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
for (ScriptConstantsMap::Element *sc = constants.front(); sc; sc = sc->next()) {
for (Map<StringName, Variant>::Element *E = sc->get().front(); E; E = E->next()) {
String script_path = sc->key() == si->get_script().ptr() ? "" : sc->key()->get_path().get_file() + "/";
- PropertyInfo pi(E->value().get_type(), "Constants/" + script_path + E->key());
- properties.push_back(PropertyDesc(pi, E->value()));
+ if (E->value().get_type() == Variant::OBJECT) {
+ Variant id = ((Object *)E->value())->get_instance_id();
+ PropertyInfo pi(id.get_type(), "Constants/" + E->key(), PROPERTY_HINT_OBJECT_ID, "Object");
+ properties.push_back(PropertyDesc(pi, id));
+ } else {
+ PropertyInfo pi(E->value().get_type(), "Constants/" + script_path + E->key());
+ properties.push_back(PropertyDesc(pi, E->value()));
+ }
}
}
}
@@ -592,8 +598,14 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
Map<StringName, Variant> constants;
s->get_constants(&constants);
for (Map<StringName, Variant>::Element *E = constants.front(); E; E = E->next()) {
- PropertyInfo pi(E->value().get_type(), String("Constants/") + E->key());
- properties.push_front(PropertyDesc(pi, E->value()));
+ if (E->value().get_type() == Variant::OBJECT) {
+ Variant id = ((Object *)E->value())->get_instance_id();
+ PropertyInfo pi(id.get_type(), "Constants/" + E->key(), PROPERTY_HINT_OBJECT_ID, "Object");
+ properties.push_front(PropertyDesc(pi, E->value()));
+ } else {
+ PropertyInfo pi(E->value().get_type(), String("Constants/") + E->key());
+ properties.push_front(PropertyDesc(pi, E->value()));
+ }
}
}
}
@@ -634,10 +646,9 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
prop.push_back(pi.hint);
prop.push_back(pi.hint_string);
prop.push_back(pi.usage);
+
if (!res.is_null()) {
- var = String("PATH") + res->get_path();
- } else if (var.get_type() == Variant::STRING) {
- var = String("DATA") + var;
+ var = res->get_path();
}
prop.push_back(var);
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 3f073b181f..1195cd0719 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -49,7 +49,7 @@
#endif
#if defined(MINGW_ENABLED) || defined(_MSC_VER)
-#define snprintf _snprintf
+#define snprintf _snprintf_s
#endif
#define MAX_DIGITS 6
@@ -586,6 +586,8 @@ String String::camelcase_to_underscore(bool lowercase) const {
bool is_upper = cstr[i] >= A && cstr[i] <= Z;
bool is_number = cstr[i] >= '0' && cstr[i] <= '9';
bool are_next_2_lower = false;
+ bool is_next_lower = false;
+ bool is_next_number = false;
bool was_precedent_upper = cstr[i - 1] >= A && cstr[i - 1] <= Z;
bool was_precedent_number = cstr[i - 1] >= '0' && cstr[i - 1] <= '9';
@@ -593,7 +595,18 @@ String String::camelcase_to_underscore(bool lowercase) const {
are_next_2_lower = cstr[i + 1] >= a && cstr[i + 1] <= z && cstr[i + 2] >= a && cstr[i + 2] <= z;
}
- bool should_split = ((is_upper && !was_precedent_upper && !was_precedent_number) || (was_precedent_upper && is_upper && are_next_2_lower) || (is_number && !was_precedent_number));
+ if (i + 1 < this->size()) {
+ is_next_lower = cstr[i + 1] >= a && cstr[i + 1] <= z;
+ is_next_number = cstr[i + 1] >= '0' && cstr[i + 1] <= '9';
+ }
+
+ const bool a = is_upper && !was_precedent_upper && !was_precedent_number;
+ const bool b = was_precedent_upper && is_upper && are_next_2_lower;
+ const bool c = is_number && !was_precedent_number;
+ const bool can_break_number_letter = is_number && !was_precedent_number && is_next_lower;
+ const bool can_break_letter_number = !is_number && was_precedent_number && (is_next_lower || is_next_number);
+
+ bool should_split = a || b || c || can_break_number_letter || can_break_letter_number;
if (should_split) {
new_string += this->substr(start_index, i - start_index) + "_";
start_index = i;
@@ -3092,7 +3105,7 @@ String String::simplify_path() const {
} else if (s.begins_with("user://")) {
drive = "user://";
- s = s.substr(6, s.length());
+ s = s.substr(7, s.length());
} else if (s.begins_with("/") || s.begins_with("\\")) {
drive = s.substr(0, 1);
diff --git a/core/variant.cpp b/core/variant.cpp
index 7d75c2243b..edbe66ba31 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -858,7 +858,7 @@ bool Variant::is_one() const {
// atomic types
case BOOL: {
- return _data._bool == true;
+ return _data._bool;
} break;
case INT: {
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index f7fa2ebc70..8693a584f2 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -1895,6 +1895,7 @@ void register_variant_methods() {
_VariantCall::add_constant(Variant::VECTOR3, "AXIS_Z", Vector3::AXIS_Z);
_VariantCall::add_variant_constant(Variant::VECTOR3, "ZERO", Vector3(0, 0, 0));
+ _VariantCall::add_variant_constant(Variant::VECTOR3, "ONE", Vector3(1, 1, 1));
_VariantCall::add_variant_constant(Variant::VECTOR3, "INF", Vector3(Math_INF, Math_INF, Math_INF));
_VariantCall::add_variant_constant(Variant::VECTOR3, "LEFT", Vector3(-1, 0, 0));
_VariantCall::add_variant_constant(Variant::VECTOR3, "RIGHT", Vector3(1, 0, 0));
@@ -1904,6 +1905,7 @@ void register_variant_methods() {
_VariantCall::add_variant_constant(Variant::VECTOR3, "BACK", Vector3(0, 0, 1));
_VariantCall::add_variant_constant(Variant::VECTOR2, "ZERO", Vector2(0, 0));
+ _VariantCall::add_variant_constant(Variant::VECTOR2, "ONE", Vector2(1, 1));
_VariantCall::add_variant_constant(Variant::VECTOR2, "INF", Vector2(Math_INF, Math_INF));
_VariantCall::add_variant_constant(Variant::VECTOR2, "LEFT", Vector2(-1, 0));
_VariantCall::add_variant_constant(Variant::VECTOR2, "RIGHT", Vector2(1, 0));
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 9afc31a772..d193858966 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -521,7 +521,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
const Dictionary *arr_a = reinterpret_cast<const Dictionary *>(p_a._data._mem);
const Dictionary *arr_b = reinterpret_cast<const Dictionary *>(p_b._data._mem);
- _RETURN((*arr_a == *arr_b) == false);
+ _RETURN(*arr_a != *arr_b);
}
CASE_TYPE(math, OP_NOT_EQUAL, ARRAY) {
@@ -3521,7 +3521,7 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
//not as efficient but..
real_t va = a;
real_t vb = b;
- r_dst = (1.0 - c) * va + vb * c;
+ r_dst = va + (vb - va) * c;
} else {
r_dst = a;
@@ -3542,13 +3542,13 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
case INT: {
int64_t va = a._data._int;
int64_t vb = b._data._int;
- r_dst = int((1.0 - c) * va + vb * c);
+ r_dst = int(va + (vb - va) * c);
}
return;
case REAL: {
real_t va = a._data._real;
real_t vb = b._data._real;
- r_dst = (1.0 - c) * va + vb * c;
+ r_dst = va + (vb - va) * c;
}
return;
case STRING: {
@@ -3556,7 +3556,9 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
String sa = *reinterpret_cast<const String *>(a._data._mem);
String sb = *reinterpret_cast<const String *>(b._data._mem);
String dst;
- int csize = sb.length() * c + sa.length() * (1.0 - c);
+ int sa_len = sa.length();
+ int sb_len = sb.length();
+ int csize = sa_len + (sb_len - sa_len) * c;
if (csize == 0) {
r_dst = "";
return;