From 0103af1ddda6a2aa31227965141dd7d3a513e081 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Thu, 29 Sep 2022 12:53:28 +0300 Subject: Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4. --- modules/csg/csg_shape.cpp | 110 ++++++++--------- modules/enet/enet_multiplayer_peer.cpp | 6 +- modules/gdscript/editor/gdscript_highlighter.cpp | 12 +- modules/gdscript/gdscript.cpp | 134 ++++++++++----------- modules/gdscript/gdscript.h | 2 +- modules/gdscript/gdscript_analyzer.cpp | 30 ++--- modules/gdscript/gdscript_compiler.cpp | 104 ++++++++-------- modules/gdscript/gdscript_compiler.h | 8 +- modules/gdscript/gdscript_disassembler.cpp | 4 +- modules/gdscript/gdscript_editor.cpp | 28 ++--- modules/gdscript/gdscript_function.cpp | 10 +- modules/gdscript/gdscript_parser.cpp | 22 ++-- modules/gdscript/gdscript_parser.h | 20 +-- modules/gdscript/gdscript_tokenizer.cpp | 18 +-- modules/gdscript/gdscript_vm.cpp | 2 +- .../language_server/gdscript_extend_parser.cpp | 42 +++---- .../language_server/gdscript_language_server.cpp | 12 +- .../language_server/gdscript_text_document.cpp | 22 ++-- .../language_server/gdscript_workspace.cpp | 36 +++--- .../gltf/editor/editor_scene_importer_blend.cpp | 10 +- modules/gltf/extensions/gltf_light.cpp | 5 +- modules/gltf/gltf_document.cpp | 95 ++++++++------- modules/gridmap/grid_map.cpp | 8 +- modules/lightmapper_rd/lightmapper_rd.cpp | 8 +- modules/multiplayer/scene_replication_config.cpp | 16 +-- modules/noise/noise_texture_2d.cpp | 18 +-- modules/openxr/action_map/openxr_action.cpp | 6 +- modules/openxr/openxr_interface.cpp | 24 ++-- modules/openxr/util.h | 84 ++++++------- modules/text_server_adv/text_server_adv.cpp | 4 +- modules/theora/video_stream_theora.cpp | 35 +++--- 31 files changed, 459 insertions(+), 476 deletions(-) (limited to 'modules') diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 3932c2377f..461960ab26 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -92,13 +92,13 @@ uint32_t CSGShape3D::get_collision_mask() const { void CSGShape3D::set_collision_layer_value(int p_layer_number, bool p_value) { ERR_FAIL_COND_MSG(p_layer_number < 1, "Collision layer number must be between 1 and 32 inclusive."); ERR_FAIL_COND_MSG(p_layer_number > 32, "Collision layer number must be between 1 and 32 inclusive."); - uint32_t collision_layer = get_collision_layer(); + uint32_t layer = get_collision_layer(); if (p_value) { - collision_layer |= 1 << (p_layer_number - 1); + layer |= 1 << (p_layer_number - 1); } else { - collision_layer &= ~(1 << (p_layer_number - 1)); + layer &= ~(1 << (p_layer_number - 1)); } - set_collision_layer(collision_layer); + set_collision_layer(layer); } bool CSGShape3D::get_collision_layer_value(int p_layer_number) const { @@ -690,7 +690,7 @@ CSGCombiner3D::CSGCombiner3D() { ///////////////////// CSGBrush *CSGPrimitive3D::_create_brush_from_arrays(const Vector &p_vertices, const Vector &p_uv, const Vector &p_smooth, const Vector> &p_materials) { - CSGBrush *brush = memnew(CSGBrush); + CSGBrush *new_brush = memnew(CSGBrush); Vector invert; invert.resize(p_vertices.size() / 3); @@ -701,9 +701,9 @@ CSGBrush *CSGPrimitive3D::_create_brush_from_arrays(const Vector &p_ver w[i] = flip_faces; } } - brush->build_from_faces(p_vertices, p_uv, p_smooth, p_materials, invert); + new_brush->build_from_faces(p_vertices, p_uv, p_smooth, p_materials, invert); - return brush; + return new_brush; } void CSGPrimitive3D::_bind_methods() { @@ -742,7 +742,7 @@ CSGBrush *CSGMesh3D::_build_brush() { Vector smooth; Vector> materials; Vector uvs; - Ref material = get_material(); + Ref base_material = get_material(); for (int i = 0; i < mesh->get_surface_count(); i++) { if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) { @@ -776,8 +776,8 @@ CSGBrush *CSGMesh3D::_build_brush() { } Ref mat; - if (material.is_valid()) { - mat = material; + if (base_material.is_valid()) { + mat = base_material; } else { mat = mesh->surface_get_material(i); } @@ -933,12 +933,12 @@ Ref CSGMesh3D::get_mesh() { CSGBrush *CSGSphere3D::_build_brush() { // set our bounding box - CSGBrush *brush = memnew(CSGBrush); + CSGBrush *new_brush = memnew(CSGBrush); int face_count = rings * radial_segments * 2 - radial_segments * 2; bool invert_val = get_flip_faces(); - Ref material = get_material(); + Ref base_material = get_material(); Vector faces; Vector uvs; @@ -1019,7 +1019,7 @@ CSGBrush *CSGSphere3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; } @@ -1036,7 +1036,7 @@ CSGBrush *CSGSphere3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; } @@ -1048,9 +1048,9 @@ CSGBrush *CSGSphere3D::_build_brush() { } } - brush->build_from_faces(faces, uvs, smooth, materials, invert); + new_brush->build_from_faces(faces, uvs, smooth, materials, invert); - return brush; + return new_brush; } void CSGSphere3D::_bind_methods() { @@ -1137,12 +1137,12 @@ CSGSphere3D::CSGSphere3D() { CSGBrush *CSGBox3D::_build_brush() { // set our bounding box - CSGBrush *brush = memnew(CSGBrush); + CSGBrush *new_brush = memnew(CSGBrush); int face_count = 12; //it's a cube.. bool invert_val = get_flip_faces(); - Ref material = get_material(); + Ref base_material = get_material(); Vector faces; Vector uvs; @@ -1204,7 +1204,7 @@ CSGBrush *CSGBox3D::_build_brush() { smoothw[face] = false; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; //face 2 @@ -1218,7 +1218,7 @@ CSGBrush *CSGBox3D::_build_brush() { smoothw[face] = false; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; } @@ -1229,9 +1229,9 @@ CSGBrush *CSGBox3D::_build_brush() { } } - brush->build_from_faces(faces, uvs, smooth, materials, invert); + new_brush->build_from_faces(faces, uvs, smooth, materials, invert); - return brush; + return new_brush; } void CSGBox3D::_bind_methods() { @@ -1270,12 +1270,12 @@ Ref CSGBox3D::get_material() const { CSGBrush *CSGCylinder3D::_build_brush() { // set our bounding box - CSGBrush *brush = memnew(CSGBrush); + CSGBrush *new_brush = memnew(CSGBrush); int face_count = sides * (cone ? 1 : 2) + sides + (cone ? 0 : sides); bool invert_val = get_flip_faces(); - Ref material = get_material(); + Ref base_material = get_material(); Vector faces; Vector uvs; @@ -1312,14 +1312,14 @@ CSGBrush *CSGCylinder3D::_build_brush() { float ang = inc * Math_TAU; float ang_n = inc_n * Math_TAU; - Vector3 base(Math::cos(ang), 0, Math::sin(ang)); - Vector3 base_n(Math::cos(ang_n), 0, Math::sin(ang_n)); + Vector3 face_base(Math::cos(ang), 0, Math::sin(ang)); + Vector3 face_base_n(Math::cos(ang_n), 0, Math::sin(ang_n)); Vector3 face_points[4] = { - base + Vector3(0, -1, 0), - base_n + Vector3(0, -1, 0), - base_n * (cone ? 0.0 : 1.0) + Vector3(0, 1, 0), - base * (cone ? 0.0 : 1.0) + Vector3(0, 1, 0), + face_base + Vector3(0, -1, 0), + face_base_n + Vector3(0, -1, 0), + face_base_n * (cone ? 0.0 : 1.0) + Vector3(0, 1, 0), + face_base * (cone ? 0.0 : 1.0) + Vector3(0, 1, 0), }; Vector2 u[4] = { @@ -1340,7 +1340,7 @@ CSGBrush *CSGCylinder3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; @@ -1356,7 +1356,7 @@ CSGBrush *CSGCylinder3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; } @@ -1371,7 +1371,7 @@ CSGBrush *CSGCylinder3D::_build_brush() { smoothw[face] = false; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; if (!cone) { @@ -1386,7 +1386,7 @@ CSGBrush *CSGCylinder3D::_build_brush() { smoothw[face] = false; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; } } @@ -1397,9 +1397,9 @@ CSGBrush *CSGCylinder3D::_build_brush() { } } - brush->build_from_faces(faces, uvs, smooth, materials, invert); + new_brush->build_from_faces(faces, uvs, smooth, materials, invert); - return brush; + return new_brush; } void CSGCylinder3D::_bind_methods() { @@ -1515,12 +1515,12 @@ CSGBrush *CSGTorus3D::_build_brush() { float radius = (max_radius - min_radius) * 0.5; - CSGBrush *brush = memnew(CSGBrush); + CSGBrush *new_brush = memnew(CSGBrush); int face_count = ring_sides * sides * 2; bool invert_val = get_flip_faces(); - Ref material = get_material(); + Ref base_material = get_material(); Vector faces; Vector uvs; @@ -1596,7 +1596,7 @@ CSGBrush *CSGTorus3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; @@ -1611,7 +1611,7 @@ CSGBrush *CSGTorus3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = invert_val; - materialsw[face] = material; + materialsw[face] = base_material; face++; } } @@ -1622,9 +1622,9 @@ CSGBrush *CSGTorus3D::_build_brush() { } } - brush->build_from_faces(faces, uvs, smooth, materials, invert); + new_brush->build_from_faces(faces, uvs, smooth, materials, invert); - return brush; + return new_brush; } void CSGTorus3D::_bind_methods() { @@ -1726,10 +1726,10 @@ CSGTorus3D::CSGTorus3D() { /////////////// CSGBrush *CSGPolygon3D::_build_brush() { - CSGBrush *brush = memnew(CSGBrush); + CSGBrush *new_brush = memnew(CSGBrush); if (polygon.size() < 3) { - return brush; + return new_brush; } // Triangulate polygon shape. @@ -1739,7 +1739,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { } int shape_sides = shape_polygon.size(); Vector shape_faces = Geometry2D::triangulate_polygon(shape_polygon); - ERR_FAIL_COND_V_MSG(shape_faces.size() < 3, brush, "Failed to triangulate CSGPolygon. Make sure the polygon doesn't have any intersecting edges."); + ERR_FAIL_COND_V_MSG(shape_faces.size() < 3, new_brush, "Failed to triangulate CSGPolygon. Make sure the polygon doesn't have any intersecting edges."); // Get polygon enclosing Rect2. Rect2 shape_rect(shape_polygon[0], Vector2()); @@ -1764,12 +1764,12 @@ CSGBrush *CSGPolygon3D::_build_brush() { } if (!path) { - return brush; + return new_brush; } curve = path->get_curve(); if (curve.is_null() || curve->get_point_count() < 2) { - return brush; + return new_brush; } } @@ -1806,7 +1806,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { int face_count = extrusions * extrusion_face_count + end_count * shape_face_count; // Initialize variables used to create the mesh. - Ref material = get_material(); + Ref base_material = get_material(); Vector faces; Vector uvs; @@ -1896,7 +1896,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { } smoothw[face] = false; - materialsw[face] = material; + materialsw[face] = base_material; invertw[face] = flip_faces; face++; } @@ -2003,7 +2003,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = flip_faces; - materialsw[face] = material; + materialsw[face] = base_material; face++; @@ -2018,7 +2018,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { smoothw[face] = smooth_faces; invertw[face] = flip_faces; - materialsw[face] = material; + materialsw[face] = base_material; face++; } @@ -2041,14 +2041,14 @@ CSGBrush *CSGPolygon3D::_build_brush() { } smoothw[face] = false; - materialsw[face] = material; + materialsw[face] = base_material; invertw[face] = flip_faces; face++; } } face_count -= faces_removed; - ERR_FAIL_COND_V_MSG(face != face_count, brush, "Bug: Failed to create the CSGPolygon mesh correctly."); + ERR_FAIL_COND_V_MSG(face != face_count, new_brush, "Bug: Failed to create the CSGPolygon mesh correctly."); } if (faces_removed > 0) { @@ -2059,9 +2059,9 @@ CSGBrush *CSGPolygon3D::_build_brush() { invert.resize(face_count); } - brush->build_from_faces(faces, uvs, smooth, materials, invert); + new_brush->build_from_faces(faces, uvs, smooth, materials, invert); - return brush; + return new_brush; } void CSGPolygon3D::_notification(int p_what) { diff --git a/modules/enet/enet_multiplayer_peer.cpp b/modules/enet/enet_multiplayer_peer.cpp index dfdd08c9f4..e7728f4aec 100644 --- a/modules/enet/enet_multiplayer_peer.cpp +++ b/modules/enet/enet_multiplayer_peer.cpp @@ -436,9 +436,9 @@ Error ENetMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size int packet_flags = 0; int channel = SYSCH_RELIABLE; - int transfer_channel = get_transfer_channel(); - if (transfer_channel > 0) { - channel = SYSCH_MAX + transfer_channel - 1; + int tr_channel = get_transfer_channel(); + if (tr_channel > 0) { + channel = SYSCH_MAX + tr_channel - 1; } else { switch (get_transfer_mode()) { case TRANSFER_MODE_UNRELIABLE: { diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 8b27307d0c..8645aa6f15 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -653,23 +653,23 @@ void GDScriptSyntaxHighlighter::_update_cache() { add_color_region(beg, end, string_color, end.is_empty()); } - const Ref