make -q option take number of seconds to pause before quitting

This commit is contained in:
ehouse 2008-10-26 15:33:21 +00:00
parent a59c2456d5
commit e30c72c829
4 changed files with 10 additions and 7 deletions

View file

@ -334,11 +334,13 @@ curses_util_notifyGameOver( XW_UtilCtxt* uc )
catGameHistory( &globals->cGlobals ); catGameHistory( &globals->cGlobals );
} }
if ( globals->cGlobals.params->quitAfter ) { if ( globals->cGlobals.params->quitAfter >= 0 ) {
sleep( globals->cGlobals.params->quitAfter );
globals->timeToExit = XP_TRUE; globals->timeToExit = XP_TRUE;
} else if ( globals->cGlobals.params->undoWhenDone ) { } else if ( globals->cGlobals.params->undoWhenDone ) {
server_handleUndo( globals->cGlobals.game.server ); server_handleUndo( globals->cGlobals.game.server );
} else { } else {
/* This is modal. Don't show if quitting */
cursesShowFinalScores( globals ); cursesShowFinalScores( globals );
} }
} /* curses_util_notifyGameOver */ } /* curses_util_notifyGameOver */

View file

@ -1119,7 +1119,8 @@ gtk_util_notifyGameOver( XW_UtilCtxt* uc )
printFinalScores( globals ); printFinalScores( globals );
if ( globals->cGlobals.params->quitAfter ) { if ( globals->cGlobals.params->quitAfter >= 0 ) {
sleep( globals->cGlobals.params->quitAfter );
quit( NULL, globals ); quit( NULL, 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 );

View file

@ -180,7 +180,7 @@ usage( char* appName, char* msg )
# endif # endif
#endif #endif
"\t [-f file] # use this file to save/load game\n" "\t [-f file] # use this file to save/load game\n"
"\t [-q] # quit when game over (useful for robot-only)\n" "\t [-q nSecs] # quit with pause when game over (useful for robot-only)\n"
"\t [-S] # slow robot down \n" "\t [-S] # slow robot down \n"
"\t [-i] # print game history when game over\n" "\t [-i] # print game history when game over\n"
"\t [-U] # call 'Undo' after game ends\n" "\t [-U] # call 'Undo' after game ends\n"
@ -674,7 +674,7 @@ main( int argc, char** argv )
mainParams.connInfo.ip.hostName = "localhost"; mainParams.connInfo.ip.hostName = "localhost";
#endif #endif
mainParams.gi.boardSize = 15; mainParams.gi.boardSize = 15;
mainParams.quitAfter = XP_FALSE; mainParams.quitAfter = -1;
mainParams.sleepOnAnchor = XP_FALSE; mainParams.sleepOnAnchor = XP_FALSE;
mainParams.printHistory = XP_FALSE; mainParams.printHistory = XP_FALSE;
mainParams.undoWhenDone = XP_FALSE; mainParams.undoWhenDone = XP_FALSE;
@ -707,7 +707,7 @@ main( int argc, char** argv )
#if defined PLATFORM_GTK #if defined PLATFORM_GTK
"h:I" "h:I"
#endif #endif
"kKf:ln:Nsd:e:r:b:qw:Sit:Umvc" "kKf:ln:Nsd:e:r:b:q:w:Sit:Umvc"
#ifdef XWFEATURE_RELAY #ifdef XWFEATURE_RELAY
"a:p:C:H" "a:p:C:H"
#endif #endif
@ -823,7 +823,7 @@ main( int argc, char** argv )
hostName = optarg; hostName = optarg;
break; break;
case 'q': case 'q':
mainParams.quitAfter = XP_TRUE; mainParams.quitAfter = atoi(optarg);
break; break;
case 'b': case 'b':
mainParams.gi.boardSize = atoi(optarg); mainParams.gi.boardSize = atoi(optarg);

View file

@ -52,7 +52,7 @@ typedef struct LaunchParams {
XP_U16 nLocalPlayers; XP_U16 nLocalPlayers;
XP_U16 nHidden; XP_U16 nHidden;
XP_Bool askNewGame; XP_Bool askNewGame;
XP_Bool quitAfter; XP_S16 quitAfter;
XP_Bool sleepOnAnchor; XP_Bool sleepOnAnchor;
XP_Bool printHistory; XP_Bool printHistory;
XP_Bool undoWhenDone; XP_Bool undoWhenDone;