mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
Merge remote-tracking branch 'origin/android_branch' into android_branch
This commit is contained in:
commit
cd2550a90d
8 changed files with 77 additions and 78 deletions
|
@ -785,9 +785,11 @@ comms_saveSucceeded( CommsCtxt* comms, XP_U16 saveToken )
|
|||
XP_LOGF( "%s(saveToken=%d)", __func__, saveToken );
|
||||
XP_ASSERT( !!comms );
|
||||
if ( saveToken == comms->lastSaveToken ) {
|
||||
XP_LOGF( "%s: lastSave matches", __func__ );
|
||||
AddressRecord* rec;
|
||||
for ( rec = comms->recs; !!rec; rec = rec->next ) {
|
||||
XP_LOGF( "%s: lastSave matches; updating lastMsgSaved %ld to "
|
||||
"lastMsgRcd %ld", __func__, rec->lastMsgSaved,
|
||||
rec->lastMsgRcd );
|
||||
rec->lastMsgSaved = rec->lastMsgRcd;
|
||||
}
|
||||
#ifdef XWFEATURE_COMMSACK
|
||||
|
@ -996,24 +998,28 @@ comms_getChannelSeed( CommsCtxt* comms )
|
|||
XP_S16
|
||||
comms_send( CommsCtxt* comms, XWStreamCtxt* stream )
|
||||
{
|
||||
XP_PlayerAddr channelNo = stream_getAddress( stream );
|
||||
XP_LOGF( "%s: channelNo=%x", __func__, channelNo );
|
||||
AddressRecord* rec = getRecordFor( comms, NULL, channelNo, XP_FALSE );
|
||||
MsgID msgID = (!!rec)? ++rec->nextMsgID : 0;
|
||||
MsgQueueElem* elem;
|
||||
XP_S16 result = -1;
|
||||
if ( 0 == stream_getSize(stream) ) {
|
||||
XP_LOGF( "%s: dropping 0-len message", __func__ );
|
||||
} else {
|
||||
XP_PlayerAddr channelNo = stream_getAddress( stream );
|
||||
XP_LOGF( "%s: channelNo=%x", __func__, channelNo );
|
||||
AddressRecord* rec = getRecordFor( comms, NULL, channelNo, XP_FALSE );
|
||||
MsgID msgID = (!!rec)? ++rec->nextMsgID : 0;
|
||||
MsgQueueElem* elem;
|
||||
|
||||
if ( 0 == channelNo ) {
|
||||
channelNo = comms_getChannelSeed(comms) & ~CHANNEL_MASK;
|
||||
}
|
||||
if ( 0 == channelNo ) {
|
||||
channelNo = comms_getChannelSeed(comms) & ~CHANNEL_MASK;
|
||||
}
|
||||
|
||||
XP_DEBUGF( "%s: assigning msgID=" XP_LD " on chnl %x", __func__,
|
||||
msgID, channelNo );
|
||||
XP_DEBUGF( "%s: assigning msgID=" XP_LD " on chnl %x", __func__,
|
||||
msgID, channelNo );
|
||||
|
||||
elem = makeElemWithID( comms, msgID, rec, channelNo, stream );
|
||||
if ( NULL != elem ) {
|
||||
addToQueue( comms, elem );
|
||||
result = sendMsg( comms, elem );
|
||||
elem = makeElemWithID( comms, msgID, rec, channelNo, stream );
|
||||
if ( NULL != elem ) {
|
||||
addToQueue( comms, elem );
|
||||
result = sendMsg( comms, elem );
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} /* comms_send */
|
||||
|
@ -1037,9 +1043,10 @@ addToQueue( CommsCtxt* comms, MsgQueueElem* newMsgElem )
|
|||
XP_ASSERT( comms->queueLen > 0 );
|
||||
}
|
||||
++comms->queueLen;
|
||||
XP_LOGF( "%s: queueLen now %d after channelNo: %d; msgID: " XP_LD,
|
||||
__func__, comms->queueLen,
|
||||
newMsgElem->channelNo & CHANNEL_MASK, newMsgElem->msgID );
|
||||
XP_LOGF( "%s: queueLen now %d after channelNo: %d; msgID: " XP_LD
|
||||
"; len: %d", __func__, comms->queueLen,
|
||||
newMsgElem->channelNo & CHANNEL_MASK, newMsgElem->msgID,
|
||||
newMsgElem->len );
|
||||
} /* addToQueue */
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -1244,14 +1251,25 @@ comms_resendAll( CommsCtxt* comms )
|
|||
void
|
||||
comms_ackAny( CommsCtxt* comms )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
XP_Bool noneSent = XP_TRUE;
|
||||
#endif
|
||||
AddressRecord* rec;
|
||||
for ( rec = comms->recs; !!rec; rec = rec->next ) {
|
||||
if ( rec->lastMsgAckd < rec->lastMsgRcd ) {
|
||||
XP_LOGF( "%s: %ld < %ld: rec needs ack", __func__,
|
||||
rec->lastMsgAckd, rec->lastMsgRcd );
|
||||
#ifdef DEBUG
|
||||
noneSent = XP_FALSE;
|
||||
#endif
|
||||
XP_LOGF( "%s: channel %x; %ld < %ld: rec needs ack", __func__,
|
||||
rec->channelNo, rec->lastMsgAckd, rec->lastMsgRcd );
|
||||
sendEmptyMsg( comms, rec );
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if ( noneSent ) {
|
||||
XP_LOGF( "%s: nothing to send", __func__ );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1845,7 +1863,7 @@ sendEmptyMsg( CommsCtxt* comms, AddressRecord* rec )
|
|||
0 /*rec? rec->lastMsgRcd : 0*/,
|
||||
rec,
|
||||
rec? rec->channelNo : 0, NULL );
|
||||
sendMsg( comms, elem );
|
||||
(void)sendMsg( comms, elem );
|
||||
freeElem( comms, elem );
|
||||
} /* sendEmptyMsg */
|
||||
#endif
|
||||
|
|
|
@ -147,7 +147,7 @@ stack_getHash( const StackCtxt* stack )
|
|||
stream_copyBits( stack->data, 0, stack->top, buf, &len );
|
||||
// LOG_HEX( buf, len, __func__ );
|
||||
hash = finishHash( augmentHash( 0L, buf, len ) );
|
||||
LOG_RETURNF( "%.8X", (unsigned int)hash );
|
||||
// LOG_RETURNF( "%.8X", (unsigned int)hash );
|
||||
return hash;
|
||||
} /* stack_getHash */
|
||||
#endif
|
||||
|
|
|
@ -111,6 +111,7 @@ DEFINES += -DXWFEATURE_HILITECELL
|
|||
# allow change dict inside running game
|
||||
DEFINES += -DXWFEATURE_CHANGEDICT
|
||||
DEFINES += -DXWFEATURE_DEVID
|
||||
DEFINES += -DXWFEATURE_COMMSACK
|
||||
|
||||
# MAX_ROWS controls STREAM_VERS_BIGBOARD and with it move hashing
|
||||
DEFINES += -DMAX_ROWS=32
|
||||
|
|
|
@ -474,6 +474,7 @@ onetime_idle( gpointer data )
|
|||
if ( !!globals->cGlobals.game.board ) {
|
||||
board_draw( globals->cGlobals.game.board );
|
||||
}
|
||||
saveGame( &globals->cGlobals );
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1219,7 +1220,7 @@ static XP_Bool
|
|||
blocking_gotEvent( CursesAppGlobals* globals, int* ch )
|
||||
{
|
||||
XP_Bool result = XP_FALSE;
|
||||
int numEvents;
|
||||
int numEvents, ii;
|
||||
short fdIndex;
|
||||
XP_Bool redraw = XP_FALSE;
|
||||
|
||||
|
@ -1334,12 +1335,15 @@ blocking_gotEvent( CursesAppGlobals* globals, int* ch )
|
|||
}
|
||||
}
|
||||
|
||||
redraw = server_do( globals->cGlobals.game.server, NULL ) || redraw;
|
||||
for ( ii = 0; ii < 5; ++ii ) {
|
||||
redraw = server_do( globals->cGlobals.game.server, NULL ) || redraw;
|
||||
}
|
||||
if ( redraw ) {
|
||||
/* messages change a lot */
|
||||
board_invalAll( globals->cGlobals.game.board );
|
||||
board_draw( globals->cGlobals.game.board );
|
||||
}
|
||||
saveGame( globals->cGlobals );
|
||||
}
|
||||
return result;
|
||||
} /* blocking_gotEvent */
|
||||
|
@ -1486,25 +1490,15 @@ curses_util_remSelected( XW_UtilCtxt* uc )
|
|||
}
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
static void
|
||||
cursesSendOnClose( XWStreamCtxt* stream, void* closure )
|
||||
{
|
||||
CursesAppGlobals* globals = (CursesAppGlobals*)closure;
|
||||
|
||||
XP_LOGF( "cursesSendOnClose called" );
|
||||
(void)comms_send( globals->cGlobals.game.comms, stream );
|
||||
} /* cursesSendOnClose */
|
||||
|
||||
static XWStreamCtxt*
|
||||
curses_util_makeStreamFromAddr(XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
|
||||
{
|
||||
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
|
||||
LaunchParams* params = globals->cGlobals.params;
|
||||
|
||||
XWStreamCtxt* stream = mem_stream_make( MPPARM(uc->mpool)
|
||||
params->vtMgr,
|
||||
uc->closure, channelNo,
|
||||
cursesSendOnClose );
|
||||
XWStreamCtxt* stream = mem_stream_make( MPPARM(uc->mpool) params->vtMgr,
|
||||
&globals->cGlobals, channelNo,
|
||||
sendOnClose );
|
||||
return stream;
|
||||
} /* curses_util_makeStreamFromAddr */
|
||||
#endif
|
||||
|
@ -1544,17 +1538,6 @@ setupCursesUtilCallbacks( CursesAppGlobals* globals, XW_UtilCtxt* util )
|
|||
util->closure = globals;
|
||||
} /* setupCursesUtilCallbacks */
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
static void
|
||||
sendOnClose( XWStreamCtxt* stream, void* closure )
|
||||
{
|
||||
CursesAppGlobals* globals = closure;
|
||||
XP_LOGF( "curses sendOnClose called" );
|
||||
XP_ASSERT( !!globals->cGlobals.game.comms );
|
||||
comms_send( globals->cGlobals.game.comms, stream );
|
||||
} /* sendOnClose */
|
||||
#endif
|
||||
|
||||
static CursesMenuHandler
|
||||
getHandlerForKey( const MenuList* list, char ch )
|
||||
{
|
||||
|
@ -1871,7 +1854,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
|
|||
server_initClientConnection( g_globals.cGlobals.game.server,
|
||||
mem_stream_make( MEMPOOL
|
||||
params->vtMgr,
|
||||
&g_globals,
|
||||
&g_globals.cGlobals,
|
||||
(XP_PlayerAddr)0,
|
||||
sendOnClose ) );
|
||||
} else {
|
||||
|
|
|
@ -65,9 +65,6 @@
|
|||
#include "filestream.h"
|
||||
|
||||
/* static guint gtkSetupClientSocket( GtkAppGlobals* globals, int sock ); */
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
static void sendOnCloseGTK( XWStreamCtxt* stream, void* closure );
|
||||
#endif
|
||||
static void setCtrlsForTray( GtkAppGlobals* globals );
|
||||
static void new_game( GtkWidget* widget, GtkAppGlobals* globals );
|
||||
static void new_game_impl( GtkAppGlobals* globals, XP_Bool fireConnDlg );
|
||||
|
@ -508,8 +505,8 @@ createOrLoadObjects( GtkAppGlobals* globals )
|
|||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
} else if ( !isServer ) {
|
||||
XWStreamCtxt* stream =
|
||||
mem_stream_make( MEMPOOL params->vtMgr, globals, CHANNEL_NONE,
|
||||
sendOnCloseGTK );
|
||||
mem_stream_make( MEMPOOL params->vtMgr, &globals->cGlobals, CHANNEL_NONE,
|
||||
sendOnClose );
|
||||
server_initClientConnection( globals->cGlobals.game.server,
|
||||
stream );
|
||||
#endif
|
||||
|
@ -814,11 +811,9 @@ new_game_impl( GtkAppGlobals* globals, XP_Bool fireConnDlg )
|
|||
|
||||
if ( isClient ) {
|
||||
XWStreamCtxt* stream =
|
||||
mem_stream_make( MEMPOOL
|
||||
globals->cGlobals.params->vtMgr,
|
||||
globals,
|
||||
CHANNEL_NONE,
|
||||
sendOnCloseGTK );
|
||||
mem_stream_make( MEMPOOL globals->cGlobals.params->vtMgr,
|
||||
&globals->cGlobals, CHANNEL_NONE,
|
||||
sendOnClose );
|
||||
server_initClientConnection( globals->cGlobals.game.server,
|
||||
stream );
|
||||
}
|
||||
|
@ -1747,8 +1742,8 @@ gtk_util_makeStreamFromAddr(XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
|
|||
|
||||
XWStreamCtxt* stream = mem_stream_make( MEMPOOL
|
||||
globals->cGlobals.params->vtMgr,
|
||||
uc->closure, channelNo,
|
||||
sendOnCloseGTK );
|
||||
&globals->cGlobals, channelNo,
|
||||
sendOnClose );
|
||||
return stream;
|
||||
} /* gtk_util_makeStreamFromAddr */
|
||||
|
||||
|
@ -2270,15 +2265,6 @@ gtk_socket_acceptor( int listener, Acceptor func, CommonGlobals* globals,
|
|||
}
|
||||
} /* gtk_socket_acceptor */
|
||||
|
||||
static void
|
||||
sendOnCloseGTK( XWStreamCtxt* stream, void* closure )
|
||||
{
|
||||
GtkAppGlobals* globals = closure;
|
||||
|
||||
XP_LOGF( "sendOnClose called" );
|
||||
(void)comms_send( globals->cGlobals.game.comms, stream );
|
||||
} /* sendOnClose */
|
||||
|
||||
static void
|
||||
drop_msg_toggle( GtkWidget* toggle, GtkAppGlobals* globals )
|
||||
{
|
||||
|
|
|
@ -196,6 +196,14 @@ catOnClose( XWStreamCtxt* stream, void* XP_UNUSED(closure) )
|
|||
free( buffer );
|
||||
} /* catOnClose */
|
||||
|
||||
void
|
||||
sendOnClose( XWStreamCtxt* stream, void* closure )
|
||||
{
|
||||
CommonGlobals* cGlobals = (CommonGlobals*)closure;
|
||||
XP_LOGF( "%s called with msg of len %d", __func__, stream_getSize(stream) );
|
||||
(void)comms_send( cGlobals->game.comms, stream );
|
||||
}
|
||||
|
||||
void
|
||||
catGameHistory( CommonGlobals* cGlobals )
|
||||
{
|
||||
|
|
|
@ -60,6 +60,8 @@ XP_UCHAR* strFromStream( XWStreamCtxt* stream );
|
|||
|
||||
void catGameHistory( CommonGlobals* cGlobals );
|
||||
void catOnClose( XWStreamCtxt* stream, void* closure );
|
||||
void sendOnClose( XWStreamCtxt* stream, void* closure );
|
||||
|
||||
void catFinalScores( const CommonGlobals* cGlobals, XP_S16 quitter );
|
||||
XP_Bool file_exists( const char* fileName );
|
||||
XWStreamCtxt* streamFromFile( CommonGlobals* cGlobals, char* name,
|
||||
|
|
|
@ -81,7 +81,9 @@ def notifyGCM( devids, typ ):
|
|||
for error, reg_ids in response.items():
|
||||
print error
|
||||
else:
|
||||
print 'no errors'
|
||||
print 'no errors',
|
||||
if g_debug: print ':', response
|
||||
else: print
|
||||
else:
|
||||
print "not sending to", len(devids), "devices because typ ==", typ
|
||||
|
||||
|
@ -176,15 +178,14 @@ def main():
|
|||
print "devices needing notification:", targets
|
||||
notifyGCM( asGCMIds( g_con, targets, typ ), typ )
|
||||
pruneSent( devids )
|
||||
else:
|
||||
if not g_debug:
|
||||
sys.stdout.write('.')
|
||||
sys.stdout.flush()
|
||||
emptyCount = emptyCount + 1
|
||||
if 0 == (emptyCount % LINE_LEN): print ""
|
||||
else:
|
||||
emptyCount += 1
|
||||
if not g_debug:
|
||||
sys.stdout.write('.')
|
||||
sys.stdout.flush()
|
||||
if 0 == (emptyCount % LINE_LEN): print ""
|
||||
if 0 == loopInterval: break
|
||||
time.sleep( loopInterval )
|
||||
if not g_debug: print
|
||||
|
||||
cleanup()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue