mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
add fromRematch to existing api to avoid race condition
This commit is contained in:
parent
b5de43e3dc
commit
52a1de0463
9 changed files with 24 additions and 28 deletions
|
@ -177,6 +177,7 @@ public class BoardDelegate extends DelegateBase
|
|||
int nGuestDevs;
|
||||
CommsAddrRec hostAddr;
|
||||
boolean inTrade;
|
||||
boolean fromRematch;
|
||||
StartAlertOrder mAlertOrder = StartAlertOrder.values()[0];
|
||||
}
|
||||
private MySIS m_mySIS;
|
||||
|
@ -2049,7 +2050,7 @@ public class BoardDelegate extends DelegateBase
|
|||
@Override
|
||||
public void informMissing( boolean isServer, CommsAddrRec hostAddr,
|
||||
CommsConnTypeSet connTypes, int nDevs,
|
||||
int nMissing, int nInvited )
|
||||
int nMissing, int nInvited, boolean fromRematch )
|
||||
{
|
||||
// Log.d( TAG, "informMissing(isServer: %b, nDevs: %d; nMissing: %d, "
|
||||
// + " nInvited: %d", isServer, nDevs, nMissing, nInvited );
|
||||
|
@ -2057,6 +2058,7 @@ public class BoardDelegate extends DelegateBase
|
|||
m_mySIS.nMissing = nMissing; // will be 0 unless isServer is true
|
||||
m_mySIS.nInvited = nInvited;
|
||||
m_mySIS.nGuestDevs = nDevs;
|
||||
m_mySIS.fromRematch = fromRematch;
|
||||
m_mySIS.hostAddr = hostAddr;
|
||||
m_connTypes = connTypes;
|
||||
|
||||
|
@ -2583,10 +2585,8 @@ public class BoardDelegate extends DelegateBase
|
|||
|
||||
private void showOrHide( InvitesNeededAlert.Wrapper wrapper )
|
||||
{
|
||||
boolean fromRematch = null != m_jniGamePtr
|
||||
&& XwJNI.server_isFromRematch( m_jniGamePtr );
|
||||
wrapper.showOrHide( m_mySIS.hostAddr, m_mySIS.nMissing,
|
||||
m_mySIS.nInvited, fromRematch );
|
||||
m_mySIS.nInvited, m_mySIS.fromRematch );
|
||||
}
|
||||
|
||||
private InvitesNeededAlert.Wrapper mINAWrapper;
|
||||
|
|
|
@ -110,7 +110,7 @@ public interface UtilCtxt {
|
|||
|
||||
void informMissing( boolean isServer, CommsAddrRec hostAddr,
|
||||
CommsConnTypeSet connTypes, int nDevs,
|
||||
int nMissingPlayers, int nInvited );
|
||||
int nMissingPlayers, int nInvited, boolean fromRematch );
|
||||
|
||||
void notifyGameOver();
|
||||
// Don't need this unless we have a scroll thumb to indicate position
|
||||
|
|
|
@ -228,7 +228,8 @@ public class UtilCtxtImpl implements UtilCtxt {
|
|||
@Override
|
||||
public void informMissing( boolean isServer, CommsAddrRec hostAddr,
|
||||
CommsConnTypeSet connTypes, int nDevices,
|
||||
int nMissingPlayers, int nInvited )
|
||||
int nMissingPlayers, int nInvited,
|
||||
boolean fromRematch )
|
||||
{
|
||||
subclassOverride( "informMissing" );
|
||||
}
|
||||
|
|
|
@ -551,7 +551,6 @@ public class XwJNI {
|
|||
public static native String server_writeFinalScores( GamePtr gamePtr );
|
||||
public static native boolean server_initClientConnection( GamePtr gamePtr );
|
||||
public static native boolean server_canOfferRematch( GamePtr gamePtr );
|
||||
public static native boolean server_isFromRematch( GamePtr gamePtr );
|
||||
public static native void server_endGame( GamePtr gamePtr );
|
||||
|
||||
// hybrid to save work
|
||||
|
|
|
@ -694,11 +694,11 @@ static void
|
|||
and_util_informMissing( XW_UtilCtxt* uc, XWEnv xwe, XP_Bool isServer,
|
||||
const CommsAddrRec* hostAddr,
|
||||
const CommsAddrRec* selfAddr, XP_U16 nDevs,
|
||||
XP_U16 nMissing, XP_U16 nInvited )
|
||||
XP_U16 nMissing, XP_U16 nInvited, XP_Bool fromRematch )
|
||||
{
|
||||
UTIL_CBK_HEADER( "informMissing",
|
||||
"(ZL" PKG_PATH("jni/CommsAddrRec") ";"
|
||||
"L" PKG_PATH("jni/CommsAddrRec$CommsConnTypeSet") ";III)V" );
|
||||
"L" PKG_PATH("jni/CommsAddrRec$CommsConnTypeSet") ";IIIZ)V" );
|
||||
jobject jHostAddr = NULL;
|
||||
if ( !!hostAddr ) {
|
||||
jHostAddr = makeJAddr( env, hostAddr );
|
||||
|
@ -709,7 +709,7 @@ and_util_informMissing( XW_UtilCtxt* uc, XWEnv xwe, XP_Bool isServer,
|
|||
jtypset = addrTypesToJ( env, selfAddr );
|
||||
}
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid, isServer, jHostAddr,
|
||||
jtypset, nDevs, nMissing, nInvited );
|
||||
jtypset, nDevs, nMissing, nInvited, fromRematch );
|
||||
deleteLocalRefs( env, jHostAddr, jtypset, DELETE_NO_REF );
|
||||
UTIL_CBK_TAIL();
|
||||
}
|
||||
|
|
|
@ -2202,17 +2202,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1initClientConnection
|
|||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_server_1isFromRematch
|
||||
( JNIEnv* env, jclass C, GamePtrType gamePtr )
|
||||
{
|
||||
jboolean result;
|
||||
XWJNI_START_GLOBALS(gamePtr);
|
||||
result = server_isFromRematch( state->game.server );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_server_1canOfferRematch
|
||||
( JNIEnv* env, jclass C, GamePtrType gamePtr )
|
||||
|
|
|
@ -571,6 +571,7 @@ informMissing( const ServerCtxt* server, XWEnv xwe )
|
|||
|
||||
XP_U16 nDevs = 0;
|
||||
XP_U16 nPending = 0;
|
||||
XP_Bool fromRematch = XP_FALSE;
|
||||
if ( XWSTATE_BEGIN < server->nv.gameState ) {
|
||||
/* do nothing */
|
||||
} else if ( isHost ) {
|
||||
|
@ -582,11 +583,13 @@ informMissing( const ServerCtxt* server, XWEnv xwe )
|
|||
nInvited = nPending;
|
||||
}
|
||||
}
|
||||
fromRematch = server_isFromRematch( server );
|
||||
} else if ( SERVER_ISCLIENT == gi->serverRole ) {
|
||||
nPending = gi->nPlayers - gi_countLocalPlayers( gi, XP_FALSE);
|
||||
}
|
||||
util_informMissing( server->vol.util, xwe, isHost,
|
||||
hostAddrP, selfAddrP, nDevs, nPending, nInvited );
|
||||
hostAddrP, selfAddrP, nDevs, nPending, nInvited,
|
||||
fromRematch );
|
||||
}
|
||||
|
||||
XP_U16
|
||||
|
|
|
@ -170,7 +170,8 @@ typedef struct UtilVtable {
|
|||
void (*m_util_informMissing)( XW_UtilCtxt* uc, XWEnv xwe, XP_Bool isHost,
|
||||
const CommsAddrRec* hostAddr,
|
||||
const CommsAddrRec* selfAddr, XP_U16 nDevs,
|
||||
XP_U16 nMissing, XP_U16 nInvited );
|
||||
XP_U16 nMissing, XP_U16 nInvited,
|
||||
XP_Bool fromRematch );
|
||||
|
||||
void (*m_util_informWordsBlocked)( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 nBadWords,
|
||||
XWStreamCtxt* words, const XP_UCHAR* dictName );
|
||||
|
@ -305,8 +306,9 @@ struct XW_UtilCtxt {
|
|||
(uc)->vtable->m_util_cellSquareHeld( (uc), (e), (s) )
|
||||
#endif
|
||||
|
||||
#define util_informMissing( uc, e, is, ha, sa, nd, nm, ni ) \
|
||||
(uc)->vtable->m_util_informMissing((uc), (e), (is), (ha), (sa), (nd), (nm), (ni) )
|
||||
#define util_informMissing( uc, e, is, ha, sa, nd, nm, ni, fr ) \
|
||||
(uc)->vtable->m_util_informMissing((uc), (e), (is), (ha), (sa), \
|
||||
(nd), (nm), (ni), (fr) )
|
||||
|
||||
#define util_informWordsBlocked(uc,e, c, w, d) \
|
||||
(uc)->vtable->m_util_informWordsBlocked( (uc), (e), (c), (w), (d) )
|
||||
|
|
|
@ -1694,10 +1694,12 @@ linux_util_informMissing( XW_UtilCtxt* XP_UNUSED(uc), XWEnv XP_UNUSED(xwe),
|
|||
const CommsAddrRec* XP_UNUSED_DBG(selfAddr),
|
||||
XP_U16 XP_UNUSED_DBG(nDevs),
|
||||
XP_U16 XP_UNUSED_DBG(nMissing),
|
||||
XP_U16 XP_UNUSED_DBG(nInvited) )
|
||||
XP_U16 XP_UNUSED_DBG(nInvited),
|
||||
XP_Bool XP_UNUSED_DBG(fromRematch) )
|
||||
{
|
||||
XP_LOGFF( "(isServer=%d, addr=%p, nDevs=%d, nMissing=%d, nInvited=%d)",
|
||||
isServer, selfAddr, nDevs, nMissing, nInvited );
|
||||
XP_LOGFF( "(isServer=%d, addr=%p, nDevs=%d, nMissing=%d, "
|
||||
"nInvited=%d, fromRematch=%s)", isServer, selfAddr,
|
||||
nDevs, nMissing, nInvited, boolToStr(fromRematch) );
|
||||
}
|
||||
|
||||
unsigned int
|
||||
|
|
Loading…
Add table
Reference in a new issue