diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index 00acaab08..9d2f2aabf 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -278,7 +278,11 @@ CommsCtxt* comms_make( MPFORMAL XW_UtilCtxt* util, XP_Bool isServer, XP_U16 XP_UNUSED_RELAY(nPlayersHere), XP_U16 XP_UNUSED_RELAY(nPlayersTotal), - const TransportProcs* procs ) + const TransportProcs* procs +#ifdef SET_GAMESEED + , XP_U16 gameSeed +#endif + ) { CommsCtxt* result = (CommsCtxt*)XP_MALLOC( mpool, sizeof(*result) ); XP_MEMSET( result, 0, sizeof(*result) ); @@ -293,6 +297,9 @@ comms_make( MPFORMAL XW_UtilCtxt* util, XP_Bool isServer, #ifdef XWFEATURE_RELAY init_relay( result, nPlayersHere, nPlayersTotal ); +# ifdef SET_GAMESEED + result->channelSeed = gameSeed; +# endif #endif return result; } /* comms_make */ @@ -527,7 +534,11 @@ comms_makeFromStream( MPFORMAL XWStreamCtxt* stream, XW_UtilCtxt* util, nPlayersTotal = 0; } comms = comms_make( MPPARM(mpool) util, isServer, - nPlayersHere, nPlayersTotal, procs ); + nPlayersHere, nPlayersTotal, procs +#ifdef SET_GAMESEED + , 0 +#endif + ); XP_MEMCPY( &comms->addr, &addr, sizeof(comms->addr) ); comms->connID = stream_getU32( stream ); diff --git a/xwords4/common/comms.h b/xwords4/common/comms.h index 34370956a..1abf90ae9 100644 --- a/xwords4/common/comms.h +++ b/xwords4/common/comms.h @@ -142,7 +142,11 @@ typedef struct _TransportProcs { CommsCtxt* comms_make( MPFORMAL XW_UtilCtxt* util, XP_Bool isServer, XP_U16 nPlayersHere, XP_U16 nPlayersTotal, - const TransportProcs* procs ); + const TransportProcs* procs +#ifdef SET_GAMESEED + ,XP_U16 gameSeed +#endif + ); void comms_reset( CommsCtxt* comms, XP_Bool isServer, XP_U16 nPlayersHere, XP_U16 nPlayersTotal ); @@ -174,7 +178,8 @@ CommsConnType comms_getConType( const CommsCtxt* comms ); XP_Bool comms_getIsServer( const CommsCtxt* comms ); CommsCtxt* comms_makeFromStream( MPFORMAL XWStreamCtxt* stream, - XW_UtilCtxt* util, const TransportProcs* procs ); + XW_UtilCtxt* util, + const TransportProcs* procs ); void comms_start( CommsCtxt* comms ); void comms_writeToStream( const CommsCtxt* comms, XWStreamCtxt* stream ); diff --git a/xwords4/common/game.c b/xwords4/common/game.c index 15cb1191a..12137b899 100644 --- a/xwords4/common/game.c +++ b/xwords4/common/game.c @@ -72,7 +72,11 @@ checkServerRole( CurGameInfo* gi, XP_U16* nPlayersHere, XP_U16* nPlayersTotal ) void game_makeNewGame( MPFORMAL XWGame* game, CurGameInfo* gi, XW_UtilCtxt* util, DrawCtx* draw, - CommonPrefs* cp, const TransportProcs* procs ) + CommonPrefs* cp, const TransportProcs* procs +#ifdef SET_GAMESEED + ,XP_U16 gameSeed +#endif + ) { XP_U16 gameID = 0; XP_U16 nPlayersHere, nPlayersTotal; @@ -92,7 +96,12 @@ game_makeNewGame( MPFORMAL XWGame* game, CurGameInfo* gi, if ( gi->serverRole != SERVER_STANDALONE ) { game->comms = comms_make( MPPARM(mpool) util, gi->serverRole != SERVER_ISCLIENT, - nPlayersHere, nPlayersTotal, procs ); + nPlayersHere, nPlayersTotal, + procs +#ifdef SET_GAMESEED + , gameSeed +#endif + ); } else { game->comms = (CommsCtxt*)NULL; } @@ -141,7 +150,11 @@ game_reset( MPFORMAL XWGame* game, CurGameInfo* gi, } else if ( gi->serverRole != SERVER_STANDALONE ) { game->comms = comms_make( MPPARM(mpool) util, gi->serverRole != SERVER_ISCLIENT, - nPlayersHere, nPlayersTotal, procs ); + nPlayersHere, nPlayersTotal, procs +#ifdef SET_GAMESEED + , 0 +#endif + ); } #else # ifdef DEBUG diff --git a/xwords4/common/game.h b/xwords4/common/game.h index 17d02311a..d8fcbff15 100644 --- a/xwords4/common/game.h +++ b/xwords4/common/game.h @@ -108,7 +108,11 @@ typedef struct XWGame { void game_makeNewGame( MPFORMAL XWGame* game, CurGameInfo* gi, XW_UtilCtxt* util, DrawCtx* draw, - CommonPrefs* cp, const TransportProcs* procs ); + CommonPrefs* cp, const TransportProcs* procs +#ifdef SET_GAMESEED + ,XP_U16 gameSeed +#endif + ); void game_reset( MPFORMAL XWGame* game, CurGameInfo* gi, XW_UtilCtxt* util, CommonPrefs* cp, const TransportProcs* procs ); diff --git a/xwords4/linux/Makefile b/xwords4/linux/Makefile index 228050428..802372670 100644 --- a/xwords4/linux/Makefile +++ b/xwords4/linux/Makefile @@ -87,6 +87,7 @@ DEFINES += -DFEATURE_TRAY_EDIT DEFINES += -DXWFEATURE_CROSSHAIRS DEFINES += -DXWFEATURE_CHAT DEFINES += -DDISABLE_TILE_SEL +DEFINES += -DSET_GAMESEED DEFINES += -DTEXT_MODEL ifdef CURSES_CELL_HT diff --git a/xwords4/linux/cursesmain.c b/xwords4/linux/cursesmain.c index 03cb09f62..337164a69 100644 --- a/xwords4/linux/cursesmain.c +++ b/xwords4/linux/cursesmain.c @@ -1528,7 +1528,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params ) } else { game_makeNewGame( MEMPOOL &g_globals.cGlobals.game, ¶ms->gi, params->util, (DrawCtx*)g_globals.draw, - &g_globals.cGlobals.cp, &procs ); + &g_globals.cGlobals.cp, &procs, params->gameSeed ); } #ifndef XWFEATURE_STANDALONE_ONLY diff --git a/xwords4/linux/gtkmain.c b/xwords4/linux/gtkmain.c index 641aeea74..5602fb285 100644 --- a/xwords4/linux/gtkmain.c +++ b/xwords4/linux/gtkmain.c @@ -443,7 +443,7 @@ createOrLoadObjects( GtkAppGlobals* globals ) game_makeNewGame( MEMPOOL &globals->cGlobals.game, ¶ms->gi, params->util, (DrawCtx*)globals->draw, - &globals->cGlobals.cp, &procs ); + &globals->cGlobals.cp, &procs, params->gameSeed ); addr.conType = params->conType; if ( 0 ) { diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index 146ab6521..46fc72319 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -250,6 +250,7 @@ typedef enum { ,CMD_DICT ,CMD_PLAYERDICT ,CMD_SEED + ,CMD_GAMESEED ,CMD_GAMEFILE ,CMD_MMAP ,CMD_PRINTHISORY @@ -323,6 +324,7 @@ static CmdInfoRec CmdInfoRecs[] = { ,{ CMD_DICT, true, "game-dict", "dictionary name for game" } ,{ CMD_PLAYERDICT, true, "player-dict", "dictionary name for player (in sequence)" } ,{ CMD_SEED, true, "seed", "random seed" } + ,{ CMD_GAMESEED, true, "game-seed", "game seed (for relay play)" } ,{ CMD_GAMEFILE, true, "file", "file to save to/read from" } ,{ CMD_MMAP, false, "use-mmap", "mmap dicts rather than copy them to memory" } ,{ CMD_PRINTHISORY, false, "print-history", "print history on game over" } @@ -1026,6 +1028,9 @@ main( int argc, char** argv ) case CMD_SEED: seed = atoi(optarg); break; + case CMD_GAMESEED: + mainParams.gameSeed = atoi(optarg); + break; case CMD_GAMEFILE: mainParams.fileName = optarg; break; diff --git a/xwords4/linux/main.h b/xwords4/linux/main.h index 9a234d748..98b031f9a 100644 --- a/xwords4/linux/main.h +++ b/xwords4/linux/main.h @@ -54,6 +54,7 @@ typedef struct LaunchParams { VTableMgr* vtMgr; XP_U16 nLocalPlayers; XP_U16 nHidden; + XP_U16 gameSeed; XP_S16 dropNthRcvd; /* negative means use for random calc */ XP_U16 nPacketsRcvd; /* toward dropNthRcvd */ XP_Bool askNewGame;