drop duplicate packet rather than asserting

This commit is contained in:
Eric House 2013-09-11 07:30:12 -07:00
parent 51850ad019
commit 8fa5e3e4bd

View file

@ -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 */