mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
pass index of resigning player into util_notifyGameOver. Not yet
passed into java.
This commit is contained in:
parent
3221fb237a
commit
e90c5ee94f
9 changed files with 22 additions and 16 deletions
|
@ -284,7 +284,7 @@ and_util_informNetDict( XW_UtilCtxt* uc, const XP_UCHAR* oldName,
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_notifyGameOver( XW_UtilCtxt* uc )
|
||||
and_util_notifyGameOver( XW_UtilCtxt* uc, XP_S16 XP_UNUSED(quitter) )
|
||||
{
|
||||
UTIL_CBK_HEADER( "notifyGameOver", "()V" );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid );
|
||||
|
|
|
@ -87,7 +87,7 @@ static void dictChanged( void* p_board, XP_S16 playerNum,
|
|||
const DictionaryCtxt* newDict );
|
||||
|
||||
static void boardTurnChanged( void* board );
|
||||
static void boardGameOver( void* board );
|
||||
static void boardGameOver( void* board, XP_S16 quitter );
|
||||
static void setArrow( BoardCtxt* board, XP_U16 row, XP_U16 col, XP_Bool* vp );
|
||||
static XP_Bool setArrowVisible( BoardCtxt* board, XP_Bool visible );
|
||||
|
||||
|
@ -3467,12 +3467,12 @@ boardTurnChanged( void* p_board )
|
|||
} /* boardTurnChanged */
|
||||
|
||||
static void
|
||||
boardGameOver( void* closure )
|
||||
boardGameOver( void* closure, XP_S16 quitter )
|
||||
{
|
||||
BoardCtxt* board = (BoardCtxt*)closure;
|
||||
board->scoreBoardInvalid = XP_TRUE; /* not sure if this will do it. */
|
||||
board->gameOver = XP_TRUE;
|
||||
util_notifyGameOver( board->util );
|
||||
util_notifyGameOver( board->util, quitter );
|
||||
} /* boardGameOver */
|
||||
|
||||
static void
|
||||
|
|
|
@ -2411,7 +2411,7 @@ doEndGame( ServerCtxt* server, XP_S16 quitter )
|
|||
setTurn( server, -1 );
|
||||
server->nv.quitter = quitter;
|
||||
|
||||
(*server->vol.gameOverListener)( server->vol.gameOverData );
|
||||
(*server->vol.gameOverListener)( server->vol.gameOverData, quitter );
|
||||
} /* doEndGame */
|
||||
|
||||
static void
|
||||
|
|
|
@ -73,7 +73,7 @@ typedef void (*TurnChangeListener)( void* data );
|
|||
void server_setTurnChangeListener( ServerCtxt* server, TurnChangeListener tl,
|
||||
void* data );
|
||||
|
||||
typedef void (*GameOverListener)( void* data );
|
||||
typedef void (*GameOverListener)( void* data, XP_S16 quitter );
|
||||
void server_setGameOverListener( ServerCtxt* server, GameOverListener gol,
|
||||
void* data );
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ typedef struct UtilVtable {
|
|||
const XP_UCHAR* newSum,
|
||||
XWPhoniesChoice phoniesAction );
|
||||
|
||||
void (*m_util_notifyGameOver)( XW_UtilCtxt* uc );
|
||||
void (*m_util_notifyGameOver)( XW_UtilCtxt* uc, XP_S16 quitter );
|
||||
#ifdef XWFEATURE_HILITECELL
|
||||
XP_Bool (*m_util_hiliteCell)( XW_UtilCtxt* uc, XP_U16 col, XP_U16 row );
|
||||
#endif
|
||||
|
@ -253,8 +253,8 @@ struct XW_UtilCtxt {
|
|||
(uc)->vtable->m_util_informUndo( (uc))
|
||||
#define util_informNetDict(uc, on, nn, ns, pa ) \
|
||||
(uc)->vtable->m_util_informNetDict( (uc), (on), (nn), (ns), (pa) )
|
||||
#define util_notifyGameOver( uc ) \
|
||||
(uc)->vtable->m_util_notifyGameOver((uc))
|
||||
#define util_notifyGameOver( uc, q ) \
|
||||
(uc)->vtable->m_util_notifyGameOver((uc), (q))
|
||||
|
||||
#ifdef XWFEATURE_HILITECELL
|
||||
# define util_hiliteCell( uc, c, r ) \
|
||||
|
|
|
@ -371,7 +371,7 @@ curses_util_informUndo( XW_UtilCtxt* XP_UNUSED(uc))
|
|||
}
|
||||
|
||||
static void
|
||||
curses_util_notifyGameOver( XW_UtilCtxt* uc )
|
||||
curses_util_notifyGameOver( XW_UtilCtxt* uc, XP_S16 quitter )
|
||||
{
|
||||
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
|
||||
board_draw( globals->cGlobals.game.board );
|
||||
|
@ -381,7 +381,7 @@ curses_util_notifyGameOver( XW_UtilCtxt* uc )
|
|||
catGameHistory( &globals->cGlobals );
|
||||
}
|
||||
|
||||
catFinalScores( &globals->cGlobals );
|
||||
catFinalScores( &globals->cGlobals, quitter );
|
||||
|
||||
if ( globals->cGlobals.params->quitAfter >= 0 ) {
|
||||
sleep( globals->cGlobals.params->quitAfter );
|
||||
|
|
|
@ -762,7 +762,7 @@ final_scores( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
|
|||
XP_Bool gameOver = server_getGameIsOver( globals->cGlobals.game.server );
|
||||
|
||||
if ( gameOver ) {
|
||||
catFinalScores( &globals->cGlobals );
|
||||
catFinalScores( &globals->cGlobals, -1 );
|
||||
} else {
|
||||
if ( gtkask( globals->window,
|
||||
"Are you sure you want to resign?",
|
||||
|
@ -1438,7 +1438,7 @@ gtk_util_informUndo( XW_UtilCtxt* uc )
|
|||
}
|
||||
|
||||
static void
|
||||
gtk_util_notifyGameOver( XW_UtilCtxt* uc )
|
||||
gtk_util_notifyGameOver( XW_UtilCtxt* uc, XP_S16 quitter )
|
||||
{
|
||||
GtkAppGlobals* globals = (GtkAppGlobals*)uc->closure;
|
||||
CommonGlobals* cGlobals = &globals->cGlobals;
|
||||
|
@ -1447,7 +1447,7 @@ gtk_util_notifyGameOver( XW_UtilCtxt* uc )
|
|||
catGameHistory( cGlobals );
|
||||
}
|
||||
|
||||
catFinalScores( cGlobals );
|
||||
catFinalScores( cGlobals, quitter );
|
||||
|
||||
if ( cGlobals->params->quitAfter >= 0 ) {
|
||||
sleep( cGlobals->params->quitAfter );
|
||||
|
|
|
@ -213,13 +213,19 @@ catGameHistory( CommonGlobals* cGlobals )
|
|||
} /* catGameHistory */
|
||||
|
||||
void
|
||||
catFinalScores( const CommonGlobals* cGlobals )
|
||||
catFinalScores( const CommonGlobals* cGlobals, XP_S16 quitter )
|
||||
{
|
||||
XWStreamCtxt* stream;
|
||||
|
||||
stream = mem_stream_make( MPPARM(cGlobals->params->util->mpool)
|
||||
cGlobals->params->vtMgr,
|
||||
NULL, CHANNEL_NONE, catOnClose );
|
||||
if ( -1 != quitter ) {
|
||||
XP_UCHAR buf[128];
|
||||
XP_SNPRINTF( buf, VSIZE(buf), "Player %s resigned\n",
|
||||
cGlobals->params->gi.players[quitter].name );
|
||||
stream_catString( stream, buf );
|
||||
}
|
||||
server_writeFinalScores( cGlobals->game.server, stream );
|
||||
stream_putU8( stream, '\n' );
|
||||
stream_destroy( stream );
|
||||
|
|
|
@ -60,7 +60,7 @@ XP_UCHAR* strFromStream( XWStreamCtxt* stream );
|
|||
|
||||
void catGameHistory( CommonGlobals* cGlobals );
|
||||
void catOnClose( XWStreamCtxt* stream, void* closure );
|
||||
void catFinalScores( const CommonGlobals* cGlobals );
|
||||
void catFinalScores( const CommonGlobals* cGlobals, XP_S16 quitter );
|
||||
XP_Bool file_exists( const char* fileName );
|
||||
XWStreamCtxt* streamFromFile( CommonGlobals* cGlobals, char* name,
|
||||
void* closure );
|
||||
|
|
Loading…
Add table
Reference in a new issue