mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-14 08:01:38 +01:00
Merge remote branch 'origin/android_branch' into android_branch
Conflicts: xwords4/common/model.c
This commit is contained in:
commit
1e48a8d615
84 changed files with 906 additions and 608 deletions
1
xwords4/android/XWords4/.gitignore
vendored
1
xwords4/android/XWords4/.gitignore
vendored
|
@ -4,3 +4,4 @@ local.properties
|
|||
bin
|
||||
gen
|
||||
libs
|
||||
proguard.cfg
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<!-- <uses-permission android:name="android.permission.RECEIVE_SMS" /> -->
|
||||
<!-- <uses-permission android:name="android.permission.SEND_SMS" /> -->
|
||||
|
||||
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />
|
||||
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="5" />
|
||||
|
||||
<application android:icon="@drawable/icon48x48"
|
||||
android:label="@string/app_name"
|
||||
|
|
13
xwords4/android/XWords4/project.properties
Normal file
13
xwords4/android/XWords4/project.properties
Normal file
|
@ -0,0 +1,13 @@
|
|||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system use,
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
|
||||
# Indicates whether an apk should be generated for each density.
|
||||
split.density=false
|
||||
# Project target.
|
||||
target=android-5
|
35
xwords4/android/XWords4/res/layout/prefs_w_buttons.xml
Normal file
35
xwords4/android/XWords4/res/layout/prefs_w_buttons.xml
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1"
|
||||
>
|
||||
|
||||
<ListView android:id="@id/android:list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1"
|
||||
android:drawSelectorOnTop="false"
|
||||
/>
|
||||
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
>
|
||||
<Button android:id="@+id/revert_colors"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/button_revert_colors"
|
||||
/>
|
||||
<Button android:id="@+id/revert_all"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/button_revert_all"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/menu_revert_colors"
|
||||
android:title="@string/menu_revert_colors"
|
||||
/>
|
||||
<item android:id="@+id/menu_revert_all"
|
||||
android:title="@string/menu_revert_all"
|
||||
/>
|
||||
</menu>
|
|
@ -797,13 +797,13 @@
|
|||
-->
|
||||
<!-- text of first menu item. Will revert all preferences to
|
||||
their default/original values -->
|
||||
<string name="menu_revert_all">Restore all</string>
|
||||
<string name="button_revert_all">Restore all</string>
|
||||
<!-- Text of confirmation dialog for above -->
|
||||
<string name="confirm_revert_colors">Are you sure you want to
|
||||
restore all color settings to their original values?</string>
|
||||
<!-- Second menu item. Reverts only the colors to their
|
||||
default/original values -->
|
||||
<string name="menu_revert_colors">Restore colors</string>
|
||||
<string name="button_revert_colors">Restore colors</string>
|
||||
<!-- Text of confirmation dialog for above -->
|
||||
<string name="confirm_revert_all">Are you sure you want to restore
|
||||
all settings to their original values?</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2011 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -652,7 +652,7 @@ public class BoardActivity extends XWActivity
|
|||
break;
|
||||
|
||||
default:
|
||||
Utils.logf( "menuitem %d not handled", id );
|
||||
DbgUtils.logf( "menuitem %d not handled", id );
|
||||
handled = false;
|
||||
}
|
||||
|
||||
|
@ -978,8 +978,8 @@ public class BoardActivity extends XWActivity
|
|||
DeviceRole newRole = isServer? DeviceRole.SERVER_ISSERVER
|
||||
: DeviceRole.SERVER_ISCLIENT;
|
||||
if ( newRole != m_gi.serverRole ) {
|
||||
Utils.logf( "new role: %s; old role: %s",
|
||||
newRole.toString(), m_gi.serverRole.toString() );
|
||||
DbgUtils.logf( "new role: %s; old role: %s",
|
||||
newRole.toString(), m_gi.serverRole.toString() );
|
||||
m_gi.serverRole = newRole;
|
||||
if ( !isServer ) {
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_SWITCHCLIENT );
|
||||
|
@ -1249,14 +1249,14 @@ public class BoardActivity extends XWActivity
|
|||
|
||||
// public void yOffsetChange( int maxOffset, int oldOffset, int newOffset )
|
||||
// {
|
||||
// Utils.logf( "yOffsetChange(maxOffset=%d)", maxOffset );
|
||||
// DbgUtils.logf( "yOffsetChange(maxOffset=%d)", maxOffset );
|
||||
// m_view.setVerticalScrollBarEnabled( maxOffset > 0 );
|
||||
// }
|
||||
@Override
|
||||
public boolean warnIllegalWord( String[] words, int turn,
|
||||
boolean turnLost )
|
||||
{
|
||||
Utils.logf( "warnIllegalWord" );
|
||||
DbgUtils.logf( "warnIllegalWord" );
|
||||
boolean accept = turnLost;
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
@ -1280,7 +1280,7 @@ public class BoardActivity extends XWActivity
|
|||
accept = 0 != waitBlockingDialog( QUERY_REQUEST_BLK, 0 );
|
||||
}
|
||||
|
||||
Utils.logf( "warnIllegalWord=>%b", accept );
|
||||
DbgUtils.logf( "warnIllegalWord=>%b", accept );
|
||||
return accept;
|
||||
}
|
||||
|
||||
|
@ -1464,7 +1464,7 @@ public class BoardActivity extends XWActivity
|
|||
{
|
||||
int result = cancelResult;
|
||||
if ( m_blockingDlgPosted ) { // this has been true; dunno why
|
||||
Utils.logf( "waitBlockingDialog: dropping dlgID %d", dlgID );
|
||||
DbgUtils.logf( "waitBlockingDialog: dropping dlgID %d", dlgID );
|
||||
} else {
|
||||
setBlockingThread();
|
||||
m_resultCode = cancelResult;
|
||||
|
@ -1480,7 +1480,7 @@ public class BoardActivity extends XWActivity
|
|||
m_forResultWait.acquire();
|
||||
m_blockingDlgPosted = false;
|
||||
} catch ( java.lang.InterruptedException ie ) {
|
||||
Utils.logf( "waitBlockingDialog: got %s", ie.toString() );
|
||||
DbgUtils.logf( "waitBlockingDialog: got %s", ie.toString() );
|
||||
if ( m_blockingDlgPosted ) {
|
||||
dismissDialog( dlgID );
|
||||
m_blockingDlgPosted = false;
|
||||
|
@ -1601,7 +1601,7 @@ public class BoardActivity extends XWActivity
|
|||
if ( null == m_screenTimer ) {
|
||||
m_screenTimer = new Runnable() {
|
||||
public void run() {
|
||||
Utils.logf( "run() called for setKeepScreenOn()" );
|
||||
DbgUtils.logf( "run() called for setKeepScreenOn()" );
|
||||
if ( null != m_view ) {
|
||||
m_view.setKeepScreenOn( false );
|
||||
}
|
||||
|
@ -1619,7 +1619,7 @@ public class BoardActivity extends XWActivity
|
|||
if ( canPost ) {
|
||||
m_handler.post( runnable );
|
||||
} else {
|
||||
Utils.logf( "post: dropping because handler null" );
|
||||
DbgUtils.logf( "post: dropping because handler null" );
|
||||
}
|
||||
return canPost;
|
||||
}
|
||||
|
@ -1629,7 +1629,7 @@ public class BoardActivity extends XWActivity
|
|||
if ( null != m_handler ) {
|
||||
m_handler.postDelayed( runnable, when );
|
||||
} else {
|
||||
Utils.logf( "postDelayed: dropping %d because handler null", when );
|
||||
DbgUtils.logf( "postDelayed: dropping %d because handler null", when );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1638,8 +1638,8 @@ public class BoardActivity extends XWActivity
|
|||
if ( null != m_handler ) {
|
||||
m_handler.removeCallbacks( which );
|
||||
} else {
|
||||
Utils.logf( "removeCallbacks: dropping %h because handler null",
|
||||
which );
|
||||
DbgUtils.logf( "removeCallbacks: dropping %h because handler null",
|
||||
which );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -34,17 +34,29 @@ import android.view.MotionEvent;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Paint.FontMetricsInt;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import java.nio.IntBuffer;
|
||||
import android.util.FloatMath;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||
SyncedDraw {
|
||||
|
||||
public interface MultiHandlerIface {
|
||||
boolean inactive();
|
||||
void activate( MotionEvent event );
|
||||
void deactivate();
|
||||
int figureZoom( MotionEvent event );
|
||||
int getSpacing( MotionEvent event );
|
||||
}
|
||||
|
||||
private static final float MIN_FONT_DIPS = 14.0f;
|
||||
|
||||
private static Bitmap s_bitmap; // the board
|
||||
private static final int IN_TRADE_ALPHA = 0x3FFFFFFF;
|
||||
private static final int PINCH_THRESHOLD = 40;
|
||||
|
||||
private Context m_context;
|
||||
private Paint m_drawPaint;
|
||||
|
@ -83,6 +95,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
private int m_pendingScore;
|
||||
private Handler m_viewHandler;
|
||||
|
||||
private MultiHandlerIface m_multiHandler = null;
|
||||
|
||||
// FontDims: exists to translate space available to the largest
|
||||
// font we can draw within that space taking advantage of our use
|
||||
// being limited to a known small subset of glyphs. We need two
|
||||
|
@ -93,20 +107,20 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
// future wantHt by. Ditto for the descent
|
||||
private class FontDims {
|
||||
FontDims( float askedHt, int topRow, int bottomRow, float width ) {
|
||||
// Utils.logf( "FontDims(): askedHt=" + askedHt );
|
||||
// Utils.logf( "FontDims(): topRow=" + topRow );
|
||||
// Utils.logf( "FontDims(): bottomRow=" + bottomRow );
|
||||
// Utils.logf( "FontDims(): width=" + width );
|
||||
// DbgUtils.logf( "FontDims(): askedHt=" + askedHt );
|
||||
// DbgUtils.logf( "FontDims(): topRow=" + topRow );
|
||||
// DbgUtils.logf( "FontDims(): bottomRow=" + bottomRow );
|
||||
// DbgUtils.logf( "FontDims(): width=" + width );
|
||||
float gotHt = bottomRow - topRow + 1;
|
||||
m_htProportion = gotHt / askedHt;
|
||||
Assert.assertTrue( (bottomRow+1) >= askedHt );
|
||||
float descent = (bottomRow+1) - askedHt;
|
||||
// Utils.logf( "descent: " + descent );
|
||||
// DbgUtils.logf( "descent: " + descent );
|
||||
m_descentProportion = descent / askedHt;
|
||||
Assert.assertTrue( m_descentProportion >= 0 );
|
||||
m_widthProportion = width / askedHt;
|
||||
// Utils.logf( "m_htProportion: " + m_htProportion );
|
||||
// Utils.logf( "m_descentProportion: " + m_descentProportion );
|
||||
// DbgUtils.logf( "m_htProportion: " + m_htProportion );
|
||||
// DbgUtils.logf( "m_descentProportion: " + m_descentProportion );
|
||||
}
|
||||
private float m_htProportion;
|
||||
private float m_descentProportion;
|
||||
|
@ -168,6 +182,15 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
}
|
||||
|
||||
m_viewHandler = new Handler();
|
||||
|
||||
try {
|
||||
int sdk_int = Integer.decode( Build.VERSION.SDK );
|
||||
if ( sdk_int >= Build.VERSION_CODES.ECLAIR ) {
|
||||
m_multiHandler = new MultiHandler();
|
||||
} else {
|
||||
DbgUtils.logf( "OS version %d too old for multi-touch", sdk_int );
|
||||
}
|
||||
} catch ( Exception ex ) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -179,17 +202,41 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
|
||||
switch ( action ) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
if ( null != m_multiHandler ) {
|
||||
m_multiHandler.deactivate();
|
||||
}
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_DOWN, xx, yy );
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_MOVE, xx, yy );
|
||||
if ( null == m_multiHandler || m_multiHandler.inactive() ) {
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_MOVE, xx, yy );
|
||||
} else {
|
||||
int zoomBy = m_multiHandler.figureZoom( event );
|
||||
if ( 0 != zoomBy ) {
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_ZOOM,
|
||||
zoomBy < 0 ? -2 : 2 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_UP, xx, yy );
|
||||
break;
|
||||
case MotionEvent.ACTION_POINTER_DOWN:
|
||||
case MotionEvent.ACTION_POINTER_2_DOWN:
|
||||
if ( null != m_multiHandler ) {
|
||||
m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_UP, xx, yy );
|
||||
m_multiHandler.activate( event );
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
case MotionEvent.ACTION_POINTER_2_UP:
|
||||
if ( null != m_multiHandler ) {
|
||||
m_multiHandler.deactivate();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Utils.logf( "unknown action: %d", action );
|
||||
Utils.logf( event.toString() );
|
||||
DbgUtils.logf( "unknown action: %d", action );
|
||||
break;
|
||||
}
|
||||
|
||||
return true; // required to get subsequent events
|
||||
|
@ -313,7 +360,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
drew = XwJNI.board_draw( m_jniGamePtr );
|
||||
}
|
||||
if ( !drew ) {
|
||||
Utils.logf( "draw not complete" );
|
||||
DbgUtils.logf( "draw not complete" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -720,7 +767,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
int height = rect.height() - 4; // borders and padding, 2 each
|
||||
descent = fontDims.descentFor( height );
|
||||
textSize = fontDims.heightFor( height );
|
||||
// Utils.logf( "using descent: " + descent + " and textSize: "
|
||||
// DbgUtils.logf( "using descent: " + descent + " and textSize: "
|
||||
// + textSize + " in height " + height );
|
||||
}
|
||||
m_fillPaint.setTextSize( textSize );
|
||||
|
@ -829,13 +876,13 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
Canvas canvas = new Canvas( bitmap );
|
||||
|
||||
// FontMetrics fmi = paint.getFontMetrics();
|
||||
// Utils.logf( "ascent: " + fmi.ascent );
|
||||
// Utils.logf( "bottom: " + fmi.bottom );
|
||||
// Utils.logf( "descent: " + fmi.descent );
|
||||
// Utils.logf( "leading: " + fmi.leading );
|
||||
// Utils.logf( "top : " + fmi.top );
|
||||
// DbgUtils.logf( "ascent: " + fmi.ascent );
|
||||
// DbgUtils.logf( "bottom: " + fmi.bottom );
|
||||
// DbgUtils.logf( "descent: " + fmi.descent );
|
||||
// DbgUtils.logf( "leading: " + fmi.leading );
|
||||
// DbgUtils.logf( "top : " + fmi.top );
|
||||
|
||||
// Utils.logf( "using as baseline: " + ht );
|
||||
// DbgUtils.logf( "using as baseline: " + ht );
|
||||
|
||||
Rect bounds = new Rect();
|
||||
int maxWidth = 0;
|
||||
|
@ -855,7 +902,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
// int pixel = bitmap.getPixel( col, row );
|
||||
// sb.append( pixel==0? "." : "X" );
|
||||
// }
|
||||
// Utils.logf( sb.append(row).toString() );
|
||||
// DbgUtils.logf( sb.append(row).toString() );
|
||||
// }
|
||||
|
||||
int topRow = 0;
|
||||
|
@ -949,4 +996,52 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
private class MultiHandler implements MultiHandlerIface {
|
||||
private static final int INACTIVE = -1;
|
||||
private int m_lastSpacing = INACTIVE;
|
||||
|
||||
public boolean inactive()
|
||||
{
|
||||
return INACTIVE == m_lastSpacing;
|
||||
}
|
||||
|
||||
public void activate( MotionEvent event )
|
||||
{
|
||||
m_lastSpacing = getSpacing( event );
|
||||
}
|
||||
|
||||
public void deactivate()
|
||||
{
|
||||
m_lastSpacing = INACTIVE;
|
||||
}
|
||||
|
||||
public int getSpacing( MotionEvent event )
|
||||
{
|
||||
int result;
|
||||
if ( 1 == event.getPointerCount() ) {
|
||||
result = INACTIVE;
|
||||
} else {
|
||||
float xx = event.getX( 0 ) - event.getX( 1 );
|
||||
float yy = event.getY( 0 ) - event.getY( 1 );
|
||||
result = (int)FloatMath.sqrt( (xx * xx) + (yy * yy) );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int figureZoom( MotionEvent event )
|
||||
{
|
||||
int zoomDir = 0;
|
||||
if ( ! inactive() ) {
|
||||
int newSpacing = getSpacing( event );
|
||||
int diff = Math.abs( newSpacing - m_lastSpacing );
|
||||
if ( diff > PINCH_THRESHOLD ) {
|
||||
zoomDir = newSpacing < m_lastSpacing? -1 : 1;
|
||||
m_lastSpacing = newSpacing;
|
||||
}
|
||||
}
|
||||
return zoomDir;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2011 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -91,11 +91,11 @@ public class CommsTransport implements TransportProcs,
|
|||
|
||||
closeSocket();
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
Utils.logf( ioe.toString() );
|
||||
DbgUtils.logf( ioe.toString() );
|
||||
} catch ( UnresolvedAddressException uae ) {
|
||||
Utils.logf( "bad address: name: %s; port: %s; exception: %s",
|
||||
m_addr.ip_relay_hostName, m_addr.ip_relay_port,
|
||||
uae.toString() );
|
||||
DbgUtils.logf( "bad address: name: %s; port: %s; exception: %s",
|
||||
m_addr.ip_relay_hostName, m_addr.ip_relay_port,
|
||||
uae.toString() );
|
||||
}
|
||||
|
||||
m_thread = null;
|
||||
|
@ -118,15 +118,15 @@ public class CommsTransport implements TransportProcs,
|
|||
try {
|
||||
m_socketChannel = SocketChannel.open();
|
||||
m_socketChannel.configureBlocking( false );
|
||||
Utils.logf( "connecting to %s:%d",
|
||||
m_addr.ip_relay_hostName,
|
||||
m_addr.ip_relay_port );
|
||||
DbgUtils.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 );
|
||||
m_socketChannel.connect( isa );
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
Utils.logf( ioe.toString() );
|
||||
DbgUtils.logf( ioe.toString() );
|
||||
failed = true;
|
||||
break outer_loop;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class CommsTransport implements TransportProcs,
|
|||
|
||||
if ( null != m_socketChannel ) {
|
||||
int ops = figureOps();
|
||||
// Utils.logf( "calling with ops=%x", ops );
|
||||
// DbgUtils.logf( "calling with ops=%x", ops );
|
||||
m_socketChannel.register( m_selector, ops );
|
||||
}
|
||||
}
|
||||
|
@ -143,14 +143,14 @@ public class CommsTransport implements TransportProcs,
|
|||
// we get this when relay goes down. Need to notify!
|
||||
failed = true;
|
||||
closeSocket();
|
||||
Utils.logf( "exiting: %s", cce.toString() );
|
||||
DbgUtils.logf( "exiting: %s", cce.toString() );
|
||||
break; // don't try again
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
closeSocket();
|
||||
Utils.logf( "exiting: %s", ioe.toString() );
|
||||
Utils.logf( ioe.toString() );
|
||||
DbgUtils.logf( "exiting: %s", ioe.toString() );
|
||||
DbgUtils.logf( ioe.toString() );
|
||||
} catch ( java.nio.channels.NoConnectionPendingException ncp ) {
|
||||
Utils.logf( "%s", ncp.toString() );
|
||||
DbgUtils.logf( "%s", ncp.toString() );
|
||||
closeSocket();
|
||||
break;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ public class CommsTransport implements TransportProcs,
|
|||
}
|
||||
if (key.isValid() && key.isReadable()) {
|
||||
m_bytesIn.clear(); // will wipe any pending data!
|
||||
// Utils.logf( "socket is readable; buffer has space for "
|
||||
// DbgUtils.logf( "socket is readable; buffer has space for "
|
||||
// + m_bytesIn.remaining() );
|
||||
int nRead = channel.read( m_bytesIn );
|
||||
if ( nRead == -1 ) {
|
||||
|
@ -181,17 +181,17 @@ public class CommsTransport implements TransportProcs,
|
|||
getOut();
|
||||
if ( null != m_bytesOut ) {
|
||||
int nWritten = channel.write( m_bytesOut );
|
||||
//Utils.logf( "wrote " + nWritten + " bytes" );
|
||||
//DbgUtils.logf( "wrote " + nWritten + " bytes" );
|
||||
}
|
||||
}
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
Utils.logf( "%s: cancelling key", ioe.toString() );
|
||||
DbgUtils.logf( "%s: cancelling key", ioe.toString() );
|
||||
key.cancel();
|
||||
failed = true;
|
||||
break outer_loop;
|
||||
} catch ( java.nio.channels.
|
||||
NoConnectionPendingException ncp ) {
|
||||
Utils.logf( "%s", ncp.toString() );
|
||||
DbgUtils.logf( "%s", ncp.toString() );
|
||||
break outer_loop;
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ public class CommsTransport implements TransportProcs,
|
|||
try {
|
||||
m_socketChannel.close();
|
||||
} catch ( Exception e ) {
|
||||
Utils.logf( "closing socket: %s", e.toString() );
|
||||
DbgUtils.logf( "closing socket: %s", e.toString() );
|
||||
}
|
||||
m_socketChannel = null;
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ public class CommsTransport implements TransportProcs,
|
|||
try {
|
||||
m_thread.join(100); // wait up to 1/10 second
|
||||
} catch ( java.lang.InterruptedException ie ) {
|
||||
Utils.logf( "got InterruptedException: %s", ie.toString() );
|
||||
DbgUtils.logf( "got InterruptedException: %s", ie.toString() );
|
||||
}
|
||||
m_thread = null;
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ public class CommsTransport implements TransportProcs,
|
|||
// TransportProcs interface
|
||||
public int transportSend( byte[] buf, final CommsAddrRec faddr )
|
||||
{
|
||||
//Utils.logf( "CommsTransport::transportSend(nbytes=%d)", buf.length );
|
||||
//DbgUtils.logf( "CommsTransport::transportSend(nbytes=%d)", buf.length );
|
||||
int nSent = -1;
|
||||
|
||||
if ( null == m_addr ) {
|
||||
|
@ -358,7 +358,7 @@ public class CommsTransport implements TransportProcs,
|
|||
// to verify. IFF the plan's to ship a version that
|
||||
// doesn't do SMS.
|
||||
|
||||
// Utils.logf( "sending via sms to %s:%d",
|
||||
// DbgUtils.logf( "sending via sms to %s:%d",
|
||||
// m_addr.sms_phone, m_addr.sms_port );
|
||||
// try {
|
||||
// Intent intent = new Intent( m_context, StatusReceiver.class);
|
||||
|
@ -369,17 +369,17 @@ public class CommsTransport implements TransportProcs,
|
|||
// SmsManager.getDefault().sendTextMessage( m_addr.sms_phone,
|
||||
// null, "Hello world",
|
||||
// pi, pi );
|
||||
// Utils.logf( "called sendTextMessage" );
|
||||
// DbgUtils.logf( "called sendTextMessage" );
|
||||
// } else {
|
||||
// SmsManager.getDefault().
|
||||
// sendDataMessage( m_addr.sms_phone, (String)null,
|
||||
// (short)m_addr.sms_port,
|
||||
// buf, pi, pi );
|
||||
// Utils.logf( "called sendDataMessage" );
|
||||
// DbgUtils.logf( "called sendDataMessage" );
|
||||
// }
|
||||
// nSent = buf.length;
|
||||
// } catch ( java.lang.IllegalArgumentException iae ) {
|
||||
// Utils.logf( iae.toString() );
|
||||
// DbgUtils.logf( iae.toString() );
|
||||
// }
|
||||
break;
|
||||
case COMMS_CONN_BT:
|
||||
|
@ -391,17 +391,17 @@ public class CommsTransport implements TransportProcs,
|
|||
// Keep this while debugging why the resend_all that gets
|
||||
// fired on reconnect doesn't unstall a game but a manual
|
||||
// resend does.
|
||||
Utils.logf( "transportSend(%d)=>%d", buf.length, nSent );
|
||||
DbgUtils.logf( "transportSend(%d)=>%d", buf.length, nSent );
|
||||
return nSent;
|
||||
}
|
||||
|
||||
public void relayStatus( CommsRelayState newState )
|
||||
{
|
||||
//Utils.logf( "relayStatus called; state=%s", newState.toString() );
|
||||
//DbgUtils.logf( "relayStatus called; state=%s", newState.toString() );
|
||||
if ( null != m_jniThread ) {
|
||||
m_jniThread.handle( JNICmd.CMD_DRAW_CONNS_STATUS, newState );
|
||||
} else {
|
||||
Utils.logf( "can't draw status yet" );
|
||||
DbgUtils.logf( "can't draw status yet" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -123,7 +123,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
@Override
|
||||
public void onUpgrade( SQLiteDatabase db, int oldVersion, int newVersion )
|
||||
{
|
||||
Utils.logf( "onUpgrade: old: %d; new: %d", oldVersion, newVersion );
|
||||
DbgUtils.logf( "onUpgrade: old: %d; new: %d", oldVersion, newVersion );
|
||||
|
||||
switch( oldVersion ) {
|
||||
case 5:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -456,7 +456,7 @@ public class DBUtils {
|
|||
long result = db.replaceOrThrow( DBHelper.TABLE_NAME_OBITS,
|
||||
"", values );
|
||||
} catch ( Exception ex ) {
|
||||
Utils.logf( "ex: %s", ex.toString() );
|
||||
DbgUtils.logf( "ex: %s", ex.toString() );
|
||||
}
|
||||
db.close();
|
||||
}
|
||||
|
@ -566,7 +566,7 @@ public class DBUtils {
|
|||
Assert.fail();
|
||||
// values.put( DBHelper.FILE_NAME, path );
|
||||
// rowid = db.insert( DBHelper.TABLE_NAME_SUM, null, values );
|
||||
// Utils.logf( "insert=>%d", rowid );
|
||||
// DbgUtils.logf( "insert=>%d", rowid );
|
||||
// Assert.assertTrue( row >= 0 );
|
||||
}
|
||||
db.close();
|
||||
|
@ -688,7 +688,7 @@ public class DBUtils {
|
|||
values, selection, null );
|
||||
db.close();
|
||||
if ( 0 == result ) {
|
||||
Utils.logf( "setName(%d,%s) failed", rowid, name );
|
||||
DbgUtils.logf( "setName(%d,%s) failed", rowid, name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2011 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.
|
||||
*/
|
||||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import java.lang.Thread;
|
||||
import java.util.Formatter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.format.Time;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class DbgUtils {
|
||||
static final String TAG = "XW4";
|
||||
static boolean s_doLog = true;
|
||||
|
||||
private static Time s_time = new Time();
|
||||
|
||||
public static void logEnable( boolean enable )
|
||||
{
|
||||
s_doLog = enable;
|
||||
}
|
||||
|
||||
public static void logEnable( Context context )
|
||||
{
|
||||
SharedPreferences sp
|
||||
= PreferenceManager.getDefaultSharedPreferences( context );
|
||||
String key = context.getString( R.string.key_logging_on );
|
||||
boolean on = sp.getBoolean( key, false );
|
||||
logEnable( on );
|
||||
}
|
||||
|
||||
public static void logf( String msg )
|
||||
{
|
||||
if ( s_doLog ) {
|
||||
s_time.setToNow();
|
||||
String time = s_time.format("[%H:%M:%S]");
|
||||
long id = Thread.currentThread().getId();
|
||||
Log.d( TAG, time + "-" + id + "-" + msg );
|
||||
}
|
||||
} // logf
|
||||
|
||||
public static void logf( String format, Object... args )
|
||||
{
|
||||
if ( s_doLog ) {
|
||||
Formatter formatter = new Formatter();
|
||||
logf( formatter.format( format, args ).toString() );
|
||||
}
|
||||
} // logf
|
||||
|
||||
public static void showf( Context context, String format, Object... args )
|
||||
{
|
||||
Formatter formatter = new Formatter();
|
||||
String msg = formatter.format( format, args ).toString();
|
||||
Toast.makeText( context, msg, Toast.LENGTH_SHORT ).show();
|
||||
} // showf
|
||||
|
||||
public static void showf( Context context, int formatid, Object... args )
|
||||
{
|
||||
showf( context, context.getString( formatid ), args );
|
||||
} // showf
|
||||
|
||||
public static void printStack( StackTraceElement[] trace )
|
||||
{
|
||||
if ( s_doLog ) {
|
||||
for ( int ii = 0; ii < trace.length; ++ii ) {
|
||||
DbgUtils.logf( "ste %d: %s", ii, trace[ii].toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void printStack()
|
||||
{
|
||||
if ( s_doLog ) {
|
||||
printStack( Thread.currentThread().getStackTrace() );
|
||||
}
|
||||
}
|
||||
|
||||
private DbgUtils() {}
|
||||
}
|
|
@ -214,7 +214,7 @@ public class DictBrowseActivity extends XWListActivity
|
|||
try {
|
||||
super.finalize();
|
||||
} catch ( java.lang.Throwable err ){
|
||||
Utils.logf( "%s", err.toString() );
|
||||
DbgUtils.logf( "%s", err.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,8 +268,8 @@ public class DictBrowseActivity extends XWListActivity
|
|||
if ( 0 <= pos ) {
|
||||
getListView().setSelection( pos );
|
||||
} else {
|
||||
Utils.showf( this, R.string.dict_browse_nowordsf,
|
||||
m_name, text );
|
||||
DbgUtils.showf( this, R.string.dict_browse_nowordsf,
|
||||
m_name, text );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -56,7 +56,7 @@ public class DictImportActivity extends XWActivity {
|
|||
long totalSize = 0;
|
||||
for ( int ii = 0; ii < count; ii++ ) {
|
||||
Uri uri = uris[ii];
|
||||
Utils.logf( "trying %s", uri );
|
||||
DbgUtils.logf( "trying %s", uri );
|
||||
|
||||
try {
|
||||
URI jUri = new URI( uri.getScheme(),
|
||||
|
@ -66,11 +66,11 @@ public class DictImportActivity extends XWActivity {
|
|||
m_saved = saveDict( is, uri.getPath() );
|
||||
is.close();
|
||||
} catch ( java.net.URISyntaxException use ) {
|
||||
Utils.logf( "URISyntaxException: %s", use.toString() );
|
||||
DbgUtils.logf( "URISyntaxException: %s", use.toString() );
|
||||
} catch ( java.net.MalformedURLException mue ) {
|
||||
Utils.logf( "MalformedURLException: %s", mue.toString() );
|
||||
DbgUtils.logf( "MalformedURLException: %s", mue.toString() );
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
Utils.logf( "IOException: %s", ioe.toString() );
|
||||
DbgUtils.logf( "IOException: %s", ioe.toString() );
|
||||
}
|
||||
}
|
||||
return totalSize;
|
||||
|
@ -79,7 +79,7 @@ public class DictImportActivity extends XWActivity {
|
|||
@Override
|
||||
protected void onPostExecute( Long result )
|
||||
{
|
||||
Utils.logf( "onPostExecute passed %d", result );
|
||||
DbgUtils.logf( "onPostExecute passed %d", result );
|
||||
if ( null != m_saved ) {
|
||||
DictLangCache.inval( DictImportActivity.this, m_saved,
|
||||
s_saveWhere, true );
|
||||
|
@ -105,7 +105,7 @@ public class DictImportActivity extends XWActivity {
|
|||
if ( null != uri) {
|
||||
if ( null != intent.getType()
|
||||
&& intent.getType().equals( "application/x-xwordsdict" ) ) {
|
||||
Utils.logf( "based on MIME type" );
|
||||
DbgUtils.logf( "based on MIME type" );
|
||||
new DownloadFilesTask().execute( uri );
|
||||
} else if ( uri.toString().endsWith( XWConstants.DICT_EXTN ) ) {
|
||||
String fmt = getString( R.string.downloading_dictf );
|
||||
|
@ -114,7 +114,7 @@ public class DictImportActivity extends XWActivity {
|
|||
view.setText( txt );
|
||||
new DownloadFilesTask().execute( uri );
|
||||
} else {
|
||||
Utils.logf( "bogus intent: %s/%s", intent.getType(), uri );
|
||||
DbgUtils.logf( "bogus intent: %s/%s", intent.getType(), uri );
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2010 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
|
@ -389,7 +389,7 @@ public class DictLangCache {
|
|||
s_nameToLang.put( dal, info );
|
||||
} else {
|
||||
info = null;
|
||||
Utils.logf( "getInfo(): unable to open dict %s", dal.name );
|
||||
DbgUtils.logf( "getInfo(): unable to open dict %s", dal.name );
|
||||
}
|
||||
}
|
||||
return info;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2011 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
|
@ -242,9 +242,9 @@ public class DictUtils {
|
|||
success = true;
|
||||
|
||||
} catch ( java.io.FileNotFoundException fnfe ) {
|
||||
Utils.logf( "%s", fnfe.toString() );
|
||||
DbgUtils.logf( "%s", fnfe.toString() );
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
Utils.logf( "%s", ioe.toString() );
|
||||
DbgUtils.logf( "%s", ioe.toString() );
|
||||
} finally {
|
||||
try {
|
||||
// Order should match assignment order to above in
|
||||
|
@ -252,7 +252,7 @@ public class DictUtils {
|
|||
channelIn.close();
|
||||
channelOut.close();
|
||||
} catch ( Exception e ) {
|
||||
Utils.logf( "%s", e.toString() );
|
||||
DbgUtils.logf( "%s", e.toString() );
|
||||
}
|
||||
}
|
||||
return success;
|
||||
|
@ -305,13 +305,13 @@ public class DictUtils {
|
|||
bytes = new byte[len];
|
||||
int nRead = dict.read( bytes, 0, len );
|
||||
if ( nRead != len ) {
|
||||
Utils.logf( "**** warning ****; read only %d of %d bytes.",
|
||||
nRead, len );
|
||||
DbgUtils.logf( "**** warning ****; read only %d of %d bytes.",
|
||||
nRead, len );
|
||||
}
|
||||
// check that with len bytes we've read the whole file
|
||||
Assert.assertTrue( -1 == dict.read() );
|
||||
} catch ( java.io.IOException ee ){
|
||||
Utils.logf( "%s failed to open; likely not built-in", name );
|
||||
DbgUtils.logf( "%s failed to open; likely not built-in", name );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,7 @@ public class DictUtils {
|
|||
if ( loc == DictLoc.UNKNOWN || loc == DictLoc.DOWNLOAD ) {
|
||||
File path = getDownloadsPathFor( name );
|
||||
if ( null != path && path.exists() ) {
|
||||
Utils.logf( "loading %s from Download", name );
|
||||
DbgUtils.logf( "loading %s from Download", name );
|
||||
fis = new FileInputStream( path );
|
||||
}
|
||||
}
|
||||
|
@ -331,13 +331,13 @@ public class DictUtils {
|
|||
if ( loc == DictLoc.UNKNOWN || loc == DictLoc.EXTERNAL ) {
|
||||
File sdFile = getSDPathFor( context, name );
|
||||
if ( null != sdFile && sdFile.exists() ) {
|
||||
Utils.logf( "loading %s from SD", name );
|
||||
DbgUtils.logf( "loading %s from SD", name );
|
||||
fis = new FileInputStream( sdFile );
|
||||
}
|
||||
}
|
||||
if ( null == fis ) {
|
||||
if ( loc == DictLoc.UNKNOWN || loc == DictLoc.INTERNAL ) {
|
||||
Utils.logf( "loading %s from private storage", name );
|
||||
DbgUtils.logf( "loading %s from private storage", name );
|
||||
fis = context.openFileInput( name );
|
||||
}
|
||||
}
|
||||
|
@ -345,11 +345,11 @@ public class DictUtils {
|
|||
bytes = new byte[len];
|
||||
fis.read( bytes, 0, len );
|
||||
fis.close();
|
||||
Utils.logf( "Successfully loaded %s", name );
|
||||
DbgUtils.logf( "Successfully loaded %s", name );
|
||||
} catch ( java.io.FileNotFoundException fnf ) {
|
||||
Utils.logf( fnf.toString() );
|
||||
DbgUtils.logf( fnf.toString() );
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
Utils.logf( ioe.toString() );
|
||||
DbgUtils.logf( ioe.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,10 +449,10 @@ public class DictUtils {
|
|||
invalDictList();
|
||||
success = true;
|
||||
} catch ( java.io.FileNotFoundException fnf ) {
|
||||
Utils.logf( "saveDict: FileNotFoundException: %s",
|
||||
fnf.toString() );
|
||||
DbgUtils.logf( "saveDict: FileNotFoundException: %s",
|
||||
fnf.toString() );
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
Utils.logf( "saveDict: IOException: %s", ioe.toString() );
|
||||
DbgUtils.logf( "saveDict: IOException: %s", ioe.toString() );
|
||||
deleteDict( context, name );
|
||||
}
|
||||
}
|
||||
|
@ -498,7 +498,7 @@ public class DictUtils {
|
|||
AssetManager am = context.getAssets();
|
||||
return am.list("");
|
||||
} catch( java.io.IOException ioe ) {
|
||||
Utils.logf( ioe.toString() );
|
||||
DbgUtils.logf( ioe.toString() );
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
@ -523,7 +523,7 @@ public class DictUtils {
|
|||
if ( !result.exists() ) {
|
||||
result.mkdirs();
|
||||
if ( !result.exists() ) {
|
||||
Utils.logf( "unable to create sd dir %s", packdir );
|
||||
DbgUtils.logf( "unable to create sd dir %s", packdir );
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009 - 2011 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -306,8 +306,8 @@ public class DictsActivity extends ExpandableListActivity
|
|||
rowView.cache( toLoc );
|
||||
rowView.invalidate();
|
||||
} else {
|
||||
Utils.logf( "moveDict(%s) failed",
|
||||
rowView.getText() );
|
||||
DbgUtils.logf( "moveDict(%s) failed",
|
||||
rowView.getText() );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -480,7 +480,7 @@ public class DictsActivity extends ExpandableListActivity
|
|||
getPackedPositionChild( packedPosition );
|
||||
// int groupPosition = ExpandableListView.
|
||||
// getPackedPositionGroup( packedPosition );
|
||||
// Utils.logf( "onCreateContextMenu: group: %d; child: %d",
|
||||
// DbgUtils.logf( "onCreateContextMenu: group: %d; child: %d",
|
||||
// groupPosition, childPosition );
|
||||
|
||||
// We don't have a menu yet for languages, just for their dict
|
||||
|
@ -509,7 +509,7 @@ public class DictsActivity extends ExpandableListActivity
|
|||
try {
|
||||
info = (ExpandableListContextMenuInfo)item.getMenuInfo();
|
||||
} catch (ClassCastException e) {
|
||||
Utils.logf( "bad menuInfo: %s", e.toString() );
|
||||
DbgUtils.logf( "bad menuInfo: %s", e.toString() );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -596,7 +596,7 @@ public class DictsActivity extends ExpandableListActivity
|
|||
// MountEventReceiver.SDCardNotifiee interface
|
||||
public void cardMounted( boolean nowMounted )
|
||||
{
|
||||
Utils.logf( "DictsActivity.cardMounted(%b)", nowMounted );
|
||||
DbgUtils.logf( "DictsActivity.cardMounted(%b)", nowMounted );
|
||||
// post so other SDCardNotifiee implementations get a chance
|
||||
// to process first: avoid race conditions
|
||||
new Handler().post( new Runnable() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2010 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
|
@ -64,7 +64,7 @@ public class DispatchNotify extends Activity {
|
|||
}
|
||||
|
||||
if ( mustLaunch ) {
|
||||
Utils.logf( "DispatchNotify: nothing running" );
|
||||
DbgUtils.logf( "DispatchNotify: nothing running" );
|
||||
Intent intent = new Intent( this, GamesList.class );
|
||||
|
||||
/* Flags. Tried Intent.FLAG_ACTIVITY_NEW_TASK. I don't
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -53,7 +53,6 @@ public class DlgDelegate {
|
|||
|
||||
private static final String MSG = "msg";
|
||||
private static final String CALLBACK = "callback";
|
||||
private static final String MSGID = "msgid";
|
||||
private static final String PREFSKEY = "prefskey";
|
||||
private static final String POSBUTTON = "posbutton";
|
||||
private static final String WORDS = "words";
|
||||
|
@ -68,7 +67,6 @@ public class DlgDelegate {
|
|||
void dlgButtonClicked( int id, int button );
|
||||
}
|
||||
|
||||
private int m_msgID;
|
||||
private int m_posButton;
|
||||
private int m_cbckID = 0; // if this can be set twice I have a
|
||||
// problem. See asserts below.
|
||||
|
@ -90,7 +88,6 @@ public class DlgDelegate {
|
|||
if ( null != bundle ) {
|
||||
m_msg = bundle.getString( MSG );
|
||||
m_cbckID = bundle.getInt( CALLBACK );
|
||||
m_msgID = bundle.getInt( MSGID );
|
||||
m_posButton = bundle.getInt( POSBUTTON );
|
||||
m_prefsKey = bundle.getInt( PREFSKEY );
|
||||
m_words = bundle.getStringArray( WORDS );
|
||||
|
@ -103,7 +100,6 @@ public class DlgDelegate {
|
|||
{
|
||||
outState.putString( MSG, m_msg );
|
||||
outState.putInt( CALLBACK, m_cbckID );
|
||||
outState.putInt( MSGID, m_msgID );
|
||||
outState.putInt( POSBUTTON, m_posButton );
|
||||
outState.putInt( PREFSKEY, m_prefsKey );
|
||||
outState.putStringArray( WORDS, m_words );
|
||||
|
@ -207,7 +203,7 @@ public class DlgDelegate {
|
|||
AlertDialog.BUTTON_POSITIVE );
|
||||
}
|
||||
} else {
|
||||
m_msgID = msgID;
|
||||
m_msg = m_activity.getString( msgID );
|
||||
Assert.assertTrue( 0 != callbackID );
|
||||
Assert.assertTrue( 0 == m_cbckID ); // fired
|
||||
m_cbckID = callbackID;
|
||||
|
@ -328,7 +324,7 @@ public class DlgDelegate {
|
|||
|
||||
Dialog dialog = new AlertDialog.Builder( m_activity )
|
||||
.setTitle( R.string.newbie_title )
|
||||
.setMessage( m_msgID )
|
||||
.setMessage( m_msg )
|
||||
.setPositiveButton( R.string.button_ok, lstnr_p )
|
||||
.setNegativeButton( R.string.button_notagain, lstnr_n )
|
||||
.create();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2010 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
|
@ -49,7 +49,7 @@ public class FirstRunDialog {
|
|||
thisVersion = context.getPackageManager()
|
||||
.getPackageInfo(context.getPackageName(), 0)
|
||||
.versionCode;
|
||||
Utils.logf( "versionCode: %d", thisVersion );
|
||||
DbgUtils.logf( "versionCode: %d", thisVersion );
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class FirstRunDialog {
|
|||
page = stringBuilder.toString();
|
||||
}
|
||||
catch ( IOException ioe ) {
|
||||
Utils.logf( ioe.toString() );
|
||||
DbgUtils.logf( ioe.toString() );
|
||||
}
|
||||
finally {
|
||||
// could just catch NPE....
|
||||
|
@ -104,7 +104,7 @@ public class FirstRunDialog {
|
|||
try {
|
||||
inputStream.close();
|
||||
} catch ( IOException ioe ) {
|
||||
Utils.logf( ioe.toString() );
|
||||
DbgUtils.logf( ioe.toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -613,7 +613,7 @@ public class GameConfig extends XWActivity
|
|||
}
|
||||
|
||||
} else {
|
||||
Utils.logf( "unknown v: " + view.toString() );
|
||||
DbgUtils.logf( "unknown v: " + view.toString() );
|
||||
}
|
||||
} // onClick
|
||||
|
||||
|
@ -793,8 +793,8 @@ public class GameConfig extends XWActivity
|
|||
setting = 2;
|
||||
break;
|
||||
default:
|
||||
Utils.logf( "setSmartnessSpinner got %d from getRobotSmartness()",
|
||||
m_gi.getRobotSmartness() );
|
||||
DbgUtils.logf( "setSmartnessSpinner got %d from getRobotSmartness()",
|
||||
m_gi.getRobotSmartness() );
|
||||
Assert.fail();
|
||||
}
|
||||
m_smartnessSpinner.setSelection( setting );
|
||||
|
@ -837,7 +837,7 @@ public class GameConfig extends XWActivity
|
|||
|
||||
private void adjustPlayersLabel()
|
||||
{
|
||||
Utils.logf( "adjustPlayersLabel()" );
|
||||
DbgUtils.logf( "adjustPlayersLabel()" );
|
||||
String label;
|
||||
if ( m_notNetworkedGame ) {
|
||||
label = getString( R.string.players_label_standalone );
|
||||
|
@ -970,8 +970,8 @@ public class GameConfig extends XWActivity
|
|||
|
||||
if ( !m_notNetworkedGame ) {
|
||||
m_car.ip_relay_seeksPublicRoom = m_joinPublicCheck.isChecked();
|
||||
Utils.logf( "ip_relay_seeksPublicRoom: %b",
|
||||
m_car.ip_relay_seeksPublicRoom );
|
||||
DbgUtils.logf( "ip_relay_seeksPublicRoom: %b",
|
||||
m_car.ip_relay_seeksPublicRoom );
|
||||
m_car.ip_relay_advertiseRoom =
|
||||
Utils.getChecked( this, R.id.advertise_new_room_check );
|
||||
if ( m_car.ip_relay_seeksPublicRoom ) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -109,7 +109,7 @@ public class GameListAdapter extends XWListAdapter {
|
|||
@Override
|
||||
protected Void doInBackground( Void... unused )
|
||||
{
|
||||
// Utils.logf( "doInBackground(id=%d)", m_id );
|
||||
// DbgUtils.logf( "doInBackground(id=%d)", m_id );
|
||||
View layout = m_factory.inflate( R.layout.game_list_item, null );
|
||||
boolean hideTitle = false;//CommonPrefs.getHideTitleBar(m_context);
|
||||
GameSummary summary = DBUtils.getSummary( m_context, m_rowid, false );
|
||||
|
@ -221,7 +221,7 @@ public class GameListAdapter extends XWListAdapter {
|
|||
@Override
|
||||
protected void onPostExecute( Void unused )
|
||||
{
|
||||
// Utils.logf( "onPostExecute(id=%d)", m_id );
|
||||
// DbgUtils.logf( "onPostExecute(id=%d)", m_id );
|
||||
if ( -1 != m_rowid ) {
|
||||
m_cb.itemLoaded( m_rowid );
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -68,7 +68,7 @@ public class GameUtils {
|
|||
m_rowid = rowid;
|
||||
m_isForWrite = isForWrite;
|
||||
m_lockCount = 0;
|
||||
// Utils.logf( "GameLock.GameLock(%s,%s) done", m_path,
|
||||
// DbgUtils.logf( "GameLock.GameLock(%s,%s) done", m_path,
|
||||
// m_isForWrite?"T":"F" );
|
||||
}
|
||||
|
||||
|
@ -101,18 +101,18 @@ public class GameUtils {
|
|||
public GameLock lock()
|
||||
{
|
||||
long stopTime = System.currentTimeMillis() + 1000;
|
||||
// Utils.logf( "GameLock.lock(%s)", m_path );
|
||||
// DbgUtils.logf( "GameLock.lock(%s)", m_path );
|
||||
// Utils.printStack();
|
||||
for ( ; ; ) {
|
||||
if ( tryLock() ) {
|
||||
break;
|
||||
}
|
||||
// Utils.logf( "GameLock.lock() failed; sleeping" );
|
||||
// DbgUtils.logf( "GameLock.lock() failed; sleeping" );
|
||||
// Utils.printStack();
|
||||
try {
|
||||
Thread.sleep( 25 ); // milliseconds
|
||||
} catch( InterruptedException ie ) {
|
||||
Utils.logf( "GameLock.lock(): %s", ie.toString() );
|
||||
DbgUtils.logf( "GameLock.lock(): %s", ie.toString() );
|
||||
break;
|
||||
}
|
||||
if ( System.currentTimeMillis() >= stopTime ) {
|
||||
|
@ -120,13 +120,13 @@ public class GameUtils {
|
|||
Assert.fail();
|
||||
}
|
||||
}
|
||||
// Utils.logf( "GameLock.lock(%s) done", m_path );
|
||||
// DbgUtils.logf( "GameLock.lock(%s) done", m_path );
|
||||
return this;
|
||||
}
|
||||
|
||||
public void unlock()
|
||||
{
|
||||
// Utils.logf( "GameLock.unlock(%s)", m_path );
|
||||
// DbgUtils.logf( "GameLock.unlock(%s)", m_path );
|
||||
synchronized( s_locks ) {
|
||||
Assert.assertTrue( this == s_locks.get(m_rowid) );
|
||||
if ( 1 == m_lockCount ) {
|
||||
|
@ -136,7 +136,7 @@ public class GameUtils {
|
|||
}
|
||||
--m_lockCount;
|
||||
}
|
||||
// Utils.logf( "GameLock.unlock(%s) done", m_path );
|
||||
// DbgUtils.logf( "GameLock.unlock(%s) done", m_path );
|
||||
}
|
||||
|
||||
public long getRowid()
|
||||
|
@ -310,7 +310,7 @@ public class GameUtils {
|
|||
String[] dictNames = gi.dictNames();
|
||||
DictUtils.DictPairs pairs = DictUtils.openDicts( context, dictNames );
|
||||
if ( pairs.anyMissing( dictNames ) ) {
|
||||
Utils.logf( "loadMakeGame() failing: dict unavailable" );
|
||||
DbgUtils.logf( "loadMakeGame() failing: dict unavailable" );
|
||||
} else {
|
||||
gamePtr = XwJNI.initJNI();
|
||||
|
||||
|
@ -606,7 +606,7 @@ public class GameUtils {
|
|||
lock.unlock();
|
||||
}
|
||||
}
|
||||
Utils.logf( "feedMessages=>%b", draw );
|
||||
DbgUtils.logf( "feedMessages=>%b", draw );
|
||||
return draw;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -491,7 +491,7 @@ public class GamesList extends XWListActivity
|
|||
try {
|
||||
info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
|
||||
} catch (ClassCastException e) {
|
||||
Utils.logf( "bad menuInfo: %s", e.toString() );
|
||||
DbgUtils.logf( "bad menuInfo: %s", e.toString() );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2011 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -189,7 +189,7 @@ public class LookupView extends LinearLayout
|
|||
private void lookupWord( String word, String fmt )
|
||||
{
|
||||
if ( false ) {
|
||||
Utils.logf( "skipping lookupWord(%s)", word );
|
||||
DbgUtils.logf( "skipping lookupWord(%s)", word );
|
||||
} else {
|
||||
String langCode = s_langCodes[s_lang];
|
||||
String dict_url = String.format( fmt, langCode, word );
|
||||
|
@ -200,7 +200,7 @@ public class LookupView extends LinearLayout
|
|||
try {
|
||||
m_context.startActivity( intent );
|
||||
} catch ( android.content.ActivityNotFoundException anfe ) {
|
||||
Utils.logf( "%s", anfe.toString() );
|
||||
DbgUtils.logf( "%s", anfe.toString() );
|
||||
}
|
||||
}
|
||||
} // lookupWord
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -37,7 +37,7 @@ public class MountEventReceiver extends BroadcastReceiver {
|
|||
@Override
|
||||
public void onReceive( Context context, Intent intent )
|
||||
{
|
||||
Utils.logf( "MountEventReceiver.onReceive(%s)", intent.getAction() );
|
||||
DbgUtils.logf( "MountEventReceiver.onReceive(%s)", intent.getAction() );
|
||||
synchronized( s_procs ) {
|
||||
do {
|
||||
if ( s_procs.isEmpty() ) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// /* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
// /* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
// /*
|
||||
// * Copyright 2010 by Eric House (xwords@eehouse.org). All rights
|
||||
// * reserved.
|
||||
|
@ -31,7 +31,7 @@
|
|||
// @Override
|
||||
// public void onReceive( Context context, Intent intent )
|
||||
// {
|
||||
// Utils.logf( "NBSReceiver::onReceive(intent=%s)!!!!",
|
||||
// DbgUtils.logf( "NBSReceiver::onReceive(intent=%s)!!!!",
|
||||
// intent.toString() );
|
||||
// }
|
||||
|
||||
|
@ -46,9 +46,9 @@
|
|||
// data, null, null );
|
||||
// // PendingIntent sentIntent,
|
||||
// // PendingIntent deliveryIntent );
|
||||
// Utils.logf( "sendDataMessage finished" );
|
||||
// DbgUtils.logf( "sendDataMessage finished" );
|
||||
// } catch ( IllegalArgumentException iae ) {
|
||||
// Utils.logf( "%s", iae.toString() );
|
||||
// DbgUtils.logf( "%s", iae.toString() );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2011 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -84,7 +84,7 @@ public class NetLaunchInfo {
|
|||
nPlayers = Integer.decode( np );
|
||||
m_valid = true;
|
||||
} catch ( Exception e ) {
|
||||
Utils.logf( "unable to parse \"%s\"", data.toString() );
|
||||
DbgUtils.logf( "unable to parse \"%s\"", data.toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2010 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
|
@ -100,8 +100,8 @@ public class NetStateCache {
|
|||
|
||||
NetworkInfo ni = (NetworkInfo)intent.
|
||||
getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
|
||||
Utils.logf( "CommsBroadcastReceiver.onReceive: %s",
|
||||
ni.getState().toString() );
|
||||
DbgUtils.logf( "CommsBroadcastReceiver.onReceive: %s",
|
||||
ni.getState().toString() );
|
||||
|
||||
boolean netAvail;
|
||||
switch ( ni.getState() ) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -56,9 +56,9 @@ public class NetUtils {
|
|||
socket.setSoTimeout( timeoutMillis );
|
||||
|
||||
} catch ( java.net.UnknownHostException uhe ) {
|
||||
Utils.logf( uhe.toString() );
|
||||
DbgUtils.logf( uhe.toString() );
|
||||
} catch( java.io.IOException ioe ) {
|
||||
Utils.logf( ioe.toString() );
|
||||
DbgUtils.logf( ioe.toString() );
|
||||
}
|
||||
return socket;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class NetUtils {
|
|||
DBUtils.clearObits( m_context, m_obits );
|
||||
}
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
Utils.logf( ioe.toString() );
|
||||
DbgUtils.logf( ioe.toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -190,11 +190,11 @@ public class NetUtils {
|
|||
}
|
||||
|
||||
} catch( java.net.UnknownHostException uhe ) {
|
||||
Utils.logf( uhe.toString() );
|
||||
DbgUtils.logf( uhe.toString() );
|
||||
} catch( java.io.IOException ioe ) {
|
||||
Utils.logf( ioe.toString() );
|
||||
DbgUtils.logf( ioe.toString() );
|
||||
} catch( NullPointerException npe ) {
|
||||
Utils.logf( npe.toString() );
|
||||
DbgUtils.logf( npe.toString() );
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -19,19 +19,16 @@
|
|||
*/
|
||||
|
||||
package org.eehouse.android.xw4;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.app.Dialog;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.app.Dialog;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.Preference;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MenuInflater;
|
||||
import java.util.HashSet;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
public class PrefsActivity extends PreferenceActivity
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
@ -112,8 +109,22 @@ public class PrefsActivity extends PreferenceActivity
|
|||
|
||||
// Load the preferences from an XML resource
|
||||
addPreferencesFromResource( R.xml.xwprefs );
|
||||
setContentView( R.layout.prefs_w_buttons );
|
||||
|
||||
m_keyLogging = getString( R.string.key_logging_on );
|
||||
|
||||
Button button = (Button)findViewById( R.id.revert_colors );
|
||||
button.setOnClickListener( new View.OnClickListener() {
|
||||
public void onClick( View v ) {
|
||||
showDialog( REVERT_COLORS );
|
||||
}
|
||||
} );
|
||||
button = (Button)findViewById( R.id.revert_all );
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick( View v ) {
|
||||
showDialog( REVERT_ALL );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -135,38 +146,10 @@ public class PrefsActivity extends PreferenceActivity
|
|||
public void onSharedPreferenceChanged( SharedPreferences sp, String key )
|
||||
{
|
||||
if ( key.equals( m_keyLogging ) ) {
|
||||
Utils.logEnable( sp.getBoolean( key, false ) );
|
||||
DbgUtils.logEnable( sp.getBoolean( key, false ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu( Menu menu )
|
||||
{
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate( R.menu.prefs_menu, menu );
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected( MenuItem item )
|
||||
{
|
||||
int dlgID = 0;
|
||||
switch ( item.getItemId() ) {
|
||||
case R.id.menu_revert_all:
|
||||
dlgID = REVERT_ALL;
|
||||
break;
|
||||
case R.id.menu_revert_colors:
|
||||
dlgID = REVERT_COLORS;
|
||||
break;
|
||||
}
|
||||
|
||||
boolean handled = 0 != dlgID;
|
||||
if ( handled ) {
|
||||
showDialog( dlgID );
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
private void relaunch()
|
||||
{
|
||||
PreferenceManager.setDefaultValues( this, R.xml.xwprefs,
|
||||
|
|
|
@ -31,7 +31,7 @@ public class ReceiveNBS extends BroadcastReceiver {
|
|||
@Override
|
||||
public void onReceive( Context context, Intent intent )
|
||||
{
|
||||
Utils.logf( "onReceive called: %s", intent.toString() );
|
||||
DbgUtils.logf( "onReceive called: %s", intent.toString() );
|
||||
|
||||
Bundle bundle = intent.getExtras();
|
||||
SmsMessage[] smsarr = null;
|
||||
|
@ -40,7 +40,7 @@ public class ReceiveNBS extends BroadcastReceiver {
|
|||
smsarr = new SmsMessage[pdus.length];
|
||||
for ( int ii = 0; ii < pdus.length; ii++){
|
||||
smsarr[ii] = SmsMessage.createFromPdu((byte[])pdus[ii]);
|
||||
Utils.logf( "from %s", smsarr[ii].getOriginatingAddress() );
|
||||
DbgUtils.logf( "from %s", smsarr[ii].getOriginatingAddress() );
|
||||
// buf.append( smsarr[ii].getMessageBody() );
|
||||
// XwJni.handle( XwJni.JNICmd.CMD_RECEIVE,
|
||||
// smsarr[ii].getMessageBody() );
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -67,7 +67,7 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
|
|||
protected String[] doInBackground( Void...unused )
|
||||
{
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
Utils.logf( "doInBackground()" );
|
||||
DbgUtils.logf( "doInBackground()" );
|
||||
|
||||
try {
|
||||
Socket socket = NetUtils.MakeProxySocket( m_context, 15000 );
|
||||
|
@ -87,7 +87,7 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
|
|||
new DataInputStream(socket.getInputStream());
|
||||
short len = dis.readShort();
|
||||
short nRooms = dis.readShort();
|
||||
Utils.logf( "%s: got %d rooms", "doInBackground", nRooms );
|
||||
DbgUtils.logf( "%s: got %d rooms", "doInBackground", nRooms );
|
||||
|
||||
// Can't figure out how to read a null-terminated string
|
||||
// from DataInputStream so parse it myself.
|
||||
|
@ -101,16 +101,16 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
|
|||
++index;
|
||||
}
|
||||
String name = new String( bytes, lastIndex, index - lastIndex );
|
||||
Utils.logf( "got public room name: %s", name );
|
||||
DbgUtils.logf( "got public room name: %s", name );
|
||||
int indx = name.lastIndexOf( "/" );
|
||||
indx = name.lastIndexOf( "/", indx-1 );
|
||||
names.add( name.substring(0, indx ) );
|
||||
}
|
||||
}
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
Utils.logf( "%s", ioe.toString() );
|
||||
DbgUtils.logf( "%s", ioe.toString() );
|
||||
}
|
||||
Utils.logf( "doInBackground() returning" );
|
||||
DbgUtils.logf( "doInBackground() returning" );
|
||||
return names.toArray( new String[names.size()] );
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
|
|||
@Override
|
||||
protected void onPostExecute( String[] result )
|
||||
{
|
||||
Utils.logf( "onPostExecute()" );
|
||||
DbgUtils.logf( "onPostExecute()" );
|
||||
ArrayAdapter<String> adapter =
|
||||
new ArrayAdapter<String>( m_context,
|
||||
android.R.layout.simple_spinner_item,
|
||||
|
@ -136,6 +136,6 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
|
|||
m_nnf.NoNameFound();
|
||||
}
|
||||
|
||||
Utils.logf( "onPostExecute() done" );
|
||||
DbgUtils.logf( "onPostExecute() done" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2010 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
|
@ -49,10 +49,10 @@ public class RelayReceiver extends BroadcastReceiver {
|
|||
{
|
||||
if ( null != intent && null != intent.getAction()
|
||||
&& intent.getAction().equals( Intent.ACTION_BOOT_COMPLETED ) ) {
|
||||
Utils.logf( "launching timer on boot" );
|
||||
DbgUtils.logf( "launching timer on boot" );
|
||||
RestartTimer( context );
|
||||
} else {
|
||||
// Utils.logf( "RelayReceiver::onReceive()" );
|
||||
// DbgUtils.logf( "RelayReceiver::onReceive()" );
|
||||
// if ( XWConstants.s_showProxyToast ) {
|
||||
// Toast.makeText(context, "RelayReceiver: fired",
|
||||
// Toast.LENGTH_SHORT).show();
|
||||
|
@ -83,7 +83,7 @@ public class RelayReceiver extends BroadcastReceiver {
|
|||
PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, 0 );
|
||||
|
||||
if ( interval_millis > 0 || force ) {
|
||||
// Utils.logf( "setting alarm for %d millis", interval_millis );
|
||||
// DbgUtils.logf( "setting alarm for %d millis", interval_millis );
|
||||
am.setInexactRepeating( AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||
0, // first firing
|
||||
interval_millis, pi );
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2010 - 2011 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -29,7 +29,7 @@ public class StatusReceiver extends BroadcastReceiver {
|
|||
@Override
|
||||
public void onReceive( Context context, Intent intent )
|
||||
{
|
||||
Utils.logf( "StatusReceiver.onReceive called: %s", intent.toString() );
|
||||
DbgUtils.logf( "StatusReceiver.onReceive called: %s", intent.toString() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -20,98 +20,27 @@
|
|||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.util.Log;
|
||||
import java.lang.Thread;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.Toast;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.text.format.Time;
|
||||
import java.util.Formatter;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.jni.*;
|
||||
|
||||
public class Utils {
|
||||
static final String TAG = "XW4";
|
||||
|
||||
static final String DB_PATH = "XW_GAMES";
|
||||
|
||||
static boolean s_doLog = true;
|
||||
|
||||
private static Time s_time = new Time();
|
||||
|
||||
private Utils() {}
|
||||
|
||||
public static void logEnable( boolean enable )
|
||||
{
|
||||
s_doLog = enable;
|
||||
}
|
||||
|
||||
public static void logEnable( Context context )
|
||||
{
|
||||
SharedPreferences sp
|
||||
= PreferenceManager.getDefaultSharedPreferences( context );
|
||||
String key = context.getString( R.string.key_logging_on );
|
||||
boolean on = sp.getBoolean( key, false );
|
||||
logEnable( on );
|
||||
}
|
||||
|
||||
public static void logf( String msg )
|
||||
{
|
||||
if ( s_doLog ) {
|
||||
s_time.setToNow();
|
||||
String time = s_time.format("[%H:%M:%S]");
|
||||
long id = Thread.currentThread().getId();
|
||||
Log.d( TAG, time + "-" + id + "-" + msg );
|
||||
}
|
||||
} // logf
|
||||
|
||||
public static void logf( String format, Object... args )
|
||||
{
|
||||
if ( s_doLog ) {
|
||||
Formatter formatter = new Formatter();
|
||||
logf( formatter.format( format, args ).toString() );
|
||||
}
|
||||
} // logf
|
||||
|
||||
public static void showf( Context context, String format, Object... args )
|
||||
{
|
||||
Formatter formatter = new Formatter();
|
||||
String msg = formatter.format( format, args ).toString();
|
||||
Toast.makeText( context, msg, Toast.LENGTH_SHORT ).show();
|
||||
} // showf
|
||||
|
||||
public static void showf( Context context, int formatid, Object... args )
|
||||
{
|
||||
showf( context, context.getString( formatid ), args );
|
||||
} // showf
|
||||
|
||||
public static void printStack( StackTraceElement[] trace )
|
||||
{
|
||||
if ( s_doLog ) {
|
||||
for ( int ii = 0; ii < trace.length; ++ii ) {
|
||||
Utils.logf( "ste %d: %s", ii, trace[ii].toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void printStack()
|
||||
{
|
||||
if ( s_doLog ) {
|
||||
printStack( Thread.currentThread().getStackTrace() );
|
||||
}
|
||||
}
|
||||
|
||||
public static void notImpl( Context context )
|
||||
{
|
||||
CharSequence text = "Feature coming soon";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2010 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
|
@ -40,7 +40,7 @@ public class XWActivity extends Activity
|
|||
@Override
|
||||
protected void onCreate( Bundle savedInstanceState )
|
||||
{
|
||||
Utils.logf( "%s.onCreate(this=%H)", getClass().getName(), this );
|
||||
DbgUtils.logf( "%s.onCreate(this=%H)", getClass().getName(), this );
|
||||
super.onCreate( savedInstanceState );
|
||||
m_delegate = new DlgDelegate( this, this, savedInstanceState );
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class XWActivity extends Activity
|
|||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
Utils.logf( "%s.onStart(this=%H)", getClass().getName(), this );
|
||||
DbgUtils.logf( "%s.onStart(this=%H)", getClass().getName(), this );
|
||||
super.onStart();
|
||||
DispatchNotify.SetRunning( this );
|
||||
}
|
||||
|
@ -56,21 +56,21 @@ public class XWActivity extends Activity
|
|||
@Override
|
||||
protected void onResume()
|
||||
{
|
||||
Utils.logf( "%s.onResume(this=%H)", getClass().getName(), this );
|
||||
DbgUtils.logf( "%s.onResume(this=%H)", getClass().getName(), this );
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
Utils.logf( "%s.onPause(this=%H)", getClass().getName(), this );
|
||||
DbgUtils.logf( "%s.onPause(this=%H)", getClass().getName(), this );
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
Utils.logf( "%s.onStop(this=%H)", getClass().getName(), this );
|
||||
DbgUtils.logf( "%s.onStop(this=%H)", getClass().getName(), this );
|
||||
DispatchNotify.ClearRunning( this );
|
||||
super.onStop();
|
||||
}
|
||||
|
@ -78,8 +78,8 @@ public class XWActivity extends Activity
|
|||
@Override
|
||||
protected void onDestroy()
|
||||
{
|
||||
Utils.logf( "%s.onDestroy(this=%H); isFinishing=%b",
|
||||
getClass().getName(), this, isFinishing() );
|
||||
DbgUtils.logf( "%s.onDestroy(this=%H); isFinishing=%b",
|
||||
getClass().getName(), this, isFinishing() );
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class XWActivity extends Activity
|
|||
{
|
||||
Dialog dialog = super.onCreateDialog( id );
|
||||
if ( null == dialog ) {
|
||||
Utils.logf( "%s.onCreateDialog() called", getClass().getName() );
|
||||
DbgUtils.logf( "%s.onCreateDialog() called", getClass().getName() );
|
||||
dialog = m_delegate.onCreateDialog( id );
|
||||
}
|
||||
return dialog;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2010 - 2011 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -27,8 +27,8 @@ public class XWApp extends Application {
|
|||
@Override
|
||||
public void onCreate()
|
||||
{
|
||||
Utils.logEnable( this );
|
||||
Utils.logf( "XWApp.onCreate(); svn_rev=%s", getString(R.string.git_rev_gen) );
|
||||
DbgUtils.logEnable( this );
|
||||
DbgUtils.logf( "XWApp.onCreate(); svn_rev=%s", getString(R.string.git_rev_gen) );
|
||||
super.onCreate();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -37,7 +37,7 @@ public class XWListActivity extends ListActivity
|
|||
@Override
|
||||
protected void onCreate( Bundle savedInstanceState )
|
||||
{
|
||||
Utils.logf( "%s.onCreate(this=%H)", getClass().getName(), this );
|
||||
DbgUtils.logf( "%s.onCreate(this=%H)", getClass().getName(), this );
|
||||
super.onCreate( savedInstanceState );
|
||||
m_delegate = new DlgDelegate( this, this, savedInstanceState );
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class XWListActivity extends ListActivity
|
|||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
Utils.logf( "%s.onStart(this=%H)", getClass().getName(), this );
|
||||
DbgUtils.logf( "%s.onStart(this=%H)", getClass().getName(), this );
|
||||
super.onStart();
|
||||
DispatchNotify.SetRunning( this );
|
||||
}
|
||||
|
@ -53,21 +53,21 @@ public class XWListActivity extends ListActivity
|
|||
@Override
|
||||
protected void onResume()
|
||||
{
|
||||
Utils.logf( "%s.onResume(this=%H)", getClass().getName(), this );
|
||||
DbgUtils.logf( "%s.onResume(this=%H)", getClass().getName(), this );
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
Utils.logf( "%s.onPause(this=%H)", getClass().getName(), this );
|
||||
DbgUtils.logf( "%s.onPause(this=%H)", getClass().getName(), this );
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
Utils.logf( "%s.onStop(this=%H)", getClass().getName(), this );
|
||||
DbgUtils.logf( "%s.onStop(this=%H)", getClass().getName(), this );
|
||||
DispatchNotify.ClearRunning( this );
|
||||
super.onStop();
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ public class XWListActivity extends ListActivity
|
|||
@Override
|
||||
protected void onDestroy()
|
||||
{
|
||||
Utils.logf( "%s.onDestroy(this=%H); isFinishing=%b",
|
||||
getClass().getName(), this, isFinishing() );
|
||||
DbgUtils.logf( "%s.onDestroy(this=%H); isFinishing=%b",
|
||||
getClass().getName(), this, isFinishing() );
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class XWListActivity extends ListActivity
|
|||
@Override
|
||||
protected Dialog onCreateDialog( final int id )
|
||||
{
|
||||
Utils.logf( "%s.onCreateDialog() called", getClass().getName() );
|
||||
DbgUtils.logf( "%s.onCreateDialog() called", getClass().getName() );
|
||||
Dialog dialog = m_delegate.onCreateDialog( id );
|
||||
if ( null == dialog ) {
|
||||
dialog = super.onCreateDialog( id );
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2010 - 2011 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -164,7 +164,7 @@ public class CommonPrefs {
|
|||
result = Integer.parseInt( val );
|
||||
} catch ( Exception ex ) {
|
||||
}
|
||||
// Utils.logf( "getDefaultProxyPort=>%d", result );
|
||||
// DbgUtils.logf( "getDefaultProxyPort=>%d", result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -26,7 +26,7 @@ import java.util.HashSet;
|
|||
import java.util.Arrays;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.Utils;
|
||||
import org.eehouse.android.xw4.DbgUtils;
|
||||
import org.eehouse.android.xw4.DictUtils;
|
||||
import org.eehouse.android.xw4.R;
|
||||
import org.eehouse.android.xw4.DictLangCache;
|
||||
|
@ -216,7 +216,7 @@ public class CurGameInfo {
|
|||
++count;
|
||||
}
|
||||
}
|
||||
Utils.logf( "remoteCount()=>%d", count );
|
||||
DbgUtils.logf( "remoteCount()=>%d", count );
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -21,7 +21,6 @@
|
|||
|
||||
package org.eehouse.android.xw4.jni;
|
||||
|
||||
import org.eehouse.android.xw4.Utils;
|
||||
import android.content.Context;
|
||||
import java.lang.InterruptedException;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
@ -32,6 +31,7 @@ import android.graphics.Paint;
|
|||
import android.graphics.Rect;
|
||||
|
||||
import org.eehouse.android.xw4.R;
|
||||
import org.eehouse.android.xw4.DbgUtils;
|
||||
import org.eehouse.android.xw4.BoardDims;
|
||||
import org.eehouse.android.xw4.GameUtils;
|
||||
import org.eehouse.android.xw4.DBUtils;
|
||||
|
@ -163,7 +163,7 @@ public class JNIThread extends Thread {
|
|||
join();
|
||||
// Assert.assertFalse( isAlive() );
|
||||
} catch ( java.lang.InterruptedException ie ) {
|
||||
Utils.logf( "JNIThread.waitToStop() got %s", ie.toString() );
|
||||
DbgUtils.logf( "JNIThread.waitToStop() got %s", ie.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -290,7 +290,7 @@ public class JNIThread extends Thread {
|
|||
try {
|
||||
elem = m_queue.take();
|
||||
} catch ( InterruptedException ie ) {
|
||||
Utils.logf( "interrupted; killing thread" );
|
||||
DbgUtils.logf( "interrupted; killing thread" );
|
||||
break;
|
||||
}
|
||||
boolean draw = false;
|
||||
|
@ -565,7 +565,7 @@ public class JNIThread extends Thread {
|
|||
public void handle( JNICmd cmd, boolean isUI, Object... args )
|
||||
{
|
||||
QueueElem elem = new QueueElem( cmd, isUI, args );
|
||||
// Utils.logf( "adding: %s", cmd.toString() );
|
||||
// DbgUtils.logf( "adding: %s", cmd.toString() );
|
||||
m_queue.add( elem );
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -56,7 +56,7 @@ public class JNIUtilsImpl implements JNIUtils {
|
|||
try {
|
||||
isr = new InputStreamReader( bais, isUTF8? "UTF8" : "ISO8859_1" );
|
||||
} catch( java.io.UnsupportedEncodingException uee ) {
|
||||
Utils.logf( "splitFaces: %s", uee.toString() );
|
||||
DbgUtils.logf( "splitFaces: %s", uee.toString() );
|
||||
isr = new InputStreamReader( bais );
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class JNIUtilsImpl implements JNIUtils {
|
|||
try {
|
||||
chr = isr.read();
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
Utils.logf( ioe.toString() );
|
||||
DbgUtils.logf( ioe.toString() );
|
||||
}
|
||||
if ( -1 == chr ) {
|
||||
break;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
@ -22,7 +22,7 @@ package org.eehouse.android.xw4.jni;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import org.eehouse.android.xw4.Utils;
|
||||
import org.eehouse.android.xw4.DbgUtils;
|
||||
import org.eehouse.android.xw4.R;
|
||||
|
||||
public class UtilCtxtImpl implements UtilCtxt {
|
||||
|
@ -173,7 +173,7 @@ public class UtilCtxtImpl implements UtilCtxt {
|
|||
id = R.string.strd_turn_score;
|
||||
break;
|
||||
default:
|
||||
Utils.logf( "no such stringCode: %d", stringCode );
|
||||
DbgUtils.logf( "no such stringCode: %d", stringCode );
|
||||
}
|
||||
|
||||
String result;
|
||||
|
@ -227,7 +227,7 @@ public class UtilCtxtImpl implements UtilCtxt {
|
|||
}
|
||||
|
||||
private void subclassOverride( String name ) {
|
||||
Utils.logf( "%s::%s() called", getClass().getName(), name );
|
||||
DbgUtils.logf( "%s::%s() called", getClass().getName(), name );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
|
||||
/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
|
|
|
@ -7,7 +7,7 @@ cd ../XWords4
|
|||
|
||||
# create local.properties for 1.6 sdk (target id 4). Use 'android
|
||||
# list targets' to get the full set.
|
||||
android update project --path . --target 4
|
||||
android update project --path . --target 6
|
||||
|
||||
echo "local.properties looks like this:"
|
||||
echo ""
|
||||
|
|
|
@ -207,6 +207,12 @@ board_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model,
|
|||
BoardCtxt* board;
|
||||
XP_U16 ii;
|
||||
XP_U16 version = stream_getVersion( stream );
|
||||
XP_U16 nColsNBits;
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
nColsNBits = 16 > model_numCols(model) ? NUMCOLS_NBITS_4 : NUMCOLS_NBITS_5;
|
||||
#else
|
||||
nColsNBits = NUMCOLS_NBITS_4;
|
||||
#endif
|
||||
|
||||
board = board_make( MPPARM(mpool) model, server, draw, util );
|
||||
|
||||
|
@ -238,8 +244,8 @@ board_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model,
|
|||
for ( ii = 0; ii < nPlayers; ++ii ) {
|
||||
PerTurnInfo* pti = &board->pti[ii];
|
||||
BoardArrow* arrow = &pti->boardArrow;
|
||||
arrow->col = (XP_U8)stream_getBits( stream, NUMCOLS_NBITS );
|
||||
arrow->row = (XP_U8)stream_getBits( stream, NUMCOLS_NBITS );
|
||||
arrow->col = (XP_U8)stream_getBits( stream, nColsNBits );
|
||||
arrow->row = (XP_U8)stream_getBits( stream, nColsNBits );
|
||||
arrow->vert = (XP_Bool)stream_getBits( stream, 1 );
|
||||
arrow->visible = (XP_Bool)stream_getBits( stream, 1 );
|
||||
|
||||
|
@ -284,7 +290,15 @@ board_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model,
|
|||
void
|
||||
board_writeToStream( BoardCtxt* board, XWStreamCtxt* stream )
|
||||
{
|
||||
XP_U16 nPlayers, i;
|
||||
XP_U16 nPlayers, ii;
|
||||
XP_U16 nColsNBits;
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
nColsNBits = 16 > model_numCols(board->model) ? NUMCOLS_NBITS_4
|
||||
: NUMCOLS_NBITS_5;
|
||||
#else
|
||||
nColsNBits = NUMCOLS_NBITS_4;
|
||||
#endif
|
||||
|
||||
|
||||
stream_putBits( stream, 4, board->sd[SCROLL_H].offset );
|
||||
stream_putBits( stream, 4, board->zoomCount );
|
||||
|
@ -304,11 +318,11 @@ board_writeToStream( BoardCtxt* board, XWStreamCtxt* stream )
|
|||
XP_ASSERT( !!board->server );
|
||||
nPlayers = board->gi->nPlayers;
|
||||
|
||||
for ( i = 0; i < nPlayers; ++i ) {
|
||||
PerTurnInfo* pti = &board->pti[i];
|
||||
for ( ii = 0; ii < nPlayers; ++ii ) {
|
||||
PerTurnInfo* pti = &board->pti[ii];
|
||||
BoardArrow* arrow = &pti->boardArrow;
|
||||
stream_putBits( stream, NUMCOLS_NBITS, arrow->col );
|
||||
stream_putBits( stream, NUMCOLS_NBITS, arrow->row );
|
||||
stream_putBits( stream, nColsNBits, arrow->col );
|
||||
stream_putBits( stream, nColsNBits, arrow->row );
|
||||
stream_putBits( stream, 1, arrow->vert );
|
||||
stream_putBits( stream, 1, arrow->visible );
|
||||
|
||||
|
|
|
@ -42,6 +42,11 @@
|
|||
|
||||
#define VSIZE(arr) (sizeof(arr)/sizeof(arr[0]))
|
||||
|
||||
#ifndef MAX_ROWS
|
||||
# define MAX_ROWS 16
|
||||
#endif
|
||||
#define MAX_COLS MAX_ROWS
|
||||
|
||||
#if MAX_COLS > 16
|
||||
# define STREAM_VERS_BIGBOARD 0x12
|
||||
#endif
|
||||
|
@ -146,10 +151,6 @@ typedef enum {
|
|||
} XWTimerReason;
|
||||
|
||||
#define MAX_NUM_PLAYERS 4
|
||||
#ifndef MAX_ROWS
|
||||
# define MAX_ROWS 16
|
||||
#endif
|
||||
#define MAX_COLS MAX_ROWS
|
||||
#ifdef EIGHT_TILES
|
||||
# define MAX_TRAY_TILES 8
|
||||
#else
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*- compile-command: "cd ../linux && make MEMDEBUG=TRUE"; -*- */
|
||||
/* -*- compile-command: "cd ../linux && make -j3 MEMDEBUG=TRUE"; -*- */
|
||||
/*
|
||||
* Copyright 2001-2009 by Eric House (xwords@eehouse.org). All rights
|
||||
* Copyright 2001-2011 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -90,7 +90,7 @@ game_makeNewGame( MPFORMAL XWGame* game, CurGameInfo* gi,
|
|||
gi->gameID = gameID;
|
||||
|
||||
game->model = model_make( MPPARM(mpool) (DictionaryCtxt*)NULL, NULL, util,
|
||||
gi->boardSize, gi->boardSize );
|
||||
gi->boardSize );
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
if ( gi->serverRole != SERVER_STANDALONE ) {
|
||||
|
@ -162,7 +162,7 @@ game_reset( MPFORMAL XWGame* game, CurGameInfo* gi,
|
|||
# endif
|
||||
#endif
|
||||
|
||||
model_init( game->model, gi->boardSize, gi->boardSize );
|
||||
model_setSize( game->model, gi->boardSize );
|
||||
server_reset( game->server,
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
game->comms
|
||||
|
@ -259,6 +259,7 @@ game_saveToStream( const XWGame* game, const CurGameInfo* gi,
|
|||
XWStreamCtxt* stream )
|
||||
{
|
||||
stream_putU8( stream, CUR_STREAM_VERS );
|
||||
stream_setVersion( stream, CUR_STREAM_VERS );
|
||||
|
||||
gi_writeToStream( stream, gi );
|
||||
|
||||
|
@ -426,10 +427,13 @@ gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi )
|
|||
XP_U16 ii;
|
||||
XP_UCHAR* str;
|
||||
XP_U16 strVersion = stream_getVersion( stream );
|
||||
XP_U16 nColsNBits;
|
||||
XP_ASSERT( 0 < strVersion );
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
XP_U16 nColsNBits = STREAM_VERS_BIGBOARD > strVersion ? 4 : NUMCOLS_NBITS;
|
||||
nColsNBits = STREAM_VERS_BIGBOARD > strVersion ? NUMCOLS_NBITS_4
|
||||
: NUMCOLS_NBITS_5;
|
||||
#else
|
||||
XP_U16 nColsNBits = NUMCOLS_NBITS;
|
||||
nColsNBits = NUMCOLS_NBITS_4;
|
||||
#endif
|
||||
|
||||
str = stringFromStream( mpool, stream );
|
||||
|
@ -495,16 +499,16 @@ gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi )
|
|||
{
|
||||
const LocalPlayer* pl;
|
||||
XP_U16 ii;
|
||||
|
||||
XP_U16 nColsNBits;
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
XP_U16 strVersion = stream_getVersion( stream );
|
||||
XP_ASSERT( STREAM_SAVE_PREVWORDS <= strVersion );
|
||||
XP_U16 nColsNBits = STREAM_VERS_BIGBOARD > strVersion ? 4 : NUMCOLS_NBITS;
|
||||
nColsNBits = STREAM_VERS_BIGBOARD > strVersion ? NUMCOLS_NBITS_4
|
||||
: NUMCOLS_NBITS_5;
|
||||
#else
|
||||
XP_U16 nColsNBits = NUMCOLS_NBITS;
|
||||
nColsNBits = NUMCOLS_NBITS_4;
|
||||
#endif
|
||||
|
||||
|
||||
stringToStream( stream, gi->dictName );
|
||||
|
||||
stream_putBits( stream, NPLAYERS_NBITS, gi->nPlayers );
|
||||
|
|
|
@ -71,9 +71,10 @@ static void buildModelFromStack( ModelCtxt* model, StackCtxt* stack,
|
|||
MovePrintFuncPre mpfpr,
|
||||
MovePrintFuncPost mpfpo, void* closure );
|
||||
static void setPendingCounts( ModelCtxt* model, XP_S16 turn );
|
||||
static void loadPlayerCtxt( XWStreamCtxt* stream, XP_U16 version,
|
||||
PlayerCtxt* pc );
|
||||
static void writePlayerCtxt( XWStreamCtxt* stream, PlayerCtxt* pc );
|
||||
static void loadPlayerCtxt( const ModelCtxt* model, XWStreamCtxt* stream,
|
||||
XP_U16 version, PlayerCtxt* pc );
|
||||
static void writePlayerCtxt( const ModelCtxt* model, XWStreamCtxt* stream,
|
||||
PlayerCtxt* pc );
|
||||
static XP_U16 model_getRecentPassCount( ModelCtxt* model );
|
||||
static XP_Bool recordWord( const XP_UCHAR* word, XP_Bool isLegal,
|
||||
#ifdef XWFEATURE_BOARDWORDS
|
||||
|
@ -85,15 +86,10 @@ static XP_Bool recordWord( const XP_UCHAR* word, XP_Bool isLegal,
|
|||
*
|
||||
****************************************************************************/
|
||||
ModelCtxt*
|
||||
model_make( MPFORMAL DictionaryCtxt* dict,
|
||||
const PlayerDicts* dicts, XW_UtilCtxt* util, XP_U16 nCols,
|
||||
XP_U16 nRows )
|
||||
model_make( MPFORMAL DictionaryCtxt* dict, const PlayerDicts* dicts,
|
||||
XW_UtilCtxt* util, XP_U16 nCols )
|
||||
{
|
||||
ModelCtxt* result;
|
||||
XP_U16 size;
|
||||
XP_ASSERT( nCols == nRows && nCols <= MAX_COLS );
|
||||
size = sizeof(*result) + TILES_SIZE(result, nCols);
|
||||
result = (ModelCtxt*)XP_MALLOC( mpool, size );
|
||||
ModelCtxt* result = (ModelCtxt*)XP_MALLOC( mpool, sizeof( *result ) );
|
||||
if ( result != NULL ) {
|
||||
XP_MEMSET( result, 0, sizeof(*result) );
|
||||
MPASSIGN(result->vol.mpool, mpool);
|
||||
|
@ -102,7 +98,7 @@ model_make( MPFORMAL DictionaryCtxt* dict,
|
|||
result->vol.wni.proc = recordWord;
|
||||
result->vol.wni.closure = &result->vol.rwi;
|
||||
|
||||
model_init( result, nCols, nRows );
|
||||
model_setSize( result, nCols );
|
||||
|
||||
XP_ASSERT( !!util->gameInfo );
|
||||
result->vol.gi = util->gameInfo;
|
||||
|
@ -123,18 +119,21 @@ model_makeFromStream( MPFORMAL XWStreamCtxt* stream, DictionaryCtxt* dict,
|
|||
XP_U16 ii;
|
||||
XP_Bool hasDict;
|
||||
XP_U16 nPlayers;
|
||||
XP_U16 nColsNBits;
|
||||
XP_U16 version = stream_getVersion( stream );
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
nColsNBits = STREAM_VERS_BIGBOARD > version ? 4 : NUMCOLS_NBITS;
|
||||
#else
|
||||
nColsNBits = NUMCOLS_NBITS;
|
||||
#endif
|
||||
|
||||
XP_ASSERT( !!dict || !!dicts );
|
||||
|
||||
nCols = (XP_U16)stream_getBits( stream, nColsNBits );
|
||||
nRows = (XP_U16)stream_getBits( stream, nColsNBits );
|
||||
if ( 0 ) {
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
} else if ( STREAM_VERS_BIGBOARD <= version ) {
|
||||
nCols = (XP_U16)stream_getBits( stream, NUMCOLS_NBITS_5 );
|
||||
nRows = nCols;
|
||||
#endif
|
||||
} else {
|
||||
nCols = (XP_U16)stream_getBits( stream, NUMCOLS_NBITS_4 );
|
||||
nRows = (XP_U16)stream_getBits( stream, NUMCOLS_NBITS_4 );
|
||||
}
|
||||
XP_ASSERT( MAX_COLS >= nCols );
|
||||
|
||||
hasDict = (version >= STREAM_VERS_MODEL_NO_DICT)
|
||||
? XP_FALSE : stream_getBits( stream, 1 );
|
||||
|
@ -146,18 +145,18 @@ model_makeFromStream( MPFORMAL XWStreamCtxt* stream, DictionaryCtxt* dict,
|
|||
dict_destroy( savedDict );
|
||||
}
|
||||
|
||||
model = model_make( MPPARM(mpool) dict, dicts, util, nCols, nRows );
|
||||
model = model_make( MPPARM(mpool) dict, dicts, util, nCols );
|
||||
model->nPlayers = nPlayers;
|
||||
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
if ( STREAM_VERS_BIGBOARD <= version ) {
|
||||
model->nBonuses = stream_getBits( stream, 7 );
|
||||
if ( 0 < model->nBonuses ) {
|
||||
model->bonuses =
|
||||
model->vol.nBonuses = stream_getBits( stream, 7 );
|
||||
if ( 0 < model->vol.nBonuses ) {
|
||||
model->vol.bonuses =
|
||||
XP_MALLOC( model->vol.mpool,
|
||||
model->nBonuses * sizeof( model->bonuses[0] ) );
|
||||
for ( ii = 0; ii < model->nBonuses; ++ii ) {
|
||||
model->bonuses[ii] = stream_getBits( stream, 4 );
|
||||
model->vol.nBonuses * sizeof( model->vol.bonuses[0] ) );
|
||||
for ( ii = 0; ii < model->vol.nBonuses; ++ii ) {
|
||||
model->vol.bonuses[ii] = stream_getBits( stream, 4 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +170,7 @@ model_makeFromStream( MPFORMAL XWStreamCtxt* stream, DictionaryCtxt* dict,
|
|||
NULL );
|
||||
|
||||
for ( ii = 0; ii < model->nPlayers; ++ii ) {
|
||||
loadPlayerCtxt( stream, version, &model->players[ii] );
|
||||
loadPlayerCtxt( model, stream, version, &model->players[ii] );
|
||||
setPendingCounts( model, ii );
|
||||
invalidateScore( model, ii );
|
||||
}
|
||||
|
@ -183,24 +182,28 @@ void
|
|||
model_writeToStream( ModelCtxt* model, XWStreamCtxt* stream )
|
||||
{
|
||||
XP_U16 ii;
|
||||
|
||||
stream_putBits( stream, NUMCOLS_NBITS, model->nCols );
|
||||
stream_putBits( stream, NUMCOLS_NBITS, model->nRows );
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
XP_ASSERT( STREAM_VERS_BIGBOARD <= stream_getVersion( stream ) );
|
||||
stream_putBits( stream, NUMCOLS_NBITS_5, model->nCols );
|
||||
#else
|
||||
stream_putBits( stream, NUMCOLS_NBITS_4, model->nCols );
|
||||
stream_putBits( stream, NUMCOLS_NBITS_4, model->nRows );
|
||||
#endif
|
||||
|
||||
/* we have two bits for nPlayers, so range must be 0..3, not 1..4 */
|
||||
stream_putBits( stream, NPLAYERS_NBITS, model->nPlayers );
|
||||
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
stream_putBits( stream, 7, model->nBonuses );
|
||||
for ( ii = 0; ii < model->nBonuses; ++ii ) {
|
||||
stream_putBits( stream, 4, model->bonuses[ii] );
|
||||
stream_putBits( stream, 7, model->vol.nBonuses );
|
||||
for ( ii = 0; ii < model->vol.nBonuses; ++ii ) {
|
||||
stream_putBits( stream, 4, model->vol.bonuses[ii] );
|
||||
}
|
||||
#endif
|
||||
|
||||
stack_writeToStream( model->vol.stack, stream );
|
||||
|
||||
for ( ii = 0; ii < model->nPlayers; ++ii ) {
|
||||
writePlayerCtxt( stream, &model->players[ii] );
|
||||
writePlayerCtxt( model, stream, &model->players[ii] );
|
||||
}
|
||||
} /* model_writeToStream */
|
||||
|
||||
|
@ -246,35 +249,44 @@ model_writeToTextStream( const ModelCtxt* model, XWStreamCtxt* stream )
|
|||
#endif
|
||||
|
||||
void
|
||||
model_init( ModelCtxt* model, XP_U16 nCols, XP_U16 nRows )
|
||||
model_setSize( ModelCtxt* model, XP_U16 nCols )
|
||||
{
|
||||
ModelVolatiles vol = model->vol; /* save vol so we don't wipe it out */
|
||||
XP_U16 oldSize = model->nCols; /* zero when called from model_make() */
|
||||
|
||||
XP_ASSERT( MAX_COLS >= nCols );
|
||||
XP_ASSERT( model != NULL );
|
||||
XP_MEMSET( model, 0, sizeof( *model ) );
|
||||
XP_MEMSET( &model->tiles, TILE_EMPTY_BIT, TILES_SIZE(model, nCols) );
|
||||
|
||||
model->nCols = nCols;
|
||||
model->nRows = nRows;
|
||||
|
||||
model->nRows = nCols;
|
||||
model->vol = vol;
|
||||
|
||||
if ( oldSize != nCols ) {
|
||||
if ( !!model->vol.tiles ) {
|
||||
XP_FREE( model->vol.mpool, model->vol.tiles );
|
||||
}
|
||||
model->vol.tiles = XP_MALLOC( model->vol.mpool, TILES_SIZE(model, nCols) );
|
||||
}
|
||||
XP_MEMSET( model->vol.tiles, TILE_EMPTY_BIT, TILES_SIZE(model, nCols) );
|
||||
|
||||
if ( !!model->vol.stack ) {
|
||||
stack_init( model->vol.stack );
|
||||
} else {
|
||||
model->vol.stack = stack_make( MPPARM(model->vol.mpool)
|
||||
util_getVTManager(model->vol.util));
|
||||
}
|
||||
} /* model_init */
|
||||
} /* model_setSize */
|
||||
|
||||
void
|
||||
model_destroy( ModelCtxt* model )
|
||||
{
|
||||
stack_destroy( model->vol.stack );
|
||||
/* is this it!? */
|
||||
if ( !!model->bonuses ) {
|
||||
XP_FREE( model->vol.mpool, model->bonuses );
|
||||
if ( !!model->vol.bonuses ) {
|
||||
XP_FREE( model->vol.mpool, model->vol.bonuses );
|
||||
}
|
||||
XP_FREE( model->vol.mpool, model->vol.tiles );
|
||||
XP_FREE( model->vol.mpool, model );
|
||||
} /* model_destroy */
|
||||
|
||||
|
@ -292,42 +304,28 @@ model_setSquareBonuses( ModelCtxt* model, XWBonusType* bonuses, XP_U16 nBonuses
|
|||
XP_ASSERT( wantLen == nBonuses );
|
||||
#endif
|
||||
|
||||
if ( !!model->bonuses ) {
|
||||
XP_FREE( model->vol.mpool, model->bonuses );
|
||||
if ( !!model->vol.bonuses ) {
|
||||
XP_FREE( model->vol.mpool, model->vol.bonuses );
|
||||
}
|
||||
model->bonuses = XP_MALLOC( model->vol.mpool,
|
||||
nBonuses * sizeof(model->bonuses[0]) );
|
||||
XP_MEMCPY( model->bonuses, bonuses, nBonuses * sizeof(model->bonuses[0]) );
|
||||
model->nBonuses = nBonuses;
|
||||
model->vol.bonuses = XP_MALLOC( model->vol.mpool,
|
||||
nBonuses * sizeof(model->vol.bonuses[0]) );
|
||||
XP_MEMCPY( model->vol.bonuses, bonuses,
|
||||
nBonuses * sizeof(model->vol.bonuses[0]) );
|
||||
model->vol.nBonuses = nBonuses;
|
||||
}
|
||||
|
||||
static void
|
||||
borrowSquareBonuses( ModelCtxt* dest, const ModelCtxt* src )
|
||||
{
|
||||
XP_ASSERT( !dest->bonuses );
|
||||
dest->bonuses = src->bonuses;
|
||||
dest->nBonuses = src->nBonuses;
|
||||
}
|
||||
|
||||
static void
|
||||
returnSquareBonuses( ModelCtxt* dest )
|
||||
{
|
||||
dest->bonuses = NULL;
|
||||
dest->nBonuses = 0;
|
||||
}
|
||||
#else
|
||||
# define borrowSquareBonuses(d,s)
|
||||
# define returnSquareBonuses(d)
|
||||
#endif
|
||||
|
||||
XWBonusType
|
||||
model_getSquareBonus( const ModelCtxt* model, XP_U16 col, XP_U16 row )
|
||||
{
|
||||
XWBonusType result = BONUS_NONE;
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
const ModelCtxt* bonusOwner = model->loaner? model->loaner : model;
|
||||
#endif
|
||||
|
||||
if ( 0 ) {
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
} else if ( !!model->bonuses ) {
|
||||
} else if ( !!bonusOwner->vol.bonuses ) {
|
||||
XP_U16 nCols = model_numCols( model );
|
||||
XP_U16 ii;
|
||||
if ( col > (nCols/2) ) {
|
||||
|
@ -345,8 +343,8 @@ model_getSquareBonus( const ModelCtxt* model, XP_U16 col, XP_U16 row )
|
|||
col += ii;
|
||||
}
|
||||
|
||||
if ( col < model->nBonuses ) {
|
||||
result = model->bonuses[col];
|
||||
if ( col < bonusOwner->vol.nBonuses ) {
|
||||
result = bonusOwner->vol.bonuses[col];
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
|
@ -696,7 +694,7 @@ setModelTileRaw( ModelCtxt* model, XP_U16 col, XP_U16 row, CellTile tile )
|
|||
{
|
||||
XP_ASSERT( col < model->nCols );
|
||||
XP_ASSERT( row < model->nRows );
|
||||
model->tiles[(row*model->nCols) + col] = tile;
|
||||
model->vol.tiles[(row*model->nCols) + col] = tile;
|
||||
} /* model_setTile */
|
||||
|
||||
static CellTile
|
||||
|
@ -706,7 +704,7 @@ getModelTileRaw( const ModelCtxt* model, XP_U16 col, XP_U16 row )
|
|||
XP_ASSERT( model->nRows == nCols );
|
||||
XP_ASSERT( col < nCols );
|
||||
XP_ASSERT( row < nCols );
|
||||
return model->tiles[(row*nCols) + col];
|
||||
return model->vol.tiles[(row*nCols) + col];
|
||||
} /* getModelTileRaw */
|
||||
|
||||
static void
|
||||
|
@ -930,11 +928,12 @@ model_currentMoveToStream( ModelCtxt* model, XP_S16 turn,
|
|||
{
|
||||
PlayerCtxt* player;
|
||||
XP_S16 numTiles;
|
||||
XP_U16 nColsNBits;
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
XP_U16 version = stream_getVersion( stream );
|
||||
XP_U16 nColsNBits = STREAM_VERS_BIGBOARD > version ? 4 : NUMCOLS_NBITS;
|
||||
nColsNBits = 16 <= model_numCols( model ) ? NUMCOLS_NBITS_5
|
||||
: NUMCOLS_NBITS_4;
|
||||
#else
|
||||
XP_U16 nColsNBits = NUMCOLS_NBITS;
|
||||
nColsNBits = NUMCOLS_NBITS_4;
|
||||
#endif
|
||||
|
||||
XP_ASSERT( turn >= 0 );
|
||||
|
@ -970,14 +969,14 @@ model_makeTurnFromStream( ModelCtxt* model, XP_U16 playerNum,
|
|||
{
|
||||
XP_U16 numTiles, ii;
|
||||
Tile blank = dict_getBlankTile( model_getDictionary(model) );
|
||||
XP_U16 nColsNBits;
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
XP_U16 version = stream_getVersion( stream );
|
||||
XP_U16 nColsNBits = STREAM_VERS_BIGBOARD > version ? 4 : NUMCOLS_NBITS;
|
||||
nColsNBits = 16 <= model_numCols( model ) ? NUMCOLS_NBITS_5
|
||||
: NUMCOLS_NBITS_4;
|
||||
#else
|
||||
XP_U16 nColsNBits = NUMCOLS_NBITS;
|
||||
nColsNBits = NUMCOLS_NBITS_4;
|
||||
#endif
|
||||
|
||||
|
||||
model_resetCurrentTurn( model, playerNum );
|
||||
|
||||
numTiles = (XP_U16)stream_getBits( stream, NTILES_NBITS );
|
||||
|
@ -2056,10 +2055,9 @@ makeTmpModel( ModelCtxt* model, XWStreamCtxt* stream,
|
|||
{
|
||||
ModelCtxt* tmpModel = model_make( MPPARM(model->vol.mpool)
|
||||
model_getDictionary(model), NULL,
|
||||
model->vol.util, model_numCols(model),
|
||||
model_numRows(model));
|
||||
model->vol.util, model_numCols(model) );
|
||||
tmpModel->loaner = model;
|
||||
model_setNPlayers( tmpModel, model->nPlayers );
|
||||
borrowSquareBonuses( tmpModel, model );
|
||||
|
||||
buildModelFromStack( tmpModel, model->vol.stack, XP_FALSE, 0, stream,
|
||||
(WordNotifierInfo*)NULL, mpf_pre, mpf_post, closure );
|
||||
|
@ -2081,7 +2079,6 @@ model_writeGameHistory( ModelCtxt* model, XWStreamCtxt* stream,
|
|||
|
||||
tmpModel = makeTmpModel( model, stream, printMovePre, printMovePost,
|
||||
&closure );
|
||||
returnSquareBonuses( tmpModel );
|
||||
model_destroy( tmpModel );
|
||||
|
||||
if ( gameOver ) {
|
||||
|
@ -2341,14 +2338,18 @@ model_getPlayersLastScore( ModelCtxt* model, XP_S16 player,
|
|||
} /* model_getPlayersLastScore */
|
||||
|
||||
static void
|
||||
loadPlayerCtxt( XWStreamCtxt* stream, XP_U16 version, PlayerCtxt* pc )
|
||||
loadPlayerCtxt( const ModelCtxt* model, XWStreamCtxt* stream, XP_U16 version,
|
||||
PlayerCtxt* pc )
|
||||
{
|
||||
PendingTile* pt;
|
||||
XP_U16 nTiles;
|
||||
XP_U16 nColsNBits;
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
XP_U16 nColsNBits = STREAM_VERS_BIGBOARD > version ? 4 : NUMCOLS_NBITS;
|
||||
nColsNBits = 16 <= model_numCols( model ) ? NUMCOLS_NBITS_5
|
||||
: NUMCOLS_NBITS_4;
|
||||
#else
|
||||
XP_U16 nColsNBits = NUMCOLS_NBITS;
|
||||
XP_USE(model);
|
||||
nColsNBits = NUMCOLS_NBITS_4;
|
||||
#endif
|
||||
|
||||
pc->curMoveValid = stream_getBits( stream, 1 );
|
||||
|
@ -2375,10 +2376,18 @@ loadPlayerCtxt( XWStreamCtxt* stream, XP_U16 version, PlayerCtxt* pc )
|
|||
} /* loadPlayerCtxt */
|
||||
|
||||
static void
|
||||
writePlayerCtxt( XWStreamCtxt* stream, PlayerCtxt* pc )
|
||||
writePlayerCtxt( const ModelCtxt* model, XWStreamCtxt* stream, PlayerCtxt* pc )
|
||||
{
|
||||
XP_U16 nTiles;
|
||||
PendingTile* pt;
|
||||
XP_U16 nColsNBits;
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
nColsNBits = 16 <= model_numCols( model ) ? NUMCOLS_NBITS_5
|
||||
: NUMCOLS_NBITS_4;
|
||||
#else
|
||||
XP_USE(model);
|
||||
nColsNBits = NUMCOLS_NBITS_4;
|
||||
#endif
|
||||
|
||||
stream_putBits( stream, 1, pc->curMoveValid );
|
||||
|
||||
|
@ -2389,8 +2398,8 @@ writePlayerCtxt( XWStreamCtxt* stream, PlayerCtxt* pc )
|
|||
|
||||
nTiles = pc->nPending + pc->nUndone;
|
||||
for ( pt = pc->pendingTiles; nTiles-- > 0; ++pt ) {
|
||||
stream_putBits( stream, NUMCOLS_NBITS, pt->col );
|
||||
stream_putBits( stream, NUMCOLS_NBITS, pt->row );
|
||||
stream_putBits( stream, nColsNBits, pt->col );
|
||||
stream_putBits( stream, nColsNBits, pt->row );
|
||||
stream_putBits( stream, 7, pt->tile );
|
||||
}
|
||||
} /* writePlayerCtxt */
|
||||
|
|
|
@ -29,10 +29,9 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if MAX_COLS <= 16
|
||||
# define NUMCOLS_NBITS 4
|
||||
#elif MAX_COLS <= 32
|
||||
# define NUMCOLS_NBITS 5
|
||||
#define NUMCOLS_NBITS_4 4
|
||||
#if 16 < MAX_COLS && MAX_COLS <= 32
|
||||
# define NUMCOLS_NBITS_5 5
|
||||
#endif
|
||||
|
||||
#ifdef EIGHT_TILES
|
||||
|
@ -101,7 +100,7 @@ typedef XP_U8 TileBit; /* bits indicating selection of tiles in tray */
|
|||
|
||||
|
||||
ModelCtxt* model_make( MPFORMAL DictionaryCtxt* dict, const PlayerDicts* dicts,
|
||||
XW_UtilCtxt* util, XP_U16 nCols, XP_U16 nRows );
|
||||
XW_UtilCtxt* util, XP_U16 nCols );
|
||||
|
||||
ModelCtxt* model_makeFromStream( MPFORMAL XWStreamCtxt* stream,
|
||||
DictionaryCtxt* dict, const PlayerDicts* dicts,
|
||||
|
@ -113,7 +112,7 @@ void model_writeToStream( ModelCtxt* model, XWStreamCtxt* stream );
|
|||
void model_writeToTextStream( const ModelCtxt* model, XWStreamCtxt* stream );
|
||||
#endif
|
||||
|
||||
void model_init( ModelCtxt* model, XP_U16 nCols, XP_U16 nRows );
|
||||
void model_setSize( ModelCtxt* model, XP_U16 boardSize );
|
||||
void model_destroy( ModelCtxt* model );
|
||||
void model_setNPlayers( ModelCtxt* model, XP_U16 numPlayers );
|
||||
XP_U16 model_getNPlayers( const ModelCtxt* model );
|
||||
|
|
|
@ -64,6 +64,11 @@ typedef struct ModelVolatiles {
|
|||
RecordWordsInfo rwi;
|
||||
WordNotifierInfo wni;
|
||||
XP_U16 nTilesOnBoard;
|
||||
CellTile* tiles;
|
||||
|
||||
XP_U16 nBonuses;
|
||||
XWBonusType* bonuses;
|
||||
|
||||
MPSLOT
|
||||
} ModelVolatiles;
|
||||
|
||||
|
@ -75,13 +80,11 @@ struct ModelCtxt {
|
|||
XP_U16 nPlayers;
|
||||
XP_U16 nCols;
|
||||
XP_U16 nRows;
|
||||
XP_U16 nBonuses;
|
||||
XWBonusType* bonuses;
|
||||
|
||||
CellTile tiles[];
|
||||
const ModelCtxt* loaner; /* allows sharing bonuses */
|
||||
};
|
||||
|
||||
#define TILES_SIZE(m,nc) ((nc) * (nc) * sizeof((m)->tiles[0]))
|
||||
#define TILES_SIZE(m,nc) ((nc) * (nc) * sizeof((m)->vol.tiles[0]))
|
||||
|
||||
void invalidateScore( ModelCtxt* model, XP_S16 player );
|
||||
XP_Bool tilesInLine( ModelCtxt* model, XP_S16 turn, XP_Bool* isHorizontal );
|
||||
|
|
|
@ -1199,8 +1199,7 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream )
|
|||
XP_ASSERT( channelNo != 0 );
|
||||
server->nv.addresses[0].channelNo = channelNo;
|
||||
|
||||
/* PENDING init's a bit harsh for setting the size */
|
||||
model_init( model, nCols, nCols );
|
||||
model_setSize( model, nCols );
|
||||
|
||||
nPlayers = localGI.nPlayers;
|
||||
XP_STATUSF( "reading in %d players", localGI.nPlayers );
|
||||
|
@ -1418,9 +1417,6 @@ messageStreamWithHeader( ServerCtxt* server, XP_U16 devIndex, XW_Proto code )
|
|||
printCode("making", code);
|
||||
|
||||
stream = util_makeStreamFromAddr( server->vol.util, channelNo );
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
stream_setVersion( stream, server->nv.streamVersion );
|
||||
#endif
|
||||
stream_open( stream );
|
||||
writeProto( server, stream, code );
|
||||
|
||||
|
@ -2528,6 +2524,7 @@ writeProto( const ServerCtxt* server, XWStreamCtxt* stream, XW_Proto proto )
|
|||
stream_putBits( stream, XWPROTO_NBITS, XWPROTO_NEW_PROTO );
|
||||
stream_putBits( stream, 8, CUR_STREAM_VERS );
|
||||
}
|
||||
stream_setVersion( stream, server->nv.streamVersion );
|
||||
#else
|
||||
XP_USE(server);
|
||||
#endif
|
||||
|
|
|
@ -20,7 +20,7 @@ ifeq ($(MEMDEBUG),TRUE)
|
|||
DEFINES = -DMEM_DEBUG -DDEBUG -DENABLE_LOGGING -DNUMBER_KEY_AS_INDEX
|
||||
DEFINES += -DCOMMS_CHECKSUM
|
||||
CFLAGS += -g $(GPROFFLAG) -Wall -Wunused-parameter -Wcast-align -Werror -O0
|
||||
CFLAGS += -DDEBUG_TS
|
||||
CFLAGS += -DDEBUG_TS -rdynamic
|
||||
PLATFORM = obj_linux_memdbg
|
||||
else
|
||||
DEFINES =
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <ctype.h> /* BAD: use glib to support utf8 */
|
||||
#ifdef DEBUG
|
||||
# include <execinfo.h> /* for backtrace */
|
||||
#endif
|
||||
|
||||
#include "linuxutl.h"
|
||||
#include "main.h"
|
||||
|
@ -54,6 +57,21 @@ linux_debugf( const char* format, ... )
|
|||
|
||||
fprintf( stderr, "%s\n", buf );
|
||||
}
|
||||
|
||||
void
|
||||
linux_backtrace( void )
|
||||
{
|
||||
void* buffer[128];
|
||||
int nFound = backtrace( buffer, VSIZE(buffer) );
|
||||
XP_ASSERT( nFound < VSIZE(buffer) );
|
||||
char** traces = backtrace_symbols( buffer, nFound );
|
||||
|
||||
XP_U16 ii;
|
||||
for ( ii = 0; ii < nFound; ++ii ) {
|
||||
XP_LOGF( "trace[%.2d]: %s", ii, traces[ii] );
|
||||
}
|
||||
free( traces );
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef MEM_DEBUG
|
||||
|
|
|
@ -1,101 +1,47 @@
|
|||
#!/bin/bash
|
||||
set -u -e
|
||||
|
||||
NGAMES=${NGAMES:-1}
|
||||
NROOMS=${NROOMS:-$NGAMES}
|
||||
HOST=${HOST:-localhost}
|
||||
PORT=${PORT:-10997}
|
||||
TIMEOUT=${TIMEOUT:-$((NGAMES*60+500))}
|
||||
DICTS=${DICTS:-dict.xwd}
|
||||
SAVE_GOOD=${SAVE_GOOD:-YES}
|
||||
MINDEVS=${MINDEVS:-2}
|
||||
MAXDEVS=${MAXDEVS:-4}
|
||||
RESIGN_RATIO=${RESIGN_RATIO:-1000}
|
||||
DROP_N=${DROP_N:-0}
|
||||
APP_NEW=""
|
||||
NGAMES=""
|
||||
NROOMS=""
|
||||
HOST=""
|
||||
PORT=""
|
||||
TIMEOUT=""
|
||||
SAVE_GOOD=""
|
||||
MINDEVS=""
|
||||
MAXDEVS=""
|
||||
RESIGN_RATIO=""
|
||||
DROP_N=""
|
||||
MINRUN=2
|
||||
ONE_PER_ROOM=""
|
||||
USE_GTK=""
|
||||
ALL_VIA_RQ=${ALL_VIA_RQ:-FALSE}
|
||||
|
||||
declare -a DICTS_ARR
|
||||
for DICT in $DICTS; do
|
||||
DICTS_ARR[${#DICTS_ARR[*]}]=$DICT
|
||||
done
|
||||
|
||||
SEED=""
|
||||
BOARD_SIZES_OLD=(15)
|
||||
BOARD_SIZES_NEW=(15)
|
||||
NAMES=(UNUSED Brynn Ariela Kati Eric)
|
||||
[ -n "$SEED" ] && RANDOM=$SEED
|
||||
|
||||
LOGDIR=$(basename $0)_logs
|
||||
RESUME=""
|
||||
for FILE in $(ls $LOGDIR/*.{xwg,txt} 2>/dev/null); do
|
||||
if [ -e $FILE ]; then
|
||||
echo "Unfinished games found in $LOGDIR; continue with them (or discard)?"
|
||||
read -p "<yes/no> " ANSWER
|
||||
case "$ANSWER" in
|
||||
y|yes|Y|YES)
|
||||
RESUME=1
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
break
|
||||
done
|
||||
|
||||
if [ -z "$RESUME" -a -d $LOGDIR ];then
|
||||
mv $LOGDIR /tmp/${LOGDIR}_$$
|
||||
fi
|
||||
mkdir -p $LOGDIR
|
||||
|
||||
if [ "$SAVE_GOOD" = YES ]; then
|
||||
DONEDIR=$LOGDIR/done
|
||||
mkdir -p $DONEDIR
|
||||
fi
|
||||
DEADDIR=$LOGDIR/dead
|
||||
mkdir -p $DEADDIR
|
||||
|
||||
USE_GTK=${USE_GTK:-FALSE}
|
||||
|
||||
declare -A PIDS
|
||||
declare -A CMDS
|
||||
declare -A APPS
|
||||
declare -A ARGS
|
||||
declare -A ROOMS
|
||||
declare -A FILES
|
||||
declare -A LOGS
|
||||
declare -A MINEND
|
||||
declare -A ROOM_PIDS
|
||||
# if [ TRUE = "$ALL_VIA_RQ" ]; then
|
||||
# declare -A PIPES
|
||||
# fi
|
||||
declare -a APPS_OLD
|
||||
declare -A CHECKED_ROOMS
|
||||
|
||||
PLAT_PARMS=""
|
||||
if [ $USE_GTK = FALSE ]; then
|
||||
PLAT_PARMS="--curses --close-stdin"
|
||||
fi
|
||||
|
||||
usage() {
|
||||
echo "usage: [env=val *] $0" 1>&2
|
||||
echo " current env variables and their values: " 1>&2
|
||||
for VAR in NGAMES NROOMS USE_GTK TIMEOUT HOST PORT DICTS SAVE_GOOD MINDEVS MAXDEVS RESIGN_RATIO DROP_N ALL_VIA_RQ; do
|
||||
echo "$VAR:" $(eval "echo \$${VAR}") 1>&2
|
||||
done
|
||||
exit 1
|
||||
}
|
||||
|
||||
connName() {
|
||||
function connName() {
|
||||
LOG=$1
|
||||
grep 'got_connect_cmd: connName' $LOG | \
|
||||
tail -n 1 | \
|
||||
sed 's,^.*connName: \"\(.*\)\"$,\1,'
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case $1 in
|
||||
*) usage
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
declare -A CHECKED_ROOMS
|
||||
check_room() {
|
||||
function check_room() {
|
||||
ROOM=$1
|
||||
if [ -z ${CHECKED_ROOMS[$ROOM]:-""} ]; then
|
||||
NUM=$(echo "SELECT COUNT(*) FROM games "\
|
||||
|
@ -114,15 +60,26 @@ check_room() {
|
|||
fi
|
||||
}
|
||||
|
||||
print_cmdline() {
|
||||
local COUNTER=$1
|
||||
local LOG=${LOGS[$COUNTER]}
|
||||
echo "New cmdline: ${APPS[$COUNTER]} ${ARGS[$COUNTER]}" >> $LOG
|
||||
}
|
||||
|
||||
build_cmds() {
|
||||
COUNTER=0
|
||||
PLAT_PARMS=""
|
||||
if [ $USE_GTK = FALSE ]; then
|
||||
PLAT_PARMS="--curses --close-stdin"
|
||||
fi
|
||||
|
||||
for GAME in $(seq 1 $NGAMES); do
|
||||
ROOM=$(printf "ROOM_%.3d" $((GAME % NROOMS)))
|
||||
ROOM_PIDS[$ROOM]=0
|
||||
check_room $ROOM
|
||||
NDEVS=$(( $RANDOM % ($MAXDEVS-1) + 2 ))
|
||||
[ $NDEVS -lt $MINDEVS ] && NDEVS=$MINDEVS
|
||||
DICT=${DICTS_ARR[$((GAME%${#DICTS_ARR[*]}))]}
|
||||
DICT=${DICTS[$((GAME%${#DICTS[*]}))]}
|
||||
# make one in three games public
|
||||
PUBLIC=""
|
||||
[ $((RANDOM%3)) -eq 0 ] && PUBLIC="--make-public --join-public"
|
||||
|
@ -135,22 +92,34 @@ build_cmds() {
|
|||
for DEV in $(seq $NDEVS); do
|
||||
FILE="${LOGDIR}/GAME_${GAME}_${DEV}.xwg"
|
||||
LOG=${LOGDIR}/${GAME}_${DEV}_LOG.txt
|
||||
> $LOG # clear the log
|
||||
touch $LOG # so greps won't show errors
|
||||
CMD="./obj_linux_memdbg/xwords --room $ROOM"
|
||||
CMD="$CMD --robot ${NAMES[$DEV]} --robot-iq $((1 + (RANDOM%100))) "
|
||||
CMD="$CMD $OTHERS --game-dict $DICT --port $PORT --host $HOST "
|
||||
CMD="$CMD --file $FILE --slow-robot 1:3 --skip-confirm"
|
||||
CMD="$CMD --drop-nth-packet $DROP_N $PLAT_PARMS"
|
||||
|
||||
CMD="$CMD $PUBLIC"
|
||||
CMDS[$COUNTER]=$CMD
|
||||
PARAMS=""
|
||||
APPS[$COUNTER]="$APP_NEW"
|
||||
BOARD_SIZE="--board-size ${BOARD_SIZES_NEW[$((RANDOM%${#BOARD_SIZES_NEW[*]}))]}"
|
||||
if [ xx = "${APPS_OLD+xx}" ]; then
|
||||
# 50% chance of starting out with old app
|
||||
if [ 0 -eq $((RANDOM%2)) ]; then
|
||||
APPS[$COUNTER]=${APPS_OLD[$((RANDOM%${#APPS_OLD[*]}))]}
|
||||
BOARD_SIZE="--board-size ${BOARD_SIZES_OLD[$((RANDOM%${#BOARD_SIZES_OLD[*]}))]}"
|
||||
fi
|
||||
fi
|
||||
PARAMS="$PARAMS $BOARD_SIZE --room $ROOM"
|
||||
PARAMS="$PARAMS --robot ${NAMES[$DEV]} --robot-iq $((1 + (RANDOM%100))) "
|
||||
PARAMS="$PARAMS $OTHERS --game-dict $DICT --port $PORT --host $HOST "
|
||||
PARAMS="$PARAMS --file $FILE --slow-robot 1:3 --skip-confirm"
|
||||
PARAMS="$PARAMS --drop-nth-packet $DROP_N $PLAT_PARMS"
|
||||
[ -n "$SEED" ] && PARAMS="$PARAMS --seed $RANDOM"
|
||||
PARAMS="$PARAMS $PUBLIC"
|
||||
ARGS[$COUNTER]=$PARAMS
|
||||
ROOMS[$COUNTER]=$ROOM
|
||||
FILES[$COUNTER]=$FILE
|
||||
LOGS[$COUNTER]=$LOG
|
||||
PIDS[$COUNTER]=0
|
||||
COUNTER=$((COUNTER+1))
|
||||
|
||||
echo "${CMD}" > $LOG
|
||||
print_cmdline $COUNTER
|
||||
|
||||
COUNTER=$((COUNTER+1))
|
||||
done
|
||||
done
|
||||
echo "finished creating $COUNTER commands"
|
||||
|
@ -159,9 +128,11 @@ build_cmds() {
|
|||
read_resume_cmds() {
|
||||
COUNTER=0
|
||||
for LOG in $(ls $LOGDIR/*.txt); do
|
||||
echo "need to parse cmd and deal with changes"
|
||||
exit 1
|
||||
CMD=$(head -n 1 $LOG)
|
||||
|
||||
CMDS[$COUNTER]=$CMD
|
||||
ARGS[$COUNTER]=$CMD
|
||||
LOGS[$COUNTER]=$LOG
|
||||
PIDS[$COUNTER]=0
|
||||
|
||||
|
@ -186,8 +157,9 @@ read_resume_cmds() {
|
|||
|
||||
launch() {
|
||||
LOG=${LOGS[$1]}
|
||||
CMD="${CMDS[$1]}"
|
||||
exec $CMD >/dev/null 2>>$LOG
|
||||
APP="${APPS[$1]}"
|
||||
PARAMS="${ARGS[$1]}"
|
||||
exec $APP $PARAMS >/dev/null 2>>$LOG
|
||||
}
|
||||
|
||||
# launch_via_rq() {
|
||||
|
@ -211,7 +183,7 @@ close_device() {
|
|||
[ ${ROOM_PIDS[$ROOM]} -eq $PID ] && ROOM_PIDS[$ROOM]=0
|
||||
fi
|
||||
unset PIDS[$ID]
|
||||
unset CMDS[$ID]
|
||||
unset ARGS[$ID]
|
||||
echo "closing game: $REASON" >> ${LOGS[$ID]}
|
||||
if [ -n "$MVTO" ]; then
|
||||
[ -f ${FILES[$ID]} ] && mv ${FILES[$ID]} $MVTO
|
||||
|
@ -223,6 +195,7 @@ close_device() {
|
|||
unset FILES[$ID]
|
||||
unset LOGS[$ID]
|
||||
unset ROOMS[$ID]
|
||||
unset APPS[$ID]
|
||||
}
|
||||
|
||||
OBITS=""
|
||||
|
@ -255,6 +228,19 @@ maybe_resign() {
|
|||
fi
|
||||
}
|
||||
|
||||
try_upgrade() {
|
||||
KEY=$1
|
||||
if [ xx = "${APPS_OLD+xx}" ]; then
|
||||
if [ $APP_NEW != ${APPS[$KEY]} ]; then
|
||||
# one in five chance of upgrading
|
||||
if [ 0 -eq $((RANDOM%5)) ]; then
|
||||
APPS[$KEY]=$APP_NEW
|
||||
print_cmdline $KEY
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
check_game() {
|
||||
KEY=$1
|
||||
LOG=${LOGS[$KEY]}
|
||||
|
@ -303,12 +289,12 @@ check_game() {
|
|||
|
||||
increment_drop() {
|
||||
KEY=$1
|
||||
CMD=${CMDS[$KEY]}
|
||||
CMD=${ARGS[$KEY]}
|
||||
if [ "$CMD" != "${CMD/drop-nth-packet//}" ]; then
|
||||
DROP_N=$(echo $CMD | sed 's,^.*drop-nth-packet \(-*[0-9]*\) .*$,\1,')
|
||||
if [ $DROP_N -gt 0 ]; then
|
||||
NEXT_N=$((DROP_N+1))
|
||||
CMDS[$KEY]=$(echo $CMD | sed "s,^\(.*drop-nth-packet \)$DROP_N\(.*\)$,\1$NEXT_N\2,")
|
||||
ARGS[$KEY]=$(echo $CMD | sed "s,^\(.*drop-nth-packet \)$DROP_N\(.*\)$,\1$NEXT_N\2,")
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -316,18 +302,19 @@ increment_drop() {
|
|||
run_cmds() {
|
||||
ENDTIME=$(($(date +%s) + TIMEOUT))
|
||||
while :; do
|
||||
COUNT=${#CMDS[*]}
|
||||
COUNT=${#ARGS[*]}
|
||||
[ 0 -ge $COUNT ] && break
|
||||
NOW=$(date '+%s')
|
||||
[ $NOW -ge $ENDTIME ] && break
|
||||
INDX=$(($RANDOM%COUNT))
|
||||
KEYS=( ${!CMDS[*]} )
|
||||
KEYS=( ${!ARGS[*]} )
|
||||
KEY=${KEYS[$INDX]}
|
||||
ROOM=${ROOMS[$KEY]}
|
||||
if [ 0 -eq ${PIDS[$KEY]} ]; then
|
||||
if [ -n "$ONE_PER_ROOM" -a 0 -ne ${ROOM_PIDS[$ROOM]} ]; then
|
||||
continue
|
||||
fi
|
||||
try_upgrade $KEY
|
||||
launch $KEY &
|
||||
PID=$!
|
||||
PIDS[$KEY]=$PID
|
||||
|
@ -351,27 +338,15 @@ run_cmds() {
|
|||
if [ $COUNT -gt 0 ]; then
|
||||
mkdir -p ${LOGDIR}/not_done
|
||||
echo "processing unfinished games...."
|
||||
for KEY in ${!CMDS[*]}; do
|
||||
for KEY in ${!ARGS[*]}; do
|
||||
close_device $KEY ${LOGDIR}/not_done "unfinished game"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# add_pipe() {
|
||||
# KEY=$1
|
||||
# CMD=${CMDS[$KEY]}
|
||||
# LOG=${LOGS[$KEY]}
|
||||
# PIPE=${LOG/LOG.txt/pipe}
|
||||
# PIPES[$KEY]=$PIPE
|
||||
# echo "mkfifo $PIPE"
|
||||
# mkfifo $PIPE
|
||||
# CMDS[$KEY]="$CMD --with-pipe $PIPE"
|
||||
# echo ${CMDS[$KEY]}
|
||||
# }
|
||||
|
||||
run_via_rq() {
|
||||
# launch then kill all games to give chance to hook up
|
||||
for KEY in ${!CMDS[*]}; do
|
||||
for KEY in ${!ARGS[*]}; do
|
||||
echo "launching $KEY"
|
||||
launch $KEY &
|
||||
PID=$!
|
||||
|
@ -384,13 +359,13 @@ run_via_rq() {
|
|||
echo "now running via rq"
|
||||
# then run them
|
||||
while :; do
|
||||
COUNT=${#CMDS[*]}
|
||||
COUNT=${#ARGS[*]}
|
||||
[ 0 -ge $COUNT ] && break
|
||||
|
||||
INDX=$(($RANDOM%COUNT))
|
||||
KEYS=( ${!CMDS[*]} )
|
||||
KEYS=( ${!ARGS[*]} )
|
||||
KEY=${KEYS[$INDX]}
|
||||
CMD=${CMDS[$KEY]}
|
||||
CMD=${ARGS[$KEY]}
|
||||
|
||||
RELAYID=$(./scripts/relayID.sh --short ${LOGS[$KEY]})
|
||||
MSG_COUNT=$(../relay/rq -a $HOST -m $RELAYID 2>/dev/null | sed 's,^.*-- ,,')
|
||||
|
@ -406,10 +381,140 @@ run_via_rq() {
|
|||
done
|
||||
} # run_via_rq
|
||||
|
||||
print_stats() {
|
||||
:
|
||||
function getArg() {
|
||||
echo $* >&2
|
||||
[ 1 -lt "$#" ] || usage "$1 requires an argument"
|
||||
echo $2
|
||||
}
|
||||
|
||||
function usage() {
|
||||
[ $# -gt 0 ] && echo "Error: $1" >&2
|
||||
echo "Usage: $(basename $0) \\" >&2
|
||||
echo " [--dict <path/to/dict>]* \\" >&2
|
||||
echo " [--old-app <path/to/app]* \\" >&2
|
||||
echo " [--new-app <path/to/app] \\" >&2
|
||||
echo " [--min-devs <int>] \\" >&2
|
||||
echo " [--max-devs <int>] \\" >&2
|
||||
echo " [--help] \\" >&2
|
||||
echo " [--num-games <int>] \\" >&2
|
||||
echo " [--num-rooms <int>] \\" >&2
|
||||
echo " [--host <hostname>] \\" >&2
|
||||
echo " [--port <int>] \\" >&2
|
||||
echo " [--seed <int>] \\" >&2
|
||||
echo " [--help] \\" >&2
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
#######################################################
|
||||
##################### MAIN begins #####################
|
||||
#######################################################
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case $1 in
|
||||
--num-games)
|
||||
NGAMES=$(getArg $*)
|
||||
shift
|
||||
;;
|
||||
--num-rooms)
|
||||
NROOMS=$(getArg $*)
|
||||
shift
|
||||
;;
|
||||
--old-app)
|
||||
APPS_OLD[${#APPS_OLD[@]}]=$(getArg $*)
|
||||
shift
|
||||
;;
|
||||
--new-app)
|
||||
APP_NEW=$(getArg $*)
|
||||
shift
|
||||
;;
|
||||
--dict)
|
||||
DICTS[${#DICTS[@]}]=$(getArg $*)
|
||||
shift
|
||||
;;
|
||||
--min-devs)
|
||||
MINDEVS=$(getArg $*)
|
||||
shift
|
||||
;;
|
||||
--max-devs)
|
||||
MAXDEVS=$(getArg $*)
|
||||
shift
|
||||
;;
|
||||
--host)
|
||||
HOST=$(getArg $*)
|
||||
shift
|
||||
;;
|
||||
--port)
|
||||
PORT=$(getArg $*)
|
||||
shift
|
||||
;;
|
||||
--seed)
|
||||
SEED=$(getArg $*)
|
||||
shift
|
||||
;;
|
||||
--help)
|
||||
usage
|
||||
;;
|
||||
*) usage "unrecognized option $1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Assign defaults
|
||||
#[ 0 -eq ${#DICTS[@]} ] && DICTS=(dict.xwd)
|
||||
[ xx = "${DICTS+xx}" ] || DICTS=(dict.xwd)
|
||||
[ -z "$APP_NEW" ] && APP_NEW=./obj_linux_memdbg/xwords
|
||||
[ -z "$MINDEVS" ] && MINDEVS=2
|
||||
[ -z "$MAXDEVS" ] && MAXDEVS=4
|
||||
[ -z "$NGAMES" ] && NGAMES=1
|
||||
[ -z "$NROOMS" ] && NROOMS=$NGAMES
|
||||
[ -z "$HOST" ] && HOST=localhost
|
||||
[ -z "$PORT" ] && PORT=10997
|
||||
[ -z "$TIMEOUT" ] && TIMEOUT=$((NGAMES*60+500))
|
||||
[ -z "$SAVE_GOOD" ] && SAVE_GOOD=YES
|
||||
[ -z "$RESIGN_RATIO" ] && RESIGN_RATIO=1000
|
||||
[ -z "$DROP_N" ] && DROP_N=0
|
||||
[ -z "$USE_GTK" ] && USE_GTK=FALSE
|
||||
|
||||
|
||||
LOGDIR=$(basename $0)_logs
|
||||
RESUME=""
|
||||
for FILE in $(ls $LOGDIR/*.{xwg,txt} 2>/dev/null); do
|
||||
if [ -e $FILE ]; then
|
||||
echo "Unfinished games found in $LOGDIR; continue with them (or discard)?"
|
||||
read -p "<yes/no> " ANSWER
|
||||
case "$ANSWER" in
|
||||
y|yes|Y|YES)
|
||||
RESUME=1
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
break
|
||||
done
|
||||
|
||||
if [ -z "$RESUME" -a -d $LOGDIR ];then
|
||||
mv $LOGDIR /tmp/${LOGDIR}_$$
|
||||
fi
|
||||
mkdir -p $LOGDIR
|
||||
|
||||
if [ "$SAVE_GOOD" = YES ]; then
|
||||
DONEDIR=$LOGDIR/done
|
||||
mkdir -p $DONEDIR
|
||||
fi
|
||||
DEADDIR=$LOGDIR/dead
|
||||
mkdir -p $DEADDIR
|
||||
|
||||
for VAR in NGAMES NROOMS USE_GTK TIMEOUT HOST PORT SAVE_GOOD \
|
||||
MINDEVS MAXDEVS RESIGN_RATIO DROP_N ALL_VIA_RQ SEED \
|
||||
APP_NEW; do
|
||||
echo "$VAR:" $(eval "echo \$${VAR}") 1>&2
|
||||
done
|
||||
echo "DICTS: ${DICTS[*]}"
|
||||
echo -n "APPS_OLD: "; [ xx = "${APPS_OLD[*]+xx}" ] && echo "APPS_OLD: ${APPS_OLD[*]}" || echo ""
|
||||
|
||||
echo "*********$0 starting: $(date)**************"
|
||||
STARTTIME=$(date +%s)
|
||||
[ -z "$RESUME" ] && build_cmds || read_resume_cmds
|
||||
|
@ -418,7 +523,6 @@ if [ TRUE = "$ALL_VIA_RQ" ]; then
|
|||
else
|
||||
run_cmds
|
||||
fi
|
||||
print_stats
|
||||
|
||||
wait
|
||||
|
||||
|
|
|
@ -115,8 +115,11 @@ void linux_lowerstr( XP_UCHAR* str );
|
|||
|
||||
#ifdef DEBUG
|
||||
# define XP_ASSERT(b) assert(b)
|
||||
void linux_backtrace( void );
|
||||
# define XP_BACKTRACE linux_backtrace
|
||||
#else
|
||||
# define XP_ASSERT(b)
|
||||
# define XP_BACKTRACE
|
||||
#endif
|
||||
|
||||
#define DGRAM_TYPE SOCK_DGRAM
|
||||
|
|
|
@ -241,9 +241,9 @@ do_deletes( int sockfd, const char** connNames, int nConnNames )
|
|||
int ii;
|
||||
|
||||
char buf[4096];
|
||||
int nused = 0;
|
||||
size_t nused = 0;
|
||||
for ( ii = 0; ii < nConnNames; ++ii ) {
|
||||
char tmp[32];
|
||||
char tmp[128];
|
||||
strcpy( tmp, connNames[ii] );
|
||||
char* seedp = strrchr( tmp, '/' );
|
||||
assert( !!seedp );
|
||||
|
@ -256,6 +256,7 @@ do_deletes( int sockfd, const char** connNames, int nConnNames )
|
|||
nused += sprintf( &buf[nused], "%s", tmp );
|
||||
buf[nused++] = '\n';
|
||||
}
|
||||
assert( nused < sizeof(buf) );
|
||||
|
||||
unsigned char hdr[] = { 0, PRX_DEVICE_GONE };
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ done
|
|||
|
||||
QUERY="WHERE NOT -NTOTAL = sum_array(nperdevice)"
|
||||
|
||||
echo "Device count: $(pidof xwords | wc | awk '{print $2}')"
|
||||
echo "Device (pid) count: $(pidof xwords | wc | awk '{print $2}')"
|
||||
echo "Row count:" $(psql -t xwgames -c "select count(*) FROM games $QUERY;")
|
||||
|
||||
echo "SELECT dead,connname,cid,room,lang,ntotal,nperdevice,seeds,ack,nsent "\
|
||||
|
|
|
@ -8,7 +8,6 @@ PIDFILE=${DIR}/xwrelay.pid
|
|||
CONFFILE=${DIR}/xwrelay.conf
|
||||
IDFILE=${DIR}/nextid.txt
|
||||
CSSFILE=${DIR}/xwrelay.css
|
||||
CONFFILE=${DIR}/xwrelay.conf
|
||||
|
||||
LOGFILE=/tmp/xwrelay_log_$$.txt
|
||||
#LOGFILE=/dev/null
|
||||
|
@ -79,6 +78,10 @@ do_start() {
|
|||
elif pidof $XWRELAY >/dev/null; then
|
||||
echo "already running: pid($XWRELAY)=>$(pidof $XWRELAY)" | tee -a $LOGFILE
|
||||
else
|
||||
if [ ! -e $CONFFILE ]; then
|
||||
echo "unable to find $CONFFILE"
|
||||
exit 1
|
||||
fi
|
||||
echo "starting..." | tee -a $LOGFILE
|
||||
echo "running $XWRELAY $@ -f $CONFFILE -s $CSSFILE" | tee -a $LOGFILE
|
||||
$XWRELAY $@ -f $CONFFILE -i $IDFILE -s $CSSFILE &
|
||||
|
|
Loading…
Reference in a new issue