mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-15 08:47:56 +01:00
always generate gameID using the same function
Android was using curSeconds(): bad!
This commit is contained in:
parent
5347762300
commit
dfa0502a06
3 changed files with 7 additions and 11 deletions
|
@ -470,9 +470,7 @@ makeGI( MPFORMAL JNIEnv* env, jobject jgi )
|
||||||
game_makeNewGame, which sets gameID. So check here if it's still unset
|
game_makeNewGame, which sets gameID. So check here if it's still unset
|
||||||
and if necessary set it -- including back in the java world. */
|
and if necessary set it -- including back in the java world. */
|
||||||
if ( 0 == gi->gameID ) {
|
if ( 0 == gi->gameID ) {
|
||||||
while ( 0 == gi->gameID ) {
|
gi->gameID = game_makeGameID( 0 );
|
||||||
gi->gameID = getCurSeconds( env );
|
|
||||||
}
|
|
||||||
setInt( env, jgi, "gameID", gi->gameID );
|
setInt( env, jgi, "gameID", gi->gameID );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,11 +79,9 @@ checkServerRole( CurGameInfo* gi, XP_U16* nPlayersHere,
|
||||||
}
|
}
|
||||||
} /* checkServerRole */
|
} /* checkServerRole */
|
||||||
|
|
||||||
static XP_U32
|
XP_U32
|
||||||
makeGameID( XW_UtilCtxt* XP_UNUSED_DBG(util) )
|
game_makeGameID( XP_U32 gameID )
|
||||||
{
|
{
|
||||||
XP_U32 gameID = 0;
|
|
||||||
assertUtilOK( util );
|
|
||||||
while ( 0 == gameID ) {
|
while ( 0 == gameID ) {
|
||||||
/* High bit never set by XP_RANDOM() alone */
|
/* High bit never set by XP_RANDOM() alone */
|
||||||
gameID = (XP_RANDOM() << 16) ^ XP_RANDOM();
|
gameID = (XP_RANDOM() << 16) ^ XP_RANDOM();
|
||||||
|
@ -178,9 +176,7 @@ game_makeNewGame( MPFORMAL XWEnv xwe, XWGame* game, CurGameInfo* gi,
|
||||||
checkServerRole( gi, &nPlayersHere, &nPlayersTotal );
|
checkServerRole( gi, &nPlayersHere, &nPlayersTotal );
|
||||||
assertUtilOK( util );
|
assertUtilOK( util );
|
||||||
|
|
||||||
if ( 0 == gi->gameID ) {
|
gi->gameID = game_makeGameID( gi->gameID );
|
||||||
gi->gameID = makeGameID( util );
|
|
||||||
}
|
|
||||||
XW_DUtilCtxt* dutil = util_getDevUtilCtxt( util, xwe );
|
XW_DUtilCtxt* dutil = util_getDevUtilCtxt( util, xwe );
|
||||||
game->created = dutil_getCurSeconds( dutil, xwe );
|
game->created = dutil_getCurSeconds( dutil, xwe );
|
||||||
game->util = util;
|
game->util = util;
|
||||||
|
@ -247,7 +243,7 @@ game_makeRematch( const XWGame* oldGame, XWEnv xwe, XW_UtilCtxt* newUtil,
|
||||||
|
|
||||||
RematchInfo* rip;
|
RematchInfo* rip;
|
||||||
if ( server_getRematchInfo( oldGame->server, newUtil,
|
if ( server_getRematchInfo( oldGame->server, newUtil,
|
||||||
makeGameID( newUtil ), nop, &rip ) ) {
|
game_makeGameID( 0 ), nop, &rip ) ) {
|
||||||
CommsAddrRec* selfAddrP = NULL;
|
CommsAddrRec* selfAddrP = NULL;
|
||||||
CommsAddrRec selfAddr;
|
CommsAddrRec selfAddr;
|
||||||
if ( !!oldGame->comms ) {
|
if ( !!oldGame->comms ) {
|
||||||
|
|
|
@ -77,6 +77,8 @@ typedef struct _XWGame {
|
||||||
XP_U32 created; /* dutil_getCurSeconds() of creation */
|
XP_U32 created; /* dutil_getCurSeconds() of creation */
|
||||||
} XWGame;
|
} XWGame;
|
||||||
|
|
||||||
|
XP_U32 game_makeGameID();
|
||||||
|
|
||||||
XP_Bool game_makeNewGame( MPFORMAL XWEnv xwe, XWGame* game, CurGameInfo* gi,
|
XP_Bool game_makeNewGame( MPFORMAL XWEnv xwe, XWGame* game, CurGameInfo* gi,
|
||||||
const CommsAddrRec* selfAddr, const CommsAddrRec* hostAddr,
|
const CommsAddrRec* selfAddr, const CommsAddrRec* hostAddr,
|
||||||
XW_UtilCtxt* util, DrawCtx* draw, const CommonPrefs* cp,
|
XW_UtilCtxt* util, DrawCtx* draw, const CommonPrefs* cp,
|
||||||
|
|
Loading…
Add table
Reference in a new issue