mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-27 07:58:49 +01:00
Merge remote-tracking branch 'origin/android_branch' into android_branch
This commit is contained in:
commit
a8f49ad94b
4 changed files with 26 additions and 13 deletions
|
@ -287,7 +287,9 @@ static void
|
|||
init_relay( CommsCtxt* comms, XP_U16 nPlayersHere, XP_U16 nPlayersTotal )
|
||||
{
|
||||
comms->r.myHostID = comms->isServer? HOST_ID_SERVER: HOST_ID_NONE;
|
||||
XP_LOGF( "%s: set hostid: %x", __func__, comms->r.myHostID );
|
||||
if ( HOST_ID_NONE != comms->r.myHostID ) {
|
||||
XP_LOGF( "%s: set hostid: %x", __func__, comms->r.myHostID );
|
||||
}
|
||||
set_relay_state( comms, COMMS_RELAYSTATE_UNCONNECTED );
|
||||
comms->r.nPlayersHere = nPlayersHere;
|
||||
comms->r.nPlayersTotal = nPlayersTotal;
|
||||
|
@ -953,6 +955,8 @@ static MsgQueueElem*
|
|||
makeElemWithID( CommsCtxt* comms, MsgID msgID, AddressRecord* rec,
|
||||
XP_PlayerAddr channelNo, XWStreamCtxt* stream )
|
||||
{
|
||||
XP_LOGF( "%s(channelNo=%x)", __func__, channelNo );
|
||||
// XP_ASSERT( 0 == (channelNo & CHANNEL_MASK) );
|
||||
XP_U16 headerLen;
|
||||
XP_U16 streamSize = NULL == stream? 0 : stream_getSize( stream );
|
||||
MsgID lastMsgSaved = (!!rec)? rec->lastMsgSaved : 0;
|
||||
|
@ -1634,7 +1638,7 @@ preProcess( CommsCtxt* comms, XWStreamCtxt* stream,
|
|||
|
||||
static AddressRecord*
|
||||
getRecordFor( CommsCtxt* comms, const CommsAddrRec* addr,
|
||||
XP_PlayerAddr channelNo, XP_Bool maskChannel )
|
||||
const XP_PlayerAddr channelNo, XP_Bool maskChannel )
|
||||
{
|
||||
CommsConnType conType;
|
||||
AddressRecord* rec;
|
||||
|
@ -1688,6 +1692,8 @@ getRecordFor( CommsCtxt* comms, const CommsAddrRec* addr,
|
|||
break;
|
||||
}
|
||||
}
|
||||
XP_LOGF( "%s(channelNo=%x, maskChannel=%s) => %p", __func__,
|
||||
channelNo, maskChannel? "true":"false", rec );
|
||||
return rec;
|
||||
} /* getRecordFor */
|
||||
|
||||
|
|
|
@ -1171,13 +1171,17 @@ registerRemotePlayer( ServerCtxt* server, XWStreamCtxt* stream )
|
|||
RemoteAddress* addr;
|
||||
addr = &server->nv.addresses[server->nv.nDevices];
|
||||
|
||||
deviceIndex = server->nv.nDevices++;
|
||||
|
||||
XP_ASSERT( channelNo != 0 );
|
||||
addr->channelNo = channelNo;
|
||||
XP_LOGF( "%s: set channelNo to %x for device %d", __func__,
|
||||
channelNo, server->nv.nDevices );
|
||||
|
||||
deviceIndex = server->nv.nDevices++;
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
addr->streamVersion = STREAM_SAVE_PREVWORDS;
|
||||
#endif
|
||||
} else {
|
||||
XP_LOGF( "%s: deviceIndex already set", __func__ );
|
||||
}
|
||||
|
||||
player->deviceIndex = deviceIndex;
|
||||
|
@ -1272,11 +1276,12 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream )
|
|||
channelNo = stream_getAddress( stream );
|
||||
XP_ASSERT( channelNo != 0 );
|
||||
server->nv.addresses[0].channelNo = channelNo;
|
||||
XP_LOGF( "%s: assigning channelNo %x for 0", __func__, channelNo );
|
||||
|
||||
model_setSize( model, nCols );
|
||||
|
||||
nPlayers = localGI.nPlayers;
|
||||
XP_STATUSF( "reading in %d players", localGI.nPlayers );
|
||||
XP_LOGF( "%s: reading in %d players", __func__, localGI.nPlayers );
|
||||
|
||||
gi_disposePlayerInfo( MPPARM(server->mpool) &localGI );
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- compile-command: "make -k -j3"; -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2010-2012 by Eric House (xwords@eehouse.org). All rights
|
||||
* Copyright 2010-2013 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -122,7 +122,9 @@ UdpQueue::handle( const AddrInfo* addr, QueueCallback cb )
|
|||
// First see if we've read the length bytes
|
||||
if ( packet->readSoFar() < sizeof( packet->m_len ) ) {
|
||||
if ( packet->readAtMost( sizeof(packet->m_len) - packet->readSoFar() ) ) {
|
||||
packet->m_len = ntohs(*(unsigned short*)packet->data());
|
||||
uint16_t tmp;
|
||||
memcpy( &tmp, packet->data(), sizeof(tmp) );
|
||||
packet->m_len = ntohs(tmp);
|
||||
success = 0 < packet->m_len;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,17 +71,17 @@ public:
|
|||
|
||||
class PartialPacket {
|
||||
public:
|
||||
PartialPacket(int sock) {
|
||||
m_sock = sock;
|
||||
m_len = 0;
|
||||
m_errno = 0;
|
||||
}
|
||||
PartialPacket(int sock)
|
||||
:m_len(0)
|
||||
,m_sock(sock)
|
||||
,m_errno(0)
|
||||
{}
|
||||
bool stillGood() const ;
|
||||
bool readAtMost( int len );
|
||||
size_t readSoFar() const { return m_buf.size(); }
|
||||
const uint8_t* data() const { return m_buf.data(); }
|
||||
|
||||
unsigned short m_len;
|
||||
unsigned short m_len; /* decoded via ntohs from the first 2 bytes */
|
||||
private:
|
||||
|
||||
vector<uint8_t> m_buf;
|
||||
|
|
Loading…
Add table
Reference in a new issue