mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-13 08:01:33 +01:00
add param to server_handleUndo to prevent it from undoing all moves in
robot-vs-robot game, which is the wrong thing to do during a test simulating play.
This commit is contained in:
parent
0cb217496e
commit
0b1a9a67fe
6 changed files with 15 additions and 11 deletions
|
@ -801,7 +801,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1handleUndo
|
|||
(JNIEnv* env, jclass C, jint gamePtr)
|
||||
{
|
||||
XWJNI_START();
|
||||
server_handleUndo( state->game.server );
|
||||
server_handleUndo( state->game.server, 0 );
|
||||
XWJNI_END();
|
||||
}
|
||||
|
||||
|
|
|
@ -1958,9 +1958,12 @@ readMoveInfo( ServerCtxt* server, XWStreamCtxt* stream,
|
|||
#ifdef STREAM_VERS_BIGBOARD
|
||||
if ( STREAM_VERS_BIGBOARD <= stream_getVersion( stream ) ) {
|
||||
XP_U32 hashReceived = stream_getU32( stream );
|
||||
success = hashReceived == model_getHash( server->vol.model );
|
||||
XP_U32 hashLocal = model_getHash( server->vol.model );
|
||||
success = hashReceived == hashLocal;
|
||||
if ( !success ) {
|
||||
XP_LOGF( "%s: hash mismatch: dropping move", __func__ );
|
||||
XP_LOGF( "%s: hash mismatch: rcvd %.8X vs local %.8X; dropping move",
|
||||
__func__, (unsigned int)hashReceived,
|
||||
(unsigned int)hashLocal );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -2151,7 +2154,6 @@ reflectMove( ServerCtxt* server, XWStreamCtxt* stream )
|
|||
XWStreamCtxt* wordsStream = NULL;
|
||||
|
||||
moveOk = XWSTATE_INTURN == server->nv.gameState;
|
||||
XP_ASSERT( moveOk ); /* message permanently lost if dropped here! */
|
||||
if ( moveOk ) {
|
||||
moveOk = readMoveInfo( server, stream, &whoMoved, &isTrade, &newTiles,
|
||||
&tradedTiles, &isLegal ); /* modifies model */
|
||||
|
@ -2540,7 +2542,7 @@ reflectUndos( ServerCtxt* server, XWStreamCtxt* stream, XW_Proto code )
|
|||
#endif
|
||||
|
||||
XP_Bool
|
||||
server_handleUndo( ServerCtxt* server )
|
||||
server_handleUndo( ServerCtxt* server, XP_U16 limit )
|
||||
{
|
||||
XP_Bool result = XP_FALSE;
|
||||
XP_U16 lastTurnUndone = 0; /* quiet compiler good */
|
||||
|
@ -2568,6 +2570,8 @@ server_handleUndo( ServerCtxt* server )
|
|||
lastUndone = moveNum;
|
||||
if ( !LP_IS_ROBOT(&gi->players[lastTurnUndone]) ) {
|
||||
break;
|
||||
} else if ( 0 != limit && nUndone >= limit ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ XP_U16 server_secondsUsedBy( ServerCtxt* server, XP_U16 playerNum );
|
|||
|
||||
/* It might make more sense to have the board supply the undo method clients
|
||||
call... */
|
||||
XP_Bool server_handleUndo( ServerCtxt* server );
|
||||
XP_Bool server_handleUndo( ServerCtxt* server, XP_U16 limit );
|
||||
|
||||
/* signed because negative number means nobody's turn yet */
|
||||
XP_S16 server_getCurrentTurn( ServerCtxt* server );
|
||||
|
|
|
@ -387,7 +387,7 @@ curses_util_notifyGameOver( XW_UtilCtxt* uc )
|
|||
sleep( globals->cGlobals.params->quitAfter );
|
||||
handleQuit( globals );
|
||||
} else if ( globals->cGlobals.params->undoWhenDone ) {
|
||||
server_handleUndo( globals->cGlobals.game.server );
|
||||
server_handleUndo( globals->cGlobals.game.server, 0 );
|
||||
} else if ( !globals->cGlobals.params->skipGameOver ) {
|
||||
/* This is modal. Don't show if quitting */
|
||||
cursesShowFinalScores( globals );
|
||||
|
@ -757,7 +757,7 @@ handleBackspace( CursesAppGlobals* globals )
|
|||
static XP_Bool
|
||||
handleUndo( CursesAppGlobals* globals )
|
||||
{
|
||||
globals->doDraw = server_handleUndo( globals->cGlobals.game.server );
|
||||
globals->doDraw = server_handleUndo( globals->cGlobals.game.server, 0 );
|
||||
return XP_TRUE;
|
||||
} /* handleUndo */
|
||||
|
||||
|
|
|
@ -1163,7 +1163,7 @@ handle_juggle_button( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
|
|||
static void
|
||||
handle_undo_button( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
|
||||
{
|
||||
if ( server_handleUndo( globals->cGlobals.game.server ) ) {
|
||||
if ( server_handleUndo( globals->cGlobals.game.server, 0 ) ) {
|
||||
board_draw( globals->cGlobals.game.board );
|
||||
}
|
||||
} /* handle_undo_button */
|
||||
|
@ -1456,7 +1456,7 @@ gtk_util_notifyGameOver( XW_UtilCtxt* uc )
|
|||
sleep( cGlobals->params->quitAfter );
|
||||
quit();
|
||||
} else if ( cGlobals->params->undoWhenDone ) {
|
||||
server_handleUndo( cGlobals->game.server );
|
||||
server_handleUndo( cGlobals->game.server, 0 );
|
||||
board_draw( cGlobals->game.board );
|
||||
} else if ( !cGlobals->params->skipGameOver ) {
|
||||
gtkShowFinalScores( globals );
|
||||
|
|
|
@ -383,7 +383,7 @@ secondTimerFired( gpointer data )
|
|||
if ( 0 != undoRatio ) {
|
||||
if ( (XP_RANDOM() % 100) < undoRatio ) {
|
||||
XP_LOGF( "%s: calling server_handleUndo", __func__ );
|
||||
if ( server_handleUndo( game->server ) ) {
|
||||
if ( server_handleUndo( game->server, 1 ) ) {
|
||||
board_draw( game->board );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue