Skip to content

Commit 8d7b2cf

Browse files
authored
Merge pull request #204 from OpenBrickProtocolFoundation/store_mino_stack_as_u8
Store mino stack as u8
2 parents 3328fb7 + 947357b commit 8d7b2cf

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/libs/recordings/utility/tetrion_snapshot.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ helper::expected<TetrionSnapshot, std::string> TetrionSnapshot::from_istream(std
8282
};
8383
}
8484

85-
mino_stack.set(grid::GridPoint(x_coord.value(), y_coord.value()), maybe_type.value());
85+
auto mino_pos = shapes::AbstractPoint<Coordinate>(x_coord.value(), y_coord.value());
86+
87+
mino_stack.set(mino_pos.cast<i8>(), maybe_type.value());
8688
}
8789

8890

@@ -148,12 +150,17 @@ TetrionSnapshot::TetrionSnapshot(
148150

149151
for (const auto& mino : m_mino_stack.minos()) {
150152
static_assert(sizeof(Coordinate) == 1);
153+
static_assert(not std::is_signed_v<Coordinate>);
154+
155+
auto mino_pos = mino.position().cast<u8>();
151156

152-
static_assert(sizeof(decltype(mino.position().x)) == 1);
153-
helper::writer::append_value(bytes, mino.position().x);
157+
static_assert(sizeof(decltype(mino_pos.x)) == 1);
158+
static_assert(not std::is_signed_v<decltype(mino_pos.x)>);
159+
helper::writer::append_value(bytes, mino_pos.x);
154160

155-
static_assert(sizeof(decltype(mino.position().y)) == 1);
156-
helper::writer::append_value(bytes, mino.position().y);
161+
static_assert(sizeof(decltype(mino_pos.y)) == 1);
162+
static_assert(not std::is_signed_v<decltype(mino_pos.y)>);
163+
helper::writer::append_value(bytes, mino_pos.y);
157164

158165
static_assert(sizeof(std::underlying_type_t<helper::TetrominoType>) == 1);
159166
helper::writer::append_value(bytes, std::to_underlying(mino.type()));

src/libs/recordings/utility/tetrion_snapshot.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct TetrionSnapshot final {
2828

2929
public:
3030
using MinoCount = u64;
31-
using Coordinate = i8;
31+
using Coordinate = u8;
3232

3333
OOPETRIS_RECORDINGS_EXPORTED TetrionSnapshot(
3434
u8 tetrion_index,

src/ui/layouts/grid_layout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void ui::GridLayout::render(const ServiceProvider& service_provider) const {
5353
x_pos += margin_x + total_width;
5454
} else {
5555
const u32 total_margin = this->m_size <= 1 ? 0 : (this->m_size - 1) * m_gap.get_margin();
56-
assert(layout().get_rect().height() > (total_margin - (m_margin.second * 2))
56+
assert(layout().get_rect().height() > (total_margin + (m_margin.second * 2))
5757
&& "height has to be greater than the margins");
5858
height = (layout().get_rect().height() - total_margin - (m_margin.second * 2)) / this->m_size;
5959

0 commit comments

Comments
 (0)