Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Make conversion from int types to `HashMap` / `AHashMap` / `HashSet` explicit.

Lukas Tenbrinkdfae95c14e84
diff --git a/core/math/a_star.h b/core/math/a_star.h
index c3f2468610e..ac3decb1c59 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -48,8 +48,8 @@ class AStar3D : public RefCounted {
real_t weight_scale = 0;
bool enabled = false;
- AHashMap<int64_t, Point *> neighbors = 4u;
- AHashMap<int64_t, Point *> unlinked_neighbours = 4u;
+ AHashMap<int64_t, Point *> neighbors{ 4u };
+ AHashMap<int64_t, Point *> unlinked_neighbours{ 4u };
// Used for pathfinding.
Point *prev_point = nullptr;
diff --git a/core/templates/a_hash_map.h b/core/templates/a_hash_map.h
index 00b0b0c6739..262ea62e9f1 100644
--- a/core/templates/a_hash_map.h
+++ b/core/templates/a_hash_map.h
@@ -662,7 +662,7 @@ public:
_init_from(p_other);
}
- AHashMap(uint32_t p_initial_capacity) {
+ explicit AHashMap(uint32_t p_initial_capacity) {
// Capacity can't be 0 and must be 2^n - 1.
_capacity_mask = MAX(4u, p_initial_capacity);
_capacity_mask = Math::next_power_of_2(_capacity_mask) - 1;
diff --git a/core/templates/hash_map.h b/core/templates/hash_map.h
index 6f9d6612620..963d5857f45 100644
--- a/core/templates/hash_map.h
+++ b/core/templates/hash_map.h
@@ -673,7 +673,7 @@ public:
return *this;
}
- HashMap(uint32_t p_initial_capacity) {
+ explicit HashMap(uint32_t p_initial_capacity) {
// Capacity can't be 0.
_capacity_idx = 0;
reserve(p_initial_capacity);
diff --git a/core/templates/hash_set.h b/core/templates/hash_set.h
index d077ee8afd3..5d0ab732a81 100644
--- a/core/templates/hash_set.h
+++ b/core/templates/hash_set.h
@@ -489,7 +489,7 @@ public:
return !(*this == p_other);
}
- HashSet(uint32_t p_initial_capacity) {
+ explicit HashSet(uint32_t p_initial_capacity) {
// Capacity can't be 0.
_capacity_idx = 0;
reserve(p_initial_capacity);
diff --git a/editor/export/editor_export_platform_apple_embedded.cpp b/editor/export/editor_export_platform_apple_embedded.cpp
index 9c1b9820c03..d36af171f19 100644
--- a/editor/export/editor_export_platform_apple_embedded.cpp
+++ b/editor/export/editor_export_platform_apple_embedded.cpp
@@ -3098,10 +3098,10 @@ void EditorExportPlatformAppleEmbedded::_initialize(const char *p_platform_logo_
Ref<Image> img = memnew(Image);
const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
- ImageLoaderSVG::create_image_from_string(img, p_platform_logo_svg, EDSCALE, upsample, false);
+ ImageLoaderSVG::create_image_from_string(img, p_platform_logo_svg, EDSCALE, upsample, HashMap<Color, Color>());
logo = ImageTexture::create_from_image(img);
- ImageLoaderSVG::create_image_from_string(img, p_run_icon_svg, EDSCALE, upsample, false);
+ ImageLoaderSVG::create_image_from_string(img, p_run_icon_svg, EDSCALE, upsample, HashMap<Color, Color>());
run_icon = ImageTexture::create_from_image(img);
plugins_changed.set();
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index 2e3d91eb5e7..47d9520995c 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -4266,10 +4266,10 @@ void EditorExportPlatformAndroid::initialize() {
Ref<Image> img = memnew(Image);
const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
- ImageLoaderSVG::create_image_from_string(img, _android_logo_svg, EDSCALE, upsample, false);
+ ImageLoaderSVG::create_image_from_string(img, _android_logo_svg, EDSCALE, upsample, HashMap<Color, Color>());
logo = ImageTexture::create_from_image(img);
- ImageLoaderSVG::create_image_from_string(img, _android_run_icon_svg, EDSCALE, upsample, false);
+ ImageLoaderSVG::create_image_from_string(img, _android_run_icon_svg, EDSCALE, upsample, HashMap<Color, Color>());
run_icon = ImageTexture::create_from_image(img);
#ifndef DISABLE_DEPRECATED
diff --git a/platform/linuxbsd/export/export_plugin.cpp b/platform/linuxbsd/export/export_plugin.cpp
index 29dc096e2bf..d567a883b84 100644
--- a/platform/linuxbsd/export/export_plugin.cpp
+++ b/platform/linuxbsd/export/export_plugin.cpp
@@ -620,10 +620,10 @@ void EditorExportPlatformLinuxBSD::initialize() {
Ref<Image> img = memnew(Image);
const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
- ImageLoaderSVG::create_image_from_string(img, _linuxbsd_logo_svg, EDSCALE, upsample, false);
+ ImageLoaderSVG::create_image_from_string(img, _linuxbsd_logo_svg, EDSCALE, upsample, HashMap<Color, Color>());
set_logo(ImageTexture::create_from_image(img));
- ImageLoaderSVG::create_image_from_string(img, _linuxbsd_run_icon_svg, EDSCALE, upsample, false);
+ ImageLoaderSVG::create_image_from_string(img, _linuxbsd_run_icon_svg, EDSCALE, upsample, HashMap<Color, Color>());
run_icon = ImageTexture::create_from_image(img);
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp
index 7d6aa3ca340..4c3a3d1da97 100644
--- a/platform/macos/export/export_plugin.cpp
+++ b/platform/macos/export/export_plugin.cpp
@@ -2833,10 +2833,10 @@ void EditorExportPlatformMacOS::initialize() {
Ref<Image> img = memnew(Image);
const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
- ImageLoaderSVG::create_image_from_string(img, _macos_logo_svg, EDSCALE, upsample, false);
+ ImageLoaderSVG::create_image_from_string(img, _macos_logo_svg, EDSCALE, upsample, HashMap<Color, Color>());
logo = ImageTexture::create_from_image(img);
- ImageLoaderSVG::create_image_from_string(img, _macos_run_icon_svg, EDSCALE, upsample, false);
+ ImageLoaderSVG::create_image_from_string(img, _macos_run_icon_svg, EDSCALE, upsample, HashMap<Color, Color>());
run_icon = ImageTexture::create_from_image(img);
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp
index 4e9857fd90f..991cee840a4 100644
--- a/platform/web/export/export_plugin.cpp
+++ b/platform/web/export/export_plugin.cpp
@@ -914,10 +914,10 @@ void EditorExportPlatformWeb::initialize() {
Ref<Image> img = memnew(Image);
const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
- ImageLoaderSVG::create_image_from_string(img, _web_logo_svg, EDSCALE, upsample, false);
+ ImageLoaderSVG::create_image_from_string(img, _web_logo_svg, EDSCALE, upsample, HashMap<Color, Color>());
logo = ImageTexture::create_from_image(img);
- ImageLoaderSVG::create_image_from_string(img, _web_run_icon_svg, EDSCALE, upsample, false);
+ ImageLoaderSVG::create_image_from_string(img, _web_run_icon_svg, EDSCALE, upsample, HashMap<Color, Color>());
run_icon = ImageTexture::create_from_image(img);
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp
index ad1ec961866..6c50d835b30 100644
--- a/platform/windows/export/export_plugin.cpp
+++ b/platform/windows/export/export_plugin.cpp
@@ -1137,10 +1137,10 @@ void EditorExportPlatformWindows::initialize() {
Ref<Image> img = memnew(Image);
const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
- ImageLoaderSVG::create_image_from_string(img, _windows_logo_svg, EDSCALE, upsample, false);
+ ImageLoaderSVG::create_image_from_string(img, _windows_logo_svg, EDSCALE, upsample, HashMap<Color, Color>());
set_logo(ImageTexture::create_from_image(img));
- ImageLoaderSVG::create_image_from_string(img, _windows_run_icon_svg, EDSCALE, upsample, false);
+ ImageLoaderSVG::create_image_from_string(img, _windows_run_icon_svg, EDSCALE, upsample, HashMap<Color, Color>());
run_icon = ImageTexture::create_from_image(img);
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index 4116e439376..609cac4fa41 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -743,7 +743,7 @@ void SurfaceTool::index() {
return; //already indexed
}
- AHashMap<Vertex &, int, VertexHasher> indices = vertex_array.size();
+ AHashMap<Vertex &, int, VertexHasher> indices(vertex_array.size());
uint32_t new_size = 0;
for (Vertex &vertex : vertex_array) {
@@ -1164,7 +1164,7 @@ void SurfaceTool::generate_normals(bool p_flip) {
ERR_FAIL_COND((vertex_array.size() % 3) != 0);
- AHashMap<SmoothGroupVertex, Vector3, SmoothGroupVertexHasher> smooth_hash = vertex_array.size();
+ AHashMap<SmoothGroupVertex, Vector3, SmoothGroupVertexHasher> smooth_hash(vertex_array.size());
for (uint32_t vi = 0; vi < vertex_array.size(); vi += 3) {
Vertex *v = &vertex_array[vi];