mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
drop duplicate packet rather than asserting
This commit is contained in:
parent
51850ad019
commit
8fa5e3e4bd
1 changed files with 37 additions and 27 deletions
|
@ -706,6 +706,10 @@ handleRegistrationMsg( ServerCtxt* server, XWStreamCtxt* stream )
|
|||
#endif
|
||||
for ( ; ii < playersInMsg; ++ii ) {
|
||||
clientIndex = registerRemotePlayer( server, stream );
|
||||
if ( -1 == clientIndex ) {
|
||||
success = XP_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* This is abusing the semantics of turn change -- at least in the
|
||||
case where there is another device yet to register -- but we
|
||||
|
@ -1133,15 +1137,19 @@ findFirstPending( ServerCtxt* server, ServerPlayer** playerP )
|
|||
}
|
||||
}
|
||||
}
|
||||
XP_ASSERT( lp >= gi->players ); /* did we find a slot? */
|
||||
if ( lp < gi->players ) { /* did we find a slot? */
|
||||
XP_LOGF( "%s: no slot found for player; duplicate packet?", __func__ );
|
||||
lp = NULL;
|
||||
} else {
|
||||
*playerP = server->players + nPlayers;
|
||||
}
|
||||
return lp;
|
||||
} /* findFirstPending */
|
||||
|
||||
static XP_S8
|
||||
registerRemotePlayer( ServerCtxt* server, XWStreamCtxt* stream )
|
||||
{
|
||||
XP_S8 deviceIndex;
|
||||
XP_S8 deviceIndex = -1;
|
||||
XP_PlayerAddr channelNo;
|
||||
XP_UCHAR* name;
|
||||
XP_U16 nameLen;
|
||||
|
@ -1154,6 +1162,7 @@ registerRemotePlayer( ServerCtxt* server, XWStreamCtxt* stream )
|
|||
|
||||
/* find the slot to use */
|
||||
lp = findFirstPending( server, &player );
|
||||
if ( NULL != lp ) {
|
||||
|
||||
/* get data from stream */
|
||||
lp->robotIQ = 1 == stream_getBits( stream, 1 )? 1 : 0;
|
||||
|
@ -1188,6 +1197,7 @@ registerRemotePlayer( ServerCtxt* server, XWStreamCtxt* stream )
|
|||
}
|
||||
|
||||
player->deviceIndex = deviceIndex;
|
||||
}
|
||||
return deviceIndex;
|
||||
} /* registerRemotePlayer */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue