mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
add compile-time option to allow passing game seed from commandline.
This should allow testing relay changes to deal better with duplicate seeds.
This commit is contained in:
parent
1c227c8921
commit
cbfdf992bd
9 changed files with 50 additions and 10 deletions
|
@ -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 );
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue