summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/array.cpp1
-rw-r--r--core/class_db.cpp4
-rw-r--r--core/image.cpp39
-rw-r--r--core/io/compression.cpp2
-rw-r--r--core/io/file_access_pack.cpp4
-rw-r--r--core/io/image_loader.cpp1
-rw-r--r--core/io/marshalls.cpp2
-rw-r--r--core/io/resource_loader.cpp2
-rw-r--r--core/io/resource_loader.h4
-rw-r--r--core/math/bsp_tree.cpp5
-rw-r--r--core/math/math_funcs.h2
-rw-r--r--core/os/input.cpp2
-rw-r--r--core/os/memory.cpp2
-rw-r--r--core/rid.h1
-rw-r--r--core/ustring.cpp4
15 files changed, 42 insertions, 33 deletions
diff --git a/core/array.cpp b/core/array.cpp
index 9708452850..9f09ddbe15 100644
--- a/core/array.cpp
+++ b/core/array.cpp
@@ -258,6 +258,7 @@ struct _ArrayVariantSortCustom {
Array &Array::sort_custom(Object *p_obj, const StringName &p_function) {
ERR_FAIL_NULL_V(p_obj, *this);
+ ERR_FAIL_COND_V(!p_obj->has_method(p_function), *this);
SortArray<Variant, _ArrayVariantSortCustom, true> avs;
avs.compare.obj = p_obj;
diff --git a/core/class_db.cpp b/core/class_db.cpp
index dcc07f8f41..71809d5454 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -809,10 +809,10 @@ void ClassDB::add_signal(StringName p_class, const MethodInfo &p_signal) {
ClassInfo *type = classes.getptr(p_class);
ERR_FAIL_COND(!type);
- ClassInfo *check = type;
StringName sname = p_signal.name;
-#ifdef DEBUG_METHODS_ENABLED
+#ifdef DEBUG_METHODS_ENABLED
+ ClassInfo *check = type;
while (check) {
if (check->signal_map.has(sname)) {
ERR_EXPLAIN("Type " + String(p_class) + " already has signal: " + String(sname));
diff --git a/core/image.cpp b/core/image.cpp
index c0002e0cd6..3d85bdd345 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -307,6 +307,7 @@ void Image::_get_mipmap_offset_and_size(int p_mipmap, int &r_offset, int &r_widt
r_width = w;
r_height = h;
}
+
int Image::get_mipmap_offset(int p_mipmap) const {
ERR_FAIL_INDEX_V(p_mipmap, get_mipmap_count() + 1, -1);
@@ -499,8 +500,6 @@ void Image::convert(Format p_new_format) {
bool gen_mipmaps = mipmaps;
- //mipmaps=false;
-
_copy_internals_from(new_img);
if (gen_mipmaps)
@@ -781,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) {
@@ -799,6 +798,7 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
if (interpolate_mipmaps) {
dst2.create(p_width, p_height, 0, format);
}
+
bool had_mipmaps = mipmaps;
if (interpolate_mipmaps && !had_mipmaps) {
generate_mipmaps();
@@ -951,6 +951,7 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
}
void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) {
+
if (!_can_modify(format)) {
ERR_EXPLAIN("Cannot crop in indexed, compressed or custom image formats.");
ERR_FAIL();
@@ -996,7 +997,7 @@ void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) {
}
}
- if (mipmaps > 0)
+ if (has_mipmaps())
dst.generate_mipmaps();
_copy_internals_from(dst);
}
@@ -1013,10 +1014,10 @@ void Image::flip_y() {
ERR_FAIL();
}
- bool gm = mipmaps;
-
- if (gm)
+ bool used_mipmaps = has_mipmaps();
+ if (used_mipmaps) {
clear_mipmaps();
+ }
{
PoolVector<uint8_t>::Write w = data.write();
@@ -1037,8 +1038,9 @@ void Image::flip_y() {
}
}
- if (gm)
+ if (used_mipmaps) {
generate_mipmaps();
+ }
}
void Image::flip_x() {
@@ -1048,9 +1050,10 @@ void Image::flip_x() {
ERR_FAIL();
}
- bool gm = mipmaps;
- if (gm)
+ bool used_mipmaps = has_mipmaps();
+ if (used_mipmaps) {
clear_mipmaps();
+ }
{
PoolVector<uint8_t>::Write w = data.write();
@@ -1071,8 +1074,9 @@ void Image::flip_x() {
}
}
- if (gm)
+ if (used_mipmaps) {
generate_mipmaps();
+ }
}
int Image::_get_dst_image_size(int p_width, int p_height, Format p_format, int &r_mipmaps, int p_mipmaps) {
@@ -1167,12 +1171,13 @@ void Image::expand_x2_hq2x() {
ERR_FAIL_COND(!_can_modify(format));
- Format current = format;
- bool mm = has_mipmaps();
- if (mm) {
+ bool used_mipmaps = has_mipmaps();
+ if (used_mipmaps) {
clear_mipmaps();
}
+ Format current = format;
+
if (current != FORMAT_RGBA8)
convert(FORMAT_RGBA8);
@@ -1193,6 +1198,8 @@ void Image::expand_x2_hq2x() {
if (current != FORMAT_RGBA8)
convert(current);
+ // 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();
}
diff --git a/core/io/compression.cpp b/core/io/compression.cpp
index e456a85c65..3c0b6541bd 100644
--- a/core/io/compression.cpp
+++ b/core/io/compression.cpp
@@ -175,7 +175,7 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p
} break;
case MODE_ZSTD: {
ZSTD_DCtx *dctx = ZSTD_createDCtx();
- if (zstd_long_distance_matching) ZSTD_DCtx_setMaxWindowSize(dctx, 1 << zstd_window_log_size);
+ if (zstd_long_distance_matching) ZSTD_DCtx_setMaxWindowSize(dctx, (size_t)1 << zstd_window_log_size);
int ret = ZSTD_decompressDCtx(dctx, p_dst, p_dst_max_size, p_src, p_src_size);
ZSTD_freeDCtx(dctx);
return ret;
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index e3c8fb9eb8..40f756ba9a 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -169,11 +169,11 @@ bool PackedSourcePCK::try_open_pack(const String &p_path) {
uint32_t version = f->get_32();
uint32_t ver_major = f->get_32();
uint32_t ver_minor = f->get_32();
- uint32_t ver_rev = f->get_32();
+ f->get_32(); // ver_rev
ERR_EXPLAIN("Pack version unsupported: " + itos(version));
ERR_FAIL_COND_V(version != PACK_VERSION, false);
- ERR_EXPLAIN("Pack created with a newer version of the engine: " + itos(ver_major) + "." + itos(ver_minor) + "." + itos(ver_rev));
+ ERR_EXPLAIN("Pack created with a newer version of the engine: " + itos(ver_major) + "." + itos(ver_minor));
ERR_FAIL_COND_V(ver_major > VERSION_MAJOR || (ver_major == VERSION_MAJOR && ver_minor > VERSION_MINOR), false);
for (int i = 0; i < 16; i++) {
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/marshalls.cpp b/core/io/marshalls.cpp
index 628019ef7f..ec430d41a9 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -868,8 +868,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
} break;
case Variant::REAL: {
- double d = p_variant;
- float f = d;
if (flags & ENCODE_FLAG_64) {
if (buf) {
encode_double(p_variant.operator double(), buf);
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/bsp_tree.cpp b/core/math/bsp_tree.cpp
index 6e51c56357..6ffc963783 100644
--- a/core/math/bsp_tree.cpp
+++ b/core/math/bsp_tree.cpp
@@ -165,7 +165,6 @@ int BSP_Tree::get_points_inside(const Vector3 *p_points, int p_point_count) cons
int pass_count = 0;
const Node *nodesptr = &nodes[0];
const Plane *planesptr = &planes[0];
- int plane_count = planes.size();
int node_count = nodes.size();
if (node_count == 0) // no nodes!
@@ -192,9 +191,9 @@ int BSP_Tree::get_points_inside(const Vector3 *p_points, int p_point_count) cons
break;
}
- uint16_t plane = nodesptr[idx].plane;
#ifdef DEBUG_ENABLED
-
+ int plane_count = planes.size();
+ uint16_t plane = nodesptr[idx].plane;
ERR_FAIL_INDEX_V(plane, plane_count, false);
#endif
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/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/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/ustring.cpp b/core/ustring.cpp
index e46896ca85..3f073b181f 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -1828,8 +1828,8 @@ static double built_in_strtod(const C *string, /* A decimal ASCII floating-point
int sign, expSign = false;
double fraction, dblExp;
const double *d;
- register const C *p;
- register int c;
+ const C *p;
+ int c;
int exp = 0; /* Exponent read from "EX" field. */
int fracExp = 0; /* Exponent that derives from the fractional
* part. Under normal circumstances, it is