From 818868bdb27b2c58f113823460e4898f576275fe Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 3 Aug 2022 19:54:53 -0700 Subject: [PATCH] remove undo as an option for duplicate mode games --- xwords4/common/model.c | 14 +++++++++----- xwords4/common/server.c | 12 +++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/xwords4/common/model.c b/xwords4/common/model.c index 49717c369..c24712c8b 100644 --- a/xwords4/common/model.c +++ b/xwords4/common/model.c @@ -955,12 +955,16 @@ model_rejectPreviousMove( ModelCtxt* model, XWEnv xwe, XP_Bool model_canUndo( const ModelCtxt* model ) { - const StackCtxt* stack = model->vol.stack; - XP_U16 nStackEntries = stack_getNEntries( stack ); + /* PENDING Turning off undo for duplicate mode for now. */ + XP_Bool result = !model->vol.gi->inDuplicateMode; + if ( result ) { + const StackCtxt* stack = model->vol.stack; + XP_U16 nStackEntries = stack_getNEntries( stack ); - /* More than just tile assignment? */ - XP_U16 assignCount = model->vol.gi->inDuplicateMode ? 1 : model->nPlayers; - XP_Bool result = nStackEntries > assignCount; + /* More than just tile assignment? */ + XP_U16 assignCount = model->vol.gi->inDuplicateMode ? 1 : model->nPlayers; + result = nStackEntries > assignCount; + } return result; } diff --git a/xwords4/common/server.c b/xwords4/common/server.c index 2c346fdf3..44c6599cb 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -1026,12 +1026,14 @@ static void setPrevMoveStream( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) { if ( !server->nv._prevMoveStream ) { - server->nv._prevMoveStream = mkServerStream( server ); + server->nv._prevMoveStream = stream; + // mkServerStream( server ); + } else { + XP_LOGFF( "appending to existing stream" ); + stream_putBytes( server->nv._prevMoveStream, stream_getPtr( stream ), + stream_getSize( stream ) ); + stream_destroy( stream, xwe ); } - XP_ASSERT( '\0' != ((XP_UCHAR*)stream_getPtr( stream ))[0] ); - stream_putBytes( server->nv._prevMoveStream, stream_getPtr( stream ), - stream_getSize( stream ) ); - stream_destroy( stream, xwe ); } static void