From d74814a806097e1310fd46e23599fa5ea05854a5 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 9 May 2013 06:33:19 -0700 Subject: [PATCH] part of previous (merge) commit that got left out -- files not saved. --- xwords4/linux/gtkboard.c | 6 +- xwords4/linux/linuxmain.c | 177 ++++++++------------------------------ xwords4/relay/xwrelay.cpp | 4 +- 3 files changed, 43 insertions(+), 144 deletions(-) diff --git a/xwords4/linux/gtkboard.c b/xwords4/linux/gtkboard.c index 65a38c117..8ec6d4dab 100644 --- a/xwords4/linux/gtkboard.c +++ b/xwords4/linux/gtkboard.c @@ -1173,9 +1173,9 @@ disenable_buttons( GtkGameGlobals* globals ) XP_Bool canToggle = board_canTogglePending( globals->cGlobals.game.board ); gtk_widget_set_sensitive( globals->toggle_undo_button, canToggle ); - XP_Bool canHing = board_canHint( globals->cGlobals.game.board ); - gtk_widget_set_sensitive( globals->prevhint_button, canHing ); - gtk_widget_set_sensitive( globals->nexthint_button, canHing ); + XP_Bool canHint = board_canHint( globals->cGlobals.game.board ); + gtk_widget_set_sensitive( globals->prevhint_button, canHint ); + gtk_widget_set_sensitive( globals->nexthint_button, canHint ); #ifdef XWFEATURE_CHAT XP_Bool canChat = !!globals->cGlobals.game.comms diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index 7178fc07f..6d676874b 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -1765,7 +1765,7 @@ dawg2dict( const LaunchParams* params, GSList* testDicts ) guint count = g_slist_length( testDicts ); for ( int ii = 0; ii < count; ++ii ) { DictionaryCtxt* dict = - linux_dictionary_make( MPPARM(params->util->mpool) params, + linux_dictionary_make( MPPARM(params->mpool) params, g_slist_nth_data( testDicts, ii ), params->useMmap ); if ( NULL != dict ) { @@ -2190,37 +2190,22 @@ main( int argc, char** argv ) } } -<<<<<<< HEAD - XP_ASSERT( mainParams.pgi.nPlayers == mainParams.nLocalPlayers - + mainParams.info.serverInfo.nRemotePlayers ); - - if ( isServer ) { - if ( mainParams.info.serverInfo.nRemotePlayers == 0 ) { - mainParams.pgi.serverRole = SERVER_STANDALONE; - } else { - mainParams.pgi.serverRole = SERVER_ISSERVER; - } - } else { - mainParams.pgi.serverRole = SERVER_ISCLIENT; - } -======= int result; if ( g_str_has_suffix( argv[0], "dawg2dict" ) ) { result = dawg2dict( &mainParams, testDicts ); } else { - XP_ASSERT( mainParams.gi.nPlayers == mainParams.nLocalPlayers + XP_ASSERT( mainParams.pgi.nPlayers == mainParams.nLocalPlayers + mainParams.info.serverInfo.nRemotePlayers ); if ( isServer ) { if ( mainParams.info.serverInfo.nRemotePlayers == 0 ) { - mainParams.gi.serverRole = SERVER_STANDALONE; + mainParams.pgi.serverRole = SERVER_STANDALONE; } else { - mainParams.gi.serverRole = SERVER_ISSERVER; + mainParams.pgi.serverRole = SERVER_ISSERVER; } } else { - mainParams.gi.serverRole = SERVER_ISCLIENT; + mainParams.pgi.serverRole = SERVER_ISCLIENT; } ->>>>>>> android_branch /* sanity checks */ totalPlayerCount = mainParams.nLocalPlayers @@ -2236,39 +2221,21 @@ main( int argc, char** argv ) } } -<<<<<<< HEAD - if ( !!mainParams.pgi.dictName ) { - /* char path[256]; */ - /* getDictPath( &mainParams, mainParams.gi.dictName, path, VSIZE(path) ); */ - /* mainParams.dict = */ - /* linux_dictionary_make( MPPARM(mainParams.mpool) &mainParams, */ - /* mainParams.pgi.dictName, */ - /* mainParams.useMmap ); */ - /* XP_ASSERT( !!mainParams.dict ); */ - /* mainParams.pgi.dictLang = dict_getLangCode( mainParams.dict ); */ - } else if ( isServer ) { -#ifdef STUBBED_DICT - mainParams.dict = make_stubbed_dict( - MPPARM_NOCOMMA(mainParams.util->mpool) ); - XP_WARNF( "no dictionary provided: using English stub dict\n" ); - mainParams.pgi.dictLang = dict_getLangCode( mainParams.dict ); -======= - if ( !!mainParams.gi.dictName ) { + if ( !!mainParams.pgi.dictName ) { /* char path[256]; */ /* getDictPath( &mainParams, mainParams.gi.dictName, path, VSIZE(path) ); */ - mainParams.dict = - linux_dictionary_make( MPPARM(mainParams.util->mpool) &mainParams, - mainParams.gi.dictName, - mainParams.useMmap ); - XP_ASSERT( !!mainParams.dict ); - mainParams.gi.dictLang = dict_getLangCode( mainParams.dict ); + /* mainParams.dict = */ + /* linux_dictionary_make( MPPARM(mainParams.mpool) &mainParams, */ + /* mainParams.pgi.dictName, */ + /* mainParams.useMmap ); */ + /* XP_ASSERT( !!mainParams.dict ); */ + /* mainParams.pgi.dictLang = dict_getLangCode( mainParams.dict ); */ } else if ( isServer ) { #ifdef STUBBED_DICT - mainParams.dict = make_stubbed_dict( - MPPARM_NOCOMMA(mainParams.util->mpool) ); + mainParams.dict = + make_stubbed_dict( MPPARM_NOCOMMA(mainParams.util->mpool) ); XP_WARNF( "no dictionary provided: using English stub dict\n" ); - mainParams.gi.dictLang = dict_getLangCode( mainParams.dict ); ->>>>>>> android_branch + mainParams.pgi.dictLang = dict_getLangCode( mainParams.dict ); #else if ( 0 == nPlayerDicts ) { mainParams.needsNewGame = XP_TRUE; @@ -2278,34 +2245,8 @@ main( int argc, char** argv ) mainParams.needsNewGame = XP_TRUE; } -<<<<<<< HEAD - if ( 0 < mainParams.info.serverInfo.nRemotePlayers - && SERVER_STANDALONE == mainParams.pgi.serverRole ) { - mainParams.needsNewGame = XP_TRUE; - } - - /* per-player dicts are for local players only. Assign in the order - given. It's an error to give too many, or not to give enough if - there's no game-dict */ - if ( 0 < nPlayerDicts ) { - /* XP_U16 nextDict = 0; */ - /* for ( ii = 0; ii < mainParams.pgi.nPlayers; ++ii ) { */ - /* if ( mainParams.pgi.players[ii].isLocal ) { */ - /* const XP_UCHAR* name = mainParams.playerDictNames[nextDict++]; */ - /* XP_ASSERT( !!name ); */ - /* mainParams.dicts.dicts[ii] = */ - /* linux_dictionary_make( MPPARM(mainParams.mpool) */ - /* &mainParams, name, mainParams.useMmap ); */ - /* } */ - /* } */ - /* if ( nextDict < nPlayerDicts ) { */ - /* usage( argv[0], " --player-dict used more times than there are " */ - /* "local players" ); */ - /* } */ - } -======= if ( 0 < mainParams.info.serverInfo.nRemotePlayers - && SERVER_STANDALONE == mainParams.gi.serverRole ) { + && SERVER_STANDALONE == mainParams.pgi.serverRole ) { mainParams.needsNewGame = XP_TRUE; } @@ -2313,22 +2254,21 @@ main( int argc, char** argv ) given. It's an error to give too many, or not to give enough if there's no game-dict */ if ( 0 < nPlayerDicts ) { - XP_U16 nextDict = 0; - for ( ii = 0; ii < mainParams.gi.nPlayers; ++ii ) { - if ( mainParams.gi.players[ii].isLocal ) { - const XP_UCHAR* name = mainParams.playerDictNames[nextDict++]; - XP_ASSERT( !!name ); - mainParams.dicts.dicts[ii] = - linux_dictionary_make( MPPARM(mainParams.util->mpool) - &mainParams, name, mainParams.useMmap ); - } - } - if ( nextDict < nPlayerDicts ) { - usage( argv[0], " --player-dict used more times than there are " - "local players" ); - } + /* XP_U16 nextDict = 0; */ + /* for ( ii = 0; ii < mainParams.gi.nPlayers; ++ii ) { */ + /* if ( mainParams.gi.players[ii].isLocal ) { */ + /* const XP_UCHAR* name = mainParams.playerDictNames[nextDict++]; */ + /* XP_ASSERT( !!name ); */ + /* mainParams.dicts.dicts[ii] = */ + /* linux_dictionary_make( MPPARM(mainParams.util->mpool) */ + /* &mainParams, name, mainParams.useMmap ); */ + /* } */ + /* } */ + /* if ( nextDict < nPlayerDicts ) { */ + /* usage( argv[0], " --player-dict used more times than there are " */ + /* "local players" ); */ + /* } */ } ->>>>>>> android_branch /* if ( !isServer ) { */ /* if ( mainParams.info.serverInfo.nRemotePlayers > 0 ) { */ @@ -2336,17 +2276,11 @@ main( int argc, char** argv ) /* } */ /* } */ #ifdef XWFEATURE_WALKDICT -<<<<<<< HEAD - if ( !!testDicts ) { - walk_dict_test_all( mainParams.mpool, &mainParams, testDicts, testPrefixes, testMinMax ); - exit( 0 ); - } -======= if ( !!testDicts ) { - walk_dict_test_all( &mainParams, testDicts, testPrefixes, testMinMax ); + walk_dict_test_all( MPPARM(mainParams.mpool) &mainParams, testDicts, + testPrefixes, testMinMax ); exit( 0 ); } ->>>>>>> android_branch #endif if ( 0 ) { #ifdef XWFEATURE_RELAY @@ -2409,19 +2343,7 @@ main( int argc, char** argv ) /* mainParams.util->vtable->m_util_makeStreamFromAddr = */ /* linux_util_makeStreamFromAddr; */ -<<<<<<< HEAD - // mainParams.util->gameInfo = &mainParams.pgi; -======= - mainParams.util->gameInfo = &mainParams.gi; - - linux_util_vt_init( MPPARM(mainParams.util->mpool) mainParams.util ); - -#ifndef XWFEATURE_STANDALONE_ONLY - mainParams.util->vtable->m_util_informMissing = linux_util_informMissing; - mainParams.util->vtable->m_util_addrChange = linux_util_addrChange; - mainParams.util->vtable->m_util_setIsServer = linux_util_setIsServer; -#endif ->>>>>>> android_branch + // mainParams.util->gameInfo = &mainParams.pgi; srandom( seed ); /* init linux random number generator */ XP_LOGF( "seeded srandom with %d", seed ); @@ -2443,17 +2365,10 @@ main( int argc, char** argv ) mainParams.serverRole = SERVER_ISCLIENT; } -<<<<<<< HEAD - if ( mainParams.needsNewGame ) { - gi_disposePlayerInfo( MPPARM(mainParams.mpool) &mainParams.pgi ); - gi_initPlayerInfo( MPPARM(mainParams.mpool) &mainParams.pgi, NULL ); - } -======= if ( mainParams.needsNewGame ) { - gi_initPlayerInfo( MPPARM(mainParams.util->mpool) - &mainParams.gi, NULL ); + gi_disposePlayerInfo( MPPARM(mainParams.mpool) &mainParams.pgi ); + gi_initPlayerInfo( MPPARM(mainParams.mpool) &mainParams.pgi, NULL ); } ->>>>>>> android_branch /* curses doesn't have newgame dialog */ if ( useCurses && !mainParams.needsNewGame ) { @@ -2462,31 +2377,15 @@ main( int argc, char** argv ) #endif } else if ( !useCurses ) { #if defined PLATFORM_GTK -<<<<<<< HEAD - gtk_init( &argc, &argv ); - gtkmain( &mainParams ); -======= - gtkmain( &mainParams, argc, argv ); ->>>>>>> android_branch + gtk_init( &argc, &argv ); + gtkmain( &mainParams ); #endif } else { usage( argv[0], "rtfm" ); } -<<<<<<< HEAD - freeParams( &mainParams ); -======= - vtmgr_destroy( MPPARM(mainParams.util->mpool) mainParams.vtMgr ); - - linux_util_vt_destroy( mainParams.util ); - - mpool_destroy( mainParams.util->mpool ); - - free( mainParams.util ); - - result = 0; + freeParams( &mainParams ); } ->>>>>>> android_branch XP_LOGF( "%s exiting main", argv[0] ); return result; diff --git a/xwords4/relay/xwrelay.cpp b/xwords4/relay/xwrelay.cpp index 5d0cb9d84..f5c172f48 100644 --- a/xwords4/relay/xwrelay.cpp +++ b/xwords4/relay/xwrelay.cpp @@ -1104,7 +1104,7 @@ handleProxyMsgs( int sock, const AddrInfo* addr, const unsigned char* bufp, if ( getNetShort( &bufp, end, &len ) ) { if ( handlePutMessage( scr, hid, addr, len, &bufp, end ) ) { continue; - } + } } break; } @@ -1196,7 +1196,7 @@ proxy_thread_proc( UdpThreadClosure* utc ) int olen = 0; /* return a 0-length message */ write( socket, &olen, sizeof(olen) ); break; /* PRX_DEVICE_GONE */ - } + } default: logf( XW_LOGERROR, "unexpected command %d", __func__, cmd ); break;