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