mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-15 15:41:24 +01:00
make invitation to three-device games work on gtk/linux
This commit is contained in:
parent
ad5514ac17
commit
d924776a84
3 changed files with 61 additions and 38 deletions
|
@ -83,14 +83,14 @@ typedef enum {
|
||||||
|
|
||||||
#define XWPROTO_NBITS 4
|
#define XWPROTO_NBITS 4
|
||||||
|
|
||||||
|
#define UNKNOWN_DEVICE -1
|
||||||
|
#define SERVER_DEVICE 0
|
||||||
|
|
||||||
typedef struct ServerPlayer {
|
typedef struct ServerPlayer {
|
||||||
EngineCtxt* engine; /* each needs his own so don't interfere each other */
|
EngineCtxt* engine; /* each needs his own so don't interfere each other */
|
||||||
XP_S8 deviceIndex; /* 0 means local, -1 means unknown */
|
XP_S8 deviceIndex; /* 0 means local, -1 means unknown */
|
||||||
} ServerPlayer;
|
} ServerPlayer;
|
||||||
|
|
||||||
#define UNKNOWN_DEVICE -1
|
|
||||||
#define SERVER_DEVICE 0
|
|
||||||
|
|
||||||
typedef struct RemoteAddress {
|
typedef struct RemoteAddress {
|
||||||
XP_PlayerAddr channelNo;
|
XP_PlayerAddr channelNo;
|
||||||
#ifdef STREAM_VERS_BIGBOARD
|
#ifdef STREAM_VERS_BIGBOARD
|
||||||
|
@ -3862,6 +3862,26 @@ server_getMissingPlayers( const ServerCtxt* server )
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XP_Bool
|
||||||
|
server_getOpenChannel( const ServerCtxt* server, XP_U16* channel )
|
||||||
|
{
|
||||||
|
XP_Bool result = XP_FALSE;
|
||||||
|
XP_ASSERT( amServer( server ) );
|
||||||
|
if ( amServer( server ) && 0 < server->nv.pendingRegistrations ) {
|
||||||
|
const XP_U16 nPlayers = server->vol.gi->nPlayers;
|
||||||
|
const ServerPlayer* players = server->players;
|
||||||
|
for ( int ii = 0; ii < nPlayers && !result; ++ii ) {
|
||||||
|
result = UNKNOWN_DEVICE == players->deviceIndex;
|
||||||
|
if ( result ) {
|
||||||
|
*channel = ii;
|
||||||
|
}
|
||||||
|
++players;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XP_LOGFF( "channel= %d, found: %s", *channel, boolToStr(result) );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
XP_U32
|
XP_U32
|
||||||
server_getLastMoveTime( const ServerCtxt* server )
|
server_getLastMoveTime( const ServerCtxt* server )
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,6 +90,7 @@ void server_unpause( ServerCtxt* server, XWEnv xwe, XP_S16 turn, const XP_UCHAR*
|
||||||
|
|
||||||
/* return bitvector marking players still not arrived in networked game */
|
/* return bitvector marking players still not arrived in networked game */
|
||||||
XP_U16 server_getMissingPlayers( const ServerCtxt* server );
|
XP_U16 server_getMissingPlayers( const ServerCtxt* server );
|
||||||
|
XP_Bool server_getOpenChannel( const ServerCtxt* server, XP_U16* channel );
|
||||||
XP_U32 server_getLastMoveTime( const ServerCtxt* server );
|
XP_U32 server_getLastMoveTime( const ServerCtxt* server );
|
||||||
/* Signed in case no dictionary available */
|
/* Signed in case no dictionary available */
|
||||||
XP_S16 server_countTilesInPool( ServerCtxt* server );
|
XP_S16 server_countTilesInPool( ServerCtxt* server );
|
||||||
|
|
|
@ -1386,7 +1386,9 @@ send_invites( CommonGlobals* cGlobals, XP_U16 nPlayers,
|
||||||
XP_ASSERT( comms );
|
XP_ASSERT( comms );
|
||||||
comms_getSelfAddr( comms, &myAddr );
|
comms_getSelfAddr( comms, &myAddr );
|
||||||
|
|
||||||
gint forceChannel = 1; /* 1 is what Android does. Limits to two-device games */
|
XP_U16 channel;
|
||||||
|
if ( server_getOpenChannel( cGlobals->game.server, &channel ) ) {
|
||||||
|
gint forceChannel = channel;
|
||||||
|
|
||||||
NetLaunchInfo nli = {0}; /* include everything!!! */
|
NetLaunchInfo nli = {0}; /* include everything!!! */
|
||||||
nli_init( &nli, cGlobals->gi, &myAddr, nPlayers, forceChannel );
|
nli_init( &nli, cGlobals->gi, &myAddr, nPlayers, forceChannel );
|
||||||
|
@ -1434,7 +1436,7 @@ send_invites( CommonGlobals* cGlobals, XP_U16 nPlayers,
|
||||||
mqttc_invite( cGlobals->params, 0, &nli, &destAddr->u.mqtt.devID );
|
mqttc_invite( cGlobals->params, 0, &nli, &destAddr->u.mqtt.devID );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
/* while ( gtkaskm( "Invite how many and how?", infos, VSIZE(infos) ) ) { */
|
/* while ( gtkaskm( "Invite how many and how?", infos, VSIZE(infos) ) ) { */
|
||||||
/* int nPlayers = atoi( countStr ); */
|
/* int nPlayers = atoi( countStr ); */
|
||||||
/* if ( 0 >= nPlayers || nPlayers > nMissing ) { */
|
/* if ( 0 >= nPlayers || nPlayers > nMissing ) { */
|
||||||
|
|
Loading…
Reference in a new issue