From 3e8768866c217238125700c12f1fe38f446024db Mon Sep 17 00:00:00 2001 From: Christian Kroll Date: Sun, 26 Jun 2011 00:17:51 +0000 Subject: [PATCH] cosmetic cleanups and fixed bucket limits (didn't cause any bugs, though) --- games/tetris/bucket.c | 20 ++++++++++---------- games/tetris/bucket.h | 6 +++--- games/tetris/variant_bastet.c | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/games/tetris/bucket.c b/games/tetris/bucket.c index 0a24e1d..f294ac6 100644 --- a/games/tetris/bucket.c +++ b/games/tetris/bucket.c @@ -107,14 +107,14 @@ static void tetris_bucket_hoverStatus(tetris_bucket_t *pBucket) tetris_bucket_t *tetris_bucket_construct(int8_t nWidth, int8_t nHeight) { - assert((nWidth >= 4) && (nWidth <= 16)); - assert((nHeight >= 4) && (nHeight <= 124)); + assert((nWidth >= 4) && (nWidth <= TETRIS_BUCKET_MAX_COLUMNS)); + assert((nHeight >= 4) && (nHeight <= TETRIS_BUCKET_MAX_ROWS)); // allocating memory tetris_bucket_t *pBucket = (tetris_bucket_t *)malloc(sizeof(tetris_bucket_t)); 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); // setting requested attributes @@ -355,8 +355,8 @@ int8_t tetris_bucket_predictDeepestRow(tetris_bucket_t *pBucket, { assert(pBucket != NULL); assert(pPiece != NULL); - assert(nStartRow >= -1 && nStartRow < pBucket->nHeight); - assert(nColumn >= -3 && nColumn < pBucket->nWidth); + assert(nStartRow > TETRIS_BUCKET_INVALID && nStartRow < pBucket->nHeight); + assert(nColumn > TETRIS_BUCKET_INVALID && nColumn < pBucket->nWidth); // exchange current piece of the bucket (to use its collision detection) tetris_piece_t *pActualPiece = pBucket->pPiece; @@ -376,7 +376,7 @@ int8_t tetris_bucket_predictDeepestRow(tetris_bucket_t *pBucket, // bucket overflow? 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(pPiece != NULL); - assert(nRow > -4 && nRow < pBucket->nHeight); - assert(nColumn > -4 && nColumn < pBucket->nWidth); + assert(nRow > TETRIS_BUCKET_INVALID && nRow < pBucket->nHeight); + assert(nColumn > TETRIS_BUCKET_INVALID && nColumn < pBucket->nWidth); // initialization int8_t nCompleteRows = 0; @@ -433,8 +433,8 @@ uint16_t* tetris_bucket_predictBottomRow(tetris_bucket_iterator_t *pIt, assert(pIt != NULL); assert(pBucket != NULL); assert(pPiece != NULL); - assert(nRow > -4 && nRow < pBucket->nHeight); - assert(nColumn > -4 && nColumn < pBucket->nWidth); + assert(nRow > TETRIS_BUCKET_INVALID && nRow < pBucket->nHeight); + assert(nColumn > TETRIS_BUCKET_INVALID && nColumn < pBucket->nWidth); pIt->pBucket = pBucket; pIt->nCurrentRow = pBucket->nHeight - 1; diff --git a/games/tetris/bucket.h b/games/tetris/bucket.h index 0dc67f1..7a5d00e 100644 --- a/games/tetris/bucket.h +++ b/games/tetris/bucket.h @@ -13,9 +13,9 @@ * defines * ***********/ -#define TETRIS_BUCKET_INVALIDROW -4 -#define TETRIS_BUCKET_MAX_COLUMNS (INT8_MAX - 4) -#define TETRIS_BUCKET_MAX_ROWS +#define TETRIS_BUCKET_INVALID -4 +#define TETRIS_BUCKET_MAX_COLUMNS 16 +#define TETRIS_BUCKET_MAX_ROWS (INT8_MAX - 4) /********* diff --git a/games/tetris/variant_bastet.c b/games/tetris/variant_bastet.c index 0f2aaf8..506645c 100644 --- a/games/tetris/variant_bastet.c +++ b/games/tetris/variant_bastet.c @@ -171,7 +171,7 @@ static int16_t tetris_bastet_evaluateMove(tetris_bastet_variant_t *pBastet, pPiece, pBastet->pStartingRow[nColumn + 3], nColumn); // in case the prediction fails we return the lowest possible score - if (nDeepestRow <= TETRIS_BUCKET_INVALIDROW) + if (nDeepestRow <= TETRIS_BUCKET_INVALID) { return -32766; }