mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
tweaks to game_makeRematch
This commit is contained in:
parent
b9c6551e8b
commit
6b29ee92e6
3 changed files with 34 additions and 12 deletions
|
@ -2817,6 +2817,10 @@ comms_checkIncomingStream( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream,
|
|||
XP_MEMSET( state, 0, sizeof(*state) );
|
||||
#ifdef DEBUG
|
||||
state->comms = comms;
|
||||
if ( comms->processingMsg ) {
|
||||
XP_LOGFF( "processingMsg SET, so dropping message" );
|
||||
return XP_FALSE;
|
||||
}
|
||||
XP_ASSERT( !comms->processingMsg );
|
||||
comms->processingMsg = XP_TRUE;
|
||||
CommsConnType addrType = addr_getType( retAddr );
|
||||
|
|
|
@ -238,29 +238,34 @@ game_makeRematch( const XWGame* oldGame, XWEnv xwe, XW_UtilCtxt* util,
|
|||
CurGameInfo newGI = {0};
|
||||
gi_copy( MPPARM(util->mpool) &newGI, gi );
|
||||
newGI.gameID = 0; /* clear so will get generated */
|
||||
newGI.serverRole = SERVER_ISSERVER;
|
||||
if ( SERVER_ISCLIENT == newGI.serverRole ) {
|
||||
newGI.serverRole = SERVER_ISSERVER; /* we'll be inviting */
|
||||
}
|
||||
|
||||
XWGame newGame;
|
||||
CommsAddrRec* selfAddrP = NULL;
|
||||
/* CommsAddrRec* hostAddrP = NULL; */
|
||||
CommsAddrRec selfAddr;
|
||||
if ( !!oldGame->comms ) {
|
||||
comms_getSelfAddr( oldGame->comms, &selfAddr );
|
||||
selfAddrP = &selfAddr;
|
||||
/* if ( SERVER_ISCLIENT == gi->serverRole ) { */
|
||||
/* comms_getHostAddr( oldGame->comms, &hostAddr ); */
|
||||
/* hostAddrP = &hostAddr; */
|
||||
/* } */
|
||||
}
|
||||
|
||||
if ( game_makeNewGame( MPPARM(util->mpool) xwe, &newGame, &newGI,
|
||||
selfAddrP, NULL, util,
|
||||
CommsAddrRec hostAddr;
|
||||
XP_Bool haveRemote = !oldGame->comms
|
||||
|| comms_getHostAddr( oldGame->comms, &hostAddr );
|
||||
if ( !haveRemote ) {
|
||||
XP_U16 nRecs = 1;
|
||||
comms_getAddrs( oldGame->comms, xwe, &hostAddr, &nRecs );
|
||||
haveRemote = 0 < nRecs;
|
||||
}
|
||||
XP_ASSERT( haveRemote );
|
||||
|
||||
if ( haveRemote &&
|
||||
game_makeNewGame( MPPARM(util->mpool) xwe, &newGame, &newGI,
|
||||
selfAddrP, (CommsAddrRec*)NULL, util,
|
||||
(DrawCtx*)NULL, cp, (TransportProcs*)NULL ) ) {
|
||||
if ( !!newGame.comms ) {
|
||||
CommsAddrRec hostAddr;
|
||||
comms_getHostAddr( oldGame->comms, &hostAddr );
|
||||
|
||||
NetLaunchInfo nli = {0};
|
||||
NetLaunchInfo nli;
|
||||
nli_init( &nli, &newGI, selfAddrP, 1, 1 );
|
||||
LOGNLI( &nli );
|
||||
comms_invite( newGame.comms, xwe, &nli, &hostAddr );
|
||||
|
|
|
@ -147,6 +147,17 @@ ensureLocalPlayerNames( LaunchParams* XP_UNUSED_DBG(params), CurGameInfo* gi )
|
|||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
send_msgs_idle( gpointer data )
|
||||
{
|
||||
CommonGlobals* cGlobals = (CommonGlobals*)data;
|
||||
CommsCtxt* comms = cGlobals->game.comms;
|
||||
if ( !!comms ) {
|
||||
comms_resendAll( comms, NULL_XWE, COMMS_CONN_NONE, XP_FALSE );
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool
|
||||
linuxOpenGame( CommonGlobals* cGlobals, const TransportProcs* procs )
|
||||
{
|
||||
|
@ -230,6 +241,8 @@ linuxOpenGame( CommonGlobals* cGlobals, const TransportProcs* procs )
|
|||
#endif
|
||||
server_do( cGlobals->game.server, NULL_XWE );
|
||||
linuxSaveGame( cGlobals ); /* again, to include address etc. */
|
||||
|
||||
(void)g_idle_add( send_msgs_idle, cGlobals );
|
||||
}
|
||||
LOG_RETURNF( "%s", boolToStr(opened) );
|
||||
return opened;
|
||||
|
|
Loading…
Add table
Reference in a new issue