mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
fix so curses app can invite two players on one device
Turns out the host, when inviting a remote device, needs to know how many players are on it (since more than one is supported and the script currently generates that case.) So pass to --server devices an array, one per remote -- but don't bother when all entries are "1";
This commit is contained in:
parent
e68e972396
commit
4720ede1d7
5 changed files with 30 additions and 5 deletions
|
@ -89,6 +89,7 @@ nli_setInviteID( NetLaunchInfo* nli, const XP_UCHAR* inviteID )
|
|||
void
|
||||
nli_saveToStream( const NetLaunchInfo* nli, XWStreamCtxt* stream )
|
||||
{
|
||||
LOGNLI( nli );
|
||||
stream_putU8( stream, NLI_VERSION );
|
||||
|
||||
stream_putU16( stream, nli->_conTypes );
|
||||
|
@ -172,6 +173,7 @@ nli_makeFromStream( NetLaunchInfo* nli, XWStreamCtxt* stream )
|
|||
XP_ASSERT( 0 == stream_getSize( stream ) );
|
||||
|
||||
LOG_RETURNF( "%s", boolToStr(success) );
|
||||
LOGNLI( nli );
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
|
@ -1213,10 +1213,12 @@ inviteList( CommonGlobals* cGlobals, CommsAddrRec* addr, GSList* invitees,
|
|||
if ( haveAddressees ) {
|
||||
LaunchParams* params = cGlobals->params;
|
||||
for ( int ii = 0; ii < g_slist_length(invitees); ++ii ) {
|
||||
const XP_U16 nPlayers = 1;
|
||||
gint forceChannel = ii + 1;
|
||||
const XP_U16 nPlayersH = params->connInfo.inviteeCounts[ii];
|
||||
const gint forceChannel = ii + 1;
|
||||
XP_LOGFF( "using nPlayersH of %d, forceChannel of %d for guest device %d",
|
||||
nPlayersH, forceChannel, ii );
|
||||
NetLaunchInfo nli = {0};
|
||||
nli_init( &nli, cGlobals->gi, addr, nPlayers, forceChannel );
|
||||
nli_init( &nli, cGlobals->gi, addr, nPlayersH, forceChannel );
|
||||
if ( useRelay ) {
|
||||
uint64_t inviteeRelayID = (uint64_t)g_slist_nth_data( invitees, ii );
|
||||
relaycon_invite( params, (XP_U32)inviteeRelayID, NULL, &nli );
|
||||
|
@ -1241,8 +1243,8 @@ handleInvite( void* closure, int XP_UNUSED(key) )
|
|||
XP_ASSERT( comms );
|
||||
comms_getAddr( comms, &addr );
|
||||
|
||||
XP_U16 nPlayers = 1;
|
||||
gint forceChannel = 1;
|
||||
const XP_U16 nPlayers = params->connInfo.inviteeCounts[forceChannel-1];
|
||||
NetLaunchInfo nli = {0};
|
||||
nli_init( &nli, cGlobals->gi, &addr, nPlayers, forceChannel );
|
||||
|
||||
|
|
|
@ -329,7 +329,7 @@ linuxOpenGame( CommonGlobals* cGlobals, const TransportProcs* procs,
|
|||
cGlobals->gi->allowHintRect = params->allowHintRect;
|
||||
#endif
|
||||
|
||||
if ( params->needsNewGame ) {
|
||||
if ( params->needsNewGame && !opened ) {
|
||||
XP_ASSERT(0);
|
||||
// new_game_impl( globals, XP_FALSE );
|
||||
}
|
||||
|
@ -881,6 +881,7 @@ typedef enum {
|
|||
,CMD_INVITEE_SMSNUMBER
|
||||
,CMD_SMSPORT
|
||||
#endif
|
||||
,CMD_INVITEE_COUNTS
|
||||
#ifdef XWFEATURE_RELAY
|
||||
,CMD_ROOMNAME
|
||||
,CMD_ADVERTISEROOM
|
||||
|
@ -1014,6 +1015,9 @@ static CmdInfoRec CmdInfoRecs[] = {
|
|||
,{ CMD_INVITEE_SMSNUMBER, true, "invitee-sms-number", "number to send any invitation to" }
|
||||
,{ CMD_SMSPORT, true, "sms-port", "this devices's sms port" }
|
||||
#endif
|
||||
,{ CMD_INVITEE_COUNTS, true, "invitee-counts",
|
||||
"When invitations sent, how many on each device? e.g. \"1:2\" for a "
|
||||
"three-dev game with two players on second guest" }
|
||||
#ifdef XWFEATURE_RELAY
|
||||
,{ CMD_ROOMNAME, true, "room", "name of room on relay" }
|
||||
,{ CMD_ADVERTISEROOM, false, "make-public", "make room public on relay" }
|
||||
|
@ -2537,6 +2541,9 @@ main( int argc, char** argv )
|
|||
initParams( &mainParams );
|
||||
|
||||
/* defaults */
|
||||
for ( int ii = 0; ii < VSIZE(mainParams.connInfo.inviteeCounts); ++ii ) {
|
||||
mainParams.connInfo.inviteeCounts[ii] = 1;
|
||||
}
|
||||
#ifdef XWFEATURE_RELAY
|
||||
mainParams.connInfo.relay.defaultSendPort = DEFAULT_PORT;
|
||||
mainParams.connInfo.relay.relayName = "localhost";
|
||||
|
@ -2737,6 +2744,16 @@ main( int argc, char** argv )
|
|||
g_slist_append( mainParams.connInfo.sms.inviteePhones, optarg );
|
||||
addr_addType( &mainParams.addr, COMMS_CONN_SMS );
|
||||
break;
|
||||
case CMD_INVITEE_COUNTS: {
|
||||
gchar** strs = g_strsplit( optarg, ":", -1 );
|
||||
for ( int ii = 0;
|
||||
!!strs[ii] && ii < VSIZE(mainParams.connInfo.inviteeCounts);
|
||||
++ii ) {
|
||||
mainParams.connInfo.inviteeCounts[ii] = atoi(strs[ii]);
|
||||
}
|
||||
g_strfreev( strs );
|
||||
}
|
||||
break;
|
||||
case CMD_SMSPORT:
|
||||
mainParams.connInfo.sms.port = atoi(optarg);
|
||||
addr_addType( &mainParams.addr, COMMS_CONN_SMS );
|
||||
|
|
|
@ -136,6 +136,7 @@ typedef struct LaunchParams {
|
|||
|
||||
CommsAddrRec addr;
|
||||
struct {
|
||||
XP_U16 inviteeCounts[MAX_NUM_PLAYERS];
|
||||
#ifdef XWFEATURE_RELAY
|
||||
struct {
|
||||
char* relayName;
|
||||
|
|
|
@ -483,6 +483,9 @@ def build_cmds(args):
|
|||
if DEV == 1 or usePublic: PARAMS += ['--force-game']
|
||||
if DEV == 1:
|
||||
PARAMS += ['--server', '--phonies', phonies ]
|
||||
# IFF there are any non-1 player counts, tell inviter which
|
||||
if sum(LOCALS) > NDEVS:
|
||||
PARAMS += ['--invitee-counts', ":".join(str(n) for n in LOCALS[1:])]
|
||||
else:
|
||||
PARAMS += ['--force-channel', DEV - 1]
|
||||
if args.PHONY_PCT and phonies == 2: PARAMS += [ '--make-phony-pct', args.PHONY_PCT ]
|
||||
|
|
Loading…
Reference in a new issue