Fix to compile and run standalone

This commit is contained in:
ehouse 2008-01-19 16:03:53 +00:00
parent 3d314081b2
commit 6e9e5b5c99
5 changed files with 84 additions and 29 deletions

View file

@ -1,6 +1,6 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make MEMDEBUG=TRUE"; -*- */ /* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make MEMDEBUG=TRUE"; -*- */
/* /*
* Copyright 2000-2007 by Eric House (xwords@eehouse.org). All rights * Copyright 2000-2008 by Eric House (xwords@eehouse.org). All rights
* reserved. * reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -768,9 +768,6 @@ blocking_gotEvent( CursesAppGlobals* globals, int* ch )
if ( numEvents > 0 && if ( numEvents > 0 &&
(globals->fdArray[fdIndex].revents & POLLIN) != 0 ) { (globals->fdArray[fdIndex].revents & POLLIN) != 0 ) {
int nBytes;
unsigned char buf[256];
struct sockaddr_in addr_sock;
--numEvents; --numEvents;
@ -781,6 +778,9 @@ blocking_gotEvent( CursesAppGlobals* globals, int* ch )
(*globals->cGlobals.acceptor)( globals->fdArray[fdIndex].fd, (*globals->cGlobals.acceptor)( globals->fdArray[fdIndex].fd,
globals ); globals );
} else { } else {
#ifndef XWFEATURE_STANDALONE_ONLY
unsigned char buf[256];
int nBytes;
/* It's a normal data socket */ /* It's a normal data socket */
if ( 0 ) { if ( 0 ) {
#ifdef XWFEATURE_RELAY #ifdef XWFEATURE_RELAY
@ -801,6 +801,7 @@ blocking_gotEvent( CursesAppGlobals* globals, int* ch )
if ( nBytes != -1 ) { if ( nBytes != -1 ) {
XWStreamCtxt* inboundS; XWStreamCtxt* inboundS;
struct sockaddr_in addr_sock;
redraw = XP_FALSE; redraw = XP_FALSE;
XP_STATUSF( "linuxReceive=>%d", nBytes ); XP_STATUSF( "linuxReceive=>%d", nBytes );
@ -836,7 +837,9 @@ blocking_gotEvent( CursesAppGlobals* globals, int* ch )
curses_util_requestTime(globals->cGlobals.params->util); curses_util_requestTime(globals->cGlobals.params->util);
} }
} }
#else
XP_ASSERT(0); /* no socket activity in standalone game! */
#endif /* #ifndef XWFEATURE_STANDALONE_ONLY */
} }
++fdIndex; ++fdIndex;
} }
@ -924,6 +927,7 @@ curses_util_warnIllegalWord( XW_UtilCtxt* XP_UNUSED(uc),
return XP_FALSE; return XP_FALSE;
} /* curses_util_warnIllegalWord */ } /* curses_util_warnIllegalWord */
#ifndef XWFEATURE_STANDALONE_ONLY
static void static void
cursesSendOnClose( XWStreamCtxt* stream, void* closure ) cursesSendOnClose( XWStreamCtxt* stream, void* closure )
{ {
@ -946,6 +950,7 @@ curses_util_makeStreamFromAddr(XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
cursesSendOnClose ); cursesSendOnClose );
return stream; return stream;
} /* curses_util_makeStreamFromAddr */ } /* curses_util_makeStreamFromAddr */
#endif
static void static void
setupCursesUtilCallbacks( CursesAppGlobals* globals, XW_UtilCtxt* util ) setupCursesUtilCallbacks( CursesAppGlobals* globals, XW_UtilCtxt* util )
@ -956,8 +961,9 @@ setupCursesUtilCallbacks( CursesAppGlobals* globals, XW_UtilCtxt* util )
util->vtable->m_util_askPassword = curses_util_askPassword; util->vtable->m_util_askPassword = curses_util_askPassword;
util->vtable->m_util_yOffsetChange = curses_util_yOffsetChange; util->vtable->m_util_yOffsetChange = curses_util_yOffsetChange;
util->vtable->m_util_warnIllegalWord = curses_util_warnIllegalWord; util->vtable->m_util_warnIllegalWord = curses_util_warnIllegalWord;
#ifndef XWFEATURE_STANDALONE_ONLY
util->vtable->m_util_makeStreamFromAddr = curses_util_makeStreamFromAddr; util->vtable->m_util_makeStreamFromAddr = curses_util_makeStreamFromAddr;
#endif
util->vtable->m_util_userQuery = curses_util_userQuery; util->vtable->m_util_userQuery = curses_util_userQuery;
util->vtable->m_util_userPickTile = curses_util_userPickTile; util->vtable->m_util_userPickTile = curses_util_userPickTile;
util->vtable->m_util_trayHiddenChange = curses_util_trayHiddenChange; util->vtable->m_util_trayHiddenChange = curses_util_trayHiddenChange;
@ -972,6 +978,7 @@ setupCursesUtilCallbacks( CursesAppGlobals* globals, XW_UtilCtxt* util )
util->closure = globals; util->closure = globals;
} /* setupCursesUtilCallbacks */ } /* setupCursesUtilCallbacks */
#ifndef XWFEATURE_STANDALONE_ONLY
static void static void
sendOnClose( XWStreamCtxt* stream, void* closure ) sendOnClose( XWStreamCtxt* stream, void* closure )
{ {
@ -980,6 +987,7 @@ sendOnClose( XWStreamCtxt* stream, void* closure )
XP_ASSERT( !!globals->cGlobals.game.comms ); XP_ASSERT( !!globals->cGlobals.game.comms );
comms_send( globals->cGlobals.game.comms, stream ); comms_send( globals->cGlobals.game.comms, stream );
} /* sendOnClose */ } /* sendOnClose */
#endif
static XP_Bool static XP_Bool
handleKeyEvent( CursesAppGlobals* globals, MenuList* list, char ch ) handleKeyEvent( CursesAppGlobals* globals, MenuList* list, char ch )
@ -1055,14 +1063,15 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
gameID = (XP_U16)util_getCurSeconds( globals.cGlobals.params->util ); gameID = (XP_U16)util_getCurSeconds( globals.cGlobals.params->util );
game_makeNewGame( MEMPOOL &globals.cGlobals.game, &params->gi, game_makeNewGame( MEMPOOL &globals.cGlobals.game, &params->gi,
params->util, (DrawCtx*)globals.draw, params->util, (DrawCtx*)globals.draw,
gameID, &globals.cp, linux_send, gameID, &globals.cp, LINUX_SEND,
IF_CH(linux_reset) &globals ); IF_CH(linux_reset) &globals );
#ifndef XWFEATURE_STANDALONE_ONLY
if ( globals.cGlobals.game.comms ) { if ( globals.cGlobals.game.comms ) {
CommsAddrRec addr; CommsAddrRec addr;
if ( 0 ) { if ( 0 ) {
#ifdef XWFEATURE_RELAY # ifdef XWFEATURE_RELAY
} else if ( params->conType == COMMS_CONN_RELAY ) { } else if ( params->conType == COMMS_CONN_RELAY ) {
addr.conType = COMMS_CONN_RELAY; addr.conType = COMMS_CONN_RELAY;
addr.u.ip_relay.ipAddr = 0; /* ??? */ addr.u.ip_relay.ipAddr = 0; /* ??? */
@ -1071,18 +1080,19 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
sizeof(addr.u.ip_relay.hostName) - 1 ); sizeof(addr.u.ip_relay.hostName) - 1 );
XP_STRNCPY( addr.u.ip_relay.cookie, params->connInfo.relay.cookie, XP_STRNCPY( addr.u.ip_relay.cookie, params->connInfo.relay.cookie,
sizeof(addr.u.ip_relay.cookie) - 1 ); sizeof(addr.u.ip_relay.cookie) - 1 );
#endif # endif
#ifdef XWFEATURE_BLUETOOTH # ifdef XWFEATURE_BLUETOOTH
} else if ( params->conType == COMMS_CONN_BT ) { } else if ( params->conType == COMMS_CONN_BT ) {
addr.conType = COMMS_CONN_BT; addr.conType = COMMS_CONN_BT;
XP_ASSERT( sizeof(addr.u.bt.btAddr) XP_ASSERT( sizeof(addr.u.bt.btAddr)
>= sizeof(params->connInfo.bt.hostAddr)); >= sizeof(params->connInfo.bt.hostAddr));
XP_MEMCPY( &addr.u.bt.btAddr, &params->connInfo.bt.hostAddr, XP_MEMCPY( &addr.u.bt.btAddr, &params->connInfo.bt.hostAddr,
sizeof(params->connInfo.bt.hostAddr) ); sizeof(params->connInfo.bt.hostAddr) );
#endif # endif
} }
comms_setAddr( globals.cGlobals.game.comms, &addr ); comms_setAddr( globals.cGlobals.game.comms, &addr );
} }
#endif
model_setDictionary( globals.cGlobals.game.model, params->dict ); model_setDictionary( globals.cGlobals.game.model, params->dict );
@ -1102,6 +1112,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
board_invalAll( globals.cGlobals.game.board ); board_invalAll( globals.cGlobals.game.board );
#ifndef XWFEATURE_STANDALONE_ONLY
/* send any events that need to get off before the event loop begins */ /* send any events that need to get off before the event loop begins */
if ( !isServer ) { if ( !isServer ) {
if ( 1 /* stream_open( params->info.clientInfo.stream ) */) { if ( 1 /* stream_open( params->info.clientInfo.stream ) */) {
@ -1116,6 +1127,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
exit( 0 ); exit( 0 );
} }
} }
#endif
server_do( globals.cGlobals.game.server ); server_do( globals.cGlobals.game.server );

