mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
Add option to close stdin on startup, which seems required to run
curses version from script. There's probably a better way...
This commit is contained in:
parent
df293db349
commit
d7cd277893
1 changed files with 13 additions and 1 deletions
|
@ -187,6 +187,7 @@ usage( char* appName, char* msg )
|
|||
#endif
|
||||
"\t [-f file] # use this file to save/load game\n"
|
||||
"\t [-q nSecs] # quit with pause when game over (useful for robot-only)\n"
|
||||
"\t [-0] # close fd 0 (stdin) on start; assumes -q\n"
|
||||
"\t [-S] # slow robot down \n"
|
||||
"\t [-i] # print game history when game over\n"
|
||||
"\t [-U] # call 'Undo' after game ends\n"
|
||||
|
@ -686,6 +687,7 @@ main( int argc, char** argv )
|
|||
XP_Bool isServer = XP_FALSE;
|
||||
char* portNum = NULL;
|
||||
char* hostName = "localhost";
|
||||
XP_Bool closeStdin = XP_FALSE;
|
||||
unsigned int seed = defaultRandomSeed();
|
||||
LaunchParams mainParams;
|
||||
XP_U16 robotCount = 0;
|
||||
|
@ -768,7 +770,7 @@ main( int argc, char** argv )
|
|||
#if defined PLATFORM_GTK
|
||||
"h:I"
|
||||
#endif
|
||||
"kKf:ln:Nsd:e:r:b:q:w:Sit:UmvcVP"
|
||||
"kKf:ln:Nsd:e:r:b:0q:w:Sit:UmvcVP"
|
||||
#ifdef XWFEATURE_SLOW_ROBOT
|
||||
"z:"
|
||||
#endif
|
||||
|
@ -900,6 +902,9 @@ main( int argc, char** argv )
|
|||
conType = COMMS_CONN_RELAY;
|
||||
hostName = optarg;
|
||||
break;
|
||||
case '0':
|
||||
closeStdin = XP_TRUE;
|
||||
break;
|
||||
case 'q':
|
||||
mainParams.quitAfter = atoi(optarg);
|
||||
break;
|
||||
|
@ -1065,6 +1070,13 @@ main( int argc, char** argv )
|
|||
srandom( seed ); /* init linux random number generator */
|
||||
XP_LOGF( "seeded srandom with %d", seed );
|
||||
|
||||
if ( closeStdin ) {
|
||||
fclose( stdin );
|
||||
if ( mainParams.quitAfter < 0 ) {
|
||||
fprintf( stderr, "stdin closed; you'll need some way to quit\n" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isServer ) {
|
||||
if ( mainParams.info.serverInfo.nRemotePlayers == 0 ) {
|
||||
mainParams.serverRole = SERVER_STANDALONE;
|
||||
|
|
Loading…
Add table
Reference in a new issue