2011-02-10 07:17:18 +01:00
|
|
|
/* -*- compile-command: "cd ../linux && make -j3 MEMDEBUG=TRUE"; -*- */
|
2003-11-01 06:35:29 +01:00
|
|
|
/*
|
2011-02-10 07:17:18 +01:00
|
|
|
* Copyright 2001-2011 by Eric House (xwords@eehouse.org). All rights
|
2009-01-04 00:54:25 +01:00
|
|
|
* reserved.
|
2003-11-01 06:35:29 +01: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 _GAME_H_
|
|
|
|
#define _GAME_H_
|
|
|
|
|
2013-11-03 21:12:25 +01:00
|
|
|
#include "gameinfo.h"
|
2003-11-01 06:35:29 +01:00
|
|
|
#include "model.h"
|
|
|
|
#include "board.h"
|
|
|
|
#include "comms.h"
|
|
|
|
#include "server.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
#ifdef CPLUS
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-03-11 03:13:56 +01:00
|
|
|
typedef struct _GameStateInfo {
|
|
|
|
XP_U16 visTileCount;
|
2014-03-02 01:15:35 +01:00
|
|
|
XP_U16 nPendingMessages;
|
2012-06-06 07:13:26 +02:00
|
|
|
XW_TrayVisState trayVisState;
|
2011-03-11 03:13:56 +01:00
|
|
|
XP_Bool canHint;
|
2013-12-03 16:06:48 +01:00
|
|
|
XP_Bool canUndo;
|
2011-03-11 03:13:56 +01:00
|
|
|
XP_Bool canRedo;
|
|
|
|
XP_Bool inTrade;
|
2011-09-10 04:04:25 +02:00
|
|
|
XP_Bool tradeTilesSelected;
|
2013-07-18 16:37:45 +02:00
|
|
|
XP_Bool canChat;
|
2011-03-11 03:13:56 +01:00
|
|
|
XP_Bool canShuffle;
|
2011-10-05 15:36:01 +02:00
|
|
|
XP_Bool curTurnSelected;
|
2013-11-17 22:54:21 +01:00
|
|
|
XP_Bool canHideRack;
|
2013-12-02 06:53:41 +01:00
|
|
|
XP_Bool canTrade;
|
2011-03-11 03:13:56 +01:00
|
|
|
} GameStateInfo;
|
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
typedef struct XWGame {
|
|
|
|
BoardCtxt* board;
|
|
|
|
ModelCtxt* model;
|
|
|
|
ServerCtxt* server;
|
|
|
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
|
|
|
CommsCtxt* comms;
|
|
|
|
#endif
|
|
|
|
} XWGame;
|
|
|
|
|
|
|
|
void game_makeNewGame( MPFORMAL XWGame* game, CurGameInfo* gi,
|
2010-01-31 22:35:07 +01:00
|
|
|
XW_UtilCtxt* util, DrawCtx* draw,
|
2011-08-01 07:23:46 +02:00
|
|
|
CommonPrefs* cp, const TransportProcs* procs
|
|
|
|
#ifdef SET_GAMESEED
|
|
|
|
,XP_U16 gameSeed
|
|
|
|
#endif
|
|
|
|
);
|
2013-01-06 01:08:19 +01:00
|
|
|
XP_Bool game_reset( MPFORMAL XWGame* game, CurGameInfo* gi, XW_UtilCtxt* util,
|
|
|
|
CommonPrefs* cp, const TransportProcs* procs );
|
2012-10-24 04:06:00 +02:00
|
|
|
void game_changeDict( MPFORMAL XWGame* game, CurGameInfo* gi,
|
|
|
|
DictionaryCtxt* dict );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2006-11-05 17:54:18 +01:00
|
|
|
XP_Bool game_makeFromStream( MPFORMAL XWStreamCtxt* stream, XWGame* game,
|
2011-04-02 04:57:10 +02:00
|
|
|
CurGameInfo* gi, DictionaryCtxt* dict,
|
|
|
|
const PlayerDicts* dicts, XW_UtilCtxt* util,
|
2006-11-05 17:54:18 +01:00
|
|
|
DrawCtx* draw, CommonPrefs* cp,
|
2009-09-12 23:39:13 +02:00
|
|
|
const TransportProcs* procs );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2006-09-15 09:31:24 +02:00
|
|
|
void game_saveToStream( const XWGame* game, const CurGameInfo* gi,
|
2012-09-10 16:31:45 +02:00
|
|
|
XWStreamCtxt* stream, XP_U16 saveToken );
|
|
|
|
void game_saveSucceeded( const XWGame* game, XP_U16 saveToken );
|
2003-11-01 06:35:29 +01:00
|
|
|
void game_dispose( XWGame* game );
|
2011-03-11 03:13:56 +01:00
|
|
|
|
|
|
|
void game_getState( const XWGame* game, GameStateInfo* gsi );
|
|
|
|
|
2007-02-03 18:54:20 +01:00
|
|
|
void gi_initPlayerInfo( MPFORMAL CurGameInfo* gi,
|
|
|
|
const XP_UCHAR* nameTemplate );
|
2013-12-18 06:54:02 +01:00
|
|
|
void gi_setNPlayers( CurGameInfo* gi, XP_U16 nTotal, XP_U16 nHere );
|
2003-11-01 06:35:29 +01:00
|
|
|
void gi_disposePlayerInfo( MPFORMAL CurGameInfo* gi );
|
2006-09-15 09:31:24 +02:00
|
|
|
void gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi );
|
2004-06-24 07:18:46 +02:00
|
|
|
void gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi );
|
2007-12-31 21:00:13 +01:00
|
|
|
void gi_copy( MPFORMAL CurGameInfo* destGI, const CurGameInfo* srcGi );
|
2010-09-10 10:30:40 +02:00
|
|
|
XP_U16 gi_countLocalPlayers( const CurGameInfo* gi, XP_Bool humanOnly );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
|
|
|
XP_Bool player_hasPasswd( LocalPlayer* player );
|
|
|
|
XP_Bool player_passwordMatches( LocalPlayer* player, XP_U8* buf, XP_U16 len );
|
|
|
|
XP_U16 player_timePenalty( CurGameInfo* gi, XP_U16 playerNum );
|
|
|
|
|
|
|
|
#ifdef CPLUS
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|