From 23a4a7ef6418511cf4e69bd15700cf47425f51d5 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Mon, 13 Dec 2010 06:37:26 -0800 Subject: [PATCH 1/6] get rid of unused/stubbed out method --- .../org/eehouse/android/xw4/GameConfig.java | 2 -- .../org/eehouse/android/xw4/GameUtils.java | 2 -- .../eehouse/android/xw4/jni/CurGameInfo.java | 30 ------------------- 3 files changed, 34 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java index 467b74c97..4d93354da 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java @@ -857,8 +857,6 @@ public class GameConfig extends XWActivity } } - m_gi.fixup(); - // position = m_connectSpinner.getSelectedItemPosition(); // m_car.conType = m_types[ position ]; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java index 7e16295d3..0216bdda0 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -71,7 +71,6 @@ public class GameUtils { XwJNI.game_dispose( gamePtr ); gi.setInProgress( false ); - gi.fixup(); gamePtr = XwJNI.initJNI(); XwJNI.game_makeNewGame( gamePtr, gi, JNIUtilsImpl.get(), @@ -408,7 +407,6 @@ public class GameUtils { if ( forceNew || !madeGame ) { gi.setInProgress( false ); - gi.fixup(); XwJNI.game_makeNewGame( gamePtr, gi, JNIUtilsImpl.get(), cp, dictBytes, gi.dictName ); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java index c5838eefa..421568b5b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java @@ -191,36 +191,6 @@ public class CurGameInfo { return !consistent; } - /** - * fixup: if we're pretending some players don't exist, move them - * up and make externally (i.e. in the jni world) visible fields - * consistent. - */ - public void fixup() - { - // if ( m_nVisiblePlayers < nPlayers ) { - // Assert.assertTrue( serverRole == DeviceRole.SERVER_ISCLIENT ); - - // for ( int ii = 0; ii < nPlayers; ++ii ) { - // // Assert.assertTrue( m_visiblePlayers[ii] >= ii ); - // if ( m_visiblePlayers[ii] != ii ) { - // LocalPlayer tmp = players[ii]; - // players[ii] = players[m_visiblePlayers[ii]]; - // players[m_visiblePlayers[ii]] = tmp; - // m_visiblePlayers[ii] = ii; - // } - // } - - // nPlayers = m_nVisiblePlayers; - // } - - // if ( !m_inProgress && serverRole != DeviceRole.SERVER_ISSERVER ) { - // for ( int ii = 0; ii < nPlayers; ++ii ) { - // players[ii].isLocal = true; - // } - // } - } - public String[] visibleNames( Context context ) { String[] names = new String[nPlayers]; From 299c84bb2b5d2b8ae3d90040c13aedcdab942805 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Mon, 13 Dec 2010 18:16:22 -0800 Subject: [PATCH 2/6] =?UTF-8?q?use=20sed=20rather=20than=20tr=20to=20upper?= =?UTF-8?q?case=20letters.=20=20tr=20was=20dropping=20the=20=C3=81=20lette?= =?UTF-8?q?r=20for=20some=20reason.=20=20The=20sed=20feature=20I'm=20using?= =?UTF-8?q?=20is=20a=20gnu=20extension=20but=20has=20the=20advantage=20of?= =?UTF-8?q?=20working.=20=20Should=20probably=20do=20this=20for=20all=20la?= =?UTF-8?q?nguages=20and=20in=20the=20info=20files.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xwords4/dawg/Slovak/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwords4/dawg/Slovak/Makefile b/xwords4/dawg/Slovak/Makefile index 8a2ff9062..bb8f7bf38 100644 --- a/xwords4/dawg/Slovak/Makefile +++ b/xwords4/dawg/Slovak/Makefile @@ -29,7 +29,7 @@ SOURCEDICT ?= $(XWDICTPATH)/Slovak/slovnik_scrabble.dict.gz $(XWLANG)Main.dict.gz: $(SOURCEDICT) Makefile zcat $< | tr -d '\r' | \ - tr [aáäbcčdďeéfghiíjklĺľmnňoôóprŕsštťuúvxyýzž] [AÁÄBCČDĎEÉFGHIÍJKLĹĽMNŇOÔÓPRŔSŠTŤUÚVXYÝZŽ] | \ + sed 's,.,\U\0,g' | \ grep '^[AÁÄBCČDĎEÉFGHIÍJKLĹĽMNŇOÔÓPRŔSŠTŤUÚVXYÝZŽ]*$$' | \ gzip -c > $@ From cd3ff71efbd48fbd0ca1a15b1a4262f6fe2c39dd Mon Sep 17 00:00:00 2001 From: Andy2 Date: Mon, 13 Dec 2010 18:30:22 -0800 Subject: [PATCH 3/6] notify comms layer when unable to establish connection. This allows comms logic to retry and fixes failure on device to detect when network comes up after being down when game was opened. --- .../eehouse/android/xw4/CommsTransport.java | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java index c15996e56..a5f11006d 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java @@ -100,6 +100,7 @@ public class CommsTransport implements TransportProcs { @Override public void run() { + boolean failed = true; try { if ( Build.PRODUCT.contains("sdk") ) { System.setProperty("java.net.preferIPv6Addresses", "false"); @@ -107,7 +108,7 @@ public class CommsTransport implements TransportProcs { m_selector = Selector.open(); - loop(); + failed = loop(); closeSocket(); } catch ( java.io.IOException ioe ) { @@ -117,11 +118,16 @@ public class CommsTransport implements TransportProcs { m_addr.ip_relay_hostName, m_addr.ip_relay_port, uae.toString() ); } + m_thread = null; + if ( failed ) { + m_jniThread.handle( JNICmd.CMD_TRANSFAIL ); + } } - private void loop() + private boolean loop() { + boolean failed = false; outer_loop: while ( !m_done ) { try { @@ -136,12 +142,14 @@ public class CommsTransport implements TransportProcs { Utils.logf( "connecting to %s:%d", m_addr.ip_relay_hostName, m_addr.ip_relay_port ); - InetSocketAddress isa - = new InetSocketAddress( m_addr.ip_relay_hostName, - m_addr.ip_relay_port ); + InetSocketAddress isa = new + InetSocketAddress(m_addr.ip_relay_hostName, + m_addr.ip_relay_port ); m_socketChannel.connect( isa ); } catch ( java.io.IOException ioe ) { Utils.logf( ioe.toString() ); + failed = true; + break outer_loop; } } @@ -154,7 +162,7 @@ public class CommsTransport implements TransportProcs { m_selector.select(); } catch ( ClosedChannelException cce ) { // we get this when relay goes down. Need to notify! - m_jniThread.handle( JNICmd.CMD_TRANSFAIL ); + failed = true; closeSocket(); Utils.logf( "exiting: " + cce.toString() ); break; // don't try again @@ -162,6 +170,10 @@ public class CommsTransport implements TransportProcs { closeSocket(); Utils.logf( "exiting: " + ioe.toString() ); Utils.logf( ioe.toString() ); + } catch ( java.nio.channels.NoConnectionPendingException ncp ) { + Utils.logf( "%s", ncp.toString() ); + closeSocket(); + break; } Iterator iter = m_selector.selectedKeys().iterator(); @@ -196,12 +208,17 @@ public class CommsTransport implements TransportProcs { } catch ( java.io.IOException ioe ) { Utils.logf( "%s: cancelling key", ioe.toString() ); key.cancel(); + failed = true; + break outer_loop; + } catch ( java.nio.channels. + NoConnectionPendingException ncp ) { + Utils.logf( "%s", ncp.toString() ); break outer_loop; } } } + return failed; } // loop - } public void setReceiver( JNIThread jnit ) From dc807c948a8e686a2b47f78d86f6017c5e183cb0 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Mon, 13 Dec 2010 19:58:37 -0800 Subject: [PATCH 4/6] use sed instead of tr since as with Slovak a letter was getting dropped. Same one in fact. --- xwords4/dawg/Czech/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwords4/dawg/Czech/Makefile b/xwords4/dawg/Czech/Makefile index 3f9502292..33e07e750 100644 --- a/xwords4/dawg/Czech/Makefile +++ b/xwords4/dawg/Czech/Makefile @@ -29,7 +29,7 @@ SOURCEDICT ?= $(XWDICTPATH)/Czech/Czech.2-1-6.dict.gz $(XWLANG)Main.dict.gz: $(SOURCEDICT) Makefile zcat $< | tr -d '\r' | \ - tr [aábcčdďeéěfghiíjklmnňoóprřsštťuúůvxyýzž] [AÁBCČDĎEÉĚFGHIÍJKLMNŇOÓPRŘSŠTŤUÚŮVXYÝZŽ] | \ + sed 's,.,\U\0,g' | \ grep '^[AÁBCČDĎEÉĚFGHIÍJKLMNŇOÓPRŘSŠTŤUÚŮVXYÝZŽ]*$$' | \ gzip -c > $@ From bb0a79914b04fbe475d30dd3520c71f3d5540363 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Mon, 13 Dec 2010 20:09:09 -0800 Subject: [PATCH 5/6] add conversion from ISO88591 since the default dict's in that format. --- xwords4/dawg/German/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xwords4/dawg/German/Makefile b/xwords4/dawg/German/Makefile index b5e453d5a..2352b1de3 100644 --- a/xwords4/dawg/German/Makefile +++ b/xwords4/dawg/German/Makefile @@ -30,7 +30,8 @@ SOURCEDICT ?= $(XWDICTPATH)/German/HansGerman.dict.gz $(XWLANG)Main.dict.gz: $(SOURCEDICT) Makefile zcat $< \ - | tr [a-zäöü] [A-ZÄÖÜ] \ + | iconv -f iso88591 -t utf8 \ + | sed 's,.,\U\0,g' \ | sed -e 's/ß/SS/g' \ | grep '^[A-ZÄÖÜ]*$$' \ | gzip -c > $@ From d78584fddfadace37c2545247d527c3b097e8990 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Mon, 13 Dec 2010 20:09:26 -0800 Subject: [PATCH 6/6] remove obsolete, pre-utf8 files --- xwords4/dawg/Czech-CP1250/Makefile | 43 -------------- xwords4/dawg/Czech-CP1250/info.txt | 84 --------------------------- xwords4/dawg/Czech-ISO8859-2/Makefile | 43 -------------- xwords4/dawg/Czech-ISO8859-2/info.txt | 84 --------------------------- 4 files changed, 254 deletions(-) delete mode 100644 xwords4/dawg/Czech-CP1250/Makefile delete mode 100644 xwords4/dawg/Czech-CP1250/info.txt delete mode 100644 xwords4/dawg/Czech-ISO8859-2/Makefile delete mode 100644 xwords4/dawg/Czech-ISO8859-2/info.txt diff --git a/xwords4/dawg/Czech-CP1250/Makefile b/xwords4/dawg/Czech-CP1250/Makefile deleted file mode 100644 index a93be3001..000000000 --- a/xwords4/dawg/Czech-CP1250/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# -*-mode: Makefile; coding: windows-1250; -*- -# Copyright 2002-2008 by Eric House (xwords@eehouse.org). All rights reserved. -# -# 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. - -XWLANG=Czech-CP1250 -LANGCODE=cs_CS - -TARGET_TYPE ?= PALM - -include ../Makefile.2to8 - -include ../Makefile.langcommon - -SOURCEDICT ?= $(XWDICTPATH)/$(XWLANG)/czech2_5.dict.gz - -$(XWLANG)Main.dict.gz: $(SOURCEDICT) Makefile - export LC_ALL=$(LANGCODE); \ - zcat $< | \ - tr [abcdefghijklmnoprstuvxyz] [ABCDEFGHIJKLMNOPRSTUVXYZ] | \ - grep '^[ABCDEFGHIJKLMNOPRSTUVXYZ]\+$$' | \ - gzip -c > $@ - -# Everything but creating of the Main.dict file is inherited from the -# "parent" Makefile.langcommon in the parent directory. - -clean: clean_common - rm -f $(XWLANG)Main.dict.gz *.bin $(XWLANG)*.pdb $(XWLANG)*.seb - -help: - @echo 'make [SOURCEDICT=$(XWDICTPATH)/$(XWLANG)/czech2_5.dict.gz]' diff --git a/xwords4/dawg/Czech-CP1250/info.txt b/xwords4/dawg/Czech-CP1250/info.txt deleted file mode 100644 index 28f171332..000000000 --- a/xwords4/dawg/Czech-CP1250/info.txt +++ /dev/null @@ -1,84 +0,0 @@ -# -*- coding: windows-1250; mode: conf; -*- -# Copyright 2002-2008 by Eric House (xwords@eehouse.org). All rights reserved. -# -# 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. - -LANGCODE:cs_CZ -CHARSET:windows-1250 - -# deal with DOS files -LANGFILTER: tr -d '\r' -# tr seems to work on systems that don't know the Czech locale, but -# grep does not. So don't use grep, e.g. to eliminate words -# containing letters not in our alphabet. Instead, pass the -r flag -# via D2DARGS so they're dropped. -LANGFILTER: | tr [abcdefghijklmnoprstuvxyz] [ABCDEFGHIJKLMNOPRSTUVXYZ] -LANGFILTER: | sort -u - -# presence of high-ascii means we must not pass -nosort -D2DARGS: -term 10 -r - -LANGINFO:

