clang-tidy
This commit is contained in:
@@ -14,7 +14,7 @@ auto TileCollider::getTileAt(int tile_x, int tile_y) const -> Tile {
|
||||
if (tile_x < 0 || tile_x >= MW || tile_y < 0 || tile_y >= MH) {
|
||||
return Tile::EMPTY;
|
||||
}
|
||||
int value = tile_map_[tile_y * MW + tile_x];
|
||||
int value = tile_map_[(tile_y * MW) + tile_x];
|
||||
if (value >= 0 && value <= 5) {
|
||||
return static_cast<Tile>(value);
|
||||
}
|
||||
@@ -30,7 +30,7 @@ auto TileCollider::isSolid(int tile_x, int tile_y) const -> bool {
|
||||
// SLOPE_L (\): alto a la izquierda, bajo a la derecha. surface = bottom - (7 - x_in_tile)
|
||||
// SLOPE_R (/): alto a la derecha, bajo a la izquierda. surface = bottom - x_in_tile
|
||||
auto TileCollider::getSlopeY(int tile_x, int tile_y, float px) const -> float {
|
||||
float tile_bottom = static_cast<float>((tile_y + 1) * TS - 1);
|
||||
auto tile_bottom = static_cast<float>(((tile_y + 1) * TS) - 1);
|
||||
float x_in_tile = px - static_cast<float>(tile_x * TS);
|
||||
x_in_tile = std::clamp(x_in_tile, 0.0F, static_cast<float>(TS - 1));
|
||||
|
||||
@@ -96,6 +96,7 @@ auto TileCollider::checkCeiling(float x, float y, float w) const -> float {
|
||||
// SLOPE: solo si los pies estaban por encima de la superficie Y el jugador no está
|
||||
// parcialmente dentro de otra slope (evita aterrizar al hacer drop-through
|
||||
// o al saltar a través de una slope desde abajo).
|
||||
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||
auto TileCollider::checkFloor(float x, float foot_y_current, float w, float foot_y_new) const -> FloorHit {
|
||||
int start_row = toTile(static_cast<int>(foot_y_current));
|
||||
int end_row = toTile(static_cast<int>(foot_y_new));
|
||||
@@ -115,7 +116,7 @@ auto TileCollider::checkFloor(float x, float foot_y_current, float w, float foot
|
||||
if (tile == Tile::WALL) {
|
||||
floor_y = static_cast<float>(row * TS);
|
||||
} else if (tile == Tile::PASSABLE) {
|
||||
float tile_top = static_cast<float>(row * TS);
|
||||
auto tile_top = static_cast<float>(row * TS);
|
||||
// Solo cuenta como suelo si los pies estaban por encima antes del movimiento
|
||||
if (foot_y_current <= tile_top) {
|
||||
floor_y = tile_top;
|
||||
@@ -130,7 +131,7 @@ auto TileCollider::checkFloor(float x, float foot_y_current, float w, float foot
|
||||
}
|
||||
|
||||
if (floor_y != Collision::NONE && (best.y == Collision::NONE || floor_y < best.y)) {
|
||||
best = {floor_y, tile, col, row};
|
||||
best = {.y = floor_y, .type = tile, .tile_x = col, .tile_y = row};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,6 +194,7 @@ auto TileCollider::isInsideAnySlope(float x, float foot_y, float w) const -> boo
|
||||
// Busca una slope directamente debajo del jugador (para transición ground→slope).
|
||||
// Escanea la fila de los pies Y la fila superior: las slopes en escalera siempre
|
||||
// tienen el tile de entrada una fila arriba del suelo desde el que se accede.
|
||||
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||
auto TileCollider::checkSlopeBelow(float x, float foot_y, float w) const -> SlopeInfo {
|
||||
int foot_row = toTile(static_cast<int>(foot_y));
|
||||
int left_col = toTile(static_cast<int>(x));
|
||||
@@ -205,14 +207,14 @@ auto TileCollider::checkSlopeBelow(float x, float foot_y, float w) const -> Slop
|
||||
float foot_x = (col == left_col) ? x : x + w - 1;
|
||||
float slope_y = getSlopeY(col, row, foot_x);
|
||||
if (slope_y <= foot_y && slope_y >= foot_y - TS) {
|
||||
return {true, Tile::SLOPE_L, col, row, slope_y};
|
||||
return {.on_slope = true, .type = Tile::SLOPE_L, .tile_x = col, .tile_y = row, .surface_y = slope_y};
|
||||
}
|
||||
}
|
||||
if (tile == Tile::SLOPE_R) {
|
||||
float foot_x = (col == right_col) ? x + w - 1 : x;
|
||||
float slope_y = getSlopeY(col, row, foot_x);
|
||||
if (slope_y <= foot_y && slope_y >= foot_y - TS) {
|
||||
return {true, Tile::SLOPE_R, col, row, slope_y};
|
||||
return {.on_slope = true, .type = Tile::SLOPE_R, .tile_x = col, .tile_y = row, .surface_y = slope_y};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user