From 4ea9ff8226c972f98304f2730677c5b67872fa85 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Fri, 24 Sep 2010 18:45:42 -0700 Subject: [PATCH] add server_reset and util_setIsServer to jni --- xwords4/android/XWords4/jni/utilwrapper.c | 10 ++++++++++ xwords4/android/XWords4/jni/xwjni.c | 9 +++++++++ .../src/org/eehouse/android/xw4/jni/UtilCtxt.java | 3 ++- .../XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/xwords4/android/XWords4/jni/utilwrapper.c b/xwords4/android/XWords4/jni/utilwrapper.c index 794a1ddcd..791de092a 100644 --- a/xwords4/android/XWords4/jni/utilwrapper.c +++ b/xwords4/android/XWords4/jni/utilwrapper.c @@ -355,6 +355,15 @@ and_util_remSelected(XW_UtilCtxt* uc) UTIL_CBK_TAIL(); } +static void +and_util_setIsServer(XW_UtilCtxt* uc, XP_Bool isServer ) +{ + /* Change both the C and Java structs, which need to stay in sync */ + uc->gameInfo->serverRole = isServer? SERVER_ISSERVER : SERVER_ISCLIENT; + UTIL_CBK_HEADER("setIsServer", "(Z)V" ); + (*env)->CallVoidMethod( env, util->jutil, mid, isServer ); + UTIL_CBK_TAIL(); +} #ifndef XWFEATURE_STANDALONE_ONLY static void @@ -437,6 +446,7 @@ makeUtil( MPFORMAL JNIEnv** envp, jobject jutil, CurGameInfo* gi, SET_PROC(getUserString); SET_PROC(warnIllegalWord); SET_PROC(remSelected); + SET_PROC(setIsServer); #ifndef XWFEATURE_STANDALONE_ONLY SET_PROC(addrChange); diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 5d10df213..be9db722e 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -731,6 +731,15 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1redoReplacedTiles return result; } +JNIEXPORT void JNICALL +Java_org_eehouse_android_xw4_jni_XwJNI_server_1reset +(JNIEnv* env, jclass C, jint gamePtr ) +{ + XWJNI_START(); + server_reset( state->game.server, state->game.comms ); + XWJNI_END(); +} + JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_server_1handleUndo (JNIEnv* env, jclass C, jint gamePtr) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxt.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxt.java index 339422c39..bc6a11b86 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxt.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxt.java @@ -45,9 +45,10 @@ public interface UtilCtxt { public static final int TIMER_SLOWROBOT = 4; void setTimer( int why, int when, int handle ); void clearTimer( int why ); + void requestTime(); void remSelected(); - + void setIsServer( boolean isServer ); static final int STRD_ROBOT_TRADED = 1; static final int STR_ROBOT_MOVED = 2; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java index 4bcda57ac..c28004762 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java @@ -182,6 +182,7 @@ public class XwJNI { public static native int model_getNMoves( int gamePtr ); // Server + public static native void server_reset( int gamePtr ); public static native void server_handleUndo( int gamePtr ); public static native boolean server_do( int gamePtr ); public static native String server_formatDictCounts( int gamePtr, int nCols );