mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-14 08:01:38 +01:00
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:
parent
d6fecaa3d3
commit
86d5778ec3
10 changed files with 52 additions and 19 deletions
|
@ -1198,7 +1198,7 @@ invalPerimeter( BoardCtxt* board )
|
||||||
ScrollData* hsd = &board->sd[SCROLL_H];
|
ScrollData* hsd = &board->sd[SCROLL_H];
|
||||||
XP_U16 firstCol = hsd->offset;
|
XP_U16 firstCol = hsd->offset;
|
||||||
XP_U16 lastCol = hsd->lastVisible;
|
XP_U16 lastCol = hsd->lastVisible;
|
||||||
XP_U16 firstAndLast = (1 << lastCol) | (1 << firstCol);
|
RowFlags firstAndLast = (1 << lastCol) | (1 << firstCol);
|
||||||
ScrollData* vsd = &board->sd[SCROLL_V];
|
ScrollData* vsd = &board->sd[SCROLL_V];
|
||||||
XP_U16 firstRow = vsd->offset;
|
XP_U16 firstRow = vsd->offset;
|
||||||
XP_U16 lastRow = vsd->lastVisible;
|
XP_U16 lastRow = vsd->lastVisible;
|
||||||
|
@ -1588,7 +1588,7 @@ invalReflection( BoardCtxt* board )
|
||||||
|
|
||||||
while ( nRows-- ) {
|
while ( nRows-- ) {
|
||||||
XP_U16 nCols;
|
XP_U16 nCols;
|
||||||
XP_U16 redrawFlag = board->redrawFlags[nRows];
|
RowFlags redrawFlag = board->redrawFlags[nRows];
|
||||||
if ( !redrawFlag ) {
|
if ( !redrawFlag ) {
|
||||||
continue; /* nothing set this row */
|
continue; /* nothing set this row */
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,11 +299,11 @@ drawBoard( BoardCtxt* board )
|
||||||
|
|
||||||
nVisCols = model_numCols( model ) - board->zoomCount;
|
nVisCols = model_numCols( model ) - board->zoomCount;
|
||||||
for ( row = vsd->offset; row <= vsd->lastVisible; ++row ) {
|
for ( row = vsd->offset; row <= vsd->lastVisible; ++row ) {
|
||||||
XP_U16 rowFlags = board->redrawFlags[row];
|
RowFlags rowFlags = board->redrawFlags[row];
|
||||||
if ( rowFlags != 0 ) {
|
if ( rowFlags != 0 ) {
|
||||||
XP_U16 failedBits = 0;
|
RowFlags failedBits = 0;
|
||||||
for ( col = 0; col < nVisCols; ++col ) {
|
for ( col = 0; col < nVisCols; ++col ) {
|
||||||
XP_U16 colMask = 1 << (col + hsd->offset);
|
RowFlags colMask = 1 << (col + hsd->offset);
|
||||||
if ( 0 != (rowFlags & colMask) ) {
|
if ( 0 != (rowFlags & colMask) ) {
|
||||||
if ( !drawCell( board, col + hsd->offset,
|
if ( !drawCell( board, col + hsd->offset,
|
||||||
row, XP_TRUE )) {
|
row, XP_TRUE )) {
|
||||||
|
|
|
@ -157,7 +157,7 @@ struct BoardCtxt {
|
||||||
XP_S16 timerStoppedTurn;
|
XP_S16 timerStoppedTurn;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XP_U16 redrawFlags[MAX_ROWS];
|
RowFlags redrawFlags[MAX_ROWS];
|
||||||
|
|
||||||
XP_Rect boardBounds;
|
XP_Rect boardBounds;
|
||||||
XP_U16 heightAsSet;
|
XP_U16 heightAsSet;
|
||||||
|
|
|
@ -115,7 +115,9 @@ typedef enum {
|
||||||
} XWTimerReason;
|
} XWTimerReason;
|
||||||
|
|
||||||
#define MAX_NUM_PLAYERS 4
|
#define MAX_NUM_PLAYERS 4
|
||||||
#define MAX_ROWS 16
|
#ifndef MAX_ROWS
|
||||||
|
# define MAX_ROWS 16
|
||||||
|
#endif
|
||||||
#define MAX_COLS MAX_ROWS
|
#define MAX_COLS MAX_ROWS
|
||||||
#ifdef EIGHT_TILES
|
#ifdef EIGHT_TILES
|
||||||
# define MAX_TRAY_TILES 8
|
# define MAX_TRAY_TILES 8
|
||||||
|
@ -127,6 +129,14 @@ typedef enum {
|
||||||
#define NPLAYERS_NBITS 3
|
#define NPLAYERS_NBITS 3
|
||||||
#define EMPTIED_TRAY_BONUS 50
|
#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
|
/* 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
|
* 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
|
* want to deal with versioning in the common code. Second, becuase they
|
||||||
|
|
|
@ -432,7 +432,10 @@ gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi )
|
||||||
XP_FREEP( mpool, &str );
|
XP_FREEP( mpool, &str );
|
||||||
|
|
||||||
gi->nPlayers = (XP_U8)stream_getBits( stream, NPLAYERS_NBITS );
|
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->serverRole = (DeviceRole)stream_getBits( stream, 2 );
|
||||||
gi->hintsNotAllowed = stream_getBits( stream, 1 );
|
gi->hintsNotAllowed = stream_getBits( stream, 1 );
|
||||||
if ( strVersion < STREAM_VERS_ROBOTIQ ) {
|
if ( strVersion < STREAM_VERS_ROBOTIQ ) {
|
||||||
|
@ -494,7 +497,7 @@ gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi )
|
||||||
stringToStream( stream, gi->dictName );
|
stringToStream( stream, gi->dictName );
|
||||||
|
|
||||||
stream_putBits( stream, NPLAYERS_NBITS, gi->nPlayers );
|
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, 2, gi->serverRole );
|
||||||
stream_putBits( stream, 1, gi->hintsNotAllowed );
|
stream_putBits( stream, 1, gi->hintsNotAllowed );
|
||||||
stream_putBits( stream, 2, gi->phoniesAction );
|
stream_putBits( stream, 2, gi->phoniesAction );
|
||||||
|
|
|
@ -31,6 +31,11 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MAX_COLS > 16
|
||||||
|
# define STREAM_VERS_BIGBOARD 0x12
|
||||||
|
#else
|
||||||
|
# define STREAM_VERS_BIGBOARD 0x11
|
||||||
|
#endif
|
||||||
#define STREAM_SAVE_PREVWORDS 0x11
|
#define STREAM_SAVE_PREVWORDS 0x11
|
||||||
#define STREAM_VERS_SERVER_SAVES_TOSHOW 0x10
|
#define STREAM_VERS_SERVER_SAVES_TOSHOW 0x10
|
||||||
#define STREAM_VERS_PLAYERDICTS 0x0F
|
#define STREAM_VERS_PLAYERDICTS 0x0F
|
||||||
|
@ -53,7 +58,7 @@ extern "C" {
|
||||||
#define STREAM_VERS_41B4 0x02
|
#define STREAM_VERS_41B4 0x02
|
||||||
#define STREAM_VERS_405 0x01
|
#define STREAM_VERS_405 0x01
|
||||||
|
|
||||||
#define CUR_STREAM_VERS STREAM_SAVE_PREVWORDS
|
#define CUR_STREAM_VERS STREAM_VERS_BIGBOARD
|
||||||
|
|
||||||
typedef struct LocalPlayer {
|
typedef struct LocalPlayer {
|
||||||
XP_UCHAR* name;
|
XP_UCHAR* name;
|
||||||
|
|
|
@ -119,11 +119,14 @@ model_makeFromStream( MPFORMAL XWStreamCtxt* stream, DictionaryCtxt* dict,
|
||||||
XP_Bool hasDict;
|
XP_Bool hasDict;
|
||||||
XP_U16 nPlayers;
|
XP_U16 nPlayers;
|
||||||
XP_U16 version = stream_getVersion( stream );
|
XP_U16 version = stream_getVersion( stream );
|
||||||
|
XP_U16 nColsNBits =
|
||||||
|
STREAM_VERS_BIGBOARD > version ? 4 :
|
||||||
|
NUMCOLS_NBITS;
|
||||||
|
|
||||||
XP_ASSERT( !!dict || !!dicts );
|
XP_ASSERT( !!dict || !!dicts );
|
||||||
|
|
||||||
nCols = (XP_U16)stream_getBits( stream, NUMCOLS_NBITS );
|
nCols = (XP_U16)stream_getBits( stream, nColsNBits );
|
||||||
nRows = (XP_U16)stream_getBits( stream, NUMCOLS_NBITS );
|
nRows = (XP_U16)stream_getBits( stream, nColsNBits );
|
||||||
|
|
||||||
hasDict = (version >= STREAM_VERS_MODEL_NO_DICT)
|
hasDict = (version >= STREAM_VERS_MODEL_NO_DICT)
|
||||||
? XP_FALSE : stream_getBits( stream, 1 );
|
? XP_FALSE : stream_getBits( stream, 1 );
|
||||||
|
@ -849,6 +852,9 @@ model_makeTurnFromStream( ModelCtxt* model, XP_U16 playerNum,
|
||||||
{
|
{
|
||||||
XP_U16 numTiles;
|
XP_U16 numTiles;
|
||||||
Tile blank = dict_getBlankTile( model_getDictionary(model) );
|
Tile blank = dict_getBlankTile( model_getDictionary(model) );
|
||||||
|
XP_U16 nColsNBits =
|
||||||
|
STREAM_VERS_BIGBOARD > stream_getVersion( stream ) ? 4 :
|
||||||
|
NUMCOLS_NBITS;
|
||||||
|
|
||||||
model_resetCurrentTurn( model, playerNum );
|
model_resetCurrentTurn( model, playerNum );
|
||||||
|
|
||||||
|
@ -860,8 +866,8 @@ model_makeTurnFromStream( ModelCtxt* model, XP_U16 playerNum,
|
||||||
XP_S16 foundAt;
|
XP_S16 foundAt;
|
||||||
Tile moveTile;
|
Tile moveTile;
|
||||||
Tile tileFace = (Tile)stream_getBits( stream, TILE_NBITS );
|
Tile tileFace = (Tile)stream_getBits( stream, TILE_NBITS );
|
||||||
XP_U16 col = (XP_U16)stream_getBits( stream, NUMCOLS_NBITS );
|
XP_U16 col = (XP_U16)stream_getBits( stream, nColsNBits );
|
||||||
XP_U16 row = (XP_U16)stream_getBits( stream, NUMCOLS_NBITS );
|
XP_U16 row = (XP_U16)stream_getBits( stream, nColsNBits );
|
||||||
XP_Bool isBlank = stream_getBits( stream, 1 );
|
XP_Bool isBlank = stream_getBits( stream, 1 );
|
||||||
|
|
||||||
/* This code gets called both for the server, which has all the
|
/* 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;
|
PendingTile* pt;
|
||||||
XP_U16 nTiles;
|
XP_U16 nTiles;
|
||||||
|
XP_U16 nColsNBits =
|
||||||
|
STREAM_VERS_BIGBOARD > stream_getVersion( stream ) ? 4 :
|
||||||
|
NUMCOLS_NBITS;
|
||||||
|
|
||||||
pc->curMoveValid = stream_getBits( stream, 1 );
|
pc->curMoveValid = stream_getBits( stream, 1 );
|
||||||
|
|
||||||
|
@ -2230,8 +2239,8 @@ loadPlayerCtxt( XWStreamCtxt* stream, XP_U16 version, PlayerCtxt* pc )
|
||||||
nTiles = pc->nPending + pc->nUndone;
|
nTiles = pc->nPending + pc->nUndone;
|
||||||
for ( pt = pc->pendingTiles; nTiles-- > 0; ++pt ) {
|
for ( pt = pc->pendingTiles; nTiles-- > 0; ++pt ) {
|
||||||
XP_U16 nBits;
|
XP_U16 nBits;
|
||||||
pt->col = (XP_U8)stream_getBits( stream, NUMCOLS_NBITS );
|
pt->col = (XP_U8)stream_getBits( stream, nColsNBits );
|
||||||
pt->row = (XP_U8)stream_getBits( stream, NUMCOLS_NBITS );
|
pt->row = (XP_U8)stream_getBits( stream, nColsNBits );
|
||||||
|
|
||||||
nBits = (version <= STREAM_VERS_RELAY) ? 6 : 7;
|
nBits = (version <= STREAM_VERS_RELAY) ? 6 : 7;
|
||||||
pt->tile = (Tile)stream_getBits( stream, nBits );
|
pt->tile = (Tile)stream_getBits( stream, nBits );
|
||||||
|
|
|
@ -29,7 +29,11 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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
|
#ifdef EIGHT_TILES
|
||||||
# define NTILES_NBITS 4
|
# define NTILES_NBITS 4
|
||||||
|
|
|
@ -93,6 +93,7 @@ DEFINES += -DSET_GAMESEED
|
||||||
DEFINES += -DTEXT_MODEL
|
DEFINES += -DTEXT_MODEL
|
||||||
DEFINES += -DXWFEATURE_WALKDICT
|
DEFINES += -DXWFEATURE_WALKDICT
|
||||||
DEFINES += -DXWFEATURE_DICTSANITY
|
DEFINES += -DXWFEATURE_DICTSANITY
|
||||||
|
#DEFINES += -DMAX_ROWS=32
|
||||||
|
|
||||||
ifdef CURSES_CELL_HT
|
ifdef CURSES_CELL_HT
|
||||||
DEFINES += -DCURSES_CELL_HT=$(CURSES_CELL_HT)
|
DEFINES += -DCURSES_CELL_HT=$(CURSES_CELL_HT)
|
||||||
|
|
|
@ -179,8 +179,9 @@ linux_util_getSquareBonus( XW_UtilCtxt* uc, const ModelCtxt* model,
|
||||||
TW,EM,EM,DL,EM,EM,EM,DW,
|
TW,EM,EM,DL,EM,EM,EM,DW,
|
||||||
}; /* scrabbleBoard */
|
}; /* scrabbleBoard */
|
||||||
|
|
||||||
if ( col > 7 ) col = 14 - col;
|
XP_U16 nCols = model_numCols( model );
|
||||||
if ( row > 7 ) row = 14 - row;
|
if ( col > (nCols/2) ) col = nCols - 1 - col;
|
||||||
|
if ( row > (nCols/2) ) row = nCols - 1 - row;
|
||||||
if ( col > row ) {
|
if ( col > row ) {
|
||||||
XP_U16 tmp = col;
|
XP_U16 tmp = col;
|
||||||
col = row;
|
col = row;
|
||||||
|
|
Loading…
Reference in a new issue