diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index 7b8fbbc75..602e0336f 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -460,11 +460,11 @@ init_relay( CommsCtxt* comms, XWEnv xwe, XP_U16 nPlayersHere, XP_U16 nPlayersTot CommsCtxt* comms_make( MPFORMAL XWEnv xwe, XW_UtilCtxt* util, XP_Bool isServer, const CommsAddrRec* selfAddr, const CommsAddrRec* hostAddr, + const TransportProcs* procs, #ifdef XWFEATURE_RELAY XP_U16 nPlayersHere, XP_U16 nPlayersTotal, -#endif - const TransportProcs* procs, RoleChangeProc rcp, void* rcClosure, +#endif XP_U16 forceChannel #ifdef SET_GAMESEED , XP_U16 gameSeed @@ -489,14 +489,14 @@ comms_make( MPFORMAL XWEnv xwe, XW_UtilCtxt* util, XP_Bool isServer, comms->xportFlags = comms->procs.flags; #endif } - XP_ASSERT( rcp ); - comms->rcProc = rcp; - comms->rcClosure = rcClosure; - comms->util = util; comms->dutil = util_getDevUtilCtxt( util, xwe ); #ifdef XWFEATURE_RELAY + XP_ASSERT( rcp ); + comms->rcProc = rcp; + comms->rcClosure = rcClosure; + init_relay( comms, xwe, nPlayersHere, nPlayersTotal ); # ifdef SET_GAMESEED comms->channelSeed = gameSeed; @@ -790,7 +790,9 @@ CommsCtxt* comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, XW_UtilCtxt* util, XP_Bool isServer, const TransportProcs* procs, +#ifdef XWFEATURE_RELAY RoleChangeProc rcp, void* rcClosure, +#endif XP_U16 forceChannel ) { LOG_FUNC(); @@ -819,11 +821,12 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, nPlayersHere = 0; nPlayersTotal = 0; } - CommsCtxt* comms = comms_make( MPPARM(mpool) xwe, util, isServer, NULL, NULL, + CommsCtxt* comms = comms_make( MPPARM(mpool) xwe, util, isServer, + NULL, NULL, procs, #ifdef XWFEATURE_RELAY - nPlayersHere, nPlayersTotal, + nPlayersHere, nPlayersTotal, rcp, rcClosure, #endif - procs, rcp, rcClosure, forceChannel + forceChannel #ifdef SET_GAMESEED , 0 #endif diff --git a/xwords4/common/comms.h b/xwords4/common/comms.h index 9c92c52d5..2caa882f0 100644 --- a/xwords4/common/comms.h +++ b/xwords4/common/comms.h @@ -150,11 +150,11 @@ CommsCtxt* comms_make( MPFORMAL XWEnv xwe, XW_UtilCtxt* util, XP_Bool isServer, const CommsAddrRec* selfAddr, const CommsAddrRec* hostAddr, + const TransportProcs* procs, #ifdef XWFEATURE_RELAY XP_U16 nPlayersHere, XP_U16 nPlayersTotal, -#endif - const TransportProcs* procs, RoleChangeProc rcp, void* rcClosure, +#endif XP_U16 forceChannel #ifdef SET_GAMESEED ,XP_U16 gameSeed @@ -191,7 +191,9 @@ XP_Bool comms_getIsServer( const CommsCtxt* comms ); CommsCtxt* comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, XW_UtilCtxt* util, XP_Bool isServer, const TransportProcs* procs, +#ifdef XWFEATURE_RELAY RoleChangeProc rcp, void* rcClosure, +#endif XP_U16 forceChannel ); void comms_start( CommsCtxt* comms, XWEnv xwe ); void comms_stop( CommsCtxt* comms diff --git a/xwords4/common/game.c b/xwords4/common/game.c index 2459b5784..a6f8518ff 100644 --- a/xwords4/common/game.c +++ b/xwords4/common/game.c @@ -105,6 +105,7 @@ timerChangeListener( XWEnv xwe, void* data, const XP_U32 gameID, gameID, oldVal, newVal ); } +#ifdef XWFEATURE_RELAY static void onRoleChanged( XWEnv xwe, void* closure, XP_Bool amNowGuest ) { @@ -112,6 +113,7 @@ onRoleChanged( XWEnv xwe, void* closure, XP_Bool amNowGuest ) XWGame* game = (XWGame*)closure; server_onRoleChanged( game->server, xwe, amNowGuest ); } +#endif static void setListeners( XWGame* game, const CommonPrefs* cp ) @@ -196,11 +198,11 @@ game_makeNewGame( MPFORMAL XWEnv xwe, XWGame* game, CurGameInfo* gi, if ( gi->serverRole != SERVER_STANDALONE ) { game->comms = comms_make( MPPARM(mpool) xwe, util, gi->serverRole != SERVER_ISCLIENT, - selfAddr, hostAddr, + selfAddr, hostAddr, procs, #ifdef XWFEATURE_RELAY nPlayersHere, nPlayersTotal, + onRoleChanged, game, #endif - procs, onRoleChanged, game, gi->forceChannel #ifdef SET_GAMESEED , gameSeed @@ -345,7 +347,10 @@ game_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, if ( hasComms ) { game->comms = comms_makeFromStream( MPPARM(mpool) xwe, stream, util, gi->serverRole != SERVER_ISCLIENT, - procs, onRoleChanged, game, + procs, +#ifdef XWFEATURE_RELAY + onRoleChanged, game, +#endif gi->forceChannel ); } else { XP_ASSERT( NULL == game->comms ); diff --git a/xwords4/common/server.c b/xwords4/common/server.c index f9fe2da1c..e3d4093f6 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -640,6 +640,7 @@ server_writeToStream( const ServerCtxt* server, XWStreamCtxt* stream ) } } /* server_writeToStream */ +#ifdef XWFEATURE_RELAY void server_onRoleChanged( ServerCtxt* server, XWEnv xwe, XP_Bool amNowGuest ) { @@ -654,6 +655,7 @@ server_onRoleChanged( ServerCtxt* server, XWEnv xwe, XP_Bool amNowGuest ) } } } +#endif static void cleanupServer( ServerCtxt* server ) diff --git a/xwords4/common/server.h b/xwords4/common/server.h index a5e142e57..1b7d3b83c 100644 --- a/xwords4/common/server.h +++ b/xwords4/common/server.h @@ -44,7 +44,9 @@ void server_reset( ServerCtxt* server, XWEnv xwe, CommsCtxt* comms ); void server_destroy( ServerCtxt* server ); void server_prefsChanged( ServerCtxt* server, const CommonPrefs* cp ); +#ifdef XWFEATURE_RELAY void server_onRoleChanged( ServerCtxt* server, XWEnv xwe, XP_Bool amNowGuest ); +#endif typedef void (*TurnChangeListener)( XWEnv xwe, void* data ); void server_setTurnChangeListener( ServerCtxt* server, TurnChangeListener tl,