diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWService.java index c1f305fb1..fc2e666ae 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWService.java @@ -82,7 +82,7 @@ class XWService extends Service { s_seen.add( inviteID ); } } - Log.d( TAG, "checkNotDupe(%s) => %b", inviteID, !isDupe ); + Log.d( TAG, "checkNotDupe('%s') => %b", inviteID, !isDupe ); return !isDupe; } diff --git a/xwords4/common/nli.c b/xwords4/common/nli.c index e54c72a8f..29ea12285 100644 --- a/xwords4/common/nli.c +++ b/xwords4/common/nli.c @@ -61,6 +61,13 @@ nli_setDevID( NetLaunchInfo* nli, XP_U32 devID ) types_addType( &nli->_conTypes, COMMS_CONN_RELAY ); } +void +nli_setInviteID( NetLaunchInfo* nli, const XP_UCHAR* inviteID ) +{ + nli->inviteID[0] = '\0'; + XP_STRCAT( nli->inviteID, inviteID ); +} + void nli_saveToStream( const NetLaunchInfo* nli, XWStreamCtxt* stream ) { diff --git a/xwords4/common/nli.h b/xwords4/common/nli.h index 721a839c4..47f572585 100644 --- a/xwords4/common/nli.h +++ b/xwords4/common/nli.h @@ -76,6 +76,7 @@ void nli_saveToStream( const NetLaunchInfo* invit, XWStreamCtxt* stream ); void nli_makeAddrRec( const NetLaunchInfo* invit, CommsAddrRec* addr ); void nli_setDevID( NetLaunchInfo* invit, XP_U32 devID ); +void nli_setInviteID( NetLaunchInfo* invit, const XP_UCHAR* inviteID ); #endif diff --git a/xwords4/linux/gtkboard.c b/xwords4/linux/gtkboard.c index 7abae1409..0930e3935 100644 --- a/xwords4/linux/gtkboard.c +++ b/xwords4/linux/gtkboard.c @@ -1640,6 +1640,9 @@ send_invites( CommonGlobals* cGlobals, XP_U16 nPlayers, NetLaunchInfo nli = {0}; nli_init( &nli, cGlobals->gi, &addr, nPlayers, forceChannel ); + XP_UCHAR buf[32]; + snprintf( buf, sizeof(buf), "%X", makeRandomInt() ); + nli_setInviteID( &nli, buf ); nli_setDevID( &nli, linux_getDevIDRelay( cGlobals->params ) ); #ifdef DEBUG diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index ba38e5143..948054cd6 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -1558,8 +1558,8 @@ linuxChangeRoles( CommonGlobals* cGlobals ) } #endif -static unsigned int -defaultRandomSeed() +unsigned int +makeRandomInt() { /* use kernel device rather than time() so can run multiple times/second without getting the same results. */ @@ -2034,7 +2034,7 @@ main( int argc, char** argv ) XP_Bool isServer = XP_FALSE; // char* portNum = NULL; // char* hostName = "localhost"; - unsigned int seed = defaultRandomSeed(); + unsigned int seed = makeRandomInt(); LaunchParams mainParams; XP_U16 nPlayerDicts = 0; XP_U16 robotCount = 0; diff --git a/xwords4/linux/linuxmain.h b/xwords4/linux/linuxmain.h index 5f902c810..a3622257e 100644 --- a/xwords4/linux/linuxmain.h +++ b/xwords4/linux/linuxmain.h @@ -111,6 +111,8 @@ const XP_UCHAR* linux_getDevID( LaunchParams* params, DevIDType* typ ); void linux_doInitialReg( LaunchParams* params, XP_Bool idIsNew ); XP_Bool linux_setupDevidParams( LaunchParams* params ); +unsigned int makeRandomInt(); + /* void initParams( LaunchParams* params ); */ /* void freeParams( LaunchParams* params ); */