diff --git a/xwords4/android/jni/xwjni.c b/xwords4/android/jni/xwjni.c index 7b4db95bc..1d12e9509 100644 --- a/xwords4/android/jni/xwjni.c +++ b/xwords4/android/jni/xwjni.c @@ -2245,29 +2245,22 @@ JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize ( JNIEnv* env, jclass C, GamePtrType gamePtr, jobject jsummary ) { - XWJNI_START(); - ModelCtxt* model = state->game.model; - ServerCtxt* server = state->game.server; - XP_S16 nMoves = model_getNMoves( model ); - setInt( env, jsummary, "nMoves", nMoves ); - XP_Bool gameOver = server_getGameIsOver( server ); - setBool( env, jsummary, "gameOver", gameOver ); - XP_Bool isLocal = XP_FALSE; - setInt( env, jsummary, "turn", - server_getCurrentTurn( server, &isLocal ) ); - setBool( env, jsummary, "turnIsLocal", isLocal ); - setInt( env, jsummary, "lastMoveTime", - server_getLastMoveTime(server) ); - setInt( env, jsummary, "dupTimerExpires", - server_getDupTimerExpires(server) ); + XWJNI_START_GLOBALS(); + GameSummary summary = {0}; + game_summarize( &state->game, globals->gi, &summary ); + + setInt( env, jsummary, "nMoves", summary.nMoves ); + setBool( env, jsummary, "gameOver", summary.gameOver ); + setInt( env, jsummary, "turn", summary.turn ); + setBool( env, jsummary, "turnIsLocal", summary.turnIsLocal ); + setInt( env, jsummary, "lastMoveTime", summary.lastMoveTime ); + setInt( env, jsummary, "dupTimerExpires", summary.dupTimerExpires ); if ( !!state->game.comms ) { CommsCtxt* comms = state->game.comms; setInt( env, jsummary, "seed", comms_getChannelSeed( comms ) ); - setInt( env, jsummary, "missingPlayers", - server_getMissingPlayers( server ) ); - setInt( env, jsummary, "nPacketsPending", - comms_countPendingPackets( state->game.comms ) ); + setInt( env, jsummary, "missingPlayers", summary.missingPlayers ); + setInt( env, jsummary, "nPacketsPending", summary.nPacketsPending ); CommsAddrRec addr; comms_getAddr( comms, &addr ); @@ -2317,9 +2310,10 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize } } + ModelCtxt* model = state->game.model; XP_U16 nPlayers = model_getNPlayers( model ); jint jvals[nPlayers]; - if ( gameOver ) { + if ( summary.gameOver ) { ScoresArray scores; model_figureFinalScores( model, &scores, NULL ); for ( int ii = 0; ii < nPlayers; ++ii ) { diff --git a/xwords4/common/dutil.h b/xwords4/common/dutil.h index a110ab6f1..ebb9e8606 100644 --- a/xwords4/common/dutil.h +++ b/xwords4/common/dutil.h @@ -36,9 +36,6 @@ typedef enum { UNPAUSED, typedef XP_Bool (*OnOneProc)(void* closure, const XP_UCHAR* keys[]); -typedef void (*OnStoreProc)( void* closure, XP_Bool success ); -typedef void (*OnLoadProc)( void* closure, const char* key, void* data, int len ); - #define KEY_WILDCARD "*" typedef struct _DUtilVtable { @@ -163,16 +160,4 @@ void dutil_super_init( MPFORMAL XW_DUtilCtxt* dutil ); #define dutil_onGameGoneReceived(duc, xwe, gameID, from) \ (duc)->vtable.m_dutil_onGameGoneReceived((duc),(xwe),(gameID),(from)) -/* #define dutil_storePtrAt( duc, xwe, data, len, keys ) \ */ -/* (duc)->vtable.m_dutil_storePtrAt((duc), (xwe), (data), (len), (keys)) */ - -/* #define dutil_storeStreamAt( duc, xwe, stream, keys ) \ */ -/* (duc)->vtable.m_dutil_storeStreamAt((duc), (xwe), (stream), (keys)) */ - -/* #define dutil_loadStreamAt( duc, xwe, inOut, keys, ... ) \ */ -/* (duc)->vtable.m_dutil_loadStreamAt((duc), (xwe), (inOut), (keys)) */ - -/* #define dutil_loadPtrAt( duc, xwe, ptr, lenp, keys ) \ */ -/* (duc)->vtable.m_dutil_loadPtrAt( (duc), (xwe), (ptr), (lenp), (keys)) */ - #endif diff --git a/xwords4/common/game.c b/xwords4/common/game.c index 60551a11c..57e60c50a 100644 --- a/xwords4/common/game.c +++ b/xwords4/common/game.c @@ -553,6 +553,8 @@ game_summarize( XWGame* game, CurGameInfo* gi, GameSummary* summary ) summary->lastMoveTime = server_getLastMoveTime(server); summary->lang = gi->dictLang; summary->gameOver = server_getGameIsOver( server ); + summary->nMoves = model_getNMoves( game->model ); + summary->dupTimerExpires = server_getDupTimerExpires( server ); for ( int ii = 0; ii < gi->nPlayers; ++ii ) { LocalPlayer* lp = &gi->players[ii]; @@ -564,9 +566,8 @@ game_summarize( XWGame* game, CurGameInfo* gi, GameSummary* summary ) } } if ( !!game->comms ) { - CommsCtxt* comms = game->comms; summary->missingPlayers = server_getMissingPlayers( server ); - summary->nPacketsPending = comms_countPendingPackets( comms ); + summary->nPacketsPending = comms_countPendingPackets( game->comms ); } } diff --git a/xwords4/common/game.h b/xwords4/common/game.h index f3be6eb1b..92a5afc8a 100644 --- a/xwords4/common/game.h +++ b/xwords4/common/game.h @@ -56,8 +56,10 @@ typedef struct _GameSummary { XP_Bool gameOver; XP_S8 turn; XP_U32 lastMoveTime; + XP_S32 dupTimerExpires; XP_U8 missingPlayers; XP_U8 nPacketsPending; + XP_S16 nMoves; XP_LangCode lang; XP_UCHAR opponents[64]; } GameSummary;