summaryrefslogtreecommitdiff
path: root/Userland/Games
diff options
context:
space:
mode:
authorJean-Baptiste Boric <jblbeurope@gmail.com>2021-05-16 14:55:20 +0200
committerLinus Groh <mail@linusgroh.de>2021-05-17 18:14:05 +0100
commit0262a99a1f0b0c07de4a5742d05338133b18c3ef (patch)
tree902f78f9fd5bfb1b3e5c8c107fdd7919f885b3c5 /Userland/Games
parentd0eb376520db8fc2f95547f272fe4727f247d0fa (diff)
downloadserenity-0262a99a1f0b0c07de4a5742d05338133b18c3ef.zip
Chess: Fix signed/unsigned issues
Make everything signed so that we don't have to deal with silly casting issues thoughout the Chess code. I am unsure if this affects the chess AI negatively, it seems just as "intelligent" before and after this change :^)
Diffstat (limited to 'Userland/Games')
-rw-r--r--Userland/Games/Chess/ChessWidget.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/Userland/Games/Chess/ChessWidget.cpp b/Userland/Games/Chess/ChessWidget.cpp
index eb17457682..92921bb6be 100644
--- a/Userland/Games/Chess/ChessWidget.cpp
+++ b/Userland/Games/Chess/ChessWidget.cpp
@@ -37,7 +37,7 @@ void ChessWidget::paint_event(GUI::PaintEvent& event)
size_t tile_width = frame_inner_rect().width() / 8;
size_t tile_height = frame_inner_rect().height() / 8;
- unsigned coord_rank_file = (side() == Chess::Color::White) ? 0 : 7;
+ int coord_rank_file = (side() == Chess::Color::White) ? 0 : 7;
Chess::Board& active_board = (m_playback ? board_playback() : board());
@@ -362,13 +362,13 @@ void ChessWidget::set_piece_set(const StringView& set)
Chess::Square ChessWidget::mouse_to_square(GUI::MouseEvent& event) const
{
- unsigned tile_width = frame_inner_rect().width() / 8;
- unsigned tile_height = frame_inner_rect().height() / 8;
+ int tile_width = frame_inner_rect().width() / 8;
+ int tile_height = frame_inner_rect().height() / 8;
if (side() == Chess::Color::White) {
- return { (unsigned)(7 - (event.y() / tile_height)), (unsigned)(event.x() / tile_width) };
+ return { 7 - (event.y() / tile_height), event.x() / tile_width };
} else {
- return { (unsigned)(event.y() / tile_height), (unsigned)(7 - (event.x() / tile_width)) };
+ return { event.y() / tile_height, 7 - (event.x() / tile_width) };
}
}