mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
Merge remote-tracking branch 'origin/android_branch' into local_fix_relay
Conflicts: xwords4/linux/linuxmain.c xwords4/linux/main.h
This commit is contained in:
commit
7967966982
3 changed files with 52 additions and 0 deletions
|
@ -23,6 +23,8 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include <netdb.h> /* gethostbyname */
|
#include <netdb.h> /* gethostbyname */
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -1513,6 +1515,15 @@ curses_util_makeStreamFromAddr(XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
|
||||||
} /* curses_util_makeStreamFromAddr */
|
} /* curses_util_makeStreamFromAddr */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_CHAT
|
||||||
|
static void
|
||||||
|
curses_util_showChat( XW_UtilCtxt* XP_UNUSED(uc), const XP_UCHAR* const msg )
|
||||||
|
{
|
||||||
|
XP_LOGF( "%s: got \"%s\"", __func__, msg );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setupCursesUtilCallbacks( CursesAppGlobals* globals, XW_UtilCtxt* util )
|
setupCursesUtilCallbacks( CursesAppGlobals* globals, XW_UtilCtxt* util )
|
||||||
{
|
{
|
||||||
|
@ -1526,6 +1537,10 @@ setupCursesUtilCallbacks( CursesAppGlobals* globals, XW_UtilCtxt* util )
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||||
util->vtable->m_util_makeStreamFromAddr = curses_util_makeStreamFromAddr;
|
util->vtable->m_util_makeStreamFromAddr = curses_util_makeStreamFromAddr;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef XWFEATURE_CHAT
|
||||||
|
util->vtable->m_util_showChat = curses_util_showChat;
|
||||||
|
#endif
|
||||||
|
|
||||||
util->vtable->m_util_userQuery = curses_util_userQuery;
|
util->vtable->m_util_userQuery = curses_util_userQuery;
|
||||||
util->vtable->m_util_confirmTrade = curses_util_confirmTrade;
|
util->vtable->m_util_confirmTrade = curses_util_confirmTrade;
|
||||||
util->vtable->m_util_userPickTileBlank = curses_util_userPickTileBlank;
|
util->vtable->m_util_userPickTileBlank = curses_util_userPickTileBlank;
|
||||||
|
@ -1699,6 +1714,32 @@ handle_stdin( GIOChannel* XP_UNUSED_DBG(source), GIOCondition condition,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
chatsTimerFired( gpointer data )
|
||||||
|
{
|
||||||
|
CursesAppGlobals* globals = (CursesAppGlobals*)data;
|
||||||
|
|
||||||
|
GameStateInfo gsi;
|
||||||
|
game_getState( &globals->cGlobals.game, &gsi );
|
||||||
|
|
||||||
|
if ( gsi.gameIsConnected ) {
|
||||||
|
XP_UCHAR msg[128];
|
||||||
|
struct tm* timp;
|
||||||
|
struct timeval tv;
|
||||||
|
struct timezone tz;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cursesmain( XP_Bool isServer, LaunchParams* params )
|
cursesmain( XP_Bool isServer, LaunchParams* params )
|
||||||
{
|
{
|
||||||
|
@ -1788,6 +1829,11 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
|
||||||
} else if ( !!params->nbs && !!params->fileName ) {
|
} else if ( !!params->nbs && !!params->fileName ) {
|
||||||
do_nbs_then_close( &g_globals.cGlobals, &procs );
|
do_nbs_then_close( &g_globals.cGlobals, &procs );
|
||||||
} else {
|
} else {
|
||||||
|
if ( 0 != params->chatsInterval ) {
|
||||||
|
(void)g_timeout_add_seconds( params->chatsInterval, chatsTimerFired,
|
||||||
|
&g_globals );
|
||||||
|
}
|
||||||
|
|
||||||
XP_Bool opened = XP_FALSE;
|
XP_Bool opened = XP_FALSE;
|
||||||
initCurses( &g_globals );
|
initCurses( &g_globals );
|
||||||
getmaxyx( g_globals.boardWin, height, width );
|
getmaxyx( g_globals.boardWin, height, width );
|
||||||
|
|
|
@ -550,6 +550,7 @@ typedef enum {
|
||||||
,CMD_VERTICALSCORE
|
,CMD_VERTICALSCORE
|
||||||
,CMD_NOPEEK
|
,CMD_NOPEEK
|
||||||
,CMD_SPLITPACKETS
|
,CMD_SPLITPACKETS
|
||||||
|
,CMD_CHAT
|
||||||
#ifdef XWFEATURE_CROSSHAIRS
|
#ifdef XWFEATURE_CROSSHAIRS
|
||||||
,CMD_NOCROSSHAIRS
|
,CMD_NOCROSSHAIRS
|
||||||
#endif
|
#endif
|
||||||
|
@ -652,6 +653,7 @@ static CmdInfoRec CmdInfoRecs[] = {
|
||||||
,{ CMD_NOPEEK, false, "no-peek", "disallow scoreboard tap changing player" }
|
,{ CMD_NOPEEK, false, "no-peek", "disallow scoreboard tap changing player" }
|
||||||
,{ CMD_SPLITPACKETS, false, "split-packets", "send tcp packets in "
|
,{ CMD_SPLITPACKETS, false, "split-packets", "send tcp packets in "
|
||||||
"sections to test relay reassembly" }
|
"sections to test relay reassembly" }
|
||||||
|
,{ CMD_CHAT, true, "send-chat", "send a chat every <n> seconds" }
|
||||||
#ifdef XWFEATURE_CROSSHAIRS
|
#ifdef XWFEATURE_CROSSHAIRS
|
||||||
,{ CMD_NOCROSSHAIRS, false, "hide-crosshairs",
|
,{ CMD_NOCROSSHAIRS, false, "hide-crosshairs",
|
||||||
"don't show crosshairs on board" }
|
"don't show crosshairs on board" }
|
||||||
|
@ -1913,6 +1915,9 @@ main( int argc, char** argv )
|
||||||
case CMD_SPLITPACKETS:
|
case CMD_SPLITPACKETS:
|
||||||
mainParams.splitPackets = XP_TRUE;
|
mainParams.splitPackets = XP_TRUE;
|
||||||
break;
|
break;
|
||||||
|
case CMD_CHAT:
|
||||||
|
mainParams.chatsInterval = atoi(optarg);
|
||||||
|
break;
|
||||||
#ifdef XWFEATURE_CROSSHAIRS
|
#ifdef XWFEATURE_CROSSHAIRS
|
||||||
case CMD_NOCROSSHAIRS:
|
case CMD_NOCROSSHAIRS:
|
||||||
mainParams.hideCrosshairs = XP_TRUE;
|
mainParams.hideCrosshairs = XP_TRUE;
|
||||||
|
|
|
@ -91,6 +91,7 @@ typedef struct LaunchParams {
|
||||||
XP_Bool useMmap;
|
XP_Bool useMmap;
|
||||||
XP_Bool closeStdin;
|
XP_Bool closeStdin;
|
||||||
XP_Bool splitPackets;
|
XP_Bool splitPackets;
|
||||||
|
XP_U16 chatsInterval; /* 0 means disabled */
|
||||||
#ifdef XWFEATURE_SEARCHLIMIT
|
#ifdef XWFEATURE_SEARCHLIMIT
|
||||||
XP_Bool allowHintRect;
|
XP_Bool allowHintRect;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue