mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
fix so curses app works well enough that discon_ok2.sh script runs
successfully. GTK mode is untested and certainly broken.
This commit is contained in:
parent
48fbf15a69
commit
5a20cc282c
5 changed files with 45 additions and 53 deletions
|
@ -240,7 +240,7 @@ curses_util_userPickTileBlank( XW_UtilCtxt* uc, XP_U16 playerNum,
|
|||
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
|
||||
char query[128];
|
||||
XP_S16 index;
|
||||
char* playerName = globals->cGlobals.gi.players[playerNum].name;
|
||||
char* playerName = globals->cGlobals.gi->players[playerNum].name;
|
||||
|
||||
snprintf( query, sizeof(query),
|
||||
"Pick tile for %s! (Tab or type letter to select "
|
||||
|
@ -258,7 +258,7 @@ curses_util_userPickTileTray( XW_UtilCtxt* uc, const PickInfo* XP_UNUSED(pi),
|
|||
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
|
||||
char query[128];
|
||||
XP_S16 index;
|
||||
char* playerName = globals->cGlobals.gi.players[playerNum].name;
|
||||
char* playerName = globals->cGlobals.gi->players[playerNum].name;
|
||||
|
||||
snprintf( query, sizeof(query),
|
||||
"Pick tile for %s! (Tab or type letter to select "
|
||||
|
@ -1631,7 +1631,7 @@ positionSizeStuff( CursesAppGlobals* globals, int width, int height )
|
|||
XP_U16 cellWidth, cellHt, scoreLeft, scoreWidth;
|
||||
BoardCtxt* board = globals->cGlobals.game.board;
|
||||
int remWidth = width;
|
||||
int nRows = globals->cGlobals.gi.boardSize;
|
||||
int nRows = globals->cGlobals.gi->boardSize;
|
||||
|
||||
cellWidth = CURSES_CELL_WIDTH;
|
||||
cellHt = CURSES_CELL_HT;
|
||||
|
@ -1917,6 +1917,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
|
|||
g_globals.cGlobals.cp.robotTradePct = params->robotTradePct;
|
||||
#endif
|
||||
|
||||
g_globals.cGlobals.gi = ¶ms->pgi;
|
||||
setupUtil( &g_globals.cGlobals );
|
||||
setupCursesUtilCallbacks( &g_globals, g_globals.cGlobals.util );
|
||||
|
||||
|
@ -2040,26 +2041,26 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
|
|||
} else {
|
||||
cGlobals->dict =
|
||||
linux_dictionary_make( MEMPOOL params,
|
||||
cGlobals->gi.dictName, XP_TRUE );
|
||||
cGlobals->gi->dictName, XP_TRUE );
|
||||
}
|
||||
}
|
||||
cGlobals->gi.dictLang = dict_getLangCode( cGlobals->dict );
|
||||
cGlobals->gi->dictLang = dict_getLangCode( cGlobals->dict );
|
||||
|
||||
if ( !!stream ) {
|
||||
(void)game_makeFromStream( MEMPOOL stream, &cGlobals->game,
|
||||
&cGlobals->gi, cGlobals->dict,
|
||||
cGlobals->gi, cGlobals->dict,
|
||||
&cGlobals->dicts, cGlobals->util,
|
||||
(DrawCtx*)g_globals.draw,
|
||||
&g_globals.cGlobals.cp, &procs );
|
||||
|
||||
stream_destroy( stream );
|
||||
if ( !isServer && cGlobals->gi.serverRole == SERVER_ISSERVER ) {
|
||||
if ( !isServer && cGlobals->gi->serverRole == SERVER_ISSERVER ) {
|
||||
isServer = XP_TRUE;
|
||||
}
|
||||
opened = XP_TRUE;
|
||||
}
|
||||
if ( !opened ) {
|
||||
game_makeNewGame( MEMPOOL &cGlobals->game, &cGlobals->gi,
|
||||
game_makeNewGame( MEMPOOL &cGlobals->game, cGlobals->gi,
|
||||
cGlobals->util, (DrawCtx*)g_globals.draw,
|
||||
&g_globals.cGlobals.cp, &procs, params->gameSeed );
|
||||
g_globals.cGlobals.selRow = -1;
|
||||
|
@ -2159,7 +2160,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
|
|||
saveGame( &g_globals.cGlobals );
|
||||
|
||||
game_dispose( &g_globals.cGlobals.game ); /* takes care of the dict */
|
||||
gi_disposePlayerInfo( MEMPOOL &cGlobals->gi );
|
||||
gi_disposePlayerInfo( MEMPOOL cGlobals->gi );
|
||||
|
||||
#ifdef XWFEATURE_BLUETOOTH
|
||||
linux_bt_close( &g_globals.cGlobals );
|
||||
|
|
|
@ -476,8 +476,8 @@ createOrLoadObjects( GtkGameGlobals* globals )
|
|||
}
|
||||
|
||||
opened = game_makeFromStream( MEMPOOL stream, &cGlobals->game,
|
||||
&cGlobals->gi,
|
||||
cGlobals->dict, &cGlobals->dicts, cGlobals->util,
|
||||
cGlobals->gi, cGlobals->dict,
|
||||
&cGlobals->dicts, cGlobals->util,
|
||||
(DrawCtx*)globals->draw,
|
||||
&cGlobals->cp, &procs );
|
||||
XP_LOGF( "%s: loaded gi at %p", __func__, &cGlobals->gi );
|
||||
|
@ -497,7 +497,7 @@ createOrLoadObjects( GtkGameGlobals* globals )
|
|||
/* = params->connInfo.relay.relayName; */
|
||||
/* } */
|
||||
#endif
|
||||
game_makeNewGame( MEMPOOL &cGlobals->game, &cGlobals->gi,
|
||||
game_makeNewGame( MEMPOOL &cGlobals->game, cGlobals->gi,
|
||||
cGlobals->util, (DrawCtx*)globals->draw,
|
||||
&cGlobals->cp, &procs, params->gameSeed );
|
||||
|
||||
|
@ -550,7 +550,7 @@ createOrLoadObjects( GtkGameGlobals* globals )
|
|||
model_setPlayerDicts( cGlobals->game.model, &cGlobals->dicts );
|
||||
|
||||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
cGlobals->gi.allowHintRect = params->allowHintRect;
|
||||
cGlobals->gi->allowHintRect = params->allowHintRect;
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -558,7 +558,7 @@ createOrLoadObjects( GtkGameGlobals* globals )
|
|||
new_game_impl( globals, XP_FALSE );
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
} else {
|
||||
DeviceRole serverRole = cGlobals->gi.serverRole;
|
||||
DeviceRole serverRole = cGlobals->gi->serverRole;
|
||||
if ( serverRole == SERVER_ISCLIENT ) {
|
||||
XWStreamCtxt* stream =
|
||||
mem_stream_make( MEMPOOL params->vtMgr,
|
||||
|
@ -608,7 +608,7 @@ configure_event( GtkWidget* widget, GdkEventConfigure* XP_UNUSED(event),
|
|||
createOrLoadObjects( globals );
|
||||
}
|
||||
|
||||
nCols = globals->cGlobals.gi.boardSize;
|
||||
nCols = globals->cGlobals.gi->boardSize;
|
||||
nRows = nCols;
|
||||
bdWidth = widget->allocation.width - (GTK_RIGHT_MARGIN
|
||||
+ GTK_BOARD_LEFT_MARGIN);
|
||||
|
@ -767,7 +767,7 @@ cleanup( GtkGameGlobals* globals )
|
|||
linux_close_socket( &globals->cGlobals );
|
||||
#endif
|
||||
game_dispose( &globals->cGlobals.game ); /* takes care of the dict */
|
||||
gi_disposePlayerInfo( MEMPOOL &globals->cGlobals.gi );
|
||||
gi_disposePlayerInfo( MEMPOOL globals->cGlobals.gi );
|
||||
|
||||
linux_util_vt_destroy( globals->cGlobals.util );
|
||||
free( globals->cGlobals.util );
|
||||
|
@ -862,7 +862,7 @@ new_game_impl( GtkGameGlobals* globals, XP_Bool fireConnDlg )
|
|||
comms_getInitialAddr( &addr, RELAY_NAME_DEFAULT, RELAY_PORT_DEFAULT );
|
||||
}
|
||||
|
||||
CurGameInfo* gi = &globals->cGlobals.gi;
|
||||
CurGameInfo* gi = globals->cGlobals.gi;
|
||||
success = newGameDialog( globals, gi, &addr, XP_TRUE, fireConnDlg );
|
||||
if ( success ) {
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
|
@ -934,7 +934,7 @@ game_info( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
|
||||
/* Anything to do if OK is clicked? Changed names etc. already saved. Try
|
||||
server_do in case one's become a robot. */
|
||||
CurGameInfo* gi = &globals->cGlobals.gi;
|
||||
CurGameInfo* gi = globals->cGlobals.gi;
|
||||
if ( newGameDialog( globals, gi, &addr, XP_FALSE, XP_FALSE ) ) {
|
||||
if ( server_do( globals->cGlobals.game.server ) ) {
|
||||
board_draw( globals->cGlobals.game.board );
|
||||
|
@ -968,7 +968,7 @@ change_dictionary( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
linux_dictionary_make( MPPARM(cGlobals->util->mpool) params, name,
|
||||
params->useMmap );
|
||||
game_changeDict( MPPARM(cGlobals->util->mpool) &cGlobals->game,
|
||||
&cGlobals->gi, dict );
|
||||
cGlobals->gi, dict );
|
||||
}
|
||||
g_slist_free( dicts );
|
||||
} /* change_dictionary */
|
||||
|
@ -1375,7 +1375,7 @@ handle_hide_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
XP_Bool draw = XP_FALSE;
|
||||
|
||||
if ( globals->cGlobals.params->nHidden > 0 ) {
|
||||
gint nRows = globals->cGlobals.gi.boardSize;
|
||||
gint nRows = globals->cGlobals.gi->boardSize;
|
||||
globals->adjustment->page_size = nRows;
|
||||
globals->adjustment->value = 0.0;
|
||||
|
||||
|
@ -1430,7 +1430,7 @@ gtk_util_userPickTileBlank( XW_UtilCtxt* uc, XP_U16 playerNum,
|
|||
{
|
||||
XP_S16 chosen;
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
XP_UCHAR* name = globals->cGlobals.gi.players[playerNum].name;
|
||||
XP_UCHAR* name = globals->cGlobals.gi->players[playerNum].name;
|
||||
|
||||
chosen = gtkletterask( NULL, XP_FALSE, name, nTiles, texts );
|
||||
return chosen;
|
||||
|
@ -1443,7 +1443,7 @@ gtk_util_userPickTileTray( XW_UtilCtxt* uc, const PickInfo* pi,
|
|||
{
|
||||
XP_S16 chosen;
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
XP_UCHAR* name = globals->cGlobals.gi.players[playerNum].name;
|
||||
XP_UCHAR* name = globals->cGlobals.gi->players[playerNum].name;
|
||||
|
||||
chosen = gtkletterask( pi, XP_TRUE, name, nTiles, texts );
|
||||
return chosen;
|
||||
|
@ -1498,7 +1498,7 @@ gtk_util_yOffsetChange( XW_UtilCtxt* uc, XP_U16 maxOffset,
|
|||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
if ( !!globals->adjustment ) {
|
||||
gint nRows = globals->cGlobals.gi.boardSize;
|
||||
gint nRows = globals->cGlobals.gi->boardSize;
|
||||
globals->adjustment->page_size = nRows - maxOffset;
|
||||
globals->adjustment->value = newOffset;
|
||||
gtk_adjustment_value_changed( GTK_ADJUSTMENT(globals->adjustment) );
|
||||
|
@ -1801,7 +1801,7 @@ gtk_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi, XP_U16 player,
|
|||
if ( turnLost ) {
|
||||
char wordsBuf[256];
|
||||
XP_U16 i;
|
||||
XP_UCHAR* name = globals->cGlobals.gi.players[player].name;
|
||||
XP_UCHAR* name = globals->cGlobals.gi->players[player].name;
|
||||
XP_ASSERT( !!name );
|
||||
|
||||
for ( i = 0, wordsBuf[0] = '\0'; ; ) {
|
||||
|
@ -2415,7 +2415,7 @@ initGlobalsNoDraw( GtkGameGlobals* globals, LaunchParams* params )
|
|||
{
|
||||
memset( globals, 0, sizeof(*globals) );
|
||||
|
||||
gi_copy( MPPARM(params->mpool) &globals->cGlobals.gi, ¶ms->pgi );
|
||||
gi_copy( MPPARM(params->mpool) globals->cGlobals.gi, ¶ms->pgi );
|
||||
|
||||
globals->cGlobals.params = params;
|
||||
globals->cGlobals.lastNTilesToUse = MAX_TRAY_TILES;
|
||||
|
@ -2514,7 +2514,7 @@ initGlobals( GtkGameGlobals* globals, LaunchParams* params )
|
|||
/* install scrollbar even if not needed -- since zooming can make it
|
||||
needed later */
|
||||
GtkWidget* vscrollbar;
|
||||
gint nRows = globals->cGlobals.gi.boardSize;
|
||||
gint nRows = globals->cGlobals.gi->boardSize;
|
||||
globals->adjustment = (GtkAdjustment*)
|
||||
gtk_adjustment_new( 0, 0, nRows, 1, 2,
|
||||
nRows - globals->cGlobals.params->nHidden );
|
||||
|
@ -2597,8 +2597,8 @@ loadGameNoDraw( GtkGameGlobals* globals, LaunchParams* params,
|
|||
cGlobals->dict = makeDictForStream( cGlobals, stream );
|
||||
}
|
||||
loaded = game_makeFromStream( MEMPOOL stream, &cGlobals->game,
|
||||
&cGlobals->gi,
|
||||
cGlobals->dict, &cGlobals->dicts, cGlobals->util,
|
||||
cGlobals->gi, cGlobals->dict,
|
||||
&cGlobals->dicts, cGlobals->util,
|
||||
(DrawCtx*)NULL, &cGlobals->cp, &procs );
|
||||
if ( loaded ) {
|
||||
XP_LOGF( "%s: game loaded", __func__ );
|
||||
|
@ -2632,7 +2632,7 @@ makeNewGame( GtkGameGlobals* globals )
|
|||
comms_getInitialAddr( &cGlobals->addr, relayName, relayPort );
|
||||
}
|
||||
|
||||
CurGameInfo* gi = &cGlobals->gi;
|
||||
CurGameInfo* gi = cGlobals->gi;
|
||||
XP_Bool success = newGameDialog( globals, gi, &cGlobals->addr,
|
||||
XP_TRUE, XP_FALSE );
|
||||
if ( success && !!gi->dictName && !cGlobals->dict ) {
|
||||
|
|
|
@ -296,7 +296,7 @@ void
|
|||
catFinalScores( const CommonGlobals* cGlobals, XP_S16 quitter )
|
||||
{
|
||||
XWStreamCtxt* stream;
|
||||
XP_ASSERT( quitter < cGlobals->gi.nPlayers );
|
||||
XP_ASSERT( quitter < cGlobals->gi->nPlayers );
|
||||
|
||||
stream = mem_stream_make( MPPARM(cGlobals->util->mpool)
|
||||
cGlobals->params->vtMgr,
|
||||
|
@ -304,7 +304,7 @@ catFinalScores( const CommonGlobals* cGlobals, XP_S16 quitter )
|
|||
if ( -1 != quitter ) {
|
||||
XP_UCHAR buf[128];
|
||||
XP_SNPRINTF( buf, VSIZE(buf), "Player %s resigned\n",
|
||||
cGlobals->gi.players[quitter].name );
|
||||
cGlobals->gi->players[quitter].name );
|
||||
stream_catString( stream, buf );
|
||||
}
|
||||
server_writeFinalScores( cGlobals->game.server, stream );
|
||||
|
@ -348,8 +348,7 @@ saveGame( CommonGlobals* cGlobals )
|
|||
cGlobals, 0, onClose );
|
||||
stream_open( outStream );
|
||||
|
||||
game_saveToStream( &cGlobals->game,
|
||||
&cGlobals->gi,
|
||||
game_saveToStream( &cGlobals->game, cGlobals->gi,
|
||||
outStream, ++cGlobals->curSaveToken );
|
||||
cGlobals->lastStreamSize = stream_getSize( outStream );
|
||||
stream_destroy( outStream );
|
||||
|
@ -380,7 +379,7 @@ handle_messages_from( CommonGlobals* cGlobals, const TransportProcs* procs,
|
|||
#endif
|
||||
game_makeFromStream( MPPARM(cGlobals->util->mpool)
|
||||
stream, &cGlobals->game,
|
||||
&cGlobals->gi, cGlobals->dict,
|
||||
cGlobals->gi, cGlobals->dict,
|
||||
&cGlobals->dicts, cGlobals->util,
|
||||
NULL /*draw*/,
|
||||
&cGlobals->cp, procs );
|
||||
|
@ -441,7 +440,7 @@ read_pipe_then_close( CommonGlobals* cGlobals, const TransportProcs* procs )
|
|||
#endif
|
||||
game_makeFromStream( MPPARM(cGlobals->util->mpool)
|
||||
stream, &cGlobals->game,
|
||||
&cGlobals->gi, cGlobals->dict,
|
||||
cGlobals->gi, cGlobals->dict,
|
||||
&cGlobals->dicts, cGlobals->util,
|
||||
NULL /*draw*/,
|
||||
&cGlobals->cp, procs );
|
||||
|
@ -1363,7 +1362,7 @@ linuxSetIsServer( CommonGlobals* cGlobals, XP_Bool isServer )
|
|||
XP_LOGF( "%s(isServer=%d)", __func__, isServer );
|
||||
DeviceRole newRole = isServer? SERVER_ISSERVER : SERVER_ISCLIENT;
|
||||
cGlobals->params->serverRole = newRole;
|
||||
cGlobals->gi.serverRole = newRole;
|
||||
cGlobals->gi->serverRole = newRole;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1371,7 +1370,7 @@ linuxChangeRoles( CommonGlobals* cGlobals )
|
|||
{
|
||||
ServerCtxt* server = cGlobals->game.server;
|
||||
server_reset( server, cGlobals->game.comms );
|
||||
if ( SERVER_ISCLIENT == cGlobals->gi.serverRole ) {
|
||||
if ( SERVER_ISCLIENT == cGlobals->gi->serverRole ) {
|
||||
XWStreamCtxt* stream =
|
||||
mem_stream_make( MPPARM(cGlobals->util->mpool) cGlobals->params->vtMgr,
|
||||
cGlobals, CHANNEL_NONE, sendOnClose );
|
||||
|
@ -1781,7 +1780,7 @@ initFromParams( CommonGlobals* cGlobals, LaunchParams* params )
|
|||
{
|
||||
LOG_FUNC();
|
||||
/* CurGameInfo */
|
||||
cGlobals->gi = params->pgi;
|
||||
cGlobals->gi = ¶ms->pgi;
|
||||
|
||||
/* addr */
|
||||
CommsAddrRec* addr = &cGlobals->addr;
|
||||
|
@ -1825,7 +1824,7 @@ setupUtil( CommonGlobals* cGlobals )
|
|||
XW_UtilCtxt* util = calloc( 1, sizeof(*util) );
|
||||
cGlobals->util = util;
|
||||
linux_util_vt_init( MPPARM(cGlobals->params->mpool) util );
|
||||
util->gameInfo = &cGlobals->gi;
|
||||
util->gameInfo = cGlobals->gi;
|
||||
setupLinuxUtilCallbacks( util );
|
||||
}
|
||||
|
||||
|
@ -1853,18 +1852,10 @@ initParams( LaunchParams* params )
|
|||
static void
|
||||
freeParams( LaunchParams* params )
|
||||
{
|
||||
XP_U16 ii;
|
||||
// linux_util_vt_destroy( params->util );
|
||||
vtmgr_destroy( MPPARM(params->mpool) params->vtMgr );
|
||||
|
||||
// XP_FREEP( params->mpool, ¶ms->pgi.dictName );
|
||||
for ( ii = 0; ii < params->nLocalPlayers; ++ii ) {
|
||||
XP_FREEP( params->mpool, ¶ms->pgi.players[ii].name );
|
||||
}
|
||||
|
||||
gi_disposePlayerInfo( MPPARM(params->mpool) ¶ms->pgi );
|
||||
mpool_destroy( params->mpool );
|
||||
|
||||
// free( params->util );
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2013,7 +2004,7 @@ main( int argc, char** argv )
|
|||
conType == COMMS_CONN_RELAY );
|
||||
mainParams.connInfo.relay.invite = optarg;
|
||||
conType = COMMS_CONN_RELAY;
|
||||
isServer = XP_TRUE; /* implicit */
|
||||
// isServer = XP_TRUE; /* implicit */
|
||||
break;
|
||||
#endif
|
||||
case CMD_HOSTIP:
|
||||
|
@ -2304,7 +2295,7 @@ main( int argc, char** argv )
|
|||
}
|
||||
}
|
||||
|
||||
int result;
|
||||
int result = 0;
|
||||
if ( g_str_has_suffix( argv[0], "dawg2dict" ) ) {
|
||||
result = dawg2dict( &mainParams, testDicts );
|
||||
} else {
|
||||
|
@ -2503,7 +2494,7 @@ main( int argc, char** argv )
|
|||
freeParams( &mainParams );
|
||||
}
|
||||
|
||||
XP_LOGF( "%s exiting main", argv[0] );
|
||||
XP_LOGF( "%s exiting main, returning %d", argv[0], result );
|
||||
return result;
|
||||
} /* main */
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ setSquareBonuses( const CommonGlobals* cGlobals )
|
|||
{
|
||||
XP_U16 nBonuses;
|
||||
XWBonusType* bonuses =
|
||||
bonusesFor( cGlobals->gi.boardSize, &nBonuses );
|
||||
bonusesFor( cGlobals->gi->boardSize, &nBonuses );
|
||||
if ( !!bonuses ) {
|
||||
model_setSquareBonuses( cGlobals->game.model, bonuses, nBonuses );
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ struct CommonGlobals {
|
|||
XW_UtilCtxt* util;
|
||||
|
||||
XWGame game;
|
||||
CurGameInfo gi;
|
||||
CurGameInfo* gi;
|
||||
CommsAddrRec addr;
|
||||
DictionaryCtxt* dict;
|
||||
PlayerDicts dicts;
|
||||
|
|
Loading…
Reference in a new issue