mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
fix gtk version to correctly implement util_setIsServer (which only
Android did so far) by calling server_initClientConnection(). Now relay games work with both started as hosts. (GTK UI prevents starting one as a guest; cmdline is required for that, if it still works.)
This commit is contained in:
parent
5e2bfd20da
commit
fac3e6b678
4 changed files with 47 additions and 6 deletions
|
@ -407,6 +407,14 @@ curses_util_informNetDict( XW_UtilCtxt* uc, XP_LangCode XP_UNUSED(lang),
|
|||
XP_LOGF( "%s: %s => %s (cksum: %s)", __func__, oldName, newName, newSum );
|
||||
}
|
||||
|
||||
static void
|
||||
curses_util_setIsServer( XW_UtilCtxt* uc, XP_Bool isServer )
|
||||
{
|
||||
LOG_FUNC();
|
||||
CommonGlobals* cGlobals = (CommonGlobals*)uc->closure;
|
||||
linuxSetIsServer( cGlobals, isServer );
|
||||
}
|
||||
|
||||
#ifdef XWFEATURE_HILITECELL
|
||||
static XP_Bool
|
||||
curses_util_hiliteCell( XW_UtilCtxt* uc,
|
||||
|
@ -1526,6 +1534,8 @@ setupCursesUtilCallbacks( CursesAppGlobals* globals, XW_UtilCtxt* util )
|
|||
util->vtable->m_util_informUndo = curses_util_informUndo;
|
||||
util->vtable->m_util_notifyGameOver = curses_util_notifyGameOver;
|
||||
util->vtable->m_util_informNetDict = curses_util_informNetDict;
|
||||
util->vtable->m_util_setIsServer = curses_util_setIsServer;
|
||||
|
||||
#ifdef XWFEATURE_HILITECELL
|
||||
util->vtable->m_util_hiliteCell = curses_util_hiliteCell;
|
||||
#endif
|
||||
|
|
|
@ -1534,6 +1534,22 @@ gtk_util_informNetDict( XW_UtilCtxt* uc, XP_LangCode XP_UNUSED(lang),
|
|||
(void)gtkask( globals->window, buf, GTK_BUTTONS_OK );
|
||||
}
|
||||
|
||||
static gint
|
||||
changeRoles( gpointer data )
|
||||
{
|
||||
linuxChangeRoles( (CommonGlobals*)data );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_util_setIsServer( XW_UtilCtxt* uc, XP_Bool isServer )
|
||||
{
|
||||
CommonGlobals* cGlobals = (CommonGlobals*)uc->closure;
|
||||
linuxSetIsServer( cGlobals, isServer );
|
||||
|
||||
(void)g_idle_add( changeRoles, cGlobals );
|
||||
}
|
||||
|
||||
/* define this to prevent user events during debugging from stopping the engine */
|
||||
/* #define DONT_ABORT_ENGINE */
|
||||
|
||||
|
@ -1604,7 +1620,7 @@ pen_timer_func( gpointer data )
|
|||
}
|
||||
|
||||
return XP_FALSE;
|
||||
} /* pentimer_idle_func */
|
||||
} /* pen_timer_func */
|
||||
|
||||
static gint
|
||||
score_timer_func( gpointer data )
|
||||
|
@ -2061,6 +2077,7 @@ setupGtkUtilCallbacks( GtkAppGlobals* globals, XW_UtilCtxt* util )
|
|||
util->vtable->m_util_informUndo = gtk_util_informUndo;
|
||||
util->vtable->m_util_notifyGameOver = gtk_util_notifyGameOver;
|
||||
util->vtable->m_util_informNetDict = gtk_util_informNetDict;
|
||||
util->vtable->m_util_setIsServer = gtk_util_setIsServer;
|
||||
#ifdef XWFEATURE_HILITECELL
|
||||
util->vtable->m_util_hiliteCell = gtk_util_hiliteCell;
|
||||
#endif
|
||||
|
|
|
@ -1152,15 +1152,28 @@ linux_util_addrChange( XW_UtilCtxt* uc,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
linux_util_setIsServer( XW_UtilCtxt* uc, XP_Bool isServer )
|
||||
void
|
||||
linuxSetIsServer( CommonGlobals* cGlobals, XP_Bool isServer )
|
||||
{
|
||||
XP_LOGF( "%s(%d)", __func__, isServer );
|
||||
CommonGlobals* cGlobals = (CommonGlobals*)uc->closure;
|
||||
XP_LOGF( "%s(isServer=%d)", __func__, isServer );
|
||||
DeviceRole newRole = isServer? SERVER_ISSERVER : SERVER_ISCLIENT;
|
||||
cGlobals->params->serverRole = newRole;
|
||||
cGlobals->gi.serverRole = newRole;
|
||||
}
|
||||
|
||||
void
|
||||
linuxChangeRoles( CommonGlobals* cGlobals )
|
||||
{
|
||||
ServerCtxt* server = cGlobals->game.server;
|
||||
server_reset( server, cGlobals->game.comms );
|
||||
if ( SERVER_ISCLIENT == cGlobals->gi.serverRole ) {
|
||||
XWStreamCtxt* stream =
|
||||
mem_stream_make( MPPARM(cGlobals->util->mpool) cGlobals->params->vtMgr,
|
||||
cGlobals, CHANNEL_NONE, sendOnClose );
|
||||
server_initClientConnection( server, stream );
|
||||
}
|
||||
(void)server_do( server );
|
||||
}
|
||||
#endif
|
||||
|
||||
static unsigned int
|
||||
|
@ -1539,7 +1552,6 @@ setupLinuxUtilCallbacks( XW_UtilCtxt* util )
|
|||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
util->vtable->m_util_informMissing = linux_util_informMissing;
|
||||
util->vtable->m_util_addrChange = linux_util_addrChange;
|
||||
util->vtable->m_util_setIsServer = linux_util_setIsServer;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,8 @@ void setupUtil( CommonGlobals* cGlobals );
|
|||
|
||||
DictionaryCtxt* makeDictForStream( CommonGlobals* cGlobals,
|
||||
XWStreamCtxt* stream );
|
||||
void linuxSetIsServer( CommonGlobals* cGlobals, XP_Bool isServer );
|
||||
void linuxChangeRoles( CommonGlobals* cGlobals );
|
||||
|
||||
/* void initParams( LaunchParams* params ); */
|
||||
/* void freeParams( LaunchParams* params ); */
|
||||
|
|
Loading…
Add table
Reference in a new issue