add server_reset and util_setIsServer to jni

This commit is contained in:
Andy2 2010-09-24 18:45:42 -07:00
parent f7bad05390
commit 4ea9ff8226
4 changed files with 22 additions and 1 deletions

View file

@ -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);

View file

@ -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)

View file

@ -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;

View file

@ -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 );