From d3ce87b0572a7e9e286ab901a76a614a73593c11 Mon Sep 17 00:00:00 2001 From: ehouse Date: Fri, 14 Mar 2008 09:36:42 +0000 Subject: [PATCH] Indicate empty cell with CELL_ISEMPTY rather than an empty string; fix palm to not draw star on top of placed tile. --- xwords4/common/board.c | 5 ++++- xwords4/linux/gtkdraw.c | 2 +- xwords4/palm/palmdraw.c | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/xwords4/common/board.c b/xwords4/common/board.c index 662bb0f6b..24478de94 100644 --- a/xwords4/common/board.c +++ b/xwords4/common/board.c @@ -1743,7 +1743,7 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks ) XP_S16 owner = -1; XP_Bool invert = XP_FALSE; XP_Bitmap bitmap = NULL; - XP_UCHAR* textP = (XP_UCHAR*)ch; + XP_UCHAR* textP = NULL; HintAtts hintAtts; CellFlags flags = CELL_NONE; XP_Bool isOrigin; @@ -1763,6 +1763,7 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks ) if ( isEmpty ) { isBlank = XP_FALSE; + flags |= CELL_ISEMPTY; } else if ( isBlank && skipBlanks ) { break; } else { @@ -1777,12 +1778,14 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks ) Tile valTile = isBlank? dict_getBlankTile( dict ) : tile; XP_U16 val = dict_getTileValue( dict, valTile ); XP_SNPRINTF( ch, sizeof(ch), (XP_UCHAR*)"%d", val ); + textP = ch; } else if ( dict_faceIsBitmap( dict, tile ) ) { bitmap = dict_getFaceBitmap( dict, tile, XP_FALSE ); XP_ASSERT( !!bitmap ); textP = (XP_UCHAR*)NULL; } else { (void)dict_tilesToString( dict, &tile, 1, ch, sizeof(ch) ); + textP = ch; } } bonus = util_getSquareBonus( board->util, model, col, row ); diff --git a/xwords4/linux/gtkdraw.c b/xwords4/linux/gtkdraw.c index 12fd267c1..96b543278 100644 --- a/xwords4/linux/gtkdraw.c +++ b/xwords4/linux/gtkdraw.c @@ -434,7 +434,7 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter, /* We draw just an empty, potentially colored, square IFF there's nothing in the cell or if CELL_DRAGSRC is set */ - if ( (flags & CELL_DRAGSRC) != 0 || ( !!letter && *letter == LETTER_NONE ) ) { + if ( (flags & (CELL_DRAGSRC|CELL_ISEMPTY)) != 0 ) { if ( bonus != BONUS_NONE ) { gdk_gc_set_foreground( dctx->drawGC, &dctx->bonusColors[bonus-1] ); gdk_draw_rectangle( DRAW_WHAT(dctx), dctx->drawGC, TRUE, diff --git a/xwords4/palm/palmdraw.c b/xwords4/palm/palmdraw.c index 3fe6d3cc2..b6b0004d3 100644 --- a/xwords4/palm/palmdraw.c +++ b/xwords4/palm/palmdraw.c @@ -1,6 +1,6 @@ /* -*-mode: C; fill-column: 77; c-basic-offset: 4; compile-command: "make ARCH=68K_ONLY MEMDEBUG=TRUE";-*- */ /* - * Copyright 1999 - 2007 by Eric House (xwords@eehouse.org). All rights + * Copyright 1999 - 2008 by Eric House (xwords@eehouse.org). All rights * reserved. * * This program is free software; you can redistribute it and/or @@ -496,6 +496,7 @@ palm_common_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, if ( !!letters ) { len = XP_STRLEN( (const char*)letters ); + XP_ASSERT( len > 0 ); if ( len > 0 ) { XP_S16 strWidth = FntCharsWidth( (const char*)letters, len ); XP_U16 x, y; @@ -539,7 +540,8 @@ palm_common_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, empty = XP_FALSE; } - if ( (flags & CELL_ISSTAR) != 0 ) { + if ( ((flags & CELL_ISSTAR) != 0) + && ((flags & (CELL_DRAGSRC | CELL_ISEMPTY)) != 0 ) ) { bitmapInRect( dctx, STAR_BMP_RES_ID, rect ); } else if ( showBonus && (able == ONEBIT) ) { /* this is my one refusal to totally factor bandw and color