From c202cd8608e8ae7dafb6db14e585aecf34f6031c Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 1 Jul 2013 07:51:38 -0700 Subject: [PATCH] don't pile on chat messages when relay isn't even connected: it's an unfair test that doesn't duplicate what users will likely do. --- xwords4/linux/cursesmain.c | 13 ++++++------- xwords4/linux/cursesmain.h | 1 + xwords4/linux/linuxmain.c | 2 -- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/xwords4/linux/cursesmain.c b/xwords4/linux/cursesmain.c index bd8f0ffdf..2614dd0e7 100644 --- a/xwords4/linux/cursesmain.c +++ b/xwords4/linux/cursesmain.c @@ -1661,9 +1661,10 @@ relay_sendNoConn_curses( const XP_U8* msg, XP_U16 len, } /* relay_sendNoConn_curses */ static void -relay_status_curses( void* XP_UNUSED(closure), - CommsRelayState XP_UNUSED_DBG(state) ) +relay_status_curses( void* closure, CommsRelayState state ) { + CursesAppGlobals* globals = (CursesAppGlobals*)closure; + globals->commsRelayState = state; XP_LOGF( "%s got status: %s", __func__, CommsRelayState2Str(state) ); } @@ -1720,22 +1721,20 @@ chatsTimerFired( gpointer data ) { CursesAppGlobals* globals = (CursesAppGlobals*)data; - GameStateInfo gsi; - game_getState( &globals->cGlobals.game, &gsi ); - - if ( gsi.gameIsConnected ) { + if ( COMMS_RELAYSTATE_ALLCONNECTED == globals->commsRelayState ) { XP_UCHAR msg[128]; struct tm* timp; struct timeval tv; struct timezone tz; + XP_LOGF( "%s: sending \"%s\"", __func__, msg ); + gettimeofday( &tv, &tz ); timp = localtime( &tv.tv_sec ); snprintf( msg, sizeof(msg), "Saying hi via chat at %.2d:%.2d:%.2d", timp->tm_hour, timp->tm_min, timp->tm_sec ); server_sendChat( globals->cGlobals.game.server, msg ); - XP_LOGF( "%s: sent \"%s\"", __func__, msg ); } return TRUE; diff --git a/xwords4/linux/cursesmain.h b/xwords4/linux/cursesmain.h index f9dd34cd6..99f771730 100644 --- a/xwords4/linux/cursesmain.h +++ b/xwords4/linux/cursesmain.h @@ -81,6 +81,7 @@ struct CursesAppGlobals { short statusLine; XWGameState state; + CommsRelayState commsRelayState; struct sockaddr_in listenerSockAddr; #ifdef USE_GLIBLOOP diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index 53288984e..aa1f6e868 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -48,8 +48,6 @@ # include #endif -/* #include */ - #include "linuxmain.h" #include "linuxutl.h" #include "linuxbt.h"