snapshot. New game button works and game gets saved in DB. Next: display and open from DB.

This commit is contained in:
Eric House 2013-01-05 16:08:19 -08:00
parent 63487dc5d0
commit 4af30c534c
22 changed files with 2927 additions and 2630 deletions

View file

@ -377,14 +377,16 @@ public class CommsTransport implements TransportProcs,
switch ( addr.conType ) {
case COMMS_CONN_RELAY:
if ( NetStateCache.netAvail( m_context ) ) {
putOut( buf ); // add to queue
if ( null == m_thread ) {
m_thread = new CommsThread();
m_thread.start();
}
nSent = buf.length;
}
nSent = RelayService.sendPacket( m_context, addr.sms_phone,
gameID, buf );
// if ( NetStateCache.netAvail( m_context ) ) {
// putOut( buf ); // add to queue
// if ( null == m_thread ) {
// m_thread = new CommsThread();
// m_thread.start();
// }
// nSent = buf.length;
// }
break;
case COMMS_CONN_SMS:
nSent = SMSService.sendPacket( m_context, addr.sms_phone,

View file

@ -133,13 +133,15 @@ game_makeNewGame( MPFORMAL XWGame* game, CurGameInfo* gi,
board_prefsChanged( game->board, cp );
} /* game_makeNewGame */
void
XP_Bool
game_reset( MPFORMAL XWGame* game, CurGameInfo* gi,
XW_UtilCtxt* XP_UNUSED_STANDALONE(util),
CommonPrefs* cp, const TransportProcs* procs )
{
XP_Bool result = XP_FALSE;
XP_U16 ii;
if ( !!game->model ) {
XP_ASSERT( !!game->model );
XP_ASSERT( !!gi );
@ -189,6 +191,9 @@ game_reset( MPFORMAL XWGame* game, CurGameInfo* gi,
server_prefsChanged( game->server, cp );
board_prefsChanged( game->board, cp );
result = XP_TRUE;
}
return result;
} /* game_reset */
#ifdef XWFEATURE_CHANGEDICT

View file

@ -93,7 +93,7 @@ void game_makeNewGame( MPFORMAL XWGame* game, CurGameInfo* gi,
,XP_U16 gameSeed
#endif
);
void game_reset( MPFORMAL XWGame* game, CurGameInfo* gi, XW_UtilCtxt* util,
XP_Bool game_reset( MPFORMAL XWGame* game, CurGameInfo* gi, XW_UtilCtxt* util,
CommonPrefs* cp, const TransportProcs* procs );
void game_changeDict( MPFORMAL XWGame* game, CurGameInfo* gi,
DictionaryCtxt* dict );

View file

@ -169,6 +169,7 @@ INCLUDES += ${EXTRAINCS}
ifdef DO_GTK
GTK_OBJS = \
$(BUILD_PLAT_DIR)/gtkmain.o \
$(BUILD_PLAT_DIR)/gtkboard.o \
$(BUILD_PLAT_DIR)/gtkdraw.o \
$(BUILD_PLAT_DIR)/gtkask.o \
$(BUILD_PLAT_DIR)/gtkletterask.o \
@ -201,6 +202,7 @@ OBJ = \
$(BUILD_PLAT_DIR)/linuxsms.o \
$(BUILD_PLAT_DIR)/linuxdict.o \
$(BUILD_PLAT_DIR)/linuxutl.o \
$(BUILD_PLAT_DIR)/gamesdb.o \
$(CURSES_OBJS) $(GTK_OBJS) $(MAIN_OBJS)
LIBS = -lm -luuid $(GPROFFLAG)

53
xwords4/linux/gamesdb.c Normal file
View file

@ -0,0 +1,53 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make MEMDEBUG=TRUE -j3"; -*- */
/*
* Copyright 2000-2012 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.
*/
#include <sqlite3.h>
#include "comtypes.h"
#include "gamesdb.h"
#define DB_NAME "games.db"
sqlite3*
openGamesDB( void )
{
sqlite3* pDb = NULL;
int result = sqlite3_open( DB_NAME, &pDb );
XP_ASSERT( SQLITE_OK == result );
const char* createStr =
"CREATE TABLE games ( "
"game BLOB"
",room VARCHAR(32)"
")";
result = sqlite3_exec( pDb, createStr, NULL, NULL, NULL );
XP_LOGF( "sqlite3_exec=>%d", result );
// XP_ASSERT( SQLITE_OK == result );
return pDb;
}
void
closeGamesDB( sqlite3* pDb )
{
sqlite3_close( pDb );
XP_LOGF( "%s finished", __func__ );
}

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

@ -0,0 +1,29 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make MEMDEBUG=TRUE -j3"; -*- */
/*
* Copyright 2000-2012 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 _GAMESDB_H_
#define _GAMESDB_H_
#include <sqlite3.h>
sqlite3* openGamesDB( void );
void closeGamesDB( sqlite3* dbp );
#endif

View file

@ -23,7 +23,7 @@
#ifndef _GTKASK_H_
#define _GTKASK_H_
#include "gtkmain.h"
#include "gtkboard.h"
/* Returns true for "yes" or "ok" answer, false otherwise.
*/

View file

@ -23,7 +23,7 @@
#ifndef _GTKASKDICT_H_
#define _GTKASKDICT_H_
#include "gtkmain.h"
#include "gtkboard.h"
gchar* gtkaskdict( GSList* dicts, gchar* buf, gint buflen );

2485
xwords4/linux/gtkboard.c Normal file

File diff suppressed because it is too large Load diff

176
xwords4/linux/gtkboard.h Normal file
View file

@ -0,0 +1,176 @@
/* -*- mode: C; fill-column: 78; c-basic-offset: 4; -*- */
/* Copyright 1997 - 2005 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 _GTKBOARD_H_
#define _GTKBOARD_H_
#ifdef PLATFORM_GTK
#include <gtk/gtk.h>
#include <sys/time.h>
#include <pango/pango-font.h>
#include <glib.h>
#include "draw.h"
#include "main.h"
#include "game.h"
#include "dictnry.h"
enum {
LAYOUT_BOARD
,LAYOUT_SMALL
,LAYOUT_LARGE
,LAYOUT_NLAYOUTS
};
#define MAX_SCORE_LEN 31
typedef struct GtkDrawCtx {
DrawCtxVTable* vtable;
/* GdkDrawable* pixmap; */
GtkWidget* drawing_area;
struct GtkAppGlobals* globals;
#ifdef USE_CAIRO
cairo_t* cr;
#else
GdkGC* drawGC;
#endif
GdkColor black;
GdkColor white;
GdkColor red; /* for pending tiles */
GdkColor tileBack; /* for pending tiles */
GdkColor cursor;
GdkColor bonusColors[4];
GdkColor playerColors[MAX_NUM_PLAYERS];
/* new for gtk 2.0 */
PangoContext* pangoContext;
GList* fontsPerSize;
struct {
XP_UCHAR str[MAX_SCORE_LEN+1];
XP_U16 fontHt;
} scoreCache[MAX_NUM_PLAYERS];
XP_U16 trayOwner;
XP_U16 cellWidth;
XP_U16 cellHeight;
XP_Bool scoreIsVertical;
} GtkDrawCtx;
typedef struct ClientStreamRec {
XWStreamCtxt* stream;
guint key;
int sock;
} ClientStreamRec;
typedef struct GtkAppGlobals {
CommonGlobals cGlobals;
GtkWidget* window;
GtkDrawCtx* draw;
/* GdkPixmap* pixmap; */
GtkWidget* drawing_area;
GtkWidget* flip_button;
GtkWidget* zoomin_button;
GtkWidget* zoomout_button;
GtkWidget* toggle_undo_button;
GtkWidget* prevhint_button;
GtkWidget* nexthint_button;
#ifdef XWFEATURE_CHAT
GtkWidget* chat_button;
#endif
EngineCtxt* engine;
guint idleID;
struct timeval scoreTv; /* for timer */
XP_U32 scoreTimerInterval;
GtkAdjustment* adjustment;
ClientStreamRec clientRecs[MAX_NUM_PLAYERS];
guint timerSources[NUM_TIMERS_PLUS_ONE - 1];
#ifndef XWFEATURE_STANDALONE_ONLY
XP_U16 netStatLeft, netStatTop;
XP_UCHAR stateChar;
#endif
XP_Bool gridOn;
XP_Bool dropIncommingMsgs;
XP_Bool mouseDown;
XP_Bool altKeyDown;
#ifdef KEYBOARD_NAV
XP_Bool keyDown;
#endif
} GtkAppGlobals;
/* DictionaryCtxt* gtk_dictionary_make(); */
#define GTK_MIN_SCALE 12 /* was 14 */
#define GTK_MIN_TRAY_SCALEH 24
#define GTK_MIN_TRAY_SCALEV GTK_MIN_TRAY_SCALEH
#define GTK_TRAYPAD_WIDTH 2
#define GTK_TOP_MARGIN 0 /* was 2 */
#define GTK_BOARD_LEFT_MARGIN 2
#define GTK_TRAY_LEFT_MARGIN 2
#define GTK_SCORE_BOARD_PADDING 0
#define GTK_HOR_SCORE_LEFT (GTK_BOARD_LEFT_MARGIN)
#define GTK_HOR_SCORE_HEIGHT 12
#define GTK_TIMER_HEIGHT GTK_HOR_SCORE_HEIGHT
#define GTK_HOR_SCORE_TOP (GTK_TOP_MARGIN)
#define GTK_TIMER_PAD 10
#define GTK_VERT_SCORE_TOP (GTK_TIMER_HEIGHT + GTK_TIMER_PAD)
#define GTK_VERT_SCORE_HEIGHT ((MIN_SCALE*MAX_COLS) - GTK_TIMER_HEIGHT - \
GTK_TIMER_PAD)
#define GTK_TIMER_WIDTH 40
#define GTK_NETSTAT_WIDTH 20
#define GTK_TIMER_TOP GTK_HOR_SCORE_TOP
#define GTK_HOR_SCORE_WIDTH ((GTK_MIN_SCALE*20)-GTK_TIMER_PAD)
#define GTK_VERT_SCORE_WIDTH 40
#define GTK_BOARD_TOP (GTK_SCORE_TOP + GTK_SCORE_HEIGHT \
+ GTK_SCORE_BOARD_PADDING )
#define GTK_BOARD_LEFT (GTK_BOARD_LEFT_MARGIN)
#define GTK_TRAY_LEFT GTK_TRAY_LEFT_MARGIN
#define GTK_DIVIDER_WIDTH 5
#define GTK_BOTTOM_MARGIN GTK_TOP_MARGIN
#define GTK_RIGHT_MARGIN GTK_BOARD_LEFT_MARGIN
void initGlobals( GtkAppGlobals* globals, LaunchParams* params );
void freeGlobals( GtkAppGlobals* globals );
XP_Bool makeNewGame( GtkAppGlobals* globals );
#endif /* PLATFORM_GTK */
#endif

View file

@ -23,7 +23,7 @@
#ifdef PLATFORM_GTK
#include <glib.h>
#include "gtkmain.h"
#include "gtkboard.h"
gchar* gtkGetChatMessage( GtkAppGlobals* globals );

View file

@ -24,7 +24,7 @@
#ifndef _GTKCONNSDLG_H_
#define _GTKCONNSDLG_H_
#include "gtkmain.h"
#include "gtkboard.h"
gboolean gtkConnsDlg( GtkAppGlobals* globals, CommsAddrRec* addr,
DeviceRole role, XP_Bool readOnly );

View file

@ -26,7 +26,7 @@
#include <gdk/gdkdrawable.h>
#include "gtkmain.h"
#include "gtkboard.h"
#include "draw.h"
#include "board.h"
#include "linuxmain.h"

View file

@ -24,7 +24,7 @@
#ifndef _GTKLETTERASK_H_
#define _GTKLETTERASK_H_
#include "gtkmain.h"
#include "gtkboard.h"
XP_S16 gtkletterask( const PickInfo* pi, XP_Bool forTray,
const XP_UCHAR* name,

File diff suppressed because it is too large Load diff

View file

@ -20,154 +20,8 @@
#ifndef _GTKMAIN_H_
#define _GTKMAIN_H_
#ifdef PLATFORM_GTK
#include <gtk/gtk.h>
#include <sys/time.h>
#include <pango/pango-font.h>
#include <glib.h>
#include "draw.h"
#include "main.h"
#include "game.h"
#include "dictnry.h"
enum {
LAYOUT_BOARD
,LAYOUT_SMALL
,LAYOUT_LARGE
,LAYOUT_NLAYOUTS
};
#define MAX_SCORE_LEN 31
typedef struct GtkDrawCtx {
DrawCtxVTable* vtable;
/* GdkDrawable* pixmap; */
GtkWidget* drawing_area;
struct GtkAppGlobals* globals;
#ifdef USE_CAIRO
cairo_t* cr;
#else
GdkGC* drawGC;
#endif
GdkColor black;
GdkColor white;
GdkColor red; /* for pending tiles */
GdkColor tileBack; /* for pending tiles */
GdkColor cursor;
GdkColor bonusColors[4];
GdkColor playerColors[MAX_NUM_PLAYERS];
/* new for gtk 2.0 */
PangoContext* pangoContext;
GList* fontsPerSize;
struct {
XP_UCHAR str[MAX_SCORE_LEN+1];
XP_U16 fontHt;
} scoreCache[MAX_NUM_PLAYERS];
XP_U16 trayOwner;
XP_U16 cellWidth;
XP_U16 cellHeight;
XP_Bool scoreIsVertical;
} GtkDrawCtx;
typedef struct ClientStreamRec {
XWStreamCtxt* stream;
guint key;
int sock;
} ClientStreamRec;
typedef struct GtkAppGlobals {
CommonGlobals cGlobals;
GtkWidget* window;
GtkDrawCtx* draw;
/* GdkPixmap* pixmap; */
GtkWidget* drawing_area;
GtkWidget* flip_button;
GtkWidget* zoomin_button;
GtkWidget* zoomout_button;
GtkWidget* toggle_undo_button;
GtkWidget* prevhint_button;
GtkWidget* nexthint_button;
#ifdef XWFEATURE_CHAT
GtkWidget* chat_button;
#endif
EngineCtxt* engine;
guint idleID;
struct timeval scoreTv; /* for timer */
XP_U32 scoreTimerInterval;
GtkAdjustment* adjustment;
ClientStreamRec clientRecs[MAX_NUM_PLAYERS];
guint timerSources[NUM_TIMERS_PLUS_ONE - 1];
#ifndef XWFEATURE_STANDALONE_ONLY
XP_U16 netStatLeft, netStatTop;
XP_UCHAR stateChar;
#endif
XP_Bool gridOn;
XP_Bool dropIncommingMsgs;
XP_Bool mouseDown;
XP_Bool altKeyDown;
#ifdef KEYBOARD_NAV
XP_Bool keyDown;
#endif
} GtkAppGlobals;
/* DictionaryCtxt* gtk_dictionary_make(); */
int gtkmain( LaunchParams* params, int argc, char *argv[] );
#define GTK_MIN_SCALE 12 /* was 14 */
#define GTK_MIN_TRAY_SCALEH 24
#define GTK_MIN_TRAY_SCALEV GTK_MIN_TRAY_SCALEH
#define GTK_TRAYPAD_WIDTH 2
#define GTK_TOP_MARGIN 0 /* was 2 */
#define GTK_BOARD_LEFT_MARGIN 2
#define GTK_TRAY_LEFT_MARGIN 2
#define GTK_SCORE_BOARD_PADDING 0
#define GTK_HOR_SCORE_LEFT (GTK_BOARD_LEFT_MARGIN)
#define GTK_HOR_SCORE_HEIGHT 12
#define GTK_TIMER_HEIGHT GTK_HOR_SCORE_HEIGHT
#define GTK_HOR_SCORE_TOP (GTK_TOP_MARGIN)
#define GTK_TIMER_PAD 10
#define GTK_VERT_SCORE_TOP (GTK_TIMER_HEIGHT + GTK_TIMER_PAD)
#define GTK_VERT_SCORE_HEIGHT ((MIN_SCALE*MAX_COLS) - GTK_TIMER_HEIGHT - \
GTK_TIMER_PAD)
#define GTK_TIMER_WIDTH 40
#define GTK_NETSTAT_WIDTH 20
#define GTK_TIMER_TOP GTK_HOR_SCORE_TOP
#define GTK_HOR_SCORE_WIDTH ((GTK_MIN_SCALE*20)-GTK_TIMER_PAD)
#define GTK_VERT_SCORE_WIDTH 40
#define GTK_BOARD_TOP (GTK_SCORE_TOP + GTK_SCORE_HEIGHT \
+ GTK_SCORE_BOARD_PADDING )
#define GTK_BOARD_LEFT (GTK_BOARD_LEFT_MARGIN)
#define GTK_TRAY_LEFT GTK_TRAY_LEFT_MARGIN
#define GTK_DIVIDER_WIDTH 5
#define GTK_BOTTOM_MARGIN GTK_TOP_MARGIN
#define GTK_RIGHT_MARGIN GTK_BOARD_LEFT_MARGIN
#endif /* PLATFORM_GTK */
int gtkmain( LaunchParams* params );
#endif