View file

@ -1,6 +1,6 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make MEMDEBUG=TRUE"; -*- */ /* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make MEMDEBUG=TRUE"; -*- */
/* /*
* Copyright 2000-2007 by Eric House (xwords@eehouse.org). All rights reserved. * Copyright 2000-2008 by Eric House (xwords@eehouse.org). All rights reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -58,7 +58,9 @@
#include "filestream.h" #include "filestream.h"
/* static guint gtkSetupClientSocket( GtkAppGlobals* globals, int sock ); */ /* static guint gtkSetupClientSocket( GtkAppGlobals* globals, int sock ); */
#ifndef XWFEATURE_STANDALONE_ONLY
static void sendOnClose( XWStreamCtxt* stream, void* closure ); static void sendOnClose( XWStreamCtxt* stream, void* closure );
#endif
static XP_Bool file_exists( const char* fileName ); static XP_Bool file_exists( const char* fileName );
static void setCtrlsForTray( GtkAppGlobals* globals ); static void setCtrlsForTray( GtkAppGlobals* globals );
static void printFinalScores( GtkAppGlobals* globals ); static void printFinalScores( GtkAppGlobals* globals );
@ -292,8 +294,10 @@ createOrLoadObjects( GtkAppGlobals* globals )
XWStreamCtxt* stream = NULL; XWStreamCtxt* stream = NULL;
XP_Bool opened = XP_FALSE; XP_Bool opened = XP_FALSE;
#ifndef XWFEATURE_STANDALONE_ONLY
DeviceRole serverRole = globals->cGlobals.params->serverRole; DeviceRole serverRole = globals->cGlobals.params->serverRole;
XP_Bool isServer = serverRole != SERVER_ISCLIENT; XP_Bool isServer = serverRole != SERVER_ISCLIENT;
#endif
LaunchParams* params = globals->cGlobals.params; LaunchParams* params = globals->cGlobals.params;
globals->draw = (GtkDrawCtx*)gtkDrawCtxtMake( globals->drawing_area, globals->draw = (GtkDrawCtx*)gtkDrawCtxtMake( globals->drawing_area,
@ -308,7 +312,7 @@ createOrLoadObjects( GtkAppGlobals* globals )
params->dict, params->util, params->dict, params->util,
(DrawCtx*)globals->draw, (DrawCtx*)globals->draw,
&globals->cp, &globals->cp,
linux_send, IF_CH(linux_reset) globals ); LINUX_SEND, IF_CH(linux_reset) globals );
stream_destroy( stream ); stream_destroy( stream );
} }
@ -335,7 +339,7 @@ createOrLoadObjects( GtkAppGlobals* globals )
game_makeNewGame( MEMPOOL &globals->cGlobals.game, &params->gi, game_makeNewGame( MEMPOOL &globals->cGlobals.game, &params->gi,
params->util, (DrawCtx*)globals->draw, params->util, (DrawCtx*)globals->draw,
gameID, &globals->cp, linux_send, gameID, &globals->cp, LINUX_SEND,
IF_CH(linux_reset) globals ); IF_CH(linux_reset) globals );
addr.conType = params->conType; addr.conType = params->conType;
@ -364,11 +368,12 @@ createOrLoadObjects( GtkAppGlobals* globals )
#endif #endif
} }
#ifndef XWFEATURE_STANDALONE_ONLY
/* This may trigger network activity */ /* This may trigger network activity */
if ( !!globals->cGlobals.game.comms ) { if ( !!globals->cGlobals.game.comms ) {
comms_setAddr( globals->cGlobals.game.comms, &addr ); comms_setAddr( globals->cGlobals.game.comms, &addr );
} }
#endif
model_setDictionary( globals->cGlobals.game.model, params->dict ); model_setDictionary( globals->cGlobals.game.model, params->dict );
/* params->gi.phoniesAction = PHONIES_DISALLOW; */ /* params->gi.phoniesAction = PHONIES_DISALLOW; */
@ -376,6 +381,7 @@ createOrLoadObjects( GtkAppGlobals* globals )
params->gi.allowHintRect = XP_TRUE; params->gi.allowHintRect = XP_TRUE;
#endif #endif
#ifndef XWFEATURE_STANDALONE_ONLY
if ( !isServer ) { if ( !isServer ) {
XWStreamCtxt* stream = XWStreamCtxt* stream =
mem_stream_make( MEMPOOL params->vtMgr, globals, CHANNEL_NONE, mem_stream_make( MEMPOOL params->vtMgr, globals, CHANNEL_NONE,
@ -383,12 +389,14 @@ createOrLoadObjects( GtkAppGlobals* globals )
server_initClientConnection( globals->cGlobals.game.server, server_initClientConnection( globals->cGlobals.game.server,
stream ); stream );
} }
#endif
} }
#ifndef XWFEATURE_STANDALONE_ONLY
if ( !!globals->cGlobals.game.comms ) { if ( !!globals->cGlobals.game.comms ) {
comms_start( globals->cGlobals.game.comms ); comms_start( globals->cGlobals.game.comms );
} }
#endif
server_do( globals->cGlobals.game.server ); server_do( globals->cGlobals.game.server );
} /* createOrLoadObjects */ } /* createOrLoadObjects */
@ -640,15 +648,18 @@ new_game( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
confirmed = newGameDialog( globals, XP_TRUE ); confirmed = newGameDialog( globals, XP_TRUE );
if ( confirmed ) { if ( confirmed ) {
CurGameInfo* gi = &globals->cGlobals.params->gi; CurGameInfo* gi = &globals->cGlobals.params->gi;
#ifndef XWFEATURE_STANDALONE_ONLY
XP_Bool isClient = gi->serverRole == SERVER_ISCLIENT; XP_Bool isClient = gi->serverRole == SERVER_ISCLIENT;
#endif
XP_U32 gameID = util_getCurSeconds( globals->cGlobals.params->util ); XP_U32 gameID = util_getCurSeconds( globals->cGlobals.params->util );
XP_STATUSF( "grabbed gameID: %ld\n", gameID ); XP_STATUSF( "grabbed gameID: %ld\n", gameID );
game_reset( MEMPOOL &globals->cGlobals.game, gi, game_reset( MEMPOOL &globals->cGlobals.game, gi,
globals->cGlobals.params->util, globals->cGlobals.params->util,
gameID, &globals->cp, linux_send, gameID, &globals->cp, LINUX_SEND,
IF_CH(linux_reset) globals ); IF_CH(linux_reset) globals );
#ifndef XWFEATURE_STANDALONE_ONLY
if ( isClient ) { if ( isClient ) {
XWStreamCtxt* stream = XWStreamCtxt* stream =
mem_stream_make( MEMPOOL mem_stream_make( MEMPOOL
@ -659,7 +670,7 @@ new_game( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
server_initClientConnection( globals->cGlobals.game.server, server_initClientConnection( globals->cGlobals.game.server,
stream ); stream );
} }
#endif
(void)server_do( globals->cGlobals.game.server ); /* assign tiles, etc. */ (void)server_do( globals->cGlobals.game.server ); /* assign tiles, etc. */
board_invalAll( globals->cGlobals.game.board ); board_invalAll( globals->cGlobals.game.board );
board_draw( globals->cGlobals.game.board ); board_draw( globals->cGlobals.game.board );
@ -726,6 +737,7 @@ handle_trayEditToggle_off( GtkWidget* widget, GtkAppGlobals* globals )
} }
#endif #endif
#ifndef XWFEATURE_STANDALONE_ONLY
static void static void
handle_resend( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals ) handle_resend( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
{ {
@ -752,6 +764,7 @@ handle_commstats( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
} }
} /* handle_commstats */ } /* handle_commstats */
#endif #endif
#endif
#ifdef MEM_DEBUG #ifdef MEM_DEBUG
static void static void
@ -831,11 +844,13 @@ makeMenus( GtkAppGlobals* globals, int XP_UNUSED(argc),
fileMenu = makeAddSubmenu( menubar, "Network" ); fileMenu = makeAddSubmenu( menubar, "Network" );
#ifndef XWFEATURE_STANDALONE_ONLY
(void)createAddItem( fileMenu, "Resend", (void)createAddItem( fileMenu, "Resend",
GTK_SIGNAL_FUNC(handle_resend), globals ); GTK_SIGNAL_FUNC(handle_resend), globals );
#ifdef DEBUG # ifdef DEBUG
(void)createAddItem( fileMenu, "Stats", (void)createAddItem( fileMenu, "Stats",
GTK_SIGNAL_FUNC(handle_commstats), globals ); GTK_SIGNAL_FUNC(handle_commstats), globals );
# endif
#endif #endif
#ifdef MEM_DEBUG #ifdef MEM_DEBUG
(void)createAddItem( fileMenu, "Mem stats", (void)createAddItem( fileMenu, "Mem stats",
@ -1332,6 +1347,7 @@ gtk_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi, XP_U16 player,
return result; return result;
} /* gtk_util_warnIllegalWord */ } /* gtk_util_warnIllegalWord */
#ifndef XWFEATURE_STANDALONE_ONLY
static XWStreamCtxt* static XWStreamCtxt*
gtk_util_makeStreamFromAddr(XW_UtilCtxt* uc, XP_PlayerAddr channelNo ) gtk_util_makeStreamFromAddr(XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
{ {
@ -1343,6 +1359,7 @@ gtk_util_makeStreamFromAddr(XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
sendOnClose ); sendOnClose );
return stream; return stream;
} /* gtk_util_makeStreamFromAddr */ } /* gtk_util_makeStreamFromAddr */
#endif
#ifdef XWFEATURE_SEARCHLIMIT #ifdef XWFEATURE_SEARCHLIMIT
static XP_Bool static XP_Bool
@ -1558,9 +1575,9 @@ setupGtkUtilCallbacks( GtkAppGlobals* globals, XW_UtilCtxt* util )
util->vtable->m_util_setTimer = gtk_util_setTimer; util->vtable->m_util_setTimer = gtk_util_setTimer;
util->vtable->m_util_requestTime = gtk_util_requestTime; util->vtable->m_util_requestTime = gtk_util_requestTime;
util->vtable->m_util_warnIllegalWord = gtk_util_warnIllegalWord; util->vtable->m_util_warnIllegalWord = gtk_util_warnIllegalWord;
#ifndef XWFEATURE_STANDALONE_ONLY
util->vtable->m_util_makeStreamFromAddr = gtk_util_makeStreamFromAddr; util->vtable->m_util_makeStreamFromAddr = gtk_util_makeStreamFromAddr;
#endif
#ifdef XWFEATURE_SEARCHLIMIT #ifdef XWFEATURE_SEARCHLIMIT
util->vtable->m_util_getTraySearchLimits = gtk_util_getTraySearchLimits; util->vtable->m_util_getTraySearchLimits = gtk_util_getTraySearchLimits;
#endif #endif
@ -1568,6 +1585,7 @@ setupGtkUtilCallbacks( GtkAppGlobals* globals, XW_UtilCtxt* util )
util->closure = globals; util->closure = globals;
} /* setupGtkUtilCallbacks */ } /* setupGtkUtilCallbacks */
#ifndef XWFEATURE_STANDALONE_ONLY
static gboolean static gboolean
newConnectionInput( GIOChannel *source, newConnectionInput( GIOChannel *source,
GIOCondition condition, GIOCondition condition,
@ -1780,6 +1798,7 @@ drop_msg_toggle( GtkWidget* toggle, GtkAppGlobals* globals )
globals->dropIncommingMsgs = gtk_toggle_button_get_active( globals->dropIncommingMsgs = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(toggle) ); GTK_TOGGLE_BUTTON(toggle) );
} /* drop_msg_toggle */ } /* drop_msg_toggle */
#endif
int int
gtkmain( LaunchParams* params, int argc, char *argv[] ) gtkmain( LaunchParams* params, int argc, char *argv[] )
@ -1792,19 +1811,23 @@ gtkmain( LaunchParams* params, int argc, char *argv[] )
GtkWidget* vbox; GtkWidget* vbox;
GtkWidget* hbox; GtkWidget* hbox;
GtkAppGlobals globals; GtkAppGlobals globals;
#ifndef XWFEATURE_STANDALONE_ONLY
GtkWidget* dropCheck; GtkWidget* dropCheck;
#endif
memset( &globals, 0, sizeof(globals) ); memset( &globals, 0, sizeof(globals) );
globals.cGlobals.params = params; globals.cGlobals.params = params;
globals.cGlobals.lastNTilesToUse = MAX_TRAY_TILES; globals.cGlobals.lastNTilesToUse = MAX_TRAY_TILES;
#ifdef XWFEATURE_RELAY #ifndef XWFEATURE_STANDALONE_ONLY
# ifdef XWFEATURE_RELAY
globals.cGlobals.socket = -1; globals.cGlobals.socket = -1;
#endif # endif
globals.cGlobals.socketChanged = gtk_socket_changed; globals.cGlobals.socketChanged = gtk_socket_changed;
globals.cGlobals.socketChangedClosure = &globals; globals.cGlobals.socketChangedClosure = &globals;
globals.cGlobals.addAcceptor = gtk_socket_acceptor; globals.cGlobals.addAcceptor = gtk_socket_acceptor;
#endif
globals.cp.showBoardArrow = XP_TRUE; globals.cp.showBoardArrow = XP_TRUE;
globals.cp.showRobotScores = params->showRobotScores; globals.cp.showRobotScores = params->showRobotScores;
@ -1840,11 +1863,13 @@ gtkmain( LaunchParams* params, int argc, char *argv[] )
menubar = makeMenus( &globals, argc, argv ); menubar = makeMenus( &globals, argc, argv );
gtk_box_pack_start( GTK_BOX(vbox), menubar, FALSE, TRUE, 0); gtk_box_pack_start( GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
#ifndef XWFEATURE_STANDALONE_ONLY
dropCheck = gtk_check_button_new_with_label( "drop incoming messages" ); dropCheck = gtk_check_button_new_with_label( "drop incoming messages" );
g_signal_connect( GTK_OBJECT(dropCheck), g_signal_connect( GTK_OBJECT(dropCheck),
"toggled", G_CALLBACK(drop_msg_toggle), &globals ); "toggled", G_CALLBACK(drop_msg_toggle), &globals );
gtk_box_pack_start( GTK_BOX(vbox), dropCheck, FALSE, TRUE, 0); gtk_box_pack_start( GTK_BOX(vbox), dropCheck, FALSE, TRUE, 0);
gtk_widget_show( dropCheck ); gtk_widget_show( dropCheck );
#endif
buttonbar = makeButtons( &globals, argc, argv ); buttonbar = makeButtons( &globals, argc, argv );
gtk_box_pack_start( GTK_BOX(vbox), buttonbar, FALSE, TRUE, 0); gtk_box_pack_start( GTK_BOX(vbox), buttonbar, FALSE, TRUE, 0);

View file

@ -1,6 +1,6 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make MEMDEBUG=TRUE"; -*- */ /* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make MEMDEBUG=TRUE"; -*- */
/* /*
* Copyright 2001-2006 by Eric House (xwords@eehouse.org). All rights * Copyright 2001-2008 by Eric House (xwords@eehouse.org). All rights
* reserved. * reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -37,6 +37,7 @@ typedef struct GtkNewGameState {
#ifndef XWFEATURE_STANDALONE_ONLY #ifndef XWFEATURE_STANDALONE_ONLY
GtkWidget* remoteChecks[MAX_NUM_PLAYERS]; GtkWidget* remoteChecks[MAX_NUM_PLAYERS];
GtkWidget* roleCombo;
#endif #endif
GtkWidget* robotChecks[MAX_NUM_PLAYERS]; GtkWidget* robotChecks[MAX_NUM_PLAYERS];
GtkWidget* nameLabels[MAX_NUM_PLAYERS]; GtkWidget* nameLabels[MAX_NUM_PLAYERS];
@ -44,7 +45,6 @@ typedef struct GtkNewGameState {
GtkWidget* passwdLabels[MAX_NUM_PLAYERS]; GtkWidget* passwdLabels[MAX_NUM_PLAYERS];
GtkWidget* passwdFields[MAX_NUM_PLAYERS]; GtkWidget* passwdFields[MAX_NUM_PLAYERS];
GtkWidget* nPlayersCombo; GtkWidget* nPlayersCombo;
GtkWidget* roleCombo;
GtkWidget* nPlayersLabel; GtkWidget* nPlayersLabel;
GtkWidget* juggleButton; GtkWidget* juggleButton;
} GtkNewGameState; } GtkNewGameState;
@ -59,6 +59,7 @@ nplayers_menu_changed( GtkComboBox* combo, GtkNewGameState* state )
} }
} /* nplayers_menu_changed */ } /* nplayers_menu_changed */
#ifndef XWFEATURE_STANDALONE_ONLY
static void static void
role_combo_changed( GtkComboBox* combo, gpointer gp ) role_combo_changed( GtkComboBox* combo, gpointer gp )
{ {
@ -70,6 +71,7 @@ role_combo_changed( GtkComboBox* combo, gpointer gp )
newg_attrChanged( state->newGameCtxt, NG_ATTR_ROLE, value ); newg_attrChanged( state->newGameCtxt, NG_ATTR_ROLE, value );
} }
} /* role_combo_changed */ } /* role_combo_changed */
#endif
static void static void
callChangedWithIndex( GtkNewGameState* state, GtkWidget* item, callChangedWithIndex( GtkNewGameState* state, GtkWidget* item,
@ -161,18 +163,21 @@ makeNewGameDialog( GtkNewGameState* state, XP_Bool isNewGame )
GtkWidget* dialog; GtkWidget* dialog;
GtkWidget* vbox; GtkWidget* vbox;
GtkWidget* hbox; GtkWidget* hbox;
#ifndef XWFEATURE_STANDALONE_ONLY
GtkWidget* roleCombo; GtkWidget* roleCombo;
char* roles[] = { "Standalone", "Host", "Guest" };
#endif
GtkWidget* nPlayersCombo; GtkWidget* nPlayersCombo;
GtkWidget* boardSizeCombo; GtkWidget* boardSizeCombo;
CurGameInfo* gi; CurGameInfo* gi;
short i; short i;
char* roles[] = { "Standalone", "Host", "Guest" };
dialog = gtk_dialog_new(); dialog = gtk_dialog_new();
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE ); gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
vbox = gtk_vbox_new( FALSE, 0 ); vbox = gtk_vbox_new( FALSE, 0 );
#ifndef XWFEATURE_STANDALONE_ONLY
hbox = gtk_hbox_new( FALSE, 0 ); hbox = gtk_hbox_new( FALSE, 0 );
gtk_box_pack_start( GTK_BOX(hbox), gtk_label_new("Role:"), gtk_box_pack_start( GTK_BOX(hbox), gtk_label_new("Role:"),
FALSE, TRUE, 0 ); FALSE, TRUE, 0 );
@ -187,6 +192,7 @@ makeNewGameDialog( GtkNewGameState* state, XP_Bool isNewGame )
gtk_box_pack_start( GTK_BOX(hbox), roleCombo, FALSE, TRUE, 0 ); gtk_box_pack_start( GTK_BOX(hbox), roleCombo, FALSE, TRUE, 0 );
gtk_box_pack_start( GTK_BOX(vbox), hbox, FALSE, TRUE, 0 ); gtk_box_pack_start( GTK_BOX(vbox), hbox, FALSE, TRUE, 0 );
#endif
/* NPlayers menu */ /* NPlayers menu */
hbox = gtk_hbox_new( FALSE, 0 ); hbox = gtk_hbox_new( FALSE, 0 );
@ -388,8 +394,10 @@ gtk_newgame_attr_enable( void* closure, NewGameAttr attr, XP_TriEnable enable )
GtkWidget* widget = NULL; GtkWidget* widget = NULL;
if ( attr == NG_ATTR_NPLAYERS ) { if ( attr == NG_ATTR_NPLAYERS ) {
widget = state->nPlayersCombo; widget = state->nPlayersCombo;
#ifndef XWFEATURE_STANDALONE_ONLY
} else if ( attr == NG_ATTR_ROLE ) { } else if ( attr == NG_ATTR_ROLE ) {
widget = state->roleCombo; widget = state->roleCombo;
#endif
} else if ( attr == NG_ATTR_CANJUGGLE ) { } else if ( attr == NG_ATTR_CANJUGGLE ) {
widget = state->juggleButton; widget = state->juggleButton;
} }
@ -456,11 +464,13 @@ gtk_newgame_attr_set( void* closure, NewGameAttr attr, NGValue value )
XP_U16 i = value.ng_u16; XP_U16 i = value.ng_u16;
XP_LOGF( "%s: setting menu %d", __func__, i-1 ); XP_LOGF( "%s: setting menu %d", __func__, i-1 );
gtk_combo_box_set_active( GTK_COMBO_BOX(state->nPlayersCombo), i-1 ); gtk_combo_box_set_active( GTK_COMBO_BOX(state->nPlayersCombo), i-1 );
#ifndef XWFEATURE_STANDALONE_ONLY
} else if ( attr == NG_ATTR_ROLE ) { } else if ( attr == NG_ATTR_ROLE ) {
gtk_combo_box_set_active( GTK_COMBO_BOX(state->roleCombo), gtk_combo_box_set_active( GTK_COMBO_BOX(state->roleCombo),
value.ng_role ); value.ng_role );
} else if ( attr == NG_ATTR_REMHEADER ) { } else if ( attr == NG_ATTR_REMHEADER ) {
/* ignored on GTK: no headers at all */ /* ignored on GTK: no headers at all */
#endif
} else if ( attr == NG_ATTR_NPLAYHEADER ) { } else if ( attr == NG_ATTR_NPLAYHEADER ) {
gtk_label_set_text( GTK_LABEL(state->nPlayersLabel), value.ng_cp ); gtk_label_set_text( GTK_LABEL(state->nPlayersLabel), value.ng_cp );
} }

