From 4ffaa5dd7326663fe808cf41fed8b17310ebc329 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 1 Jan 2024 15:56:41 -0800 Subject: [PATCH] cleanup -- should be no behavior/code change --- .../org/eehouse/android/xw4/jni/XwJNI.java | 14 -------- xwords4/android/jni/xwjni.c | 11 ------- xwords4/common/board.c | 18 ++++++++--- xwords4/common/board.h | 2 ++ xwords4/common/comms.c | 2 +- xwords4/common/scorebdp.h | 6 ++++ xwords4/linux/cursesboard.c | 32 ++++++++----------- 7 files changed, 36 insertions(+), 49 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java index d109e8366..5adede865 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java @@ -444,20 +444,6 @@ public class XwJNI { // Only if COMMON_LAYOUT defined public static native void board_applyLayout( GamePtr gamePtr, BoardDims dims ); - // public static native void board_setPos( int gamePtr, int left, int top, - // int width, int height, - // int maxCellHt, boolean lefty ); - // public static native void board_setScoreboardLoc( int gamePtr, int left, - // int top, int width, - // int height, - // boolean divideHorizontally ); - // public static native void board_setTrayLoc( int gamePtr, int left, - // int top, int width, - // int height, int minDividerWidth ); - // public static native void board_setTimerLoc( int gamePtr, - // int timerLeft, int timerTop, - // int timerWidth, - // int timerHeight ); public static native boolean board_zoom( GamePtr gamePtr, int zoomBy, boolean[] canZoom ); diff --git a/xwords4/android/jni/xwjni.c b/xwords4/android/jni/xwjni.c index bc86b894c..dc1597b46 100644 --- a/xwords4/android/jni/xwjni.c +++ b/xwords4/android/jni/xwjni.c @@ -1677,17 +1677,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1applyLayout #else -JNIEXPORT void JNICALL -Java_org_eehouse_android_xw4_jni_XwJNI_board_1setPos -(JNIEnv* env, jclass C, GamePtrType gamePtr, jint left, jint top, jint width, - jint height, jint maxCellSize, jboolean lefty ) -{ - XWJNI_START(gamePtr); - board_setPos( state->game.board, left, top, width, height, maxCellSize, - lefty ); - XWJNI_END(); -} - JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_board_1setScoreboardLoc ( JNIEnv* env, jclass C, GamePtrType gamePtr, jint left, jint top, diff --git a/xwords4/common/board.c b/xwords4/common/board.c index 91df56577..a408d0282 100644 --- a/xwords4/common/board.c +++ b/xwords4/common/board.c @@ -132,6 +132,14 @@ static XP_Bool moveKeyTileToBoard( BoardCtxt* board, XWEnv xwe, static XP_S16 keyToIndex( BoardCtxt* board, XP_Key key, Tile* blankFace ); #endif +#ifdef COMMON_LAYOUT +static void board_setPos( BoardCtxt* board, XWEnv xwe, XP_U16 left, XP_U16 top, + XP_U16 width, XP_U16 height, XP_U16 maxCellSize, + XP_Bool leftHanded ); +static void board_setTrayLoc( BoardCtxt* board, XWEnv xwe, XP_U16 trayLeft, XP_U16 trayTop, + XP_U16 trayWidth, XP_U16 trayHeight, XP_U16 nTiles ); +#endif + #ifdef KEYBOARD_NAV static XP_Bool board_moveCursor( BoardCtxt* board, XWEnv xwe, XP_Key cursorKey, XP_Bool preflightOnly, XP_Bool* up ); @@ -606,7 +614,7 @@ board_figureLayout( BoardCtxt* board, XWEnv xwe, const CurGameInfo* gi, printDims( &ldims ); if ( !!dimsp ) { - XP_MEMCPY( dimsp, &ldims, sizeof(ldims) ); + *dimsp = ldims; } else { board_applyLayout( board, xwe, &ldims ); } @@ -643,7 +651,7 @@ board_setCallbacks( BoardCtxt* board, XWEnv xwe ) setTimerIf( board, xwe ); } -void +static void board_setPos( BoardCtxt* board, XWEnv xwe, XP_U16 left, XP_U16 top, XP_U16 width, XP_U16 height, XP_U16 maxCellSz, XP_Bool leftHanded ) @@ -1688,7 +1696,7 @@ onBorderCanScroll( const BoardCtxt* board, SDIndex indx, return result; } -void +static void board_setTrayLoc( BoardCtxt* board, XWEnv xwe, XP_U16 trayLeft, XP_U16 trayTop, XP_U16 trayWidth, XP_U16 trayHeight, XP_U16 nTiles ) { @@ -1956,9 +1964,9 @@ setTrayVisState( BoardCtxt* board, XWEnv xwe, XW_TrayVisState newState ) invalSelTradeWindow( board ); (void)invalFocusOwner( board, xwe ); /* must be done before and after rect - recalculated */ + recalculated */ figureBoardRect( board, xwe ); /* comes before setYOffset since that - uses rects to calc scroll */ + uses rects to calc scroll */ (void)invalFocusOwner( board, xwe ); if ( board->boardObscuresTray ) { diff --git a/xwords4/common/board.h b/xwords4/common/board.h index 439332b9e..9b26c5229 100644 --- a/xwords4/common/board.h +++ b/xwords4/common/board.h @@ -108,6 +108,7 @@ void board_applyLayout( BoardCtxt* board, XWEnv xwe, const BoardDims* dims ); #endif /* These four aren't needed if COMMON_LAYOUT defined */ +#ifndef COMMON_LAYOUT void board_setPos( BoardCtxt* board, XWEnv xwe, XP_U16 left, XP_U16 top, XP_U16 width, XP_U16 height, XP_U16 maxCellSize, XP_Bool leftHanded ); @@ -118,6 +119,7 @@ void board_setScoreboardLoc( BoardCtxt* board, void board_setTrayLoc( BoardCtxt* board, XWEnv xwe, XP_U16 trayLeft, XP_U16 trayTop, XP_U16 trayWidth, XP_U16 trayHeight, XP_U16 nTiles ); +#endif /* Vertical scroll support; offset is in rows, not pixels */ XP_Bool board_setYOffset( BoardCtxt* board, XWEnv xwe, XP_U16 newOffset ); diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index cbb842fcb..ea5ec7eb5 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -929,7 +929,7 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, COMMS_LOGFF( "added missing timestamp" ); } #ifdef DEBUG - msg->sendCount = 0; + XP_ASSERT( 0 == msg->sendCount ); #endif XP_U16 len = msg->smp.len; if ( 0 == len ) { diff --git a/xwords4/common/scorebdp.h b/xwords4/common/scorebdp.h index f1c3fe2f6..b4e1a4756 100644 --- a/xwords4/common/scorebdp.h +++ b/xwords4/common/scorebdp.h @@ -32,6 +32,12 @@ XP_Bool handlePenUpScore( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy, XP_Bool altDown ); #endif +#ifdef COMMON_LAYOUT +void board_setScoreboardLoc( BoardCtxt* board, + XP_U16 scoreLeft, XP_U16 scoreTop, + XP_U16 scoreWidth, XP_U16 scoreHeight, + XP_Bool divideHorizontally ); +#endif #ifdef KEYBOARD_NAV XP_Bool moveScoreCursor( BoardCtxt* board, XP_Key key, XP_Bool preflightOnly, diff --git a/xwords4/linux/cursesboard.c b/xwords4/linux/cursesboard.c index 59b0ab8bb..7193f57f6 100644 --- a/xwords4/linux/cursesboard.c +++ b/xwords4/linux/cursesboard.c @@ -360,7 +360,7 @@ curses_socket_acceptor( int listener, Acceptor func, CommonGlobals* cGlobals, void** XP_UNUSED(storage) ) { if ( -1 == listener ) { - XP_LOGF( "%s: removal of listener not implemented!!!!!", __func__ ); + XP_LOGFF( "removal of listener not implemented!!!!!" ); } else { CursesBoardGlobals* globals = (CursesBoardGlobals*)cGlobals; XP_ASSERT( !cGlobals->acceptor || (func == cGlobals->acceptor) ); @@ -399,7 +399,7 @@ commonInit( CursesBoardState* cbState, sqlite3_int64 rowid, const CurGameInfo* gip ) { CursesBoardGlobals* bGlobals = g_malloc0( sizeof(*bGlobals) ); - XP_LOGF( "%s(): alloc'd bGlobals %p", __func__, bGlobals ); + XP_LOGFF( "alloc'd bGlobals %p", bGlobals ); CommonGlobals* cGlobals = &bGlobals->cGlobals; LaunchParams* params = cbState->params; @@ -438,7 +438,7 @@ disposeDraw( CursesBoardGlobals* bGlobals ) static void disposeBoard( CursesBoardGlobals* bGlobals ) { - XP_LOGF( "%s(): passed bGlobals %p", __func__, bGlobals ); + XP_LOGFF( "passed bGlobals %p", bGlobals ); /* XP_ASSERT( 0 == bGlobals->refCount ); */ CommonGlobals* cGlobals = &bGlobals->cGlobals; @@ -466,7 +466,7 @@ static CursesBoardGlobals* ref( CursesBoardGlobals* bGlobals ) { ++bGlobals->refCount; - XP_LOGF( "%s(): refCount now %d", __func__, bGlobals->refCount ); + XP_LOGFF( "refCount now %d", bGlobals->refCount ); return bGlobals; } @@ -474,7 +474,7 @@ static void unref( CursesBoardGlobals* bGlobals ) { --bGlobals->refCount; - XP_LOGF( "%s(): refCount now %d", __func__, bGlobals->refCount ); + XP_LOGFF( "refCount now %d", bGlobals->refCount ); if ( 0 == bGlobals->refCount ) { disposeBoard( bGlobals ); } @@ -537,7 +537,7 @@ setupBoard( CursesBoardGlobals* bGlobals ) fontWidth, fontHt, XP_FALSE, &dims ); board_applyLayout( board, NULL_XWE, &dims ); - XP_LOGF( "%s(): calling board_draw()", __func__ ); + XP_LOGFF( "calling board_draw()" ); board_invalAll( board ); board_draw( board, NULL_XWE ); } @@ -766,7 +766,7 @@ cursesUserError( CursesBoardGlobals* bGlobals, const char* format, ... ) if ( !!bGlobals->boardWin ) { (void)ca_inform( bGlobals->boardWin, buf ); } else { - XP_LOGF( "%s(msg=%s)", __func__, buf ); + XP_LOGFF( "(msg=%s)", buf ); } } /* cursesUserError */ @@ -819,7 +819,7 @@ curses_util_userError( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), UtilErrID id ) const XP_UCHAR* message = linux_getErrString( id, &silent ); if ( silent ) { - XP_LOGF( "silent userError: %s", message ); + XP_LOGFF( "silent userError: %s", message ); } else { cursesUserError( globals, message ); } @@ -1084,7 +1084,7 @@ curses_util_informNetDict( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), { XP_USE(uc); XP_USE(phoniesAction); - XP_LOGF( "%s: %s => %s (cksum: %s)", __func__, oldName, newName, newSum ); + XP_LOGFF( "%s => %s (cksum: %s)", oldName, newName, newSum ); } #ifdef XWFEATURE_SEARCHLIMIT @@ -1158,8 +1158,7 @@ curses_util_timerSelected( XW_UtilCtxt* XP_UNUSED(uc), XWEnv XP_UNUSED(xwe), XP_Bool XP_UNUSED_DBG(inDuplicateMode), XP_Bool XP_UNUSED_DBG(canPause) ) { - XP_LOGF( "%s(inDuplicateMode=%d, canPause=%d)", __func__, inDuplicateMode, - canPause ); + XP_LOGFF( "(inDuplicateMode=%d, canPause=%d)", inDuplicateMode, canPause ); } static void @@ -1218,7 +1217,7 @@ curses_util_showChat( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), CommonGlobals* cGlobals = &globals->cGlobals; name = cGlobals->gi->players[from].name; } - XP_LOGF( "%s: got \"%s\" from %s", __func__, msg, name ); + XP_LOGFF( "got \"%s\" from %s", msg, name ); # endif } #endif @@ -1673,17 +1672,14 @@ relay_connd_curses( XWEnv XP_UNUSED(xwe), void* XP_UNUSED(closure), XP_UCHAR* co XP_Bool XP_UNUSED_DBG(allHere), XP_U16 XP_UNUSED_DBG(nMissing) ) { - XP_LOGF( "%s got allHere: %s; nMissing: %d", __func__, - allHere?"true":"false", nMissing ); + XP_LOGFF( "got allHere: %s; nMissing: %d", allHere?"true":"false", nMissing ); } static void relay_error_curses( XWEnv XP_UNUSED(xwe), void* XP_UNUSED(closure), XWREASON XP_UNUSED_DBG(relayErr) ) { -#ifdef DEBUG - XP_LOGF( "%s(%s)", __func__, XWREASON2Str( relayErr ) ); -#endif + XP_LOGFF( "(%s)", XWREASON2Str( relayErr ) ); } static XP_Bool @@ -1741,6 +1737,6 @@ relay_status_curses( XWEnv XP_UNUSED(xwe), void* XP_UNUSED(closure), { /* CommonGlobals* cGlobals = (CommonGlobals*)closure; */ // bGlobals->commsRelayState = state; - XP_LOGF( "%s got status: %s", __func__, CommsRelayState2Str(state) ); + XP_LOGFF( "got status: %s", CommsRelayState2Str(state) ); } #endif