This BYOD language works on Czech wordlists encoded in -LANGINFO: windows-1250 and produces dictionaries that should work on -LANGINFO: windows-1250-localized systems. If your Czech wordlist is -LANGINFO: iso-8859-2-encoded, go back and choose Czech-ISO8859-2.

- -# High bit means "official". Next 7 bits are an enum where -# Czech-CP1250==0x10. Low byte is padding. -XLOC_HEADER:0x9000 - -#COUNT VAL FACE - -2 0 {"_"} -5 1 'A' -2 2 '' -2 3 'B' -3 2 'C' -1 4 '' -3 1 'D' -1 8 '' -5 1 'E' -2 3 '' -2 3 '' -1 5 'F' -1 5 'G' -3 2 'H' -4 1 'I' -3 2 '' -2 2 'J' -3 1 'K' -3 1 'L' -3 2 'M' -5 1 'N' -1 6 '' -6 1 'O' -1 7 '' -3 1 'P' -3 1 'R' -2 4 '' -4 1 'S' -2 4 '' -4 1 'T' -1 7 '' -3 2 'U' -1 5 '' -1 4 '' -4 1 'V' -1 10 'X' -2 2 'Y' -2 4 '' -2 2 'Z' -1 4 '' - diff --git a/xwords4/dawg/Czech-ISO8859-2/Makefile b/xwords4/dawg/Czech-ISO8859-2/Makefile deleted file mode 100644 index f7c4e68aa..000000000 --- a/xwords4/dawg/Czech-ISO8859-2/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# -*-mode: Makefile; coding: iso-8859-2; -*- -# Copyright 2002-2008 by Eric House (xwords@eehouse.org). All rights reserved. -# -# 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. - -XWLANG=Czech-ISO8859-2 -LANGCODE=cs_CS - -TARGET_TYPE ?= PALM - -include ../Makefile.2to8 - -include ../Makefile.langcommon - -SOURCEDICT ?= $(XWDICTPATH)/$(XWLANG)/czech2_10_iso.dict.gz - -$(XWLANG)Main.dict.gz: $(SOURCEDICT) Makefile - export LC_ALL=$(LANGCODE); \ - zcat $< | \ - tr [abcdefghijklmnoprstuvxyz] [ABCDEFGHIJKLMNOPRSTUVXYZ] | \ - grep '^[ABCDEFGHIJKLMNOPRSTUVXYZ]\+$$' | \ - gzip -c > $@ - -# Everything but creating of the Main.dict file is inherited from the -# "parent" Makefile.langcommon in the parent directory. - -clean: clean_common - rm -f $(XWLANG)Main.dict.gz *.bin $(XWLANG)*.pdb $(XWLANG)*.seb - -help: - @echo 'make [SOURCEDICT=$(XWDICTPATH)/$(XWLANG)/czech2_5.dict.gz]' diff --git a/xwords4/dawg/Czech-ISO8859-2/info.txt b/xwords4/dawg/Czech-ISO8859-2/info.txt deleted file mode 100644 index 882db9c62..000000000 --- a/xwords4/dawg/Czech-ISO8859-2/info.txt +++ /dev/null @@ -1,84 +0,0 @@ -# -*- coding: iso-8859-2; mode: conf; -*- -# Copyright 2002-2008 by Eric House (xwords@eehouse.org). All rights reserved. -# -# 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. - -LANGCODE:cs_CZ -CHARSET:iso-8859-2 - -# deal with DOS files -LANGFILTER: tr -d '\r' -# tr seems to work on systems that don't know the Czech locale, but -# grep does not. So don't use grep, e.g. to eliminate words -# containing letters not in our alphabet. Instead, pass the -r flag -# via D2DARGS so they're dropped. -LANGFILTER: | tr [abcdefghijklmnoprstuvxyz] [ABCDEFGHIJKLMNOPRSTUVXYZ] -LANGFILTER: | sort -u - -# presence of high-ascii means we must not pass -nosort -D2DARGS: -term 10 -r - -LANGINFO:

This BYOD language works on Czech wordlists encoded in -LANGINFO: iso-8859-2 and produces dictionaries that should work on -LANGINFO: iso-8859-2-localized systems. If your Czech wordlist is -LANGINFO: windows-1250-encoded, go back and choose Czech-CP1250.

- -# High bit means "official". Next 7 bits are an enum where -# Czech-ISO8859-2==0x11. Low byte is padding. -XLOC_HEADER:0x9100 - -#COUNT VAL FACE - -2 0 {"_"} -5 1 'A' -2 2 '' -2 3 'B' -3 2 'C' -1 4 '' -3 1 'D' -1 8 '' -5 1 'E' -2 3 '' -2 3 '' -1 5 'F' -1 5 'G' -3 2 'H' -4 1 'I' -3 2 '' -2 2 'J' -3 1 'K' -3 1 'L' -3 2 'M' -5 1 'N' -1 6 '' -6 1 'O' -1 7 '' -3 1 'P' -3 1 'R' -2 4 '' -4 1 'S' -2 4 '' -4 1 'T' -1 7 '' -3 2 'U' -1 5 '' -1 4 '' -4 1 'V' -1 10 'X' -2 2 'Y' -2 4 '' -2 2 'Z' -1 4 '' -