diff --git a/xwords4/linux/cursesboard.c b/xwords4/linux/cursesboard.c index 6be2dc2a4..1066a48e4 100644 --- a/xwords4/linux/cursesboard.c +++ b/xwords4/linux/cursesboard.c @@ -729,7 +729,7 @@ cb_makeMoveIf( CursesBoardState* cbState, XP_U32 gameID ) success = board_canHint( board ); if ( success ) { XP_Bool ignored; - success = board_requestHint( cGlobals->game.board, NULL_XWE, + success = board_requestHint( board, NULL_XWE, #ifdef XWFEATURE_SEARCHLIMIT XP_FALSE, #endif @@ -745,6 +745,18 @@ cb_makeMoveIf( CursesBoardState* cbState, XP_U32 gameID ) return success; } +XP_Bool +cb_sendChat( CursesBoardState* cbState, XP_U32 gameID, const char* msg ) +{ + CursesBoardGlobals* bGlobals = + findOrOpenForGameID( cbState, gameID, NULL, NULL ); + XP_Bool success = !!bGlobals; + if ( success ) { + board_sendChat( bGlobals->cGlobals.game.board, NULL_XWE, msg ); + } + return success; +} + static void kill_board( gpointer data ) { diff --git a/xwords4/linux/cursesboard.h b/xwords4/linux/cursesboard.h index caa0f37db..a2022aa4f 100644 --- a/xwords4/linux/cursesboard.h +++ b/xwords4/linux/cursesboard.h @@ -56,6 +56,7 @@ void cb_addInvites( CursesBoardState* cbState, XP_U32 gameID, XP_U16 nRemotes, XP_Bool cb_makeRematch( CursesBoardState* cbState, XP_U32 gameID, RematchOrder ro, XP_U32* newGameID ); XP_Bool cb_makeMoveIf( CursesBoardState* cbState, XP_U32 gameID ); +XP_Bool cb_sendChat( CursesBoardState* cbState, XP_U32 gameID, const char* msg ); const CommonGlobals* cb_getForGameID( CursesBoardState* cbState, XP_U32 gameID ); diff --git a/xwords4/linux/cursesmain.c b/xwords4/linux/cursesmain.c index f621fdf17..c7bace993 100644 --- a/xwords4/linux/cursesmain.c +++ b/xwords4/linux/cursesmain.c @@ -1596,6 +1596,15 @@ moveifFromArgs( CursesAppGlobals* aGlobals, cJSON* args ) return cb_makeMoveIf( aGlobals->cbState, gameID ); } +static XP_Bool +chatFromArgs( CursesAppGlobals* aGlobals, cJSON* args ) +{ + XP_U32 gameID = gidFromObject( args ); + cJSON* tmp = cJSON_GetObjectItem( args, "msg" ); + const char* msg = tmp->valuestring; + return cb_sendChat( aGlobals->cbState, gameID, msg ); +} + /* Return 'gid' of new game */ static XP_U32 rematchFromArgs( CursesAppGlobals* aGlobals, cJSON* args ) @@ -1800,6 +1809,8 @@ on_incoming_signal( GSocketService* XP_UNUSED(service), } else if ( 0 == strcmp( cmdStr, "getPlayers" ) ) { cJSON* players = getPlayersForArgs( aGlobals, args ); addObjectToObject( &response, "players", players ); + } else if ( 0 == strcmp( cmdStr, "sendChat" ) ) { + success = chatFromArgs( aGlobals, args ); } else { success = XP_FALSE; XP_ASSERT(0);