From 5a7be738ddcd3f40832d60a08bd80cd89e937f8f Mon Sep 17 00:00:00 2001 From: Totto16 Date: Wed, 6 Nov 2024 14:18:41 +0100 Subject: [PATCH 1/2] fix: store coordinates from minostack in unsigned ot signed number, as we only can store positive points anyways, the negative is only for intermediate calculations --- .../recordings/utility/tetrion_snapshot.cpp | 17 ++++++++++++----- .../recordings/utility/tetrion_snapshot.hpp | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/libs/recordings/utility/tetrion_snapshot.cpp b/src/libs/recordings/utility/tetrion_snapshot.cpp index 80c9a4e1..5a0e158a 100644 --- a/src/libs/recordings/utility/tetrion_snapshot.cpp +++ b/src/libs/recordings/utility/tetrion_snapshot.cpp @@ -82,7 +82,9 @@ helper::expected TetrionSnapshot::from_istream(std }; } - mino_stack.set(grid::GridPoint(x_coord.value(), y_coord.value()), maybe_type.value()); + auto mino_pos = shapes::AbstractPoint(x_coord.value(), y_coord.value()); + + mino_stack.set(mino_pos.cast(), maybe_type.value()); } @@ -148,12 +150,17 @@ TetrionSnapshot::TetrionSnapshot( for (const auto& mino : m_mino_stack.minos()) { static_assert(sizeof(Coordinate) == 1); + static_assert(not std::is_signed_v); + + auto mino_pos = mino.position().cast(); - static_assert(sizeof(decltype(mino.position().x)) == 1); - helper::writer::append_value(bytes, mino.position().x); + static_assert(sizeof(decltype(mino_pos.x)) == 1); + static_assert(not std::is_signed_v); + helper::writer::append_value(bytes, mino_pos.x); - static_assert(sizeof(decltype(mino.position().y)) == 1); - helper::writer::append_value(bytes, mino.position().y); + static_assert(sizeof(decltype(mino_pos.y)) == 1); + static_assert(not std::is_signed_v); + helper::writer::append_value(bytes, mino_pos.y); static_assert(sizeof(std::underlying_type_t) == 1); helper::writer::append_value(bytes, std::to_underlying(mino.type())); diff --git a/src/libs/recordings/utility/tetrion_snapshot.hpp b/src/libs/recordings/utility/tetrion_snapshot.hpp index abadda34..f833e764 100644 --- a/src/libs/recordings/utility/tetrion_snapshot.hpp +++ b/src/libs/recordings/utility/tetrion_snapshot.hpp @@ -28,7 +28,7 @@ struct TetrionSnapshot final { public: using MinoCount = u64; - using Coordinate = i8; + using Coordinate = u8; OOPETRIS_RECORDINGS_EXPORTED TetrionSnapshot( u8 tetrion_index, From 947357b3ad0a7268a39c00c6c7ddbe67002a2261 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Tue, 5 Nov 2024 23:15:23 +0100 Subject: [PATCH 2/2] fix: wrong assertion in grid_layout --- src/ui/layouts/grid_layout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/layouts/grid_layout.cpp b/src/ui/layouts/grid_layout.cpp index f2d21ea0..e5533916 100644 --- a/src/ui/layouts/grid_layout.cpp +++ b/src/ui/layouts/grid_layout.cpp @@ -53,7 +53,7 @@ void ui::GridLayout::render(const ServiceProvider& service_provider) const { x_pos += margin_x + total_width; } else { const u32 total_margin = this->m_size <= 1 ? 0 : (this->m_size - 1) * m_gap.get_margin(); - assert(layout().get_rect().height() > (total_margin - (m_margin.second * 2)) + assert(layout().get_rect().height() > (total_margin + (m_margin.second * 2)) && "height has to be greater than the margins"); height = (layout().get_rect().height() - total_margin - (m_margin.second * 2)) / this->m_size;