Add clang format (#270)

This commit is contained in:
Vasilii Rogin 2023-04-26 15:35:02 +03:00 committed by GitHub
parent 81c3ff9b1a
commit 63d8300c61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 49 additions and 37 deletions

View File

@ -31,6 +31,18 @@ jobs:
- name: cppcheck
run: cppcheck --std=c++17 src/
code-format:
name: Code format check
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
- name: clang-format
run: find src -type f -exec clang-format --dry-run --Werror {} \;
android:
name: Android

View File

@ -92,7 +92,7 @@ typedef enum AnimationType {
LAST_SF_DEATH_ANIM = ANIM_FALL_FRONT_BLOOD_SF,
} AnimationType;
#define FID_ANIM_TYPE(value) ((value) & 0xFF0000) >> 16
#define FID_ANIM_TYPE(value) ((value)&0xFF0000) >> 16
// Signature of animation callback accepting 2 parameters.
typedef int(AnimationCallback)(void* a1, void* a2);

View File

@ -996,8 +996,8 @@ bool _critter_is_prone(Object* critter)
int anim = FID_ANIM_TYPE(critter->fid);
return (critter->data.critter.combat.results & (DAM_KNOCKED_OUT | DAM_KNOCKED_DOWN)) != 0
|| (anim >= FIRST_KNOCKDOWN_AND_DEATH_ANIM && anim <= LAST_KNOCKDOWN_AND_DEATH_ANIM)
|| (anim >= FIRST_SF_DEATH_ANIM && anim <= LAST_SF_DEATH_ANIM);
|| (anim >= FIRST_KNOCKDOWN_AND_DEATH_ANIM && anim <= LAST_KNOCKDOWN_AND_DEATH_ANIM)
|| (anim >= FIRST_SF_DEATH_ANIM && anim <= LAST_SF_DEATH_ANIM);
}
// critter_body_type

View File

@ -1026,24 +1026,24 @@ static void buildNormalizedQwertyKeys()
keys[SDL_SCANCODE_F13] = -1;
keys[SDL_SCANCODE_F14] = -1;
keys[SDL_SCANCODE_F15] = -1;
//keys[DIK_KANA] = -1;
//keys[DIK_CONVERT] = -1;
//keys[DIK_NOCONVERT] = -1;
//keys[DIK_YEN] = -1;
// keys[DIK_KANA] = -1;
// keys[DIK_CONVERT] = -1;
// keys[DIK_NOCONVERT] = -1;
// keys[DIK_YEN] = -1;
keys[SDL_SCANCODE_KP_EQUALS] = -1;
//keys[DIK_PREVTRACK] = -1;
//keys[DIK_AT] = -1;
//keys[DIK_COLON] = -1;
//keys[DIK_UNDERLINE] = -1;
//keys[DIK_KANJI] = -1;
// keys[DIK_PREVTRACK] = -1;
// keys[DIK_AT] = -1;
// keys[DIK_COLON] = -1;
// keys[DIK_UNDERLINE] = -1;
// keys[DIK_KANJI] = -1;
keys[SDL_SCANCODE_STOP] = -1;
//keys[DIK_AX] = -1;
//keys[DIK_UNLABELED] = -1;
// keys[DIK_AX] = -1;
// keys[DIK_UNLABELED] = -1;
keys[SDL_SCANCODE_KP_ENTER] = SDL_SCANCODE_KP_ENTER;
keys[SDL_SCANCODE_RCTRL] = SDL_SCANCODE_RCTRL;
keys[SDL_SCANCODE_KP_COMMA] = -1;
keys[SDL_SCANCODE_KP_DIVIDE] = SDL_SCANCODE_KP_DIVIDE;
//keys[DIK_SYSRQ] = 84;
// keys[DIK_SYSRQ] = 84;
keys[SDL_SCANCODE_RALT] = SDL_SCANCODE_RALT;
keys[SDL_SCANCODE_HOME] = SDL_SCANCODE_HOME;
keys[SDL_SCANCODE_UP] = SDL_SCANCODE_UP;

View File