View file

@ -1,6 +1,6 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make MEMDEBUG=TRUE"; -*- */ /* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make MEMDEBUG=TRUE"; -*- */
/* /*
* Copyright 2000-2007 by Eric House (xwords@eehouse.org). All rights * Copyright 2000-2008 by Eric House (xwords@eehouse.org). All rights
* reserved. * reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -349,6 +349,7 @@ linShiftFocus( CommonGlobals* cGlobals, XP_Key key, const BoardObjectType* order
} /* linShiftFocus */ } /* linShiftFocus */
#endif #endif
#ifndef XWFEATURE_STANDALONE_ONLY
#ifdef XWFEATURE_RELAY #ifdef XWFEATURE_RELAY
static int static int
linux_init_relay_socket( CommonGlobals* cGlobals ) linux_init_relay_socket( CommonGlobals* cGlobals )
@ -546,7 +547,8 @@ linux_relay_receive( CommonGlobals* cGlobals, unsigned char* buf, int bufSize )
} }
return nRead; return nRead;
} /* linuxReceive */ } /* linuxReceive */
#endif #endif /* XWFEATURE_RELAY */
#endif /* XWFEATURE_STANDALONE_ONLY */
/* Create a stream for the incoming message buffer, and read in any /* Create a stream for the incoming message buffer, and read in any
information specific to our platform's comms layer (return address, say) information specific to our platform's comms layer (return address, say)

View file

@ -1,6 +1,6 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make -k";-*- */ /* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make -k";-*- */
/* /*
* Copyright 1997-2000 by Eric House (xwords@eehouse.org). All rights reserved. * Copyright 1997-2008 by Eric House (xwords@eehouse.org). All rights reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -39,6 +39,12 @@ DictionaryCtxt* linux_dictionary_make( MPFORMAL const char* dictFileName );
int initListenerSocket( int port ); int initListenerSocket( int port );
XP_S16 linux_send( const XP_U8* buf, XP_U16 buflen, XP_S16 linux_send( const XP_U8* buf, XP_U16 buflen,
const CommsAddrRec* addrRec, void* closure ); const CommsAddrRec* addrRec, void* closure );
#ifndef XWFEATURE_STANDALONE_ONLY
# define LINUX_SEND linux_send
#else
# define LINUX_SEND NULL
#endif
#ifdef COMMS_HEARTBEAT #ifdef COMMS_HEARTBEAT
void linux_reset( void* closure ); void linux_reset( void* closure );
#endif #endif