From 3670af591bbdf9901cebc41886a2044f35f844c0 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 17 Jan 2024 13:34:34 -0800 Subject: [PATCH] cleanup stuff noted in code review -- no behavior change --- .../eehouse/android/xw4/BoardDelegate.java | 10 -------- .../java/org/eehouse/android/xw4/DBUtils.java | 4 +-- .../android/xw4/GamesListDelegate.java | 1 - .../android/xw4/InvitesNeededAlert.java | 1 - .../android/xw4/RematchConfigView.java | 5 ---- .../eehouse/android/xw4/jni/GameSummary.java | 1 - .../src/main/res/layout/rematch_config.xml | 25 +++++++------------ xwords4/android/jni/andutils.c | 11 ++++---- xwords4/android/jni/xwjni.c | 1 - xwords4/common/comms.c | 6 ++--- xwords4/common/game.c | 3 +-- xwords4/common/scorebdp.c | 2 +- xwords4/common/server.c | 15 +++++------ 13 files changed, 27 insertions(+), 58 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java index cc458ed7d..fc9dbd194 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java @@ -1581,16 +1581,6 @@ public class BoardDelegate extends DelegateBase callInviteChoices(); } - // @Override - // public void onInfoClicked( SentInvitesInfo sentInfo ) - // { - // String msg = sentInfo.getAsText( m_activity ); - // makeOkOnlyBuilder( msg ) - // .setTitle( R.string.title_invite_history ) - // .setAction( Action.INVITE_INFO ) - // .show(); - // } - @Override public long getRowID() { diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java index badb91b4b..bbf118f39 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java @@ -199,7 +199,6 @@ public class DBUtils { tmpInt = cursor.getInt( cursor.getColumnIndex( DBHelper.CAN_REMATCH )); summary.canRematch = 0 != (1 & tmpInt); - summary.canOfferRO = 0 != (2 & tmpInt); String str = cursor .getString(cursor.getColumnIndex(DBHelper.EXTRAS)); @@ -311,8 +310,7 @@ public class DBUtils { values.put( DBHelper.QUASHED, summary.quashed? 1 : 0 ); values.put( DBHelper.LASTMOVE, summary.lastMoveTime ); values.put( DBHelper.NEXTDUPTIMER, summary.dupTimerExpires ); - int tmpInt = (summary.canRematch? 1 : 0) | (summary.canOfferRO? 2 : 0); - values.put( DBHelper.CAN_REMATCH, tmpInt ); + values.put( DBHelper.CAN_REMATCH, summary.canRematch? 1 : 0 ); // Don't overwrite extras! Sometimes this method is called from // JNIThread which has created the summary from common code that diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java index 9ea0534bf..ef37a3835 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java @@ -67,7 +67,6 @@ import org.eehouse.android.xw4.jni.CurGameInfo; import org.eehouse.android.xw4.jni.GameSummary; import org.eehouse.android.xw4.jni.LastMoveInfo; import org.eehouse.android.xw4.jni.XwJNI; -import org.eehouse.android.xw4.jni.XwJNI.RematchOrder; import org.eehouse.android.xw4.loc.LocUtils; import static org.eehouse.android.xw4.DBUtils.ROWID_NOTFOUND; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InvitesNeededAlert.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InvitesNeededAlert.java index c53f3086c..644f4e3a0 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InvitesNeededAlert.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InvitesNeededAlert.java @@ -128,7 +128,6 @@ class InvitesNeededAlert { long getRowID(); void onCloseClicked(); void onInviteClicked(); - // void onInfoClicked( SentInvitesInfo sentInfo ); } private boolean close() diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RematchConfigView.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RematchConfigView.java index d1e5cba63..8d4d6fc5f 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RematchConfigView.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RematchConfigView.java @@ -24,9 +24,6 @@ import android.content.Context; import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; -import android.widget.AdapterView.OnItemSelectedListener; -import android.widget.AdapterView; -import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.RadioButton; import android.widget.RadioGroup; @@ -113,7 +110,6 @@ public class RematchConfigView extends LinearLayout } } else { mNameStr = TextUtils.join( mSep, mWrapper.gi().playerNames(mNewOrder) ); - Log.d( TAG, "mNameStr: %s", mNameStr ); mEWC.setText( mNameStr ); } } @@ -149,5 +145,4 @@ public class RematchConfigView extends LinearLayout } } } - } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/GameSummary.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/GameSummary.java index 243c434cf..2b305b44d 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/GameSummary.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/GameSummary.java @@ -85,7 +85,6 @@ public class GameSummary implements Serializable { public DeviceRole serverRole; public int nPacketsPending; public boolean canRematch; - public boolean canOfferRO; private Integer m_giFlags; private String m_playersSummary; diff --git a/xwords4/android/app/src/main/res/layout/rematch_config.xml b/xwords4/android/app/src/main/res/layout/rematch_config.xml index 1c5bc1c3e..3adc6200b 100644 --- a/xwords4/android/app/src/main/res/layout/rematch_config.xml +++ b/xwords4/android/app/src/main/res/layout/rematch_config.xml @@ -28,24 +28,17 @@ android:focusable="false" /> - + - - - - diff --git a/xwords4/android/jni/andutils.c b/xwords4/android/jni/andutils.c index 81db95f01..f3d511776 100644 --- a/xwords4/android/jni/andutils.c +++ b/xwords4/android/jni/andutils.c @@ -400,12 +400,13 @@ makeBooleanArray( JNIEnv* env, int siz, const jboolean* vals ) int getIntsFromArray( JNIEnv* env, int dest[], jintArray arr, int count, bool del ) { - jint* ints = (*env)->GetIntArrayElements(env, arr, 0); - jsize len = (*env)->GetArrayLength( env, arr ); - if ( len < count ) { - count = len; + { + jsize len = (*env)->GetArrayLength( env, arr ); + if ( len < count ) { + count = len; + } } - + jint* ints = (*env)->GetIntArrayElements(env, arr, 0); for ( int ii = 0; ii < count; ++ii ) { dest[ii] = ints[ii]; } diff --git a/xwords4/android/jni/xwjni.c b/xwords4/android/jni/xwjni.c index 0473f5e54..368f2d208 100644 --- a/xwords4/android/jni/xwjni.c +++ b/xwords4/android/jni/xwjni.c @@ -2343,7 +2343,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize setInt( env, jsummary, "turn", summary.turn ); setBool( env, jsummary, "turnIsLocal", summary.turnIsLocal ); setBool( env, jsummary, "canRematch", summary.canRematch ); - setBool( env, jsummary, "canOfferRO", summary.canOfferRO ); setInt( env, jsummary, "lastMoveTime", summary.lastMoveTime ); setInt( env, jsummary, "dupTimerExpires", summary.dupTimerExpires ); diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index 308f091e4..92a996de7 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -2843,10 +2843,10 @@ validateInitialMessage( CommsCtxt* comms, XP_Bool XP_UNUSED_HEARTBEAT(hasPayload const CommsAddrRec* retAddr, XWHostID senderID, XP_PlayerAddr* channelNoP, XP_U16 flags, MsgID msgID ) { - AddressRecord* rec = NULL; CNO_FMT( cbuf, *channelNoP ); COMMS_LOGFF( TAGFMT() "looking at %s", TAGPRMS, cbuf ); - rec = getRecordFor( comms, *channelNoP ); + + AddressRecord* rec = getRecordFor( comms, *channelNoP ); if ( !!rec ) { augmentChannelAddr( comms, rec, retAddr, senderID ); @@ -3700,7 +3700,7 @@ augmentAddrIntrnl( CommsCtxt* comms, CommsAddrRec* destAddr, if ( !isNewer && !newType && 0 != XP_MEMCMP( &empty, dest, siz ) ) { XP_LOGFF( "%s: not replacing new info with old", - ConnType2Str(typ) ); + ConnType2Str(typ) ); } else { XP_MEMCPY( dest, src, siz ); changed = XP_TRUE; diff --git a/xwords4/common/game.c b/xwords4/common/game.c index 669f41945..2b421494c 100644 --- a/xwords4/common/game.c +++ b/xwords4/common/game.c @@ -213,8 +213,7 @@ game_makeNewGame( MPFORMAL XWEnv xwe, XWGame* game, CurGameInfo* gi, game->server = server_make( MPPARM(mpool) xwe, game->model, - game->comms, - util ); + game->comms, util ); game->board = board_make( MPPARM(mpool) xwe, game->model, game->server, NULL, util ); board_setCallbacks( game->board, xwe ); diff --git a/xwords4/common/scorebdp.c b/xwords4/common/scorebdp.c index 1059b02f8..b73ea6acb 100644 --- a/xwords4/common/scorebdp.c +++ b/xwords4/common/scorebdp.c @@ -183,7 +183,6 @@ drawScoreBoard( BoardCtxt* board, XWEnv xwe ) XP_U16 remWidth, remHeight, remDim; DrawScoreData* dp; DrawScoreData datum[MAX_NUM_PLAYERS]; - ScoresArray scores; XP_Bool isVertical = !board->scoreSplitHor; XP_Bool remFocussed = XP_FALSE; XP_Bool focusAll = XP_FALSE; @@ -200,6 +199,7 @@ drawScoreBoard( BoardCtxt* board, XWEnv xwe ) #endif /* Get the scores from the model or by calculating them based on the end-of-game state. */ + ScoresArray scores; model_getCurScores( model, &scores, board->gameOver ); if ( draw_scoreBegin( board->draw, xwe, &board->scoreBdBounds, diff --git a/xwords4/common/server.c b/xwords4/common/server.c index eb62c9117..9bedd019a 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -385,8 +385,7 @@ initServer( ServerCtxt* server, XWEnv xwe ) SRVR_LOGFF(" "); setTurn( server, xwe, -1 ); /* game isn't under way yet */ - if ( 0 ) { - } else if ( server->vol.gi->serverRole == SERVER_ISCLIENT ) { + if ( server->vol.gi->serverRole == SERVER_ISCLIENT ) { SETSTATE( server, XWSTATE_NONE ); } else { SETSTATE( server, XWSTATE_BEGIN ); @@ -2197,7 +2196,6 @@ client_readInitialMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) } // XP_ASSERT( streamVersion <= CUR_STREAM_VERS ); /* else do what? */ - /* Get rid of this!!!! It's in the damned gi that's read next */ gameID = streamVersion < STREAM_VERS_REMATCHORDER ? stream_getU32( stream ) : 0; CurGameInfo localGI = {0}; @@ -2208,10 +2206,10 @@ client_readInitialMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) /* never seems to replace anything -- gi is already correct on guests apparently. How? Will have come in with invitation, of course. */ - SRVR_LOGFF( "read gameID of %X/%d; calling comms_setConnID (replacing %X)", - gameID, gameID, server->vol.gi->gameID ); - XP_ASSERT( server->vol.gi->gameID == gameID ); - server->vol.gi->gameID = gameID; + SRVR_LOGFF( "read gameID of %08X; calling comms_setConnID (replacing %08X)", + gameID, gi->gameID ); + XP_ASSERT( gi->gameID == gameID ); + gi->gameID = gameID; comms_setConnID( comms, gameID, streamVersion ); XP_ASSERT( !localGI.dictName ); @@ -3997,8 +3995,7 @@ finishMove( ServerCtxt* server, XWEnv xwe, TrayTileSet* newTiles, XP_U16 turn ) freeBWI( MPPARM(server->mpool) &server->illegalWordInfo ); } - if ( 0 ) { - } else if (isClient && (gi->phoniesAction == PHONIES_DISALLOW) + if (isClient && (gi->phoniesAction == PHONIES_DISALLOW) && nTilesMoved > 0 ) { SETSTATE( server, XWSTATE_MOVE_CONFIRM_WAIT ); setTurn( server, xwe, -1 );