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
|
static void
|
||||||
and_util_notifyGameOver( XW_UtilCtxt* uc )
|
and_util_notifyGameOver( XW_UtilCtxt* uc, XP_S16 XP_UNUSED(quitter) )
|
||||||
{
|
{
|
||||||
UTIL_CBK_HEADER( "notifyGameOver", "()V" );
|
UTIL_CBK_HEADER( "notifyGameOver", "()V" );
|
||||||
(*env)->CallVoidMethod( env, util->jutil, mid );
|
(*env)->CallVoidMethod( env, util->jutil, mid );
|
||||||
|
|
|
@ -87,7 +87,7 @@ static void dictChanged( void* p_board, XP_S16 playerNum,
|
||||||
const DictionaryCtxt* newDict );
|
const DictionaryCtxt* newDict );
|
||||||
|
|
||||||
static void boardTurnChanged( void* board );
|
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 void setArrow( BoardCtxt* board, XP_U16 row, XP_U16 col, XP_Bool* vp );
|
||||||
static XP_Bool setArrowVisible( BoardCtxt* board, XP_Bool visible );
|
static XP_Bool setArrowVisible( BoardCtxt* board, XP_Bool visible );
|
||||||
|
|
||||||
|
@ -3467,12 +3467,12 @@ boardTurnChanged( void* p_board )
|
||||||
} /* boardTurnChanged */
|
} /* boardTurnChanged */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
boardGameOver( void* closure )
|
boardGameOver( void* closure, XP_S16 quitter )
|
||||||
{
|
{
|
||||||
BoardCtxt* board = (BoardCtxt*)closure;
|
BoardCtxt* board = (BoardCtxt*)closure;
|
||||||
board->scoreBoardInvalid = XP_TRUE; /* not sure if this will do it. */
|
board->scoreBoardInvalid = XP_TRUE; /* not sure if this will do it. */
|
||||||
board->gameOver = XP_TRUE;
|
board->gameOver = XP_TRUE;
|
||||||
util_notifyGameOver( board->util );
|
util_notifyGameOver( board->util, quitter );
|
||||||
} /* boardGameOver */
|
} /* boardGameOver */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -2411,7 +2411,7 @@ doEndGame( ServerCtxt* server, XP_S16 quitter )
|
||||||
setTurn( server, -1 );
|
setTurn( server, -1 );
|
||||||
server->nv.quitter = quitter;
|
server->nv.quitter = quitter;
|
||||||
|
|
||||||
(*server->vol.gameOverListener)( server->vol.gameOverData );
|
(*server->vol.gameOverListener)( server->vol.gameOverData, quitter );
|
||||||
} /* doEndGame */
|
} /* doEndGame */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -73,7 +73,7 @@ typedef void (*TurnChangeListener)( void* data );
|
||||||
void server_setTurnChangeListener( ServerCtxt* server, TurnChangeListener tl,
|
void server_setTurnChangeListener( ServerCtxt* server, TurnChangeListener tl,
|
||||||
void* data );
|
void* data );
|
||||||
|
|
||||||
typedef void (*GameOverListener)( void* data );
|
typedef void (*GameOverListener)( void* data, XP_S16 quitter );
|
||||||
void server_setGameOverListener( ServerCtxt* server, GameOverListener gol,
|
void server_setGameOverListener( ServerCtxt* server, GameOverListener gol,
|
||||||
void* data );
|
void* data );
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ typedef struct UtilVtable {
|
||||||
const XP_UCHAR* newSum,
|
const XP_UCHAR* newSum,
|
||||||
XWPhoniesChoice phoniesAction );
|
XWPhoniesChoice phoniesAction );
|
||||||
|
|
||||||
void (*m_util_notifyGameOver)( XW_UtilCtxt* uc );
|
void (*m_util_notifyGameOver)( XW_UtilCtxt* uc, XP_S16 quitter );
|
||||||
#ifdef XWFEATURE_HILITECELL
|
#ifdef XWFEATURE_HILITECELL
|
||||||
XP_Bool (*m_util_hiliteCell)( XW_UtilCtxt* uc, XP_U16 col, XP_U16 row );
|
XP_Bool (*m_util_hiliteCell)( XW_UtilCtxt* uc, XP_U16 col, XP_U16 row );
|
||||||
#endif
|
#endif
|
||||||
|
@ -253,8 +253,8 @@ struct XW_UtilCtxt {
|
||||||
(uc)->vtable->m_util_informUndo( (uc))
|
(uc)->vtable->m_util_informUndo( (uc))
|
||||||
#define util_informNetDict(uc, on, nn, ns, pa ) \
|
#define util_informNetDict(uc, on, nn, ns, pa ) \
|
||||||
(uc)->vtable->m_util_informNetDict( (uc), (on), (nn), (ns), (pa) )
|
(uc)->vtable->m_util_informNetDict( (uc), (on), (nn), (ns), (pa) )
|
||||||
#define util_notifyGameOver( uc ) \
|
#define util_notifyGameOver( uc, q ) \
|
||||||
(uc)->vtable->m_util_notifyGameOver((uc))
|
(uc)->vtable->m_util_notifyGameOver((uc), (q))
|
||||||
|
|
||||||
#ifdef XWFEATURE_HILITECELL
|
#ifdef XWFEATURE_HILITECELL
|
||||||
# define util_hiliteCell( uc, c, r ) \
|
# define util_hiliteCell( uc, c, r ) \
|
||||||
|
|
|
@ -371,7 +371,7 @@ curses_util_informUndo( XW_UtilCtxt* XP_UNUSED(uc))
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
curses_util_notifyGameOver( XW_UtilCtxt* uc )
|
curses_util_notifyGameOver( XW_UtilCtxt* uc, XP_S16 quitter )
|
||||||
{
|
{
|
||||||
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
|
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
|
||||||
board_draw( globals->cGlobals.game.board );
|
board_draw( globals->cGlobals.game.board );
|
||||||
|
@ -381,7 +381,7 @@ curses_util_notifyGameOver( XW_UtilCtxt* uc )
|
||||||
catGameHistory( &globals->cGlobals );
|
catGameHistory( &globals->cGlobals );
|
||||||
}
|
}
|
||||||
|
|
||||||
catFinalScores( &globals->cGlobals );
|
catFinalScores( &globals->cGlobals, quitter );
|
||||||
|
|
||||||
if ( globals->cGlobals.params->quitAfter >= 0 ) {
|
if ( globals->cGlobals.params->quitAfter >= 0 ) {
|
||||||
sleep( globals->cGlobals.params->quitAfter );
|
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 );
|
XP_Bool gameOver = server_getGameIsOver( globals->cGlobals.game.server );
|
||||||
|
|
||||||
if ( gameOver ) {
|
if ( gameOver ) {
|
||||||
catFinalScores( &globals->cGlobals );
|
catFinalScores( &globals->cGlobals, -1 );
|
||||||
} else {
|
} else {
|
||||||
if ( gtkask( globals->window,
|
if ( gtkask( globals->window,
|
||||||
"Are you sure you want to resign?",
|
"Are you sure you want to resign?",
|
||||||
|
@ -1438,7 +1438,7 @@ gtk_util_informUndo( XW_UtilCtxt* uc )
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_util_notifyGameOver( XW_UtilCtxt* uc )
|
gtk_util_notifyGameOver( XW_UtilCtxt* uc, XP_S16 quitter )
|
||||||
{
|
{
|
||||||
GtkAppGlobals* globals = (GtkAppGlobals*)uc->closure;
|
GtkAppGlobals* globals = (GtkAppGlobals*)uc->closure;
|
||||||
CommonGlobals* cGlobals = &globals->cGlobals;
|
CommonGlobals* cGlobals = &globals->cGlobals;
|
||||||
|
@ -1447,7 +1447,7 @@ gtk_util_notifyGameOver( XW_UtilCtxt* uc )
|
||||||
catGameHistory( cGlobals );
|
catGameHistory( cGlobals );
|
||||||
}
|
}
|
||||||
|
|
||||||
catFinalScores( cGlobals );
|
catFinalScores( cGlobals, quitter );
|
||||||
|
|
||||||
if ( cGlobals->params->quitAfter >= 0 ) {
|
if ( cGlobals->params->quitAfter >= 0 ) {
|
||||||
sleep( cGlobals->params->quitAfter );
|
sleep( cGlobals->params->quitAfter );
|
||||||
|
|
|
@ -213,13 +213,19 @@ catGameHistory( CommonGlobals* cGlobals )
|
||||||
} /* catGameHistory */
|
} /* catGameHistory */
|
||||||
|
|
||||||
void
|
void
|
||||||
catFinalScores( const CommonGlobals* cGlobals )
|
catFinalScores( const CommonGlobals* cGlobals, XP_S16 quitter )
|
||||||
{
|
{
|
||||||
XWStreamCtxt* stream;
|
XWStreamCtxt* stream;
|
||||||
|
|
||||||
stream = mem_stream_make( MPPARM(cGlobals->params->util->mpool)
|
stream = mem_stream_make( MPPARM(cGlobals->params->util->mpool)
|
||||||
cGlobals->params->vtMgr,
|
cGlobals->params->vtMgr,
|
||||||
NULL, CHANNEL_NONE, catOnClose );
|
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 );
|
server_writeFinalScores( cGlobals->game.server, stream );
|
||||||
stream_putU8( stream, '\n' );
|
stream_putU8( stream, '\n' );
|
||||||
stream_destroy( stream );
|
stream_destroy( stream );
|
||||||
|
|
|
@ -60,7 +60,7 @@ XP_UCHAR* strFromStream( XWStreamCtxt* stream );
|
||||||
|
|
||||||
void catGameHistory( CommonGlobals* cGlobals );
|
void catGameHistory( CommonGlobals* cGlobals );
|
||||||
void catOnClose( XWStreamCtxt* stream, void* closure );
|
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 );
|
XP_Bool file_exists( const char* fileName );
|
||||||
XWStreamCtxt* streamFromFile( CommonGlobals* cGlobals, char* name,
|
XWStreamCtxt* streamFromFile( CommonGlobals* cGlobals, char* name,
|
||||||
void* closure );
|
void* closure );
|
||||||
|
|
Loading…
Add table
Reference in a new issue