From 81a6d422799d52e6c9d1c252f751a8cdc671fb4d Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 16 Aug 2015 09:24:42 -0700 Subject: [PATCH 01/11] fix version code --- xwords4/android/XWords4-dbg/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwords4/android/XWords4-dbg/AndroidManifest.xml b/xwords4/android/XWords4-dbg/AndroidManifest.xml index 381e8e344..bc8a109d6 100644 --- a/xwords4/android/XWords4-dbg/AndroidManifest.xml +++ b/xwords4/android/XWords4-dbg/AndroidManifest.xml @@ -22,7 +22,7 @@ to come from a domain that you own or have control over. --> From f7f4825c6763154081dbcca0a4431860965e4727 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 16 Aug 2015 09:25:00 -0700 Subject: [PATCH 02/11] deal with case where file doesn't exist --- xwords4/android/scripts/mkvariant.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwords4/android/scripts/mkvariant.sh b/xwords4/android/scripts/mkvariant.sh index 56ce68943..b781f6d6d 100755 --- a/xwords4/android/scripts/mkvariant.sh +++ b/xwords4/android/scripts/mkvariant.sh @@ -40,7 +40,7 @@ do_dir() { for FILE in $SRC_PATH/*; do if [ -d $FILE ]; then do_dir $SRC_PATH $DEST_PATH $(basename $FILE) - else + elif [ -e $FILE ]; then FILE=${FILE/$SRC_PATH/$DEST_PATH} if git ls-files $FILE --error-unmatch 2>/dev/null; then echo "skipping $FILE; it's under version control within this variant" From 01b746860e5aaaf70a323531ce3cafbacd95b7e7 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 16 Aug 2015 09:26:48 -0700 Subject: [PATCH 03/11] add accessor for current selected player --- xwords4/common/board.c | 6 ++++++ xwords4/common/board.h | 1 + 2 files changed, 7 insertions(+) diff --git a/xwords4/common/board.c b/xwords4/common/board.c index 5e95c6f1f..6696d9d87 100644 --- a/xwords4/common/board.c +++ b/xwords4/common/board.c @@ -1823,6 +1823,12 @@ board_getTrayVisState( const BoardCtxt* board ) return board->trayVisState; } /* board_getTrayVisible */ +XP_S16 +board_getSelPlayer( const BoardCtxt* board ) +{ + return board->selPlayer; +} + static XP_Bool setTrayVisState( BoardCtxt* board, XW_TrayVisState newState ) { diff --git a/xwords4/common/board.h b/xwords4/common/board.h index 196a11c22..06f116fb1 100644 --- a/xwords4/common/board.h +++ b/xwords4/common/board.h @@ -197,6 +197,7 @@ XP_Bool board_focusChanged( BoardCtxt* board, BoardObjectType typ, XP_Bool board_hideTray( BoardCtxt* board ); XP_Bool board_showTray( BoardCtxt* board ); XW_TrayVisState board_getTrayVisState( const BoardCtxt* board ); +XP_S16 board_getSelPlayer( const BoardCtxt* board ); void board_invalTrayTiles( BoardCtxt* board, TileBit what ); XP_Bool board_juggleTray( BoardCtxt* board ); From 8065e55b98eea688adc8c8f02856669196737b2b Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 16 Aug 2015 09:38:55 -0700 Subject: [PATCH 04/11] pipe board_getSelPlayer() through jni --- xwords4/android/XWords4/jni/xwjni.c | 12 ++++++++++++ .../src/org/eehouse/android/xw4/jni/XwJNI.java | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 4beaceee0..4acbec37d 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -949,6 +949,18 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1getActiveRect } #endif +JNIEXPORT jint JNICALL +Java_org_eehouse_android_xw4_jni_XwJNI_board_1getSelPlayer +( JNIEnv* env, jclass C, jint gamePtr ) +{ + jint result; + XWJNI_START(); + result = board_getSelPlayer( state->game.board ); + XWJNI_END(); + return result; +} + + JNIEXPORT jboolean JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_board_1handlePenDown (JNIEnv *env, jclass C, jint gamePtr, jint xx, jint yy, jbooleanArray barray ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java index 2f3da7be4..eaf8c29e3 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java @@ -235,7 +235,7 @@ public class XwJNI { boolean[] canZoom ); public static native boolean board_getActiveRect( int gamePtr, Rect rect, int[] dims ); - + public static native int board_getSelPlayer( int gamePtr ); public static native boolean board_handlePenDown( int gamePtr, int xx, int yy, boolean[] handled ); From 1a258be2f43c2781193ad45e11fe910255593a83 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 27 Aug 2015 21:57:19 -0700 Subject: [PATCH 05/11] merge in latest from android_translate branch --- xwords4/android/XWords4/res_src/values-fr/strings.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/xwords4/android/XWords4/res_src/values-fr/strings.xml b/xwords4/android/XWords4/res_src/values-fr/strings.xml index b48275485..c58501b51 100644 --- a/xwords4/android/XWords4/res_src/values-fr/strings.xml +++ b/xwords4/android/XWords4/res_src/values-fr/strings.xml @@ -2271,16 +2271,14 @@ seulement des informations sur les jetons. Il n\'y a pas de mots à parcourir.Envoyer un mail à l\'auteur - Comment about Crosswords + Commentaire sur Crosswords Envoyer un commentaire par - (If relevant, please include the - version: \"%1$s\"; and make/model of your phone or - tablet.) + (Si c\'est pertinent, merci d\'inclure la version : « %1$s » ; et le modèle de votre téléphone ou votre tablette.) From c8fcc32c2c3d88613c347119d4e87ee3a017caf7 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 14 Sep 2015 08:49:52 -0700 Subject: [PATCH 06/11] When two moves are identical (i.e. a one-letter word that forms two words words) drop one when looking for hints --- xwords4/common/engine.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/xwords4/common/engine.c b/xwords4/common/engine.c index 334c69342..18a513696 100644 --- a/xwords4/common/engine.c +++ b/xwords4/common/engine.c @@ -1,6 +1,6 @@ /* -*- compile-command: "cd ../linux && make -j3 MEMDEBUG=TRUE"; -*- */ /* - * Copyright 1997 - 2012 by Eric House (xwords@eehouse.org). All rights + * Copyright 1997 - 2015 by Eric House (xwords@eehouse.org). All rights * reserved. * * This program is free software; you can redistribute it and/or @@ -39,11 +39,10 @@ typedef struct BlankTuple { } BlankTuple; typedef struct PossibleMove { - XP_U16 score; /* Because I'm doing a memcmp to sort these things, - the comparison must be done differently on - little-endian platforms. */ + XP_U16 score; /* Because I'm doing a memcmp to sort these things, the + comparison must be done differently on little-endian + platforms. */ MoveInfo moveInfo; - //XP_U16 whichBlanks; /* flags */ Tile blankVals[MAX_COLS]; /* the faces for which we've substituted blanks */ } PossibleMove; @@ -1088,12 +1087,26 @@ considerMove( EngineCtxt* engine, Tile* tiles, XP_S16 tileLength, posmove.moveInfo.isHorizontal = engine->searchHorizontal; posmove.moveInfo.commonCoord = (XP_U8)lastRow; - considerScoreWordHasBlanks( engine, engine->blankCount, &posmove, lastRow, blankTuples, 0 ); } } /* considerMove */ +static XP_Bool +countWords( const XP_UCHAR* XP_UNUSED(word), XP_Bool isLegal, + const DictionaryCtxt* XP_UNUSED(dict), +#ifdef XWFEATURE_BOARDWORDS + const MoveInfo* movei, XP_U16 start, + XP_U16 end, +#endif + void* closure ) +{ + XP_U16* wcp = (XP_U16*)closure; + if ( isLegal ) { + ++*wcp; + } +} + static void considerScoreWordHasBlanks( EngineCtxt* engine, XP_U16 blanksLeft, PossibleMove* posmove, @@ -1104,11 +1117,19 @@ considerScoreWordHasBlanks( EngineCtxt* engine, XP_U16 blanksLeft, if ( blanksLeft == 0 ) { XP_U16 score; + XP_U16 nTiles = posmove->moveInfo.nTiles; + WordNotifierInfo* wiip = NULL; + WordNotifierInfo wii; + XP_U16 wordCount = 0; + if ( 1 == nTiles ) { + wii.proc = countWords; + wii.closure = &wordCount; + wiip = &wii; + } score = figureMoveScore( engine->model, engine->turn, &posmove->moveInfo, - engine, (XWStreamCtxt*)NULL, - (WordNotifierInfo*)NULL ); + engine, (XWStreamCtxt*)NULL, wiip ); #ifdef XWFEATURE_BONUSALL if ( 0 != engine->allTilesBonus && 0 == engine->nTilesMax ) { XP_LOGF( "%s: adding bonus: %d becoming %d", __func__, score , @@ -1119,7 +1140,9 @@ considerScoreWordHasBlanks( EngineCtxt* engine, XP_U16 blanksLeft, /* First, check that the score is even what we're interested in. If it is, then go to the expense of filling in a PossibleMove to be compared in full */ - if ( scoreQualifies( engine, score ) ) { + if ( 1 == nTiles && 1 < wordCount && !engine->searchHorizontal ) { + XP_LOGF( "%s(): dropping", __func__ ); + } else if ( scoreQualifies( engine, score ) ) { posmove->score = score; XP_MEMSET( &posmove->blankVals, 0, sizeof(posmove->blankVals) ); for ( ii = 0; ii < usedBlanksCount; ++ii ) { From cba1293bec84ecbcb6efda6bb0c328282952c014 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 15 Sep 2015 20:54:01 -0700 Subject: [PATCH 07/11] make return value void since it's never used --- xwords4/common/board.c | 3 +-- xwords4/common/model.c | 11 +++++------ xwords4/common/model.h | 10 +++++----- xwords4/common/server.c | 3 +-- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/xwords4/common/board.c b/xwords4/common/board.c index 5e95c6f1f..a600442a3 100644 --- a/xwords4/common/board.c +++ b/xwords4/common/board.c @@ -946,7 +946,7 @@ hideMiniWindow( BoardCtxt* board, XP_Bool destroy, MiniWindowType winType ) #endif #endif -static XP_Bool +static void warnBadWords( const XP_UCHAR* word, XP_Bool isLegal, const DictionaryCtxt* XP_UNUSED(dict), #ifdef XWFEATURE_BOARDWORDS @@ -970,7 +970,6 @@ warnBadWords( const XP_UCHAR* word, XP_Bool isLegal, && util_warnIllegalWord( board->util, &bwi, turn, XP_FALSE ); board->badWordRejected = !ok || board->badWordRejected; } - return ok; } /* warnBadWords */ static XP_Bool diff --git a/xwords4/common/model.c b/xwords4/common/model.c index 122d8b3ee..a2818113a 100644 --- a/xwords4/common/model.c +++ b/xwords4/common/model.c @@ -78,13 +78,13 @@ static void loadPlayerCtxt( const ModelCtxt* model, XWStreamCtxt* stream, static void writePlayerCtxt( const ModelCtxt* model, XWStreamCtxt* stream, const PlayerCtxt* pc ); static XP_U16 model_getRecentPassCount( ModelCtxt* model ); -static XP_Bool recordWord( const XP_UCHAR* word, XP_Bool isLegal, - const DictionaryCtxt* dict, +static void recordWord( const XP_UCHAR* word, XP_Bool isLegal, + const DictionaryCtxt* dict, #ifdef XWFEATURE_BOARDWORDS - const MoveInfo* movei, XP_U16 start, XP_U16 end, + const MoveInfo* movei, XP_U16 start, XP_U16 end, #endif - void* clsur ); + void* clsur ); #ifdef DEBUG typedef struct _DiffTurnState { XP_S16 lastPlayerNum; @@ -2281,7 +2281,7 @@ appendWithCR( XWStreamCtxt* stream, const XP_UCHAR* word, XP_U16* counter ) stream_catString( stream, word ); } -static XP_Bool +static void recordWord( const XP_UCHAR* word, XP_Bool XP_UNUSED(isLegal), const DictionaryCtxt* XP_UNUSED(dict), #ifdef XWFEATURE_BOARDWORDS @@ -2293,7 +2293,6 @@ recordWord( const XP_UCHAR* word, XP_Bool XP_UNUSED(isLegal), { RecordWordsInfo* info = (RecordWordsInfo*)closure; appendWithCR( info->stream, word, &info->nWords ); - return XP_TRUE; } WordNotifierInfo* diff --git a/xwords4/common/model.h b/xwords4/common/model.h index cfaf0b27f..c58f95ded 100644 --- a/xwords4/common/model.h +++ b/xwords4/common/model.h @@ -256,13 +256,13 @@ void model_countAllTrayTiles( ModelCtxt* model, XP_U16* counts, /********************* scoring ********************/ -typedef XP_Bool (*WordNotifierProc)( const XP_UCHAR* word, XP_Bool isLegal, - const DictionaryCtxt* dict, +typedef void (*WordNotifierProc)( const XP_UCHAR* word, XP_Bool isLegal, + const DictionaryCtxt* dict, #ifdef XWFEATURE_BOARDWORDS - const MoveInfo* movei, XP_U16 start, - XP_U16 end, + const MoveInfo* movei, XP_U16 start, + XP_U16 end, #endif - void* closure ); + void* closure ); typedef struct WordNotifierInfo { WordNotifierProc proc; void* closure; diff --git a/xwords4/common/server.c b/xwords4/common/server.c index ae66ddf6f..c7e424db0 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -1975,7 +1975,7 @@ server_setGameOverListener( ServerCtxt* server, GameOverListener gol, server->vol.gameOverData = data; } /* server_setGameOverListener */ -static XP_Bool +static void storeBadWords( const XP_UCHAR* word, XP_Bool isLegal, const DictionaryCtxt* dict, #ifdef XWFEATURE_BOARDWORDS @@ -1995,7 +1995,6 @@ storeBadWords( const XP_UCHAR* word, XP_Bool isLegal, server->illegalWordInfo.words[server->illegalWordInfo.nWords++] = copyString( server->mpool, word ); } - return XP_TRUE; } /* storeBadWords */ static XP_Bool From f3d8f0b8eeda48e5c26d3cc6a14a2ff64055f604 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 15 Sep 2015 20:57:39 -0700 Subject: [PATCH 08/11] pass V=1 to ndk build script to make cc calls verbose --- xwords4/android/scripts/common_targets.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/xwords4/android/scripts/common_targets.xml b/xwords4/android/scripts/common_targets.xml index 83a1c640b..624c77927 100644 --- a/xwords4/android/scripts/common_targets.xml +++ b/xwords4/android/scripts/common_targets.xml @@ -36,6 +36,7 @@ + Date: Wed, 16 Sep 2015 06:42:01 -0700 Subject: [PATCH 09/11] Revert to old proto since the version that's out there now won't work with the new. Can switch once this version's distributed. --- .../src/org/eehouse/android/xw4/SMSService.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java index 4805622f7..deea62721 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java @@ -74,7 +74,7 @@ public class SMSService extends XWService { private static final int SMS_PROTO_VERSION_ORIG = 0; private static final int SMS_PROTO_VERSION_WITHPORT = 1; - private static final int SMS_PROTO_VERSION = SMS_PROTO_VERSION_WITHPORT; + private static final int SMS_PROTO_VERSION = SMS_PROTO_VERSION_ORIG; private static final int MAX_LEN_TEXT = 100; private static final int MAX_LEN_BINARY = 100; private static final int MAX_MSG_COUNT = 16; // 1.6K enough? Should be.... @@ -452,7 +452,9 @@ public class SMSService extends XWService { ByteArrayOutputStream bas = new ByteArrayOutputStream( 128 ); DataOutputStream dos = new DataOutputStream( bas ); dos.writeByte( SMS_PROTO_VERSION ); - dos.writeShort( getNBSPort() ); + if ( SMS_PROTO_VERSION_WITHPORT <= SMS_PROTO_VERSION ) { + dos.writeShort( getNBSPort() ); + } dos.writeByte( cmd.ordinal() ); dos.write( bytes, 0, bytes.length ); dos.flush(); @@ -607,19 +609,19 @@ public class SMSService extends XWService { try { byte proto = dis.readByte(); short myPort = getNBSPort(); - short sentPort; + short gotPort; if ( SMS_PROTO_VERSION_WITHPORT > proto ) { - sentPort = myPort; + gotPort = myPort; } else { - sentPort = dis.readShort(); + gotPort = dis.readShort(); } if ( SMS_PROTO_VERSION < proto ) { DbgUtils.logf( "SMSService.disAssemble: bad proto %d from %s;" + " dropping", proto, senderPhone ); sendResult( MultiEvent.BAD_PROTO_SMS, senderPhone ); - } else if ( sentPort != myPort ) { + } else if ( gotPort != myPort ) { DbgUtils.logdf( "SMSService.disAssemble(): received on port %d" - + " but expected %d", sentPort, myPort ); + + " but expected %d", gotPort, myPort ); } else { SMS_CMD cmd = SMS_CMD.values()[dis.readByte()]; byte[] rest = new byte[dis.available()]; From 6eb2e8e174f0a829a13e08c678e758f1c885269b Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 16 Sep 2015 06:49:52 -0700 Subject: [PATCH 10/11] pull in latest French translation --- .../XWords4/res_src/values-fr/strings.xml | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/xwords4/android/XWords4/res_src/values-fr/strings.xml b/xwords4/android/XWords4/res_src/values-fr/strings.xml index c58501b51..346d77730 100644 --- a/xwords4/android/XWords4/res_src/values-fr/strings.xml +++ b/xwords4/android/XWords4/res_src/values-fr/strings.xml @@ -816,9 +816,9 @@ coup ? - a échangé un jeton. - a échangé %1$d jetons. - + a échangé un jeton. + a échangé %1$d jetons. + @@ -2809,9 +2809,9 @@ les %1$d mots sélectionnés ?\n\n(Cette action ne peut pas être annulée.)%1$d word[s] copied--> - %1$d mot copié - %1$d mots copiés - + Un mot copié + %1$d mots copiés + %1$s ajouté à la liste d\'étude en %2$s @@ -2857,9 +2857,9 @@ mails. - %1$d nouvelle traduction installée - %1$d nouvelles traductions installées - + Une nouvelle traduction installée + %1$d nouvelles traductions installées + Activer les traductions locales @@ -3039,9 +3039,9 @@ pour voir ce qui est disponible. - %1$s a échangé %2$d jeton - %1$s a échangé %2$d jetons - + %1$s a échangé un jeton + %1$s a échangé %2$d jetons + %1$s a perdu un tour From 34ecd92ff5f22b63c084cefb1e33537492e43fce Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 16 Sep 2015 07:01:09 -0700 Subject: [PATCH 11/11] script to copy translation data from android_translate branch --- xwords4/android/scripts/copy-xlations.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 xwords4/android/scripts/copy-xlations.sh diff --git a/xwords4/android/scripts/copy-xlations.sh b/xwords4/android/scripts/copy-xlations.sh new file mode 100755 index 000000000..847db8970 --- /dev/null +++ b/xwords4/android/scripts/copy-xlations.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +usage() { + [ $# -eq 0 ] || echo "ERROR: $1" + echo "usage: $0" + echo " git-copies all strings.xml translations from android_translate" + echo " branch to the current one. DOES NOT COMMIT nor consider history etc." + exit 1 +} + +[ $# -eq 0 ] || usage "unexpected paramater $1" + +for LANGDIR in res_src/values-??; do + echo "copying from $LANGDIR" + git show android_translate:xwords4/android/XWords4/${LANGDIR}/strings.xml > ${LANGDIR}/strings.xml +done