1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Style: clang-format: Disable AllowShortIfStatementsOnASingleLine

Part of #33027, also discussed in #29848.

Enforcing the use of brackets even on single line statements would be
preferred, but `clang-format` doesn't have this functionality yet.
This commit is contained in:
Rémi Verschelde
2020-05-10 12:56:01 +02:00
parent 03b13e0c69
commit e956e80c1f
130 changed files with 967 additions and 511 deletions

View File

@@ -372,7 +372,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
d.name = vendor + " " + device;
if (device == String()) continue;
if (device == String())
continue;
}
ndevices.push_back(d);

View File

@@ -920,7 +920,8 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
int cnt = 0;
for (int i = cc.length; --i >= 0; cnt += cc[i] != 0 ? 1 : 0)
;
if (cnt == 0) return super.onKeyMultiple(inKeyCode, repeatCount, event);
if (cnt == 0)
return super.onKeyMultiple(inKeyCode, repeatCount, event);
mRenderView.queueOnRenderThread(new Runnable() {
// This method will be called on the rendering thread:
public void run() {

View File

@@ -423,7 +423,8 @@ String EditorExportPlatformIOS::_get_linker_flags() {
String result;
for (int i = 0; i < export_plugins.size(); ++i) {
String flags = export_plugins[i]->get_ios_linker_flags();
if (flags.length() == 0) continue;
if (flags.length() == 0)
continue;
if (result.length() > 0) {
result += ' ';
}
@@ -456,8 +457,10 @@ void EditorExportPlatformIOS::_blend_and_rotate(Ref<Image> &p_dst, Ref<Image> &p
int xs = (x_pos >= 0) ? 0 : -x_pos;
int ys = (y_pos >= 0) ? 0 : -y_pos;
if (sw + x_pos > p_dst->get_width()) sw = p_dst->get_width() - x_pos;
if (sh + y_pos > p_dst->get_height()) sh = p_dst->get_height() - y_pos;
if (sw + x_pos > p_dst->get_width())
sw = p_dst->get_width() - x_pos;
if (sh + y_pos > p_dst->get_height())
sh = p_dst->get_height() - y_pos;
for (int y = ys; y < sh; y++) {
for (int x = xs; x < sw; x++) {

View File

@@ -50,7 +50,8 @@ int iphone_main(int width, int height, int argc, char **argv, String data_dir) {
size_t len = strlen(argv[0]);
while (len--) {
if (argv[0][len] == '/') break;
if (argv[0][len] == '/')
break;
}
if (len >= 0) {

View File

@@ -178,7 +178,8 @@ int detect_prime() {
close(fdset[0]);
if (i) setenv("DRI_PRIME", "1", 1);
if (i)
setenv("DRI_PRIME", "1", 1);
create_context();
const char *vendor = (const char *)glGetString(GL_VENDOR);

View File

@@ -551,7 +551,8 @@ int DisplayServerX11::get_screen_count() const {
// Using Xinerama Extension
int event_base, error_base;
const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base);
if (!ext_okay) return 0;
if (!ext_okay)
return 0;
int count;
XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &count);
@@ -600,11 +601,13 @@ Rect2i DisplayServerX11::screen_get_usable_rect(int p_screen) const {
// Using Xinerama Extension
int event_base, error_base;
const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base);
if (!ext_okay) return Rect2i(0, 0, 0, 0);
if (!ext_okay)
return Rect2i(0, 0, 0, 0);
int count;
XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &count);
if (p_screen >= count) return Rect2i(0, 0, 0, 0);
if (p_screen >= count)
return Rect2i(0, 0, 0, 0);
Rect2i rect = Rect2i(xsi[p_screen].x_org, xsi[p_screen].y_org, xsi[p_screen].width, xsi[p_screen].height);
XFree(xsi);
@@ -827,7 +830,8 @@ void DisplayServerX11::window_set_current_screen(int p_screen, WindowID p_window
WindowData &wd = windows[p_window];
int count = get_screen_count();
if (p_screen >= count) return;
if (p_screen >= count)
return;
if (window_get_mode(p_window) == WINDOW_MODE_FULLSCREEN) {
Point2i position = screen_get_position(p_screen);

View File

@@ -463,7 +463,8 @@ void JoypadLinux::process_joypads() {
}
for (int i = 0; i < JOYPADS_MAX; i++) {
if (joypads[i].fd == -1) continue;
if (joypads[i].fd == -1)
continue;
input_event events[32];
Joypad *joy = &joypads[i];

View File

@@ -1656,7 +1656,8 @@ String DisplayServerOSX::global_menu_get_item_submenu(const String &p_menu_root,
const NSMenu *sub_menu = [menu_item submenu];
if (sub_menu) {
for (Map<String, NSMenu *>::Element *E = submenu.front(); E; E = E->next()) {
if (E->get() == sub_menu) return E->key();
if (E->get() == sub_menu)
return E->key();
}
}
}
@@ -2479,7 +2480,8 @@ void DisplayServerOSX::_set_window_per_pixel_transparency_enabled(bool p_enabled
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
if (!OS_OSX::get_singleton()->is_layered_allowed()) return;
if (!OS_OSX::get_singleton()->is_layered_allowed())
return;
if (wd.layered_window != p_enabled) {
if (p_enabled) {
[wd.window_object setBackgroundColor:[NSColor clearColor]];

View File

@@ -374,7 +374,8 @@ bool joypad::check_ff_features() {
if (ret == FF_OK && (features.supportedEffects & FFCAP_ET_CONSTANTFORCE)) {
uint32_t val;
ret = FFDeviceGetForceFeedbackProperty(ff_device, FFPROP_FFGAIN, &val, sizeof(val));
if (ret != FF_OK) return false;
if (ret != FF_OK)
return false;
int num_axes = features.numFfAxes;
ff_axes = (DWORD *)memalloc(sizeof(DWORD) * num_axes);
ff_directions = (LONG *)memalloc(sizeof(LONG) * num_axes);
@@ -509,14 +510,16 @@ void JoypadOSX::joypad_vibration_stop(int p_id, uint64_t p_timestamp) {
int JoypadOSX::get_joy_index(int p_id) const {
for (int i = 0; i < device_list.size(); i++) {
if (device_list[i].id == p_id) return i;
if (device_list[i].id == p_id)
return i;
}
return -1;
}
int JoypadOSX::get_joy_ref(IOHIDDeviceRef p_device) const {
for (int i = 0; i < device_list.size(); i++) {
if (device_list[i].device_ref == p_device) return i;
if (device_list[i].device_ref == p_device)
return i;
}
return -1;
}

View File

@@ -265,7 +265,8 @@ void AppxPackager::make_content_types(const String &p_path) {
String ext = file_metadata[i].name.get_extension();
if (types.has(ext)) continue;
if (types.has(ext))
continue;
types[ext] = content_type(ext);
@@ -664,8 +665,10 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
bool _valid_resource_name(const String &p_name) const {
if (p_name.empty()) return false;
if (p_name.ends_with(".")) return false;
if (p_name.empty())
return false;
if (p_name.ends_with("."))
return false;
static const char *invalid_names[] = {
"CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7",
@@ -675,7 +678,8 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
const char **t = invalid_names;
while (*t) {
if (p_name == *t) return false;
if (p_name == *t)
return false;
t++;
}
@@ -686,19 +690,25 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
Vector<String> parts = p_guid.split("-");
if (parts.size() != 5) return false;
if (parts[0].length() != 8) return false;
if (parts.size() != 5)
return false;
if (parts[0].length() != 8)
return false;
for (int i = 1; i < 4; i++)
if (parts[i].length() != 4) return false;
if (parts[4].length() != 12) return false;
if (parts[i].length() != 4)
return false;
if (parts[4].length() != 12)
return false;
return true;
}
bool _valid_bgcolor(const String &p_color) const {
if (p_color.empty()) return true;
if (p_color.begins_with("#") && p_color.is_valid_html_color()) return true;
if (p_color.empty())
return true;
if (p_color.begins_with("#") && p_color.is_valid_html_color())
return true;
// Colors from https://msdn.microsoft.com/en-us/library/windows/apps/dn934817.aspx
static const char *valid_colors[] = {
@@ -732,7 +742,8 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
const char **color = valid_colors;
while (*color) {
if (p_color == *color) return true;
if (p_color == *color)
return true;
color++;
}
@@ -896,7 +907,8 @@ class EditorExportPlatformUWP : public EditorExportPlatform {
ERR_PRINT("Unable to load logo");
}
if (!image) return data;
if (!image)
return data;
String tmp_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("uwp_tmp_logo.png");
@@ -1301,7 +1313,8 @@ public:
path = path.replace(".scale-100", "");
data = _get_image_data(p_preset, path);
if (data.size() > 0) do_read = false;
if (data.size() > 0)
do_read = false;
}
//read

View File

@@ -48,7 +48,8 @@ void JoypadUWP::process_controllers() {
ControllerDevice &joy = controllers[i];
if (!joy.connected) break;
if (!joy.connected)
break;
switch (joy.type) {

View File

@@ -123,7 +123,8 @@ bool OS_UWP::is_window_fullscreen() const {
void OS_UWP::set_keep_screen_on(bool p_enabled) {
if (is_keep_screen_on() == p_enabled) return;
if (is_keep_screen_on() == p_enabled)
return;
if (p_enabled)
display_request->RequestActive();
@@ -826,7 +827,8 @@ void OS_UWP::run() {
while (!force_quit) {
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
if (managed_object->alert_close_handle) continue;
if (managed_object->alert_close_handle)
continue;
process_events(); // get rid of pending events
if (Main::iteration())
break;

View File

@@ -677,7 +677,8 @@ void DisplayServerWindows::window_set_position(const Point2i &p_position, Window
ERR_FAIL_COND(!windows.has(p_window));
WindowData &wd = windows[p_window];
if (wd.fullscreen) return;
if (wd.fullscreen)
return;
#if 0
//wrong needs to account properly for decorations
RECT r;
@@ -1474,19 +1475,22 @@ DisplayServer::LatinKeyboardVariant DisplayServerWindows::get_latin_keyboard_var
int i = 0;
while (azerty[i] != 0) {
if (azerty[i] == hex) return LATIN_KEYBOARD_AZERTY;
if (azerty[i] == hex)
return LATIN_KEYBOARD_AZERTY;
i++;
}
i = 0;
while (qwertz[i] != 0) {
if (qwertz[i] == hex) return LATIN_KEYBOARD_QWERTZ;
if (qwertz[i] == hex)
return LATIN_KEYBOARD_QWERTZ;
i++;
}
i = 0;
while (dvorak[i] != 0) {
if (dvorak[i] == hex) return LATIN_KEYBOARD_DVORAK;
if (dvorak[i] == hex)
return LATIN_KEYBOARD_DVORAK;
i++;
}

View File

@@ -112,7 +112,8 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) {
return false;
}
dev_list = (PRAWINPUTDEVICELIST)malloc(sizeof(RAWINPUTDEVICELIST) * dev_list_count);
if (!dev_list) return false;
if (!dev_list)
return false;
if (GetRawInputDeviceList(dev_list, &dev_list_count, sizeof(RAWINPUTDEVICELIST)) == (UINT)-1) {
free(dev_list);
@@ -267,7 +268,8 @@ void JoypadWindows::close_joypad(int id) {
return;
}
if (!d_joypads[id].attached) return;
if (!d_joypads[id].attached)
return;
d_joypads[id].di_joy->Unacquire();
d_joypads[id].di_joy->Release();