mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +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)
|
(JNIEnv* env, jclass C, jint gamePtr)
|
||||||
{
|
{
|
||||||
XWJNI_START();
|
XWJNI_START();
|
||||||
server_handleUndo( state->game.server );
|
server_handleUndo( state->game.server, 0 );
|
||||||
XWJNI_END();
|
XWJNI_END();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1958,9 +1958,12 @@ readMoveInfo( ServerCtxt* server, XWStreamCtxt* stream,
|
||||||
#ifdef STREAM_VERS_BIGBOARD
|
#ifdef STREAM_VERS_BIGBOARD
|
||||||
if ( STREAM_VERS_BIGBOARD <= stream_getVersion( stream ) ) {
|
if ( STREAM_VERS_BIGBOARD <= stream_getVersion( stream ) ) {
|
||||||
XP_U32 hashReceived = stream_getU32( 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 ) {
|
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
|
#endif
|
||||||
|
@ -2151,7 +2154,6 @@ reflectMove( ServerCtxt* server, XWStreamCtxt* stream )
|
||||||
XWStreamCtxt* wordsStream = NULL;
|
XWStreamCtxt* wordsStream = NULL;
|
||||||
|
|
||||||
moveOk = XWSTATE_INTURN == server->nv.gameState;
|
moveOk = XWSTATE_INTURN == server->nv.gameState;
|
||||||
XP_ASSERT( moveOk ); /* message permanently lost if dropped here! */
|
|
||||||
if ( moveOk ) {
|
if ( moveOk ) {
|
||||||
moveOk = readMoveInfo( server, stream, &whoMoved, &isTrade, &newTiles,
|
moveOk = readMoveInfo( server, stream, &whoMoved, &isTrade, &newTiles,
|
||||||
&tradedTiles, &isLegal ); /* modifies model */
|
&tradedTiles, &isLegal ); /* modifies model */
|
||||||
|
@ -2540,7 +2542,7 @@ reflectUndos( ServerCtxt* server, XWStreamCtxt* stream, XW_Proto code )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XP_Bool
|
XP_Bool
|
||||||
server_handleUndo( ServerCtxt* server )
|
server_handleUndo( ServerCtxt* server, XP_U16 limit )
|
||||||
{
|
{
|
||||||
XP_Bool result = XP_FALSE;
|
XP_Bool result = XP_FALSE;
|
||||||
XP_U16 lastTurnUndone = 0; /* quiet compiler good */
|
XP_U16 lastTurnUndone = 0; /* quiet compiler good */
|
||||||
|
@ -2568,6 +2570,8 @@ server_handleUndo( ServerCtxt* server )
|
||||||
lastUndone = moveNum;
|
lastUndone = moveNum;
|
||||||
if ( !LP_IS_ROBOT(&gi->players[lastTurnUndone]) ) {
|
if ( !LP_IS_ROBOT(&gi->players[lastTurnUndone]) ) {
|
||||||
break;
|
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
|
/* It might make more sense to have the board supply the undo method clients
|
||||||
call... */
|
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 */
|
/* signed because negative number means nobody's turn yet */
|
||||||
XP_S16 server_getCurrentTurn( ServerCtxt* server );
|
XP_S16 server_getCurrentTurn( ServerCtxt* server );
|
||||||
|
|
|
@ -387,7 +387,7 @@ curses_util_notifyGameOver( XW_UtilCtxt* uc )
|
||||||
sleep( globals->cGlobals.params->quitAfter );
|
sleep( globals->cGlobals.params->quitAfter );
|
||||||
handleQuit( globals );
|
handleQuit( globals );
|
||||||
} else if ( globals->cGlobals.params->undoWhenDone ) {
|
} 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 ) {
|
} else if ( !globals->cGlobals.params->skipGameOver ) {
|
||||||
/* This is modal. Don't show if quitting */
|
/* This is modal. Don't show if quitting */
|
||||||
cursesShowFinalScores( globals );
|
cursesShowFinalScores( globals );
|
||||||
|
@ -757,7 +757,7 @@ handleBackspace( CursesAppGlobals* globals )
|
||||||
static XP_Bool
|
static XP_Bool
|
||||||
handleUndo( CursesAppGlobals* globals )
|
handleUndo( CursesAppGlobals* globals )
|
||||||
{
|
{
|
||||||
globals->doDraw = server_handleUndo( globals->cGlobals.game.server );
|
globals->doDraw = server_handleUndo( globals->cGlobals.game.server, 0 );
|
||||||
return XP_TRUE;
|
return XP_TRUE;
|
||||||
} /* handleUndo */
|
} /* handleUndo */
|
||||||
|
|
||||||
|
|
|
@ -1163,7 +1163,7 @@ handle_juggle_button( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
|
||||||
static void
|
static void
|
||||||
handle_undo_button( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
|
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 );
|
board_draw( globals->cGlobals.game.board );
|
||||||
}
|
}
|
||||||
} /* handle_undo_button */
|
} /* handle_undo_button */
|
||||||
|
@ -1456,7 +1456,7 @@ gtk_util_notifyGameOver( XW_UtilCtxt* uc )
|
||||||
sleep( cGlobals->params->quitAfter );
|
sleep( cGlobals->params->quitAfter );
|
||||||
quit();
|
quit();
|
||||||
} else if ( cGlobals->params->undoWhenDone ) {
|
} else if ( cGlobals->params->undoWhenDone ) {
|
||||||
server_handleUndo( cGlobals->game.server );
|
server_handleUndo( cGlobals->game.server, 0 );
|
||||||
board_draw( cGlobals->game.board );
|
board_draw( cGlobals->game.board );
|
||||||
} else if ( !cGlobals->params->skipGameOver ) {
|
} else if ( !cGlobals->params->skipGameOver ) {
|
||||||
gtkShowFinalScores( globals );
|
gtkShowFinalScores( globals );
|
||||||
|
|
|
@ -383,7 +383,7 @@ secondTimerFired( gpointer data )
|
||||||
if ( 0 != undoRatio ) {
|
if ( 0 != undoRatio ) {
|
||||||
if ( (XP_RANDOM() % 100) < undoRatio ) {
|
if ( (XP_RANDOM() % 100) < undoRatio ) {
|
||||||
XP_LOGF( "%s: calling server_handleUndo", __func__ );
|
XP_LOGF( "%s: calling server_handleUndo", __func__ );
|
||||||
if ( server_handleUndo( game->server ) ) {
|
if ( server_handleUndo( game->server, 1 ) ) {
|
||||||
board_draw( game->board );
|
board_draw( game->board );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue