fix curses version so discon_ok2 tests work again.

This commit is contained in:
Eric House 2013-01-07 20:40:46 -08:00
parent 565b742971
commit 76f3bb3413
7 changed files with 128 additions and 19 deletions

View file

@ -40,6 +40,7 @@
#include "linuxmain.h"
#include "linuxutl.h"
#include "linuxdict.h"
#include "cursesmain.h"
#include "cursesask.h"
#include "cursesletterask.h"
@ -1724,8 +1725,11 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
g_globals.cGlobals.cp.robotTradePct = params->robotTradePct;
#endif
setupUtil( &g_globals.cGlobals );
setupCursesUtilCallbacks( &g_globals, g_globals.cGlobals.util );
initFromParams( &g_globals.cGlobals, params );
#ifdef XWFEATURE_RELAY
if ( params->conType == COMMS_CONN_RELAY ) {
g_globals.cGlobals.defaultServerName
@ -1789,6 +1793,9 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
}
if ( !!stream ) {
if ( NULL == cGlobals->dict ) {
cGlobals->dict = makeDictForStream( cGlobals, stream );
}
(void)game_makeFromStream( MEMPOOL stream, &cGlobals->game,
&cGlobals->gi, cGlobals->dict, &cGlobals->dicts,
cGlobals->util,
@ -1844,6 +1851,11 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
}
#endif
if ( NULL == cGlobals->dict ) {
cGlobals->dict =
linux_dictionary_make( MEMPOOL params,
cGlobals->gi.dictName, XP_TRUE );
}
model_setDictionary( cGlobals->game.model, cGlobals->dict );
setSquareBonuses( cGlobals );
positionSizeStuff( &g_globals, width, height );
@ -1910,5 +1922,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
#endif
endwin();
linux_util_vt_destroy( g_globals.cGlobals.util );
} /* cursesmain */
#endif /* PLATFORM_NCURSES */

View file

