From 6bb65a94a86bd5b3dbbb175b70451208ae71d43a Mon Sep 17 00:00:00 2001 From: ehouse Date: Sun, 30 Nov 2003 18:50:41 +0000 Subject: [PATCH] change variable names around tile picking; pass stream version into reader --- xwords4/common/game.c | 33 ++++++++++++++++----------------- xwords4/common/game.h | 12 ++++++++---- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/xwords4/common/game.c b/xwords4/common/game.c index 7685e6c84..e814c9dae 100644 --- a/xwords4/common/game.c +++ b/xwords4/common/game.c @@ -141,17 +141,14 @@ game_makeFromStream( MPFORMAL XWStreamCtxt* stream, XWGame* game, XW_UtilCtxt* util, DrawCtx* draw, CommonPrefs* cp, TransportSend sendProc, void* closure ) { + XP_U8 strVersion; #ifndef XWFEATURE_STANDALONE_ONLY XP_Bool hasComms; #endif -#ifdef DEBUG - XP_U8 version = stream_getU8( stream ); - XP_ASSERT( version == CUR_STREAM_VERS ); -#else - (void)stream_getU8( stream ); -#endif + strVersion = stream_getU8( stream ); + XP_DEBUGF( "strVersion = %d", (XP_U16)strVersion ); - gi_readFromStream( MPPARM(mpool) stream, gi ); + gi_readFromStream( MPPARM(mpool) stream, strVersion, gi ); #ifndef XWFEATURE_STANDALONE_ONLY hasComms = stream_getU8( stream ); @@ -233,9 +230,8 @@ gi_initPlayerInfo( MPFORMAL CurGameInfo* gi, XP_UCHAR* nameTemplate ) gi->timerEnabled = XP_FALSE; gi->gameSeconds = 25 * 60; /* 25 minute game is common? */ #ifdef FEATURE_TRAY_EDIT + gi->enablePickTiles = XP_FALSE; gi->allowPickTiles = XP_FALSE; - gi->allowPickTilesRobot = XP_FALSE; - gi->allowPickWasUsed = XP_FALSE; #endif for ( i = 0; i < MAX_NUM_PLAYERS; ++i ) { @@ -305,9 +301,8 @@ gi_copy( MPFORMAL CurGameInfo* destGI, CurGameInfo* srcGI ) destGI->robotSmartness = (XP_U8)srcGI->robotSmartness; destGI->phoniesAction = srcGI->phoniesAction; #ifdef FEATURE_TRAY_EDIT + destGI->enablePickTiles = srcGI->enablePickTiles; destGI->allowPickTiles = srcGI->allowPickTiles; - destGI->allowPickTilesRobot = srcGI->allowPickTilesRobot; - destGI->allowPickWasUsed = srcGI->allowPickWasUsed; #endif for ( srcPl = srcGI->players, destPl = destGI->players, i = 0; @@ -323,7 +318,8 @@ gi_copy( MPFORMAL CurGameInfo* destGI, CurGameInfo* srcGI ) } /* gi_copy */ void -gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi ) +gi_readFromStream( MPFORMAL XWStreamCtxt* stream, XP_U16 strVersion, + CurGameInfo* gi ) { LocalPlayer* pl; XP_U16 i; @@ -343,9 +339,13 @@ gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi ) gi->phoniesAction = (XWPhoniesChoice)stream_getBits( stream, 2 ); gi->timerEnabled = stream_getBits( stream, 1 ); #ifdef FEATURE_TRAY_EDIT - gi->allowPickTiles = stream_getBits( stream, 1 ); - gi->allowPickTilesRobot = stream_getBits( stream, 1 ); - gi->allowPickWasUsed = stream_getBits( stream, 1 ); + if ( strVersion >= CUR_STREAM_VERS ) { + gi->enablePickTiles = stream_getBits( stream, 1 ); + gi->allowPickTiles = stream_getBits( stream, 1 ); + } else { + gi->enablePickTiles = XP_FALSE; + gi->allowPickTiles = XP_FALSE; + } #endif @@ -389,9 +389,8 @@ gi_writeToStream( XWStreamCtxt* stream, CurGameInfo* gi ) stream_putBits( stream, 2, gi->phoniesAction ); stream_putBits( stream, 1, gi->timerEnabled ); #ifdef FEATURE_TRAY_EDIT + stream_putBits( stream, 1, gi->enablePickTiles ); stream_putBits( stream, 1, gi->allowPickTiles ); - stream_putBits( stream, 1, gi->allowPickTilesRobot ); - stream_putBits( stream, 1, gi->allowPickWasUsed ); #endif stream_putU16( stream, gi->gameID ); diff --git a/xwords4/common/game.h b/xwords4/common/game.h index ad3b70191..f56cef06e 100644 --- a/xwords4/common/game.h +++ b/xwords4/common/game.h @@ -30,7 +30,11 @@ extern "C" { #endif -#define CUR_STREAM_VERS 0x01 +#ifdef FEATURE_TRAY_EDIT +# define CUR_STREAM_VERS 0x02 +#else +# define CUR_STREAM_VERS 0x01 +#endif typedef struct LocalPlayer { XP_UCHAR* name; @@ -55,9 +59,8 @@ typedef struct CurGameInfo { XP_Bool hintsNotAllowed; XP_Bool timerEnabled; #ifdef FEATURE_TRAY_EDIT + XP_Bool enablePickTiles; /* make the next option available */ XP_Bool allowPickTiles; - XP_Bool allowPickTilesRobot; - XP_Bool allowPickWasUsed; #endif XP_U8 robotSmartness; XWPhoniesChoice phoniesAction; @@ -90,7 +93,8 @@ void game_dispose( XWGame* game ); void gi_initPlayerInfo( MPFORMAL CurGameInfo* gi, XP_UCHAR* nameTemplate ); void gi_disposePlayerInfo( MPFORMAL CurGameInfo* gi ); void gi_writeToStream( XWStreamCtxt* stream, CurGameInfo* gi ); -void gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi ); +void gi_readFromStream( MPFORMAL XWStreamCtxt* stream, XP_U16 strVersion, + CurGameInfo* gi ); void gi_copy( MPFORMAL CurGameInfo* destGI, CurGameInfo* srcGi ); XP_Bool player_hasPasswd( LocalPlayer* player );