@ -2694,7 +2694,7 @@ void inventoryOpenUseItemOn(Object* a1)
inventoryWindowOpenContextMenu(keyCode, INVENTORY_WINDOW_TYPE_USE_ITEM_ON);
} else {
int inventoryItemIndex = _pud->length - (_stack_offset[_curr_stack] + keyCode - 1000 + 1);
// SFALL: Fix crash when clicking on empty space in the inventory list
// SFALL: Fix crash when clicking on empty space in the inventory list
// opened by "Use Inventory Item On" (backpack) action icon
if (inventoryItemIndex < _pud->length && inventoryItemIndex >= 0) {
InventoryItem* inventoryItem = &(_pud->items[inventoryItemIndex]);

View File

@ -1400,11 +1400,11 @@ static void keyboardBuildFrenchConfiguration()
gLogicalKeyEntries[SDL_SCANCODE_BACKSLASH].rmenu = -1;
gLogicalKeyEntries[SDL_SCANCODE_BACKSLASH].ctrl = -1;
//gLogicalKeyEntries[DIK_OEM_102].unmodified = KEY_LESS;
//gLogicalKeyEntries[DIK_OEM_102].shift = KEY_GREATER;
//gLogicalKeyEntries[DIK_OEM_102].lmenu = -1;
//gLogicalKeyEntries[DIK_OEM_102].rmenu = -1;
//gLogicalKeyEntries[DIK_OEM_102].ctrl = -1;
// gLogicalKeyEntries[DIK_OEM_102].unmodified = KEY_LESS;
// gLogicalKeyEntries[DIK_OEM_102].shift = KEY_GREATER;
// gLogicalKeyEntries[DIK_OEM_102].lmenu = -1;
// gLogicalKeyEntries[DIK_OEM_102].rmenu = -1;
// gLogicalKeyEntries[DIK_OEM_102].ctrl = -1;
switch (gKeyboardLayout) {
case KEYBOARD_LAYOUT_QWERTY:
@ -1583,11 +1583,11 @@ static void keyboardBuildGermanConfiguration()
gLogicalKeyEntries[SDL_SCANCODE_BACKSLASH].rmenu = -1;
gLogicalKeyEntries[SDL_SCANCODE_BACKSLASH].ctrl = -1;
//gLogicalKeyEntries[DIK_OEM_102].unmodified = KEY_LESS;
//gLogicalKeyEntries[DIK_OEM_102].shift = KEY_GREATER;
//gLogicalKeyEntries[DIK_OEM_102].lmenu = -1;
//gLogicalKeyEntries[DIK_OEM_102].rmenu = KEY_166;
//gLogicalKeyEntries[DIK_OEM_102].ctrl = -1;
// gLogicalKeyEntries[DIK_OEM_102].unmodified = KEY_LESS;
// gLogicalKeyEntries[DIK_OEM_102].shift = KEY_GREATER;
// gLogicalKeyEntries[DIK_OEM_102].lmenu = -1;
// gLogicalKeyEntries[DIK_OEM_102].rmenu = KEY_166;
// gLogicalKeyEntries[DIK_OEM_102].ctrl = -1;
switch (gKeyboardLayout) {
case KEYBOARD_LAYOUT_FRENCH:
@ -1684,11 +1684,11 @@ static void keyboardBuildItalianConfiguration()
gLogicalKeyEntries[SDL_SCANCODE_GRAVE].rmenu = -1;
gLogicalKeyEntries[SDL_SCANCODE_GRAVE].ctrl = -1;
//gLogicalKeyEntries[DIK_OEM_102].unmodified = KEY_LESS;
//gLogicalKeyEntries[DIK_OEM_102].shift = KEY_GREATER;
//gLogicalKeyEntries[DIK_OEM_102].lmenu = -1;
//gLogicalKeyEntries[DIK_OEM_102].rmenu = -1;
//gLogicalKeyEntries[DIK_OEM_102].ctrl = -1;
// gLogicalKeyEntries[DIK_OEM_102].unmodified = KEY_LESS;
// gLogicalKeyEntries[DIK_OEM_102].shift = KEY_GREATER;
// gLogicalKeyEntries[DIK_OEM_102].lmenu = -1;
// gLogicalKeyEntries[DIK_OEM_102].rmenu = -1;
// gLogicalKeyEntries[DIK_OEM_102].ctrl = -1;
gLogicalKeyEntries[SDL_SCANCODE_1].unmodified = KEY_1;
gLogicalKeyEntries[SDL_SCANCODE_1].shift = KEY_EXCLAMATION;
@ -1896,11 +1896,11 @@ static void keyboardBuildSpanishConfiguration()
gLogicalKeyEntries[SDL_SCANCODE_RIGHTBRACKET].rmenu = KEY_BRACKET_RIGHT;
gLogicalKeyEntries[SDL_SCANCODE_RIGHTBRACKET].ctrl = -1;
//gLogicalKeyEntries[DIK_OEM_102].unmodified = KEY_LESS;
//gLogicalKeyEntries[DIK_OEM_102].shift = KEY_GREATER;
//gLogicalKeyEntries[DIK_OEM_102].lmenu = -1;
//gLogicalKeyEntries[DIK_OEM_102].rmenu = -1;
//gLogicalKeyEntries[DIK_OEM_102].ctrl = -1;
// gLogicalKeyEntries[DIK_OEM_102].unmodified = KEY_LESS;
// gLogicalKeyEntries[DIK_OEM_102].shift = KEY_GREATER;
// gLogicalKeyEntries[DIK_OEM_102].lmenu = -1;
// gLogicalKeyEntries[DIK_OEM_102].rmenu = -1;
// gLogicalKeyEntries[DIK_OEM_102].ctrl = -1;
gLogicalKeyEntries[SDL_SCANCODE_SEMICOLON].unmodified = KEY_241;
gLogicalKeyEntries[SDL_SCANCODE_SEMICOLON].shift = KEY_209;

View File

@ -29,7 +29,7 @@ enum {
OBJ_TYPE_COUNT,
};
#define FID_TYPE(value) ((value) & 0xF000000) >> 24
#define FID_TYPE(value) ((value)&0xF000000) >> 24
#define PID_TYPE(value) (value) >> 24
#define SID_TYPE(value) (value) >> 24