From db641c4664693cfd3045698a4ea646aee06c8c6f Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 8 Jan 2019 08:16:50 -0800 Subject: [PATCH] log gameSeed; generate on linux too I'm seeing a rare case where a game connectes to relay specifying a room and somehow gets both slots, having provided different gameSeeds the two times. This means an opponent won't connect, the room being full in that game. I can't reproduce, so am logging seed changes better and switching linux client to leave seed generation to comms as Android does. --- xwords4/common/comms.c | 8 +++++--- xwords4/linux/Makefile | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index af33b24e8..2d3da8487 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -676,7 +676,7 @@ comms_makeFromStream( MPFORMAL XWStreamCtxt* stream, XW_UtilCtxt* util, } else { comms->channelSeed = stream_getU16( stream ); CNO_FMT( cbuf, comms->channelSeed ); - XP_LOGF( "%s: loaded seed: %s", __func__, cbuf ); + XP_LOGF( "%s: loaded seed: %s(%d)", __func__, cbuf, comms->channelSeed ); } if ( STREAM_VERS_COMMSBACKOFF <= version ) { comms->resendBackoff = stream_getU16( stream ); @@ -890,7 +890,9 @@ comms_writeToStream( CommsCtxt* comms, XWStreamCtxt* stream, stream_putU32( stream, comms->connID ); stream_putU16( stream, comms->nextChannelNo ); - stream_putU16( stream, comms_getChannelSeed( comms ) ); /* force creation */ + XP_U16 channelSeed = comms_getChannelSeed( comms ); /* force creation */ + stream_putU16( stream, channelSeed ); + XP_LOGF( "%s: stored seed: %x(%d)", __func__, channelSeed, channelSeed ); stream_putU16( stream, comms->resendBackoff ); stream_putU32( stream, comms->nextResend ); if ( addr_hasType( &comms->addr, COMMS_CONN_RELAY ) ) { @@ -1186,7 +1188,7 @@ comms_getChannelSeed( CommsCtxt* comms ) comms->channelSeed = XP_RANDOM() & ~CHANNEL_MASK; comms->channelSeed |= comms->forceChannel; CNO_FMT( cbuf, comms->channelSeed ); - XP_LOGF( "%s: made seed: %s", __func__, cbuf ); + XP_LOGF( "%s: made seed: %s(%d)", __func__, cbuf, comms->channelSeed ); } return comms->channelSeed; } diff --git a/xwords4/linux/Makefile b/xwords4/linux/Makefile index c721d4bdc..123162e71 100644 --- a/xwords4/linux/Makefile +++ b/xwords4/linux/Makefile @@ -105,7 +105,7 @@ DEFINES += -DFEATURE_TRAY_EDIT DEFINES += -DXWFEATURE_CROSSHAIRS DEFINES += -DXWFEATURE_CHAT DEFINES += -DDISABLE_TILE_SEL -DEFINES += -DSET_GAMESEED +# DEFINES += -DSET_GAMESEED DEFINES += -DTEXT_MODEL DEFINES += -DXWFEATURE_WALKDICT DEFINES += -DXWFEATURE_WALKDICT_FILTER