2003-11-01 05:35:29 +00:00
|
|
|
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
|
|
|
/*
|
2007-05-26 14:14:01 +00:00
|
|
|
* Copyright 2001-2007 by Eric House (xwords@eehouse.org). All rights
|
|
|
|
* reserved.
|
2003-11-01 05:35:29 +00:00
|
|
|
*
|
|
|
|
* 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 _MAIN_H_
|
|
|
|
#define _MAIN_H_
|
|
|
|
|
2007-06-02 02:07:45 +00:00
|
|
|
#ifdef XWFEATURE_BLUETOOTH
|
|
|
|
# include <bluetooth/bluetooth.h> /* for bdaddr_t, which should move */
|
|
|
|
#endif
|
2006-08-26 21:15:20 +00:00
|
|
|
|
2003-11-01 05:35:29 +00:00
|
|
|
#include "comtypes.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "vtabmgr.h"
|
|
|
|
|
|
|
|
typedef struct ServerInfo {
|
|
|
|
XP_U16 nRemotePlayers;
|
|
|
|
/* CommPipeCtxt* pipe; */
|
|
|
|
} ServerInfo;
|
|
|
|
|
|
|
|
typedef struct ClientInfo {
|
|
|
|
} ClientInfo;
|
|
|
|
|
|
|
|
typedef struct LinuxUtilCtxt {
|
|
|
|
UtilVtable* vtable;
|
|
|
|
} LinuxUtilCtxt;
|
|
|
|
|
|
|
|
typedef struct LaunchParams {
|
|
|
|
/* CommPipeCtxt* pipe; */
|
|
|
|
XW_UtilCtxt* util;
|
|
|
|
DictionaryCtxt* dict;
|
|
|
|
CurGameInfo gi;
|
|
|
|
char* fileName;
|
|
|
|
VTableMgr* vtMgr;
|
|
|
|
XP_U16 nLocalPlayers;
|
2006-05-17 06:10:24 +00:00
|
|
|
XP_U16 nHidden;
|
2003-11-01 05:35:29 +00:00
|
|
|
XP_Bool askNewGame;
|
2008-10-26 15:33:21 +00:00
|
|
|
XP_S16 quitAfter;
|
2003-11-01 05:35:29 +00:00
|
|
|
XP_Bool sleepOnAnchor;
|
|
|
|
XP_Bool printHistory;
|
|
|
|
XP_Bool undoWhenDone;
|
|
|
|
XP_Bool verticalScore;
|
2008-12-29 03:09:35 +00:00
|
|
|
XP_Bool hideValues;
|
2010-01-26 04:14:18 +00:00
|
|
|
XP_Bool showColors;
|
2010-07-17 06:22:42 -07:00
|
|
|
XP_Bool allowPeek;
|
2010-06-17 18:10:32 -07:00
|
|
|
XP_Bool sortNewTiles;
|
2009-11-08 17:25:19 +00:00
|
|
|
XP_Bool skipCommitConfirm;
|
2009-02-28 18:52:44 +00:00
|
|
|
XP_Bool needsNewGame;
|
2003-11-01 05:35:29 +00:00
|
|
|
// XP_Bool mainParams;
|
|
|
|
XP_Bool skipWarnings;
|
|
|
|
XP_Bool showRobotScores;
|
2005-09-03 15:39:15 +00:00
|
|
|
XP_Bool noHeartbeat;
|
2009-09-26 13:47:51 +00:00
|
|
|
XP_Bool duplicatePackets;
|
2010-03-28 16:08:54 +00:00
|
|
|
XP_Bool skipGameOver;
|
2008-04-08 03:55:53 +00:00
|
|
|
#ifdef XWFEATURE_SEARCHLIMIT
|
|
|
|
XP_Bool allowHintRect;
|
|
|
|
#endif
|
2003-11-01 05:35:29 +00:00
|
|
|
|
2009-07-09 12:43:51 +00:00
|
|
|
#ifdef XWFEATURE_SLOW_ROBOT
|
|
|
|
XP_U16 robotThinkMin, robotThinkMax;
|
|
|
|
#endif
|
|
|
|
|
2007-02-02 08:34:37 +00:00
|
|
|
DeviceRole serverRole;
|
2003-11-01 05:35:29 +00:00
|
|
|
|
2006-08-26 21:15:20 +00:00
|
|
|
CommsConnType conType;
|
2007-11-26 02:58:25 +00:00
|
|
|
struct {
|
2006-10-10 01:34:37 +00:00
|
|
|
#ifdef XWFEATURE_RELAY
|
2006-08-26 21:15:20 +00:00
|
|
|
struct {
|
|
|
|
char* relayName;
|
2009-09-14 03:11:11 +00:00
|
|
|
char* invite;
|
2006-08-26 21:15:20 +00:00
|
|
|
short defaultSendPort;
|
2010-09-14 21:13:45 -07:00
|
|
|
XP_Bool seeksPublicRoom;
|
|
|
|
XP_Bool advertiseRoom;
|
2006-08-26 21:15:20 +00:00
|
|
|
} relay;
|
2006-10-10 01:34:37 +00:00
|
|
|
#endif
|
|
|
|
#ifdef XWFEATURE_BLUETOOTH
|
2006-08-26 21:15:20 +00:00
|
|
|
struct {
|
|
|
|
bdaddr_t hostAddr; /* unused if a host */
|
|
|
|
} bt;
|
2007-11-26 02:58:25 +00:00
|
|
|
#endif
|
|
|
|
#ifdef XWFEATURE_IP_DIRECT
|
|
|
|
struct {
|
|
|
|
const char* hostName;
|
|
|
|
int port;
|
|
|
|
} ip;
|
2008-12-29 01:35:29 +00:00
|
|
|
#endif
|
|
|
|
#ifdef XWFEATURE_SMS
|
|
|
|
struct {
|
|
|
|
const char* serverPhone;
|
|
|
|
int port;
|
|
|
|
} sms;
|
2006-10-10 01:34:37 +00:00
|
|
|
#endif
|
2006-08-26 21:15:20 +00:00
|
|
|
} connInfo;
|
|
|
|
|
2003-11-01 05:35:29 +00:00
|
|
|
union {
|
|
|
|
ServerInfo serverInfo;
|
|
|
|
ClientInfo clientInfo;
|
|
|
|
} info;
|
|
|
|
|
|
|
|
} LaunchParams;
|
|
|
|
|
2006-09-10 19:01:06 +00:00
|
|
|
typedef struct CommonGlobals CommonGlobals;
|
|
|
|
|
2007-11-26 02:58:25 +00:00
|
|
|
typedef void (*SocketChangedFunc)(void* closure, int oldsock, int newsock,
|
|
|
|
void** storage );
|
2006-09-10 19:01:06 +00:00
|
|
|
typedef XP_Bool (*Acceptor)( int sock, void* ctxt );
|
|
|
|
typedef void (*AddAcceptorFunc)(int listener, Acceptor func,
|
2007-11-28 03:59:26 +00:00
|
|
|
CommonGlobals* globals, void** storage );
|
2005-03-19 22:07:53 +00:00
|
|
|
|
2008-12-29 01:35:29 +00:00
|
|
|
#ifdef XWFEATURE_SMS
|
|
|
|
typedef struct LinSMSData LinSMSData;
|
|
|
|
#endif
|
|
|
|
|
2009-07-10 05:04:04 +00:00
|
|
|
typedef struct _TimerInfo {
|
|
|
|
XWTimerProc proc;
|
|
|
|
void* closure;
|
|
|
|
XP_U32 when; /* used only for ncurses */
|
|
|
|
} TimerInfo;
|
|
|
|
|
2006-09-10 19:01:06 +00:00
|
|
|
struct CommonGlobals {
|
2003-11-01 05:35:29 +00:00
|
|
|
LaunchParams* params;
|
|
|
|
|
|
|
|
XWGame game;
|
2003-11-30 19:09:39 +00:00
|
|
|
XP_U16 lastNTilesToUse;
|
2006-08-26 21:15:20 +00:00
|
|
|
|
2005-03-19 22:07:53 +00:00
|
|
|
SocketChangedFunc socketChanged;
|
|
|
|
void* socketChangedClosure;
|
2005-06-23 04:20:00 +00:00
|
|
|
|
2009-09-20 18:45:25 +00:00
|
|
|
CommsRelayState state;
|
|
|
|
|
2006-09-10 19:01:06 +00:00
|
|
|
/* Allow listener sockets to be installed in either gtk or ncurses'
|
|
|
|
* polling mechanism.*/
|
|
|
|
AddAcceptorFunc addAcceptor;
|
|
|
|
Acceptor acceptor;
|
|
|
|
|
2007-11-26 02:58:25 +00:00
|
|
|
#ifdef XWFEATURE_RELAY
|
|
|
|
int socket; /* relay */
|
|
|
|
void* storage;
|
2006-09-19 03:39:08 +00:00
|
|
|
char* defaultServerName;
|
2007-11-26 02:58:25 +00:00
|
|
|
#endif
|
2006-09-19 03:39:08 +00:00
|
|
|
|
2007-11-26 02:58:25 +00:00
|
|
|
#if defined XWFEATURE_BLUETOOTH
|
2006-09-19 03:39:08 +00:00
|
|
|
struct LinBtStuff* btStuff;
|
2007-11-26 02:58:25 +00:00
|
|
|
#endif
|
|
|
|
#if defined XWFEATURE_IP_DIRECT
|
|
|
|
struct LinUDPStuff* udpStuff;
|
|
|
|
#endif
|
2008-12-29 01:35:29 +00:00
|
|
|
#ifdef XWFEATURE_SMS
|
|
|
|
LinSMSData* smsData;
|
|
|
|
#endif
|
2006-08-26 21:15:20 +00:00
|
|
|
|
2009-07-10 05:04:04 +00:00
|
|
|
TimerInfo timerInfo[NUM_TIMERS_PLUS_ONE];
|
2006-09-10 19:01:06 +00:00
|
|
|
};
|
2003-11-01 05:35:29 +00:00
|
|
|
|
|
|
|
#endif
|