mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
fix assertion chatting when remote player selected
This commit is contained in:
parent
6d17d0636e
commit
f3c7fcffd3
2 changed files with 23 additions and 6 deletions
|
@ -895,8 +895,7 @@ board_canHint( const BoardCtxt* board )
|
|||
void
|
||||
board_sendChat( const BoardCtxt* board, XWEnv xwe, const XP_UCHAR* msg )
|
||||
{
|
||||
XP_S16 turn = chooseBestSelPlayer( board );
|
||||
server_sendChat( board->server, xwe, msg, turn );
|
||||
server_sendChat( board->server, xwe, msg, board->selPlayer );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1088,14 +1088,32 @@ sendChatToClientsExcept( ServerCtxt* server, XWEnv xwe, XP_U16 skip,
|
|||
}
|
||||
|
||||
void
|
||||
server_sendChat( ServerCtxt* server, XWEnv xwe, const XP_UCHAR* msg, XP_S16 from )
|
||||
server_sendChat( ServerCtxt* server, XWEnv xwe, const XP_UCHAR* msg,
|
||||
XP_S16 fromHint )
|
||||
{
|
||||
XP_ASSERT( -1 == from || server->vol.gi->players[from].isLocal );
|
||||
/* The player sending must be local. Caller (likely board) tells us what
|
||||
player is selected, which is who the sender should be IFF it's a local
|
||||
player, but once the game's over it might not be. */
|
||||
const CurGameInfo* gi = server->vol.gi;
|
||||
if ( fromHint < 0 || gi->nPlayers <= fromHint ) {
|
||||
fromHint = 0;
|
||||
}
|
||||
if ( ! gi->players[fromHint].isLocal ) {
|
||||
for ( int ii = 0; ii < gi->nPlayers; ++ii ) {
|
||||
if ( gi->players[ii].isLocal ) {
|
||||
fromHint = ii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XP_ASSERT( server->vol.gi->players[fromHint].isLocal );
|
||||
XP_U32 timestamp = dutil_getCurSeconds( server->vol.dutil, xwe );
|
||||
if ( server->vol.gi->serverRole == SERVER_ISCLIENT ) {
|
||||
sendChatTo( server, xwe, HOST_DEVICE, msg, from, timestamp );
|
||||
sendChatTo( server, xwe, HOST_DEVICE, msg, fromHint, timestamp );
|
||||
} else {
|
||||
sendChatToClientsExcept( server, xwe, HOST_DEVICE, msg, from, timestamp );
|
||||
sendChatToClientsExcept( server, xwe, HOST_DEVICE, msg, fromHint,
|
||||
timestamp );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue