Style: Enforce use of bool literals instead of integers
Using clang-tidy's `modernize-use-bool-literals`. https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-bool-literals.html
This commit is contained in:
parent
a828398655
commit
b4af1eba0a
29 changed files with 47 additions and 47 deletions
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,modernize-use-nullptr'
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,modernize-use-bool-literals,modernize-use-nullptr'
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: '.*'
|
||||
AnalyzeTemporaryDtors: false
|
||||
|
|
|
@ -420,7 +420,7 @@ void Image::convert(Format p_new_format) {
|
|||
|
||||
} else if (format > FORMAT_RGBA8 || p_new_format > FORMAT_RGBA8) {
|
||||
//use put/set pixel which is slower but works with non byte formats
|
||||
Image new_img(width, height, 0, p_new_format);
|
||||
Image new_img(width, height, false, p_new_format);
|
||||
lock();
|
||||
new_img.lock();
|
||||
|
||||
|
@ -442,7 +442,7 @@ void Image::convert(Format p_new_format) {
|
|||
return;
|
||||
}
|
||||
|
||||
Image new_img(width, height, 0, p_new_format);
|
||||
Image new_img(width, height, false, p_new_format);
|
||||
|
||||
PoolVector<uint8_t>::Read r = data.read();
|
||||
PoolVector<uint8_t>::Write w = new_img.data.write();
|
||||
|
@ -926,7 +926,7 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
|
|||
if (p_width == width && p_height == height)
|
||||
return;
|
||||
|
||||
Image dst(p_width, p_height, 0, format);
|
||||
Image dst(p_width, p_height, false, format);
|
||||
|
||||
// Setup mipmap-aware scaling
|
||||
Image dst2;
|
||||
|
@ -946,7 +946,7 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
|
|||
}
|
||||
bool interpolate_mipmaps = mipmap_aware && mip1 != mip2;
|
||||
if (interpolate_mipmaps) {
|
||||
dst2.create(p_width, p_height, 0, format);
|
||||
dst2.create(p_width, p_height, false, format);
|
||||
}
|
||||
|
||||
bool had_mipmaps = mipmaps;
|
||||
|
@ -1236,7 +1236,7 @@ void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) {
|
|||
uint8_t pdata[16]; //largest is 16
|
||||
uint32_t pixel_size = get_format_pixel_size(format);
|
||||
|
||||
Image dst(p_width, p_height, 0, format);
|
||||
Image dst(p_width, p_height, false, format);
|
||||
|
||||
{
|
||||
PoolVector<uint8_t>::Read r = data.read();
|
||||
|
@ -1850,7 +1850,7 @@ void Image::create(const char **p_xpm) {
|
|||
}
|
||||
if (line == colormap_size) {
|
||||
status = READING_PIXELS;
|
||||
create(size_width, size_height, 0, has_alpha ? FORMAT_RGBA8 : FORMAT_RGB8);
|
||||
create(size_width, size_height, false, has_alpha ? FORMAT_RGBA8 : FORMAT_RGB8);
|
||||
w = data.write();
|
||||
pixel_size = has_alpha ? 4 : 3;
|
||||
}
|
||||
|
@ -2936,7 +2936,7 @@ Ref<Image> Image::rgbe_to_srgb() {
|
|||
|
||||
Ref<Image> new_image;
|
||||
new_image.instance();
|
||||
new_image->create(width, height, 0, Image::FORMAT_RGB8);
|
||||
new_image->create(width, height, false, Image::FORMAT_RGB8);
|
||||
|
||||
lock();
|
||||
|
||||
|
|
|
@ -309,7 +309,7 @@ void HTTPClient::close() {
|
|||
body_size = -1;
|
||||
body_left = 0;
|
||||
chunk_left = 0;
|
||||
chunk_trailer_part = 0;
|
||||
chunk_trailer_part = false;
|
||||
read_until_eof = false;
|
||||
response_num = 0;
|
||||
handshaking = false;
|
||||
|
|
|
@ -91,7 +91,7 @@ private:
|
|||
uint32_t pos = hash % capacity;
|
||||
uint32_t distance = 0;
|
||||
|
||||
while (42) {
|
||||
while (true) {
|
||||
if (hashes[pos] == EMPTY_HASH) {
|
||||
return false;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ private:
|
|||
TKey key = p_key;
|
||||
TValue value = p_value;
|
||||
|
||||
while (42) {
|
||||
while (true) {
|
||||
if (hashes[pos] == EMPTY_HASH) {
|
||||
_construct(pos, hash, key, value);
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ public:
|
|||
}
|
||||
|
||||
virtual void set_borderless_window(bool p_borderless) {}
|
||||
virtual bool get_borderless_window() { return 0; }
|
||||
virtual bool get_borderless_window() { return false; }
|
||||
|
||||
virtual bool get_window_per_pixel_transparency_enabled() const { return false; }
|
||||
virtual void set_window_per_pixel_transparency_enabled(bool p_enabled) {}
|
||||
|
|
|
@ -118,7 +118,7 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, bool p_force_linear,
|
|||
ERR_FAIL_COND_V_MSG(check_error(png_img), ERR_FILE_CORRUPT, png_img.message);
|
||||
ERR_FAIL_COND_V(!success, ERR_FILE_CORRUPT);
|
||||
|
||||
p_image->create(png_img.width, png_img.height, 0, dest_format, buffer);
|
||||
p_image->create(png_img.width, png_img.height, false, dest_format, buffer);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
@ -5659,7 +5659,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
|
|||
insert_confirm_bezier->set_text(TTR("Use Bezier Curves"));
|
||||
icvb->add_child(insert_confirm_bezier);
|
||||
keying = false;
|
||||
moving_selection = 0;
|
||||
moving_selection = false;
|
||||
key_edit = nullptr;
|
||||
multi_key_edit = nullptr;
|
||||
|
||||
|
|
|
@ -869,7 +869,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
|
|||
|
||||
ProjectSettings::CustomMap custom_map;
|
||||
if (path_remaps.size()) {
|
||||
if (1) { //new remap mode, use always as it's friendlier with multiple .pck exports
|
||||
if (true) { //new remap mode, use always as it's friendlier with multiple .pck exports
|
||||
for (int i = 0; i < path_remaps.size(); i += 2) {
|
||||
String from = path_remaps[i];
|
||||
String to = path_remaps[i + 1];
|
||||
|
|
|
@ -494,7 +494,7 @@ void EditorHelp::_update_doc() {
|
|||
class_desc->push_font(doc_code_font);
|
||||
class_desc->push_indent(1);
|
||||
class_desc->push_table(2);
|
||||
class_desc->set_table_column_expand(1, 1);
|
||||
class_desc->set_table_column_expand(1, true);
|
||||
|
||||
for (int i = 0; i < cd.properties.size(); i++) {
|
||||
property_line[cd.properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description
|
||||
|
@ -596,7 +596,7 @@ void EditorHelp::_update_doc() {
|
|||
class_desc->push_font(doc_code_font);
|
||||
class_desc->push_indent(1);
|
||||
class_desc->push_table(2);
|
||||
class_desc->set_table_column_expand(1, 1);
|
||||
class_desc->set_table_column_expand(1, true);
|
||||
|
||||
bool any_previous = false;
|
||||
for (int pass = 0; pass < 2; pass++) {
|
||||
|
@ -664,7 +664,7 @@ void EditorHelp::_update_doc() {
|
|||
|
||||
class_desc->push_indent(1);
|
||||
class_desc->push_table(2);
|
||||
class_desc->set_table_column_expand(1, 1);
|
||||
class_desc->set_table_column_expand(1, true);
|
||||
|
||||
for (int i = 0; i < cd.theme_properties.size(); i++) {
|
||||
theme_property_line[cd.theme_properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description
|
||||
|
@ -957,7 +957,7 @@ void EditorHelp::_update_doc() {
|
|||
property_line[cd.properties[i].name] = class_desc->get_line_count() - 2;
|
||||
|
||||
class_desc->push_table(2);
|
||||
class_desc->set_table_column_expand(1, 1);
|
||||
class_desc->set_table_column_expand(1, true);
|
||||
|
||||
class_desc->push_cell();
|
||||
class_desc->push_font(doc_code_font);
|
||||
|
|
|
@ -1263,7 +1263,7 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
|
|||
// which would result in an invalid texture.
|
||||
if (c3d == 0 && c2d == 0) {
|
||||
img.instance();
|
||||
img->create(1, 1, 0, Image::FORMAT_RGB8);
|
||||
img->create(1, 1, false, Image::FORMAT_RGB8);
|
||||
} else if (c3d < c2d) {
|
||||
Ref<ViewportTexture> viewport_texture = scene_root->get_texture();
|
||||
if (viewport_texture->get_width() > 0 && viewport_texture->get_height() > 0) {
|
||||
|
|
|
@ -331,7 +331,7 @@ void EditorProfiler::_update_plot() {
|
|||
|
||||
Ref<Image> img;
|
||||
img.instance();
|
||||
img->create(w, h, 0, Image::FORMAT_RGBA8, graph_image);
|
||||
img->create(w, h, false, Image::FORMAT_RGBA8, graph_image);
|
||||
|
||||
if (reset_texture) {
|
||||
if (graph_texture.is_null()) {
|
||||
|
|
|
@ -784,7 +784,7 @@ Ref<Texture> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const
|
|||
img_ref.instance();
|
||||
Image &im = **img_ref;
|
||||
|
||||
im.create(thumbnail_size, thumbnail_size / 2, 0, Image::FORMAT_RGBA8);
|
||||
im.create(thumbnail_size, thumbnail_size / 2, false, Image::FORMAT_RGBA8);
|
||||
|
||||
im.lock();
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2
|
|||
|
||||
Ref<Image> img;
|
||||
img.instance();
|
||||
img->create(bm->get_size().width, bm->get_size().height, 0, Image::FORMAT_L8, data);
|
||||
img->create(bm->get_size().width, bm->get_size().height, false, Image::FORMAT_L8, data);
|
||||
|
||||
if (img->is_compressed()) {
|
||||
if (img->decompress() != OK)
|
||||
|
@ -493,7 +493,7 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2
|
|||
Ref<Image> img;
|
||||
img.instance();
|
||||
int thumbnail_size = MAX(p_size.x, p_size.y);
|
||||
img->create(thumbnail_size, thumbnail_size, 0, Image::FORMAT_RGBA8);
|
||||
img->create(thumbnail_size, thumbnail_size, false, Image::FORMAT_RGBA8);
|
||||
|
||||
Color bg_color = EditorSettings::get_singleton()->get("text_editor/highlighting/background_color");
|
||||
Color keyword_color = EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color");
|
||||
|
|
|
@ -159,7 +159,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
|
|||
|
||||
//generate previews!
|
||||
|
||||
if (1) {
|
||||
if (true) {
|
||||
Vector<Ref<Mesh>> meshes;
|
||||
Vector<Transform> transforms;
|
||||
Vector<int> ids = p_library->get_item_list();
|
||||
|
|
|
@ -3666,7 +3666,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
|
|||
_edit.mode = TRANSFORM_NONE;
|
||||
_edit.plane = TRANSFORM_VIEW;
|
||||
_edit.edited_gizmo = 0;
|
||||
_edit.snap = 1;
|
||||
_edit.snap = true;
|
||||
_edit.gizmo_handle = 0;
|
||||
|
||||
index = p_index;
|
||||
|
|
|
@ -157,7 +157,7 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
|
|||
|
||||
if (p_color_buffer == nullptr || color_table_size == 0) { // regular pixels
|
||||
|
||||
p_image->create(width, height, 0, Image::FORMAT_RGBA8, data);
|
||||
p_image->create(width, height, false, Image::FORMAT_RGBA8, data);
|
||||
|
||||
} else { // data is in indexed format, extend it
|
||||
|
||||
|
@ -197,7 +197,7 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
|
|||
|
||||
dest += 4;
|
||||
}
|
||||
p_image->create(width, height, 0, Image::FORMAT_RGBA8, extended_data);
|
||||
p_image->create(width, height, false, Image::FORMAT_RGBA8, extended_data);
|
||||
}
|
||||
}
|
||||
return err;
|
||||
|
|
|
@ -215,7 +215,7 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf
|
|||
/// Returns the list of contacts pairs in this order: Local contact, other body contact
|
||||
bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &p_shape_xform, float p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
|
||||
if (p_result_max <= 0)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape);
|
||||
ERR_FAIL_COND_V(!shape, false);
|
||||
|
@ -224,7 +224,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &
|
|||
if (!btShape->isConvex()) {
|
||||
bulletdelete(btShape);
|
||||
ERR_PRINTS("The shape is not a convex shape, then is not supported: shape type: " + itos(shape->get_type()));
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
btConvexShape *btConvex = static_cast<btConvexShape *>(btShape);
|
||||
|
||||
|
@ -256,7 +256,7 @@ bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_sh
|
|||
if (!btShape->isConvex()) {
|
||||
bulletdelete(btShape);
|
||||
ERR_PRINTS("The shape is not a convex shape, then is not supported: shape type: " + itos(shape->get_type()));
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
btConvexShape *btConvex = static_cast<btConvexShape *>(btShape);
|
||||
|
||||
|
|
|
@ -1328,8 +1328,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
|
|||
for (int i = 0; i < 3; i++) {
|
||||
Vector3 points[4];
|
||||
for (int j = 0; j < 4; j++) {
|
||||
static const bool orderx[4] = { 0, 1, 1, 0 };
|
||||
static const bool ordery[4] = { 0, 0, 1, 1 };
|
||||
static const bool orderx[4] = { false, true, true, false };
|
||||
static const bool ordery[4] = { false, false, true, true };
|
||||
|
||||
Vector3 sp;
|
||||
if (orderx[j]) {
|
||||
|
|
|
@ -96,7 +96,7 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
|
|||
fmt = Image::FORMAT_RGB8;
|
||||
|
||||
dw.release();
|
||||
p_image->create(image_width, image_height, 0, fmt, data);
|
||||
p_image->create(image_width, image_height, false, fmt, data);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
@ -214,9 +214,9 @@ struct PVRTCBlock {
|
|||
|
||||
_FORCE_INLINE_ bool is_po2(uint32_t p_input) {
|
||||
if (p_input == 0)
|
||||
return 0;
|
||||
return false;
|
||||
uint32_t minus1 = p_input - 1;
|
||||
return ((p_input | minus1) == (p_input ^ minus1)) ? 1 : 0;
|
||||
return ((p_input | minus1) == (p_input ^ minus1)) ? true : false;
|
||||
}
|
||||
|
||||
static void unpack_5554(const PVRTCBlock *p_block, int p_ab_colors[2][4]) {
|
||||
|
|
|
@ -220,7 +220,7 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff
|
|||
|
||||
image_data_w.release();
|
||||
|
||||
p_image->create(width, height, 0, Image::FORMAT_RGBA8, image_data);
|
||||
p_image->create(width, height, false, Image::FORMAT_RGBA8, image_data);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ void VisualScriptPropertySelector::_update_search() {
|
|||
item->set_metadata(0, F->get().name);
|
||||
item->set_icon(0, type_icons[F->get().type]);
|
||||
item->set_metadata(1, "get");
|
||||
item->set_collapsed(1);
|
||||
item->set_collapsed(true);
|
||||
item->set_selectable(0, true);
|
||||
item->set_selectable(1, false);
|
||||
item->set_selectable(2, false);
|
||||
|
@ -249,7 +249,7 @@ void VisualScriptPropertySelector::_update_search() {
|
|||
item->set_selectable(0, true);
|
||||
|
||||
item->set_metadata(1, "method");
|
||||
item->set_collapsed(1);
|
||||
item->set_collapsed(true);
|
||||
item->set_selectable(1, false);
|
||||
|
||||
item->set_selectable(2, false);
|
||||
|
@ -312,7 +312,7 @@ void VisualScriptPropertySelector::create_visualscript_item(const String &name,
|
|||
item->set_metadata(0, name);
|
||||
item->set_metadata(1, "action");
|
||||
item->set_selectable(0, true);
|
||||
item->set_collapsed(1);
|
||||
item->set_collapsed(true);
|
||||
item->set_selectable(1, false);
|
||||
item->set_selectable(2, false);
|
||||
item->set_metadata(2, connecting);
|
||||
|
|
|
@ -134,7 +134,7 @@ Error webp_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
|
|||
|
||||
ERR_FAIL_COND_V_MSG(errdec, ERR_FILE_CORRUPT, "Failed decoding WebP image.");
|
||||
|
||||
p_image->create(features.width, features.height, 0, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image);
|
||||
p_image->create(features.width, features.height, false, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
@ -631,7 +631,7 @@ void Polygon2D::_bind_methods() {
|
|||
}
|
||||
|
||||
Polygon2D::Polygon2D() {
|
||||
invert = 0;
|
||||
invert = false;
|
||||
invert_border = 100;
|
||||
antialiased = false;
|
||||
tex_rot = 0;
|
||||
|
|
|
@ -2277,7 +2277,7 @@ SpatialMaterial::SpatialMaterial() :
|
|||
depth_draw_mode = DEPTH_DRAW_OPAQUE_ONLY;
|
||||
cull_mode = CULL_BACK;
|
||||
for (int i = 0; i < FLAG_MAX; i++) {
|
||||
flags[i] = 0;
|
||||
flags[i] = false;
|
||||
}
|
||||
diffuse_mode = DIFFUSE_BURLEY;
|
||||
specular_mode = SPECULAR_SCHLICK_GGX;
|
||||
|
|
|
@ -652,5 +652,5 @@ bool Generic6DOFJointSW::get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJoin
|
|||
break; // Can't happen, but silences warning
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -303,7 +303,7 @@ public:
|
|||
|
||||
virtual void soft_body_remove_all_pinned_points(RID p_body) {}
|
||||
virtual void soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) {}
|
||||
virtual bool soft_body_is_point_pinned(RID p_body, int p_point_index) { return 0; }
|
||||
virtual bool soft_body_is_point_pinned(RID p_body, int p_point_index) { return false; }
|
||||
|
||||
/* JOINT API */
|
||||
|
||||
|
|
|
@ -318,7 +318,7 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform
|
|||
|
||||
bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
|
||||
if (p_result_max <= 0)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape);
|
||||
ERR_FAIL_COND_V(!shape, 0);
|
||||
|
|
|
@ -294,7 +294,7 @@ bool Physics2DDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transfor
|
|||
|
||||
bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
|
||||
if (p_result_max <= 0)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.get(p_shape);
|
||||
ERR_FAIL_COND_V(!shape, 0);
|
||||
|
|
Loading…
Reference in a new issue