2003-11-01 06:35:29 +01:00
|
|
|
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
|
|
|
/*
|
2006-01-08 02:25:02 +01:00
|
|
|
* Copyright 1997 - 2000 by Eric House (xwords@eehouse.org). All rights 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 _SERVER_H_
|
|
|
|
#define _SERVER_H_
|
|
|
|
|
2008-05-31 05:26:16 +02:00
|
|
|
#include "comtypes.h" /* that's *common* types */
|
2003-11-01 06:35:29 +01:00
|
|
|
|
|
|
|
#include "commmgr.h"
|
|
|
|
#include "model.h"
|
|
|
|
|
|
|
|
#ifdef CPLUS
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PHONIES_IGNORE,
|
|
|
|
PHONIES_WARN,
|
|
|
|
PHONIES_DISALLOW
|
|
|
|
};
|
|
|
|
typedef XP_U8 XWPhoniesChoice;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
SERVER_STANDALONE,
|
|
|
|
SERVER_ISSERVER,
|
|
|
|
SERVER_ISCLIENT
|
|
|
|
};
|
2007-02-02 09:34:37 +01:00
|
|
|
typedef XP_U8 DeviceRole;
|
2003-11-01 06:35:29 +01:00
|
|
|
|
|
|
|
/* typedef struct ServerCtxt ServerCtxt; */
|
|
|
|
|
|
|
|
/* typedef struct ServerVtable { */
|
|
|
|
|
|
|
|
/* void (*m_registerPlayer)( ServerCtxt* server, XP_U16 playerNum, */
|
2008-05-31 05:26:16 +02:00
|
|
|
/* XP_PlayerSocket socket ); */
|
2003-11-01 06:35:29 +01:00
|
|
|
|
|
|
|
/* void (*m_getTileValueInfo)( ServerCtxt* server, void* valueBuf ); */
|
|
|
|
|
|
|
|
/* } ServerVtable; */
|
|
|
|
|
|
|
|
ServerCtxt* server_make( MPFORMAL ModelCtxt* model, CommsCtxt* comms,
|
|
|
|
XW_UtilCtxt* util );
|
|
|
|
|
|
|
|
ServerCtxt* server_makeFromStream( MPFORMAL XWStreamCtxt* stream,
|
|
|
|
ModelCtxt* model, CommsCtxt* comms,
|
|
|
|
XW_UtilCtxt* util, XP_U16 nPlayers );
|
|
|
|
|
2012-03-12 02:28:14 +01:00
|
|
|
void server_writeToStream( const ServerCtxt* server, XWStreamCtxt* stream );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2005-03-25 04:11:54 +01:00
|
|
|
void server_reset( ServerCtxt* server, CommsCtxt* comms );
|
2003-11-01 06:35:29 +01:00
|
|
|
void server_destroy( ServerCtxt* server );
|
|
|
|
|
|
|
|
void server_prefsChanged( ServerCtxt* server, CommonPrefs* cp );
|
|
|
|
|
|
|
|
typedef void (*TurnChangeListener)( void* data );
|
|
|
|
void server_setTurnChangeListener( ServerCtxt* server, TurnChangeListener tl,
|
|
|
|
void* data );
|
|
|
|
|
|
|
|
typedef void (*GameOverListener)( void* data );
|
|
|
|
void server_setGameOverListener( ServerCtxt* server, GameOverListener gol,
|
|
|
|
void* data );
|
|
|
|
|
|
|
|
/* support random assignment by telling creator of new player what it's
|
|
|
|
* number will be */
|
|
|
|
/* XP_U16 server_assignNum( ServerCtxt* server ); */
|
|
|
|
|
|
|
|
EngineCtxt* server_getEngineFor( ServerCtxt* server, XP_U16 playerNum );
|
|
|
|
void server_resetEngine( ServerCtxt* server, XP_U16 playerNum );
|
|
|
|
|
|
|
|
XP_U16 server_secondsUsedBy( ServerCtxt* server, XP_U16 playerNum );
|
|
|
|
|
|
|
|
/* It might make more sense to have the board supply the undo method clients
|
|
|
|
call... */
|
|
|
|
XP_Bool server_handleUndo( ServerCtxt* server );
|
|
|
|
|
|
|
|
/* signed because negative number means nobody's turn yet */
|
|
|
|
XP_S16 server_getCurrentTurn( ServerCtxt* server );
|
|
|
|
XP_Bool server_getGameIsOver( ServerCtxt* server );
|
2011-05-20 07:48:21 +02:00
|
|
|
/* return bitvector marking players still not arrived in networked game */
|
|
|
|
XP_U16 server_getMissingPlayers( const ServerCtxt* server );
|
2003-11-01 06:35:29 +01:00
|
|
|
/* Signed in case no dictionary available */
|
|
|
|
XP_S16 server_countTilesInPool( ServerCtxt* server );
|
|
|
|
|
|
|
|
XP_Bool server_do( ServerCtxt* server );
|
|
|
|
|
|
|
|
XP_Bool server_commitMove( ServerCtxt* server );
|
2011-10-20 03:34:26 +02:00
|
|
|
XP_Bool server_commitTrade( ServerCtxt* server, const TrayTileSet* oldTiles );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
|
|
|
/* call this when user wants to end the game */
|
|
|
|
void server_endGame( ServerCtxt* server );
|
|
|
|
|
|
|
|
/* called when running as either client or server */
|
2010-10-04 03:11:51 +02:00
|
|
|
XP_Bool server_receiveMessage( ServerCtxt* server, XWStreamCtxt* incoming );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
|
|
|
/* client-side messages. Client (platform code)owns the stream used to talk
|
|
|
|
* to the server, and passes it in. */
|
|
|
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
|
|
|
void server_initClientConnection( ServerCtxt* server, XWStreamCtxt* stream );
|
|
|
|
#endif
|
|
|
|
|
2010-10-04 03:11:51 +02:00
|
|
|
#ifdef XWFEATURE_CHAT
|
|
|
|
void server_sendChat( ServerCtxt* server, const XP_UCHAR const* msg );
|
|
|
|
#endif
|
|
|
|
|
2004-11-06 03:46:08 +01:00
|
|
|
void server_formatDictCounts( ServerCtxt* server, XWStreamCtxt* stream,
|
|
|
|
XP_U16 nCols );
|
|
|
|
void server_formatRemainingTiles( ServerCtxt* server, XWStreamCtxt* stream,
|
|
|
|
XP_S16 player );
|
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
void server_writeFinalScores( ServerCtxt* server, XWStreamCtxt* stream );
|
|
|
|
|
|
|
|
#ifdef CPLUS
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|