@ -59,6 +59,7 @@
#include "gtkpasswdask.h"
#include "gtkntilesask.h"
#include "gtkaskdict.h"
#include "linuxdict.h"
/* #include "undo.h" */
#include "gtkdraw.h"
#include "memstream.h"
@ -434,16 +435,7 @@ createOrLoadObjects( GtkAppGlobals* globals )
if ( !!stream ) {
if ( NULL == cGlobals->dict ) {
CurGameInfo gi = {0};
XWStreamPos pos = stream_getPos( stream, POS_READ );
if ( !game_makeFromStream( MEMPOOL stream, NULL, &gi, NULL, NULL,
NULL, NULL, NULL, NULL ) ) {
XP_ASSERT(0);
}
stream_setPos( stream, POS_READ, pos );
cGlobals->dict = linux_dictionary_make( MEMPOOL params, gi.dictName, XP_TRUE );
gi_disposePlayerInfo( MEMPOOL &gi );
XP_ASSERT( !!cGlobals->dict );
cGlobals->dict = makeDictForStream( cGlobals, stream );
}
opened = game_makeFromStream( MEMPOOL stream, &cGlobals->game,
@ -2405,12 +2397,8 @@ initGlobals( GtkAppGlobals* globals, LaunchParams* params )
globals->cGlobals.cp.hideCrosshairs = params->hideCrosshairs;
#endif
XW_UtilCtxt* util = calloc( 1, sizeof(*globals->cGlobals.util) );
globals->cGlobals.util = util;
linux_util_vt_init( MPPARM(params->mpool) util );
util->gameInfo = &globals->cGlobals.gi;
setupLinuxUtilCallbacks( util );
setupGtkUtilCallbacks( globals, util );
setupUtil( &globals->cGlobals );
setupGtkUtilCallbacks( globals, globals->cGlobals.util );
globals->window = window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
if ( !!params->fileName ) {

29
xwords4/linux/linuxdict.h Normal file
View file

@ -0,0 +1,29 @@
/* -*- compile-command: "make MEMDEBUG=TRUE -j3"; -*- */
/*
* Copyright 2000 - 2013 by Eric House (xwords@eehouse.org). All rights
* reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _LINUXDICT_H_
#define _LINUXDICT_H_
DictionaryCtxt* linux_dictionary_make( MPFORMAL
const LaunchParams* mainParams,
const char* dictFileName,
XP_Bool useMMap );
#endif

View file

@ -58,6 +58,7 @@
#include "dictiter.h"
#include "main.h"
#include "gamesdb.h"
#include "linuxdict.h"
#ifdef PLATFORM_NCURSES
# include "cursesmain.h"
#endif
@ -151,6 +152,25 @@ streamFromDB( CommonGlobals* cGlobals, void* closure )
}
#endif
DictionaryCtxt*
makeDictForStream( CommonGlobals* cGlobals, XWStreamCtxt* stream )
{
CurGameInfo gi = {0};
XWStreamPos pos = stream_getPos( stream, POS_READ );
if ( !game_makeFromStream( MPPARM(cGlobals->util->mpool) stream, NULL, &gi,
NULL, NULL, NULL, NULL, NULL, NULL ) ) {
XP_ASSERT(0);
}
stream_setPos( stream, POS_READ, pos );
DictionaryCtxt* dict =
linux_dictionary_make( MPPARM(cGlobals->util->mpool) cGlobals->params,
gi.dictName, XP_TRUE );
gi_disposePlayerInfo( MPPARM(cGlobals->util->mpool) &gi );
XP_ASSERT( !!dict );
return dict;
}
void
writeToFile( XWStreamCtxt* stream, void* closure )
{
@ -1523,6 +1543,60 @@ setupLinuxUtilCallbacks( XW_UtilCtxt* util )
#endif
}
/* Set up cGlobals->gi and cGlobals->addr based on params fields */
void
initFromParams( CommonGlobals* cGlobals, LaunchParams* params )
{
LOG_FUNC();
/* CurGameInfo */
cGlobals->gi = params->pgi;
/* addr */
CommsAddrRec* addr = &cGlobals->addr;
XP_MEMSET( addr, 0, sizeof(*addr) );
if ( 0 ) {
#ifdef XWFEATURE_RELAY
} else if ( params->conType == COMMS_CONN_RELAY ) {
addr->conType = COMMS_CONN_RELAY;
addr->u.ip_relay.ipAddr = 0; /* ??? */
addr->u.ip_relay.port = params->connInfo.relay.defaultSendPort;
addr->u.ip_relay.seeksPublicRoom =
params->connInfo.relay.seeksPublicRoom;
addr->u.ip_relay.advertiseRoom = params->connInfo.relay.advertiseRoom;
XP_STRNCPY( addr->u.ip_relay.hostName,
params->connInfo.relay.relayName,
sizeof(addr->u.ip_relay.hostName) - 1 );
XP_STRNCPY( addr->u.ip_relay.invite, params->connInfo.relay.invite,
sizeof(addr->u.ip_relay.invite) - 1 );
#endif
#ifdef XWFEATURE_SMS
} else if ( params->conType == COMMS_CONN_SMS ) {
addr->conType = COMMS_CONN_SMS;
XP_STRNCPY( addr->u.sms.phone, params->connInfo.sms.serverPhone,
sizeof(addr->u.sms.phone) - 1 );
addr->u.sms.port = params->connInfo.sms.port;
#endif
#ifdef XWFEATURE_BLUETOOTH
} else if ( params->conType == COMMS_CONN_BT ) {
addr->conType = COMMS_CONN_BT;
XP_ASSERT( sizeof(addr->u.bt.btAddr)
>= sizeof(params->connInfo.bt.hostAddr));
XP_MEMCPY( &addr->u.bt.btAddr, &params->connInfo.bt.hostAddr,
sizeof(params->connInfo.bt.hostAddr) );
#endif
}
}
void
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;
setupLinuxUtilCallbacks( util );
}
static void
initParams( LaunchParams* params )
{

View file

@ -95,6 +95,11 @@ void setOneSecondTimer( CommonGlobals* cGlobals );
#endif
void setupLinuxUtilCallbacks( XW_UtilCtxt* util );
void initFromParams( CommonGlobals* cGlobals, LaunchParams* params );
void setupUtil( CommonGlobals* cGlobals );
DictionaryCtxt* makeDictForStream( CommonGlobals* cGlobals,
XWStreamCtxt* stream );
/* void initParams( LaunchParams* params ); */
/* void freeParams( LaunchParams* params ); */

View file

@ -31,6 +31,7 @@
#include "linuxutl.h"
#include "main.h"
#include "linuxdict.h"
#include "LocalizedStrIncludes.h"
#ifdef DEBUG

View file

@ -32,9 +32,6 @@ void linux_debugf(const char*, ...)
__attribute__ ((format (printf, 1, 2)));
#endif
DictionaryCtxt* linux_dictionary_make( MPFORMAL const LaunchParams* mainParams,
const char* dictFileName, XP_Bool useMMap );
void linux_util_vt_init( MPFORMAL XW_UtilCtxt* util );
void linux_util_vt_destroy( XW_UtilCtxt* util );
@ -49,6 +46,7 @@ XP_Bool storeNoConnMsg( CommonGlobals* cGlobals, const XP_U8* msg, XP_U16 len,
const XP_UCHAR* relayID );
void writeNoConnMsgs( CommonGlobals* cGlobals, int fd );
#ifdef STREAM_VERS_BIGBOARD
void setSquareBonuses( const CommonGlobals* cGlobals );
#else