remove 16x16 limitation on board size, replacing with 32x32. Change

is enabled by a compile-time flag so Android needn't follow yet.
This commit is contained in:
Andy2 2011-11-14 18:21:41 -08:00
parent d6fecaa3d3
commit 86d5778ec3
10 changed files with 52 additions and 19 deletions

View file

@ -1198,7 +1198,7 @@ invalPerimeter( BoardCtxt* board )
ScrollData* hsd = &board->sd[SCROLL_H];
XP_U16 firstCol = hsd->offset;
XP_U16 lastCol = hsd->lastVisible;
XP_U16 firstAndLast = (1 << lastCol) | (1 << firstCol);
RowFlags firstAndLast = (1 << lastCol) | (1 << firstCol);
ScrollData* vsd = &board->sd[SCROLL_V];
XP_U16 firstRow = vsd->offset;
XP_U16 lastRow = vsd->lastVisible;
@ -1588,7 +1588,7 @@ invalReflection( BoardCtxt* board )
while ( nRows-- ) {
XP_U16 nCols;
XP_U16 redrawFlag = board->redrawFlags[nRows];
RowFlags redrawFlag = board->redrawFlags[nRows];
if ( !redrawFlag ) {
continue; /* nothing set this row */
}

View file

@ -299,11 +299,11 @@ drawBoard( BoardCtxt* board )
nVisCols = model_numCols( model ) - board->zoomCount;
for ( row = vsd->offset; row <= vsd->lastVisible; ++row ) {
XP_U16 rowFlags = board->redrawFlags[row];
RowFlags rowFlags = board->redrawFlags[row];
if ( rowFlags != 0 ) {
XP_U16 failedBits = 0;
RowFlags failedBits = 0;
for ( col = 0; col < nVisCols; ++col ) {
XP_U16 colMask = 1 << (col + hsd->offset);
RowFlags colMask = 1 << (col + hsd->offset);
if ( 0 != (rowFlags & colMask) ) {
if ( !drawCell( board, col + hsd->offset,
row, XP_TRUE )) {

View file

@ -157,7 +157,7 @@ struct BoardCtxt {
XP_S16 timerStoppedTurn;
#endif
XP_U16 redrawFlags[MAX_ROWS];
RowFlags redrawFlags[MAX_ROWS];
XP_Rect boardBounds;
XP_U16 heightAsSet;

View file

@ -115,7 +115,9 @@ typedef enum {
} XWTimerReason;
#define MAX_NUM_PLAYERS 4
#define MAX_ROWS 16
#ifndef MAX_ROWS
# define MAX_ROWS 16
#endif
#define MAX_COLS MAX_ROWS
#ifdef EIGHT_TILES
# define MAX_TRAY_TILES 8
@ -127,6 +129,14 @@ typedef enum {
#define NPLAYERS_NBITS 3
#define EMPTIED_TRAY_BONUS 50
#if MAX_ROWS <= 16
typedef XP_U16 RowFlags;
#elif MAX_ROWS <= 32
typedef XP_U32 RowFlags;
#else
error
#endif
/* I need a way to communiate prefs to common/ code. For now, though, I'll
* leave storage of these values up to the platforms. First, because I don't
* want to deal with versioning in the common code. Second, becuase they

View file

@ -432,7 +432,10 @@ gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi )
XP_FREEP( mpool, &str );
gi->nPlayers = (XP_U8)stream_getBits( stream, NPLAYERS_NBITS );
gi->boardSize = (XP_U8)stream_getBits( stream, 4 );
gi->boardSize =
(XP_U8)stream_getBits( stream,
strVersion < STREAM_VERS_BIGBOARD? 4 :
NUMCOLS_NBITS );
gi->serverRole = (DeviceRole)stream_getBits( stream, 2 );
gi->hintsNotAllowed = stream_getBits( stream, 1 );
if ( strVersion < STREAM_VERS_ROBOTIQ ) {
@ -494,7 +497,7 @@ gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi )
stringToStream( stream, gi->dictName );
stream_putBits( stream, NPLAYERS_NBITS, gi->nPlayers );
stream_putBits( stream, 4, gi->boardSize );
stream_putBits( stream, NUMCOLS_NBITS, gi->boardSize );
stream_putBits( stream, 2, gi->serverRole );
stream_putBits( stream, 1, gi->hintsNotAllowed );
stream_putBits( stream, 2, gi->phoniesAction );

View file

@ -31,6 +31,11 @@
extern "C" {
#endif
#if MAX_COLS > 16
# define STREAM_VERS_BIGBOARD 0x12
#else
# define STREAM_VERS_BIGBOARD 0x11
#endif
#define STREAM_SAVE_PREVWORDS 0x11
#define STREAM_VERS_SERVER_SAVES_TOSHOW 0x10
#define STREAM_VERS_PLAYERDICTS 0x0F
@ -53,7 +58,7 @@ extern "C" {
#define STREAM_VERS_41B4 0x02
#define STREAM_VERS_405 0x01
#define CUR_STREAM_VERS STREAM_SAVE_PREVWORDS
#define CUR_STREAM_VERS STREAM_VERS_BIGBOARD
typedef struct LocalPlayer {
XP_UCHAR* name;

View file

@ -119,11 +119,14 @@ model_makeFromStream( MPFORMAL XWStreamCtxt* stream, DictionaryCtxt* dict,
XP_Bool hasDict;
XP_U16 nPlayers;
XP_U16 version = stream_getVersion( stream );
XP_U16 nColsNBits =
STREAM_VERS_BIGBOARD > version ? 4 :
NUMCOLS_NBITS;
XP_ASSERT( !!dict || !!dicts );
nCols = (XP_U16)stream_getBits( stream, NUMCOLS_NBITS );
nRows = (XP_U16)stream_getBits( stream, NUMCOLS_NBITS );
nCols = (XP_U16)stream_getBits( stream, nColsNBits );
nRows = (XP_U16)stream_getBits( stream, nColsNBits );
hasDict = (version >= STREAM_VERS_MODEL_NO_DICT)
? XP_FALSE : stream_getBits( stream, 1 );
@ -849,6 +852,9 @@ model_makeTurnFromStream( ModelCtxt* model, XP_U16 playerNum,
{
XP_U16 numTiles;
Tile blank = dict_getBlankTile( model_getDictionary(model) );
XP_U16 nColsNBits =
STREAM_VERS_BIGBOARD > stream_getVersion( stream ) ? 4 :
NUMCOLS_NBITS;
model_resetCurrentTurn( model, playerNum );
@ -860,8 +866,8 @@ model_makeTurnFromStream( ModelCtxt* model, XP_U16 playerNum,
XP_S16 foundAt;
Tile moveTile;
Tile tileFace = (Tile)stream_getBits( stream, TILE_NBITS );
XP_U16 col = (XP_U16)stream_getBits( stream, NUMCOLS_NBITS );
XP_U16 row = (XP_U16)stream_getBits( stream, NUMCOLS_NBITS );
XP_U16 col = (XP_U16)stream_getBits( stream, nColsNBits );
XP_U16 row = (XP_U16)stream_getBits( stream, nColsNBits );
XP_Bool isBlank = stream_getBits( stream, 1 );
/* This code gets called both for the server, which has all the
@ -2215,6 +2221,9 @@ loadPlayerCtxt( XWStreamCtxt* stream, XP_U16 version, PlayerCtxt* pc )
{
PendingTile* pt;
XP_U16 nTiles;
XP_U16 nColsNBits =
STREAM_VERS_BIGBOARD > stream_getVersion( stream ) ? 4 :
NUMCOLS_NBITS;
pc->curMoveValid = stream_getBits( stream, 1 );
@ -2230,8 +2239,8 @@ loadPlayerCtxt( XWStreamCtxt* stream, XP_U16 version, PlayerCtxt* pc )
nTiles = pc->nPending + pc->nUndone;
for ( pt = pc->pendingTiles; nTiles-- > 0; ++pt ) {
XP_U16 nBits;
pt->col = (XP_U8)stream_getBits( stream, NUMCOLS_NBITS );
pt->row = (XP_U8)stream_getBits( stream, NUMCOLS_NBITS );
pt->col = (XP_U8)stream_getBits( stream, nColsNBits );
pt->row = (XP_U8)stream_getBits( stream, nColsNBits );
nBits = (version <= STREAM_VERS_RELAY) ? 6 : 7;
pt->tile = (Tile)stream_getBits( stream, nBits );

View file

@ -29,7 +29,11 @@
extern "C" {
#endif
#define NUMCOLS_NBITS 4
#if MAX_COLS <= 16
# define NUMCOLS_NBITS 4
#elif MAX_COLS <= 32
# define NUMCOLS_NBITS 5
#endif
#ifdef EIGHT_TILES
# define NTILES_NBITS 4

View file

@ -93,6 +93,7 @@ DEFINES += -DSET_GAMESEED
DEFINES += -DTEXT_MODEL
DEFINES += -DXWFEATURE_WALKDICT
DEFINES += -DXWFEATURE_DICTSANITY
#DEFINES += -DMAX_ROWS=32
ifdef CURSES_CELL_HT
DEFINES += -DCURSES_CELL_HT=$(CURSES_CELL_HT)

View file

@ -179,8 +179,9 @@ linux_util_getSquareBonus( XW_UtilCtxt* uc, const ModelCtxt* model,
TW,EM,EM,DL,EM,EM,EM,DW,
}; /* scrabbleBoard */
if ( col > 7 ) col = 14 - col;
if ( row > 7 ) row = 14 - row;
XP_U16 nCols = model_numCols( model );
if ( col > (nCols/2) ) col = nCols - 1 - col;
if ( row > (nCols/2) ) row = nCols - 1 - row;
if ( col > row ) {
XP_U16 tmp = col;
col = row;