build: add pre-commit hooks

This commit is contained in:
rr- 2021-10-19 16:54:06 +02:00
parent 1e913b4a2d
commit f871f298a7
No known key found for this signature in database
GPG key ID: CC65E6FD28CAE42A
7 changed files with 25 additions and 19 deletions

9
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,9 @@
repos:
- repo: local
hooks:
- id: clang-format
name: clang-format
entry: clang-format
args: ["-style=file", "-i"]
language: system
files: \.[ch]$

View file

@ -55,7 +55,7 @@ clean:
find . -type d -empty -delete
lint: $(C_FILES)
clang-format-10 -i $(C_FILES) $(H_FILES) $(TEST_C_FILES) $(TEST_H_FILES)
clang-format -i $(C_FILES) $(H_FILES) $(TEST_C_FILES) $(TEST_H_FILES)
docs:
docs/render_progress

View file

@ -572,15 +572,15 @@ int16_t GetHeight(FLOOR_INFO *floor, int32_t x, int32_t y, int32_t z)
if (xoff < 0) {
height -= (int16_t)((xoff * (z & (WALL_L - 1))) >> 2);
} else {
height += (int16_t)(
(xoff * ((WALL_L - 1 - z) & (WALL_L - 1))) >> 2);
height +=
(int16_t)((xoff * ((WALL_L - 1 - z) & (WALL_L - 1))) >> 2);
}
if (yoff < 0) {
height -= (int16_t)((yoff * (x & (WALL_L - 1))) >> 2);
} else {
height += (int16_t)(
(yoff * ((WALL_L - 1 - x) & (WALL_L - 1))) >> 2);
height +=
(int16_t)((yoff * ((WALL_L - 1 - x) & (WALL_L - 1))) >> 2);
}
}
@ -1003,13 +1003,13 @@ int16_t GetCeiling(FLOOR_INFO *floor, int32_t x, int32_t y, int32_t z)
if (xoff < 0) {
height += (int16_t)((xoff * (z & (WALL_L - 1))) >> 2);
} else {
height -= (int16_t)(
(xoff * ((WALL_L - 1 - z) & (WALL_L - 1))) >> 2);
height -=
(int16_t)((xoff * ((WALL_L - 1 - z) & (WALL_L - 1))) >> 2);
}
if (yoff < 0) {
height += (int16_t)(
(yoff * ((WALL_L - 1 - x) & (WALL_L - 1))) >> 2);
height +=
(int16_t)((yoff * ((WALL_L - 1 - x) & (WALL_L - 1))) >> 2);
} else {
height -= (int16_t)((yoff * (x & (WALL_L - 1))) >> 2);
}

View file

@ -48,8 +48,8 @@ void ControlMissile(int16_t fx_num)
int32_t z = fx->pos.z - LaraItem->pos.z;
int32_t range = SQUARE(x) + SQUARE(y) + SQUARE(z);
if (range < ROCKET_RANGE) {
LaraItem->hit_points -= (int16_t)(
ROCKET_DAMAGE * (ROCKET_RANGE - range) / ROCKET_RANGE);
LaraItem->hit_points -=
(int16_t)(ROCKET_DAMAGE * (ROCKET_RANGE - range) / ROCKET_RANGE);
LaraItem->hit_status = 1;
}
}

View file

@ -893,9 +893,7 @@ void DrawInventoryItem(INVENTORY_ITEM *inv_item)
if (inv_item->object_number == O_MAP_OPTION && i == 1) {
CompassSpeed = CompassSpeed * 19 / 20
+ (int16_t)(
-inv_item->y_rot - LaraItem->pos.y_rot
- CompassNeedle)
+ (int16_t)(-inv_item->y_rot - LaraItem->pos.y_rot - CompassNeedle)
/ 50;
CompassNeedle += CompassSpeed;
phd_RotY(CompassNeedle);

View file

@ -115,7 +115,8 @@ C3D_EC InitATI3DCIF()
HATI3DCIFModule, "ATI3DCIF_ContextCreate_lib");
if (!ATI3DCIF_ContextCreate_lib) {
LOG_ERROR("cannot find ATI3DCIF_ContextCreate_lib");
*ATI3DCIF_ContextCreate_lib = (C3D_HRC(__stdcall *)(void))ATI3DCIF_NullSub;
*ATI3DCIF_ContextCreate_lib =
(C3D_HRC(__stdcall *)(void))ATI3DCIF_NullSub;
result = C3D_EC_GENFAIL;
}

View file

@ -19,10 +19,8 @@
#include <string.h>
#define COLOR_STEPS 5
#define VISIBLE(vn1, vn2, vn3) \
((int32_t)( \
((vn3->xs - vn2->xs) * (vn1->ys - vn2->ys)) \
- ((vn1->xs - vn2->xs) * (vn3->ys - vn2->ys))) \
#define VISIBLE(vn1, vn2, vn3) \
((int32_t)(((vn3->xs - vn2->xs) * (vn1->ys - vn2->ys)) - ((vn1->xs - vn2->xs) * (vn3->ys - vn2->ys))) \
>= 0)
static RGB888 ColorBarMap[][COLOR_STEPS] = {