use dutil_phoneNumbersSame() instead of strcmp()

This commit is contained in:
Eric House 2024-09-21 20:50:41 -07:00
parent 4e50024359
commit 2a8a9b442a
7 changed files with 52 additions and 39 deletions

View file

@ -1321,7 +1321,8 @@ comms_getChannelAddr( const CommsCtxt* comms, XP_PlayerAddr channelNo,
} }
XP_Bool XP_Bool
addrsAreSame( const CommsAddrRec* addr1, const CommsAddrRec* addr2 ) addrsAreSame( XW_DUtilCtxt* dutil, XWEnv xwe, const CommsAddrRec* addr1,
const CommsAddrRec* addr2 )
{ {
/* Empty addresses are the same only if both are empty */ /* Empty addresses are the same only if both are empty */
XP_Bool same = addr1->_conTypes == 0 && addr2->_conTypes == 0; XP_Bool same = addr1->_conTypes == 0 && addr2->_conTypes == 0;
@ -1335,7 +1336,7 @@ addrsAreSame( const CommsAddrRec* addr1, const CommsAddrRec* addr2 )
break; break;
case COMMS_CONN_SMS: case COMMS_CONN_SMS:
same = addr1->u.sms.port == addr2->u.sms.port same = addr1->u.sms.port == addr2->u.sms.port
&& 0 == XP_STRCMP(addr1->u.sms.phone, addr2->u.sms.phone ); && dutil_phoneNumbersSame( dutil, xwe, addr1->u.sms.phone, addr2->u.sms.phone );
break; break;
case COMMS_CONN_BT: case COMMS_CONN_BT:
same = 0 == XP_STRCMP( addr1->u.bt.hostName, addr2->u.bt.hostName ); same = 0 == XP_STRCMP( addr1->u.bt.hostName, addr2->u.bt.hostName );
@ -1657,7 +1658,7 @@ getInviteChannels( MsgQueueElem* elem, void* closure )
/* Choose a channel IFF nli doesn't already specify one. */ /* Choose a channel IFF nli doesn't already specify one. */
static XP_PlayerAddr static XP_PlayerAddr
pickChannel( const CommsCtxt* comms, const NetLaunchInfo* nli, pickChannel( const CommsCtxt* comms, XWEnv xwe, const NetLaunchInfo* nli,
const CommsAddrRec* destAddr ) const CommsAddrRec* destAddr )
{ {
XP_PlayerAddr result = nli->forceChannel; XP_PlayerAddr result = nli->forceChannel;
@ -1665,7 +1666,7 @@ pickChannel( const CommsCtxt* comms, const NetLaunchInfo* nli,
if ( 0 == result ) { if ( 0 == result ) {
/* First, do we already have an invitation for this address */ /* First, do we already have an invitation for this address */
for ( AddressRecord* rec = comms->recs; !!rec; rec = rec->next ) { for ( AddressRecord* rec = comms->recs; !!rec; rec = rec->next ) {
if ( addrsAreSame( destAddr, &rec->addr ) ) { if ( addrsAreSame( comms->dutil, xwe, destAddr, &rec->addr ) ) {
result = rec->channelNo & CHANNEL_MASK; result = rec->channelNo & CHANNEL_MASK;
XP_LOGFF( "addrs match; reusing channel %d", result ); XP_LOGFF( "addrs match; reusing channel %d", result );
break; break;
@ -1714,7 +1715,7 @@ comms_invite( CommsCtxt* comms, XWEnv xwe, const NetLaunchInfo* nli,
COMMS_LOGFF("(sendNow=%s)", boolToStr(sendNow)); COMMS_LOGFF("(sendNow=%s)", boolToStr(sendNow));
LOGNLI(nli); LOGNLI(nli);
WITH_MUTEX(&comms->mutex); WITH_MUTEX(&comms->mutex);
XP_PlayerAddr forceChannel = pickChannel( comms, nli, destAddr ); XP_PlayerAddr forceChannel = pickChannel( comms, xwe, nli, destAddr );
XP_LOGFF( "forceChannel: %d", forceChannel ); XP_LOGFF( "forceChannel: %d", forceChannel );
XP_ASSERT( 0 < forceChannel ); XP_ASSERT( 0 < forceChannel );
if ( 0 < forceChannel ) { if ( 0 < forceChannel ) {
@ -2766,13 +2767,13 @@ preProcess(
the channel set up. Be sure to use it or we may wind up nuking undelievered the channel set up. Be sure to use it or we may wind up nuking undelievered
invitations */ invitations */
static XP_Bool static XP_Bool
getChannelFromInvite( const CommsCtxt* comms, const CommsAddrRec* retAddr, getChannelFromInvite( const CommsCtxt* comms, XWEnv xwe,
XP_PlayerAddr* channelNoP ) const CommsAddrRec* retAddr, XP_PlayerAddr* channelNoP )
{ {
XP_Bool found = XP_FALSE; XP_Bool found = XP_FALSE;
for ( const AddressRecord* rec = comms->recs; !!rec && !found; for ( const AddressRecord* rec = comms->recs; !!rec && !found;
rec = rec->next ) { rec = rec->next ) {
found = addrsAreSame( retAddr, &rec->addr ); found = addrsAreSame( comms->dutil, xwe, retAddr, &rec->addr );
if ( found ) { if ( found ) {
COMMS_LOGFF( "channelNo before: %x", *channelNoP ); COMMS_LOGFF( "channelNo before: %x", *channelNoP );
*channelNoP |= rec->channelNo; *channelNoP |= rec->channelNo;
@ -2849,13 +2850,14 @@ getNextChannelNo( CommsCtxt* comms )
} }
static XP_Bool static XP_Bool
checkChannelNo( CommsCtxt* comms, const CommsAddrRec* retAddr, XP_PlayerAddr* channelNoP ) checkChannelNo( CommsCtxt* comms, XWEnv xwe, const CommsAddrRec* retAddr,
XP_PlayerAddr* channelNoP )
{ {
XP_Bool success = XP_TRUE; XP_Bool success = XP_TRUE;
XP_PlayerAddr channelNo = *channelNoP; XP_PlayerAddr channelNo = *channelNoP;
if ( 0 == (channelNo & CHANNEL_MASK) ) { if ( 0 == (channelNo & CHANNEL_MASK) ) {
XP_ASSERT( comms->isServer ); XP_ASSERT( comms->isServer );
if ( getChannelFromInvite( comms, retAddr, &channelNo ) ) { if ( getChannelFromInvite( comms, xwe, retAddr, &channelNo ) ) {
success = XP_TRUE; success = XP_TRUE;
} else { } else {
success = comms->nextChannelNo < CHANNEL_MASK; success = comms->nextChannelNo < CHANNEL_MASK;
@ -2894,7 +2896,8 @@ checkChannelNo( CommsCtxt* comms, const CommsAddrRec* retAddr, XP_PlayerAddr* ch
* it invalid * it invalid
*/ */
static AddressRecord* static AddressRecord*
validateInitialMessage( CommsCtxt* comms, XP_Bool XP_UNUSED_HEARTBEAT(hasPayload), validateInitialMessage( CommsCtxt* comms, XWEnv xwe,
XP_Bool XP_UNUSED_HEARTBEAT(hasPayload),
const CommsAddrRec* retAddr, XWHostID senderID, const CommsAddrRec* retAddr, XWHostID senderID,
XP_PlayerAddr* channelNoP, XP_U16 flags, MsgID msgID ) XP_PlayerAddr* channelNoP, XP_U16 flags, MsgID msgID )
{ {
@ -2916,7 +2919,7 @@ validateInitialMessage( CommsCtxt* comms, XP_Bool XP_UNUSED_HEARTBEAT(hasPayload
} }
} else { } else {
if ( comms->isServer ) { if ( comms->isServer ) {
if ( checkChannelNo( comms, retAddr, channelNoP ) ) { if ( checkChannelNo( comms, xwe, retAddr, channelNoP ) ) {
CNO_FMT( cbuf, *channelNoP ); CNO_FMT( cbuf, *channelNoP );
COMMS_LOGFF( TAGFMT() "augmented channel: %s", TAGPRMS, cbuf ); COMMS_LOGFF( TAGFMT() "augmented channel: %s", TAGPRMS, cbuf );
} else { } else {
@ -3175,7 +3178,7 @@ comms_checkIncomingStream( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream,
if ( messageValid ) { if ( messageValid ) {
if ( stuff.connID == CONN_ID_NONE ) { if ( stuff.connID == CONN_ID_NONE ) {
/* special case: initial message from client or server */ /* special case: initial message from client or server */
rec = validateInitialMessage( comms, streamSize > 0, retAddr, rec = validateInitialMessage( comms, xwe, streamSize > 0, retAddr,
senderID, &stuff.channelNo, senderID, &stuff.channelNo,
stuff.flags, stuff.msgID ); stuff.flags, stuff.msgID );
state->rec = rec; state->rec = rec;

View file

@ -218,7 +218,8 @@ XP_S16 comms_resendAll( CommsCtxt* comms, XWEnv xwe, CommsConnType filter,
XP_U16 comms_getChannelSeed( CommsCtxt* comms ); XP_U16 comms_getChannelSeed( CommsCtxt* comms );
void comms_getChannelAddr( const CommsCtxt* comms, XP_PlayerAddr channelNo, void comms_getChannelAddr( const CommsCtxt* comms, XP_PlayerAddr channelNo,
CommsAddrRec* addr ); CommsAddrRec* addr );
XP_Bool addrsAreSame( const CommsAddrRec* addr1, const CommsAddrRec* addr2 ); XP_Bool addrsAreSame( XW_DUtilCtxt* dutil, XWEnv xwe, const CommsAddrRec* addr1,
const CommsAddrRec* addr2 );
#ifdef XWFEATURE_COMMSACK #ifdef XWFEATURE_COMMSACK
void comms_ackAny( CommsCtxt* comms, XWEnv xwe ); void comms_ackAny( CommsCtxt* comms, XWEnv xwe );

View file

@ -94,6 +94,9 @@ clearDS( DragState* ds )
static XP_Bool static XP_Bool
ddStartBoard( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy ) ddStartBoard( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy )
{ {
#ifndef XWFEATURE_SEARCHLIMIT
XP_USE(xwe);
#endif
DragState* ds = &board->dragState; DragState* ds = &board->dragState;
XP_Bool trayVisible; XP_Bool trayVisible;
XP_U16 col, row; XP_U16 col, row;

View file

@ -242,7 +242,7 @@ game_makeRematch( const XWGame* oldGame, XWEnv xwe, XW_UtilCtxt* newUtil,
XP_Bool success = XP_FALSE; XP_Bool success = XP_FALSE;
RematchInfo* rip; RematchInfo* rip;
if ( server_getRematchInfo( oldGame->server, newUtil, if ( server_getRematchInfo( oldGame->server, xwe, newUtil,
game_makeGameID( 0 ), nop, &rip ) ) { game_makeGameID( 0 ), nop, &rip ) ) {
CommsAddrRec* selfAddrP = NULL; CommsAddrRec* selfAddrP = NULL;
CommsAddrRec selfAddr; CommsAddrRec selfAddr;

View file

@ -384,6 +384,8 @@ kplr_nameForMqttDev( XW_DUtilCtxt* dutil, XWEnv xwe,
} }
typedef struct _MDevState { typedef struct _MDevState {
XW_DUtilCtxt* dutil;
XWEnv xwe;
const CommsAddrRec* addr; const CommsAddrRec* addr;
const XP_UCHAR* name; const XP_UCHAR* name;
} MDevState; } MDevState;
@ -395,7 +397,7 @@ addrProc( const DLHead* dl, void* closure )
const KnownPlayer* kp = (KnownPlayer*)dl; const KnownPlayer* kp = (KnownPlayer*)dl;
MDevState* msp = (MDevState*)closure; MDevState* msp = (MDevState*)closure;
if ( addrsAreSame( &kp->addr, msp->addr ) ) { if ( addrsAreSame( msp->dutil, msp->xwe, &kp->addr, msp->addr ) ) {
msp->name = kp->name; msp->name = kp->name;
result = FEA_EXIT; result = FEA_EXIT;
} }
@ -406,7 +408,8 @@ const XP_UCHAR*
kplr_nameForAddress( XW_DUtilCtxt* dutil, XWEnv xwe, kplr_nameForAddress( XW_DUtilCtxt* dutil, XWEnv xwe,
const CommsAddrRec* addr ) const CommsAddrRec* addr )
{ {
MDevState ms = {.addr = addr}; MDevState ms = {.addr = addr, .dutil = dutil, .xwe = xwe, };
WITH_MUTEX( &dutil->kpMutex ); WITH_MUTEX( &dutil->kpMutex );
KPState* state = loadStateLocked( dutil, xwe ); KPState* state = loadStateLocked( dutil, xwe );
#ifdef DEBUG #ifdef DEBUG

View file

@ -291,7 +291,7 @@ static void writeProto( const ServerCtxt* server, XWStreamCtxt* stream,
XW_Proto proto ); XW_Proto proto );
static void readGuestAddrs( ServerCtxt* server, XWStreamCtxt* stream, static void readGuestAddrs( ServerCtxt* server, XWStreamCtxt* stream,
XP_U8 streamVersion ); XP_U8 streamVersion );
static XP_Bool getRematchInfoImpl( const ServerCtxt* server, static XP_Bool getRematchInfoImpl( const ServerCtxt* server, XWEnv xwe,
CurGameInfo* newGI, const NewOrder* nop, CurGameInfo* newGI, const NewOrder* nop,
RematchInfo** ripp ); RematchInfo** ripp );
@ -299,8 +299,8 @@ static void ri_fromStream( RematchInfo* rip, XWStreamCtxt* stream,
const ServerCtxt* server ); const ServerCtxt* server );
static void ri_toStream( XWStreamCtxt* stream, const RematchInfo* rip, static void ri_toStream( XWStreamCtxt* stream, const RematchInfo* rip,
const ServerCtxt* server ); const ServerCtxt* server );
static void ri_addAddrAt( RematchInfo* rip, const CommsAddrRec* addr, static void ri_addAddrAt( XW_DUtilCtxt* dutil, XWEnv xwe, RematchInfo* rip,
XP_U16 playerIndex ); const CommsAddrRec* addr, XP_U16 playerIndex );
static void ri_addHostAddrs( RematchInfo* rip, const ServerCtxt* server ); static void ri_addHostAddrs( RematchInfo* rip, const ServerCtxt* server );
static void ri_addLocal( RematchInfo* rip ); static void ri_addLocal( RematchInfo* rip );
@ -888,7 +888,7 @@ readMQTTDevID( ServerCtxt* server, XWStreamCtxt* stream )
address, which the guest knows already, add an empty address as a address, which the guest knows already, add an empty address as a
placeholder. Guest will replace it if needed. */ placeholder. Guest will replace it if needed. */
static void static void
buildGuestRI( const ServerCtxt* server, XP_U16 guestIndex, RematchInfo* rip ) buildGuestRI( const ServerCtxt* server, XWEnv xwe, XP_U16 guestIndex, RematchInfo* rip )
{ {
XP_MEMSET( rip, 0, sizeof(*rip) ); XP_MEMSET( rip, 0, sizeof(*rip) );
@ -897,7 +897,7 @@ buildGuestRI( const ServerCtxt* server, XP_U16 guestIndex, RematchInfo* rip )
const LocalPlayer* lp = &gi->players[ii]; const LocalPlayer* lp = &gi->players[ii];
if ( lp->isLocal ) { /* that's me, the host */ if ( lp->isLocal ) { /* that's me, the host */
CommsAddrRec addr = {}; CommsAddrRec addr = {};
ri_addAddrAt( rip, &addr, ii ); ri_addAddrAt( server->vol.dutil, xwe, rip, &addr, ii );
} else { } else {
XP_S8 deviceIndex = server->srvPlyrs[ii].deviceIndex; XP_S8 deviceIndex = server->srvPlyrs[ii].deviceIndex;
if ( guestIndex == deviceIndex ) { if ( guestIndex == deviceIndex ) {
@ -907,7 +907,7 @@ buildGuestRI( const ServerCtxt* server, XP_U16 guestIndex, RematchInfo* rip )
= server->nv.addresses[deviceIndex].channelNo; = server->nv.addresses[deviceIndex].channelNo;
CommsAddrRec addr; CommsAddrRec addr;
comms_getChannelAddr( server->vol.comms, channelNo, &addr ); comms_getChannelAddr( server->vol.comms, channelNo, &addr );
ri_addAddrAt( rip, &addr, ii ); ri_addAddrAt( server->vol.dutil, xwe, rip, &addr, ii );
} }
} }
} }
@ -933,7 +933,8 @@ loadRemoteRI( const ServerCtxt* server, const CurGameInfo* XP_UNUSED_DBG(gi),
} }
static void static void
addGuestAddrsIf( const ServerCtxt* server, XP_U16 sendee, XWStreamCtxt* stream ) addGuestAddrsIf( const ServerCtxt* server, XWEnv xwe, XP_U16 sendee,
XWStreamCtxt* stream )
{ {
SRVR_LOGFF("(sendee: %d)", sendee ); SRVR_LOGFF("(sendee: %d)", sendee );
XP_ASSERT( amHost( server ) ); XP_ASSERT( amHost( server ) );
@ -947,7 +948,7 @@ addGuestAddrsIf( const ServerCtxt* server, XP_U16 sendee, XWStreamCtxt* stream )
if ( STREAM_VERS_REMATCHORDER <= version ) { if ( STREAM_VERS_REMATCHORDER <= version ) {
RematchInfo ri; RematchInfo ri;
buildGuestRI( server, sendee, &ri ); buildGuestRI( server, xwe, sendee, &ri );
ri_toStream( tmpStream, &ri, server ); ri_toStream( tmpStream, &ri, server );
/* Old verion requires no two-player devices */ /* Old verion requires no two-player devices */
@ -1066,7 +1067,7 @@ server_initClientConnection( ServerCtxt* server, XWEnv xwe )
#endif #endif
stream_destroy( stream ); stream_destroy( stream );
} else { } else {
SRVR_LOGFF( "wierd state: %s (expected XWSTATE_NONE); dropping message", SRVR_LOGFF( "wierd state: %s (expected XWSTATE_NONE); doing nothing",
getStateStr(server->nv.gameState) ); getStateStr(server->nv.gameState) );
} }
SRVR_LOGFF( "=> %s", boolToStr(result) ); SRVR_LOGFF( "=> %s", boolToStr(result) );
@ -2123,7 +2124,7 @@ findFirstPending( ServerCtxt* server, ServerPlayer** spp,
} /* findFirstPending */ } /* findFirstPending */
static XP_Bool static XP_Bool
findOrderedSlot( ServerCtxt* server, XWStreamCtxt* stream, findOrderedSlot( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream,
ServerPlayer** spp, LocalPlayer** lpp ) ServerPlayer** spp, LocalPlayer** lpp )
{ {
LOG_FUNC(); LOG_FUNC();
@ -2148,7 +2149,8 @@ findOrderedSlot( ServerCtxt* server, XWStreamCtxt* stream,
SRVR_LOGFFV( "ii: %d; deviceIndex: %d", ii, sp->deviceIndex ); SRVR_LOGFFV( "ii: %d; deviceIndex: %d", ii, sp->deviceIndex );
if ( UNKNOWN_DEVICE == sp->deviceIndex ) { if ( UNKNOWN_DEVICE == sp->deviceIndex ) {
int addrIndx = rip->addrIndices[ii]; int addrIndx = rip->addrIndices[ii];
if ( addrsAreSame( &guestAddr, &rip->addrs[addrIndx] ) ) { if ( addrsAreSame( server->vol.dutil, xwe, &guestAddr,
&rip->addrs[addrIndx] ) ) {
*spp = sp; *spp = sp;
*lpp = &gi->players[ii]; *lpp = &gi->players[ii];
XP_ASSERT( !(*lpp)->isLocal ); XP_ASSERT( !(*lpp)->isLocal );
@ -2175,7 +2177,7 @@ registerRemotePlayer( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream )
LocalPlayer* lp; LocalPlayer* lp;
XP_Bool success; XP_Bool success;
if ( server_isFromRematch( server ) ) { if ( server_isFromRematch( server ) ) {
success = findOrderedSlot( server, stream, &sp, &lp ); success = findOrderedSlot( server, xwe, stream, &sp, &lp );
} else { } else {
success = findFirstPending( server, &sp, &lp ); success = findFirstPending( server, &sp, &lp );
} }
@ -2454,7 +2456,7 @@ sendInitialMessage( ServerCtxt* server, XWEnv xwe )
} }
addMQTTDevIDIf( server, xwe, stream ); addMQTTDevIDIf( server, xwe, stream );
addGuestAddrsIf( server, deviceIndex, stream ); addGuestAddrsIf( server, xwe, deviceIndex, stream );
stream_destroy( stream ); stream_destroy( stream );
} }
@ -4273,7 +4275,7 @@ setPlayerOrder( const ServerCtxt* XP_UNUSED_DBG(server), const NewOrder* nop,
} /* setPlayerOrder */ } /* setPlayerOrder */
XP_Bool XP_Bool
server_getRematchInfo( const ServerCtxt* server, XW_UtilCtxt* newUtil, server_getRematchInfo( const ServerCtxt* server, XWEnv xwe, XW_UtilCtxt* newUtil,
XP_U32 gameID, const NewOrder* nop, RematchInfo** ripp ) XP_U32 gameID, const NewOrder* nop, RematchInfo** ripp )
{ {
XP_Bool success = server_canRematch( server, NULL ); XP_Bool success = server_canRematch( server, NULL );
@ -4289,13 +4291,13 @@ server_getRematchInfo( const ServerCtxt* server, XW_UtilCtxt* newUtil,
} }
LOGGI( newUtil->gameInfo, "ready to invite" ); LOGGI( newUtil->gameInfo, "ready to invite" );
success = getRematchInfoImpl( server, newGI, nop, ripp ); success = getRematchInfoImpl( server, xwe, newGI, nop, ripp );
} }
return success; return success;
} }
static XP_Bool static XP_Bool
getRematchInfoImpl( const ServerCtxt* server, CurGameInfo* newGI, getRematchInfoImpl( const ServerCtxt* server, XWEnv xwe, CurGameInfo* newGI,
const NewOrder* nop, RematchInfo** ripp ) const NewOrder* nop, RematchInfo** ripp )
{ {
XP_Bool success = XP_TRUE; XP_Bool success = XP_TRUE;
@ -4323,7 +4325,7 @@ getRematchInfoImpl( const ServerCtxt* server, CurGameInfo* newGI,
} else { } else {
comms_getHostAddr( comms, &addr ); comms_getHostAddr( comms, &addr );
} }
ri_addAddrAt( &ri, &addr, ii ); ri_addAddrAt( server->vol.dutil, xwe, &ri, &addr, ii );
} }
} }
} else if ( !!server->nv.rematch.addrs ) { } else if ( !!server->nv.rematch.addrs ) {
@ -4361,7 +4363,7 @@ getRematchInfoImpl( const ServerCtxt* server, CurGameInfo* newGI,
if ( newGI->players[ii].isLocal ) { if ( newGI->players[ii].isLocal ) {
ri_addLocal( &ri ); ri_addLocal( &ri );
} else if ( nextRemote < nAddrs ) { } else if ( nextRemote < nAddrs ) {
ri_addAddrAt( &ri, &addrs[nextRemote++], ii ); ri_addAddrAt( server->vol.dutil, xwe, &ri, &addrs[nextRemote++], ii );
} else { } else {
SRVR_LOGFF( "ERROR: not enough addresses for all" SRVR_LOGFF( "ERROR: not enough addresses for all"
" remote players" ); " remote players" );
@ -4499,7 +4501,7 @@ server_gatherPlayers( ServerCtxt* server, XWEnv xwe, XP_U32 created )
CurGameInfo tmpGi = *gi; CurGameInfo tmpGi = *gi;
RematchInfo* ripp; RematchInfo* ripp;
if ( getRematchInfoImpl( server, &tmpGi, &no, &ripp ) ) { if ( getRematchInfoImpl( server, xwe, &tmpGi, &no, &ripp ) ) {
for ( int ii = 0, nRemotes = 0; ii < gi->nPlayers; ++ii ) { for ( int ii = 0, nRemotes = 0; ii < gi->nPlayers; ++ii ) {
const LocalPlayer* lp = &gi->players[ii]; const LocalPlayer* lp = &gi->players[ii];
/* order unchanged? */ /* order unchanged? */
@ -4601,13 +4603,14 @@ ri_fromStream( RematchInfo* rip, XWStreamCtxt* stream,
/* Given an address, insert it if it's new, or point to an existing copy /* Given an address, insert it if it's new, or point to an existing copy
otherwise */ otherwise */
static void static void
ri_addAddrAt( RematchInfo* rip, const CommsAddrRec* addr, const XP_U16 player ) ri_addAddrAt( XW_DUtilCtxt* dutil, XWEnv xwe, RematchInfo* rip,
const CommsAddrRec* addr, const XP_U16 player )
{ {
XP_S8 newIndex = RIP_LOCAL_INDX; XP_S8 newIndex = RIP_LOCAL_INDX;
for ( int ii = 0; ii < player; ++ii ) { for ( int ii = 0; ii < player; ++ii ) {
int index = rip->addrIndices[ii]; int index = rip->addrIndices[ii];
if ( index != RIP_LOCAL_INDX && if ( index != RIP_LOCAL_INDX &&
addrsAreSame( addr, &rip->addrs[index] ) ) { addrsAreSame( dutil, xwe, addr, &rip->addrs[index] ) ) {
newIndex = index; newIndex = index;
break; break;
} }

View file

@ -186,7 +186,7 @@ void server_figureOrder( const ServerCtxt* server, RematchOrder ro,
addresses to which invitation should be sent. But: meant to be called addresses to which invitation should be sent. But: meant to be called
only from game.c anyway. only from game.c anyway.
*/ */
XP_Bool server_getRematchInfo( const ServerCtxt* server, XW_UtilCtxt* newUtil, XP_Bool server_getRematchInfo( const ServerCtxt* server, XWEnv xwe, XW_UtilCtxt* newUtil,
XP_U32 gameID, const NewOrder* nop, RematchInfo** ripp ); XP_U32 gameID, const NewOrder* nop, RematchInfo** ripp );
void server_disposeRematchInfo( ServerCtxt* server, RematchInfo** rip ); void server_disposeRematchInfo( ServerCtxt* server, RematchInfo** rip );
XP_Bool server_ri_getAddr( const RematchInfo* ri, XP_U16 nth, XP_Bool server_ri_getAddr( const RematchInfo* ri, XP_U16 nth,