mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-01 19:57:11 +01:00
always send from a local player
Seeing assertion failures with >2 dev games. I think the selPlayer variable doesn't always point at a local player, so don't use it.
This commit is contained in:
parent
32760c8570
commit
d446d3d463
3 changed files with 15 additions and 7 deletions
|
@ -93,6 +93,8 @@ static void dictChanged( void* p_board, XWEnv xwe, XP_S16 playerNum,
|
||||||
const DictionaryCtxt* newDict );
|
const DictionaryCtxt* newDict );
|
||||||
|
|
||||||
static void boardTurnChanged( XWEnv xwe, void* closure );
|
static void boardTurnChanged( XWEnv xwe, void* closure );
|
||||||
|
static XP_S16 chooseBestSelPlayer( const BoardCtxt* board );
|
||||||
|
|
||||||
static void boardGameOver( XWEnv xwe, void* closure, XP_S16 quitter );
|
static void boardGameOver( XWEnv xwe, void* closure, XP_S16 quitter );
|
||||||
static void setArrow( BoardCtxt* board, XWEnv xwe, XP_U16 row,
|
static void setArrow( BoardCtxt* board, XWEnv xwe, XP_U16 row,
|
||||||
XP_U16 col, XP_Bool* vp );
|
XP_U16 col, XP_Bool* vp );
|
||||||
|
@ -893,7 +895,8 @@ board_canHint( const BoardCtxt* board )
|
||||||
void
|
void
|
||||||
board_sendChat( const BoardCtxt* board, XWEnv xwe, const XP_UCHAR* msg )
|
board_sendChat( const BoardCtxt* board, XWEnv xwe, const XP_UCHAR* msg )
|
||||||
{
|
{
|
||||||
server_sendChat( board->server, xwe, msg, board->selPlayer );
|
XP_S16 turn = chooseBestSelPlayer( board );
|
||||||
|
server_sendChat( board->server, xwe, msg, turn );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1877,7 +1880,7 @@ board_hideTray( BoardCtxt* board, XWEnv xwe )
|
||||||
} /* board_hideTray */
|
} /* board_hideTray */
|
||||||
|
|
||||||
static XP_S16
|
static XP_S16
|
||||||
chooseBestSelPlayer( BoardCtxt* board )
|
chooseBestSelPlayer( const BoardCtxt* board )
|
||||||
{
|
{
|
||||||
ServerCtxt* server = board->server;
|
ServerCtxt* server = board->server;
|
||||||
|
|
||||||
|
|
|
@ -1090,6 +1090,7 @@ sendChatToClientsExcept( ServerCtxt* server, XWEnv xwe, XP_U16 skip,
|
||||||
void
|
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 from )
|
||||||
{
|
{
|
||||||
|
XP_ASSERT( -1 == from || server->vol.gi->players[from].isLocal );
|
||||||
XP_U32 timestamp = dutil_getCurSeconds( server->vol.dutil, xwe );
|
XP_U32 timestamp = dutil_getCurSeconds( server->vol.dutil, xwe );
|
||||||
if ( server->vol.gi->serverRole == SERVER_ISCLIENT ) {
|
if ( server->vol.gi->serverRole == SERVER_ISCLIENT ) {
|
||||||
sendChatTo( server, xwe, HOST_DEVICE, msg, from, timestamp );
|
sendChatTo( server, xwe, HOST_DEVICE, msg, from, timestamp );
|
||||||
|
@ -1102,8 +1103,12 @@ static XP_Bool
|
||||||
receiveChat( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* incoming )
|
receiveChat( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* incoming )
|
||||||
{
|
{
|
||||||
XP_UCHAR* msg = stringFromStream( server->mpool, incoming );
|
XP_UCHAR* msg = stringFromStream( server->mpool, incoming );
|
||||||
XP_S16 from = 1 <= stream_getSize( incoming )
|
XP_S16 from = -1;
|
||||||
? stream_getU8( incoming ) : -1;
|
if ( 1 <= stream_getSize( incoming ) ) {
|
||||||
|
from = stream_getU8( incoming );
|
||||||
|
XP_ASSERT( !server->vol.gi->players[from].isLocal );
|
||||||
|
}
|
||||||
|
|
||||||
XP_U32 timestamp = sizeof(timestamp) <= stream_getSize( incoming )
|
XP_U32 timestamp = sizeof(timestamp) <= stream_getSize( incoming )
|
||||||
? stream_getU32( incoming ) : 0;
|
? stream_getU32( incoming ) : 0;
|
||||||
if ( amHost( server ) ) {
|
if ( amHost( server ) ) {
|
||||||
|
|
|
@ -280,7 +280,7 @@ class Device():
|
||||||
if gids:
|
if gids:
|
||||||
random.shuffle(gids)
|
random.shuffle(gids)
|
||||||
gid = gids[0]
|
gid = gids[0]
|
||||||
response = self._sendWaitReply('sendChat', gid=gid, msg=Device.nextChatMsg())
|
response = self._sendWaitReply('sendChat', gid=gid, msg=Device.nextChatMsg(self.host))
|
||||||
success = response.get('success', False)
|
success = response.get('success', False)
|
||||||
return success
|
return success
|
||||||
|
|
||||||
|
@ -633,9 +633,9 @@ class Device():
|
||||||
self._launchProc()
|
self._launchProc()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def nextChatMsg():
|
def nextChatMsg(sender):
|
||||||
Device._nextChatID += 1
|
Device._nextChatID += 1
|
||||||
return 'Chat msg {}'.format(Device._nextChatID)
|
return 'chat msg {}: Hi, this is {}'.format(Device._nextChatID, sender)
|
||||||
|
|
||||||
def openOnExit(args):
|
def openOnExit(args):
|
||||||
devs = Device.getAll()
|
devs = Device.getAll()
|
||||||
|
|
Loading…
Add table
Reference in a new issue