View file

@ -22,13 +22,14 @@
#include <stdarg.h>
#include "linuxutl.h"
#include "linuxmain.h"
#include "gtknewgame.h"
#include "strutils.h"
#include "nwgamest.h"
#include "gtkconnsdlg.h"
#include "gtkutils.h"
#define MAX_SIZE_CHOICES 10
#define MAX_SIZE_CHOICES 32
typedef struct GtkNewGameState {
GtkAppGlobals* globals;
@ -43,6 +44,7 @@ typedef struct GtkNewGameState {
XP_Bool fireConnDlg;
gboolean isNewGame;
short nCols; /* for board size */
gchar* dict;
#ifndef XWFEATURE_STANDALONE_ONLY
GtkWidget* remoteChecks[MAX_NUM_PLAYERS];
@ -153,6 +155,14 @@ size_combo_changed( GtkComboBox* combo, gpointer gp )
}
} /* size_combo_changed */
static void
dict_combo_changed( GtkComboBox* combo, gpointer gp )
{
GtkNewGameState* state = (GtkNewGameState*)gp;
state->dict = gtk_combo_box_get_active_text( GTK_COMBO_BOX(combo) );
XP_LOGF( "got dict: %s", state->dict );
} /* size_combo_changed */
static void
handle_ok( GtkWidget* XP_UNUSED(widget), gpointer closure )
{
@ -199,6 +209,7 @@ makeNewGameDialog( GtkNewGameState* state )
#endif
GtkWidget* nPlayersCombo;
GtkWidget* boardSizeCombo;
GtkWidget* dictCombo;
CurGameInfo* gi;
short ii;
@ -334,6 +345,17 @@ makeNewGameDialog( GtkNewGameState* state )
gtk_box_pack_start( GTK_BOX(hbox), gtk_label_new("Dictionary: "),
FALSE, TRUE, 0 );
dictCombo = gtk_combo_box_new_text();
g_signal_connect( GTK_OBJECT(dictCombo), "changed",
G_CALLBACK(dict_combo_changed), state );
gtk_widget_show( dictCombo );
gtk_box_pack_start( GTK_BOX(hbox), dictCombo, FALSE, TRUE, 0 );
GSList* dicts = listDicts( state->globals->cGlobals.params );
for ( GSList* iter = dicts; !!iter; iter = iter->next ) {
gtk_combo_box_append_text( GTK_COMBO_BOX(dictCombo), iter->data );
}
g_slist_free( dicts );
if ( !!gi->dictName ) {
gtk_box_pack_start( GTK_BOX(hbox),
@ -558,6 +580,9 @@ newGameDialog( GtkAppGlobals* globals, CommsAddrRec* addr, XP_Bool isNewGame,
if ( newg_store( state.newGameCtxt, &globals->cGlobals.params->gi,
XP_TRUE ) ) {
globals->cGlobals.params->gi.boardSize = state.nCols;
replaceStringIfDifferent( globals->cGlobals.params->util->mpool,
&globals->cGlobals.params->gi.dictName,
state.dict );
} else {
/* Do it again if we warned user of inconsistency. */
state.revert = XP_TRUE;

View file

@ -24,7 +24,7 @@
#ifndef _GTKNEWGAME_H_
#define _GTKNEWGAME_H_
#include "gtkmain.h"
#include "gtkboard.h"
gboolean newGameDialog( GtkAppGlobals* globals, CommsAddrRec* addr,
XP_Bool isNewGame, XP_Bool fireConnDlg );

View file

@ -23,7 +23,7 @@
#ifndef _GTKNTILESASK_H_
#define _GTKNTILESASK_H_
#include "gtkmain.h"
#include "gtkboard.h"
XP_U16 askNTiles( XP_U16 nTilesMax, XP_U16 deflt );

View file

@ -24,7 +24,7 @@
#ifndef _GTKUTILS_H_
#define _GTKUTILS_H_
#include "gtkmain.h"
#include "gtkboard.h"
GtkWidget* makeButton( char* text, GCallback func, gpointer data );
GtkWidget* makeLabeledField( const char* labelText, GtkWidget** field );

View file

@ -61,6 +61,7 @@
# include "cursesmain.h"
#endif
#ifdef PLATFORM_GTK
# include "gtkboard.h"
# include "gtkmain.h"
#endif
#include "model.h"
@ -1214,6 +1215,7 @@ static void
tmp_noop_sigintterm( int XP_UNUSED(sig) )
{
LOG_FUNC();
exit(0);
}
#ifdef XWFEATURE_WALKDICT
@ -1505,6 +1507,39 @@ listDicts( const LaunchParams *params )
return result;
}
void
initParams( LaunchParams* params )
{
memset( params, 0, sizeof(*params) );
params->util = malloc( sizeof(params->util) );
XP_MEMSET( params->util, 0, sizeof(params->util) );
#ifdef MEM_DEBUG
params->util->mpool = mpool_make();
#endif
params->vtMgr = make_vtablemgr(MPPARM_NOCOMMA(params->util->mpool));
linux_util_vt_init( MPPARM(params->util->mpool) params->util );
#ifndef XWFEATURE_STANDALONE_ONLY
params->util->vtable->m_util_informMissing = linux_util_informMissing;
params->util->vtable->m_util_addrChange = linux_util_addrChange;
params->util->vtable->m_util_setIsServer = linux_util_setIsServer;
#endif
}
void
freeParams( LaunchParams* params )
{
vtmgr_destroy( MPPARM(params->util->mpool) params->vtMgr );
linux_util_vt_destroy( params->util );
mpool_destroy( params->util->mpool );
free( params->util );
}
int
main( int argc, char** argv )
{
@ -1560,17 +1595,7 @@ main( int argc, char** argv )
}
#endif
memset( &mainParams, 0, sizeof(mainParams) );
mainParams.util = malloc( sizeof(*mainParams.util) );
XP_MEMSET( mainParams.util, 0, sizeof(*mainParams.util) );
#ifdef MEM_DEBUG
mainParams.util->mpool = mpool_make();
#endif
mainParams.vtMgr = make_vtablemgr(MPPARM_NOCOMMA(mainParams.util->mpool));
initParams( &mainParams );
/* fprintf( stdout, "press <RET> to start\n" ); */
/* (void)fgetc( stdin ); */
@ -2074,14 +2099,6 @@ main( int argc, char** argv )
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
srandom( seed ); /* init linux random number generator */
XP_LOGF( "seeded srandom with %d", seed );
@ -2114,19 +2131,14 @@ main( int argc, char** argv )
#endif
} else if ( !useCurses ) {
#if defined PLATFORM_GTK
gtkmain( &mainParams, argc, argv );
gtk_init( &argc, &argv );
gtkmain( &mainParams );
#endif
} else {
usage( argv[0], "rtfm" );
}
vtmgr_destroy( MPPARM(mainParams.util->mpool) mainParams.vtMgr );
linux_util_vt_destroy( mainParams.util );
mpool_destroy( mainParams.util->mpool );
free( mainParams.util );
freeParams( &mainParams );
XP_LOGF( "%s exiting main", argv[0] );
return 0;

View file

@ -94,4 +94,7 @@ void setOneSecondTimer( CommonGlobals* cGlobals );
# define setOneSecondTimer( cGlobals )
#endif
void initParams( LaunchParams* params );
void freeParams( LaunchParams* params );
#endif