Fixed types

This commit is contained in:
AnnaSnoeijs 2025-06-25 11:31:45 +02:00
parent 8c41443935
commit 22356ca529

14
logic.c
View file

@ -19,21 +19,21 @@
#include "logic.h" #include "logic.h"
#include "macros.h" #include "macros.h"
static int heightMask( const int a ){ static column_t heightMask( const rowsint_t a ){
return ( 1 << a ) - 1; return ( 1 << a ) - 1;
} }
static int safeHeightMask( const int a ){ static column_t safeHeightMask( const rowsint_t a ){
return a > 0 ? heightMask( a ) : 0; return a > 0 ? heightMask( a ) : 0;
} }
static int bottomHeightMask( const int a, const int b ){ static column_t bottomHeightMask( const rowsint_t a, const rowsint_t b ){
return safeHeightMask( bottom( a, b ) ); return safeHeightMask( bottom( a, b ) );
} }
void playMove( void playMove(
board_t *boardptr, board_t *boardptr,
const int column const columnsint_t column
){ ){
boardptr->column [ column ] |= boardptr->column [ column ] |=
boardptr->player << boardptr->height [ column ]; boardptr->player << boardptr->height [ column ];
@ -43,7 +43,7 @@ void playMove(
void calcWins( void calcWins(
wins_t *wins, wins_t *wins,
const board_t board, const board_t board,
const int column const columnsint_t column
){ ){
// First the simplest win, the humble tower // First the simplest win, the humble tower
// Check for lil towers // Check for lil towers
@ -72,7 +72,7 @@ void calcWins(
// Now the rest of the wins // Now the rest of the wins
// First connect 2 // First connect 2
for( for(
int i = top( column - 1, 0 ); columnsint_t i = top( column - 1, 0 );
i < bottom( column + 1, board.columns - 1 ); i < bottom( column + 1, board.columns - 1 );
i++ i++
){ ){
@ -101,7 +101,7 @@ void calcWins(
} }
// Then stitch the twos together and count // Then stitch the twos together and count
for( for(
int i = top( column - 3, 0 ); columnsint_t i = top( column - 3, 0 );
i < bottom( column + 1, board.columns - 3 ); i < bottom( column + 1, board.columns - 3 );
i++ i++
){ ){