cosmetic cleanups and fixed bucket limits (didn't cause any bugs, though)
This commit is contained in:
parent
49c4707896
commit
3e8768866c
|
@ -107,14 +107,14 @@ static void tetris_bucket_hoverStatus(tetris_bucket_t *pBucket)
|
||||||
tetris_bucket_t *tetris_bucket_construct(int8_t nWidth,
|
tetris_bucket_t *tetris_bucket_construct(int8_t nWidth,
|
||||||
int8_t nHeight)
|
int8_t nHeight)
|
||||||
{
|
{
|
||||||
assert((nWidth >= 4) && (nWidth <= 16));
|
assert((nWidth >= 4) && (nWidth <= TETRIS_BUCKET_MAX_COLUMNS));
|
||||||
assert((nHeight >= 4) && (nHeight <= 124));
|
assert((nHeight >= 4) && (nHeight <= TETRIS_BUCKET_MAX_ROWS));
|
||||||
|
|
||||||
// allocating memory
|
// allocating memory
|
||||||
tetris_bucket_t *pBucket =
|
tetris_bucket_t *pBucket =
|
||||||
(tetris_bucket_t *)malloc(sizeof(tetris_bucket_t));
|
(tetris_bucket_t *)malloc(sizeof(tetris_bucket_t));
|
||||||
assert(pBucket != NULL);
|
assert(pBucket != NULL);
|
||||||
pBucket->dump = (uint16_t*) calloc(nHeight, sizeof(uint16_t));
|
pBucket->dump = (uint16_t *)calloc(nHeight, sizeof(uint16_t));
|
||||||
assert(pBucket->dump != NULL);
|
assert(pBucket->dump != NULL);
|
||||||
|
|
||||||
// setting requested attributes
|
// setting requested attributes
|
||||||
|
@ -355,8 +355,8 @@ int8_t tetris_bucket_predictDeepestRow(tetris_bucket_t *pBucket,
|
||||||
{
|
{
|
||||||
assert(pBucket != NULL);
|
assert(pBucket != NULL);
|
||||||
assert(pPiece != NULL);
|
assert(pPiece != NULL);
|
||||||
assert(nStartRow >= -1 && nStartRow < pBucket->nHeight);
|
assert(nStartRow > TETRIS_BUCKET_INVALID && nStartRow < pBucket->nHeight);
|
||||||
assert(nColumn >= -3 && nColumn < pBucket->nWidth);
|
assert(nColumn > TETRIS_BUCKET_INVALID && nColumn < pBucket->nWidth);
|
||||||
|
|
||||||
// exchange current piece of the bucket (to use its collision detection)
|
// exchange current piece of the bucket (to use its collision detection)
|
||||||
tetris_piece_t *pActualPiece = pBucket->pPiece;
|
tetris_piece_t *pActualPiece = pBucket->pPiece;
|
||||||
|
@ -376,7 +376,7 @@ int8_t tetris_bucket_predictDeepestRow(tetris_bucket_t *pBucket,
|
||||||
// bucket overflow?
|
// bucket overflow?
|
||||||
if (nStartRow < 0 && ((0xFFFF >> (((4 + nStartRow) * 4))) & nMap))
|
if (nStartRow < 0 && ((0xFFFF >> (((4 + nStartRow) * 4))) & nMap))
|
||||||
{
|
{
|
||||||
nStartRow = TETRIS_BUCKET_INVALIDROW;
|
nStartRow = TETRIS_BUCKET_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,8 +394,8 @@ int8_t tetris_bucket_predictCompleteLines(tetris_bucket_t *pBucket,
|
||||||
{
|
{
|
||||||
assert(pBucket != NULL);
|
assert(pBucket != NULL);
|
||||||
assert(pPiece != NULL);
|
assert(pPiece != NULL);
|
||||||
assert(nRow > -4 && nRow < pBucket->nHeight);
|
assert(nRow > TETRIS_BUCKET_INVALID && nRow < pBucket->nHeight);
|
||||||
assert(nColumn > -4 && nColumn < pBucket->nWidth);
|
assert(nColumn > TETRIS_BUCKET_INVALID && nColumn < pBucket->nWidth);
|
||||||
|
|
||||||
// initialization
|
// initialization
|
||||||
int8_t nCompleteRows = 0;
|
int8_t nCompleteRows = 0;
|
||||||
|
@ -433,8 +433,8 @@ uint16_t* tetris_bucket_predictBottomRow(tetris_bucket_iterator_t *pIt,
|
||||||
assert(pIt != NULL);
|
assert(pIt != NULL);
|
||||||
assert(pBucket != NULL);
|
assert(pBucket != NULL);
|
||||||
assert(pPiece != NULL);
|
assert(pPiece != NULL);
|
||||||
assert(nRow > -4 && nRow < pBucket->nHeight);
|
assert(nRow > TETRIS_BUCKET_INVALID && nRow < pBucket->nHeight);
|
||||||
assert(nColumn > -4 && nColumn < pBucket->nWidth);
|
assert(nColumn > TETRIS_BUCKET_INVALID && nColumn < pBucket->nWidth);
|
||||||
|
|
||||||
pIt->pBucket = pBucket;
|
pIt->pBucket = pBucket;
|
||||||
pIt->nCurrentRow = pBucket->nHeight - 1;
|
pIt->nCurrentRow = pBucket->nHeight - 1;
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
* defines *
|
* defines *
|
||||||
***********/
|
***********/
|
||||||
|
|
||||||
#define TETRIS_BUCKET_INVALIDROW -4
|
#define TETRIS_BUCKET_INVALID -4
|
||||||
#define TETRIS_BUCKET_MAX_COLUMNS (INT8_MAX - 4)
|
#define TETRIS_BUCKET_MAX_COLUMNS 16
|
||||||
#define TETRIS_BUCKET_MAX_ROWS
|
#define TETRIS_BUCKET_MAX_ROWS (INT8_MAX - 4)
|
||||||
|
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
|
|
|
@ -171,7 +171,7 @@ static int16_t tetris_bastet_evaluateMove(tetris_bastet_variant_t *pBastet,
|
||||||
pPiece, pBastet->pStartingRow[nColumn + 3], nColumn);
|
pPiece, pBastet->pStartingRow[nColumn + 3], nColumn);
|
||||||
|
|
||||||
// in case the prediction fails we return the lowest possible score
|
// in case the prediction fails we return the lowest possible score
|
||||||
if (nDeepestRow <= TETRIS_BUCKET_INVALIDROW)
|
if (nDeepestRow <= TETRIS_BUCKET_INVALID)
|
||||||
{
|
{
|
||||||
return -32766;
|
return -32766;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue