summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-01-17 10:28:32 +0100
committerGitHub <noreply@github.com>2019-01-17 10:28:32 +0100
commit9f2d98c0556e296a5ecfcbc973c6f6ef3ec10698 (patch)
treee840d3bcadc81fb1fc39547f377cf01025042fdc
parent07e2046980c903268ef0d2f5a73caea77d511519 (diff)
parent9c69d7f3392249d26236dcb33bee7de8f283dc28 (diff)
Merge pull request #24993 from YeldhamDev/cppcheck_warns_scene_fix
Appease some CppCheck warns for files in the "scene" directory
-rw-r--r--scene/2d/polygon_2d.cpp3
-rw-r--r--scene/2d/tile_map.cpp5
-rw-r--r--scene/3d/cpu_particles.cpp11
-rw-r--r--scene/3d/voxel_light_baker.cpp1
-rw-r--r--scene/gui/line_edit.cpp4
-rw-r--r--scene/gui/scroll_container.cpp1
-rw-r--r--scene/gui/text_edit.cpp1
-rw-r--r--scene/main/http_request.cpp3
-rw-r--r--scene/resources/animation.cpp2
-rw-r--r--scene/resources/curve.cpp32
10 files changed, 24 insertions, 39 deletions
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index bfa82fa12e..54b304f851 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -224,15 +224,12 @@ void Polygon2D::_notification(int p_what) {
for (int i = 0; i < bone_weights.size(); i++) {
if (bone_weights[i].weights.size() != points.size()) {
continue; //different number of vertices, sorry not using.
- print_line("wrong weight size");
}
if (!skeleton_node->has_node(bone_weights[i].path)) {
- print_line("no node");
continue; //node does not exist
}
Bone2D *bone = Object::cast_to<Bone2D>(skeleton_node->get_node(bone_weights[i].path));
if (!bone) {
- print_line("no bone");
continue;
}
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index cac59bddff..d61296b13f 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -377,13 +377,12 @@ void TileMap::update_dirty_quadrants() {
r.size = tile_set->autotile_get_size(c.id);
r.position += (r.size + Vector2(spacing, spacing)) * Vector2(c.autotile_coord_x, c.autotile_coord_y);
}
- Size2 s = tex->get_size();
+ Size2 s;
if (r == Rect2())
s = tex->get_size();
- else {
+ else
s = r.size;
- }
Rect2 rect;
rect.position = offset.floor();
diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp
index 0bf5983dd1..29610cb0bf 100644
--- a/scene/3d/cpu_particles.cpp
+++ b/scene/3d/cpu_particles.cpp
@@ -605,19 +605,14 @@ void CPUParticles::_particles_process(float p_delta) {
p.hue_rot_rand = Math::randf();
p.anim_offset_rand = Math::randf();
- float angle1_rad;
- float angle2_rad;
-
if (flags[FLAG_DISABLE_Z]) {
-
- angle1_rad = (Math::randf() * 2.0 - 1.0) * Math_PI * spread / 180.0;
+ float angle1_rad = (Math::randf() * 2.0 - 1.0) * Math_PI * spread / 180.0;
Vector3 rot = Vector3(Math::cos(angle1_rad), Math::sin(angle1_rad), 0.0);
p.velocity = rot * parameters[PARAM_INITIAL_LINEAR_VELOCITY] * Math::lerp(1.0f, float(Math::randf()), randomness[PARAM_INITIAL_LINEAR_VELOCITY]);
-
} else {
//initiate velocity spread in 3D
- angle1_rad = (Math::randf() * 2.0 - 1.0) * Math_PI * spread / 180.0;
- angle2_rad = (Math::randf() * 2.0 - 1.0) * (1.0 - flatness) * Math_PI * spread / 180.0;
+ float angle1_rad = (Math::randf() * 2.0 - 1.0) * Math_PI * spread / 180.0;
+ float angle2_rad = (Math::randf() * 2.0 - 1.0) * (1.0 - flatness) * Math_PI * spread / 180.0;
Vector3 direction_xz = Vector3(Math::sin(angle1_rad), 0, Math::cos(angle1_rad));
Vector3 direction_yz = Vector3(0, Math::sin(angle2_rad), Math::cos(angle2_rad));
diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp
index 4b910e4463..cdf0a06e36 100644
--- a/scene/3d/voxel_light_baker.cpp
+++ b/scene/3d/voxel_light_baker.cpp
@@ -1931,7 +1931,6 @@ Error VoxelLightBaker::make_lightmap(const Transform &p_xform, Ref<Mesh> &p_mesh
//add directional light (do this after blur)
{
- LightMap *lightmap_ptr = lightmap.ptrw();
const Cell *cells = bake_cells.ptr();
const Light *light = bake_light.ptr();
#ifdef _OPENMP
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 4d638b50c6..4a2bb3dad1 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -1290,13 +1290,11 @@ int LineEdit::get_max_length() const {
void LineEdit::selection_fill_at_cursor() {
- int aux;
-
selection.begin = cursor_pos;
selection.end = selection.cursor_start;
if (selection.end < selection.begin) {
- aux = selection.end;
+ int aux = selection.end;
selection.end = selection.begin;
selection.begin = aux;
}
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index f99f5e4d4b..28292309b9 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -271,7 +271,6 @@ void ScrollContainer::_notification(int p_what) {
}
if (!scroll_v || (!v_scroll->is_visible_in_tree() && c->get_v_size_flags() & SIZE_EXPAND)) {
r.position.y = 0;
- r.size.height = size.height;
if (c->get_v_size_flags() & SIZE_EXPAND)
r.size.height = MAX(size.height, minsize.height);
else
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 19c054fa43..09fbb39866 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -3811,7 +3811,6 @@ Vector<String> TextEdit::get_wrap_rows_text(int p_line) const {
if (indent_ofs + word_px > wrap_at) {
// not enough space; add it anyway
wrap_substring += word_str;
- px += word_px;
word_str = "";
word_px = 0;
}
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index 8e96873672..8b68b3215c 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -220,13 +220,12 @@ bool HTTPRequest::_handle_response(bool *ret_value) {
Error err;
if (new_request.begins_with("http")) {
// New url, request all again
- err = _parse_url(new_request);
+ _parse_url(new_request);
} else {
request_string = new_request;
}
err = _request();
-
if (err == OK) {
request_sent = false;
got_response = false;
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 5c6b0ac91a..383f3f5d4e 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -2332,7 +2332,7 @@ float Animation::bezier_track_interpolate(int p_track, float p_time) const {
float duration = bt->values[idx + 1].time - bt->values[idx].time; // time duration between our two keyframes
float low = 0; // 0% of the current animation segment
float high = 1; // 100% of the current animation segment
- float middle = 0;
+ float middle;
Vector2 start(0, bt->values[idx].value.value);
Vector2 start_out = start + bt->values[idx].value.out_handle;
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp
index e136181136..464ca60d31 100644
--- a/scene/resources/curve.cpp
+++ b/scene/resources/curve.cpp
@@ -761,8 +761,8 @@ Vector2 Curve2D::interpolate_baked(float p_offset, bool p_cubic) const {
//validate//
int pc = baked_point_cache.size();
if (pc == 0) {
- ERR_EXPLAIN("No points in Curve2D");
- ERR_FAIL_COND_V(pc == 0, Vector2());
+ ERR_EXPLAIN("No points in Curve2D.");
+ ERR_FAIL_V(Vector2());
}
if (pc == 1)
@@ -826,8 +826,8 @@ Vector2 Curve2D::get_closest_point(const Vector2 &p_to_point) const {
//validate//
int pc = baked_point_cache.size();
if (pc == 0) {
- ERR_EXPLAIN("No points in Curve2D");
- ERR_FAIL_COND_V(pc == 0, Vector2());
+ ERR_EXPLAIN("No points in Curve2D.");
+ ERR_FAIL_V(Vector2());
}
if (pc == 1)
@@ -865,8 +865,8 @@ float Curve2D::get_closest_offset(const Vector2 &p_to_point) const {
//validate//
int pc = baked_point_cache.size();
if (pc == 0) {
- ERR_EXPLAIN("No points in Curve2D");
- ERR_FAIL_COND_V(pc == 0, 0.0f);
+ ERR_EXPLAIN("No points in Curve2D.");
+ ERR_FAIL_V(0.0f);
}
if (pc == 1)
@@ -1331,8 +1331,8 @@ Vector3 Curve3D::interpolate_baked(float p_offset, bool p_cubic) const {
//validate//
int pc = baked_point_cache.size();
if (pc == 0) {
- ERR_EXPLAIN("No points in Curve3D");
- ERR_FAIL_COND_V(pc == 0, Vector3());
+ ERR_EXPLAIN("No points in Curve3D.");
+ ERR_FAIL_V(Vector3());
}
if (pc == 1)
@@ -1375,8 +1375,8 @@ float Curve3D::interpolate_baked_tilt(float p_offset) const {
//validate//
int pc = baked_tilt_cache.size();
if (pc == 0) {
- ERR_EXPLAIN("No tilts in Curve3D");
- ERR_FAIL_COND_V(pc == 0, 0);
+ ERR_EXPLAIN("No tilts in Curve3D.");
+ ERR_FAIL_V(0);
}
if (pc == 1)
@@ -1413,8 +1413,8 @@ Vector3 Curve3D::interpolate_baked_up_vector(float p_offset, bool p_apply_tilt)
// curve may not have baked up vectors
int count = baked_up_vector_cache.size();
if (count == 0) {
- ERR_EXPLAIN("No up vectors in Curve3D");
- ERR_FAIL_COND_V(count == 0, Vector3(0, 1, 0));
+ ERR_EXPLAIN("No up vectors in Curve3D.");
+ ERR_FAIL_V(Vector3(0, 1, 0));
}
if (count == 1)
@@ -1484,8 +1484,8 @@ Vector3 Curve3D::get_closest_point(const Vector3 &p_to_point) const {
//validate//
int pc = baked_point_cache.size();
if (pc == 0) {
- ERR_EXPLAIN("No points in Curve3D");
- ERR_FAIL_COND_V(pc == 0, Vector3());
+ ERR_EXPLAIN("No points in Curve3D.");
+ ERR_FAIL_V(Vector3());
}
if (pc == 1)
@@ -1523,8 +1523,8 @@ float Curve3D::get_closest_offset(const Vector3 &p_to_point) const {
//validate//
int pc = baked_point_cache.size();
if (pc == 0) {
- ERR_EXPLAIN("No points in Curve3D");
- ERR_FAIL_COND_V(pc == 0, 0.0f);
+ ERR_EXPLAIN("No points in Curve3D.");
+ ERR_FAIL_V(0.0f);
}
if (pc == 1)