From 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 16:41:43 +0200 Subject: Style: Enforce braces around if blocks and loops Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html --- modules/dds/texture_loader_dds.cpp | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'modules/dds') diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index 052f2c5e01..ba425371a8 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -95,17 +95,20 @@ static const DDSFormatInfo dds_format_info[DDS_MAX] = { }; RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { - if (r_error) + if (r_error) { *r_error = ERR_CANT_OPEN; + } Error err; FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err); - if (!f) + if (!f) { return RES(); + } FileAccessRef fref(f); - if (r_error) + if (r_error) { *r_error = ERR_FILE_CORRUPT; + } ERR_FAIL_COND_V_MSG(err != OK, RES(), "Unable to open DDS texture file '" + p_path + "'."); @@ -119,8 +122,9 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, uint32_t mipmaps = f->get_32(); //skip 11 - for (int i = 0; i < 11; i++) + for (int i = 0; i < 11; i++) { f->get_32(); + } //validate @@ -155,8 +159,9 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, */ //must avoid this later - while (f->get_position() < 128) + while (f->get_position() < 128) { f->get_8(); + } DDSFormat dds_format; @@ -200,8 +205,9 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, ERR_FAIL_V_MSG(RES(), "Unrecognized or unsupported color layout in DDS '" + p_path + "'."); } - if (!(flags & DDSD_MIPMAPCOUNT)) + if (!(flags & DDSD_MIPMAPCOUNT)) { mipmaps = 1; + } Vector src_data; @@ -241,8 +247,9 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, int colsize = 3; for (int i = 0; i < 256; i++) { - if (palette[i * 4 + 3] < 255) + if (palette[i * 4 + 3] < 255) { colsize = 4; + } } int w2 = width; @@ -264,8 +271,9 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, wb[dst_ofs + 0] = palette[src_ofs + 2]; wb[dst_ofs + 1] = palette[src_ofs + 1]; wb[dst_ofs + 2] = palette[src_ofs + 0]; - if (colsize == 4) + if (colsize == 4) { wb[dst_ofs + 3] = palette[src_ofs + 3]; + } } } else { //uncompressed generic... @@ -278,10 +286,11 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, size += w * h * info.block_size; } - if (dds_format == DDS_BGR565) + if (dds_format == DDS_BGR565) { size = size * 3 / 2; - else if (dds_format == DDS_BGR5A1) + } else if (dds_format == DDS_BGR5A1) { size = size * 2; + } src_data.resize(size); uint8_t *wb = src_data.ptrw(); @@ -404,8 +413,9 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, Ref texture = memnew(ImageTexture); texture->create_from_image(img); - if (r_error) + if (r_error) { *r_error = OK; + } return texture; } @@ -419,7 +429,8 @@ bool ResourceFormatDDS::handles_type(const String &p_type) const { } String ResourceFormatDDS::get_resource_type(const String &p_path) const { - if (p_path.get_extension().to_lower() == "dds") + if (p_path.get_extension().to_lower() == "dds") { return "ImageTexture"; + } return ""; } -- cgit v1.2.3