mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
track and pass all words when phonies==BLOCKED
This commit is contained in:
parent
cc4776d29d
commit
cbf81c64bd
9 changed files with 62 additions and 34 deletions
|
@ -46,6 +46,7 @@ import android.widget.TextView;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -1862,14 +1863,15 @@ public class BoardDelegate extends DelegateBase
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void informWordBlocked( final String word, final String dict )
|
public void informWordsBlocked( int nWords, final String words, final String dict )
|
||||||
{
|
{
|
||||||
runOnUiThread( new Runnable() {
|
runOnUiThread( new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
String fmtd = TextUtils.join( ", ", wordsToArray( words ) );
|
||||||
String msg = LocUtils
|
String msg = LocUtils
|
||||||
.getString( m_activity, R.string.word_blocked_by_phony,
|
.getString( m_activity, R.string.word_blocked_by_phony,
|
||||||
word, dict );
|
fmtd, dict );
|
||||||
makeOkOnlyBuilder( msg ).show();
|
makeOkOnlyBuilder( msg ).show();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
@ -2922,11 +2924,13 @@ public class BoardDelegate extends DelegateBase
|
||||||
private String[] wordsToArray( String words )
|
private String[] wordsToArray( String words )
|
||||||
{
|
{
|
||||||
String[] tmp = TextUtils.split( words, "\n" );
|
String[] tmp = TextUtils.split( words, "\n" );
|
||||||
String[] wordsArray = new String[tmp.length];
|
List<String> list = new ArrayList<>();
|
||||||
for ( int ii = 0, jj = tmp.length; ii < tmp.length; ++ii, --jj ) {
|
for ( String one : tmp ) {
|
||||||
wordsArray[ii] = tmp[jj-1];
|
if ( 0 < one.length() ) {
|
||||||
|
list.add( one );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return wordsArray;
|
return list.toArray( new String[list.size()] );
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean inArchiveGroup()
|
private boolean inArchiveGroup()
|
||||||
|
|
|
@ -62,7 +62,7 @@ public interface UtilCtxt {
|
||||||
void remSelected();
|
void remSelected();
|
||||||
void timerSelected( boolean inDuplicateMode, boolean canPause );
|
void timerSelected( boolean inDuplicateMode, boolean canPause );
|
||||||
void setIsServer( boolean isServer );
|
void setIsServer( boolean isServer );
|
||||||
void informWordBlocked( String word, String dict );
|
void informWordsBlocked( int nWords, String words, String dict );
|
||||||
|
|
||||||
void bonusSquareHeld( int bonus );
|
void bonusSquareHeld( int bonus );
|
||||||
void playerScoreHeld( int player );
|
void playerScoreHeld( int player );
|
||||||
|
|
|
@ -107,9 +107,9 @@ public class UtilCtxtImpl implements UtilCtxt {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void informWordBlocked( String word, String dict )
|
public void informWordsBlocked( int nWords, String words, String dict )
|
||||||
{
|
{
|
||||||
subclassOverride( "informWordBlocked" );
|
subclassOverride( "informWordsBlocked" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2528,7 +2528,7 @@
|
||||||
another crash. Do you want to open it anyway?</string>
|
another crash. Do you want to open it anyway?</string>
|
||||||
<string name="unsafe_open_disregard">Open anyway</string>
|
<string name="unsafe_open_disregard">Open anyway</string>
|
||||||
|
|
||||||
<string name="word_blocked_by_phony">Word %1$s not found in wordlist %2$s.</string>
|
<string name="word_blocked_by_phony">Word or words not found in wordlist %2$s: %1$s.</string>
|
||||||
|
|
||||||
<string name="gamel_menu_logs">Debug logs</string>
|
<string name="gamel_menu_logs">Debug logs</string>
|
||||||
<!-- Debug-build-only menu to turn on saving of logs -->
|
<!-- Debug-build-only menu to turn on saving of logs -->
|
||||||
|
|
|
@ -707,13 +707,14 @@ and_util_setIsServer( XW_UtilCtxt* uc, XP_Bool isServer )
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
and_util_informWordBlocked( XW_UtilCtxt* uc, const XP_UCHAR* word, const XP_UCHAR* dict )
|
and_util_informWordsBlocked( XW_UtilCtxt* uc, XP_U16 nBadWords,
|
||||||
|
XWStreamCtxt* words, const XP_UCHAR* dict )
|
||||||
{
|
{
|
||||||
UTIL_CBK_HEADER( "informWordBlocked", "(Ljava/lang/String;Ljava/lang/String;)V" );
|
UTIL_CBK_HEADER( "informWordsBlocked", "(ILjava/lang/String;Ljava/lang/String;)V" );
|
||||||
jstring jword = (*env)->NewStringUTF( env, word );
|
jstring jwords = streamToJString( env, words );
|
||||||
jstring jdict = (*env)->NewStringUTF( env, dict );
|
jstring jdict = (*env)->NewStringUTF( env, dict );
|
||||||
(*env)->CallVoidMethod( env, util->jutil, mid, jword, jdict );
|
(*env)->CallVoidMethod( env, util->jutil, mid, nBadWords, jwords, jdict );
|
||||||
deleteLocalRefs( env, jword, DELETE_NO_REF );
|
deleteLocalRefs( env, jwords, jdict, DELETE_NO_REF );
|
||||||
UTIL_CBK_TAIL();
|
UTIL_CBK_TAIL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -919,7 +920,7 @@ makeUtil( MPFORMAL EnvThreadInfo* ti, jobject jutil, CurGameInfo* gi,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SET_PROC(getDevUtilCtxt);
|
SET_PROC(getDevUtilCtxt);
|
||||||
SET_PROC(informWordBlocked);
|
SET_PROC(informWordsBlocked);
|
||||||
|
|
||||||
#undef SET_PROC
|
#undef SET_PROC
|
||||||
assertTableFull( vtable, sizeof(*vtable), "util" );
|
assertTableFull( vtable, sizeof(*vtable), "util" );
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*- compile-command: "cd ../linux && make -j3 MEMDEBUG=TRUE"; -*- */
|
/* -*- compile-command: "cd ../linux && make -j3 MEMDEBUG=TRUE"; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright 1998 - 2011 by Eric House (xwords@eehouse.org). All rights
|
* Copyright 1998 - 2020 by Eric House (xwords@eehouse.org). All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -218,8 +218,11 @@ model_figureFinalScores( ModelCtxt* model, ScoresArray* finalScoresP,
|
||||||
} /* model_figureFinalScores */
|
} /* model_figureFinalScores */
|
||||||
|
|
||||||
typedef struct _BlockCheckState {
|
typedef struct _BlockCheckState {
|
||||||
|
ModelCtxt* model;
|
||||||
|
XWStreamCtxt* stream;
|
||||||
WordNotifierInfo* chainNI;
|
WordNotifierInfo* chainNI;
|
||||||
XP_UCHAR word[32];
|
XP_U16 nBadWords;
|
||||||
|
XP_Bool silent;
|
||||||
} BlockCheckState;
|
} BlockCheckState;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -230,8 +233,17 @@ blockCheck( const WNParams* wnp, void* closure )
|
||||||
if ( !!bcs->chainNI ) {
|
if ( !!bcs->chainNI ) {
|
||||||
(bcs->chainNI->proc)( wnp, bcs->chainNI->closure );
|
(bcs->chainNI->proc)( wnp, bcs->chainNI->closure );
|
||||||
}
|
}
|
||||||
if ( !wnp->isLegal && '\0' == bcs->word[0] ) {
|
if ( !wnp->isLegal ) {
|
||||||
XP_STRCAT( bcs->word, wnp->word );
|
++bcs->nBadWords;
|
||||||
|
if ( !bcs->silent ) {
|
||||||
|
if ( NULL == bcs->stream ) {
|
||||||
|
bcs->stream =
|
||||||
|
mem_stream_make_raw( MPPARM(bcs->model->vol.mpool)
|
||||||
|
dutil_getVTManager(bcs->model->vol.dutil));
|
||||||
|
}
|
||||||
|
stream_catString( bcs->stream, wnp->word );
|
||||||
|
stream_putU8( bcs->stream, '\n' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +284,9 @@ checkScoreMove( ModelCtxt* model, XP_S16 turn, EngineCtxt* engine,
|
||||||
BlockCheckState bcs;
|
BlockCheckState bcs;
|
||||||
if ( checkDict ) {
|
if ( checkDict ) {
|
||||||
XP_MEMSET( &bcs, 0, sizeof(bcs) );
|
XP_MEMSET( &bcs, 0, sizeof(bcs) );
|
||||||
|
bcs.model = model;
|
||||||
bcs.chainNI = notifyInfo;
|
bcs.chainNI = notifyInfo;
|
||||||
|
bcs.silent = silent;
|
||||||
blockWNI.proc = blockCheck;
|
blockWNI.proc = blockCheck;
|
||||||
blockWNI.closure = &bcs;
|
blockWNI.closure = &bcs;
|
||||||
notifyInfo = &blockWNI;
|
notifyInfo = &blockWNI;
|
||||||
|
@ -280,10 +294,13 @@ checkScoreMove( ModelCtxt* model, XP_S16 turn, EngineCtxt* engine,
|
||||||
|
|
||||||
XP_S16 tmpScore = figureMoveScore( model, turn, &moveInfo,
|
XP_S16 tmpScore = figureMoveScore( model, turn, &moveInfo,
|
||||||
engine, stream, notifyInfo );
|
engine, stream, notifyInfo );
|
||||||
if ( checkDict && '\0' != bcs.word[0] ) {
|
if ( checkDict && 0 < bcs.nBadWords ) {
|
||||||
if ( !silent ) {
|
if ( !silent ) {
|
||||||
|
XP_ASSERT( !!bcs.stream );
|
||||||
DictionaryCtxt* dict = model_getPlayerDict( model, turn );
|
DictionaryCtxt* dict = model_getPlayerDict( model, turn );
|
||||||
util_informWordBlocked( model->vol.util, bcs.word, dict_getName( dict ) );
|
util_informWordsBlocked( model->vol.util, bcs.nBadWords,
|
||||||
|
bcs.stream, dict_getName( dict ) );
|
||||||
|
stream_destroy( bcs.stream );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
score = tmpScore;
|
score = tmpScore;
|
||||||
|
|
|
@ -174,8 +174,8 @@ typedef struct UtilVtable {
|
||||||
void (*m_util_setIsServer)(XW_UtilCtxt* uc, XP_Bool isServer );
|
void (*m_util_setIsServer)(XW_UtilCtxt* uc, XP_Bool isServer );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void (*m_util_informWordBlocked)( XW_UtilCtxt* uc, const XP_UCHAR* word,
|
void (*m_util_informWordsBlocked)( XW_UtilCtxt* uc, XP_U16 nBadWords,
|
||||||
const XP_UCHAR* dictName );
|
XWStreamCtxt* words, const XP_UCHAR* dictName );
|
||||||
|
|
||||||
#ifdef XWFEATURE_SEARCHLIMIT
|
#ifdef XWFEATURE_SEARCHLIMIT
|
||||||
XP_Bool (*m_util_getTraySearchLimits)(XW_UtilCtxt* uc,
|
XP_Bool (*m_util_getTraySearchLimits)(XW_UtilCtxt* uc,
|
||||||
|
@ -312,8 +312,8 @@ struct XW_UtilCtxt {
|
||||||
# define util_addrChange( uc, addro, addrn )
|
# define util_addrChange( uc, addro, addrn )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define util_informWordBlocked(uc, w, d) \
|
#define util_informWordsBlocked(uc, c, w, d) \
|
||||||
(uc)->vtable->m_util_informWordBlocked( (uc), (w), (d) )
|
(uc)->vtable->m_util_informWordsBlocked( (uc), (c), (w), (d) )
|
||||||
|
|
||||||
#ifdef XWFEATURE_SEARCHLIMIT
|
#ifdef XWFEATURE_SEARCHLIMIT
|
||||||
#define util_getTraySearchLimits(uc,min,max) \
|
#define util_getTraySearchLimits(uc,min,max) \
|
||||||
|
|
|
@ -1064,11 +1064,12 @@ curses_util_cellSquareHeld( XW_UtilCtxt* uc, XWStreamCtxt* words )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
curses_util_informWordBlocked( XW_UtilCtxt* XP_UNUSED(uc),
|
curses_util_informWordsBlocked( XW_UtilCtxt* XP_UNUSED(uc),
|
||||||
const XP_UCHAR* XP_UNUSED_DBG(word),
|
XP_U16 XP_UNUSED_DBG(nBadWords),
|
||||||
const XP_UCHAR* XP_UNUSED_DBG(dict) )
|
XWStreamCtxt* XP_UNUSED(words),
|
||||||
|
const XP_UCHAR* XP_UNUSED_DBG(dictName) )
|
||||||
{
|
{
|
||||||
XP_LOGFF( "(word=%s, dict=%s)", word, dict );
|
XP_LOGFF( "(nBadWords=%d, dict=%s)", nBadWords, dictName );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||||
|
@ -1141,7 +1142,7 @@ setupCursesUtilCallbacks( CursesBoardGlobals* bGlobals, XW_UtilCtxt* util )
|
||||||
#ifdef XWFEATURE_BOARDWORDS
|
#ifdef XWFEATURE_BOARDWORDS
|
||||||
SET_PROC(cellSquareHeld);
|
SET_PROC(cellSquareHeld);
|
||||||
#endif
|
#endif
|
||||||
SET_PROC(informWordBlocked);
|
SET_PROC(informWordsBlocked);
|
||||||
|
|
||||||
#ifdef XWFEATURE_SEARCHLIMIT
|
#ifdef XWFEATURE_SEARCHLIMIT
|
||||||
SET_PROC(getTraySearchLimits);
|
SET_PROC(getTraySearchLimits);
|
||||||
|
|
|
@ -1999,10 +1999,15 @@ gtk_util_cellSquareHeld( XW_UtilCtxt* uc, XWStreamCtxt* words )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_util_informWordBlocked( XW_UtilCtxt* uc, const XP_UCHAR* word, const XP_UCHAR* dict )
|
gtk_util_informWordsBlocked( XW_UtilCtxt* uc, XP_U16 nBadWords,
|
||||||
|
XWStreamCtxt* words, const XP_UCHAR* dict )
|
||||||
{
|
{
|
||||||
|
XP_U16 len = stream_getSize( words );
|
||||||
|
XP_UCHAR buf[len];
|
||||||
|
stream_getBytes( words, buf, len );
|
||||||
|
buf[len-1] = '\0'; /* overwrite \n */
|
||||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||||
gchar* msg = g_strdup_printf( "Word \"%s\" not found in %s", word, dict );
|
gchar* msg = g_strdup_printf( "%d word[s] not found in %s:\n%s", nBadWords, dict, buf );
|
||||||
gtkUserError( globals, msg );
|
gtkUserError( globals, msg );
|
||||||
g_free( msg );
|
g_free( msg );
|
||||||
}
|
}
|
||||||
|
@ -2239,7 +2244,7 @@ setupGtkUtilCallbacks( GtkGameGlobals* globals, XW_UtilCtxt* util )
|
||||||
#ifdef XWFEATURE_BOARDWORDS
|
#ifdef XWFEATURE_BOARDWORDS
|
||||||
SET_PROC(cellSquareHeld);
|
SET_PROC(cellSquareHeld);
|
||||||
#endif
|
#endif
|
||||||
SET_PROC(informWordBlocked);
|
SET_PROC(informWordsBlocked);
|
||||||
#undef SET_PROC
|
#undef SET_PROC
|
||||||
|
|
||||||
assertTableFull( util->vtable, sizeof(*util->vtable), "gtk util" );
|
assertTableFull( util->vtable, sizeof(*util->vtable), "gtk util" );
|
||||||
|
|
Loading…
Add table
Reference in a new issue