mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
test for duplicate initial client message and if so drop it; add const keyword; add assertion in addr comparion in attempt to learn why duplicates are getting through.
This commit is contained in:
parent
4074417b33
commit
40f7295802
4 changed files with 110 additions and 99 deletions
|
@ -1014,9 +1014,13 @@ preProcess( CommsCtxt* comms, XWStreamCtxt* stream,
|
||||||
static AddressRecord*
|
static AddressRecord*
|
||||||
addrToRecord( CommsCtxt* comms, const CommsAddrRec* addr )
|
addrToRecord( CommsCtxt* comms, const CommsAddrRec* addr )
|
||||||
{
|
{
|
||||||
CommsConnType conType = addr->conType;
|
CommsConnType conType;
|
||||||
AddressRecord* rec;
|
AddressRecord* rec;
|
||||||
XP_Bool matched = XP_FALSE;
|
XP_Bool matched = XP_FALSE;
|
||||||
|
|
||||||
|
XP_ASSERT( !!addr );
|
||||||
|
|
||||||
|
conType = addr->conType;
|
||||||
for ( rec = comms->recs; !!rec; rec = rec->next ) {
|
for ( rec = comms->recs; !!rec; rec = rec->next ) {
|
||||||
XP_ASSERT( conType == rec->addr.conType );
|
XP_ASSERT( conType == rec->addr.conType );
|
||||||
switch( conType ) {
|
switch( conType ) {
|
||||||
|
@ -1039,7 +1043,9 @@ addrToRecord( CommsCtxt* comms, const CommsAddrRec* addr )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COMMS_CONN_IR: /* no way to test */
|
case COMMS_CONN_IR: /* no way to test */
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
|
XP_ASSERT(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( matched ) {
|
if ( matched ) {
|
||||||
|
|
|
@ -315,10 +315,10 @@ gi_disposePlayerInfo( MPFORMAL CurGameInfo* gi )
|
||||||
} /* gi_disposePlayerInfo */
|
} /* gi_disposePlayerInfo */
|
||||||
|
|
||||||
void
|
void
|
||||||
gi_copy( MPFORMAL CurGameInfo* destGI, CurGameInfo* srcGI )
|
gi_copy( MPFORMAL CurGameInfo* destGI, const CurGameInfo* srcGI )
|
||||||
{
|
{
|
||||||
XP_U16 nPlayers, i;
|
XP_U16 nPlayers, i;
|
||||||
LocalPlayer* srcPl;
|
const LocalPlayer* srcPl;
|
||||||
LocalPlayer* destPl;
|
LocalPlayer* destPl;
|
||||||
|
|
||||||
replaceStringIfDifferent( mpool, &destGI->dictName,
|
replaceStringIfDifferent( mpool, &destGI->dictName,
|
||||||
|
|
|
@ -99,7 +99,7 @@ void gi_initPlayerInfo( MPFORMAL CurGameInfo* gi,
|
||||||
void gi_disposePlayerInfo( MPFORMAL CurGameInfo* gi );
|
void gi_disposePlayerInfo( MPFORMAL CurGameInfo* gi );
|
||||||
void gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi );
|
void gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi );
|
||||||
void gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi );
|
void gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi );
|
||||||
void gi_copy( MPFORMAL CurGameInfo* destGI, CurGameInfo* srcGi );
|
void gi_copy( MPFORMAL CurGameInfo* destGI, const CurGameInfo* srcGi );
|
||||||
XP_U16 gi_countLocalHumans( const CurGameInfo* gi );
|
XP_U16 gi_countLocalHumans( const CurGameInfo* gi );
|
||||||
|
|
||||||
XP_Bool player_hasPasswd( LocalPlayer* player );
|
XP_Bool player_hasPasswd( LocalPlayer* player );
|
||||||
|
|
|
@ -940,6 +940,12 @@ clearLocalRobots( ServerCtxt* server )
|
||||||
static XP_Bool
|
static XP_Bool
|
||||||
client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream )
|
client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream )
|
||||||
{
|
{
|
||||||
|
XP_Bool accepted = 0 == server->nv.addresses[0].channelNo;
|
||||||
|
|
||||||
|
/* We should never get this message a second time, but very rarely we do.
|
||||||
|
Drop it in that case. */
|
||||||
|
XP_ASSERT( accepted );
|
||||||
|
if ( accepted ) {
|
||||||
DictionaryCtxt* newDict;
|
DictionaryCtxt* newDict;
|
||||||
DictionaryCtxt* curDict;
|
DictionaryCtxt* curDict;
|
||||||
XP_U16 nPlayers, nCols;
|
XP_U16 nPlayers, nCols;
|
||||||
|
@ -980,7 +986,6 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream )
|
||||||
|
|
||||||
channelNo = stream_getAddress( stream );
|
channelNo = stream_getAddress( stream );
|
||||||
XP_ASSERT( channelNo != 0 );
|
XP_ASSERT( channelNo != 0 );
|
||||||
XP_ASSERT( server->nv.addresses[0].channelNo == 0 );
|
|
||||||
server->nv.addresses[0].channelNo = channelNo;
|
server->nv.addresses[0].channelNo = channelNo;
|
||||||
|
|
||||||
/* PENDING init's a bit harsh for setting the size */
|
/* PENDING init's a bit harsh for setting the size */
|
||||||
|
@ -1035,8 +1040,8 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream )
|
||||||
/* Give board a chance to redraw self with the full compliment of known
|
/* Give board a chance to redraw self with the full compliment of known
|
||||||
players */
|
players */
|
||||||
setTurn( server, 0 );
|
setTurn( server, 0 );
|
||||||
|
}
|
||||||
return XP_TRUE;
|
return accepted;
|
||||||
} /* client_readInitialMessage */
|
} /* client_readInitialMessage */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue