mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
stop using thread->env mapping for util callbacks
This commit is contained in:
parent
eb9ef738e4
commit
88335d38f2
41 changed files with 1340 additions and 1289 deletions
|
@ -33,7 +33,6 @@
|
|||
|
||||
typedef struct _AndDUtil {
|
||||
XW_DUtilCtxt dutil;
|
||||
EnvThreadInfo* ti;
|
||||
JNIUtilCtxt* jniutil;
|
||||
jobject jdutil; /* global ref to object implementing XW_DUtilCtxt */
|
||||
XP_UCHAR* userStrings[N_AND_USER_STRINGS];
|
||||
|
@ -50,14 +49,14 @@ typedef struct _TimerStorage {
|
|||
|
||||
typedef struct _AndUtil {
|
||||
XW_UtilCtxt util;
|
||||
EnvThreadInfo* ti;
|
||||
jobject jutil; /* global ref to object implementing XW_UtilCtxt */
|
||||
TimerStorage timerStorage[NUM_TIMERS_PLUS_ONE];
|
||||
} AndUtil;
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
static XWStreamCtxt*
|
||||
and_util_makeStreamFromAddr( XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
|
||||
and_util_makeStreamFromAddr( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XP_PlayerAddr channelNo )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
AndUtil* util = (AndUtil*)uc;
|
||||
|
@ -73,7 +72,7 @@ and_util_makeStreamFromAddr( XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
|
|||
|
||||
#define UTIL_CBK_HEADER(nam,sig) \
|
||||
AndUtil* util = (AndUtil*)uc; \
|
||||
JNIEnv* env = ENVFORME( util->ti ); \
|
||||
JNIEnv* env = xwe; \
|
||||
if ( NULL != util->jutil ) { \
|
||||
jmethodID mid = getMethodID( env, util->jutil, nam, sig )
|
||||
|
||||
|
@ -85,13 +84,14 @@ and_util_makeStreamFromAddr( XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
|
|||
|
||||
#define DUTIL_CBK_HEADER(nam,sig) \
|
||||
AndDUtil* dutil = (AndDUtil*)duc; \
|
||||
JNIEnv* env = ENVFORME( dutil->ti ); \
|
||||
JNIEnv* env = xwe; \
|
||||
if ( NULL != dutil->jdutil ) { \
|
||||
jmethodID mid = getMethodID( env, dutil->jdutil, nam, sig )
|
||||
|
||||
#define DUTIL_CBK_TAIL() UTIL_CBK_TAIL()
|
||||
|
||||
static XWBonusType and_util_getSquareBonus( XW_UtilCtxt* XP_UNUSED(uc),
|
||||
static XWBonusType and_util_getSquareBonus( XW_UtilCtxt* XP_UNUSED(uc),
|
||||
XWEnv XP_UNUSED(xwe),
|
||||
XP_U16 boardSize,
|
||||
XP_U16 col, XP_U16 row )
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ static XWBonusType and_util_getSquareBonus( XW_UtilCtxt* XP_UNUSED(uc),
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_userError( XW_UtilCtxt* uc, UtilErrID id )
|
||||
and_util_userError( XW_UtilCtxt* uc, XWEnv xwe, UtilErrID id )
|
||||
{
|
||||
UTIL_CBK_HEADER( "userError", "(I)V" );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid, id );
|
||||
|
@ -132,7 +132,7 @@ and_util_userError( XW_UtilCtxt* uc, UtilErrID id )
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_notifyMove( XW_UtilCtxt* uc, XWStreamCtxt* stream )
|
||||
and_util_notifyMove( XW_UtilCtxt* uc, XWEnv xwe, XWStreamCtxt* stream )
|
||||
{
|
||||
UTIL_CBK_HEADER("notifyMove", "(Ljava/lang/String;)V" );
|
||||
|
||||
|
@ -146,7 +146,7 @@ and_util_notifyMove( XW_UtilCtxt* uc, XWStreamCtxt* stream )
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_notifyTrade( XW_UtilCtxt* uc, const XP_UCHAR** tiles, XP_U16 nTiles )
|
||||
and_util_notifyTrade( XW_UtilCtxt* uc, XWEnv xwe, const XP_UCHAR** tiles, XP_U16 nTiles )
|
||||
{
|
||||
UTIL_CBK_HEADER("notifyTrade", "([Ljava/lang/String;)V" );
|
||||
jobjectArray jtiles = makeStringArray( env, nTiles, tiles );
|
||||
|
@ -156,7 +156,7 @@ and_util_notifyTrade( XW_UtilCtxt* uc, const XP_UCHAR** tiles, XP_U16 nTiles )
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_notifyPickTileBlank( XW_UtilCtxt* uc, XP_U16 playerNum,
|
||||
and_util_notifyPickTileBlank( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 playerNum,
|
||||
XP_U16 col, XP_U16 row,
|
||||
const XP_UCHAR** tileFaces, XP_U16 nTiles )
|
||||
{
|
||||
|
@ -171,7 +171,7 @@ and_util_notifyPickTileBlank( XW_UtilCtxt* uc, XP_U16 playerNum,
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_informNeedPickTiles( XW_UtilCtxt* uc, XP_Bool isInitial,
|
||||
and_util_informNeedPickTiles( XW_UtilCtxt* uc, XWEnv xwe, XP_Bool isInitial,
|
||||
XP_U16 player, XP_U16 nToPick,
|
||||
XP_U16 nFaces, const XP_UCHAR** faces,
|
||||
const XP_U16* counts )
|
||||
|
@ -189,7 +189,7 @@ and_util_informNeedPickTiles( XW_UtilCtxt* uc, XP_Bool isInitial,
|
|||
} /* and_util_informNeedPickTiles */
|
||||
|
||||
static void
|
||||
and_util_informNeedPassword( XW_UtilCtxt* uc, XP_U16 player,
|
||||
and_util_informNeedPassword( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 player,
|
||||
const XP_UCHAR* name )
|
||||
{
|
||||
UTIL_CBK_HEADER("informNeedPassword", "(ILjava/lang/String;)V" );
|
||||
|
@ -201,13 +201,14 @@ and_util_informNeedPassword( XW_UtilCtxt* uc, XP_U16 player,
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_trayHiddenChange(XW_UtilCtxt* uc, XW_TrayVisState newState,
|
||||
and_util_trayHiddenChange(XW_UtilCtxt* uc, XWEnv xwe,
|
||||
XW_TrayVisState newState,
|
||||
XP_U16 nVisibleRows )
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
and_util_yOffsetChange(XW_UtilCtxt* uc, XP_U16 maxOffset,
|
||||
and_util_yOffsetChange(XW_UtilCtxt* uc, XWEnv xwe, XP_U16 maxOffset,
|
||||
XP_U16 oldOffset, XP_U16 newOffset )
|
||||
{
|
||||
#if 0
|
||||
|
@ -223,7 +224,7 @@ and_util_yOffsetChange(XW_UtilCtxt* uc, XP_U16 maxOffset,
|
|||
|
||||
#ifdef XWFEATURE_TURNCHANGENOTIFY
|
||||
static void
|
||||
and_util_turnChanged( XW_UtilCtxt* uc, XP_S16 turn )
|
||||
and_util_turnChanged( XW_UtilCtxt* uc, XWEnv xwe, XP_S16 turn )
|
||||
{
|
||||
UTIL_CBK_HEADER( "turnChanged", "(I)V" );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid, turn );
|
||||
|
@ -232,7 +233,7 @@ and_util_turnChanged( XW_UtilCtxt* uc, XP_S16 turn )
|
|||
#endif
|
||||
|
||||
static void
|
||||
and_util_informMove( XW_UtilCtxt* uc, XP_S16 turn, XWStreamCtxt* expl,
|
||||
and_util_informMove( XW_UtilCtxt* uc, XWEnv xwe, XP_S16 turn, XWStreamCtxt* expl,
|
||||
XWStreamCtxt* words )
|
||||
{
|
||||
UTIL_CBK_HEADER( "informMove", "(ILjava/lang/String;Ljava/lang/String;)V" );
|
||||
|
@ -244,7 +245,7 @@ and_util_informMove( XW_UtilCtxt* uc, XP_S16 turn, XWStreamCtxt* expl,
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_notifyDupStatus( XW_UtilCtxt* uc, XP_Bool amHost, const XP_UCHAR* msg )
|
||||
and_util_notifyDupStatus( XW_UtilCtxt* uc, XWEnv xwe, XP_Bool amHost, const XP_UCHAR* msg )
|
||||
{
|
||||
UTIL_CBK_HEADER( "notifyDupStatus", "(ZLjava/lang/String;)V" );
|
||||
jstring jmsg = (*env)->NewStringUTF( env, msg );
|
||||
|
@ -254,7 +255,7 @@ and_util_notifyDupStatus( XW_UtilCtxt* uc, XP_Bool amHost, const XP_UCHAR* msg )
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_informUndo( XW_UtilCtxt* uc )
|
||||
and_util_informUndo( XW_UtilCtxt* uc, XWEnv xwe )
|
||||
{
|
||||
UTIL_CBK_HEADER( "informUndo", "()V" );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid );
|
||||
|
@ -262,7 +263,7 @@ and_util_informUndo( XW_UtilCtxt* uc )
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_informNetDict( XW_UtilCtxt* uc, XP_LangCode lang,
|
||||
and_util_informNetDict( XW_UtilCtxt* uc, XWEnv xwe, XP_LangCode lang,
|
||||
const XP_UCHAR* oldName,
|
||||
const XP_UCHAR* newName, const XP_UCHAR* newSum,
|
||||
XWPhoniesChoice phoniesAction )
|
||||
|
@ -285,7 +286,7 @@ and_util_informNetDict( XW_UtilCtxt* uc, XP_LangCode lang,
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_notifyGameOver( XW_UtilCtxt* uc, XP_S16 XP_UNUSED(quitter) )
|
||||
and_util_notifyGameOver( XW_UtilCtxt* uc, XWEnv xwe, XP_S16 XP_UNUSED(quitter) )
|
||||
{
|
||||
UTIL_CBK_HEADER( "notifyGameOver", "()V" );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid );
|
||||
|
@ -302,7 +303,7 @@ and_util_hiliteCell( XW_UtilCtxt* uc, XP_U16 col, XP_U16 row )
|
|||
#endif
|
||||
|
||||
static XP_Bool
|
||||
and_util_engineProgressCallback( XW_UtilCtxt* uc )
|
||||
and_util_engineProgressCallback( XW_UtilCtxt* uc, XWEnv xwe )
|
||||
{
|
||||
XP_Bool result = XP_FALSE;
|
||||
UTIL_CBK_HEADER("engineProgressCallback","()Z" );
|
||||
|
@ -333,7 +334,7 @@ utilTimerFired( XW_UtilCtxt* uc, XWEnv xwe, XWTimerReason why, int handle )
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, XP_U16 when,
|
||||
and_util_setTimer( XW_UtilCtxt* uc, XWEnv xwe, XWTimerReason why, XP_U16 when,
|
||||
XWTimerProc proc, void* closure )
|
||||
{
|
||||
UTIL_CBK_HEADER("setTimer", "(III)V" );
|
||||
|
@ -348,7 +349,7 @@ and_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, XP_U16 when,
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_clearTimer( XW_UtilCtxt* uc, XWTimerReason why )
|
||||
and_util_clearTimer( XW_UtilCtxt* uc, XWEnv xwe, XWTimerReason why )
|
||||
{
|
||||
UTIL_CBK_HEADER("clearTimer", "(I)V" );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid, why );
|
||||
|
@ -357,7 +358,7 @@ and_util_clearTimer( XW_UtilCtxt* uc, XWTimerReason why )
|
|||
|
||||
|
||||
static void
|
||||
and_util_requestTime( XW_UtilCtxt* uc )
|
||||
and_util_requestTime( XW_UtilCtxt* uc, XWEnv xwe )
|
||||
{
|
||||
UTIL_CBK_HEADER("requestTime", "()V" );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid );
|
||||
|
@ -365,20 +366,16 @@ and_util_requestTime( XW_UtilCtxt* uc )
|
|||
}
|
||||
|
||||
static XP_Bool
|
||||
and_util_altKeyDown( XW_UtilCtxt* uc )
|
||||
and_util_altKeyDown( XW_UtilCtxt* uc, XWEnv xwe )
|
||||
{
|
||||
LOG_FUNC();
|
||||
return XP_FALSE;
|
||||
}
|
||||
|
||||
XP_U32
|
||||
and_dutil_getCurSeconds( XW_DUtilCtxt* duc )
|
||||
and_dutil_getCurSeconds( XW_DUtilCtxt* XP_UNUSED(duc), XWEnv xwe )
|
||||
{
|
||||
AndDUtil* anddutil = (AndDUtil*)duc;
|
||||
XP_U32 curSeconds = getCurSeconds( ENVFORME( anddutil->ti ) );
|
||||
/* struct timeval tv; */
|
||||
/* gettimeofday( &tv, NULL ); */
|
||||
/* XP_LOGF( "%s: %d vs %d", __func__, (int)tv.tv_sec, (int)curSeconds ); */
|
||||
XP_U32 curSeconds = getCurSeconds( xwe );
|
||||
return curSeconds;
|
||||
}
|
||||
|
||||
|
@ -397,7 +394,7 @@ and_util_makeEmptyDict( XW_UtilCtxt* uc, XWEnv xwe )
|
|||
}
|
||||
|
||||
static const XP_UCHAR*
|
||||
and_dutil_getUserString( XW_DUtilCtxt* duc, XP_U16 stringCode )
|
||||
and_dutil_getUserString( XW_DUtilCtxt* duc, XWEnv xwe, XP_U16 stringCode )
|
||||
{
|
||||
XP_UCHAR* result = "";
|
||||
DUTIL_CBK_HEADER("getUserString", "(I)Ljava/lang/String;" );
|
||||
|
@ -426,7 +423,8 @@ and_dutil_getUserString( XW_DUtilCtxt* duc, XP_U16 stringCode )
|
|||
}
|
||||
|
||||
static const XP_UCHAR*
|
||||
and_dutil_getUserQuantityString( XW_DUtilCtxt* duc, XP_U16 stringCode, XP_U16 quantity )
|
||||
and_dutil_getUserQuantityString( XW_DUtilCtxt* duc, XWEnv xwe,
|
||||
XP_U16 stringCode, XP_U16 quantity )
|
||||
{
|
||||
XP_UCHAR* result = "";
|
||||
DUTIL_CBK_HEADER("getUserQuantityString", "(II)Ljava/lang/String;" );
|
||||
|
@ -473,7 +471,7 @@ and_dutil_getUserQuantityString( XW_DUtilCtxt* duc, XP_U16 stringCode, XP_U16 qu
|
|||
}
|
||||
|
||||
static void
|
||||
and_dutil_storePtr( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
||||
and_dutil_storePtr( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||
const void* data, XP_U16 len )
|
||||
{
|
||||
DUTIL_CBK_HEADER( "store", "(Ljava/lang/String;[B)V" );
|
||||
|
@ -489,17 +487,17 @@ and_dutil_storePtr( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
|||
}
|
||||
|
||||
static void
|
||||
and_dutil_storeStream( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
||||
and_dutil_storeStream( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||
XWStreamCtxt* stream )
|
||||
{
|
||||
const void* ptr = stream_getPtr( stream );
|
||||
XP_U16 len = stream_getSize( stream );
|
||||
|
||||
and_dutil_storePtr( duc, key, ptr, len );
|
||||
and_dutil_storePtr( duc, xwe, key, ptr, len );
|
||||
}
|
||||
|
||||
static jbyteArray
|
||||
loadToByteArray( XW_DUtilCtxt* duc, const XP_UCHAR* key )
|
||||
loadToByteArray( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key )
|
||||
{
|
||||
jbyteArray result = NULL;
|
||||
DUTIL_CBK_HEADER( "load", "(Ljava/lang/String;)[B");
|
||||
|
@ -512,12 +510,11 @@ loadToByteArray( XW_DUtilCtxt* duc, const XP_UCHAR* key )
|
|||
}
|
||||
|
||||
static void
|
||||
and_dutil_loadPtr( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
||||
and_dutil_loadPtr( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||
void* data, XP_U16* lenp )
|
||||
{
|
||||
AndDUtil* dutil = (AndDUtil*)duc;
|
||||
JNIEnv* env = ENVFORME( dutil->ti );
|
||||
jbyteArray jvalue = loadToByteArray( duc, key );
|
||||
JNIEnv* env = xwe;
|
||||
jbyteArray jvalue = loadToByteArray( duc, env, key );
|
||||
if ( jvalue != NULL ) {
|
||||
jsize len = (*env)->GetArrayLength( env, jvalue );
|
||||
if ( len <= *lenp ) {
|
||||
|
@ -531,11 +528,11 @@ and_dutil_loadPtr( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
|||
}
|
||||
|
||||
static void
|
||||
and_dutil_loadStream( XW_DUtilCtxt* duc, const XP_UCHAR* key, XWStreamCtxt* stream )
|
||||
and_dutil_loadStream( XW_DUtilCtxt* duc, XWEnv xwe,
|
||||
const XP_UCHAR* key, XWStreamCtxt* stream )
|
||||
{
|
||||
AndDUtil* dutil = (AndDUtil*)duc;
|
||||
JNIEnv* env = ENVFORME( dutil->ti );
|
||||
jbyteArray jvalue = loadToByteArray( duc, key );
|
||||
JNIEnv* env = xwe;
|
||||
jbyteArray jvalue = loadToByteArray( duc, xwe, key );
|
||||
if ( jvalue != NULL ) {
|
||||
jbyte* jelems = (*env)->GetByteArrayElements( env, jvalue, NULL );
|
||||
jsize len = (*env)->GetArrayLength( env, jvalue );
|
||||
|
@ -546,7 +543,7 @@ and_dutil_loadStream( XW_DUtilCtxt* duc, const XP_UCHAR* key, XWStreamCtxt* stre
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_notifyIllegalWords( XW_UtilCtxt* uc, BadWordInfo* bwi,
|
||||
and_util_notifyIllegalWords( XW_UtilCtxt* uc, XWEnv xwe, BadWordInfo* bwi,
|
||||
XP_U16 turn, XP_Bool turnLost )
|
||||
{
|
||||
UTIL_CBK_HEADER("notifyIllegalWords",
|
||||
|
@ -566,7 +563,7 @@ and_util_notifyIllegalWords( XW_UtilCtxt* uc, BadWordInfo* bwi,
|
|||
|
||||
#ifdef XWFEATURE_CHAT
|
||||
static void
|
||||
and_util_showChat( XW_UtilCtxt* uc, const XP_UCHAR* msg, XP_S16 from, XP_U32 timestamp )
|
||||
and_util_showChat( XW_UtilCtxt* uc, XWEnv xwe, const XP_UCHAR* msg, XP_S16 from, XP_U32 timestamp )
|
||||
{
|
||||
UTIL_CBK_HEADER( "showChat", "(Ljava/lang/String;ILjava/lang/String;I)V" );
|
||||
jstring jname = NULL;
|
||||
|
@ -584,7 +581,7 @@ and_util_showChat( XW_UtilCtxt* uc, const XP_UCHAR* msg, XP_S16 from, XP_U32 tim
|
|||
#endif
|
||||
|
||||
static void
|
||||
and_util_remSelected(XW_UtilCtxt* uc)
|
||||
and_util_remSelected( XW_UtilCtxt* uc, XWEnv xwe )
|
||||
{
|
||||
UTIL_CBK_HEADER("remSelected", "()V" );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid );
|
||||
|
@ -592,7 +589,7 @@ and_util_remSelected(XW_UtilCtxt* uc)
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_timerSelected( XW_UtilCtxt* uc, XP_Bool inDuplicateMode, XP_Bool canPause )
|
||||
and_util_timerSelected( XW_UtilCtxt* uc, XWEnv xwe, XP_Bool inDuplicateMode, XP_Bool canPause )
|
||||
{
|
||||
UTIL_CBK_HEADER("timerSelected", "(ZZ)V" );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid, inDuplicateMode, canPause );
|
||||
|
@ -600,7 +597,7 @@ and_util_timerSelected( XW_UtilCtxt* uc, XP_Bool inDuplicateMode, XP_Bool canPau
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_formatPauseHistory( XW_UtilCtxt* uc, XWStreamCtxt* stream,
|
||||
and_util_formatPauseHistory( XW_UtilCtxt* uc, XWEnv xwe, XWStreamCtxt* stream,
|
||||
DupPauseType typ, XP_S16 turn,
|
||||
XP_U32 secsPrev, XP_U32 secsCur,
|
||||
const XP_UCHAR* msg )
|
||||
|
@ -621,7 +618,7 @@ and_util_formatPauseHistory( XW_UtilCtxt* uc, XWStreamCtxt* stream,
|
|||
|
||||
#ifndef XWFEATURE_MINIWIN
|
||||
static void
|
||||
and_util_bonusSquareHeld( XW_UtilCtxt* uc, XWBonusType bonus )
|
||||
and_util_bonusSquareHeld( XW_UtilCtxt* uc, XWEnv xwe, XWBonusType bonus )
|
||||
{
|
||||
UTIL_CBK_HEADER( "bonusSquareHeld", "(I)V" );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid, bonus );
|
||||
|
@ -629,7 +626,7 @@ and_util_bonusSquareHeld( XW_UtilCtxt* uc, XWBonusType bonus )
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_playerScoreHeld( XW_UtilCtxt* uc, XP_U16 player )
|
||||
and_util_playerScoreHeld( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 player )
|
||||
{
|
||||
UTIL_CBK_HEADER( "playerScoreHeld", "(I)V" );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid, player );
|
||||
|
@ -639,7 +636,7 @@ and_util_playerScoreHeld( XW_UtilCtxt* uc, XP_U16 player )
|
|||
|
||||
#ifdef XWFEATURE_SMS
|
||||
static XP_Bool
|
||||
and_dutil_phoneNumbersSame( XW_DUtilCtxt* duc, const XP_UCHAR* p1,
|
||||
and_dutil_phoneNumbersSame( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* p1,
|
||||
const XP_UCHAR* p2 )
|
||||
{
|
||||
XP_Bool same = 0 == strcmp( p1, p2 );
|
||||
|
@ -658,7 +655,7 @@ and_dutil_phoneNumbersSame( XW_DUtilCtxt* duc, const XP_UCHAR* p1,
|
|||
|
||||
#ifdef XWFEATURE_BOARDWORDS
|
||||
static void
|
||||
and_util_cellSquareHeld( XW_UtilCtxt* uc, XWStreamCtxt* words )
|
||||
and_util_cellSquareHeld( XW_UtilCtxt* uc, XWEnv xwe, XWStreamCtxt* words )
|
||||
{
|
||||
if ( NULL != words ) {
|
||||
UTIL_CBK_HEADER( "cellSquareHeld", "(Ljava/lang/String;)V" );
|
||||
|
@ -673,7 +670,7 @@ and_util_cellSquareHeld( XW_UtilCtxt* uc, XWStreamCtxt* words )
|
|||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
|
||||
static void
|
||||
and_util_informMissing( XW_UtilCtxt* uc, XP_Bool isServer,
|
||||
and_util_informMissing( XW_UtilCtxt* uc, XWEnv xwe, XP_Bool isServer,
|
||||
const CommsAddrRec* addr, XP_U16 nDevs, XP_U16 nMissing)
|
||||
{
|
||||
UTIL_CBK_HEADER( "informMissing",
|
||||
|
@ -689,14 +686,15 @@ and_util_informMissing( XW_UtilCtxt* uc, XP_Bool isServer,
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_addrChange( XW_UtilCtxt* uc, const CommsAddrRec* oldAddr,
|
||||
and_util_addrChange( XW_UtilCtxt* uc, XWEnv xwe,
|
||||
const CommsAddrRec* oldAddr,
|
||||
const CommsAddrRec* newAddr )
|
||||
{
|
||||
// LOG_FUNC();
|
||||
}
|
||||
|
||||
static void
|
||||
and_util_setIsServer( XW_UtilCtxt* uc, XP_Bool isServer )
|
||||
and_util_setIsServer( XW_UtilCtxt* uc, XWEnv xwe, XP_Bool isServer )
|
||||
{
|
||||
/* Change both the C and Java structs, which need to stay in sync */
|
||||
uc->gameInfo->serverRole = isServer? SERVER_ISSERVER : SERVER_ISCLIENT;
|
||||
|
@ -706,7 +704,7 @@ and_util_setIsServer( XW_UtilCtxt* uc, XP_Bool isServer )
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_informWordsBlocked( XW_UtilCtxt* uc, XP_U16 nBadWords,
|
||||
and_util_informWordsBlocked( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 nBadWords,
|
||||
XWStreamCtxt* words, const XP_UCHAR* dict )
|
||||
{
|
||||
UTIL_CBK_HEADER( "informWordsBlocked", "(ILjava/lang/String;Ljava/lang/String;)V" );
|
||||
|
@ -719,7 +717,7 @@ and_util_informWordsBlocked( XW_UtilCtxt* uc, XP_U16 nBadWords,
|
|||
|
||||
#ifdef XWFEATURE_DEVID
|
||||
static const XP_UCHAR*
|
||||
and_dutil_getDevID( XW_DUtilCtxt* duc, DevIDType* typ )
|
||||
and_dutil_getDevID( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType* typ )
|
||||
{
|
||||
const XP_UCHAR* result = NULL;
|
||||
*typ = ID_TYPE_NONE;
|
||||
|
@ -752,7 +750,7 @@ and_dutil_getDevID( XW_DUtilCtxt* duc, DevIDType* typ )
|
|||
}
|
||||
|
||||
static void
|
||||
and_dutil_deviceRegistered( XW_DUtilCtxt* duc, DevIDType typ,
|
||||
and_dutil_deviceRegistered( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType typ,
|
||||
const XP_UCHAR* idRelay )
|
||||
{
|
||||
DUTIL_CBK_HEADER( "deviceRegistered",
|
||||
|
@ -797,7 +795,7 @@ and_util_engineStopping( XW_UtilCtxt* uc )
|
|||
#endif
|
||||
|
||||
static XW_DUtilCtxt*
|
||||
and_util_getDevUtilCtxt( XW_UtilCtxt* uc )
|
||||
and_util_getDevUtilCtxt( XW_UtilCtxt* uc, XWEnv xwe )
|
||||
{
|
||||
AndGameGlobals* globals = (AndGameGlobals*)uc->closure;
|
||||
XP_ASSERT( !!globals->dutil );
|
||||
|
@ -806,10 +804,10 @@ and_util_getDevUtilCtxt( XW_UtilCtxt* uc )
|
|||
|
||||
#ifdef COMMS_CHECKSUM
|
||||
static XP_UCHAR*
|
||||
and_dutil_md5sum( XW_DUtilCtxt* duc, const XP_U8* ptr, XP_U16 len )
|
||||
and_dutil_md5sum( XW_DUtilCtxt* duc, XWEnv xwe, const XP_U8* ptr, XP_U16 len )
|
||||
{
|
||||
AndDUtil* dutil = (AndDUtil*)duc;
|
||||
JNIEnv* env = ENVFORME( dutil->ti );
|
||||
JNIEnv* env = xwe;
|
||||
struct JNIUtilCtxt* jniutil = dutil->jniutil;
|
||||
jstring jsum = and_util_getMD5SumForBytes( jniutil, env, ptr, len );
|
||||
XP_UCHAR* result = getStringCopy( MPPARM(duc->mpool) env, jsum );
|
||||
|
@ -819,7 +817,7 @@ and_dutil_md5sum( XW_DUtilCtxt* duc, const XP_U8* ptr, XP_U16 len )
|
|||
#endif
|
||||
|
||||
static void
|
||||
and_dutil_notifyPause( XW_DUtilCtxt* duc, XP_U32 gameID, DupPauseType pauseTyp,
|
||||
and_dutil_notifyPause( XW_DUtilCtxt* duc, XWEnv xwe, XP_U32 gameID, DupPauseType pauseTyp,
|
||||
XP_U16 pauser, const XP_UCHAR* name,
|
||||
const XP_UCHAR* msg )
|
||||
{
|
||||
|
@ -833,7 +831,7 @@ and_dutil_notifyPause( XW_DUtilCtxt* duc, XP_U32 gameID, DupPauseType pauseTyp,
|
|||
}
|
||||
|
||||
static void
|
||||
and_dutil_onDupTimerChanged( XW_DUtilCtxt* duc, XP_U32 gameID,
|
||||
and_dutil_onDupTimerChanged( XW_DUtilCtxt* duc, XWEnv xwe, XP_U32 gameID,
|
||||
XP_U32 oldVal, XP_U32 newVal )
|
||||
{
|
||||
DUTIL_CBK_HEADER( "onDupTimerChanged", "(III)V" );
|
||||
|
@ -842,13 +840,11 @@ and_dutil_onDupTimerChanged( XW_DUtilCtxt* duc, XP_U32 gameID,
|
|||
}
|
||||
|
||||
XW_UtilCtxt*
|
||||
makeUtil( MPFORMAL EnvThreadInfo* ti, jobject jutil, CurGameInfo* gi,
|
||||
makeUtil( MPFORMAL JNIEnv* env, jobject jutil, CurGameInfo* gi,
|
||||
AndGameGlobals* closure )
|
||||
{
|
||||
AndUtil* util = (AndUtil*)XP_CALLOC( mpool, sizeof(*util) );
|
||||
UtilVtable* vtable = (UtilVtable*)XP_CALLOC( mpool, sizeof(*vtable) );
|
||||
util->ti = ti;
|
||||
JNIEnv* env = ENVFORME( util->ti );
|
||||
if ( NULL != jutil ) {
|
||||
util->jutil = (*env)->NewGlobalRef( env, jutil );
|
||||
}
|
||||
|
@ -927,10 +923,9 @@ makeUtil( MPFORMAL EnvThreadInfo* ti, jobject jutil, CurGameInfo* gi,
|
|||
} /* makeUtil */
|
||||
|
||||
void
|
||||
destroyUtil( XW_UtilCtxt** utilc )
|
||||
destroyUtil( XW_UtilCtxt** utilc, JNIEnv* env )
|
||||
{
|
||||
AndUtil* util = (AndUtil*)*utilc;
|
||||
JNIEnv* env = ENVFORME( util->ti );
|
||||
|
||||
if ( NULL != util->jutil ) {
|
||||
(*env)->DeleteGlobalRef( env, util->jutil );
|
||||
|
@ -941,17 +936,15 @@ destroyUtil( XW_UtilCtxt** utilc )
|
|||
}
|
||||
|
||||
XW_DUtilCtxt*
|
||||
makeDUtil( MPFORMAL EnvThreadInfo* ti, jobject jdutil, VTableMgr* vtMgr,
|
||||
makeDUtil( MPFORMAL JNIEnv* env, jobject jdutil, VTableMgr* vtMgr,
|
||||
JNIUtilCtxt* jniutil, void* closure )
|
||||
{
|
||||
AndDUtil* dutil = (AndDUtil*)XP_CALLOC( mpool, sizeof(*dutil) );
|
||||
dutil->ti = ti;
|
||||
dutil->jniutil = jniutil;
|
||||
dutil->dutil.closure = closure;
|
||||
dutil->dutil.vtMgr = vtMgr;
|
||||
|
||||
if ( NULL != jdutil ) {
|
||||
JNIEnv* env = ENVFORME( ti );
|
||||
dutil->jdutil = (*env)->NewGlobalRef( env, jdutil );
|
||||
}
|
||||
|
||||
|
@ -986,10 +979,9 @@ makeDUtil( MPFORMAL EnvThreadInfo* ti, jobject jdutil, VTableMgr* vtMgr,
|
|||
}
|
||||
|
||||
void
|
||||
destroyDUtil( XW_DUtilCtxt** dutilp )
|
||||
destroyDUtil( XW_DUtilCtxt** dutilp, JNIEnv* env )
|
||||
{
|
||||
AndDUtil* dutil = (AndDUtil*)*dutilp;
|
||||
JNIEnv* env = ENVFORME( dutil->ti );
|
||||
if ( NULL != dutil->jdutil ) {
|
||||
(*env)->DeleteGlobalRef( env, dutil->jdutil );
|
||||
}
|
||||
|
|
|
@ -29,14 +29,14 @@
|
|||
#include "andglobals.h"
|
||||
#include "jniutlswrapper.h"
|
||||
|
||||
XW_DUtilCtxt* makeDUtil( MPFORMAL EnvThreadInfo* ti, jobject j_dutil,
|
||||
XW_DUtilCtxt* makeDUtil( MPFORMAL JNIEnv* env, jobject j_dutil,
|
||||
VTableMgr* vtMgr, JNIUtilCtxt* jniutil,
|
||||
void* closure );
|
||||
void destroyDUtil( XW_DUtilCtxt** dutilp );
|
||||
void destroyDUtil( XW_DUtilCtxt** dutilp, JNIEnv* env );
|
||||
|
||||
XW_UtilCtxt* makeUtil( MPFORMAL EnvThreadInfo* ti, jobject j_util,
|
||||
XW_UtilCtxt* makeUtil( MPFORMAL JNIEnv* env, jobject j_util,
|
||||
CurGameInfo* gi, AndGameGlobals* globals );
|
||||
void destroyUtil( XW_UtilCtxt** util );
|
||||
void destroyUtil( XW_UtilCtxt** util, JNIEnv* env );
|
||||
|
||||
bool utilTimerFired( XW_UtilCtxt* util, XWEnv xwe, XWTimerReason why, int handle );
|
||||
|
||||
|
|
|
@ -359,10 +359,10 @@ Java_org_eehouse_android_xw4_jni_XwJNI_initGlobals
|
|||
map_init( MPPARM(mpool) &globalState->ti, env );
|
||||
globalState->jniutil = makeJNIUtil( MPPARM(mpool) env, &globalState->ti, jniu );
|
||||
globalState->vtMgr = make_vtablemgr( MPPARM_NOCOMMA(mpool) );
|
||||
globalState->dutil = makeDUtil( MPPARM(mpool) &globalState->ti, jdutil,
|
||||
globalState->dutil = makeDUtil( MPPARM(mpool) env, jdutil,
|
||||
globalState->vtMgr, globalState->jniutil, NULL );
|
||||
globalState->dictMgr = dmgr_make( MPPARM_NOCOMMA( mpool ) );
|
||||
globalState->smsProto = smsproto_init( MPPARM( mpool ) globalState->dutil );
|
||||
globalState->smsProto = smsproto_init( MPPARM( mpool ) env, globalState->dutil );
|
||||
MPASSIGN( globalState->mpool, mpool );
|
||||
setGlobalState( globalState );
|
||||
// LOG_RETURNF( "%p", globalState );
|
||||
|
@ -384,7 +384,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_cleanGlobals
|
|||
smsproto_free( globalState->smsProto );
|
||||
vtmgr_destroy( MPPARM(mpool) globalState->vtMgr );
|
||||
dmgr_destroy( globalState->dictMgr, env );
|
||||
destroyDUtil( &globalState->dutil );
|
||||
destroyDUtil( &globalState->dutil, env );
|
||||
destroyJNIUtil( env, &globalState->jniutil );
|
||||
map_destroy( &globalState->ti );
|
||||
XP_FREE( mpool, globalState );
|
||||
|
@ -899,7 +899,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_smsproto_1prepOutbound
|
|||
const char* toPhone = (*env)->GetStringUTFChars( env, jToPhone, NULL );
|
||||
|
||||
XP_U16 waitSecs;
|
||||
SMSMsgArray* arr = smsproto_prepOutbound( globalState->smsProto, cmd,
|
||||
SMSMsgArray* arr = smsproto_prepOutbound( globalState->smsProto, env, cmd,
|
||||
jGameID, (const XP_U8*)data, len,
|
||||
toPhone, jPort, XP_FALSE,
|
||||
&waitSecs );
|
||||
|
@ -933,7 +933,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_smsproto_1prepInbound
|
|||
jbyte* data = (*env)->GetByteArrayElements( env, jData, NULL );
|
||||
const char* fromPhone = (*env)->GetStringUTFChars( env, jFromPhone, NULL );
|
||||
|
||||
SMSMsgArray* arr = smsproto_prepInbound( globalState->smsProto, fromPhone,
|
||||
SMSMsgArray* arr = smsproto_prepInbound( globalState->smsProto, env, fromPhone,
|
||||
jWantPort, (XP_U8*)data, len );
|
||||
if ( !!arr ) {
|
||||
result = msgArrayToJMsgArray( env, arr );
|
||||
|
@ -1013,10 +1013,9 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeNewGame
|
|||
jobject j_procs )
|
||||
{
|
||||
XWJNI_START_GLOBALS();
|
||||
EnvThreadInfo* ti = &state->globalJNI->ti;
|
||||
CurGameInfo* gi = makeGI( MPPARM(mpool) env, j_gi );
|
||||
globals->gi = gi;
|
||||
globals->util = makeUtil( MPPARM(mpool) ti, j_util, gi,
|
||||
globals->util = makeUtil( MPPARM(mpool) env, j_util, gi,
|
||||
globals );
|
||||
globals->jniutil = state->globalJNI->jniutil;
|
||||
DrawCtx* dctx = NULL;
|
||||
|
@ -1066,7 +1065,7 @@ JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_game_1dispose
|
|||
|
||||
destroyDraw( &globals->dctx, env );
|
||||
destroyXportProcs( &globals->xportProcs, env );
|
||||
destroyUtil( &globals->util );
|
||||
destroyUtil( &globals->util, env );
|
||||
vtmgr_destroy( MPPARM(mpool) globals->vtMgr );
|
||||
|
||||
MAP_REMOVE( &state->globalJNI->ti, env );
|
||||
|
@ -1084,10 +1083,9 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeFromStream
|
|||
DictionaryCtxt* dict;
|
||||
PlayerDicts dicts;
|
||||
XWJNI_START_GLOBALS();
|
||||
EnvThreadInfo* ti = &state->globalJNI->ti;
|
||||
|
||||
globals->gi = (CurGameInfo*)XP_CALLOC( mpool, sizeof(*globals->gi) );
|
||||
globals->util = makeUtil( MPPARM(mpool) ti, jutil, globals->gi, globals);
|
||||
globals->util = makeUtil( MPPARM(mpool) env, jutil, globals->gi, globals);
|
||||
globals->jniutil = state->globalJNI->jniutil;
|
||||
makeDicts( MPPARM(state->globalJNI->mpool) env, state->globalJNI->dictMgr,
|
||||
globals->jniutil, &dict, &dicts, jdictNames, jdicts, jpaths,
|
||||
|
@ -1221,7 +1219,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1figureLayout
|
|||
CurGameInfo* gi = makeGI( MPPARM(mpool) env, jgi );
|
||||
|
||||
BoardDims dims;
|
||||
board_figureLayout( state->game.board, gi, left, top, width, height,
|
||||
board_figureLayout( state->game.board, env, gi, left, top, width, height,
|
||||
115, scorePct, trayPct, scoreWidth,
|
||||
fontWidth, fontHt, squareTiles,
|
||||
((!!jdims) ? &dims : NULL) );
|
||||
|
@ -1241,7 +1239,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1applyLayout
|
|||
XWJNI_START();
|
||||
BoardDims dims;
|
||||
dimsJToC( env, &dims, jdims );
|
||||
board_applyLayout( state->game.board, &dims );
|
||||
board_applyLayout( state->game.board, env, &dims );
|
||||
XWJNI_END();
|
||||
}
|
||||
|
||||
|
@ -1288,7 +1286,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1zoom
|
|||
jboolean result;
|
||||
XWJNI_START();
|
||||
XP_Bool canInOut[2];
|
||||
result = board_zoom( state->game.board, zoomBy, canInOut );
|
||||
result = board_zoom( state->game.board, env, zoomBy, canInOut );
|
||||
jboolean canZoom[2] = { canInOut[0], canInOut[1] };
|
||||
setBoolArray( env, jCanZoom, VSIZE(canZoom), canZoom );
|
||||
XWJNI_END();
|
||||
|
@ -1328,7 +1326,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1handlePenDown
|
|||
jboolean result;
|
||||
XWJNI_START();
|
||||
XP_Bool bb; /* drop this for now */
|
||||
result = board_handlePenDown( state->game.board, xx, yy, &bb );
|
||||
result = board_handlePenDown( state->game.board, env, xx, yy, &bb );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
@ -1339,7 +1337,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1handlePenMove
|
|||
{
|
||||
jboolean result;
|
||||
XWJNI_START();
|
||||
result = board_handlePenMove( state->game.board, xx, yy );
|
||||
result = board_handlePenMove( state->game.board, env, xx, yy );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
@ -1373,7 +1371,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1juggleTray
|
|||
{
|
||||
jboolean result;
|
||||
XWJNI_START();
|
||||
result = board_juggleTray( state->game.board );
|
||||
result = board_juggleTray( state->game.board, env );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
@ -1407,7 +1405,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1passwordProvided
|
|||
jboolean result;
|
||||
XWJNI_START();
|
||||
const char* passwd = (*env)->GetStringUTFChars( env, jpasswd, NULL );
|
||||
result = board_passwordProvided( state->game.board, player, passwd );
|
||||
result = board_passwordProvided( state->game.board, env, player, passwd );
|
||||
(*env)->ReleaseStringUTFChars( env, jpasswd, passwd );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
|
@ -1419,7 +1417,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1hideTray
|
|||
{
|
||||
jboolean result;
|
||||
XWJNI_START();
|
||||
result = board_hideTray( state->game.board );
|
||||
result = board_hideTray( state->game.board, env);
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
@ -1430,7 +1428,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1showTray
|
|||
{
|
||||
jboolean result;
|
||||
XWJNI_START();
|
||||
result = board_showTray( state->game.board );
|
||||
result = board_showTray( state->game.board, env );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
@ -1441,7 +1439,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1beginTrade
|
|||
{
|
||||
jboolean result;
|
||||
XWJNI_START();
|
||||
result = board_beginTrade( state->game.board );
|
||||
result = board_beginTrade( state->game.board, env );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
@ -1518,7 +1516,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1replaceTiles
|
|||
{
|
||||
jboolean result;
|
||||
XWJNI_START();
|
||||
result = board_replaceTiles( state->game.board );
|
||||
result = board_replaceTiles( state->game.board, env );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
@ -1529,7 +1527,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1redoReplacedTiles
|
|||
{
|
||||
jboolean result;
|
||||
XWJNI_START();
|
||||
result = board_redoReplacedTiles( state->game.board );
|
||||
result = board_redoReplacedTiles( state->game.board, env );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
@ -1571,7 +1569,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1tilesPicked
|
|||
XWJNI_START();
|
||||
TrayTileSet newTiles;
|
||||
tilesArrayToTileSet( env, jNewTiles, &newTiles );
|
||||
server_tilesPicked( state->game.server, player, &newTiles );
|
||||
server_tilesPicked( state->game.server, env, player, &newTiles );
|
||||
XWJNI_END();
|
||||
}
|
||||
|
||||
|
@ -1637,7 +1635,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1formatRemainingTiles
|
|||
XWJNI_START_GLOBALS();
|
||||
XWStreamCtxt* stream = mem_stream_make( MPPARM(mpool) globals->vtMgr,
|
||||
NULL, 0, NULL );
|
||||
board_formatRemainingTiles( state->game.board, stream );
|
||||
board_formatRemainingTiles( state->game.board, env, stream );
|
||||
result = streamToJString( env, stream );
|
||||
stream_destroy( stream, env );
|
||||
|
||||
|
@ -1652,7 +1650,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1formatDictCounts
|
|||
jstring result;
|
||||
XWJNI_START_GLOBALS();
|
||||
XWStreamCtxt* stream = and_empty_stream( MPPARM(mpool) globals );
|
||||
server_formatDictCounts( state->game.server, stream, nCols, XP_FALSE );
|
||||
server_formatDictCounts( state->game.server, env, stream, nCols, XP_FALSE );
|
||||
result = streamToJString( env, stream );
|
||||
stream_destroy( stream, env );
|
||||
XWJNI_END();
|
||||
|
@ -1738,7 +1736,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1writeFinalScores
|
|||
jstring result;
|
||||
XWJNI_START_GLOBALS();
|
||||
XWStreamCtxt* stream = and_empty_stream( MPPARM(mpool) globals );
|
||||
server_writeFinalScores( state->game.server, stream );
|
||||
server_writeFinalScores( state->game.server, env, stream );
|
||||
result = streamToJString( env, stream );
|
||||
stream_destroy( stream, env );
|
||||
XWJNI_END();
|
||||
|
@ -2078,7 +2076,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1getState
|
|||
{
|
||||
XWJNI_START();
|
||||
GameStateInfo info;
|
||||
game_getState( &state->game, &info );
|
||||
game_getState( &state->game, env, &info );
|
||||
|
||||
setInts( env, jgsi, (void*)&info, AANDS(gsi_ints) );
|
||||
setBools( env, jgsi, (void*)&info, AANDS(gsi_bools) );
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -59,21 +59,21 @@ typedef enum {
|
|||
|
||||
/* typedef struct BoardCtxt BoardCtxt; */
|
||||
|
||||
BoardCtxt* board_make( MPFORMAL ModelCtxt* model, ServerCtxt* server,
|
||||
BoardCtxt* board_make( MPFORMAL XWEnv xwe, ModelCtxt* model, ServerCtxt* server,
|
||||
DrawCtx* draw, XW_UtilCtxt* util );
|
||||
BoardCtxt* board_makeFromStream( MPFORMAL XWStreamCtxt* stream,
|
||||
BoardCtxt* board_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream,
|
||||
ModelCtxt* model, ServerCtxt* server,
|
||||
DrawCtx* draw, XW_UtilCtxt* util,
|
||||
XP_U16 nPlayers );
|
||||
void board_setCallbacks( BoardCtxt* board );
|
||||
void board_setCallbacks( BoardCtxt* board, XWEnv xwe );
|
||||
void board_setDraw( BoardCtxt* board, XWEnv xwe, DrawCtx* draw );
|
||||
DrawCtx* board_getDraw( const BoardCtxt* board );
|
||||
|
||||
void board_destroy( BoardCtxt* board, XP_Bool ownsUtil );
|
||||
void board_destroy( BoardCtxt* board, XWEnv xwe, XP_Bool ownsUtil );
|
||||
|
||||
void board_writeToStream( const BoardCtxt* board, XWStreamCtxt* stream );
|
||||
|
||||
void board_reset( BoardCtxt* board );
|
||||
void board_reset( BoardCtxt* board, XWEnv xwe );
|
||||
|
||||
void board_drawSnapshot( const BoardCtxt* board, XWEnv xwe, DrawCtx* dctx,
|
||||
XP_U16 width, XP_U16 height );
|
||||
|
@ -100,28 +100,29 @@ typedef struct _BoardDims {
|
|||
XP_U16 timerWidth;
|
||||
} BoardDims;
|
||||
|
||||
void board_figureLayout( BoardCtxt* board, const CurGameInfo* gi, XP_U16 bLeft,
|
||||
XP_U16 bTop, XP_U16 bWidth, XP_U16 bHeight,
|
||||
void board_figureLayout( BoardCtxt* board, XWEnv xwe, const CurGameInfo* gi,
|
||||
XP_U16 bLeft, XP_U16 bTop, XP_U16 bWidth, XP_U16 bHeight,
|
||||
XP_U16 colPctMax, XP_U16 scorePct, XP_U16 trayPct,
|
||||
XP_U16 scoreWidth, XP_U16 fontWidth, XP_U16 fontHt,
|
||||
XP_Bool squareTiles, /* out */ BoardDims* dimsp );
|
||||
void board_applyLayout( BoardCtxt* board, const BoardDims* dims );
|
||||
void board_applyLayout( BoardCtxt* board, XWEnv xwe, const BoardDims* dims );
|
||||
|
||||
#endif
|
||||
|
||||
/* These four aren't needed if COMMON_LAYOUT defined */
|
||||
void board_setPos( BoardCtxt* board, XP_U16 left, XP_U16 top,
|
||||
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 );
|
||||
void board_setScoreboardLoc( BoardCtxt* board,
|
||||
XP_U16 scoreLeft, XP_U16 scoreTop,
|
||||
XP_U16 scoreWidth, XP_U16 scoreHeight,
|
||||
XP_Bool divideHorizontally );
|
||||
void board_setTrayLoc( BoardCtxt* board, XP_U16 trayLeft, XP_U16 trayTop,
|
||||
void board_setTrayLoc( BoardCtxt* board, XWEnv xwe,
|
||||
XP_U16 trayLeft, XP_U16 trayTop,
|
||||
XP_U16 trayWidth, XP_U16 trayHeight );
|
||||
|
||||
/* Vertical scroll support; offset is in rows, not pixels */
|
||||
XP_Bool board_setYOffset( BoardCtxt* board, XP_U16 newOffset );
|
||||
XP_Bool board_setYOffset( BoardCtxt* board, XWEnv xwe, XP_U16 newOffset );
|
||||
XP_U16 board_getYOffset( const BoardCtxt* board );
|
||||
|
||||
XP_Bool board_curTurnSelected( const BoardCtxt* board );
|
||||
|
@ -130,13 +131,13 @@ void board_pause( BoardCtxt* board, XWEnv xwe, const XP_UCHAR* msg );
|
|||
void board_unpause( BoardCtxt* board, XWEnv xwe, const XP_UCHAR* msg );
|
||||
XP_Bool board_canShuffle( const BoardCtxt* board );
|
||||
XP_Bool board_canHideRack( const BoardCtxt* board );
|
||||
XP_Bool board_canTrade( BoardCtxt* board );
|
||||
XP_Bool board_canTrade( BoardCtxt* board, XWEnv xwe );
|
||||
XP_Bool board_canTogglePending( const BoardCtxt* board );
|
||||
XP_Bool board_canHint( const BoardCtxt* board );
|
||||
void board_sendChat( const BoardCtxt* board, XWEnv xwe, const XP_UCHAR* msg );
|
||||
|
||||
/* zoomBy: >0: zoom in; < 0: zoom out; 0: query only */
|
||||
XP_Bool board_zoom( BoardCtxt* board, XP_S16 zoomBy, XP_Bool* canInOut );
|
||||
XP_Bool board_zoom( BoardCtxt* board, XWEnv xwe, XP_S16 zoomBy, XP_Bool* canInOut );
|
||||
|
||||
void board_invalAll( BoardCtxt* board );
|
||||
void board_invalRect( BoardCtxt* board, XP_Rect* rect );
|
||||
|
@ -152,13 +153,13 @@ XP_Bool board_flip( BoardCtxt* board );
|
|||
XP_Bool board_inTrade( const BoardCtxt* board, XP_Bool* anySelected );
|
||||
XP_Bool board_get_showValues( const BoardCtxt* board );
|
||||
XP_Bool board_toggle_showValues( BoardCtxt* board );
|
||||
XP_Bool board_replaceTiles( BoardCtxt* board );
|
||||
XP_Bool board_redoReplacedTiles( BoardCtxt* board );
|
||||
XP_Bool board_replaceTiles( BoardCtxt* board, XWEnv xwe );
|
||||
XP_Bool board_redoReplacedTiles( BoardCtxt* board, XWEnv xwe );
|
||||
|
||||
XP_U16 board_getSelPlayer(const BoardCtxt* board );
|
||||
|
||||
XP_Bool board_passwordProvided( BoardCtxt* board, XP_U16 player, const
|
||||
XP_UCHAR* pass );
|
||||
XP_Bool board_passwordProvided( BoardCtxt* board, XWEnv xwe,
|
||||
XP_U16 player, const XP_UCHAR* pass );
|
||||
|
||||
XP_Bool board_requestHint( BoardCtxt* board, XWEnv xwe,
|
||||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
|
@ -179,15 +180,16 @@ void board_resetEngine( BoardCtxt* board );
|
|||
XP_Bool board_commitTurn( BoardCtxt* board, XWEnv xwe, XP_Bool phoniesConfirmed,
|
||||
XP_Bool turnConfirmed, TrayTileSet* newTiles );
|
||||
|
||||
void board_pushTimerSave( BoardCtxt* board );
|
||||
void board_popTimerSave( BoardCtxt* board );
|
||||
void board_pushTimerSave( BoardCtxt* board, XWEnv xwe );
|
||||
void board_popTimerSave( BoardCtxt* board, XWEnv xwe );
|
||||
|
||||
void board_formatRemainingTiles( BoardCtxt* board, XWStreamCtxt* stream );
|
||||
void board_formatRemainingTiles( BoardCtxt* board, XWEnv xwe,
|
||||
XWStreamCtxt* stream );
|
||||
|
||||
#ifdef POINTER_SUPPORT
|
||||
XP_Bool board_handlePenDown( BoardCtxt* board, XP_U16 x, XP_U16 y,
|
||||
XP_Bool* handled );
|
||||
XP_Bool board_handlePenMove( BoardCtxt* board, XP_U16 x, XP_U16 y );
|
||||
XP_Bool board_handlePenDown( BoardCtxt* board, XWEnv xwe, XP_U16 xx,
|
||||
XP_U16 yy, XP_Bool* handled );
|
||||
XP_Bool board_handlePenMove( BoardCtxt* board, XWEnv xwe, XP_U16 x, XP_U16 y );
|
||||
XP_Bool board_handlePenUp( BoardCtxt* board, XWEnv xwe, XP_U16 x, XP_U16 y );
|
||||
XP_Bool board_containsPt( const BoardCtxt* board, XP_U16 xx, XP_U16 yy );
|
||||
#endif
|
||||
|
@ -196,10 +198,10 @@ XP_Bool board_containsPt( const BoardCtxt* board, XP_U16 xx, XP_U16 yy );
|
|||
XP_Bool board_handleKey( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* handled );
|
||||
|
||||
XP_Bool board_handleKeyUp( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* handled );
|
||||
XP_Bool board_handleKeyDown( BoardCtxt* board, XP_Key key, XP_Bool* handled );
|
||||
XP_Bool board_handleKeyDown( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* handled );
|
||||
XP_Bool board_handleKeyRepeat( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* handled );
|
||||
# ifdef KEYBOARD_NAV
|
||||
XP_Bool board_focusChanged( BoardCtxt* board, BoardObjectType typ,
|
||||
XP_Bool board_focusChanged( BoardCtxt* board, XWEnv xwe, BoardObjectType typ,
|
||||
XP_Bool gained );
|
||||
# endif
|
||||
#endif
|
||||
|
@ -207,13 +209,13 @@ XP_Bool board_focusChanged( BoardCtxt* board, BoardObjectType typ,
|
|||
/******************** Tray methods ********************/
|
||||
#define NO_TILES ((TileBit)0)
|
||||
|
||||
XP_Bool board_hideTray( BoardCtxt* board );
|
||||
XP_Bool board_showTray( BoardCtxt* board );
|
||||
XP_Bool board_hideTray( BoardCtxt* board, XWEnv xwe );
|
||||
XP_Bool board_showTray( BoardCtxt* board, XWEnv xwe );
|
||||
XW_TrayVisState board_getTrayVisState( const BoardCtxt* board );
|
||||
|
||||
void board_invalTrayTiles( BoardCtxt* board, TileBit what );
|
||||
XP_Bool board_juggleTray( BoardCtxt* board );
|
||||
XP_Bool board_beginTrade( BoardCtxt* board );
|
||||
XP_Bool board_juggleTray( BoardCtxt* board, XWEnv xwe );
|
||||
XP_Bool board_beginTrade( BoardCtxt* board, XWEnv xwe );
|
||||
XP_Bool board_endTrade( BoardCtxt* board );
|
||||
|
||||
#if defined FOR_GREMLINS
|
||||
|
|
|
@ -339,7 +339,7 @@ drawBoard( BoardCtxt* board, XWEnv xwe )
|
|||
XWBonusType bonus;
|
||||
HintAtts hintAtts;
|
||||
CellFlags flags = CELL_NONE;
|
||||
bonus = model_getSquareBonus( model, col, row );
|
||||
bonus = model_getSquareBonus( model, xwe, col, row );
|
||||
hintAtts = figureHintAtts( board, col, row );
|
||||
#ifdef KEYBOARD_NAV
|
||||
if ( cellFocused( board, col, row ) ) {
|
||||
|
@ -368,7 +368,8 @@ drawBoard( BoardCtxt* board, XWEnv xwe )
|
|||
} /* drawBoard */
|
||||
|
||||
static XP_Bool
|
||||
drawCell( BoardCtxt* board, XWEnv xwe, const XP_U16 col, const XP_U16 row, XP_Bool skipBlanks )
|
||||
drawCell( BoardCtxt* board, XWEnv xwe, const XP_U16 col,
|
||||
const XP_U16 row, XP_Bool skipBlanks )
|
||||
{
|
||||
XP_Bool success = XP_TRUE;
|
||||
XP_Rect cellRect = {0};
|
||||
|
@ -443,7 +444,7 @@ drawCell( BoardCtxt* board, XWEnv xwe, const XP_U16 col, const XP_U16 row, XP_Bo
|
|||
textP = dict_getTileString( dict, tile );
|
||||
}
|
||||
}
|
||||
bonus = model_getSquareBonus( model, col, row );
|
||||
bonus = model_getSquareBonus( model, xwe, col, row );
|
||||
hintAtts = figureHintAtts( board, col, row );
|
||||
|
||||
if ( (col==board->star_row) && (row==board->star_row) ) {
|
||||
|
|
|
@ -245,15 +245,15 @@ struct BoardCtxt {
|
|||
/* tray-related functions */
|
||||
XP_Bool handlePenUpTray( BoardCtxt* board, XWEnv xwe, XP_U16 x, XP_U16 y );
|
||||
void drawTray( BoardCtxt* board, XWEnv xwe );
|
||||
XP_Bool moveTileToArrowLoc( BoardCtxt* board, XP_U8 index );
|
||||
XP_Bool moveTileToArrowLoc( BoardCtxt* board, XWEnv xwe, XP_U8 index );
|
||||
XP_U16 indexForBits( XP_U8 bits );
|
||||
XP_Bool rectContainsPt( const XP_Rect* rect1, XP_S16 x, XP_S16 y );
|
||||
XP_Bool checkRevealTray( BoardCtxt* board );
|
||||
XP_Bool checkRevealTray( BoardCtxt* board, XWEnv xwe );
|
||||
void figureTrayTileRect( BoardCtxt* board, XP_U16 index, XP_Rect* rect );
|
||||
XP_Bool rectsIntersect( const XP_Rect* rect1, const XP_Rect* rect2 );
|
||||
XP_S16 pointToTileIndex( BoardCtxt* board, XP_U16 x, XP_U16 y,
|
||||
XP_Bool* onDividerP );
|
||||
void board_selectPlayer( BoardCtxt* board, XP_U16 newPlayer, XP_Bool canPeek );
|
||||
void board_selectPlayer( BoardCtxt* board, XWEnv xwe, XP_U16 newPlayer, XP_Bool canPeek );
|
||||
void flipIf( const BoardCtxt* board, XP_U16 col, XP_U16 row,
|
||||
XP_U16* fCol, XP_U16* fRow );
|
||||
XP_Bool pointOnSomething( const BoardCtxt* board, XP_U16 xx, XP_U16 yy,
|
||||
|
@ -264,9 +264,9 @@ XP_Bool cellOccupied( const BoardCtxt* board, XP_U16 col, XP_U16 row,
|
|||
XP_Bool inclPending );
|
||||
XP_Bool holdsPendingTile( BoardCtxt* board, XP_U16 pencol, XP_U16 penrow );
|
||||
|
||||
XP_Bool moveTileToBoard( BoardCtxt* board, XP_U16 col, XP_U16 row,
|
||||
XP_Bool moveTileToBoard( BoardCtxt* board, XWEnv xwe, XP_U16 col, XP_U16 row,
|
||||
XP_U16 tileIndex, Tile blankFace );
|
||||
XP_Bool board_replaceNTiles( BoardCtxt* board, XP_U16 nTiles );
|
||||
XP_Bool board_replaceNTiles( BoardCtxt* board, XWEnv xwe, XP_U16 nTiles );
|
||||
|
||||
void invalTilesUnderRect( BoardCtxt* board, const XP_Rect* rect );
|
||||
void invalCellRegion( BoardCtxt* board, XP_U16 colA, XP_U16 rowA, XP_U16 colB,
|
||||
|
@ -312,11 +312,10 @@ const XP_UCHAR* getTileDrawInfo( const BoardCtxt* board, Tile tile,
|
|||
XP_S16* value );
|
||||
XP_Bool dividerMoved( BoardCtxt* board, XP_U8 newLoc );
|
||||
|
||||
XP_Bool scrollIntoView( BoardCtxt* board, XP_U16 col, XP_U16 row );
|
||||
XP_Bool onBorderCanScroll( const BoardCtxt* board, SDIndex indx, XP_U16 row,
|
||||
XP_S16* change );
|
||||
XP_Bool scrollIntoView( BoardCtxt* board, XWEnv xwe, XP_U16 col, XP_U16 row );
|
||||
XP_Bool onBorderCanScroll( const BoardCtxt* board, SDIndex indx, XP_U16 row, XP_S16* change );
|
||||
XP_Bool adjustXOffset( BoardCtxt* board, XP_S16 moveBy );
|
||||
XP_Bool adjustYOffset( BoardCtxt* board, XP_S16 moveBy );
|
||||
XP_Bool adjustYOffset( BoardCtxt* board, XWEnv xwe, XP_S16 moveBy );
|
||||
XP_Bool rectContainsRect( const XP_Rect* rect1, const XP_Rect* rect2 );
|
||||
|
||||
|
||||
|
|
|
@ -193,10 +193,11 @@ static AddressRecord* rememberChannelAddress( CommsCtxt* comms, XWEnv xwe,
|
|||
static void augmentChannelAddr( AddressRecord* rec, const CommsAddrRec* addr,
|
||||
XWHostID hostID );
|
||||
static void augmentAddr( CommsAddrRec* dest, const CommsAddrRec* src );
|
||||
static XP_Bool channelToAddress( CommsCtxt* comms, XP_PlayerAddr channelNo,
|
||||
static XP_Bool channelToAddress( CommsCtxt* comms, XWEnv xwe, XP_PlayerAddr channelNo,
|
||||
const CommsAddrRec** addr );
|
||||
static AddressRecord* getRecordFor( CommsCtxt* comms, const CommsAddrRec* addr,
|
||||
XP_PlayerAddr channelNo, XP_Bool maskChnl );
|
||||
static AddressRecord* getRecordFor( CommsCtxt* comms, XWEnv xwe,
|
||||
const CommsAddrRec* addr, XP_PlayerAddr channelNo,
|
||||
XP_Bool maskChnl );
|
||||
static XP_S16 sendMsg( CommsCtxt* comms, XWEnv xwe, MsgQueueElem* elem,
|
||||
CommsConnType filter );
|
||||
static MsgQueueElem* addToQueue( CommsCtxt* comms, XWEnv xwe, MsgQueueElem* newMsgElem );
|
||||
|
@ -218,11 +219,11 @@ static XP_Bool send_via_relay( CommsCtxt* comms, XWEnv xwe, XWRELAY_Cmd cmd,
|
|||
static XP_Bool sendNoConn( CommsCtxt* comms, XWEnv xwe,
|
||||
const MsgQueueElem* elem, XWHostID destID );
|
||||
static XWHostID getDestID( CommsCtxt* comms, XWEnv xwe, XP_PlayerAddr channelNo );
|
||||
static void set_reset_timer( CommsCtxt* comms );
|
||||
static void set_reset_timer( CommsCtxt* comms, XWEnv xwe );
|
||||
# ifdef XWFEATURE_DEVID
|
||||
static void putDevID( const CommsCtxt* comms, XWStreamCtxt* stream );
|
||||
static void putDevID( const CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream );
|
||||
# else
|
||||
# define putDevID( comms, stream )
|
||||
# define putDevID( comms, xwe, stream )
|
||||
# endif
|
||||
# ifdef DEBUG
|
||||
static const char* relayCmdToStr( XWRELAY_Cmd cmd );
|
||||
|
@ -378,9 +379,9 @@ comms_make( MPFORMAL XWEnv xwe, XW_UtilCtxt* util, XP_Bool isServer,
|
|||
comms->xportFlags = comms->procs.flags;
|
||||
#endif
|
||||
}
|
||||
comms->dutil = util_getDevUtilCtxt( util );
|
||||
comms->dutil = util_getDevUtilCtxt( util, xwe );
|
||||
comms->util = util;
|
||||
comms->dutil = util_getDevUtilCtxt( util );
|
||||
comms->dutil = util_getDevUtilCtxt( util, xwe );
|
||||
|
||||
#ifdef XWFEATURE_RELAY
|
||||
init_relay( comms, xwe, nPlayersHere, nPlayersTotal );
|
||||
|
@ -516,7 +517,7 @@ p_comms_resetTimer( void* closure, XWEnv xwe, XWTimerReason XP_UNUSED_DBG(why) )
|
|||
setHeartbeatTimer( comms ); /* in case we killed it with this
|
||||
one.... */
|
||||
} else {
|
||||
set_reset_timer( comms );
|
||||
set_reset_timer( comms, xwe );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -524,12 +525,12 @@ p_comms_resetTimer( void* closure, XWEnv xwe, XWTimerReason XP_UNUSED_DBG(why) )
|
|||
} /* p_comms_resetTimer */
|
||||
|
||||
static void
|
||||
set_reset_timer( CommsCtxt* comms )
|
||||
set_reset_timer( CommsCtxt* comms, XWEnv xwe )
|
||||
{
|
||||
/* This timer is allowed to overwrite a heartbeat timer, but not
|
||||
vice-versa. Make sure we can restart it. */
|
||||
comms->hbTimerPending = XP_FALSE;
|
||||
util_setTimer( comms->util, TIMER_COMMS, 15,
|
||||
util_setTimer( comms->util, xwe, TIMER_COMMS, 15,
|
||||
p_comms_resetTimer, comms );
|
||||
comms->reconTimerPending = XP_TRUE;
|
||||
} /* set_reset_timer */
|
||||
|
@ -543,26 +544,26 @@ comms_transportFailed( CommsCtxt* comms, XWEnv xwe, CommsConnType failed )
|
|||
&& comms->rr.relayState != COMMS_RELAYSTATE_DENIED ) {
|
||||
relayDisconnect( comms, xwe );
|
||||
|
||||
set_reset_timer( comms );
|
||||
set_reset_timer( comms, xwe );
|
||||
}
|
||||
LOG_RETURN_VOID();
|
||||
}
|
||||
#endif /* XWFEATURE_RELAY */
|
||||
|
||||
void
|
||||
comms_destroy( CommsCtxt* comms )
|
||||
comms_destroy( CommsCtxt* comms, XWEnv xwe )
|
||||
{
|
||||
/* did I call comms_stop()? */
|
||||
XP_ASSERT( ! addr_hasType( &comms->addr, COMMS_CONN_RELAY )
|
||||
|| COMMS_RELAYSTATE_UNCONNECTED == comms->rr.relayState );
|
||||
|
||||
CommsAddrRec aNew = {0};
|
||||
util_addrChange( comms->util, &comms->addr, &aNew );
|
||||
util_addrChange( comms->util, xwe, &comms->addr, &aNew );
|
||||
|
||||
cleanupInternal( comms );
|
||||
cleanupAddrRecs( comms );
|
||||
|
||||
util_clearTimer( comms->util, TIMER_COMMS );
|
||||
util_clearTimer( comms->util, xwe, TIMER_COMMS );
|
||||
|
||||
XP_FREE( comms->mpool, comms );
|
||||
} /* comms_destroy */
|
||||
|
@ -733,7 +734,7 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, XW_UtilCtxt* uti
|
|||
msg->msg = (XP_U8*)XP_MALLOC( mpool, msg->len );
|
||||
stream_getBytes( stream, msg->msg, msg->len );
|
||||
#ifdef COMMS_CHECKSUM
|
||||
msg->checksum = dutil_md5sum( comms->dutil, msg->msg, msg->len );
|
||||
msg->checksum = dutil_md5sum( comms->dutil, xwe, msg->msg, msg->len );
|
||||
#endif
|
||||
msg->next = (MsgQueueElem*)NULL;
|
||||
*prevsQueueNext = comms->msgQueueTail = msg;
|
||||
|
@ -808,7 +809,7 @@ sendConnect( CommsCtxt* comms, XWEnv xwe, XP_Bool breakExisting )
|
|||
set_relay_state( comms, xwe, COMMS_RELAYSTATE_UNCONNECTED );
|
||||
if ( !relayConnect( comms, xwe ) ) {
|
||||
XP_LOGF( "%s: relayConnect failed", __func__ );
|
||||
set_reset_timer( comms );
|
||||
set_reset_timer( comms, xwe );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1008,7 +1009,7 @@ comms_augmentHostAddr( CommsCtxt* comms, XWEnv xwe, const CommsAddrRec* addr )
|
|||
|
||||
CommsAddrRec tmp = comms->addr;
|
||||
augmentAddr( &tmp, addr );
|
||||
util_addrChange( comms->util, &comms->addr, &tmp );
|
||||
util_addrChange( comms->util, xwe, &comms->addr, &tmp );
|
||||
comms->addr = tmp;
|
||||
|
||||
logAddr( comms, xwe, &comms->addr, "after" );
|
||||
|
@ -1123,7 +1124,8 @@ comms_getInitialAddr( CommsAddrRec* addr
|
|||
} /* comms_getInitialAddr */
|
||||
|
||||
XP_Bool
|
||||
comms_checkAddr( DeviceRole role, const CommsAddrRec* addr, XW_UtilCtxt* util )
|
||||
comms_checkAddr( XWEnv xwe, DeviceRole role, const CommsAddrRec* addr,
|
||||
XW_UtilCtxt* util )
|
||||
{
|
||||
XP_Bool ok = XP_TRUE;
|
||||
/* make sure the user's given us enough information to make a connection */
|
||||
|
@ -1133,7 +1135,7 @@ comms_checkAddr( DeviceRole role, const CommsAddrRec* addr, XW_UtilCtxt* util )
|
|||
if ( !XP_MEMCMP( &empty, &addr->u.bt.btAddr, sizeof(empty) ) ) {
|
||||
ok = XP_FALSE;
|
||||
if ( !!util ) {
|
||||
util_userError( util, STR_NEED_BT_HOST_ADDR );
|
||||
util_userError( util, xwe, STR_NEED_BT_HOST_ADDR );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1217,7 +1219,7 @@ makeElemWithID( CommsCtxt* comms, XWEnv xwe, MsgID msgID, AddressRecord* rec,
|
|||
}
|
||||
|
||||
#ifdef COMMS_CHECKSUM
|
||||
newMsgElem->checksum = dutil_md5sum( comms->dutil, newMsgElem->msg,
|
||||
newMsgElem->checksum = dutil_md5sum( comms->dutil, xwe, newMsgElem->msg,
|
||||
newMsgElem->len );
|
||||
#endif
|
||||
return newMsgElem;
|
||||
|
@ -1249,7 +1251,7 @@ comms_send( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream )
|
|||
XP_PlayerAddr channelNo = stream_getAddress( stream );
|
||||
CNO_FMT( cbuf, channelNo );
|
||||
XP_LOGF( "%s: %s", __func__, cbuf );
|
||||
AddressRecord* rec = getRecordFor( comms, NULL, channelNo, XP_FALSE );
|
||||
AddressRecord* rec = getRecordFor( comms, xwe, NULL, channelNo, XP_FALSE );
|
||||
MsgID msgID = (!!rec)? ++rec->nextMsgID : 0;
|
||||
MsgQueueElem* elem;
|
||||
|
||||
|
@ -1386,7 +1388,7 @@ removeFromQueue( CommsCtxt* comms, XWEnv xwe, XP_PlayerAddr channelNo, MsgID msg
|
|||
XP_LOGF( "%s(channelNo=%d): remove msgs <= " XP_LD " for %s (queueLen: %d)",
|
||||
__func__, channelNo, msgID, cbuf, comms->queueLen );
|
||||
|
||||
if ((channelNo == 0) || !!getRecordFor( comms, NULL, channelNo, XP_FALSE)) {
|
||||
if ((channelNo == 0) || !!getRecordFor( comms, xwe, NULL, channelNo, XP_FALSE)) {
|
||||
|
||||
MsgQueueElem* elem = comms->msgQueueHead;
|
||||
MsgQueueElem* next;
|
||||
|
@ -1466,7 +1468,7 @@ sendMsg( CommsCtxt* comms, XWEnv xwe, MsgQueueElem* elem, const CommsConnType fi
|
|||
|
||||
CommsAddrRec addr;
|
||||
const CommsAddrRec* addrP;
|
||||
(void)channelToAddress( comms, channelNo, &addrP );
|
||||
(void)channelToAddress( comms, xwe, channelNo, &addrP );
|
||||
if ( NULL == addrP ) {
|
||||
XP_LOGF( TAGFMT() "no addr for channel so using comms'", TAGPRMS );
|
||||
comms_getAddr( comms, &addr );
|
||||
|
@ -1576,7 +1578,7 @@ resendImpl( CommsCtxt* comms, XWEnv xwe, CommsConnType filter, XP_Bool force,
|
|||
XP_Bool success = XP_TRUE;
|
||||
XP_ASSERT( !!comms );
|
||||
|
||||
XP_U32 now = dutil_getCurSeconds( comms->dutil );
|
||||
XP_U32 now = dutil_getCurSeconds( comms->dutil, xwe );
|
||||
if ( !force && (now < comms->nextResend) ) {
|
||||
XP_LOGF( "%s: aborting: %d seconds left in backoff", __func__,
|
||||
comms->nextResend - now );
|
||||
|
@ -1725,7 +1727,7 @@ got_connect_cmd( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream,
|
|||
if ( isServer != comms->isServer ) {
|
||||
XP_LOGF( "%s: becoming%s a server", __func__, isServer ? "" : " NOT" );
|
||||
comms->isServer = isServer;
|
||||
util_setIsServer( comms->util, comms->isServer );
|
||||
util_setIsServer( comms->util, xwe, comms->isServer );
|
||||
|
||||
reset_internal( comms, xwe, isServer, comms->rr.nPlayersHere,
|
||||
comms->rr.nPlayersTotal, XP_FALSE );
|
||||
|
@ -1766,7 +1768,7 @@ got_connect_cmd( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream,
|
|||
}
|
||||
if ( ID_TYPE_NONE == typ /* error case */
|
||||
|| '\0' != devID[0] ) /* new info case */ {
|
||||
dutil_deviceRegistered( comms->dutil, typ, devID );
|
||||
dutil_deviceRegistered( comms->dutil, xwe, typ, devID );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1904,7 +1906,7 @@ relayPreProcess( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream, XWHostID* se
|
|||
} else {
|
||||
set_relay_state( comms, xwe, COMMS_RELAYSTATE_RECONNECTED );
|
||||
/* we will eventually want to tell the user which player's gone */
|
||||
util_userError( comms->util, ERR_RELAY_BASE + relayErr );
|
||||
util_userError( comms->util, xwe, ERR_RELAY_BASE + relayErr );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1912,7 +1914,7 @@ relayPreProcess( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream, XWHostID* se
|
|||
case XWRELAY_DISCONNECT_YOU: /* Close socket for this? */
|
||||
relayErr = stream_getU8( stream );
|
||||
set_relay_state( comms, xwe, COMMS_RELAYSTATE_UNCONNECTED );
|
||||
util_userError( comms->util, ERR_RELAY_BASE + relayErr );
|
||||
util_userError( comms->util, xwe, ERR_RELAY_BASE + relayErr );
|
||||
break;
|
||||
|
||||
case XWRELAY_MSG_STATUS:
|
||||
|
@ -1928,7 +1930,7 @@ relayPreProcess( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream, XWHostID* se
|
|||
if ( XWRELAY_ERROR_NORECONN == relayErr ) {
|
||||
init_relay( comms, xwe, comms->rr.nPlayersHere, comms->rr.nPlayersTotal );
|
||||
} else {
|
||||
util_userError( comms->util, ERR_RELAY_BASE + relayErr );
|
||||
util_userError( comms->util, xwe, ERR_RELAY_BASE + relayErr );
|
||||
/* requires action, not just notification */
|
||||
(*comms->procs.rerror)( xwe, comms->procs.closure, relayErr );
|
||||
}
|
||||
|
@ -1949,7 +1951,7 @@ relayPreProcess( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream, XWHostID* se
|
|||
static void
|
||||
noteHBReceived( CommsCtxt* comms/* , const CommsAddrRec* addr */ )
|
||||
{
|
||||
comms->lastMsgRcvdTime = dutil_getCurSeconds( comms->dutil );
|
||||
comms->lastMsgRcvdTime = dutil_getCurSeconds( comms->dutil, xwe );
|
||||
setHeartbeatTimer( comms );
|
||||
}
|
||||
#else
|
||||
|
@ -2028,7 +2030,7 @@ preProcess( CommsCtxt* comms, XWEnv xwe, const CommsAddrRec* useAddr,
|
|||
} /* preProcess */
|
||||
|
||||
static AddressRecord*
|
||||
getRecordFor( CommsCtxt* comms, const CommsAddrRec* addr,
|
||||
getRecordFor( CommsCtxt* comms, XWEnv xwe, const CommsAddrRec* addr,
|
||||
const XP_PlayerAddr channelNo, XP_Bool maskChannel )
|
||||
{
|
||||
LOG_FUNC();
|
||||
|
@ -2083,8 +2085,8 @@ getRecordFor( CommsCtxt* comms, const CommsAddrRec* addr,
|
|||
case COMMS_CONN_SMS:
|
||||
#ifdef XWFEATURE_SMS
|
||||
{
|
||||
XW_DUtilCtxt* duc = util_getDevUtilCtxt( comms->util );
|
||||
if ( dutil_phoneNumbersSame( duc, addr->u.sms.phone,
|
||||
XW_DUtilCtxt* duc = util_getDevUtilCtxt( comms->util, xwe );
|
||||
if ( dutil_phoneNumbersSame( duc, xwe, addr->u.sms.phone,
|
||||
rec->addr.u.sms.phone )
|
||||
&& addr->u.sms.port == rec->addr.u.sms.port ) {
|
||||
matched = XP_TRUE;
|
||||
|
@ -2163,7 +2165,7 @@ validateInitialMessage( CommsCtxt* comms, XWEnv xwe,
|
|||
} else if ( comms->doHeartbeat ) {
|
||||
XP_Bool addRec = XP_FALSE;
|
||||
/* This (with mask) is untested!!! */
|
||||
rec = getRecordFor( comms, addr, *channelNo, XP_TRUE );
|
||||
rec = getRecordFor( comms, xwe, addr, *channelNo, XP_TRUE );
|
||||
|
||||
if ( hasPayload ) {
|
||||
if ( rec ) {
|
||||
|
@ -2201,7 +2203,7 @@ validateInitialMessage( CommsCtxt* comms, XWEnv xwe,
|
|||
} else {
|
||||
CNO_FMT( cbuf, *channelNo );
|
||||
XP_LOGF( TAGFMT() "looking at %s", TAGPRMS, cbuf );
|
||||
rec = getRecordFor( comms, addr, *channelNo, XP_TRUE );
|
||||
rec = getRecordFor( comms, xwe, addr, *channelNo, XP_TRUE );
|
||||
if ( !!rec ) {
|
||||
augmentChannelAddr( rec, addr, senderID );
|
||||
/* reject: we've already seen init message on channel */
|
||||
|
@ -2274,7 +2276,7 @@ validateChannelMessage( CommsCtxt* comms, XWEnv xwe, const CommsAddrRec* addr,
|
|||
AddressRecord* rec;
|
||||
LOG_FUNC();
|
||||
|
||||
rec = getRecordFor( comms, NULL, channelNo, XP_FALSE );
|
||||
rec = getRecordFor( comms, xwe, NULL, channelNo, XP_FALSE );
|
||||
if ( !!rec ) {
|
||||
removeFromQueue( comms, xwe, channelNo, lastMsgRcd );
|
||||
|
||||
|
@ -2345,7 +2347,7 @@ comms_checkIncomingStream( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream,
|
|||
XP_U16 len = stream_getSize( stream );
|
||||
// stream_getPtr pts at base, but sum excludes relay header
|
||||
const XP_U8* ptr = initialLen - len + stream_getPtr( stream );
|
||||
XP_UCHAR* sum = dutil_md5sum( comms->dutil, ptr, len );
|
||||
XP_UCHAR* sum = dutil_md5sum( comms->dutil, xwe, ptr, len );
|
||||
XP_LOGF( TAGFMT() "got message of len %d with sum %s",
|
||||
TAGPRMS, len, sum );
|
||||
XP_FREE( comms->mpool, sum );
|
||||
|
@ -2452,7 +2454,7 @@ comms_msgProcessed( CommsCtxt* comms, XWEnv xwe,
|
|||
XP_LOGFF( "msg rejected; NOT upping lastMsgRcd to %d", state->msgID );
|
||||
#endif
|
||||
} else {
|
||||
AddressRecord* rec = getRecordFor( comms, NULL, state->channelNo, XP_TRUE );
|
||||
AddressRecord* rec = getRecordFor( comms, xwe, NULL, state->channelNo, XP_TRUE );
|
||||
XP_ASSERT( !!rec );
|
||||
if ( !!rec && rec->lastMsgRcd < state->msgID ) {
|
||||
#ifdef LOG_COMMS_MSGNOS
|
||||
|
@ -2567,7 +2569,7 @@ heartbeat_checks( CommsCtxt* comms )
|
|||
|
||||
do {
|
||||
if ( comms->lastMsgRcvdTime > 0 ) {
|
||||
XP_U32 now = dutil_getCurSeconds( comms->dutil );
|
||||
XP_U32 now = dutil_getCurSeconds( comms->dutil, xwe );
|
||||
XP_U32 tooLongAgo = now - (HB_INTERVAL * 2);
|
||||
if ( comms->lastMsgRcvdTime < tooLongAgo ) {
|
||||
XP_LOGF( "%s: calling reset proc; last was %ld secs too long "
|
||||
|
@ -2641,7 +2643,7 @@ setHeartbeatTimer( CommsCtxt* comms )
|
|||
}
|
||||
#endif
|
||||
if ( when != 0 ) {
|
||||
util_setTimer( comms->util, TIMER_COMMS, when,
|
||||
util_setTimer( comms->util, xwe, TIMER_COMMS, when,
|
||||
p_comms_timerFired, comms );
|
||||
comms->hbTimerPending = XP_TRUE;
|
||||
}
|
||||
|
@ -2735,7 +2737,7 @@ rememberChannelAddress( CommsCtxt* comms, XWEnv xwe, XP_PlayerAddr channelNo,
|
|||
|
||||
logAddr( comms, xwe, addr, __func__ );
|
||||
AddressRecord* rec = NULL;
|
||||
rec = getRecordFor( comms, NULL, channelNo, XP_FALSE );
|
||||
rec = getRecordFor( comms, xwe, NULL, channelNo, XP_FALSE );
|
||||
if ( !rec ) {
|
||||
/* not found; add a new entry */
|
||||
rec = (AddressRecord*)XP_CALLOC( comms->mpool, sizeof(*rec) );
|
||||
|
@ -2911,10 +2913,10 @@ augmentAddr( CommsAddrRec* destAddr, const CommsAddrRec* srcAddr )
|
|||
}
|
||||
|
||||
static XP_Bool
|
||||
channelToAddress( CommsCtxt* comms, XP_PlayerAddr channelNo,
|
||||
channelToAddress( CommsCtxt* comms, XWEnv xwe, XP_PlayerAddr channelNo,
|
||||
const CommsAddrRec** addr )
|
||||
{
|
||||
AddressRecord* recs = getRecordFor( comms, NULL, channelNo, XP_FALSE );
|
||||
AddressRecord* recs = getRecordFor( comms, xwe, NULL, channelNo, XP_FALSE );
|
||||
XP_Bool found = !!recs;
|
||||
*addr = found? &recs->addr : NULL;
|
||||
return found;
|
||||
|
@ -3119,7 +3121,7 @@ relay_msg_to_stream( CommsCtxt* comms, XWEnv xwe, XWRELAY_Cmd cmd, XWHostID dest
|
|||
stream_putU8( stream, comms->rr.nPlayersTotal );
|
||||
stream_putU16( stream, comms_getChannelSeed(comms) );
|
||||
stream_putU8( stream, comms->util->gameInfo->dictLang );
|
||||
putDevID( comms, stream );
|
||||
putDevID( comms, xwe, stream );
|
||||
stream_putU8( stream, comms->forceChannel ); /* "clientIndx" on relay */
|
||||
|
||||
set_relay_state( comms, xwe, COMMS_RELAYSTATE_CONNECT_PENDING );
|
||||
|
@ -3143,7 +3145,7 @@ relay_msg_to_stream( CommsCtxt* comms, XWEnv xwe, XWRELAY_Cmd cmd, XWHostID dest
|
|||
stream_putU16( stream, comms_getChannelSeed(comms) );
|
||||
stream_putU8( stream, comms->util->gameInfo->dictLang );
|
||||
stringToStream( stream, comms->rr.connName );
|
||||
putDevID( comms, stream );
|
||||
putDevID( comms, xwe, stream );
|
||||
set_relay_state( comms, xwe, COMMS_RELAYSTATE_CONNECT_PENDING );
|
||||
break;
|
||||
|
||||
|
@ -3259,7 +3261,7 @@ relayConnect( CommsCtxt* comms, XWEnv xwe )
|
|||
comms_getAddr( comms, &addr );
|
||||
DevIDType ignored; /* but should it be? */
|
||||
(*comms->procs.requestJoin)( comms->procs.closure,
|
||||
util_getDevID( comms->util, &ignored ),
|
||||
util_getDevID( comms->util, xwe, &ignored ),
|
||||
addr.u.ip_relay.invite, /* room */
|
||||
comms->rr.nPlayersHere,
|
||||
comms->rr.nPlayersTotal,
|
||||
|
@ -3292,7 +3294,7 @@ send_via_bt_or_ip( CommsCtxt* comms, XWEnv xwe, BTIPMsgType msgTyp, XP_PlayerAdd
|
|||
buf = XP_MALLOC( comms->mpool, dlen + 1 );
|
||||
if ( !!buf ) {
|
||||
const CommsAddrRec* addr;
|
||||
(void)channelToAddress( comms, channelNo, &addr );
|
||||
(void)channelToAddress( comms, xwe, channelNo, &addr );
|
||||
|
||||
buf[0] = msgTyp;
|
||||
if ( dlen > 0 ) {
|
||||
|
@ -3327,11 +3329,11 @@ relayDisconnect( CommsCtxt* comms, XWEnv xwe )
|
|||
|
||||
#ifdef XWFEATURE_DEVID
|
||||
static void
|
||||
putDevID( const CommsCtxt* comms, XWStreamCtxt* stream )
|
||||
putDevID( const CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream )
|
||||
{
|
||||
# if XWRELAY_PROTO_VERSION >= XWRELAY_PROTO_VERSION_CLIENTID
|
||||
DevIDType typ;
|
||||
const XP_UCHAR* devID = dutil_getDevID( comms->dutil, &typ );
|
||||
const XP_UCHAR* devID = dutil_getDevID( comms->dutil, xwe, &typ );
|
||||
XP_ASSERT( ID_TYPE_NONE <= typ && typ < ID_TYPE_NTYPES );
|
||||
stream_putU8( stream, typ );
|
||||
if ( ID_TYPE_NONE != typ ) {
|
||||
|
|
|
@ -192,7 +192,7 @@ void comms_reset( CommsCtxt* comms, XWEnv xwe, XP_Bool isServer,
|
|||
void comms_resetSame( CommsCtxt* comms, XWEnv xwe );
|
||||
void comms_transportFailed( CommsCtxt* comms, XWEnv xwe, CommsConnType failed );
|
||||
|
||||
void comms_destroy( CommsCtxt* comms );
|
||||
void comms_destroy( CommsCtxt* comms, XWEnv xwe );
|
||||
|
||||
void comms_setConnID( CommsCtxt* comms, XP_U32 connID );
|
||||
|
||||
|
@ -203,7 +203,7 @@ void comms_getInitialAddr( CommsAddrRec* addr
|
|||
, XP_U16 relayPort
|
||||
#endif
|
||||
);
|
||||
XP_Bool comms_checkAddr( DeviceRole role, const CommsAddrRec* addr,
|
||||
XP_Bool comms_checkAddr( XWEnv xwe, DeviceRole role, const CommsAddrRec* addr,
|
||||
XW_UtilCtxt* util );
|
||||
|
||||
void comms_getAddr( const CommsCtxt* comms, CommsAddrRec* addr );
|
||||
|
|
|
@ -39,13 +39,13 @@ mkStream( XW_DUtilCtxt* dutil )
|
|||
}
|
||||
|
||||
static DevCtxt*
|
||||
load( XW_DUtilCtxt* dutil )
|
||||
load( XW_DUtilCtxt* dutil, XWEnv xwe )
|
||||
{
|
||||
LOG_FUNC();
|
||||
DevCtxt* state = (DevCtxt*)dutil->devCtxt;
|
||||
if ( NULL == state ) {
|
||||
XWStreamCtxt* stream = mkStream( dutil );
|
||||
dutil_loadStream( dutil, KEY_DEVSTATE, stream );
|
||||
dutil_loadStream( dutil, xwe, KEY_DEVSTATE, stream );
|
||||
|
||||
state = XP_CALLOC( dutil->mpool, sizeof(*state) );
|
||||
dutil->devCtxt = state;
|
||||
|
@ -64,13 +64,13 @@ load( XW_DUtilCtxt* dutil )
|
|||
}
|
||||
|
||||
void
|
||||
device_store( XW_DUtilCtxt* dutil )
|
||||
device_store( XW_DUtilCtxt* dutil, XWEnv xwe )
|
||||
{
|
||||
LOG_FUNC();
|
||||
DevCtxt* state = load( dutil );
|
||||
DevCtxt* state = load( dutil, xwe );
|
||||
XWStreamCtxt* stream = mkStream( dutil );
|
||||
stream_putU16( stream, state->devCount );
|
||||
dutil_storeStream( dutil, KEY_DEVSTATE, stream );
|
||||
dutil_storeStream( dutil, xwe, KEY_DEVSTATE, stream );
|
||||
stream_destroy( stream, NULL );
|
||||
|
||||
XP_FREEP( dutil->mpool, &dutil->devCtxt );
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
// void device_load( XW_DUtilCtxt dctxt );
|
||||
# ifdef XWFEATURE_DEVICE
|
||||
void device_store( XW_DUtilCtxt* dctxt );
|
||||
void device_store( XW_DUtilCtxt* dctxt, XWEnv xwe );
|
||||
# else
|
||||
# define device_store(dctxt)
|
||||
# define device_store(dctxt, xwe)
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,8 +30,8 @@ extern "C" {
|
|||
# define SCROLL_DRAG_THRESHHOLD 1
|
||||
#endif
|
||||
|
||||
static XP_Bool dragDropContinueImpl( BoardCtxt* board, XP_U16 xx, XP_U16 yy,
|
||||
BoardObjectType* onWhichP );
|
||||
static XP_Bool dragDropContinueImpl( BoardCtxt* board, XWEnv xwe, XP_U16 xx,
|
||||
XP_U16 yy, BoardObjectType* onWhichP );
|
||||
static void invalDragObjRange( BoardCtxt* board, const DragObjInfo* from,
|
||||
const DragObjInfo* to );
|
||||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
|
@ -49,7 +49,7 @@ static void crosshairs_clear( BoardCtxt* board );
|
|||
# define crosshairs_clear( board )
|
||||
#endif
|
||||
|
||||
static void startScrollTimerIf( BoardCtxt* board );
|
||||
static void startScrollTimerIf( BoardCtxt* board, XWEnv xwe );
|
||||
|
||||
XP_Bool
|
||||
dragDropInProgress( const BoardCtxt* board )
|
||||
|
@ -84,7 +84,7 @@ clearDS( DragState* ds )
|
|||
}
|
||||
|
||||
static XP_Bool
|
||||
ddStartBoard( BoardCtxt* board, XP_U16 xx, XP_U16 yy )
|
||||
ddStartBoard( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy )
|
||||
{
|
||||
DragState* ds = &board->dragState;
|
||||
XP_Bool trayVisible;
|
||||
|
@ -128,7 +128,7 @@ ddStartBoard( BoardCtxt* board, XP_U16 xx, XP_U16 yy )
|
|||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
} else if ( !board->gi->hintsNotAllowed && board->gi->allowHintRect
|
||||
&& trayVisible ) {
|
||||
if ( !util_altKeyDown(board->util) ) {
|
||||
if ( !util_altKeyDown(board->util, xwe) ) {
|
||||
ds->dtype = DT_HINTRGN;
|
||||
} else if ( canScroll ) {
|
||||
ds->dtype = DT_BOARD;
|
||||
|
@ -185,7 +185,7 @@ ddStartTray( BoardCtxt* board, XP_U16 x, XP_U16 y )
|
|||
* tray.
|
||||
*/
|
||||
XP_Bool
|
||||
dragDropStart( BoardCtxt* board, BoardObjectType obj, XP_U16 x, XP_U16 y )
|
||||
dragDropStart( BoardCtxt* board, XWEnv xwe, BoardObjectType obj, XP_U16 xx, XP_U16 yy )
|
||||
{
|
||||
XP_Bool result = XP_FALSE;
|
||||
DragState* ds = &board->dragState;
|
||||
|
@ -197,9 +197,9 @@ dragDropStart( BoardCtxt* board, BoardObjectType obj, XP_U16 x, XP_U16 y )
|
|||
ds->start.obj = obj;
|
||||
|
||||
if ( OBJ_BOARD == obj ) {
|
||||
result = ddStartBoard( board, x, y );
|
||||
result = ddStartBoard( board, xwe, xx, yy );
|
||||
} else if ( OBJ_TRAY == obj ) {
|
||||
result = ddStartTray( board, x, y );
|
||||
result = ddStartTray( board, xx, yy );
|
||||
} else {
|
||||
XP_ASSERT(0);
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ dragDropStart( BoardCtxt* board, BoardObjectType obj, XP_U16 x, XP_U16 y )
|
|||
if ( result ) {
|
||||
ds->cur = ds->start;
|
||||
invalDragObj( board, &ds->start );
|
||||
startScrollTimerIf( board );
|
||||
startScrollTimerIf( board, xwe );
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -229,22 +229,22 @@ dragDropStart( BoardCtxt* board, BoardObjectType obj, XP_U16 x, XP_U16 y )
|
|||
* just change it every time we can.
|
||||
*/
|
||||
XP_Bool
|
||||
dragDropContinue( BoardCtxt* board, XP_U16 xx, XP_U16 yy )
|
||||
dragDropContinue( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy )
|
||||
{
|
||||
XP_ASSERT( dragDropInProgress(board) );
|
||||
|
||||
return dragDropContinueImpl( board, xx, yy, NULL );
|
||||
return dragDropContinueImpl( board, xwe, xx, yy, NULL );
|
||||
}
|
||||
|
||||
XP_Bool
|
||||
dragDropEnd( BoardCtxt* board, XP_U16 xx, XP_U16 yy, XP_Bool* draggedP )
|
||||
dragDropEnd( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy, XP_Bool* draggedP )
|
||||
{
|
||||
DragState* ds = &board->dragState;
|
||||
BoardObjectType newObj;
|
||||
|
||||
XP_ASSERT( dragDropInProgress(board) );
|
||||
|
||||
(void)dragDropContinueImpl( board, xx, yy, &newObj );
|
||||
(void)dragDropContinueImpl( board, xwe, xx, yy, &newObj );
|
||||
if ( !!draggedP ) {
|
||||
*draggedP = ds->didMove;
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ dragDropEnd( BoardCtxt* board, XP_U16 xx, XP_U16 yy, XP_Bool* draggedP )
|
|||
|
||||
if ( newObj == OBJ_TRAY ) {
|
||||
if ( ds->start.obj == OBJ_BOARD ) { /* board->tray is pending */
|
||||
model_moveBoardToTray( board->model, board->selPlayer,
|
||||
model_moveBoardToTray( board->model, xwe, board->selPlayer,
|
||||
mod_startc, mod_startr,
|
||||
ds->cur.u.tray.index );
|
||||
} else {
|
||||
|
@ -295,14 +295,14 @@ dragDropEnd( BoardCtxt* board, XP_U16 xx, XP_U16 yy, XP_Bool* draggedP )
|
|||
ds->cur.u.board.row, XP_TRUE ) ) {
|
||||
if ( ds->start.obj == OBJ_TRAY ) {
|
||||
/* moveTileToBoard flips its inputs */
|
||||
(void)moveTileToBoard( board, ds->cur.u.board.col,
|
||||
(void)moveTileToBoard( board, xwe, ds->cur.u.board.col,
|
||||
ds->cur.u.board.row,
|
||||
ds->start.u.tray.index, EMPTY_TILE );
|
||||
} else if ( ds->start.obj == OBJ_BOARD ) {
|
||||
XP_U16 mod_curc, mod_curr;
|
||||
flipIf( board, ds->cur.u.board.col, ds->cur.u.board.row,
|
||||
&mod_curc, &mod_curr );
|
||||
if ( model_moveTileOnBoard( board->model, board->selPlayer,
|
||||
if ( model_moveTileOnBoard( board->model, xwe, board->selPlayer,
|
||||
mod_startc, mod_startr, mod_curc,
|
||||
mod_curr ) ) {
|
||||
/* inval points tile in case score changed */
|
||||
|
@ -329,7 +329,7 @@ dragDropEnd( BoardCtxt* board, XP_U16 xx, XP_U16 yy, XP_Bool* draggedP )
|
|||
|
||||
#ifdef XWFEATURE_RAISETILE
|
||||
XP_Bool
|
||||
dragDropSetAdd( BoardCtxt* board )
|
||||
dragDropSetAdd( BoardCtxt* board, XWEnv xwe )
|
||||
{
|
||||
DragState* ds = &board->dragState;
|
||||
XP_Bool draw;
|
||||
|
@ -338,7 +338,7 @@ dragDropSetAdd( BoardCtxt* board )
|
|||
if ( draw ) {
|
||||
if ( draw ) {
|
||||
ds->yyAdd = (board->trayBounds.height * 2) / 3;
|
||||
draw = dragDropContinueImpl( board, board->penDownX,
|
||||
draw = dragDropContinueImpl( board, xwe, board->penDownX,
|
||||
board->penDownY, NULL );
|
||||
}
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ invalHintRectDiffs( BoardCtxt* board, const DragObjInfo* cur,
|
|||
#endif
|
||||
|
||||
static XP_Bool
|
||||
dragDropContinueImpl( BoardCtxt* board, XP_U16 xx, XP_U16 yy,
|
||||
dragDropContinueImpl( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy,
|
||||
BoardObjectType* onWhichP )
|
||||
{
|
||||
XP_Bool moving = XP_FALSE;
|
||||
|
@ -532,7 +532,7 @@ dragDropContinueImpl( BoardCtxt* board, XP_U16 xx, XP_U16 yy,
|
|||
ds->cellChanged = XP_TRUE;
|
||||
}
|
||||
diff /= SCROLL_DRAG_THRESHHOLD;
|
||||
moving = adjustYOffset( board, diff ) || moving;
|
||||
moving = adjustYOffset( board, xwe, diff ) || moving;
|
||||
}
|
||||
} else if ( ds->dtype == DT_TILE ) {
|
||||
if ( newInfo.obj == OBJ_BOARD ) {
|
||||
|
@ -572,7 +572,7 @@ dragDropContinueImpl( BoardCtxt* board, XP_U16 xx, XP_U16 yy,
|
|||
}
|
||||
|
||||
XP_MEMCPY( &ds->cur, &newInfo, sizeof(ds->cur) );
|
||||
startScrollTimerIf( board );
|
||||
startScrollTimerIf( board, xwe );
|
||||
}
|
||||
} else {
|
||||
XP_ASSERT( 0 );
|
||||
|
@ -651,10 +651,10 @@ scrollTimerProc( void* closure, XWEnv xwe, XWTimerReason XP_UNUSED_DBG(why) )
|
|||
if ( 0 != changeY ) {
|
||||
ds->cur.u.board.row += (changeY >0 ? 1 : -1);
|
||||
}
|
||||
if ( scrollIntoView( board, ds->cur.u.board.col,
|
||||
if ( scrollIntoView( board, xwe, ds->cur.u.board.col,
|
||||
ds->cur.u.board.row ) ) {
|
||||
board_draw( board, xwe ); /* may fail, e.g. on wince */
|
||||
startScrollTimerIf( board );
|
||||
startScrollTimerIf( board, xwe );
|
||||
draw = XP_TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -663,7 +663,7 @@ scrollTimerProc( void* closure, XWEnv xwe, XWTimerReason XP_UNUSED_DBG(why) )
|
|||
} /* scrollTimerProc */
|
||||
|
||||
static void
|
||||
startScrollTimerIf( BoardCtxt* board )
|
||||
startScrollTimerIf( BoardCtxt* board, XWEnv xwe )
|
||||
{
|
||||
DragState* ds = &board->dragState;
|
||||
|
||||
|
@ -672,7 +672,7 @@ startScrollTimerIf( BoardCtxt* board )
|
|||
if ( onBorderCanScroll( board, SCROLL_H, ds->cur.u.board.col, &ignore )
|
||||
|| onBorderCanScroll( board, SCROLL_V, ds->cur.u.board.row,
|
||||
&ignore ) ) {
|
||||
util_setTimer( board->util, TIMER_PENDOWN, 0,
|
||||
util_setTimer( board->util, xwe, TIMER_PENDOWN, 0,
|
||||
scrollTimerProc, (void*) board );
|
||||
ds->scrollTimerSet = XP_TRUE;
|
||||
} else {
|
||||
|
|
|
@ -31,10 +31,11 @@ extern "C" {
|
|||
XP_Bool dragDropInProgress( const BoardCtxt* board );
|
||||
XP_Bool dragDropHasMoved( const BoardCtxt* board );
|
||||
|
||||
XP_Bool dragDropStart( BoardCtxt* board, BoardObjectType obj,
|
||||
XP_Bool dragDropStart( BoardCtxt* board, XWEnv xwe, BoardObjectType obj,
|
||||
XP_U16 xx, XP_U16 yy );
|
||||
XP_Bool dragDropContinue( BoardCtxt* board, XP_U16 xx, XP_U16 yy );
|
||||
XP_Bool dragDropEnd( BoardCtxt* board, XP_U16 xx, XP_U16 yy, XP_Bool* dragged );
|
||||
XP_Bool dragDropContinue( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy );
|
||||
XP_Bool dragDropEnd( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy,
|
||||
XP_Bool* dragged );
|
||||
|
||||
#ifdef XWFEATURE_RAISETILE
|
||||
XP_Bool dragDropSetAdd( BoardCtxt* board );
|
||||
|
|
|
@ -32,40 +32,41 @@ typedef enum { UNPAUSED,
|
|||
} DupPauseType;
|
||||
|
||||
typedef struct _DUtilVtable {
|
||||
XP_U32 (*m_dutil_getCurSeconds)( XW_DUtilCtxt* duc );
|
||||
const XP_UCHAR* (*m_dutil_getUserString)( XW_DUtilCtxt* duc,
|
||||
XP_U32 (*m_dutil_getCurSeconds)( XW_DUtilCtxt* duc, XWEnv xwe );
|
||||
const XP_UCHAR* (*m_dutil_getUserString)( XW_DUtilCtxt* duc, XWEnv xwe,
|
||||
XP_U16 stringCode );
|
||||
const XP_UCHAR* (*m_dutil_getUserQuantityString)( XW_DUtilCtxt* duc,
|
||||
XWEnv xwe,
|
||||
XP_U16 stringCode,
|
||||
XP_U16 quantity );
|
||||
void (*m_dutil_storeStream)( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
||||
void (*m_dutil_storeStream)( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||
XWStreamCtxt* data );
|
||||
/* Pass in an empty stream, and it'll be returned full */
|
||||
void (*m_dutil_loadStream)( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
||||
void (*m_dutil_loadStream)( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||
XWStreamCtxt* inOut );
|
||||
void (*m_dutil_storePtr)( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
||||
void (*m_dutil_storePtr)( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||
const void* data, XP_U16 len );
|
||||
void (*m_dutil_loadPtr)( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
||||
void (*m_dutil_loadPtr)( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||
void* data, XP_U16* lenp );
|
||||
#ifdef XWFEATURE_SMS
|
||||
XP_Bool (*m_dutil_phoneNumbersSame)( XW_DUtilCtxt* uc, const XP_UCHAR* p1,
|
||||
XP_Bool (*m_dutil_phoneNumbersSame)( XW_DUtilCtxt* uc, XWEnv xwe, const XP_UCHAR* p1,
|
||||
const XP_UCHAR* p2 );
|
||||
#endif
|
||||
|
||||
#ifdef XWFEATURE_DEVID
|
||||
const XP_UCHAR* (*m_dutil_getDevID)( XW_DUtilCtxt* duc, DevIDType* typ );
|
||||
void (*m_dutil_deviceRegistered)( XW_DUtilCtxt* duc, DevIDType typ,
|
||||
const XP_UCHAR* (*m_dutil_getDevID)( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType* typ );
|
||||
void (*m_dutil_deviceRegistered)( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType typ,
|
||||
const XP_UCHAR* idRelay );
|
||||
#endif
|
||||
|
||||
#ifdef COMMS_CHECKSUM
|
||||
XP_UCHAR* (*m_dutil_md5sum)( XW_DUtilCtxt* duc, const XP_U8* ptr, XP_U16 len );
|
||||
XP_UCHAR* (*m_dutil_md5sum)( XW_DUtilCtxt* duc, XWEnv xwe, const XP_U8* ptr, XP_U16 len );
|
||||
#endif
|
||||
|
||||
void (*m_dutil_notifyPause)( XW_DUtilCtxt* duc, XP_U32 gameID,
|
||||
void (*m_dutil_notifyPause)( XW_DUtilCtxt* duc, XWEnv xwe, XP_U32 gameID,
|
||||
DupPauseType pauseTyp, XP_U16 pauser,
|
||||
const XP_UCHAR* name, const XP_UCHAR* msg );
|
||||
void (*m_dutil_onDupTimerChanged)( XW_DUtilCtxt* duc, XP_U32 gameID,
|
||||
void (*m_dutil_onDupTimerChanged)( XW_DUtilCtxt* duc, XWEnv xwe, XP_U32 gameID,
|
||||
XP_U32 oldVal, XP_U32 newVal );
|
||||
} DUtilVtable;
|
||||
|
||||
|
@ -80,41 +81,42 @@ struct XW_DUtilCtxt {
|
|||
/* This one cheats: direct access */
|
||||
#define dutil_getVTManager(duc) (duc)->vtMgr
|
||||
|
||||
#define dutil_getCurSeconds(duc) \
|
||||
(duc)->vtable.m_dutil_getCurSeconds((duc))
|
||||
#define dutil_getUserString( duc, c ) \
|
||||
(duc)->vtable.m_dutil_getUserString((duc),(c))
|
||||
#define dutil_getUserQuantityString( duc, c, q ) \
|
||||
(duc)->vtable.m_dutil_getUserQuantityString((duc),(c),(q))
|
||||
#define dutil_getCurSeconds(duc, e) \
|
||||
(duc)->vtable.m_dutil_getCurSeconds((duc), (e))
|
||||
#define dutil_getUserString( duc, e, c ) \
|
||||
(duc)->vtable.m_dutil_getUserString((duc),(e), (c))
|
||||
#define dutil_getUserQuantityString( duc, e, c, q ) \
|
||||
(duc)->vtable.m_dutil_getUserQuantityString((duc),(e), (c),(q))
|
||||
|
||||
#define dutil_storeStream(duc, k, s) \
|
||||
(duc)->vtable.m_dutil_storeStream((duc), (k), (s));
|
||||
#define dutil_storePtr(duc, k, p, l) \
|
||||
(duc)->vtable.m_dutil_storePtr((duc), (k), (p), (l));
|
||||
#define dutil_loadStream(duc, k, s) \
|
||||
(duc)->vtable.m_dutil_loadStream((duc), (k), (s));
|
||||
#define dutil_loadPtr(duc, k, p, l) \
|
||||
(duc)->vtable.m_dutil_loadPtr((duc), (k), (p), (l));
|
||||
#define dutil_storeStream(duc, e,k, s) \
|
||||
(duc)->vtable.m_dutil_storeStream((duc), (e), (k), (s));
|
||||
#define dutil_storePtr(duc, e, k, p, l) \
|
||||
(duc)->vtable.m_dutil_storePtr((duc), (e), (k), (p), (l));
|
||||
#define dutil_loadStream(duc, e, k, s) \
|
||||
(duc)->vtable.m_dutil_loadStream((duc), (e), (k), (s));
|
||||
#define dutil_loadPtr(duc, e, k, p, l) \
|
||||
(duc)->vtable.m_dutil_loadPtr((duc), (e), (k), (p), (l));
|
||||
|
||||
#ifdef XWFEATURE_SMS
|
||||
# define dutil_phoneNumbersSame(duc,p1,p2) \
|
||||
(duc)->vtable.m_dutil_phoneNumbersSame( (duc), (p1), (p2) )
|
||||
# define dutil_phoneNumbersSame(duc,e,p1,p2) \
|
||||
(duc)->vtable.m_dutil_phoneNumbersSame( (duc), (e), (p1), (p2) )
|
||||
#endif
|
||||
|
||||
#ifdef XWFEATURE_DEVID
|
||||
# define dutil_getDevID( duc, t ) \
|
||||
(duc)->vtable.m_dutil_getDevID((duc),(t))
|
||||
# define dutil_deviceRegistered( duc, typ, id ) \
|
||||
(duc)->vtable.m_dutil_deviceRegistered( (duc), (typ), (id) )
|
||||
# define dutil_getDevID( duc, e, t ) \
|
||||
(duc)->vtable.m_dutil_getDevID((duc), (e),(t))
|
||||
# define dutil_deviceRegistered( duc, e, typ, id ) \
|
||||
(duc)->vtable.m_dutil_deviceRegistered( (duc), (e), (typ), (id) )
|
||||
#endif
|
||||
|
||||
#ifdef COMMS_CHECKSUM
|
||||
# define dutil_md5sum( duc, p, l ) (duc)->vtable.m_dutil_md5sum((duc), (p), (l))
|
||||
# define dutil_md5sum( duc, e, p, l ) \
|
||||
(duc)->vtable.m_dutil_md5sum((duc), (e), (p), (l))
|
||||
#endif
|
||||
|
||||
#define dutil_notifyPause( duc, id, ip, p, n, m ) \
|
||||
(duc)->vtable.m_dutil_notifyPause( (duc), (id), (ip), (p), (n), (m) )
|
||||
#define dutil_notifyPause( duc, e, id, ip, p, n, m ) \
|
||||
(duc)->vtable.m_dutil_notifyPause( (duc), (e), (id), (ip), (p), (n), (m) )
|
||||
|
||||
#define dutil_onDupTimerChanged(duc, id, ov, nv) \
|
||||
(duc)->vtable.m_dutil_onDupTimerChanged( (duc), (id), (ov), (nv))
|
||||
#define dutil_onDupTimerChanged(duc, e, id, ov, nv) \
|
||||
(duc)->vtable.m_dutil_onDupTimerChanged( (duc), (e), (id), (ov), (nv))
|
||||
#endif
|
||||
|
|
|
@ -123,30 +123,30 @@ struct EngineCtxt {
|
|||
MPSLOT
|
||||
}; /* EngineCtxt */
|
||||
|
||||
static void findMovesOneRow( EngineCtxt* engine );
|
||||
static void findMovesOneRow( EngineCtxt* engine, XWEnv xwe );
|
||||
static Tile localGetBoardTile( EngineCtxt* engine, XP_U16 col,
|
||||
XP_U16 row, XP_Bool substBlank );
|
||||
static void findMovesForAnchor( EngineCtxt* engine, XP_S16* prevAnchor,
|
||||
XP_U16 col, XP_U16 row ) ;
|
||||
static void findMovesForAnchor( EngineCtxt* engine, XWEnv xwe,
|
||||
XP_S16* prevAnchor, XP_U16 col, XP_U16 row ) ;
|
||||
static void figureCrosschecks( EngineCtxt* engine, XP_U16 col,
|
||||
XP_U16 row, XP_U16* scoreP,
|
||||
Crosscheck* check );
|
||||
static XP_Bool isAnchorSquare( EngineCtxt* engine, XP_U16 col, XP_U16 row );
|
||||
static array_edge* edge_from_tile( const DictionaryCtxt* dict,
|
||||
array_edge* from, Tile tile );
|
||||
static void leftPart( EngineCtxt* engine, Tile* tiles, XP_U16 tileLength,
|
||||
static void leftPart( EngineCtxt* engine, XWEnv xwe, Tile* tiles, XP_U16 tileLength,
|
||||
array_edge* edge, XP_U16 limit, XP_U16 firstCol,
|
||||
XP_U16 anchorCol, XP_U16 row );
|
||||
static void extendRight( EngineCtxt* engine, Tile* tiles, XP_U16 tileLength,
|
||||
static void extendRight( EngineCtxt* engine, XWEnv xwe, Tile* tiles, XP_U16 tileLength,
|
||||
array_edge* edge, XP_Bool accepting,
|
||||
XP_U16 firstCol, XP_U16 col, XP_U16 row );
|
||||
static array_edge* consumeFromLeft( EngineCtxt* engine, array_edge* edge,
|
||||
short col, short row );
|
||||
static XP_Bool rack_remove( EngineCtxt* engine, Tile tile, XP_Bool* isBlank );
|
||||
static void rack_replace( EngineCtxt* engine, Tile tile, XP_Bool isBlank );
|
||||
static void considerMove( EngineCtxt* engine, Tile* tiles, short tileLength,
|
||||
static void considerMove( EngineCtxt* engine, XWEnv xwe, Tile* tiles, short tileLength,
|
||||
short firstCol, short lastRow );
|
||||
static void considerScoreWordHasBlanks( EngineCtxt* engine, XP_U16 blanksLeft,
|
||||
static void considerScoreWordHasBlanks( EngineCtxt* engine, XWEnv xwe, XP_U16 blanksLeft,
|
||||
PossibleMove* posmove,
|
||||
XP_U16 lastRow,
|
||||
BlankTuple* usedBlanks,
|
||||
|
@ -170,8 +170,8 @@ static XP_S16 cmpMoves( PossibleMove* m1, PossibleMove* m2 );
|
|||
/* #define CROSSCHECK_CONTAINS(chk,tile) (((chk) & (1L<<(tile))) != 0) */
|
||||
#define CROSSCHECK_CONTAINS(chk,tile) checkIsSet( (chk), (tile) )
|
||||
|
||||
#define HILITE_CELL( engine, col, row ) \
|
||||
util_hiliteCell( (engine)->util, (col), (row) )
|
||||
#define HILITE_CELL( engine, xwe, col, row ) \
|
||||
util_hiliteCell( (engine)->util, (xwe), (col), (row) )
|
||||
|
||||
/* not implemented yet */
|
||||
XP_U16
|
||||
|
@ -377,7 +377,7 @@ normalizeIQ( EngineCtxt* engine, XP_U16 iq )
|
|||
* filled in in *newMove.
|
||||
*/
|
||||
XP_Bool
|
||||
engine_findMove( EngineCtxt* engine, const ModelCtxt* model,
|
||||
engine_findMove( EngineCtxt* engine, XWEnv xwe, const ModelCtxt* model,
|
||||
XP_S16 turn, XP_Bool includePending, XP_Bool skipCallback,
|
||||
const Tile* tiles, const XP_U16 nTiles, XP_Bool usePrev,
|
||||
#ifdef XWFEATURE_BONUSALL
|
||||
|
@ -410,7 +410,7 @@ engine_findMove( EngineCtxt* engine, const ModelCtxt* model,
|
|||
XP_U16 nTilesMin = engine->nTilesMinUser;
|
||||
XP_U16 nTilesMax = engine->nTilesMaxUser;
|
||||
|
||||
if ( util_getTraySearchLimits( engine->util,
|
||||
if ( util_getTraySearchLimits( engine->util, xwe,
|
||||
&nTilesMin, &nTilesMax ) ) {
|
||||
engine->tileLimitsKnown = XP_TRUE;
|
||||
engine->nTilesMinUser = nTilesMin;
|
||||
|
@ -454,7 +454,7 @@ engine_findMove( EngineCtxt* engine, const ModelCtxt* model,
|
|||
&& initTray( engine, tiles, nTiles );
|
||||
if ( canMove ) {
|
||||
|
||||
util_engineStarting( engine->util,
|
||||
util_engineStarting( engine->util, xwe,
|
||||
engine->rack[engine->blankTile] );
|
||||
|
||||
normalizeIQ( engine, robotIQ );
|
||||
|
@ -503,7 +503,7 @@ engine_findMove( EngineCtxt* engine, const ModelCtxt* model,
|
|||
if ( engine->isFirstMove && (engine->curRow != star_row)) {
|
||||
continue;
|
||||
}
|
||||
findMovesOneRow( engine );
|
||||
findMovesOneRow( engine, xwe );
|
||||
if ( engine->returnNOW ) {
|
||||
goto outer;
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ engine_findMove( EngineCtxt* engine, const ModelCtxt* model,
|
|||
XP_ASSERT( result );
|
||||
}
|
||||
|
||||
util_engineStopping( engine->util );
|
||||
util_engineStopping( engine->util, xwe );
|
||||
} else {
|
||||
/* set up a PASS. I suspect the caller should be deciding how to
|
||||
handle this case itself, but this doesn't preclude its doing
|
||||
|
@ -573,7 +573,7 @@ engine_findMove( EngineCtxt* engine, const ModelCtxt* model,
|
|||
} /* engine_findMove */
|
||||
|
||||
static void
|
||||
findMovesOneRow( EngineCtxt* engine )
|
||||
findMovesOneRow( EngineCtxt* engine, XWEnv xwe )
|
||||
{
|
||||
XP_U16 lastCol = engine->numCols - 1;
|
||||
XP_U16 col, row = engine->curRow;
|
||||
|
@ -614,7 +614,7 @@ findMovesOneRow( EngineCtxt* engine )
|
|||
for ( col = firstSearchCol; col <= lastSearchCol && !engine->returnNOW;
|
||||
++col ) {
|
||||
if ( isAnchorSquare( engine, col, row ) ) {
|
||||
findMovesForAnchor( engine, &prevAnchor, col, row );
|
||||
findMovesForAnchor( engine, xwe, &prevAnchor, col, row );
|
||||
}
|
||||
}
|
||||
} /* findMovesOneRow */
|
||||
|
@ -824,7 +824,7 @@ isAnchorSquare( EngineCtxt* engine, XP_U16 col, XP_U16 row )
|
|||
|
||||
#ifdef XWFEATURE_HILITECELL
|
||||
static void
|
||||
hiliteForAnchor( EngineCtxt* engine, XP_U16 col, XP_U16 row )
|
||||
hiliteForAnchor( EngineCtxt* engine, XWEnv xwe, XP_U16 col, XP_U16 row )
|
||||
{
|
||||
if ( !engine->searchHorizontal ) {
|
||||
XP_U16 tmp = col;
|
||||
|
@ -832,16 +832,16 @@ hiliteForAnchor( EngineCtxt* engine, XP_U16 col, XP_U16 row )
|
|||
row = tmp;
|
||||
}
|
||||
|
||||
if ( !HILITE_CELL( engine, col, row ) ) {
|
||||
if ( !HILITE_CELL( engine, xwe, col, row ) ) {
|
||||
engine->returnNOW = XP_TRUE;
|
||||
}
|
||||
} /* hiliteForAnchor */
|
||||
#else
|
||||
# define hiliteForAnchor( engine, col, row )
|
||||
# define hiliteForAnchor( engine, xwe, col, row )
|
||||
#endif
|
||||
|
||||
static void
|
||||
findMovesForAnchor( EngineCtxt* engine, XP_S16* prevAnchor,
|
||||
findMovesForAnchor( EngineCtxt* engine, XWEnv xwe, XP_S16* prevAnchor,
|
||||
XP_U16 col, XP_U16 row )
|
||||
{
|
||||
XP_S16 limit;
|
||||
|
@ -849,7 +849,7 @@ findMovesForAnchor( EngineCtxt* engine, XP_S16* prevAnchor,
|
|||
array_edge* topEdge;
|
||||
Tile tiles[MAX_ROWS];
|
||||
|
||||
hiliteForAnchor( engine, col, row );
|
||||
hiliteForAnchor( engine, xwe, col, row );
|
||||
|
||||
if ( engine->returnNOW ) {
|
||||
/* time to bail */
|
||||
|
@ -865,13 +865,13 @@ findMovesForAnchor( EngineCtxt* engine, XP_S16* prevAnchor,
|
|||
edge = topEdge;
|
||||
} else if ( localGetBoardTile( engine, col-1, row, XP_FALSE )
|
||||
== EMPTY_TILE ) {
|
||||
leftPart( engine, tiles, 0, topEdge, limit, col, col, row );
|
||||
leftPart( engine, xwe, tiles, 0, topEdge, limit, col, col, row );
|
||||
goto done;
|
||||
} else {
|
||||
edge = consumeFromLeft( engine, topEdge, col, row );
|
||||
}
|
||||
DEBUG_ASSIGN(engine->curLimit, 0);
|
||||
extendRight( engine, tiles, 0, edge,
|
||||
extendRight( engine, xwe, tiles, 0, edge,
|
||||
XP_FALSE, // can't accept without the anchor square
|
||||
col-limit, col, row );
|
||||
|
||||
|
@ -913,13 +913,13 @@ consumeFromLeft( EngineCtxt* engine, array_edge* edge, short col, short row )
|
|||
} /* consumeFromLeft */
|
||||
|
||||
static void
|
||||
leftPart( EngineCtxt* engine, Tile* tiles, XP_U16 tileLength,
|
||||
leftPart( EngineCtxt* engine, XWEnv xwe, Tile* tiles, XP_U16 tileLength,
|
||||
array_edge* edge, XP_U16 limit, XP_U16 firstCol,
|
||||
XP_U16 anchorCol, XP_U16 row )
|
||||
{
|
||||
DEBUG_ASSIGN( engine->curLimit, tileLength );
|
||||
|
||||
extendRight( engine, tiles, tileLength, edge, XP_FALSE, firstCol,
|
||||
extendRight( engine, xwe, tiles, tileLength, edge, XP_FALSE, firstCol,
|
||||
anchorCol, row );
|
||||
if ( !engine->returnNOW ) {
|
||||
if ( (limit > 0) && (edge != NULL) ) {
|
||||
|
@ -930,7 +930,7 @@ leftPart( EngineCtxt* engine, Tile* tiles, XP_U16 tileLength,
|
|||
Tile tile = EDGETILE( engine->dict, edge );
|
||||
if ( rack_remove( engine, tile, &isBlank ) ) {
|
||||
tiles[tileLength] = tile;
|
||||
leftPart( engine, tiles, tileLength+1,
|
||||
leftPart( engine, xwe, tiles, tileLength+1,
|
||||
dict_follow( engine->dict, edge ),
|
||||
limit-1, firstCol-1, anchorCol, row );
|
||||
rack_replace( engine, tile, isBlank );
|
||||
|
@ -947,7 +947,7 @@ leftPart( EngineCtxt* engine, Tile* tiles, XP_U16 tileLength,
|
|||
} /* leftPart */
|
||||
|
||||
static void
|
||||
extendRight( EngineCtxt* engine, Tile* tiles, XP_U16 tileLength,
|
||||
extendRight( EngineCtxt* engine, XWEnv xwe, Tile* tiles, XP_U16 tileLength,
|
||||
array_edge* edge, XP_Bool accepting,
|
||||
XP_U16 firstCol, XP_U16 col, XP_U16 row )
|
||||
{
|
||||
|
@ -989,7 +989,7 @@ extendRight( EngineCtxt* engine, Tile* tiles, XP_U16 tileLength,
|
|||
XP_Bool isBlank;
|
||||
if ( rack_remove( engine, tile, &isBlank ) ) {
|
||||
tiles[tileLength] = tile;
|
||||
extendRight( engine, tiles, tileLength+1,
|
||||
extendRight( engine, xwe, tiles, tileLength+1,
|
||||
edge_from_tile( dict, edge, tile ),
|
||||
ISACCEPTING( dict, edge ), firstCol,
|
||||
col+1, row );
|
||||
|
@ -1009,7 +1009,7 @@ extendRight( EngineCtxt* engine, Tile* tiles, XP_U16 tileLength,
|
|||
|
||||
} else if ( (edge = dict_edge_with_tile( dict, edge, tile ) ) != NULL ) {
|
||||
accepting = ISACCEPTING( dict, edge );
|
||||
extendRight( engine, tiles, tileLength, dict_follow(dict, edge),
|
||||
extendRight( engine, xwe, tiles, tileLength, dict_follow(dict, edge),
|
||||
accepting, firstCol, col+1, row );
|
||||
goto no_check; /* don't do the check at the end */
|
||||
} else {
|
||||
|
@ -1021,7 +1021,7 @@ extendRight( EngineCtxt* engine, Tile* tiles, XP_U16 tileLength,
|
|||
&& tileLength >= engine->nTilesMin
|
||||
#endif
|
||||
) {
|
||||
considerMove( engine, tiles, tileLength, firstCol, row );
|
||||
considerMove( engine, xwe, tiles, tileLength, firstCol, row );
|
||||
}
|
||||
no_check:
|
||||
return;
|
||||
|
@ -1065,14 +1065,15 @@ rack_replace( EngineCtxt* engine, Tile tile, XP_Bool isBlank )
|
|||
} /* rack_replace */
|
||||
|
||||
static void
|
||||
considerMove( EngineCtxt* engine, Tile* tiles, XP_S16 tileLength,
|
||||
considerMove( EngineCtxt* engine, XWEnv xwe, Tile* tiles, XP_S16 tileLength,
|
||||
XP_S16 firstCol, XP_S16 lastRow )
|
||||
{
|
||||
PossibleMove posmove;
|
||||
short col;
|
||||
BlankTuple blankTuples[MAX_NUM_BLANKS];
|
||||
|
||||
if ( !engine->skipProgressCallback && !util_engineProgressCallback( engine->util ) ) {
|
||||
if ( !engine->skipProgressCallback
|
||||
&& !util_engineProgressCallback( engine->util, xwe ) ) {
|
||||
engine->returnNOW = XP_TRUE;
|
||||
} else {
|
||||
|
||||
|
@ -1098,7 +1099,7 @@ considerMove( EngineCtxt* engine, Tile* tiles, XP_S16 tileLength,
|
|||
posmove.moveInfo.isHorizontal = engine->searchHorizontal;
|
||||
posmove.moveInfo.commonCoord = (XP_U8)lastRow;
|
||||
|
||||
considerScoreWordHasBlanks( engine, engine->blankCount, &posmove,
|
||||
considerScoreWordHasBlanks( engine, xwe, engine->blankCount, &posmove,
|
||||
lastRow, blankTuples, 0 );
|
||||
}
|
||||
} /* considerMove */
|
||||
|
@ -1113,7 +1114,7 @@ countWords( const WNParams* wnp, void* closure )
|
|||
}
|
||||
|
||||
static void
|
||||
considerScoreWordHasBlanks( EngineCtxt* engine, XP_U16 blanksLeft,
|
||||
considerScoreWordHasBlanks( EngineCtxt* engine, XWEnv xwe, XP_U16 blanksLeft,
|
||||
PossibleMove* posmove,
|
||||
XP_U16 lastRow, BlankTuple* usedBlanks,
|
||||
XP_U16 usedBlanksCount )
|
||||
|
@ -1137,7 +1138,7 @@ considerScoreWordHasBlanks( EngineCtxt* engine, XP_U16 blanksLeft,
|
|||
wiip = &wii;
|
||||
}
|
||||
|
||||
XP_U16 score = figureMoveScore( engine->model, engine->turn,
|
||||
XP_U16 score = figureMoveScore( engine->model, xwe, engine->turn,
|
||||
&posmove->moveInfo,
|
||||
engine, (XWStreamCtxt*)NULL, wiip );
|
||||
|
||||
|
@ -1179,7 +1180,7 @@ considerScoreWordHasBlanks( EngineCtxt* engine, XP_U16 blanksLeft,
|
|||
posmove->moveInfo.tiles[ii].tile |= TILE_BLANK_BIT;
|
||||
bt->col = ii;
|
||||
bt->tile = bTile;
|
||||
considerScoreWordHasBlanks( engine, blanksLeft,
|
||||
considerScoreWordHasBlanks( engine, xwe, blanksLeft,
|
||||
posmove, lastRow,
|
||||
usedBlanks,
|
||||
usedBlanksCount );
|
||||
|
|
|
@ -48,7 +48,7 @@ void engine_init( EngineCtxt* ctxt );
|
|||
void engine_reset( EngineCtxt* ctxt );
|
||||
void engine_destroy( EngineCtxt* ctxt );
|
||||
|
||||
XP_Bool engine_findMove( EngineCtxt* ctxt, const ModelCtxt* model, XP_S16 turn,
|
||||
XP_Bool engine_findMove( EngineCtxt* ctxt, XWEnv xwe, const ModelCtxt* model, XP_S16 turn,
|
||||
/* includePending: include pending tiles as part of words */
|
||||
XP_Bool includePending,
|
||||
/* skipCallback: skip the callback that lets client cancel */
|
||||
|
|
|
@ -75,24 +75,24 @@ checkServerRole( CurGameInfo* gi, XP_U16* nPlayersHere,
|
|||
} /* checkServerRole */
|
||||
|
||||
static XP_U32
|
||||
makeGameID( XW_UtilCtxt* util )
|
||||
makeGameID( XW_UtilCtxt* util, XWEnv xwe )
|
||||
{
|
||||
XP_U32 gameID = 0;
|
||||
assertUtilOK( util );
|
||||
while ( 0 == gameID ) {
|
||||
gameID = dutil_getCurSeconds( util_getDevUtilCtxt( util ) );
|
||||
gameID = dutil_getCurSeconds( util_getDevUtilCtxt( util, xwe ), xwe );
|
||||
}
|
||||
return gameID;
|
||||
}
|
||||
|
||||
static void
|
||||
timerChangeListener( void* data, const XP_U32 gameID,
|
||||
timerChangeListener( XWEnv xwe, void* data, const XP_U32 gameID,
|
||||
XP_S32 oldVal, XP_S32 newVal )
|
||||
{
|
||||
XWGame* game = (XWGame*)data;
|
||||
XP_ASSERT( game->util->gameInfo->gameID == gameID );
|
||||
XP_LOGF( "%s(oldVal=%d, newVal=%d, id=%d)", __func__, oldVal, newVal, gameID );
|
||||
dutil_onDupTimerChanged( util_getDevUtilCtxt( game->util ),
|
||||
dutil_onDupTimerChanged( util_getDevUtilCtxt( game->util, xwe ), xwe,
|
||||
gameID, oldVal, newVal );
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ game_makeNewGame( MPFORMAL XWEnv xwe, XWGame* game, CurGameInfo* gi,
|
|||
assertUtilOK( util );
|
||||
|
||||
if ( 0 == gi->gameID ) {
|
||||
gi->gameID = makeGameID( util );
|
||||
gi->gameID = makeGameID( util, xwe );
|
||||
}
|
||||
|
||||
game->util = util;
|
||||
|
@ -143,16 +143,16 @@ game_makeNewGame( MPFORMAL XWEnv xwe, XWGame* game, CurGameInfo* gi,
|
|||
game->comms = (CommsCtxt*)NULL;
|
||||
}
|
||||
#endif
|
||||
game->server = server_make( MPPARM(mpool) game->model,
|
||||
game->server = server_make( MPPARM(mpool) xwe, game->model,
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
game->comms,
|
||||
#else
|
||||
(CommsCtxt*)NULL,
|
||||
#endif
|
||||
util );
|
||||
game->board = board_make( MPPARM(mpool) game->model, game->server,
|
||||
game->board = board_make( MPPARM(mpool) xwe, game->model, game->server,
|
||||
NULL, util );
|
||||
board_setCallbacks( game->board );
|
||||
board_setCallbacks( game->board, xwe );
|
||||
|
||||
board_setDraw( game->board, xwe, draw );
|
||||
setListeners( game, cp );
|
||||
|
@ -170,7 +170,7 @@ game_reset( MPFORMAL XWGame* game, XWEnv xwe, CurGameInfo* gi, XW_UtilCtxt* util
|
|||
XP_ASSERT( !!game->model );
|
||||
XP_ASSERT( !!gi );
|
||||
|
||||
gi->gameID = makeGameID( util );
|
||||
gi->gameID = makeGameID( util, xwe );
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
XP_U16 nPlayersHere = 0;
|
||||
|
@ -179,7 +179,7 @@ game_reset( MPFORMAL XWGame* game, XWEnv xwe, CurGameInfo* gi, XW_UtilCtxt* util
|
|||
|
||||
if ( !!game->comms ) {
|
||||
if ( gi->serverRole == SERVER_STANDALONE ) {
|
||||
comms_destroy( game->comms );
|
||||
comms_destroy( game->comms, xwe );
|
||||
game->comms = NULL;
|
||||
} else {
|
||||
comms_reset( game->comms, xwe, gi->serverRole != SERVER_ISCLIENT,
|
||||
|
@ -209,7 +209,7 @@ game_reset( MPFORMAL XWGame* game, XWEnv xwe, CurGameInfo* gi, XW_UtilCtxt* util
|
|||
NULL
|
||||
#endif
|
||||
);
|
||||
board_reset( game->board );
|
||||
board_reset( game->board, xwe );
|
||||
|
||||
for ( ii = 0; ii < gi->nPlayers; ++ii ) {
|
||||
gi->players[ii].secondsUsed = 0;
|
||||
|
@ -287,11 +287,11 @@ game_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, XWGame* game,
|
|||
game->model = model_makeFromStream( MPPARM(mpool) xwe, stream, dict,
|
||||
dicts, util );
|
||||
|
||||
game->server = server_makeFromStream( MPPARM(mpool) stream,
|
||||
game->server = server_makeFromStream( MPPARM(mpool) xwe, stream,
|
||||
game->model, game->comms,
|
||||
util, gi->nPlayers );
|
||||
|
||||
game->board = board_makeFromStream( MPPARM(mpool) stream,
|
||||
game->board = board_makeFromStream( MPPARM(mpool) xwe, stream,
|
||||
game->model, game->server,
|
||||
NULL, util, gi->nPlayers );
|
||||
setListeners( game, cp );
|
||||
|
@ -387,7 +387,7 @@ game_receiveMessage( XWGame* game, XWEnv xwe, XWStreamCtxt* stream,
|
|||
}
|
||||
|
||||
void
|
||||
game_getState( const XWGame* game, GameStateInfo* gsi )
|
||||
game_getState( const XWGame* game, XWEnv xwe, GameStateInfo* gsi )
|
||||
{
|
||||
const ServerCtxt* server = game->server;
|
||||
BoardCtxt* board = game->board;
|
||||
|
@ -403,7 +403,7 @@ game_getState( const XWGame* game, GameStateInfo* gsi )
|
|||
gsi->canChat = !!game->comms && comms_canChat( game->comms );
|
||||
gsi->canShuffle = board_canShuffle( board );
|
||||
gsi->canHideRack = board_canHideRack( board );
|
||||
gsi->canTrade = board_canTrade( board );
|
||||
gsi->canTrade = board_canTrade( board, xwe );
|
||||
gsi->nPendingMessages = !!game->comms ?
|
||||
comms_countPendingPackets(game->comms) : 0;
|
||||
|
||||
|
@ -423,14 +423,14 @@ game_dispose( XWGame* game, XWEnv xwe )
|
|||
{
|
||||
/* The board should be reused!!! PENDING(ehouse) */
|
||||
if ( !!game->board ) {
|
||||
board_destroy( game->board, XP_TRUE );
|
||||
board_destroy( game->board, xwe, XP_TRUE );
|
||||
game->board = NULL;
|
||||
}
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
if ( !!game->comms ) {
|
||||
comms_stop( game->comms, xwe );
|
||||
comms_destroy( game->comms );
|
||||
comms_destroy( game->comms, xwe );
|
||||
game->comms = NULL;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -92,7 +92,7 @@ XP_Bool game_receiveMessage( XWGame* game, XWEnv xwe, XWStreamCtxt* stream,
|
|||
|
||||
void game_dispose( XWGame* game, XWEnv xwe );
|
||||
|
||||
void game_getState( const XWGame* game, GameStateInfo* gsi );
|
||||
void game_getState( const XWGame* game, XWEnv xwe, GameStateInfo* gsi );
|
||||
XP_Bool game_getIsServer( const XWGame* game );
|
||||
|
||||
void gi_initPlayerInfo( MPFORMAL CurGameInfo* gi,
|
||||
|
|
|
@ -38,15 +38,15 @@ extern "C" {
|
|||
#define MAX_PASSES 2 /* how many times can all players pass? */
|
||||
|
||||
/****************************** prototypes ******************************/
|
||||
typedef void (*MovePrintFuncPre)(ModelCtxt*, XP_U16, const StackEntry*, void*);
|
||||
typedef void (*MovePrintFuncPost)(ModelCtxt*, XP_U16, const StackEntry*,
|
||||
typedef void (*MovePrintFuncPre)(ModelCtxt*, XWEnv, XP_U16, const StackEntry*, void*);
|
||||
typedef void (*MovePrintFuncPost)(ModelCtxt*, XWEnv, XP_U16, const StackEntry*,
|
||||
XP_S16, void*);
|
||||
|
||||
static void incrPendingTileCountAt( ModelCtxt* model, XP_U16 col,
|
||||
XP_U16 row );
|
||||
static void decrPendingTileCountAt( ModelCtxt* model, XP_U16 col,
|
||||
XP_U16 row );
|
||||
static void notifyBoardListeners( ModelCtxt* model, XP_U16 turn,
|
||||
static void notifyBoardListeners( ModelCtxt* model, XWEnv xwe, XP_U16 turn,
|
||||
XP_U16 col, XP_U16 row, XP_Bool added );
|
||||
static void notifyTrayListeners( ModelCtxt* model, XP_U16 turn,
|
||||
XP_S16 index1, XP_S16 index2 );
|
||||
|
@ -83,7 +83,7 @@ typedef struct _DiffTurnState {
|
|||
XP_S16 lastPlayerNum;
|
||||
XP_S16 lastMoveNum;
|
||||
} DiffTurnState;
|
||||
static void assertDiffTurn( ModelCtxt* model, XP_U16 turn,
|
||||
static void assertDiffTurn( ModelCtxt* model, XWEnv xwe, XP_U16 turn,
|
||||
const StackEntry* entry, void* closure);
|
||||
#endif
|
||||
|
||||
|
@ -100,7 +100,7 @@ model_make( MPFORMAL XWEnv xwe, DictionaryCtxt* dict, const PlayerDicts* dicts,
|
|||
MPASSIGN(result->vol.mpool, mpool);
|
||||
|
||||
result->vol.util = util;
|
||||
result->vol.dutil = util_getDevUtilCtxt( util );
|
||||
result->vol.dutil = util_getDevUtilCtxt( util, xwe );
|
||||
result->vol.wni.proc = recordWord;
|
||||
result->vol.wni.closure = &result->vol.rwi;
|
||||
|
||||
|
@ -328,7 +328,7 @@ model_hashMatches( const ModelCtxt* model, const XP_U32 hash )
|
|||
}
|
||||
|
||||
XP_Bool
|
||||
model_popToHash( ModelCtxt* model, const XP_U32 hash, PoolContext* pool )
|
||||
model_popToHash( ModelCtxt* model, XWEnv xwe, const XP_U32 hash, PoolContext* pool )
|
||||
{
|
||||
LOG_FUNC();
|
||||
XP_U16 nPopped = 0;
|
||||
|
@ -366,7 +366,7 @@ model_popToHash( ModelCtxt* model, const XP_U32 hash, PoolContext* pool )
|
|||
#ifdef DEBUG
|
||||
XP_Bool success =
|
||||
#endif
|
||||
model_undoLatestMoves( model, pool, foundAt, NULL, NULL );
|
||||
model_undoLatestMoves( model, xwe, pool, foundAt, NULL, NULL );
|
||||
XP_ASSERT( success );
|
||||
}
|
||||
/* Assert not needed for long */
|
||||
|
@ -405,7 +405,7 @@ model_setSquareBonuses( ModelCtxt* model, XWBonusType* bonuses, XP_U16 nBonuses
|
|||
#endif
|
||||
|
||||
XWBonusType
|
||||
model_getSquareBonus( const ModelCtxt* model, XP_U16 col, XP_U16 row )
|
||||
model_getSquareBonus( const ModelCtxt* model, XWEnv xwe, XP_U16 col, XP_U16 row )
|
||||
{
|
||||
XWBonusType result = BONUS_NONE;
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
|
@ -437,7 +437,8 @@ model_getSquareBonus( const ModelCtxt* model, XP_U16 col, XP_U16 row )
|
|||
}
|
||||
#endif
|
||||
} else {
|
||||
result = util_getSquareBonus( model->vol.util, model_numRows(model),
|
||||
result = util_getSquareBonus( model->vol.util, xwe,
|
||||
model_numRows(model),
|
||||
col, row );
|
||||
}
|
||||
return result;
|
||||
|
@ -448,7 +449,7 @@ makeAndCommit( ModelCtxt* model, XWEnv xwe, XP_U16 turn, const MoveInfo* mi,
|
|||
const TrayTileSet* tiles, XWStreamCtxt* stream,
|
||||
XP_Bool useStack, WordNotifierInfo* wni )
|
||||
{
|
||||
model_makeTurnFromMoveInfo( model, turn, mi );
|
||||
model_makeTurnFromMoveInfo( model, xwe, turn, mi );
|
||||
XP_U16 moveScore = commitTurn( model, xwe, turn, tiles,
|
||||
stream, wni, useStack );
|
||||
return moveScore;
|
||||
|
@ -464,13 +465,13 @@ dupe_adjustScores( ModelCtxt* model, XP_Bool add, XP_U16 nScores, const XP_U16*
|
|||
}
|
||||
|
||||
void
|
||||
model_cloneDupeTrays( ModelCtxt* model )
|
||||
model_cloneDupeTrays( ModelCtxt* model, XWEnv xwe )
|
||||
{
|
||||
XP_ASSERT( model->vol.gi->inDuplicateMode );
|
||||
XP_U16 nTiles = model->players[DUP_PLAYER].trayTiles.nTiles;
|
||||
for ( XP_U16 ii = 0; ii < model->nPlayers; ++ii ) {
|
||||
if ( ii != DUP_PLAYER ) {
|
||||
model_resetCurrentTurn( model, ii );
|
||||
model_resetCurrentTurn( model, xwe, ii );
|
||||
model->players[ii].trayTiles = model->players[DUP_PLAYER].trayTiles;
|
||||
notifyTrayListeners( model, ii, 0, nTiles );
|
||||
}
|
||||
|
@ -485,7 +486,7 @@ modelAddEntry( ModelCtxt* model, XWEnv xwe, XP_U16 indx, const StackEntry* entry
|
|||
{
|
||||
XP_S16 moveScore = 0; /* keep compiler happy */
|
||||
if ( !!mpf_pre ) {
|
||||
(*mpf_pre)( model, indx, entry, closure );
|
||||
(*mpf_pre)( model, xwe, indx, entry, closure );
|
||||
}
|
||||
|
||||
switch ( entry->moveType ) {
|
||||
|
@ -496,7 +497,7 @@ modelAddEntry( ModelCtxt* model, XWEnv xwe, XP_U16 indx, const StackEntry* entry
|
|||
XP_ASSERT( DUP_PLAYER == entry->playerNum );
|
||||
dupe_adjustScores( model, XP_TRUE, entry->u.move.dup.nScores,
|
||||
entry->u.move.dup.scores );
|
||||
model_cloneDupeTrays( model );
|
||||
model_cloneDupeTrays( model, xwe );
|
||||
}
|
||||
break;
|
||||
case TRADE_TYPE:
|
||||
|
@ -504,24 +505,24 @@ modelAddEntry( ModelCtxt* model, XWEnv xwe, XP_U16 indx, const StackEntry* entry
|
|||
&entry->u.trade.newTiles );
|
||||
if ( model->vol.gi->inDuplicateMode ) {
|
||||
XP_ASSERT( DUP_PLAYER == entry->playerNum );
|
||||
model_cloneDupeTrays( model );
|
||||
model_cloneDupeTrays( model, xwe );
|
||||
}
|
||||
break;
|
||||
case ASSIGN_TYPE:
|
||||
model_addNewTiles( model, entry->playerNum, &entry->u.assign.tiles );
|
||||
if ( model->vol.gi->inDuplicateMode ) {
|
||||
XP_ASSERT( DUP_PLAYER == entry->playerNum );
|
||||
model_cloneDupeTrays( model );
|
||||
model_cloneDupeTrays( model, xwe );
|
||||
}
|
||||
break;
|
||||
case PHONY_TYPE: /* nothing to add */
|
||||
model_makeTurnFromMoveInfo( model, entry->playerNum,
|
||||
model_makeTurnFromMoveInfo( model, xwe, entry->playerNum,
|
||||
&entry->u.phony.moveInfo);
|
||||
/* do something here to cause it to print */
|
||||
(void)getCurrentMoveScoreIfLegal( model, xwe, entry->playerNum, stream,
|
||||
wni, &moveScore );
|
||||
moveScore = 0;
|
||||
model_resetCurrentTurn( model, entry->playerNum );
|
||||
model_resetCurrentTurn( model, xwe, entry->playerNum );
|
||||
|
||||
break;
|
||||
case PAUSE_TYPE:
|
||||
|
@ -532,7 +533,7 @@ modelAddEntry( ModelCtxt* model, XWEnv xwe, XP_U16 indx, const StackEntry* entry
|
|||
}
|
||||
|
||||
if ( !!mpf_post ) {
|
||||
(*mpf_post)( model, indx, entry, moveScore, closure );
|
||||
(*mpf_post)( model, xwe, indx, entry, moveScore, closure );
|
||||
}
|
||||
} /* modelAddEntry */
|
||||
|
||||
|
@ -747,7 +748,7 @@ model_listPlacedBlanks( ModelCtxt* model, XP_U16 turn,
|
|||
} /* model_listPlacedBlanks */
|
||||
|
||||
void
|
||||
model_foreachPrevCell( ModelCtxt* model, BoardListener bl, void* closure )
|
||||
model_foreachPrevCell( ModelCtxt* model, XWEnv xwe, BoardListener bl, void* closure )
|
||||
{
|
||||
XP_U16 col, row;
|
||||
|
||||
|
@ -755,41 +756,41 @@ model_foreachPrevCell( ModelCtxt* model, BoardListener bl, void* closure )
|
|||
for ( row = 0; row < model->nRows; ++row) {
|
||||
CellTile tile = getModelTileRaw( model, col, row );
|
||||
if ( (tile & PREV_MOVE_BIT) != 0 ) {
|
||||
(*bl)( closure, (XP_U16)CELL_OWNER(tile), col, row, XP_FALSE );
|
||||
(*bl)( xwe, closure, (XP_U16)CELL_OWNER(tile), col, row, XP_FALSE );
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* model_foreachPrevCell */
|
||||
|
||||
static void
|
||||
clearAndNotify( void* closure, XP_U16 XP_UNUSED(turn), XP_U16 col, XP_U16 row,
|
||||
XP_Bool XP_UNUSED(added) )
|
||||
clearAndNotify( XWEnv xwe, void* closure, XP_U16 XP_UNUSED(turn),
|
||||
XP_U16 col, XP_U16 row, XP_Bool XP_UNUSED(added) )
|
||||
{
|
||||
ModelCtxt* model = (ModelCtxt*)closure;
|
||||
CellTile tile = getModelTileRaw( model, col, row );
|
||||
setModelTileRaw( model, col, row, (CellTile)(tile & ~PREV_MOVE_BIT) );
|
||||
|
||||
notifyBoardListeners( model, (XP_U16)CELL_OWNER(tile), col, row,
|
||||
notifyBoardListeners( model, xwe, (XP_U16)CELL_OWNER(tile), col, row,
|
||||
XP_FALSE );
|
||||
} /* clearAndNotify */
|
||||
|
||||
static void
|
||||
clearLastMoveInfo( ModelCtxt* model )
|
||||
clearLastMoveInfo( ModelCtxt* model, XWEnv xwe )
|
||||
{
|
||||
model_foreachPrevCell( model, clearAndNotify, model );
|
||||
model_foreachPrevCell( model, xwe, clearAndNotify, model );
|
||||
} /* clearLastMoveInfo */
|
||||
|
||||
static void
|
||||
invalLastMove( ModelCtxt* model )
|
||||
invalLastMove( ModelCtxt* model, XWEnv xwe )
|
||||
{
|
||||
if ( !!model->vol.boardListenerFunc ) {
|
||||
model_foreachPrevCell( model, model->vol.boardListenerFunc,
|
||||
model_foreachPrevCell( model, xwe, model->vol.boardListenerFunc,
|
||||
model->vol.boardListenerData );
|
||||
}
|
||||
} /* invalLastMove */
|
||||
|
||||
void
|
||||
model_foreachPendingCell( ModelCtxt* model, XP_S16 turn,
|
||||
model_foreachPendingCell( ModelCtxt* model, XWEnv xwe, XP_S16 turn,
|
||||
BoardListener bl, void* closure )
|
||||
{
|
||||
PendingTile* pt;
|
||||
|
@ -801,7 +802,7 @@ model_foreachPendingCell( ModelCtxt* model, XP_S16 turn,
|
|||
count = player->nPending;
|
||||
|
||||
for ( pt = player->pendingTiles; count--; ++pt ) {
|
||||
(*bl)( closure, turn, pt->col, pt->row, XP_FALSE );
|
||||
(*bl)( xwe, closure, turn, pt->col, pt->row, XP_FALSE );
|
||||
}
|
||||
} /* model_foreachPendingCell */
|
||||
|
||||
|
@ -837,7 +838,7 @@ getModelTileRaw( const ModelCtxt* model, XP_U16 col, XP_U16 row )
|
|||
} /* getModelTileRaw */
|
||||
|
||||
static void
|
||||
undoFromMove( ModelCtxt* model, XP_U16 turn, Tile blankTile, MoveRec* move )
|
||||
undoFromMove( ModelCtxt* model, XWEnv xwe, XP_U16 turn, Tile blankTile, MoveRec* move )
|
||||
{
|
||||
const MoveInfo* mi = &move->moveInfo;
|
||||
|
||||
|
@ -852,7 +853,7 @@ undoFromMove( ModelCtxt* model, XP_U16 turn, Tile blankTile, MoveRec* move )
|
|||
*other = tinfo->varCoord;
|
||||
|
||||
setModelTileRaw( model, col, row, EMPTY_TILE );
|
||||
notifyBoardListeners( model, turn, col, row, XP_FALSE );
|
||||
notifyBoardListeners( model, xwe, turn, col, row, XP_FALSE );
|
||||
--model->vol.nTilesOnBoard;
|
||||
|
||||
if ( IS_BLANK(tile) ) {
|
||||
|
@ -864,7 +865,7 @@ undoFromMove( ModelCtxt* model, XP_U16 turn, Tile blankTile, MoveRec* move )
|
|||
if ( model->vol.gi->inDuplicateMode ) {
|
||||
dupe_adjustScores( model, XP_FALSE, move->dup.nScores, move->dup.scores );
|
||||
} else {
|
||||
adjustScoreForUndone( model, mi, turn );
|
||||
adjustScoreForUndone( model, xwe, mi, turn );
|
||||
}
|
||||
} /* undoFromMove */
|
||||
|
||||
|
@ -894,7 +895,8 @@ replaceNewTiles( ModelCtxt* model, PoolContext* pool, XP_U16 turn,
|
|||
/* Turn the most recent move into a phony.
|
||||
*/
|
||||
void
|
||||
model_rejectPreviousMove( ModelCtxt* model, PoolContext* pool, XP_U16* turn )
|
||||
model_rejectPreviousMove( ModelCtxt* model, XWEnv xwe,
|
||||
PoolContext* pool, XP_U16* turn )
|
||||
{
|
||||
StackCtxt* stack = model->vol.stack;
|
||||
StackEntry entry;
|
||||
|
@ -903,11 +905,11 @@ model_rejectPreviousMove( ModelCtxt* model, PoolContext* pool, XP_U16* turn )
|
|||
stack_popEntry( stack, &entry );
|
||||
XP_ASSERT( entry.moveType == MOVE_TYPE );
|
||||
|
||||
model_resetCurrentTurn( model, entry.playerNum );
|
||||
model_resetCurrentTurn( model, xwe, entry.playerNum );
|
||||
|
||||
replaceNewTiles( model, pool, entry.playerNum, &entry.u.move.newTiles );
|
||||
XP_ASSERT( !model->vol.gi->inDuplicateMode );
|
||||
undoFromMove( model, entry.playerNum, blankTile, &entry.u.move );
|
||||
undoFromMove( model, xwe, entry.playerNum, blankTile, &entry.u.move );
|
||||
|
||||
stack_addPhony( stack, entry.playerNum, &entry.u.phony.moveInfo );
|
||||
|
||||
|
@ -931,7 +933,7 @@ model_canUndo( const ModelCtxt* model )
|
|||
* indicated by *moveNumP, if >= 0).
|
||||
*/
|
||||
XP_Bool
|
||||
model_undoLatestMoves( ModelCtxt* model, PoolContext* pool,
|
||||
model_undoLatestMoves( ModelCtxt* model, XWEnv xwe, PoolContext* pool,
|
||||
XP_U16 nMovesSought, XP_U16* turnP, XP_S16* moveNumP )
|
||||
{
|
||||
XP_ASSERT( 0 < nMovesSought ); /* this case isn't handled correctly */
|
||||
|
@ -968,19 +970,19 @@ model_undoLatestMoves( ModelCtxt* model, PoolContext* pool,
|
|||
++nMovesUndone;
|
||||
|
||||
turn = entry.playerNum;
|
||||
model_resetCurrentTurn( model, turn );
|
||||
model_resetCurrentTurn( model, xwe, turn );
|
||||
|
||||
if ( entry.moveType == MOVE_TYPE ) {
|
||||
/* get the tiles out of player's tray and back into the
|
||||
pool */
|
||||
replaceNewTiles( model, pool, turn, &entry.u.move.newTiles );
|
||||
|
||||
undoFromMove( model, turn, blankTile, &entry.u.move );
|
||||
undoFromMove( model, xwe, turn, blankTile, &entry.u.move );
|
||||
model_sortTiles( model, turn );
|
||||
|
||||
if ( model->vol.gi->inDuplicateMode ) {
|
||||
XP_ASSERT( DUP_PLAYER == turn );
|
||||
model_cloneDupeTrays( model );
|
||||
model_cloneDupeTrays( model, xwe );
|
||||
}
|
||||
} else if ( entry.moveType == TRADE_TYPE ) {
|
||||
replaceNewTiles( model, pool, turn,
|
||||
|
@ -1040,7 +1042,7 @@ model_undoLatestMoves( ModelCtxt* model, PoolContext* pool,
|
|||
tile = getModelTileRaw( model, col, row );
|
||||
setModelTileRaw( model, col, row,
|
||||
(CellTile)(tile | PREV_MOVE_BIT) );
|
||||
notifyBoardListeners( model, entry.playerNum, col, row,
|
||||
notifyBoardListeners( model, xwe, entry.playerNum, col, row,
|
||||
XP_FALSE );
|
||||
}
|
||||
break;
|
||||
|
@ -1171,7 +1173,7 @@ model_currentMoveToStream( ModelCtxt* model, XP_S16 turn,
|
|||
* board.
|
||||
*/
|
||||
XP_Bool
|
||||
model_makeTurnFromStream( ModelCtxt* model, XP_U16 playerNum,
|
||||
model_makeTurnFromStream( ModelCtxt* model, XWEnv xwe, XP_U16 playerNum,
|
||||
XWStreamCtxt* stream )
|
||||
{
|
||||
Tile blank = dict_getBlankTile( model_getDictionary(model) );
|
||||
|
@ -1183,7 +1185,7 @@ model_makeTurnFromStream( ModelCtxt* model, XP_U16 playerNum,
|
|||
#endif
|
||||
;
|
||||
|
||||
model_resetCurrentTurn( model, playerNum );
|
||||
model_resetCurrentTurn( model, xwe, playerNum );
|
||||
|
||||
XP_U16 numTiles = (XP_U16)stream_getBits( stream, NTILES_NBITS );
|
||||
XP_LOGF( "%s: numTiles=%d", __func__, numTiles );
|
||||
|
@ -1229,7 +1231,7 @@ model_makeTurnFromStream( ModelCtxt* model, XP_U16 playerNum,
|
|||
model_addPlayerTile( model, playerNum, -1, moveTiles[ii] );
|
||||
}
|
||||
|
||||
model_moveTrayToBoard( model, playerNum, cols[ii], rows[ii], foundAt,
|
||||
model_moveTrayToBoard( model, xwe, playerNum, cols[ii], rows[ii], foundAt,
|
||||
tileFaces[ii] );
|
||||
}
|
||||
}
|
||||
|
@ -1275,7 +1277,7 @@ reverseTiles( MoveInfo* move )
|
|||
#endif
|
||||
|
||||
void
|
||||
model_makeTurnFromMoveInfo( ModelCtxt* model, XP_U16 playerNum,
|
||||
model_makeTurnFromMoveInfo( ModelCtxt* model, XWEnv xwe, XP_U16 playerNum,
|
||||
const MoveInfo* newMove )
|
||||
{
|
||||
XP_U16 col, row, ii;
|
||||
|
@ -1300,7 +1302,7 @@ model_makeTurnFromMoveInfo( ModelCtxt* model, XP_U16 playerNum,
|
|||
XP_ASSERT( tileIndex >= 0 );
|
||||
|
||||
*other = tinfo->varCoord;
|
||||
model_moveTrayToBoard( model, (XP_S16)playerNum, col, row, tileIndex,
|
||||
model_moveTrayToBoard( model, xwe, (XP_S16)playerNum, col, row, tileIndex,
|
||||
(Tile)(tinfo->tile & TILE_VALUE_MASK) );
|
||||
}
|
||||
} /* model_makeTurnFromMoveInfo */
|
||||
|
@ -1502,7 +1504,7 @@ model_packTilesUtil( ModelCtxt* model, PoolContext* pool,
|
|||
/* setup async query for blank value, but while at it return a reasonable
|
||||
default. */
|
||||
Tile
|
||||
model_askBlankTile( ModelCtxt* model, XP_U16 turn, XP_U16 col, XP_U16 row )
|
||||
model_askBlankTile( ModelCtxt* model, XWEnv xwe, XP_U16 turn, XP_U16 col, XP_U16 row )
|
||||
{
|
||||
XP_U16 nUsed = MAX_UNIQUE_TILES;
|
||||
const XP_UCHAR* tfaces[MAX_UNIQUE_TILES];
|
||||
|
@ -1511,13 +1513,13 @@ model_askBlankTile( ModelCtxt* model, XP_U16 turn, XP_U16 col, XP_U16 row )
|
|||
model_packTilesUtil( model, NULL, XP_FALSE,
|
||||
&nUsed, tfaces, tiles );
|
||||
|
||||
util_notifyPickTileBlank( model->vol.util, turn, col, row,
|
||||
util_notifyPickTileBlank( model->vol.util, xwe, turn, col, row,
|
||||
tfaces, nUsed );
|
||||
return tiles[0];
|
||||
} /* model_askBlankTile */
|
||||
|
||||
void
|
||||
model_moveTrayToBoard( ModelCtxt* model, XP_S16 turn, XP_U16 col, XP_U16 row,
|
||||
model_moveTrayToBoard( ModelCtxt* model, XWEnv xwe, XP_S16 turn, XP_U16 col, XP_U16 row,
|
||||
XP_S16 tileIndex, Tile blankFace )
|
||||
{
|
||||
PlayerCtxt* player;
|
||||
|
@ -1531,7 +1533,7 @@ model_moveTrayToBoard( ModelCtxt* model, XP_S16 turn, XP_U16 col, XP_U16 row,
|
|||
} else {
|
||||
XP_ASSERT( turn >= 0 );
|
||||
tile = TILE_BLANK_BIT
|
||||
| model_askBlankTile( model, (XP_U16)turn, col, row );
|
||||
| model_askBlankTile( model, xwe, (XP_U16)turn, col, row );
|
||||
}
|
||||
tile |= TILE_BLANK_BIT;
|
||||
}
|
||||
|
@ -1539,7 +1541,7 @@ model_moveTrayToBoard( ModelCtxt* model, XP_S16 turn, XP_U16 col, XP_U16 row,
|
|||
player = &model->players[turn];
|
||||
|
||||
if ( player->nPending == 0 ) {
|
||||
invalLastMove( model );
|
||||
invalLastMove( model, xwe );
|
||||
}
|
||||
|
||||
player->nUndone = 0;
|
||||
|
@ -1553,7 +1555,7 @@ model_moveTrayToBoard( ModelCtxt* model, XP_S16 turn, XP_U16 col, XP_U16 row,
|
|||
invalidateScore( model, turn );
|
||||
incrPendingTileCountAt( model, col, row );
|
||||
|
||||
notifyBoardListeners( model, turn, col, row, XP_TRUE );
|
||||
notifyBoardListeners( model, xwe, turn, col, row, XP_TRUE );
|
||||
} /* model_moveTrayToBoard */
|
||||
|
||||
XP_Bool
|
||||
|
@ -1586,7 +1588,7 @@ model_setBlankValue( ModelCtxt* model, XP_U16 turn,
|
|||
}
|
||||
|
||||
XP_Bool
|
||||
model_redoPendingTiles( ModelCtxt* model, XP_S16 turn )
|
||||
model_redoPendingTiles( ModelCtxt* model, XWEnv xwe, XP_S16 turn )
|
||||
{
|
||||
XP_U16 actualCnt = 0;
|
||||
PlayerCtxt* player;
|
||||
|
@ -1618,9 +1620,9 @@ model_redoPendingTiles( ModelCtxt* model, XP_S16 turn )
|
|||
|
||||
if ( !model_getTile( model, pt->col, pt->row, XP_FALSE, turn,
|
||||
NULL, NULL, NULL, NULL ) ) {
|
||||
model_moveTrayToBoard( model, turn, pt->col, pt->row,
|
||||
model_moveTrayToBoard( model, xwe, turn, pt->col, pt->row,
|
||||
foundAt, pt->tile & ~TILE_BLANK_BIT );
|
||||
++actualCnt;
|
||||
++actualCnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1628,7 +1630,7 @@ model_redoPendingTiles( ModelCtxt* model, XP_S16 turn )
|
|||
}
|
||||
|
||||
void
|
||||
model_moveBoardToTray( ModelCtxt* model, XP_S16 turn,
|
||||
model_moveBoardToTray( ModelCtxt* model, XWEnv xwe, XP_S16 turn,
|
||||
XP_U16 col, XP_U16 row, XP_U16 trayOffset )
|
||||
{
|
||||
XP_S16 index;
|
||||
|
@ -1652,7 +1654,7 @@ model_moveBoardToTray( ModelCtxt* model, XP_S16 turn,
|
|||
if ( index < player->nPending ) {
|
||||
PendingTile tmpPending;
|
||||
decrPendingTileCountAt( model, col, row );
|
||||
notifyBoardListeners( model, turn, col, row, XP_FALSE );
|
||||
notifyBoardListeners( model, xwe, turn, col, row, XP_FALSE );
|
||||
|
||||
tile = pt->tile;
|
||||
if ( (tile & TILE_BLANK_BIT) != 0 ) {
|
||||
|
@ -1672,7 +1674,7 @@ model_moveBoardToTray( ModelCtxt* model, XP_S16 turn,
|
|||
//XP_LOGF( "%s: nUndone(%d): %d", __func__, turn, player->nUndone );
|
||||
|
||||
if ( player->nPending == 0 ) {
|
||||
invalLastMove( model );
|
||||
invalLastMove( model, xwe );
|
||||
}
|
||||
|
||||
invalidateScore( model, turn );
|
||||
|
@ -1680,7 +1682,7 @@ model_moveBoardToTray( ModelCtxt* model, XP_S16 turn,
|
|||
} /* model_moveBoardToTray */
|
||||
|
||||
XP_Bool
|
||||
model_moveTileOnBoard( ModelCtxt* model, XP_S16 turn, XP_U16 colCur,
|
||||
model_moveTileOnBoard( ModelCtxt* model, XWEnv xwe, XP_S16 turn, XP_U16 colCur,
|
||||
XP_U16 rowCur, XP_U16 colNew, XP_U16 rowNew )
|
||||
{
|
||||
XP_Bool found = XP_FALSE;
|
||||
|
@ -1703,7 +1705,7 @@ model_moveTileOnBoard( ModelCtxt* model, XP_S16 turn, XP_U16 colCur,
|
|||
pt->col = colNew;
|
||||
pt->row = rowNew;
|
||||
if ( isBlank ) {
|
||||
(void)model_askBlankTile( model, turn, colNew, rowNew );
|
||||
(void)model_askBlankTile( model, xwe, turn, colNew, rowNew );
|
||||
}
|
||||
|
||||
decrPendingTileCountAt( model, colCur, rowCur );
|
||||
|
@ -1718,7 +1720,7 @@ model_moveTileOnBoard( ModelCtxt* model, XP_S16 turn, XP_U16 colCur,
|
|||
} /* model_moveTileOnBoard */
|
||||
|
||||
void
|
||||
model_resetCurrentTurn( ModelCtxt* model, XP_S16 whose )
|
||||
model_resetCurrentTurn( ModelCtxt* model, XWEnv xwe, XP_S16 whose )
|
||||
{
|
||||
PlayerCtxt* player;
|
||||
|
||||
|
@ -1726,7 +1728,7 @@ model_resetCurrentTurn( ModelCtxt* model, XP_S16 whose )
|
|||
player = &model->players[whose];
|
||||
|
||||
while ( player->nPending > 0 ) {
|
||||
model_moveBoardToTray( model, whose,
|
||||
model_moveBoardToTray( model, xwe, whose,
|
||||
player->pendingTiles[0].col,
|
||||
player->pendingTiles[0].row,
|
||||
-1 );
|
||||
|
@ -1819,7 +1821,7 @@ decrPendingTileCountAt( ModelCtxt* model, XP_U16 col, XP_U16 row )
|
|||
} /* decrPendingTileCountAt */
|
||||
|
||||
static void
|
||||
putBackOtherPlayersTiles( ModelCtxt* model, XP_U16 notMyTurn,
|
||||
putBackOtherPlayersTiles( ModelCtxt* model, XWEnv xwe, XP_U16 notMyTurn,
|
||||
XP_U16 col, XP_U16 row )
|
||||
{
|
||||
XP_U16 turn;
|
||||
|
@ -1828,7 +1830,7 @@ putBackOtherPlayersTiles( ModelCtxt* model, XP_U16 notMyTurn,
|
|||
if ( turn == notMyTurn ) {
|
||||
continue;
|
||||
}
|
||||
model_moveBoardToTray( model, turn, col, row, -1 );
|
||||
model_moveBoardToTray( model, xwe, turn, col, row, -1 );
|
||||
}
|
||||
} /* putBackOtherPlayersTiles */
|
||||
|
||||
|
@ -1858,7 +1860,7 @@ commitTurn( ModelCtxt* model, XWEnv xwe, XP_S16 turn, const TrayTileSet* newTile
|
|||
|
||||
XP_ASSERT( turn >= 0 && turn < MAX_NUM_PLAYERS);
|
||||
|
||||
clearLastMoveInfo( model );
|
||||
clearLastMoveInfo( model, xwe );
|
||||
|
||||
PlayerCtxt* player = &model->players[turn];
|
||||
|
||||
|
@ -1886,7 +1888,7 @@ commitTurn( ModelCtxt* model, XWEnv xwe, XP_S16 turn, const TrayTileSet* newTile
|
|||
|
||||
XP_U16 val = tile & TILE_VALUE_MASK;
|
||||
if ( val > 1 ) { /* somebody else is using this square too! */
|
||||
putBackOtherPlayersTiles( model, turn, col, row );
|
||||
putBackOtherPlayersTiles( model, xwe, turn, col, row );
|
||||
}
|
||||
|
||||
tile = pt->tile;
|
||||
|
@ -1895,7 +1897,7 @@ commitTurn( ModelCtxt* model, XWEnv xwe, XP_S16 turn, const TrayTileSet* newTile
|
|||
|
||||
setModelTileRaw( model, col, row, tile );
|
||||
|
||||
notifyBoardListeners( model, turn, col, row, XP_FALSE );
|
||||
notifyBoardListeners( model, xwe, turn, col, row, XP_FALSE );
|
||||
|
||||
++model->vol.nTilesOnBoard;
|
||||
}
|
||||
|
@ -1930,8 +1932,8 @@ void
|
|||
model_commitDupeTurn( ModelCtxt* model, XWEnv xwe, const MoveInfo* moveInfo,
|
||||
XP_U16 nScores, XP_U16* scores, TrayTileSet* newTiles )
|
||||
{
|
||||
model_resetCurrentTurn( model, DUP_PLAYER );
|
||||
model_makeTurnFromMoveInfo( model, DUP_PLAYER, moveInfo );
|
||||
model_resetCurrentTurn( model, xwe, DUP_PLAYER );
|
||||
model_makeTurnFromMoveInfo( model, xwe, DUP_PLAYER, moveInfo );
|
||||
(void)commitTurn( model, xwe, DUP_PLAYER, newTiles, NULL, NULL, XP_FALSE );
|
||||
dupe_adjustScores( model, XP_TRUE, nScores, scores );
|
||||
invalidateScores( model );
|
||||
|
@ -1947,10 +1949,10 @@ model_commitDupeTrade( ModelCtxt* model, const TrayTileSet* oldTiles,
|
|||
}
|
||||
|
||||
void
|
||||
model_noteDupePause( ModelCtxt* model, DupPauseType typ, XP_S16 turn,
|
||||
model_noteDupePause( ModelCtxt* model, XWEnv xwe, DupPauseType typ, XP_S16 turn,
|
||||
const XP_UCHAR* msg )
|
||||
{
|
||||
XP_U32 when = dutil_getCurSeconds( model->vol.dutil );
|
||||
XP_U32 when = dutil_getCurSeconds( model->vol.dutil, xwe );
|
||||
stack_addPause( model->vol.stack, typ, turn, when, msg );
|
||||
}
|
||||
|
||||
|
@ -2119,10 +2121,10 @@ model_getNextTurn( const ModelCtxt* model )
|
|||
}
|
||||
|
||||
void
|
||||
model_assignDupeTiles( ModelCtxt* model, const TrayTileSet* tiles )
|
||||
model_assignDupeTiles( ModelCtxt* model, XWEnv xwe, const TrayTileSet* tiles )
|
||||
{
|
||||
model_assignPlayerTiles( model, DUP_PLAYER, tiles );
|
||||
model_cloneDupeTrays( model );
|
||||
model_cloneDupeTrays( model, xwe );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2196,12 +2198,12 @@ model_setDictListener( ModelCtxt* model, DictListener dl, void* data )
|
|||
} /* model_setDictListener */
|
||||
|
||||
static void
|
||||
notifyBoardListeners( ModelCtxt* model, XP_U16 turn, XP_U16 col, XP_U16 row,
|
||||
XP_Bool added )
|
||||
notifyBoardListeners( ModelCtxt* model, XWEnv xwe, XP_U16 turn, XP_U16 col,
|
||||
XP_U16 row, XP_Bool added )
|
||||
{
|
||||
if ( model->vol.boardListenerFunc != NULL ) {
|
||||
(*model->vol.boardListenerFunc)( model->vol.boardListenerData, turn,
|
||||
col, row, added );
|
||||
(*model->vol.boardListenerFunc)( xwe, model->vol.boardListenerData,
|
||||
turn, col, row, added );
|
||||
}
|
||||
} /* notifyBoardListeners */
|
||||
|
||||
|
@ -2258,8 +2260,8 @@ typedef struct MovePrintClosure {
|
|||
} MovePrintClosure;
|
||||
|
||||
static void
|
||||
printMovePre( ModelCtxt* model, XP_U16 XP_UNUSED(moveN), const StackEntry* entry,
|
||||
void* p_closure )
|
||||
printMovePre( ModelCtxt* model, XWEnv xwe, XP_U16 XP_UNUSED(moveN),
|
||||
const StackEntry* entry, void* p_closure )
|
||||
{
|
||||
if ( entry->moveType != ASSIGN_TYPE ) {
|
||||
const XP_UCHAR* format;
|
||||
|
@ -2293,13 +2295,13 @@ printMovePre( ModelCtxt* model, XP_U16 XP_UNUSED(moveN), const StackEntry* entry
|
|||
}
|
||||
|
||||
if ( isPass ) {
|
||||
format = dutil_getUserString( model->vol.dutil, STR_PASS );
|
||||
format = dutil_getUserString( model->vol.dutil, xwe, STR_PASS );
|
||||
XP_SNPRINTF( buf, VSIZE(buf), "%s", format );
|
||||
} else {
|
||||
if ( isHorizontal ) {
|
||||
format = dutil_getUserString( model->vol.dutil, STRS_MOVE_ACROSS );
|
||||
format = dutil_getUserString( model->vol.dutil, xwe, STRS_MOVE_ACROSS );
|
||||
} else {
|
||||
format = dutil_getUserString( model->vol.dutil, STRS_MOVE_DOWN );
|
||||
format = dutil_getUserString( model->vol.dutil, xwe, STRS_MOVE_DOWN );
|
||||
}
|
||||
|
||||
row = mi->commonCoord;
|
||||
|
@ -2316,7 +2318,7 @@ printMovePre( ModelCtxt* model, XP_U16 XP_UNUSED(moveN), const StackEntry* entry
|
|||
printString( stream, (XP_UCHAR*)buf );
|
||||
|
||||
if ( !closure->keepHidden ) {
|
||||
format = dutil_getUserString( model->vol.dutil, STRS_TRAY_AT_START );
|
||||
format = dutil_getUserString( model->vol.dutil, xwe, STRS_TRAY_AT_START );
|
||||
formatTray( model_getPlayerTiles( model, entry->playerNum ),
|
||||
closure->dict, (XP_UCHAR*)traybuf, sizeof(traybuf),
|
||||
XP_FALSE );
|
||||
|
@ -2330,7 +2332,7 @@ printMovePre( ModelCtxt* model, XP_U16 XP_UNUSED(moveN), const StackEntry* entry
|
|||
} /* printMovePre */
|
||||
|
||||
static void
|
||||
printMovePost( ModelCtxt* model, XP_U16 XP_UNUSED(moveN),
|
||||
printMovePost( ModelCtxt* model, XWEnv xwe, XP_U16 XP_UNUSED(moveN),
|
||||
const StackEntry* entry, XP_S16 XP_UNUSED(score),
|
||||
void* p_closure )
|
||||
{
|
||||
|
@ -2355,14 +2357,14 @@ printMovePost( ModelCtxt* model, XP_U16 XP_UNUSED(moveN),
|
|||
formatTray( (const TrayTileSet*) &entry->u.trade.newTiles,
|
||||
dict, traybuf2, sizeof(traybuf2), closure->keepHidden );
|
||||
|
||||
format = dutil_getUserString( model->vol.dutil, STRSS_TRADED_FOR );
|
||||
format = dutil_getUserString( model->vol.dutil, xwe, STRSS_TRADED_FOR );
|
||||
XP_SNPRINTF( buf, sizeof(buf), format, traybuf1, traybuf2 );
|
||||
printString( stream, buf );
|
||||
addCR = XP_TRUE;
|
||||
break;
|
||||
|
||||
case PHONY_TYPE:
|
||||
format = dutil_getUserString( model->vol.dutil, STR_PHONY_REJECTED );
|
||||
format = dutil_getUserString( model->vol.dutil, xwe, STR_PHONY_REJECTED );
|
||||
printString( stream, format );
|
||||
/* FALLTHRU */
|
||||
case MOVE_TYPE:
|
||||
|
@ -2377,7 +2379,7 @@ printMovePost( ModelCtxt* model, XP_U16 XP_UNUSED(moveN),
|
|||
printString( stream, buf );
|
||||
}
|
||||
|
||||
format = dutil_getUserString( model->vol.dutil, STRD_CUMULATIVE_SCORE );
|
||||
format = dutil_getUserString( model->vol.dutil, xwe, STRD_CUMULATIVE_SCORE );
|
||||
XP_SNPRINTF( buf, sizeof(buf), format, totalScore );
|
||||
printString( stream, buf );
|
||||
|
||||
|
@ -2392,7 +2394,7 @@ printMovePost( ModelCtxt* model, XP_U16 XP_UNUSED(moveN),
|
|||
if ( entry->moveType == PHONY_TYPE ) {
|
||||
/* printString( stream, (XP_UCHAR*)"phony rejected " ); */
|
||||
} else if ( !closure->keepHidden ) {
|
||||
format = dutil_getUserString( model->vol.dutil, STRS_NEW_TILES );
|
||||
format = dutil_getUserString( model->vol.dutil, xwe, STRS_NEW_TILES );
|
||||
XP_SNPRINTF( buf, sizeof(buf), format,
|
||||
formatTray( &entry->u.move.newTiles, dict,
|
||||
traybuf1, sizeof(traybuf1),
|
||||
|
@ -2404,7 +2406,7 @@ printMovePost( ModelCtxt* model, XP_U16 XP_UNUSED(moveN),
|
|||
|
||||
break;
|
||||
case PAUSE_TYPE:
|
||||
util_formatPauseHistory( model->vol.util, stream, entry->u.pause.pauseType,
|
||||
util_formatPauseHistory( model->vol.util, xwe, stream, entry->u.pause.pauseType,
|
||||
entry->playerNum, closure->lastPauseWhen,
|
||||
entry->u.pause.when, entry->u.pause.msg );
|
||||
closure->lastPauseWhen = entry->u.pause.when;
|
||||
|
@ -2472,7 +2474,7 @@ model_writeGameHistory( ModelCtxt* model, XWEnv xwe, XWStreamCtxt* stream,
|
|||
if ( gameOver ) {
|
||||
/* if the game's over, it shouldn't matter which model I pass to this
|
||||
method */
|
||||
server_writeFinalScores( server, stream );
|
||||
server_writeFinalScores( server, xwe, stream );
|
||||
}
|
||||
} /* model_writeGameHistory */
|
||||
|
||||
|
@ -2503,7 +2505,7 @@ scoreLastMove( ModelCtxt* model, XWEnv xwe, MoveInfo* moveInfo, XP_U16 howMany,
|
|||
|
||||
copyStack( model, xwe, tmpModel->vol.stack, model->vol.stack );
|
||||
|
||||
if ( !model_undoLatestMoves( tmpModel, NULL, howMany, &turn,
|
||||
if ( !model_undoLatestMoves( tmpModel, xwe, NULL, howMany, &turn,
|
||||
&moveNum ) ) {
|
||||
XP_ASSERT( 0 );
|
||||
}
|
||||
|
@ -2511,7 +2513,7 @@ scoreLastMove( ModelCtxt* model, XWEnv xwe, MoveInfo* moveInfo, XP_U16 howMany,
|
|||
data.word[0] = '\0';
|
||||
notifyInfo.proc = getFirstWord;
|
||||
notifyInfo.closure = &data;
|
||||
score = figureMoveScore( tmpModel, turn, moveInfo, (EngineCtxt*)NULL,
|
||||
score = figureMoveScore( tmpModel, xwe, turn, moveInfo, (EngineCtxt*)NULL,
|
||||
(XWStreamCtxt*)NULL, ¬ifyInfo );
|
||||
|
||||
model_destroy( tmpModel, xwe );
|
||||
|
@ -2626,7 +2628,7 @@ model_listWordsThrough( ModelCtxt* model, XWEnv xwe, XP_U16 col, XP_U16 row,
|
|||
if ( tilesInLine( model, turn, &isHorizontal ) ) {
|
||||
MoveInfo moveInfo = {0};
|
||||
normalizeMoves( model, turn, isHorizontal, &moveInfo );
|
||||
model_makeTurnFromMoveInfo( tmpModel, turn, &moveInfo );
|
||||
model_makeTurnFromMoveInfo( tmpModel, xwe, turn, &moveInfo );
|
||||
|
||||
/* Might not be a legal move. If isn't, don't add it! */
|
||||
if ( getCurrentMoveScoreIfLegal( tmpModel, xwe, turn, (XWStreamCtxt*)NULL,
|
||||
|
@ -2634,7 +2636,7 @@ model_listWordsThrough( ModelCtxt* model, XWEnv xwe, XP_U16 col, XP_U16 row,
|
|||
TrayTileSet newTiles = {.nTiles = 0};
|
||||
commitTurn( tmpModel, xwe, turn, &newTiles, NULL, NULL, XP_TRUE );
|
||||
} else {
|
||||
model_resetCurrentTurn( tmpModel, turn );
|
||||
model_resetCurrentTurn( tmpModel, xwe, turn );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2644,7 +2646,7 @@ model_listWordsThrough( ModelCtxt* model, XWEnv xwe, XP_U16 col, XP_U16 row,
|
|||
XP_U16 nEntriesAfter;
|
||||
|
||||
/* Loop until we undo the move that placed the tile. */
|
||||
while ( model_undoLatestMoves( tmpModel, NULL, 1, NULL, NULL ) ) {
|
||||
while ( model_undoLatestMoves( tmpModel, xwe, NULL, 1, NULL, NULL ) ) {
|
||||
if ( 0 != (TILE_EMPTY_BIT & getModelTileRaw( tmpModel, col, row ) ) ) {
|
||||
break;
|
||||
}
|
||||
|
@ -2852,8 +2854,9 @@ setContains( const TrayTileSet* tiles, Tile tile )
|
|||
|
||||
#ifdef DEBUG
|
||||
static void
|
||||
assertDiffTurn( ModelCtxt* model, XP_U16 XP_UNUSED(turn),
|
||||
const StackEntry* entry, void* closure )
|
||||
assertDiffTurn( ModelCtxt* model, XWEnv XP_UNUSED(xwe),
|
||||
XP_U16 XP_UNUSED(turn), const StackEntry* entry,
|
||||
void* closure )
|
||||
{
|
||||
if ( 1 < model->nPlayers && ! model->vol.gi->inDuplicateMode ) {
|
||||
DiffTurnState* state = (DiffTurnState*)closure;
|
||||
|
|
|
@ -122,7 +122,7 @@ void model_setSize( ModelCtxt* model, XP_U16 boardSize );
|
|||
void model_destroy( ModelCtxt* model, XWEnv xwe );
|
||||
XP_U32 model_getHash( const ModelCtxt* model );
|
||||
XP_Bool model_hashMatches( const ModelCtxt* model, XP_U32 hash );
|
||||
XP_Bool model_popToHash( ModelCtxt* model, const XP_U32 hash,
|
||||
XP_Bool model_popToHash( ModelCtxt* model, XWEnv xwe, const XP_U32 hash,
|
||||
PoolContext* pool );
|
||||
|
||||
void model_setNPlayers( ModelCtxt* model, XP_U16 numPlayers );
|
||||
|
@ -147,7 +147,7 @@ void model_addNewTiles( ModelCtxt* model, XP_S16 turn,
|
|||
const TrayTileSet* tiles );
|
||||
void model_assignPlayerTiles( ModelCtxt* model, XP_S16 turn,
|
||||
const TrayTileSet* tiles );
|
||||
void model_assignDupeTiles( ModelCtxt* model, const TrayTileSet* tiles );
|
||||
void model_assignDupeTiles( ModelCtxt* model, XWEnv xwe, const TrayTileSet* tiles );
|
||||
|
||||
Tile model_getPlayerTile( const ModelCtxt* model, XP_S16 turn, XP_S16 index );
|
||||
|
||||
|
@ -172,13 +172,14 @@ void model_printTrays( const ModelCtxt* model );
|
|||
void model_sortTiles( ModelCtxt* model, XP_S16 turn );
|
||||
XP_U16 model_getNumTilesInTray( ModelCtxt* model, XP_S16 turn );
|
||||
XP_U16 model_getNumTilesTotal( ModelCtxt* model, XP_S16 turn );
|
||||
void model_moveBoardToTray( ModelCtxt* model, XP_S16 turn,
|
||||
void model_moveBoardToTray( ModelCtxt* model, XWEnv xwe, XP_S16 turn,
|
||||
XP_U16 col, XP_U16 row, XP_U16 trayOffset );
|
||||
void model_moveTrayToBoard( ModelCtxt* model, XP_S16 turn, XP_U16 col,
|
||||
void model_moveTrayToBoard( ModelCtxt* model, XWEnv xwe, XP_S16 turn, XP_U16 col,
|
||||
XP_U16 row, XP_S16 tileIndex, Tile blankFace );
|
||||
XP_Bool model_moveTileOnBoard( ModelCtxt* model, XP_S16 turn, XP_U16 colCur,
|
||||
XP_U16 rowCur, XP_U16 colNew, XP_U16 rowNew );
|
||||
XP_Bool model_redoPendingTiles( ModelCtxt* model, XP_S16 turn );
|
||||
XP_Bool model_moveTileOnBoard( ModelCtxt* model, XWEnv xwe, XP_S16 turn,
|
||||
XP_U16 colCur, XP_U16 rowCur, XP_U16 colNew,
|
||||
XP_U16 rowNew );
|
||||
XP_Bool model_redoPendingTiles( ModelCtxt* model, XWEnv xwe, XP_S16 turn );
|
||||
XP_Bool model_setBlankValue( ModelCtxt* model, XP_U16 XP_UNUSED(player),
|
||||
XP_U16 col, XP_U16 row, XP_U16 tileIndex );
|
||||
|
||||
|
@ -210,20 +211,20 @@ void model_commitDupeTurn( ModelCtxt* model, XWEnv xwe,
|
|||
TrayTileSet* newTiles );
|
||||
void model_commitDupeTrade( ModelCtxt* model, const TrayTileSet* oldTiles,
|
||||
const TrayTileSet* newTiles );
|
||||
void model_noteDupePause( ModelCtxt* model, DupPauseType typ, XP_S16 turn,
|
||||
const XP_UCHAR* msg );
|
||||
void model_cloneDupeTrays( ModelCtxt* model );
|
||||
void model_noteDupePause( ModelCtxt* model, XWEnv xwe, DupPauseType typ,
|
||||
XP_S16 turn, const XP_UCHAR* msg );
|
||||
void model_cloneDupeTrays( ModelCtxt* model, XWEnv xwe );
|
||||
|
||||
void model_commitRejectedPhony( ModelCtxt* model, XP_S16 player );
|
||||
void model_makeTileTrade( ModelCtxt* model, XP_S16 player,
|
||||
const TrayTileSet* oldTiles,
|
||||
const TrayTileSet* newTiles );
|
||||
XP_Bool model_canUndo( const ModelCtxt* model );
|
||||
XP_Bool model_undoLatestMoves( ModelCtxt* model, PoolContext* pool,
|
||||
XP_Bool model_undoLatestMoves( ModelCtxt* model, XWEnv xwe, PoolContext* pool,
|
||||
XP_U16 nMovesSought, XP_U16* turn,
|
||||
XP_S16* moveNum );
|
||||
void model_rejectPreviousMove( ModelCtxt* model, PoolContext* pool,
|
||||
XP_U16* turn );
|
||||
void model_rejectPreviousMove( ModelCtxt* model, XWEnv xwe,
|
||||
PoolContext* pool, XP_U16* turn );
|
||||
|
||||
void model_trayToStream( ModelCtxt* model, XP_S16 turn,
|
||||
XWStreamCtxt* stream );
|
||||
|
@ -231,9 +232,9 @@ void model_currentMoveToStream( ModelCtxt* model, XP_S16 turn,
|
|||
XWStreamCtxt* stream );
|
||||
void model_currentMoveToMoveInfo( ModelCtxt* model, XP_S16 turn,
|
||||
MoveInfo* moveInfo );
|
||||
XP_Bool model_makeTurnFromStream( ModelCtxt* model, XP_U16 playerNum,
|
||||
XP_Bool model_makeTurnFromStream( ModelCtxt* model, XWEnv xwe, XP_U16 playerNum,
|
||||
XWStreamCtxt* stream );
|
||||
void model_makeTurnFromMoveInfo( ModelCtxt* model, XP_U16 playerNum,
|
||||
void model_makeTurnFromMoveInfo( ModelCtxt* model, XWEnv xwe, XP_U16 playerNum,
|
||||
const MoveInfo* newMove );
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -245,7 +246,7 @@ void model_dumpSelf( const ModelCtxt* model, const XP_UCHAR* msg );
|
|||
# define model_dumpSelf( model, msg )
|
||||
#endif
|
||||
|
||||
void model_resetCurrentTurn( ModelCtxt* model, XP_S16 turn );
|
||||
void model_resetCurrentTurn( ModelCtxt* model, XWEnv xwe, XP_S16 turn );
|
||||
XP_S16 model_getNMoves( const ModelCtxt* model );
|
||||
|
||||
/* Are there two or more tiles visible */
|
||||
|
@ -256,8 +257,8 @@ XP_Bool model_canShuffle( const ModelCtxt* model, XP_U16 turn,
|
|||
XP_Bool model_canTogglePending( const ModelCtxt* model, XP_U16 turn );
|
||||
|
||||
/********************* notification ********************/
|
||||
typedef void (*BoardListener)(void* data, XP_U16 turn, XP_U16 col,
|
||||
XP_U16 row, XP_Bool added );
|
||||
typedef void (*BoardListener)( XWEnv xwe, void* data, XP_U16 turn, XP_U16 col,
|
||||
XP_U16 row, XP_Bool added );
|
||||
void model_setBoardListener( ModelCtxt* model, BoardListener bl,
|
||||
void* data );
|
||||
typedef void (*TrayListener)( void* data, XP_U16 turn,
|
||||
|
@ -269,9 +270,9 @@ typedef void (*DictListener)( void* data, XWEnv xwe, XP_S16 playerNum,
|
|||
const DictionaryCtxt* newDict );
|
||||
void model_setDictListener( ModelCtxt* model, DictListener dl,
|
||||
void* data );
|
||||
void model_foreachPendingCell( ModelCtxt* model, XP_S16 turn,
|
||||
void model_foreachPendingCell( ModelCtxt* model, XWEnv xwe, XP_S16 turn,
|
||||
BoardListener bl, void* data );
|
||||
void model_foreachPrevCell( ModelCtxt* model, BoardListener bl, void* data );
|
||||
void model_foreachPrevCell( ModelCtxt* model, XWEnv xwe, BoardListener bl, void* data );
|
||||
|
||||
void model_writeGameHistory( ModelCtxt* model, XWEnv xwe, XWStreamCtxt* stream,
|
||||
ServerCtxt* server, /* for player names */
|
||||
|
@ -317,7 +318,7 @@ XP_Bool model_listWordsThrough( ModelCtxt* model, XWEnv xwe, XP_U16 col,
|
|||
XP_Bool model_recentPassCountOk( ModelCtxt* model );
|
||||
|
||||
XWBonusType model_getSquareBonus( const ModelCtxt* model,
|
||||
XP_U16 col, XP_U16 row );
|
||||
XWEnv xwe, XP_U16 col, XP_U16 row );
|
||||
#ifdef STREAM_VERS_BIGBOARD
|
||||
void model_setSquareBonuses( ModelCtxt* model, XWBonusType* bonuses,
|
||||
XP_U16 nBonuses );
|
||||
|
@ -332,7 +333,7 @@ void model_figureFinalScores( ModelCtxt* model, ScoresArray* scores,
|
|||
ScoresArray* tilePenalties );
|
||||
|
||||
/* figureMoveScore is meant only for the engine's use */
|
||||
XP_U16 figureMoveScore( const ModelCtxt* model, XP_U16 turn,
|
||||
XP_U16 figureMoveScore( const ModelCtxt* model, XWEnv xwe, XP_U16 turn,
|
||||
const MoveInfo* mvInfo, EngineCtxt* engine,
|
||||
XWStreamCtxt* stream, WordNotifierInfo* notifyInfo );
|
||||
|
||||
|
@ -352,7 +353,8 @@ void model_packTilesUtil( ModelCtxt* model, PoolContext* pool,
|
|||
XP_U16* nUsed, const XP_UCHAR** texts,
|
||||
Tile* tiles );
|
||||
|
||||
Tile model_askBlankTile( ModelCtxt* model, XP_U16 turn, XP_U16 col, XP_U16 row);
|
||||
Tile model_askBlankTile( ModelCtxt* model, XWEnv xwe, XP_U16 turn,
|
||||
XP_U16 col, XP_U16 row);
|
||||
|
||||
XP_S16 model_getNextTurn( const ModelCtxt* model );
|
||||
|
||||
|
|
|
@ -93,7 +93,8 @@ XP_Bool tilesInLine( ModelCtxt* model, XP_S16 turn, XP_Bool* isHorizontal );
|
|||
void normalizeMoves( const ModelCtxt* model, XP_S16 turn,
|
||||
XP_Bool isHorizontal, MoveInfo* moveInfo );
|
||||
void normalizeMI( MoveInfo* moveInfoOut, const MoveInfo* moveInfoIn );
|
||||
void adjustScoreForUndone( ModelCtxt* model, const MoveInfo* mi, XP_U16 turn );
|
||||
void adjustScoreForUndone( ModelCtxt* model, XWEnv xwe, const MoveInfo* mi,
|
||||
XP_U16 turn );
|
||||
#ifdef CPLUS
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -32,8 +32,9 @@ extern "C" {
|
|||
#define IMPOSSIBLY_LOW_PENALTY (-20*MAX_TRAY_TILES)
|
||||
|
||||
/****************************** prototypes ******************************/
|
||||
static XP_Bool isLegalMove( ModelCtxt* model, MoveInfo* moves, XP_Bool silent );
|
||||
static XP_U16 word_multiplier( const ModelCtxt* model,
|
||||
static XP_Bool isLegalMove( ModelCtxt* model, XWEnv xwe, MoveInfo* moves,
|
||||
XP_Bool silent );
|
||||
static XP_U16 word_multiplier( const ModelCtxt* model, XWEnv xwe,
|
||||
XP_U16 col, XP_U16 row );
|
||||
static XP_U16 find_end( const ModelCtxt* model, XP_U16 col, XP_U16 row,
|
||||
XP_Bool isHorizontal );
|
||||
|
@ -42,7 +43,7 @@ static XP_U16 find_start( const ModelCtxt* model, XP_U16 col, XP_U16 row,
|
|||
static XP_S16 checkScoreMove( ModelCtxt* model, XWEnv xwe, XP_S16 turn,
|
||||
EngineCtxt* engine, XWStreamCtxt* stream,
|
||||
XP_Bool silent, WordNotifierInfo* notifyInfo );
|
||||
static XP_U16 scoreWord( const ModelCtxt* model, XP_U16 turn,
|
||||
static XP_U16 scoreWord( const ModelCtxt* model, XWEnv xwe, XP_U16 turn,
|
||||
const MoveInfo* movei, EngineCtxt* engine,
|
||||
XWStreamCtxt* stream, WordNotifierInfo* notifyInfo );
|
||||
|
||||
|
@ -68,7 +69,7 @@ static void wordScoreFormatterFinish( WordScoreFormatter* fmtr, Tile* word,
|
|||
XWStreamCtxt* stream );
|
||||
static void formatWordScore( XWStreamCtxt* stream, XP_U16 wordScore,
|
||||
XP_U16 moveMultiplier );
|
||||
static void formatSummary( XWStreamCtxt* stream, const ModelCtxt* model,
|
||||
static void formatSummary( XWStreamCtxt* stream, XWEnv xwe, const ModelCtxt* model,
|
||||
XP_U16 score );
|
||||
|
||||
|
||||
|
@ -95,7 +96,7 @@ scoreCurrentMove( ModelCtxt* model, XWEnv xwe, XP_S16 turn, XWStreamCtxt* stream
|
|||
} /* scoreCurrentMove */
|
||||
|
||||
void
|
||||
adjustScoreForUndone( ModelCtxt* model, const MoveInfo* mi, XP_U16 turn )
|
||||
adjustScoreForUndone( ModelCtxt* model, XWEnv xwe, const MoveInfo* mi, XP_U16 turn )
|
||||
{
|
||||
XP_U16 moveScore;
|
||||
PlayerCtxt* player = &model->players[turn];
|
||||
|
@ -103,7 +104,7 @@ adjustScoreForUndone( ModelCtxt* model, const MoveInfo* mi, XP_U16 turn )
|
|||
if ( mi->nTiles == 0 ) {
|
||||
moveScore = 0;
|
||||
} else {
|
||||
moveScore = figureMoveScore( model, turn, mi, (EngineCtxt*)NULL,
|
||||
moveScore = figureMoveScore( model, xwe, turn, mi, (EngineCtxt*)NULL,
|
||||
(XWStreamCtxt*)NULL,
|
||||
(WordNotifierInfo*)NULL );
|
||||
}
|
||||
|
@ -265,18 +266,18 @@ checkScoreMove( ModelCtxt* model, XWEnv xwe, XP_S16 turn, EngineCtxt* engine,
|
|||
score = 0;
|
||||
|
||||
if ( !!stream ) {
|
||||
formatSummary( stream, model, 0 );
|
||||
formatSummary( stream, xwe, model, 0 );
|
||||
}
|
||||
|
||||
} else if ( !tilesInLine( model, turn, &isHorizontal ) ) {
|
||||
if ( !silent ) { /* tiles out of line */
|
||||
util_userError( model->vol.util, ERR_TILES_NOT_IN_LINE );
|
||||
util_userError( model->vol.util, xwe, ERR_TILES_NOT_IN_LINE );
|
||||
}
|
||||
} else {
|
||||
MoveInfo moveInfo;
|
||||
normalizeMoves( model, turn, isHorizontal, &moveInfo );
|
||||
|
||||
if ( isLegalMove( model, &moveInfo, silent ) ) {
|
||||
if ( isLegalMove( model, xwe, &moveInfo, silent ) ) {
|
||||
/* If I'm testing for blocking, I need to chain my test onto any
|
||||
existing WordNotifierInfo. blockCheck() does that. */
|
||||
XP_Bool checkDict = PHONIES_BLOCK == model->vol.gi->phoniesAction;
|
||||
|
@ -292,13 +293,13 @@ checkScoreMove( ModelCtxt* model, XWEnv xwe, XP_S16 turn, EngineCtxt* engine,
|
|||
notifyInfo = &blockWNI;
|
||||
}
|
||||
|
||||
XP_S16 tmpScore = figureMoveScore( model, turn, &moveInfo,
|
||||
XP_S16 tmpScore = figureMoveScore( model, xwe, turn, &moveInfo,
|
||||
engine, stream, notifyInfo );
|
||||
if ( checkDict && 0 < bcs.nBadWords ) {
|
||||
if ( !silent ) {
|
||||
XP_ASSERT( !!bcs.stream );
|
||||
DictionaryCtxt* dict = model_getPlayerDict( model, turn );
|
||||
util_informWordsBlocked( model->vol.util, bcs.nBadWords,
|
||||
util_informWordsBlocked( model->vol.util, xwe, bcs.nBadWords,
|
||||
bcs.stream, dict_getName( dict ) );
|
||||
stream_destroy( bcs.stream, xwe );
|
||||
}
|
||||
|
@ -415,7 +416,7 @@ modelIsEmptyAt( const ModelCtxt* model, XP_U16 col, XP_U16 row )
|
|||
* handles dragging the tiles, will have taken care of that.
|
||||
****************************************************************************/
|
||||
static XP_Bool
|
||||
isLegalMove( ModelCtxt* model, MoveInfo* mInfo, XP_Bool silent )
|
||||
isLegalMove( ModelCtxt* model, XWEnv xwe, MoveInfo* mInfo, XP_Bool silent )
|
||||
{
|
||||
XP_Bool result = XP_TRUE;
|
||||
XP_S16 high, low;
|
||||
|
@ -453,7 +454,7 @@ isLegalMove( ModelCtxt* model, MoveInfo* mInfo, XP_Bool silent )
|
|||
++newTile;
|
||||
} else if ( modelIsEmptyAt( model, col, row ) ) {
|
||||
if ( !silent ) {
|
||||
util_userError( model->vol.util, ERR_NO_EMPTIES_IN_TURN );
|
||||
util_userError( model->vol.util, xwe, ERR_NO_EMPTIES_IN_TURN );
|
||||
}
|
||||
result = XP_FALSE;
|
||||
goto exit;
|
||||
|
@ -507,14 +508,14 @@ isLegalMove( ModelCtxt* model, MoveInfo* mInfo, XP_Bool silent )
|
|||
goto exit;
|
||||
} else {
|
||||
if ( !silent ) {
|
||||
util_userError(model->vol.util, ERR_TWO_TILES_FIRST_MOVE);
|
||||
util_userError(model->vol.util, xwe, ERR_TWO_TILES_FIRST_MOVE);
|
||||
}
|
||||
result = XP_FALSE;
|
||||
goto exit;
|
||||
}
|
||||
} else {
|
||||
if ( !silent ) {
|
||||
util_userError( model->vol.util, ERR_TILES_MUST_CONTACT );
|
||||
util_userError( model->vol.util, xwe, ERR_TILES_MUST_CONTACT );
|
||||
}
|
||||
result = XP_FALSE;
|
||||
goto exit;
|
||||
|
@ -526,7 +527,7 @@ isLegalMove( ModelCtxt* model, MoveInfo* mInfo, XP_Bool silent )
|
|||
} /* isLegalMove */
|
||||
|
||||
XP_U16
|
||||
figureMoveScore( const ModelCtxt* model, XP_U16 turn, const MoveInfo* moveInfo,
|
||||
figureMoveScore( const ModelCtxt* model, XWEnv xwe, XP_U16 turn, const MoveInfo* moveInfo,
|
||||
EngineCtxt* engine, XWStreamCtxt* stream,
|
||||
WordNotifierInfo* notifyInfo )
|
||||
{
|
||||
|
@ -553,11 +554,12 @@ figureMoveScore( const ModelCtxt* model, XP_U16 turn, const MoveInfo* moveInfo,
|
|||
|
||||
for ( ii = 0; ii < nTiles; ++ii ) {
|
||||
*incr = moveInfo->tiles[ii].varCoord;
|
||||
moveMultiplier *= multipliers[ii] = word_multiplier( model, col, row );
|
||||
moveMultiplier *= multipliers[ii] =
|
||||
word_multiplier( model, xwe, col, row );
|
||||
}
|
||||
|
||||
oneScore = scoreWord( model, turn, moveInfo, (EngineCtxt*)NULL, stream,
|
||||
notifyInfo );
|
||||
oneScore = scoreWord( model, xwe, turn, moveInfo, (EngineCtxt*)NULL,
|
||||
stream, notifyInfo );
|
||||
if ( !!stream ) {
|
||||
formatWordScore( stream, oneScore, moveMultiplier );
|
||||
}
|
||||
|
@ -574,7 +576,7 @@ figureMoveScore( const ModelCtxt* model, XP_U16 turn, const MoveInfo* moveInfo,
|
|||
tmpMI.commonCoord = tiles->varCoord;
|
||||
tmpMI.tiles[0].tile = tiles->tile;
|
||||
|
||||
oneScore = scoreWord( model, turn, &tmpMI, engine, stream, notifyInfo );
|
||||
oneScore = scoreWord( model, xwe, turn, &tmpMI, engine, stream, notifyInfo );
|
||||
if ( !!stream ) {
|
||||
formatWordScore( stream, oneScore, multipliers[ii] );
|
||||
}
|
||||
|
@ -588,22 +590,22 @@ figureMoveScore( const ModelCtxt* model, XP_U16 turn, const MoveInfo* moveInfo,
|
|||
|
||||
if ( !!stream ) {
|
||||
const XP_UCHAR* bstr = dutil_getUserString( model->vol.dutil,
|
||||
STR_BONUS_ALL );
|
||||
xwe, STR_BONUS_ALL );
|
||||
stream_catString( stream, bstr );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !!stream ) {
|
||||
formatSummary( stream, model, score );
|
||||
formatSummary( stream, xwe, model, score );
|
||||
}
|
||||
|
||||
return score;
|
||||
} /* figureMoveScore */
|
||||
|
||||
static XP_U16
|
||||
word_multiplier( const ModelCtxt* model, XP_U16 col, XP_U16 row )
|
||||
word_multiplier( const ModelCtxt* model, XWEnv xwe, XP_U16 col, XP_U16 row )
|
||||
{
|
||||
XWBonusType bonus = model_getSquareBonus( model, col, row );
|
||||
XWBonusType bonus = model_getSquareBonus( model, xwe, col, row );
|
||||
switch ( bonus ) {
|
||||
case BONUS_DOUBLE_WORD:
|
||||
return 2;
|
||||
|
@ -615,9 +617,9 @@ word_multiplier( const ModelCtxt* model, XP_U16 col, XP_U16 row )
|
|||
} /* word_multiplier */
|
||||
|
||||
static XP_U16
|
||||
tile_multiplier( const ModelCtxt* model, XP_U16 col, XP_U16 row )
|
||||
tile_multiplier( const ModelCtxt* model, XWEnv xwe, XP_U16 col, XP_U16 row )
|
||||
{
|
||||
XWBonusType bonus = model_getSquareBonus( model, col, row );
|
||||
XWBonusType bonus = model_getSquareBonus( model, xwe, col, row );
|
||||
switch ( bonus ) {
|
||||
case BONUS_DOUBLE_LETTER:
|
||||
return 2;
|
||||
|
@ -629,7 +631,7 @@ tile_multiplier( const ModelCtxt* model, XP_U16 col, XP_U16 row )
|
|||
} /* tile_multiplier */
|
||||
|
||||
static XP_U16
|
||||
scoreWord( const ModelCtxt* model, XP_U16 turn,
|
||||
scoreWord( const ModelCtxt* model, XWEnv xwe, XP_U16 turn,
|
||||
const MoveInfo* movei, /* new tiles */
|
||||
EngineCtxt* engine,/* for crosswise caching */
|
||||
XWStreamCtxt* stream,
|
||||
|
@ -678,7 +680,7 @@ scoreWord( const ModelCtxt* model, XP_U16 turn,
|
|||
thisTileValue = dict_getTileValue( dict, tile );
|
||||
|
||||
XP_ASSERT( *incr == tiles[0].varCoord );
|
||||
thisTileValue *= tile_multiplier( model, col, row );
|
||||
thisTileValue *= tile_multiplier( model, xwe, col, row );
|
||||
|
||||
XP_ASSERT( engine == NULL || nTiles == 1 );
|
||||
|
||||
|
@ -714,7 +716,7 @@ scoreWord( const ModelCtxt* model, XP_U16 turn,
|
|||
* mode, as the blank won't be known there. (Assert will
|
||||
* fail.) */
|
||||
|
||||
tileMultiplier = tile_multiplier( model, col, row );
|
||||
tileMultiplier = tile_multiplier( model, xwe, col, row );
|
||||
++tiles;
|
||||
--nTiles;
|
||||
} else { /* placed on the board before this move */
|
||||
|
@ -919,11 +921,12 @@ formatWordScore( XWStreamCtxt* stream, XP_U16 wordScore,
|
|||
} /* formatWordScore */
|
||||
|
||||
static void
|
||||
formatSummary( XWStreamCtxt* stream, const ModelCtxt* model, XP_U16 score )
|
||||
formatSummary( XWStreamCtxt* stream, XWEnv xwe,
|
||||
const ModelCtxt* model, XP_U16 score )
|
||||
{
|
||||
XP_UCHAR buf[60];
|
||||
XP_SNPRINTF( buf, sizeof(buf),
|
||||
dutil_getUserString(model->vol.dutil, STRD_TURN_SCORE),
|
||||
dutil_getUserString(model->vol.dutil, xwe, STRD_TURN_SCORE),
|
||||
score );
|
||||
XP_ASSERT( XP_STRLEN(buf) < sizeof(buf) );
|
||||
stream_catString( stream, buf );
|
||||
|
|
|
@ -62,16 +62,16 @@ static void enableOne( NewGameCtx* ngc, XP_U16 player, NewGameColumn col,
|
|||
XP_TriEnable enable, XP_Bool force );
|
||||
static void adjustAllRows( NewGameCtx* ngc, XP_Bool force );
|
||||
static void adjustOneRow( NewGameCtx* ngc, XP_U16 player, XP_Bool force );
|
||||
static void setRoleStrings( NewGameCtx* ngc );
|
||||
static void setRoleStrings( NewGameCtx* ngc, XWEnv xwe );
|
||||
static void considerEnable( NewGameCtx* ngc );
|
||||
static void storePlayer( NewGameCtx* ngc, XP_U16 player, LocalPlayer* lp );
|
||||
static void loadPlayer( NewGameCtx* ngc, XP_U16 player,
|
||||
const LocalPlayer* lp );
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
static XP_Bool changeRole( NewGameCtx* ngc, DeviceRole role );
|
||||
static XP_Bool checkConsistent( NewGameCtx* ngc, XP_Bool warnUser );
|
||||
static XP_Bool changeRole( NewGameCtx* ngc, XWEnv xwe, DeviceRole role );
|
||||
static XP_Bool checkConsistent( NewGameCtx* ngc, XWEnv xwe, XP_Bool warnUser );
|
||||
#else
|
||||
# define checkConsistent( ngc, warnUser ) XP_TRUE
|
||||
# define checkConsistent( ngc, xwe, warnUser ) XP_TRUE
|
||||
#endif
|
||||
|
||||
NewGameCtx*
|
||||
|
@ -105,7 +105,7 @@ newg_destroy( NewGameCtx* ngc )
|
|||
} /* newg_destroy */
|
||||
|
||||
void
|
||||
newg_load( NewGameCtx* ngc, const CurGameInfo* gi )
|
||||
newg_load( NewGameCtx* ngc, XWEnv xwe, const CurGameInfo* gi )
|
||||
{
|
||||
void* closure = ngc->closure;
|
||||
NGValue value;
|
||||
|
@ -164,7 +164,7 @@ newg_load( NewGameCtx* ngc, const CurGameInfo* gi )
|
|||
value.ng_u16 = ngc->timerSeconds;
|
||||
(*ngc->setAttrProc)( closure, NG_ATTR_TIMER, value );
|
||||
|
||||
setRoleStrings( ngc );
|
||||
setRoleStrings( ngc, xwe );
|
||||
considerEnable( ngc );
|
||||
|
||||
/* Load local players first */
|
||||
|
@ -227,10 +227,10 @@ cpToLP( NGValue value, const void* cbClosure )
|
|||
} /* cpToLP */
|
||||
|
||||
XP_Bool
|
||||
newg_store( NewGameCtx* ngc, CurGameInfo* gi,
|
||||
newg_store( NewGameCtx* ngc, XWEnv xwe, CurGameInfo* gi,
|
||||
XP_Bool XP_UNUSED_STANDALONE(warn) )
|
||||
{
|
||||
XP_Bool consistent = checkConsistent( ngc, warn );
|
||||
XP_Bool consistent = checkConsistent( ngc, xwe, warn );
|
||||
|
||||
if ( consistent ) {
|
||||
XP_Bool makeLocal = XP_FALSE;
|
||||
|
@ -268,7 +268,8 @@ newg_colChanged( NewGameCtx* ngc, XP_U16 player )
|
|||
}
|
||||
|
||||
void
|
||||
newg_attrChanged( NewGameCtx* ngc, NewGameAttr attr, NGValue value )
|
||||
newg_attrChanged( NewGameCtx* ngc, XWEnv xwe,
|
||||
NewGameAttr attr, NGValue value )
|
||||
{
|
||||
XP_Bool changed = XP_FALSE;
|
||||
switch ( attr ) {
|
||||
|
@ -281,7 +282,7 @@ newg_attrChanged( NewGameCtx* ngc, NewGameAttr attr, NGValue value )
|
|||
break;
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
case NG_ATTR_ROLE:
|
||||
changed = changeRole( ngc, value.ng_role );
|
||||
changed = changeRole( ngc, xwe, value.ng_role );
|
||||
break;
|
||||
#endif
|
||||
case NG_ATTR_TIMER:
|
||||
|
@ -373,7 +374,7 @@ newg_juggle( NewGameCtx* ngc )
|
|||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
static XP_Bool
|
||||
checkConsistent( NewGameCtx* ngc, XP_Bool warnUser )
|
||||
checkConsistent( NewGameCtx* ngc, XWEnv xwe, XP_Bool warnUser )
|
||||
{
|
||||
XP_Bool consistent;
|
||||
XP_U16 ii;
|
||||
|
@ -390,7 +391,7 @@ checkConsistent( NewGameCtx* ngc, XP_Bool warnUser )
|
|||
}
|
||||
}
|
||||
if ( !consistent && warnUser ) {
|
||||
util_userError( ngc->util, ERR_REG_SERVER_SANS_REMOTE );
|
||||
util_userError( ngc->util, xwe, ERR_REG_SERVER_SANS_REMOTE );
|
||||
}
|
||||
|
||||
/* Add other consistency checks, and error messages, here. */
|
||||
|
@ -511,7 +512,7 @@ adjustOneRow( NewGameCtx* ngc, XP_U16 player, XP_Bool force )
|
|||
*/
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
static XP_Bool
|
||||
changeRole( NewGameCtx* ngc, DeviceRole newRole )
|
||||
changeRole( NewGameCtx* ngc, XWEnv xwe, DeviceRole newRole )
|
||||
{
|
||||
DeviceRole oldRole = ngc->role;
|
||||
XP_Bool changing = oldRole != newRole;
|
||||
|
@ -529,14 +530,14 @@ changeRole( NewGameCtx* ngc, DeviceRole newRole )
|
|||
}
|
||||
}
|
||||
ngc->role = newRole;
|
||||
setRoleStrings( ngc );
|
||||
setRoleStrings( ngc, xwe );
|
||||
}
|
||||
return changing;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
setRoleStrings( NewGameCtx* ngc )
|
||||
setRoleStrings( NewGameCtx* ngc, XWEnv xwe )
|
||||
{
|
||||
XP_U16 strID;
|
||||
NGValue value;
|
||||
|
@ -561,7 +562,8 @@ setRoleStrings( NewGameCtx* ngc )
|
|||
strID = STR_TOTALPLAYERS;
|
||||
}
|
||||
|
||||
value.ng_cp = dutil_getUserString( util_getDevUtilCtxt(ngc->util), strID );
|
||||
value.ng_cp = dutil_getUserString( util_getDevUtilCtxt(ngc->util, xwe),
|
||||
xwe, strID );
|
||||
(*ngc->setAttrProc)( closure, NG_ATTR_NPLAYHEADER, value );
|
||||
} /* setRoleStrings */
|
||||
|
||||
|
|
|
@ -101,11 +101,11 @@ NewGameCtx* newg_make( MPFORMAL XP_Bool isNewGame,
|
|||
void* closure );
|
||||
void newg_destroy( NewGameCtx* ngc );
|
||||
|
||||
void newg_load( NewGameCtx* ngc, const CurGameInfo* gi );
|
||||
XP_Bool newg_store( NewGameCtx* ngc, CurGameInfo* gi, XP_Bool warn );
|
||||
void newg_load( NewGameCtx* ngc, XWEnv xwe, const CurGameInfo* gi );
|
||||
XP_Bool newg_store( NewGameCtx* ngc, XWEnv xwe, CurGameInfo* gi, XP_Bool warn );
|
||||
|
||||
void newg_colChanged( NewGameCtx* ngc, XP_U16 player );
|
||||
void newg_attrChanged( NewGameCtx* ngc, NewGameAttr attr,
|
||||
void newg_attrChanged( NewGameCtx* ngc, XWEnv xwe, NewGameAttr attr,
|
||||
NGValue value );
|
||||
|
||||
/** newg_juggle: Return XP_TRUE if a juggle happened, XP_FALSE if randomness
|
||||
|
|
|
@ -267,7 +267,7 @@ drawScoreBoard( BoardCtxt* board, XWEnv xwe )
|
|||
dp->dsi.isRemote = !lp->isLocal;
|
||||
XP_ASSERT( !isMissing || dp->dsi.isRemote );
|
||||
if ( dp->dsi.isRemote && isMissing ) {
|
||||
dp->dsi.name = dutil_getUserString( board->dutil, STR_PENDING_PLAYER );
|
||||
dp->dsi.name = dutil_getUserString( board->dutil, xwe, STR_PENDING_PLAYER );
|
||||
} else {
|
||||
dp->dsi.name = emptyStringIfNull( lp->name );
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ void
|
|||
drawTimer( const BoardCtxt* board, XWEnv xwe )
|
||||
{
|
||||
if ( !!board->draw && board->gi->timerEnabled ) {
|
||||
XP_S16 secondsLeft = server_getTimerSeconds( board->server,
|
||||
XP_S16 secondsLeft = server_getTimerSeconds( board->server, xwe,
|
||||
board->selPlayer );
|
||||
XP_Bool turnDone = board->gi->inDuplicateMode
|
||||
? server_dupTurnDone( board->server, board->selPlayer )
|
||||
|
@ -409,20 +409,20 @@ figureScoreRectTapped( const BoardCtxt* board, XP_U16 xx, XP_U16 yy )
|
|||
*/
|
||||
#if defined POINTER_SUPPORT || defined KEYBOARD_NAV
|
||||
XP_Bool
|
||||
handlePenUpScore( BoardCtxt* board, XP_U16 xx, XP_U16 yy, XP_Bool altDown )
|
||||
handlePenUpScore( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy, XP_Bool altDown )
|
||||
{
|
||||
XP_Bool result = XP_TRUE;
|
||||
|
||||
XP_S16 rectNum = figureScoreRectTapped( board, xx, yy );
|
||||
|
||||
if ( rectNum == CURSOR_LOC_REM ) {
|
||||
util_remSelected( board->util );
|
||||
util_remSelected( board->util, xwe );
|
||||
} else if ( --rectNum >= 0 ) {
|
||||
XP_Bool canSwitch = board->gameOver || board->allowPeek;
|
||||
if ( altDown || !canSwitch ) {
|
||||
penTimerFiredScore( board );
|
||||
penTimerFiredScore( board, xwe );
|
||||
} else {
|
||||
board_selectPlayer( board, rectNum, XP_TRUE );
|
||||
board_selectPlayer( board, xwe, rectNum, XP_TRUE );
|
||||
}
|
||||
} else {
|
||||
result = XP_FALSE;
|
||||
|
@ -432,7 +432,7 @@ handlePenUpScore( BoardCtxt* board, XP_U16 xx, XP_U16 yy, XP_Bool altDown )
|
|||
#endif
|
||||
|
||||
void
|
||||
penTimerFiredScore( const BoardCtxt* board )
|
||||
penTimerFiredScore( const BoardCtxt* board, XWEnv xwe )
|
||||
{
|
||||
XP_S16 scoreIndex = figureScoreRectTapped( board, board->penDownX,
|
||||
board->penDownY );
|
||||
|
@ -459,7 +459,7 @@ penTimerFiredScore( const BoardCtxt* board )
|
|||
}
|
||||
text = buf;
|
||||
#else
|
||||
util_playerScoreHeld( board->util, player );
|
||||
util_playerScoreHeld( board->util, xwe, player );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,11 @@
|
|||
void drawScoreBoard( BoardCtxt* board, XWEnv xwe );
|
||||
XP_S16 figureScoreRectTapped( const BoardCtxt* board, XP_U16 x, XP_U16 y );
|
||||
void drawTimer( const BoardCtxt* board, XWEnv xwe );
|
||||
void penTimerFiredScore( const BoardCtxt* board );
|
||||
void penTimerFiredScore( const BoardCtxt* board, XWEnv xwe );
|
||||
|
||||
#if defined POINTER_SUPPORT || defined KEYBOARD_NAV
|
||||
XP_Bool handlePenUpScore( BoardCtxt* board, XP_U16 xx, XP_U16 yy, XP_Bool altDown );
|
||||
XP_Bool handlePenUpScore( BoardCtxt* board, XWEnv xwe, XP_U16 xx,
|
||||
XP_U16 yy, XP_Bool altDown );
|
||||
#endif
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -30,10 +30,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
ServerCtxt* server_make( MPFORMAL ModelCtxt* model, CommsCtxt* comms,
|
||||
ServerCtxt* server_make( MPFORMAL XWEnv xwe, ModelCtxt* model, CommsCtxt* comms,
|
||||
XW_UtilCtxt* util );
|
||||
|
||||
ServerCtxt* server_makeFromStream( MPFORMAL XWStreamCtxt* stream,
|
||||
ServerCtxt* server_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream,
|
||||
ModelCtxt* model, CommsCtxt* comms,
|
||||
XW_UtilCtxt* util, XP_U16 nPlayers );
|
||||
|
||||
|
@ -44,16 +44,16 @@ void server_destroy( ServerCtxt* server, XWEnv xwe );
|
|||
|
||||
void server_prefsChanged( ServerCtxt* server, const CommonPrefs* cp );
|
||||
|
||||
typedef void (*TurnChangeListener)( void* data );
|
||||
typedef void (*TurnChangeListener)( XWEnv xwe, void* data );
|
||||
void server_setTurnChangeListener( ServerCtxt* server, TurnChangeListener tl,
|
||||
void* data );
|
||||
|
||||
typedef void (*TimerChangeListener)( void* data, XP_U32 gameID,
|
||||
typedef void (*TimerChangeListener)( XWEnv xwe, void* data, XP_U32 gameID,
|
||||
XP_S32 oldVal, XP_S32 newVal );
|
||||
void server_setTimerChangeListener( ServerCtxt* server, TimerChangeListener tl,
|
||||
void* data );
|
||||
|
||||
typedef void (*GameOverListener)( void* data, XP_S16 quitter );
|
||||
typedef void (*GameOverListener)( XWEnv xwe, void* data, XP_S16 quitter );
|
||||
void server_setGameOverListener( ServerCtxt* server, GameOverListener gol,
|
||||
void* data );
|
||||
|
||||
|
@ -78,7 +78,7 @@ XP_S16 server_getCurrentTurn( const ServerCtxt* server, XP_Bool* isLocal );
|
|||
XP_Bool server_isPlayersTurn( const ServerCtxt* server, XP_U16 turn );
|
||||
XP_Bool server_getGameIsOver( const ServerCtxt* server );
|
||||
XP_S32 server_getDupTimerExpires( const ServerCtxt* server );
|
||||
XP_S16 server_getTimerSeconds( const ServerCtxt* server, XP_U16 turn );
|
||||
XP_S16 server_getTimerSeconds( const ServerCtxt* server, XWEnv xwe, XP_U16 turn );
|
||||
XP_Bool server_dupTurnDone( const ServerCtxt* server, XP_U16 turn );
|
||||
XP_Bool server_canPause( const ServerCtxt* server );
|
||||
XP_Bool server_canUnpause( const ServerCtxt* server );
|
||||
|
@ -91,9 +91,9 @@ XP_U32 server_getLastMoveTime( const ServerCtxt* server );
|
|||
/* Signed in case no dictionary available */
|
||||
XP_S16 server_countTilesInPool( ServerCtxt* server );
|
||||
|
||||
XP_Bool server_askPickTiles( ServerCtxt* server, XP_U16 player,
|
||||
XP_Bool server_askPickTiles( ServerCtxt* server, XWEnv xwe, XP_U16 player,
|
||||
TrayTileSet* newTiles, XP_U16 nToPick );
|
||||
void server_tilesPicked( ServerCtxt* server, XP_U16 player,
|
||||
void server_tilesPicked( ServerCtxt* server, XWEnv xwe, XP_U16 player,
|
||||
const TrayTileSet* newTiles );
|
||||
|
||||
XP_U16 server_getPendingRegs( const ServerCtxt* server );
|
||||
|
@ -124,12 +124,12 @@ void server_sendChat( ServerCtxt* server, XWEnv xwe,
|
|||
const XP_UCHAR* msg, XP_S16 from );
|
||||
#endif
|
||||
|
||||
void server_formatDictCounts( ServerCtxt* server, XWStreamCtxt* stream,
|
||||
void server_formatDictCounts( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream,
|
||||
XP_U16 nCols, XP_Bool allFaces );
|
||||
void server_formatRemainingTiles( ServerCtxt* server, XWStreamCtxt* stream,
|
||||
XP_S16 player );
|
||||
void server_formatRemainingTiles( ServerCtxt* server, XWEnv xwe,
|
||||
XWStreamCtxt* stream, XP_S16 player );
|
||||
|
||||
void server_writeFinalScores( ServerCtxt* server, XWStreamCtxt* stream );
|
||||
void server_writeFinalScores( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream );
|
||||
|
||||
#ifdef XWFEATURE_BONUSALL
|
||||
XP_U16 server_figureFinishBonus( const ServerCtxt* server, XP_U16 turn );
|
||||
|
|
|
@ -87,10 +87,11 @@ struct SMSProto {
|
|||
#define KEY_PARTIALS PERSIST_KEY("partials")
|
||||
#define KEY_NEXTID PERSIST_KEY("nextID")
|
||||
|
||||
static int nextMsgID( SMSProto* state );
|
||||
static int nextMsgID( SMSProto* state, XWEnv xwe );
|
||||
static XWStreamCtxt* mkStream( SMSProto* state );
|
||||
static void destroyStream( XWStreamCtxt* stream );
|
||||
static SMSMsgArray* toNetMsgs( SMSProto* state, ToPhoneRec* rec, XP_Bool forceOld );
|
||||
static SMSMsgArray* toNetMsgs( SMSProto* state, XWEnv xwe, ToPhoneRec* rec,
|
||||
XP_Bool forceOld );
|
||||
static ToPhoneRec* getForPhone( SMSProto* state, const XP_UCHAR* phone,
|
||||
XP_Bool create );
|
||||
static void addToOutRec( SMSProto* state, ToPhoneRec* rec, SMS_CMD cmd,
|
||||
|
@ -101,8 +102,8 @@ static void addMessage( SMSProto* state, const XP_UCHAR* fromPhone, int msgID,
|
|||
static SMSMsgArray* completeMsgs( SMSProto* state, SMSMsgArray* arr,
|
||||
const XP_UCHAR* fromPhone, XP_U16 wantPort,
|
||||
int msgID );
|
||||
static void savePartials( SMSProto* state );
|
||||
static void restorePartials( SMSProto* state );
|
||||
static void savePartials( SMSProto* state, XWEnv xwe );
|
||||
static void restorePartials( SMSProto* state, XWEnv xwe );
|
||||
static void rmFromPhoneRec( SMSProto* state, int fromPhoneIndex );
|
||||
static void freeMsgIDRec( SMSProto* state, MsgIDRec* rec, int fromPhoneIndex,
|
||||
int msgIDIndex );
|
||||
|
@ -110,13 +111,14 @@ static void freeForPhone( SMSProto* state, const XP_UCHAR* phone );
|
|||
static void freeMsg( SMSProto* state, MsgRec** msg );
|
||||
static void freeRec( SMSProto* state, ToPhoneRec* rec );
|
||||
#ifdef DEBUG
|
||||
static void logResult( const SMSProto* state, const SMSMsgArray* result, const char* caller );
|
||||
static void logResult( const SMSProto* state, XWEnv xwe,
|
||||
const SMSMsgArray* result, const char* caller );
|
||||
#else
|
||||
# define logResult( state, result, caller )
|
||||
#endif
|
||||
|
||||
SMSProto*
|
||||
smsproto_init( MPFORMAL XW_DUtilCtxt* dutil )
|
||||
smsproto_init( MPFORMAL XWEnv xwe, XW_DUtilCtxt* dutil )
|
||||
{
|
||||
SMSProto* state = (SMSProto*)XP_CALLOC( mpool, sizeof(*state) );
|
||||
pthread_mutex_init( &state->mutex, NULL );
|
||||
|
@ -124,10 +126,10 @@ smsproto_init( MPFORMAL XW_DUtilCtxt* dutil )
|
|||
MPASSIGN( state->mpool, mpool );
|
||||
|
||||
XP_U16 siz = sizeof(state->nNextID);
|
||||
dutil_loadPtr( state->dutil, KEY_NEXTID, &state->nNextID, &siz );
|
||||
dutil_loadPtr( state->dutil, xwe, KEY_NEXTID, &state->nNextID, &siz );
|
||||
XP_LOGF( "%s(): loaded nextMsgID: %d", __func__, state->nNextID );
|
||||
|
||||
restorePartials( state );
|
||||
restorePartials( state, xwe );
|
||||
|
||||
return state;
|
||||
}
|
||||
|
@ -212,7 +214,7 @@ headerFromStream( XWStreamCtxt* stream, SMS_CMD* cmd, XP_U16* port, XP_U32* game
|
|||
* UtilCtxt around.
|
||||
*/
|
||||
SMSMsgArray*
|
||||
smsproto_prepOutbound( SMSProto* state, SMS_CMD cmd, XP_U32 gameID,
|
||||
smsproto_prepOutbound( SMSProto* state, XWEnv xwe, SMS_CMD cmd, XP_U32 gameID,
|
||||
const void* buf, XP_U16 buflen, const XP_UCHAR* toPhone,
|
||||
int toPort, XP_Bool forceOld, XP_U16* waitSecsP )
|
||||
{
|
||||
|
@ -221,7 +223,7 @@ smsproto_prepOutbound( SMSProto* state, SMS_CMD cmd, XP_U32 gameID,
|
|||
pthread_mutex_lock( &state->mutex );
|
||||
|
||||
#ifdef DEBUG
|
||||
XP_UCHAR* checksum = dutil_md5sum( state->dutil, buf, buflen );
|
||||
XP_UCHAR* checksum = dutil_md5sum( state->dutil, xwe, buf, buflen );
|
||||
XP_LOGFF( "(cmd=%d, gameID=%d): len=%d, sum=%s, toPhone=%s", cmd,
|
||||
gameID, buflen, checksum, toPhone );
|
||||
XP_FREEP( state->mpool, &checksum );
|
||||
|
@ -230,7 +232,7 @@ smsproto_prepOutbound( SMSProto* state, SMS_CMD cmd, XP_U32 gameID,
|
|||
ToPhoneRec* rec = getForPhone( state, toPhone, cmd != NONE );
|
||||
|
||||
/* First, add the new message (if present) to the array */
|
||||
XP_U32 nowSeconds = dutil_getCurSeconds( state->dutil );
|
||||
XP_U32 nowSeconds = dutil_getCurSeconds( state->dutil, xwe );
|
||||
if ( cmd != NONE && 0 < buflen ) {
|
||||
addToOutRec( state, rec, cmd, toPort, gameID, buf, buflen, nowSeconds );
|
||||
}
|
||||
|
@ -245,7 +247,7 @@ smsproto_prepOutbound( SMSProto* state, SMS_CMD cmd, XP_U32 gameID,
|
|||
}
|
||||
|
||||
if ( doSend ) {
|
||||
result = toNetMsgs( state, rec, forceOld );
|
||||
result = toNetMsgs( state, xwe, rec, forceOld );
|
||||
freeForPhone( state, toPhone );
|
||||
}
|
||||
|
||||
|
@ -259,7 +261,7 @@ smsproto_prepOutbound( SMSProto* state, SMS_CMD cmd, XP_U32 gameID,
|
|||
!!result ? result->nMsgs : 0, *waitSecsP );
|
||||
|
||||
pthread_mutex_unlock( &state->mutex );
|
||||
logResult( state, result, __func__ );
|
||||
logResult( state, xwe, result, __func__ );
|
||||
return result;
|
||||
} /* smsproto_prepOutbound */
|
||||
|
||||
|
@ -296,13 +298,13 @@ appendNetMsg( SMSProto* XP_UNUSED_DBG(state), SMSMsgArray* arr, SMSMsgNet* msg )
|
|||
}
|
||||
|
||||
SMSMsgArray*
|
||||
smsproto_prepInbound( SMSProto* state, const XP_UCHAR* fromPhone,
|
||||
smsproto_prepInbound( SMSProto* state, XWEnv xwe, const XP_UCHAR* fromPhone,
|
||||
XP_U16 wantPort, const XP_U8* data, XP_U16 len )
|
||||
{
|
||||
XP_LOGFF( "len=%d, fromPhone=%s", len, fromPhone );
|
||||
|
||||
#ifdef DEBUG
|
||||
XP_UCHAR* checksum = dutil_md5sum( state->dutil, data, len );
|
||||
XP_UCHAR* checksum = dutil_md5sum( state->dutil, xwe, data, len );
|
||||
XP_LOGFF( "(fromPhone=%s, len=%d); sum=%s", fromPhone, len, checksum );
|
||||
XP_FREEP( state->mpool, &checksum );
|
||||
#endif
|
||||
|
@ -327,7 +329,7 @@ smsproto_prepInbound( SMSProto* state, const XP_UCHAR* fromPhone,
|
|||
stream_getBytes( stream, buf, len );
|
||||
addMessage( state, fromPhone, msgID, indx, count, buf, len );
|
||||
result = completeMsgs( state, result, fromPhone, wantPort, msgID );
|
||||
savePartials( state );
|
||||
savePartials( state, xwe );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -376,7 +378,7 @@ smsproto_prepInbound( SMSProto* state, const XP_UCHAR* fromPhone,
|
|||
destroyStream( stream );
|
||||
|
||||
XP_LOGFF( "=> %p (len=%d)", result, (!!result) ? result->nMsgs : 0 );
|
||||
logResult( state, result, __func__ );
|
||||
logResult( state, xwe, result, __func__ );
|
||||
|
||||
pthread_mutex_unlock( &state->mutex );
|
||||
return result;
|
||||
|
@ -412,7 +414,8 @@ smsproto_freeMsgArray( SMSProto* state, SMSMsgArray* arr )
|
|||
|
||||
#ifdef DEBUG
|
||||
static void
|
||||
logResult( const SMSProto* state, const SMSMsgArray* result, const char* caller )
|
||||
logResult( const SMSProto* state, XWEnv xwe, const SMSMsgArray* result,
|
||||
const char* caller )
|
||||
{
|
||||
if ( !!result ) {
|
||||
for ( int ii = 0; ii < result->nMsgs; ++ii ) {
|
||||
|
@ -435,7 +438,7 @@ logResult( const SMSProto* state, const SMSMsgArray* result, const char* caller
|
|||
XP_ASSERT(0);
|
||||
}
|
||||
XP_ASSERT( 0 < len );
|
||||
XP_UCHAR* checksum = dutil_md5sum( state->dutil, data, len );
|
||||
XP_UCHAR* checksum = dutil_md5sum( state->dutil, xwe, data, len );
|
||||
XP_LOGFF( "%s() => datum[%d] sum: %s, len: %d", caller, ii, checksum, len );
|
||||
XP_FREEP( state->mpool, &checksum );
|
||||
}
|
||||
|
@ -670,7 +673,7 @@ freeMsgIDRec( SMSProto* state, MsgIDRec* XP_UNUSED_DBG(rec), int fromPhoneIndex,
|
|||
}
|
||||
|
||||
static void
|
||||
savePartials( SMSProto* state )
|
||||
savePartials( SMSProto* state, XWEnv xwe )
|
||||
{
|
||||
XWStreamCtxt* stream = mkStream( state );
|
||||
stream_putU8( stream, PARTIALS_FORMAT );
|
||||
|
@ -698,7 +701,7 @@ savePartials( SMSProto* state )
|
|||
if ( state->lastStoredSize == 2 && newSize == 2 ) {
|
||||
XP_LOGFF( "not storing empty again" );
|
||||
} else {
|
||||
dutil_storeStream( state->dutil, KEY_PARTIALS, stream );
|
||||
dutil_storeStream( state->dutil, xwe, KEY_PARTIALS, stream );
|
||||
state->lastStoredSize = newSize;
|
||||
}
|
||||
|
||||
|
@ -708,11 +711,11 @@ savePartials( SMSProto* state )
|
|||
} /* savePartials */
|
||||
|
||||
static void
|
||||
restorePartials( SMSProto* state )
|
||||
restorePartials( SMSProto* state, XWEnv xwe )
|
||||
{
|
||||
XWStreamCtxt* stream = mkStream( state );
|
||||
|
||||
dutil_loadStream( state->dutil, KEY_PARTIALS, stream );
|
||||
dutil_loadStream( state->dutil, xwe, KEY_PARTIALS, stream );
|
||||
if ( stream_getSize( stream ) >= 1
|
||||
&& PARTIALS_FORMAT == stream_getU8( stream ) ) {
|
||||
int nFromPhones = stream_getU8( stream );
|
||||
|
@ -795,7 +798,7 @@ completeMsgs( SMSProto* state, SMSMsgArray* arr, const XP_UCHAR* fromPhone,
|
|||
}
|
||||
|
||||
static SMSMsgArray*
|
||||
toNetMsgs( SMSProto* state, ToPhoneRec* rec, XP_Bool forceOld )
|
||||
toNetMsgs( SMSProto* state, XWEnv xwe, ToPhoneRec* rec, XP_Bool forceOld )
|
||||
{
|
||||
SMSMsgArray* result = NULL;
|
||||
|
||||
|
@ -831,14 +834,14 @@ toNetMsgs( SMSProto* state, ToPhoneRec* rec, XP_Bool forceOld )
|
|||
for ( int jj = ii; jj < last; ++jj ) {
|
||||
const SMSMsgNet* msg = &rec->msgs[jj]->msgNet;
|
||||
newMsg.data[indx++] = msg->len;
|
||||
newMsg.data[indx++] = nextMsgID( state );
|
||||
newMsg.data[indx++] = nextMsgID( state, xwe );
|
||||
XP_MEMCPY( &newMsg.data[indx], msg->data, msg->len ); /* bad! */
|
||||
indx += msg->len;
|
||||
}
|
||||
result = appendNetMsg( state, result, &newMsg );
|
||||
ii = last;
|
||||
} else {
|
||||
int msgID = nextMsgID( state );
|
||||
int msgID = nextMsgID( state, xwe );
|
||||
const SMSMsgNet* msg = &rec->msgs[ii]->msgNet;
|
||||
XP_U8* nextStart = msg->data;
|
||||
XP_U16 lenLeft = msg->len;
|
||||
|
@ -870,10 +873,10 @@ toNetMsgs( SMSProto* state, ToPhoneRec* rec, XP_Bool forceOld )
|
|||
} /* toMsgs */
|
||||
|
||||
static int
|
||||
nextMsgID( SMSProto* state )
|
||||
nextMsgID( SMSProto* state, XWEnv xwe )
|
||||
{
|
||||
int result = ++state->nNextID % 0x000000FF;
|
||||
dutil_storePtr( state->dutil, KEY_NEXTID, &state->nNextID,
|
||||
dutil_storePtr( state->dutil, xwe, KEY_NEXTID, &state->nNextID,
|
||||
sizeof(state->nNextID) );
|
||||
LOG_RETURNF( "%d", result );
|
||||
return result;
|
||||
|
@ -895,10 +898,10 @@ destroyStream( XWStreamCtxt* stream )
|
|||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
smsproto_runTests( MPFORMAL XW_DUtilCtxt* dutil )
|
||||
smsproto_runTests( MPFORMAL XWEnv xwe, XW_DUtilCtxt* dutil )
|
||||
{
|
||||
LOG_FUNC();
|
||||
SMSProto* state = smsproto_init( mpool, dutil );
|
||||
SMSProto* state = smsproto_init( mpool, xwe, dutil );
|
||||
|
||||
const int smallSiz = 20;
|
||||
const char* phones[] = {"1234", "3456", "5467", "9877"};
|
||||
|
@ -923,10 +926,10 @@ smsproto_runTests( MPFORMAL XW_DUtilCtxt* dutil )
|
|||
XP_U16 waitSecs;
|
||||
if ( firstTime ) {
|
||||
XP_U16 len = (ii + 1) * 30;
|
||||
arrs[ii] = smsproto_prepOutbound( state, DATA, gameID, buf, len, phones[ii],
|
||||
arrs[ii] = smsproto_prepOutbound( state, xwe, DATA, gameID, buf, len, phones[ii],
|
||||
port, forceOld, &waitSecs );
|
||||
} else if ( NULL == arrs[ii]) {
|
||||
arrs[ii] = smsproto_prepOutbound( state, DATA, gameID, NULL, 0, phones[ii],
|
||||
arrs[ii] = smsproto_prepOutbound( state, xwe, DATA, gameID, NULL, 0, phones[ii],
|
||||
port, forceOld, &waitSecs );
|
||||
} else {
|
||||
continue;
|
||||
|
@ -946,7 +949,7 @@ smsproto_runTests( MPFORMAL XW_DUtilCtxt* dutil )
|
|||
if (!!arrs[ii] && indx < arrs[ii]->nMsgs) {
|
||||
XP_ASSERT( arrs[ii]->format == FORMAT_NET );
|
||||
haveOne = XP_TRUE;
|
||||
SMSMsgArray* outArr = smsproto_prepInbound( state, phones[ii], port,
|
||||
SMSMsgArray* outArr = smsproto_prepInbound( state, xwe, phones[ii], port,
|
||||
arrs[ii]->u.msgsNet[indx].data,
|
||||
arrs[ii]->u.msgsNet[indx].len );
|
||||
if ( !!outArr ) {
|
||||
|
@ -972,7 +975,7 @@ smsproto_runTests( MPFORMAL XW_DUtilCtxt* dutil )
|
|||
/* Now let's send a bunch of small messages that should get combined */
|
||||
for ( int nUsed = 0; ; ++nUsed ) {
|
||||
XP_U16 waitSecs;
|
||||
SMSMsgArray* sendArr = smsproto_prepOutbound( state, DATA, gameID, &buf[nUsed],
|
||||
SMSMsgArray* sendArr = smsproto_prepOutbound( state, xwe, DATA, gameID, &buf[nUsed],
|
||||
smallSiz, phones[0], port,
|
||||
XP_FALSE, &waitSecs );
|
||||
if ( sendArr == NULL ) {
|
||||
|
@ -984,7 +987,7 @@ smsproto_runTests( MPFORMAL XW_DUtilCtxt* dutil )
|
|||
XP_ASSERT( sendArr->format == FORMAT_NET );
|
||||
int totalBack = 0;
|
||||
for ( int jj = 0; jj < sendArr->nMsgs; ++jj ) {
|
||||
SMSMsgArray* recvArr = smsproto_prepInbound( state, phones[0], port,
|
||||
SMSMsgArray* recvArr = smsproto_prepInbound( state, xwe, phones[0], port,
|
||||
sendArr->u.msgsNet[jj].data,
|
||||
sendArr->u.msgsNet[jj].len );
|
||||
|
||||
|
@ -1013,21 +1016,21 @@ smsproto_runTests( MPFORMAL XW_DUtilCtxt* dutil )
|
|||
/* Now let's add a too-long message and unpack only the first part. Make
|
||||
sure it's cleaned up correctly */
|
||||
XP_U16 waitSecs;
|
||||
SMSMsgArray* arr = smsproto_prepOutbound( state, DATA, gameID, buf, 200, "33333",
|
||||
SMSMsgArray* arr = smsproto_prepOutbound( state, xwe, DATA, gameID, buf, 200, "33333",
|
||||
port, XP_TRUE, &waitSecs );
|
||||
XP_ASSERT( !!arr && arr->nMsgs > 1 );
|
||||
/* add only part 1 */
|
||||
SMSMsgArray* out = smsproto_prepInbound( state, "33333", port, arr->u.msgsNet[0].data,
|
||||
SMSMsgArray* out = smsproto_prepInbound( state, xwe, "33333", port, arr->u.msgsNet[0].data,
|
||||
arr->u.msgsNet[0].len );
|
||||
XP_ASSERT( !out );
|
||||
smsproto_freeMsgArray( state, arr );
|
||||
|
||||
/* Try the no-buffer messages */
|
||||
XP_LOGF( "%s(): trying DEATH", __func__ );
|
||||
arr = smsproto_prepOutbound( state, DEATH, gameID, NULL, 0, "33333",
|
||||
arr = smsproto_prepOutbound( state, xwe, DEATH, gameID, NULL, 0, "33333",
|
||||
port, XP_TRUE, &waitSecs );
|
||||
XP_ASSERT( arr->format == FORMAT_NET );
|
||||
out = smsproto_prepInbound( state, "33333", port,
|
||||
out = smsproto_prepInbound( state, xwe, "33333", port,
|
||||
arr->u.msgsNet[0].data,
|
||||
arr->u.msgsNet[0].len );
|
||||
XP_ASSERT( out->format == FORMAT_LOC );
|
||||
|
@ -1038,10 +1041,10 @@ smsproto_runTests( MPFORMAL XW_DUtilCtxt* dutil )
|
|||
XP_LOGF( "%s(): DEATH checked out", __func__ );
|
||||
|
||||
/* Test port mismatch */
|
||||
arr = smsproto_prepOutbound( state, DEATH, gameID, NULL, 0, "33333",
|
||||
arr = smsproto_prepOutbound( state, xwe, DEATH, gameID, NULL, 0, "33333",
|
||||
port, XP_TRUE, &waitSecs );
|
||||
XP_ASSERT( arr->format == FORMAT_NET );
|
||||
out = smsproto_prepInbound( state, "33333", port + 1,
|
||||
out = smsproto_prepInbound( state, xwe, "33333", port + 1,
|
||||
arr->u.msgsNet[0].data,
|
||||
arr->u.msgsNet[0].len );
|
||||
XP_ASSERT( out == NULL );
|
||||
|
@ -1050,10 +1053,10 @@ smsproto_runTests( MPFORMAL XW_DUtilCtxt* dutil )
|
|||
|
||||
/* now a message that's unpacked across multiple sessions to test store/load */
|
||||
XP_LOGF( "%s(): testing store/restore", __func__ );
|
||||
arr = smsproto_prepOutbound( state, DATA, gameID, (XP_U8*)buf, 200, "33333",
|
||||
arr = smsproto_prepOutbound( state, xwe, DATA, gameID, (XP_U8*)buf, 200, "33333",
|
||||
port, XP_TRUE, &waitSecs );
|
||||
for ( int ii = 0; ii < arr->nMsgs; ++ii ) {
|
||||
SMSMsgArray* out = smsproto_prepInbound( state, "33333", port,
|
||||
SMSMsgArray* out = smsproto_prepInbound( state, xwe, "33333", port,
|
||||
arr->u.msgsNet[ii].data,
|
||||
arr->u.msgsNet[ii].len );
|
||||
if ( !!out ) {
|
||||
|
@ -1066,7 +1069,7 @@ smsproto_runTests( MPFORMAL XW_DUtilCtxt* dutil )
|
|||
break;
|
||||
}
|
||||
smsproto_free( state ); /* give it a chance to store state */
|
||||
state = smsproto_init( mpool, dutil );
|
||||
state = smsproto_init( mpool, xwe, dutil );
|
||||
}
|
||||
|
||||
/* Really bad to pass a different state than was created with, but now
|
||||
|
|
|
@ -78,7 +78,7 @@ typedef struct _SMSMsgArray {
|
|||
} u;
|
||||
} SMSMsgArray;
|
||||
|
||||
struct SMSProto* smsproto_init( MPFORMAL XW_DUtilCtxt* dutil );
|
||||
struct SMSProto* smsproto_init( MPFORMAL XWEnv xwe, XW_DUtilCtxt* dutil );
|
||||
void smsproto_free( SMSProto* state );
|
||||
|
||||
|
||||
|
@ -90,20 +90,20 @@ void smsproto_free( SMSProto* state );
|
|||
* freeMsgArray() or there will be leakage.
|
||||
*/
|
||||
|
||||
SMSMsgArray* smsproto_prepOutbound( SMSProto* state, SMS_CMD cmd,
|
||||
SMSMsgArray* smsproto_prepOutbound( SMSProto* state, XWEnv xwe, SMS_CMD cmd,
|
||||
XP_U32 gameID, const void* buf, XP_U16 buflen,
|
||||
const XP_UCHAR* toPhone, int port,
|
||||
XP_Bool forceOld, XP_U16* waitSecs );
|
||||
|
||||
/* When a message is received, pass it in for reassambly. Non-null return
|
||||
means one or more messages is ready for consumption. */
|
||||
SMSMsgArray* smsproto_prepInbound( SMSProto* state, const XP_UCHAR* fromPhone,
|
||||
SMSMsgArray* smsproto_prepInbound( SMSProto* state, XWEnv xwe, const XP_UCHAR* fromPhone,
|
||||
XP_U16 wantPort, const XP_U8* data, XP_U16 len );
|
||||
|
||||
void smsproto_freeMsgArray( SMSProto* state, SMSMsgArray* arr );
|
||||
|
||||
# ifdef DEBUG
|
||||
void smsproto_runTests( MPFORMAL XW_DUtilCtxt* dutil );
|
||||
void smsproto_runTests( MPFORMAL XWEnv xwe, XW_DUtilCtxt* dutil );
|
||||
# else
|
||||
# define smsproto_runTests( p1, p2 )
|
||||
# endif
|
||||
|
|
|
@ -432,7 +432,7 @@ handleActionInTray( BoardCtxt* board, XWEnv xwe, XP_S16 index, XP_Bool onDivider
|
|||
result = handleTrayDuringTrade( board, index );
|
||||
}
|
||||
} else if ( index >= 0 ) {
|
||||
result = moveTileToArrowLoc( board, (XP_U8)index );
|
||||
result = moveTileToArrowLoc( board, xwe, (XP_U8)index );
|
||||
#ifndef DISABLE_TILE_SEL
|
||||
if ( !result ) {
|
||||
TileBit newBits = 1 << index;
|
||||
|
@ -468,7 +468,7 @@ handleActionInTray( BoardCtxt* board, XWEnv xwe, XP_S16 index, XP_Bool onDivider
|
|||
#elif defined XWFEATURE_TRAYUNDO_ONE
|
||||
} else if ( index < 0 ) { /* other empty area */
|
||||
/* it better be true */
|
||||
(void)board_replaceNTiles( board, 1 );
|
||||
(void)board_replaceNTiles( board, xwe, 1 );
|
||||
result = XP_TRUE;
|
||||
#endif
|
||||
}
|
||||
|
@ -561,12 +561,12 @@ invalTrayTilesBetween( BoardCtxt* board, XP_U16 tileIndex1,
|
|||
} /* invalTrayTilesBetween */
|
||||
|
||||
XP_Bool
|
||||
board_juggleTray( BoardCtxt* board )
|
||||
board_juggleTray( BoardCtxt* board, XWEnv xwe )
|
||||
{
|
||||
XP_Bool result = XP_FALSE;
|
||||
const XP_S16 turn = board->selPlayer;
|
||||
|
||||
if ( checkRevealTray( board ) ) {
|
||||
if ( checkRevealTray( board, xwe ) ) {
|
||||
XP_S16 nTiles;
|
||||
XP_U16 dividerLoc = getDividerLoc( board );
|
||||
ModelCtxt* model = board->model;
|
||||
|
|
|
@ -86,113 +86,113 @@ typedef XP_Bool (*XWTimerProc)( void* closure, XWEnv xwe, XWTimerReason why );
|
|||
typedef struct UtilVtable {
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
XWStreamCtxt* (*m_util_makeStreamFromAddr )(XW_UtilCtxt* uc,
|
||||
XWStreamCtxt* (*m_util_makeStreamFromAddr )(XW_UtilCtxt* uc, XWEnv xwe,
|
||||
XP_PlayerAddr channelNo );
|
||||
#endif
|
||||
|
||||
XWBonusType (*m_util_getSquareBonus)( XW_UtilCtxt* uc, XP_U16 boardSize,
|
||||
XWBonusType (*m_util_getSquareBonus)( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 boardSize,
|
||||
XP_U16 col, XP_U16 row );
|
||||
void (*m_util_userError)( XW_UtilCtxt* uc, UtilErrID id );
|
||||
void (*m_util_userError)( XW_UtilCtxt* uc, XWEnv xwe, UtilErrID id );
|
||||
|
||||
void (*m_util_notifyMove)( XW_UtilCtxt* uc, XWStreamCtxt* stream );
|
||||
void (*m_util_notifyTrade)( XW_UtilCtxt* uc, const XP_UCHAR** tiles,
|
||||
void (*m_util_notifyMove)( XW_UtilCtxt* uc, XWEnv xwe, XWStreamCtxt* stream );
|
||||
void (*m_util_notifyTrade)( XW_UtilCtxt* uc, XWEnv xwe, const XP_UCHAR** tiles,
|
||||
XP_U16 nTiles );
|
||||
void (*m_util_notifyPickTileBlank)( XW_UtilCtxt* uc, XP_U16 playerNum,
|
||||
void (*m_util_notifyPickTileBlank)( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 playerNum,
|
||||
XP_U16 col, XP_U16 row,
|
||||
const XP_UCHAR** tileFaces,
|
||||
XP_U16 nTiles );
|
||||
void (*m_util_informNeedPickTiles)( XW_UtilCtxt* uc, XP_Bool isInitial,
|
||||
void (*m_util_informNeedPickTiles)( XW_UtilCtxt* uc, XWEnv xwe, XP_Bool isInitial,
|
||||
XP_U16 player, XP_U16 nToPick,
|
||||
XP_U16 nFaces, const XP_UCHAR** faces,
|
||||
const XP_U16* counts );
|
||||
|
||||
void (*m_util_informNeedPassword)( XW_UtilCtxt* uc, XP_U16 playerNum,
|
||||
void (*m_util_informNeedPassword)( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 playerNum,
|
||||
const XP_UCHAR* name );
|
||||
|
||||
void (*m_util_trayHiddenChange)(XW_UtilCtxt* uc,
|
||||
void (*m_util_trayHiddenChange)(XW_UtilCtxt* uc, XWEnv xwe,
|
||||
XW_TrayVisState newState,
|
||||
XP_U16 nVisibleRows );
|
||||
void (*m_util_yOffsetChange)(XW_UtilCtxt* uc, XP_U16 maxOffset,
|
||||
void (*m_util_yOffsetChange)(XW_UtilCtxt* uc, XWEnv xwe, XP_U16 maxOffset,
|
||||
XP_U16 oldOffset, XP_U16 newOffset );
|
||||
#ifdef XWFEATURE_TURNCHANGENOTIFY
|
||||
void (*m_util_turnChanged)(XW_UtilCtxt* uc, XP_S16 newTurn);
|
||||
void (*m_util_turnChanged)(XW_UtilCtxt* uc, XWEnv xwe, XP_S16 newTurn);
|
||||
#endif
|
||||
void (*m_util_notifyDupStatus)( XW_UtilCtxt* uc, XP_Bool amHost,
|
||||
void (*m_util_notifyDupStatus)( XW_UtilCtxt* uc, XWEnv xwe, XP_Bool amHost,
|
||||
const XP_UCHAR* msg );
|
||||
void (*m_util_informMove)( XW_UtilCtxt* uc, XP_S16 turn,
|
||||
void (*m_util_informMove)( XW_UtilCtxt* uc, XWEnv xwe, XP_S16 turn,
|
||||
XWStreamCtxt* expl, XWStreamCtxt* words );
|
||||
void (*m_util_informUndo)( XW_UtilCtxt* uc );
|
||||
void (*m_util_informNetDict)( XW_UtilCtxt* uc, XP_LangCode lang,
|
||||
void (*m_util_informUndo)( XW_UtilCtxt* uc, XWEnv xwe );
|
||||
void (*m_util_informNetDict)( XW_UtilCtxt* uc, XWEnv xwe, XP_LangCode lang,
|
||||
const XP_UCHAR* oldName,
|
||||
const XP_UCHAR* newName,
|
||||
const XP_UCHAR* newSum,
|
||||
XWPhoniesChoice phoniesAction );
|
||||
|
||||
void (*m_util_notifyGameOver)( XW_UtilCtxt* uc, XP_S16 quitter );
|
||||
void (*m_util_notifyGameOver)( XW_UtilCtxt* uc, XWEnv xwe, XP_S16 quitter );
|
||||
#ifdef XWFEATURE_HILITECELL
|
||||
XP_Bool (*m_util_hiliteCell)( XW_UtilCtxt* uc, XP_U16 col, XP_U16 row );
|
||||
XP_Bool (*m_util_hiliteCell)( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 col, XP_U16 row );
|
||||
#endif
|
||||
|
||||
XP_Bool (*m_util_engineProgressCallback)( XW_UtilCtxt* uc );
|
||||
XP_Bool (*m_util_engineProgressCallback)( XW_UtilCtxt* uc, XWEnv xwe );
|
||||
|
||||
void (*m_util_setTimer)( XW_UtilCtxt* uc, XWTimerReason why, XP_U16 when,
|
||||
void (*m_util_setTimer)( XW_UtilCtxt* uc, XWEnv xwe, XWTimerReason why, XP_U16 when,
|
||||
XWTimerProc proc, void* closure );
|
||||
void (*m_util_clearTimer)( XW_UtilCtxt* uc, XWTimerReason why );
|
||||
void (*m_util_clearTimer)( XW_UtilCtxt* uc, XWEnv xwe, XWTimerReason why );
|
||||
|
||||
void (*m_util_requestTime)( XW_UtilCtxt* uc );
|
||||
void (*m_util_requestTime)( XW_UtilCtxt* uc, XWEnv xwe );
|
||||
|
||||
XP_Bool (*m_util_altKeyDown)( XW_UtilCtxt* uc );
|
||||
XP_Bool (*m_util_altKeyDown)( XW_UtilCtxt* uc, XWEnv xwe );
|
||||
DictionaryCtxt* (*m_util_makeEmptyDict)( XW_UtilCtxt* uc, XWEnv xwe );
|
||||
|
||||
void (*m_util_notifyIllegalWords)( XW_UtilCtxt* uc, BadWordInfo* bwi,
|
||||
void (*m_util_notifyIllegalWords)( XW_UtilCtxt* uc, XWEnv xwe, BadWordInfo* bwi,
|
||||
XP_U16 turn, XP_Bool turnLost );
|
||||
|
||||
void (*m_util_remSelected)(XW_UtilCtxt* uc);
|
||||
void (*m_util_remSelected)(XW_UtilCtxt* uc, XWEnv xwe);
|
||||
|
||||
void (*m_util_timerSelected)(XW_UtilCtxt* uc, XP_Bool inDuplicateMode,
|
||||
void (*m_util_timerSelected)(XW_UtilCtxt* uc, XWEnv xwe, XP_Bool inDuplicateMode,
|
||||
XP_Bool canPause);
|
||||
|
||||
void (*m_util_formatPauseHistory)( XW_UtilCtxt* uc, XWStreamCtxt* stream,
|
||||
void (*m_util_formatPauseHistory)( XW_UtilCtxt* uc, XWEnv xwe, XWStreamCtxt* stream,
|
||||
DupPauseType typ, XP_S16 turn,
|
||||
XP_U32 secsPrev, XP_U32 secsCur,
|
||||
const XP_UCHAR* msg );
|
||||
|
||||
#ifndef XWFEATURE_MINIWIN
|
||||
void (*m_util_bonusSquareHeld)( XW_UtilCtxt* uc, XWBonusType bonus );
|
||||
void (*m_util_playerScoreHeld)( XW_UtilCtxt* uc, XP_U16 player );
|
||||
void (*m_util_bonusSquareHeld)( XW_UtilCtxt* uc, XWEnv xwe, XWBonusType bonus );
|
||||
void (*m_util_playerScoreHeld)( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 player );
|
||||
#endif
|
||||
#ifdef XWFEATURE_BOARDWORDS
|
||||
void (*m_util_cellSquareHeld)( XW_UtilCtxt* uc, XWStreamCtxt* words );
|
||||
void (*m_util_cellSquareHeld)( XW_UtilCtxt* uc, XWEnv xwe, XWStreamCtxt* words );
|
||||
#endif
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
void (*m_util_informMissing)(XW_UtilCtxt* uc, XP_Bool isServer,
|
||||
void (*m_util_informMissing)(XW_UtilCtxt* uc, XWEnv xwe, XP_Bool isServer,
|
||||
const CommsAddrRec* addr, XP_U16 nDevs,
|
||||
XP_U16 nMissing );
|
||||
void (*m_util_addrChange)( XW_UtilCtxt* uc, const CommsAddrRec* oldAddr,
|
||||
void (*m_util_addrChange)( XW_UtilCtxt* uc, XWEnv xwe, const CommsAddrRec* oldAddr,
|
||||
const CommsAddrRec* newAddr );
|
||||
void (*m_util_setIsServer)(XW_UtilCtxt* uc, XP_Bool isServer );
|
||||
void (*m_util_setIsServer)(XW_UtilCtxt* uc, XWEnv xwe, XP_Bool isServer );
|
||||
#endif
|
||||
|
||||
void (*m_util_informWordsBlocked)( XW_UtilCtxt* uc, XP_U16 nBadWords,
|
||||
void (*m_util_informWordsBlocked)( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 nBadWords,
|
||||
XWStreamCtxt* words, const XP_UCHAR* dictName );
|
||||
|
||||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
XP_Bool (*m_util_getTraySearchLimits)(XW_UtilCtxt* uc,
|
||||
XP_Bool (*m_util_getTraySearchLimits)(XW_UtilCtxt* uc, XWEnv xwe,
|
||||
XP_U16* min, XP_U16* max );
|
||||
#endif
|
||||
|
||||
#ifdef XWFEATURE_CHAT
|
||||
void (*m_util_showChat)( XW_UtilCtxt* uc, const XP_UCHAR* const msg,
|
||||
void (*m_util_showChat)( XW_UtilCtxt* uc, XWEnv xwe, const XP_UCHAR* const msg,
|
||||
XP_S16 from, XP_U32 timestamp );
|
||||
#endif
|
||||
|
||||
#ifdef SHOW_PROGRESS
|
||||
void (*m_util_engineStarting)( XW_UtilCtxt* uc, XP_U16 nBlanks );
|
||||
void (*m_util_engineStopping)( XW_UtilCtxt* uc );
|
||||
void (*m_util_engineStarting)( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 nBlanks );
|
||||
void (*m_util_engineStopping)( XW_UtilCtxt* uc, XWEnv xwe );
|
||||
#endif
|
||||
|
||||
XW_DUtilCtxt* (*m_util_getDevUtilCtxt)( XW_UtilCtxt* uc );
|
||||
XW_DUtilCtxt* (*m_util_getDevUtilCtxt)( XW_UtilCtxt* uc, XWEnv xwe );
|
||||
|
||||
} UtilVtable;
|
||||
|
||||
|
@ -206,135 +206,135 @@ struct XW_UtilCtxt {
|
|||
MPSLOT
|
||||
};
|
||||
|
||||
#define util_makeStreamFromAddr(uc,a) \
|
||||
(uc)->vtable->m_util_makeStreamFromAddr((uc),(a))
|
||||
#define util_makeStreamFromAddr(uc,e,a) \
|
||||
(uc)->vtable->m_util_makeStreamFromAddr((uc), (e),(a))
|
||||
|
||||
#define util_getSquareBonus(uc,b,c,r) \
|
||||
(uc)->vtable->m_util_getSquareBonus((uc),(b),(c),(r))
|
||||
#define util_getSquareBonus(uc,e,b,c,r) \
|
||||
(uc)->vtable->m_util_getSquareBonus((uc), (e),(b),(c),(r))
|
||||
|
||||
#define util_userError(uc,err) \
|
||||
(uc)->vtable->m_util_userError((uc),(err))
|
||||
#define util_userError(uc,e,err) \
|
||||
(uc)->vtable->m_util_userError((uc),(e),(err))
|
||||
|
||||
#define util_notifyMove(uc, str) \
|
||||
(uc)->vtable->m_util_notifyMove((uc), (str))
|
||||
#define util_notifyMove(uc,e, str) \
|
||||
(uc)->vtable->m_util_notifyMove((uc), (e), (str))
|
||||
|
||||
#define util_notifyTrade(uc, tx, nt) \
|
||||
(uc)->vtable->m_util_notifyTrade((uc), (tx), (nt))
|
||||
#define util_notifyTrade(uc,e, tx, nt) \
|
||||
(uc)->vtable->m_util_notifyTrade((uc), (e), (tx), (nt))
|
||||
|
||||
#define util_notifyPickTileBlank( uc, c, r, n, tx, nt ) \
|
||||
(uc)->vtable->m_util_notifyPickTileBlank( (uc), (c), (r), (n), (tx), (nt) )
|
||||
#define util_notifyPickTileBlank( uc,e, c, r, n, tx, nt ) \
|
||||
(uc)->vtable->m_util_notifyPickTileBlank( (uc), (e), (c), (r), (n), (tx), (nt) )
|
||||
|
||||
#define util_informNeedPickTiles( uc, ii, pl, np, nt, fc, cn ) \
|
||||
(uc)->vtable->m_util_informNeedPickTiles( (uc), (ii), (pl), (np), (nt), (fc), (cn) )
|
||||
#define util_informNeedPickTiles( uc,e, ii, pl, np, nt, fc, cn ) \
|
||||
(uc)->vtable->m_util_informNeedPickTiles( (uc), (e), (ii), (pl), (np), (nt), (fc), (cn) )
|
||||
|
||||
#define util_informNeedPassword( uc, pn, n ) \
|
||||
(uc)->vtable->m_util_informNeedPassword( (uc), (pn), (n) )
|
||||
#define util_informNeedPassword( uc,e, pn, n ) \
|
||||
(uc)->vtable->m_util_informNeedPassword( (uc), (e), (pn), (n) )
|
||||
|
||||
#define util_trayHiddenChange( uc, b, n ) \
|
||||
(uc)->vtable->m_util_trayHiddenChange((uc), (b), (n))
|
||||
#define util_trayHiddenChange( uc,e, b, n ) \
|
||||
(uc)->vtable->m_util_trayHiddenChange((uc), (e), (b), (n))
|
||||
|
||||
#define util_yOffsetChange( uc, m, o, n ) \
|
||||
(uc)->vtable->m_util_yOffsetChange((uc), (m), (o), (n) )
|
||||
#define util_yOffsetChange( uc,e, m, o, n ) \
|
||||
(uc)->vtable->m_util_yOffsetChange((uc), (e), (m), (o), (n) )
|
||||
|
||||
#ifdef XWFEATURE_TURNCHANGENOTIFY
|
||||
# define util_turnChanged( uc, t ) \
|
||||
(uc)->vtable->m_util_turnChanged( (uc), (t) )
|
||||
# define util_turnChanged( uc,e, t ) \
|
||||
(uc)->vtable->m_util_turnChanged( (uc), (e), (t) )
|
||||
#else
|
||||
# define util_turnChanged( uc, t )
|
||||
# define util_turnChanged( uc,e, t )
|
||||
#endif
|
||||
|
||||
#define util_notifyDupStatus(uc, h, m) \
|
||||
(uc)->vtable->m_util_notifyDupStatus( (uc), (h), (m) )
|
||||
#define util_informMove(uc,t,e,w) \
|
||||
(uc)->vtable->m_util_informMove( (uc), (t), (e), (w))
|
||||
#define util_informUndo(uc) \
|
||||
(uc)->vtable->m_util_informUndo( (uc))
|
||||
#define util_informNetDict(uc, cd, on, nn, ns, pa ) \
|
||||
(uc)->vtable->m_util_informNetDict( (uc), (cd), (on), (nn), (ns), \
|
||||
#define util_notifyDupStatus(uc,e, h, m) \
|
||||
(uc)->vtable->m_util_notifyDupStatus( (uc), (e), (h), (m) )
|
||||
#define util_informMove(uc,e,t,ex,w) \
|
||||
(uc)->vtable->m_util_informMove( (uc), (e), (t), (ex), (w))
|
||||
#define util_informUndo(uc,e) \
|
||||
(uc)->vtable->m_util_informUndo( (uc), (e))
|
||||
#define util_informNetDict(uc,e, cd, on, nn, ns, pa ) \
|
||||
(uc)->vtable->m_util_informNetDict( (uc), (e), (cd), (on), (nn), (ns), \
|
||||
(pa) )
|
||||
#define util_notifyGameOver( uc, q ) \
|
||||
(uc)->vtable->m_util_notifyGameOver((uc), (q))
|
||||
#define util_notifyGameOver( uc,e, q ) \
|
||||
(uc)->vtable->m_util_notifyGameOver((uc), (e), (q))
|
||||
|
||||
#ifdef XWFEATURE_HILITECELL
|
||||
# define util_hiliteCell( uc, c, r ) \
|
||||
(uc)->vtable->m_util_hiliteCell((uc), (c), (r))
|
||||
# define util_hiliteCell( uc,e, c, r ) \
|
||||
(uc)->vtable->m_util_hiliteCell((uc), (e), (c), (r))
|
||||
#endif
|
||||
|
||||
#define util_engineProgressCallback( uc ) \
|
||||
(uc)->vtable->m_util_engineProgressCallback((uc))
|
||||
#define util_engineProgressCallback( uc,e ) \
|
||||
(uc)->vtable->m_util_engineProgressCallback((uc), (e))
|
||||
|
||||
#define util_setTimer( uc, why, when, proc, clos ) \
|
||||
(uc)->vtable->m_util_setTimer((uc),(why),(when),(proc),(clos))
|
||||
#define util_clearTimer( uc, why ) \
|
||||
(uc)->vtable->m_util_clearTimer((uc),(why))
|
||||
#define util_setTimer( uc,e, why, when, proc, clos ) \
|
||||
(uc)->vtable->m_util_setTimer((uc), (e),(why),(when),(proc),(clos))
|
||||
#define util_clearTimer( uc,e, why ) \
|
||||
(uc)->vtable->m_util_clearTimer((uc), (e),(why))
|
||||
|
||||
#define util_requestTime( uc ) \
|
||||
(uc)->vtable->m_util_requestTime((uc))
|
||||
#define util_requestTime( uc,e ) \
|
||||
(uc)->vtable->m_util_requestTime((uc), (e))
|
||||
|
||||
#define util_altKeyDown( uc ) \
|
||||
(uc)->vtable->m_util_altKeyDown((uc))
|
||||
#define util_altKeyDown( uc,e ) \
|
||||
(uc)->vtable->m_util_altKeyDown((uc),(e))
|
||||
|
||||
#define util_makeEmptyDict( uc, xwe ) \
|
||||
(uc)->vtable->m_util_makeEmptyDict((uc), (xwe))
|
||||
#define util_makeEmptyDict( uc, e ) \
|
||||
(uc)->vtable->m_util_makeEmptyDict((uc), (e))
|
||||
|
||||
#define util_notifyIllegalWords( uc, w, p, b ) \
|
||||
(uc)->vtable->m_util_notifyIllegalWords((uc),(w),(p),(b))
|
||||
#define util_notifyIllegalWords( uc,e, w, p, b ) \
|
||||
(uc)->vtable->m_util_notifyIllegalWords((uc), (e),(w),(p),(b))
|
||||
|
||||
#define util_remSelected( uc ) \
|
||||
(uc)->vtable->m_util_remSelected((uc))
|
||||
#define util_remSelected( uc,e ) \
|
||||
(uc)->vtable->m_util_remSelected((uc), (e))
|
||||
|
||||
#define util_timerSelected( uc, dm, cp ) \
|
||||
(uc)->vtable->m_util_timerSelected((uc), (dm), (cp))
|
||||
#define util_timerSelected( uc,e, dm, cp ) \
|
||||
(uc)->vtable->m_util_timerSelected((uc), (e), (dm), (cp))
|
||||
|
||||
#define util_formatPauseHistory( uc, s, typ, turn, secsPrev, secsCur, msg ) \
|
||||
(uc)->vtable->m_util_formatPauseHistory( (uc), (s), (typ), (turn), \
|
||||
#define util_formatPauseHistory( uc,e, s, typ, turn, secsPrev, secsCur, msg ) \
|
||||
(uc)->vtable->m_util_formatPauseHistory( (uc), (e), (s), (typ), (turn), \
|
||||
(secsPrev), (secsCur), (msg) )
|
||||
|
||||
#ifndef XWFEATURE_MINIWIN
|
||||
# define util_bonusSquareHeld( uc, b ) \
|
||||
(uc)->vtable->m_util_bonusSquareHeld( (uc), (b) )
|
||||
# define util_playerScoreHeld( uc, player ) \
|
||||
(uc)->vtable->m_util_playerScoreHeld( (uc), (player) )
|
||||
# define util_bonusSquareHeld( uc,e, b ) \
|
||||
(uc)->vtable->m_util_bonusSquareHeld( (uc), (e), (b) )
|
||||
# define util_playerScoreHeld( uc,e, player ) \
|
||||
(uc)->vtable->m_util_playerScoreHeld( (uc), (e), (player) )
|
||||
#endif
|
||||
#ifdef XWFEATURE_BOARDWORDS
|
||||
#define util_cellSquareHeld(uc, s) \
|
||||
(uc)->vtable->m_util_cellSquareHeld( (uc), (s) )
|
||||
#define util_cellSquareHeld(uc,e, s) \
|
||||
(uc)->vtable->m_util_cellSquareHeld( (uc), (e), (s) )
|
||||
#endif
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
# define util_informMissing( uc, is, ct, nd, nm ) \
|
||||
(uc)->vtable->m_util_informMissing((uc), (is), (ct), (nd), (nm) )
|
||||
# define util_addrChange( uc, addro, addrn ) \
|
||||
(uc)->vtable->m_util_addrChange((uc), (addro), (addrn))
|
||||
# define util_setIsServer( uc, is ) \
|
||||
(uc)->vtable->m_util_setIsServer((uc), (is))
|
||||
# define util_informMissing( uc,e, is, ct, nd, nm ) \
|
||||
(uc)->vtable->m_util_informMissing((uc), (e), (is), (ct), (nd), (nm) )
|
||||
# define util_addrChange( uc,e, addro, addrn ) \
|
||||
(uc)->vtable->m_util_addrChange((uc), (e), (addro), (addrn))
|
||||
# define util_setIsServer( uc,e, is ) \
|
||||
(uc)->vtable->m_util_setIsServer((uc), (e), (is))
|
||||
# else
|
||||
# define util_addrChange( uc, addro, addrn )
|
||||
# define util_addrChange( uc,e, addro, addrn )
|
||||
#endif
|
||||
|
||||
#define util_informWordsBlocked(uc, c, w, d) \
|
||||
(uc)->vtable->m_util_informWordsBlocked( (uc), (c), (w), (d) )
|
||||
#define util_informWordsBlocked(uc,e, c, w, d) \
|
||||
(uc)->vtable->m_util_informWordsBlocked( (uc), (e), (c), (w), (d) )
|
||||
|
||||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
#define util_getTraySearchLimits(uc,min,max) \
|
||||
(uc)->vtable->m_util_getTraySearchLimits((uc), (min), (max))
|
||||
#define util_getTraySearchLimits(uc,e,min,max) \
|
||||
(uc)->vtable->m_util_getTraySearchLimits((uc), (e), (min), (max))
|
||||
#endif
|
||||
|
||||
#ifdef XWFEATURE_CHAT
|
||||
# define util_showChat( uc, m, f, ts ) (uc)->vtable->m_util_showChat((uc),(m),(f), (ts))
|
||||
# define util_showChat( uc,e, m, f, ts ) (uc)->vtable->m_util_showChat((uc), (e),(m),(f), (ts))
|
||||
#endif
|
||||
|
||||
# ifdef SHOW_PROGRESS
|
||||
# define util_engineStarting( uc, nb ) \
|
||||
(uc)->vtable->m_util_engineStarting((uc),(nb))
|
||||
# define util_engineStopping( uc ) \
|
||||
(uc)->vtable->m_util_engineStopping((uc))
|
||||
# define util_engineStarting( uc,e, nb ) \
|
||||
(uc)->vtable->m_util_engineStarting((uc), (e),(nb))
|
||||
# define util_engineStopping( uc,e ) \
|
||||
(uc)->vtable->m_util_engineStopping((uc), (e))
|
||||
# else
|
||||
# define util_engineStarting( uc, nb )
|
||||
# define util_engineStopping( uc )
|
||||
# define util_engineStarting( uc,e, nb )
|
||||
# define util_engineStopping( uc,e )
|
||||
# endif
|
||||
|
||||
# define util_getDevUtilCtxt(uc) \
|
||||
(uc)->vtable->m_util_getDevUtilCtxt( (uc) )
|
||||
# define util_getDevUtilCtxt(uc,e) \
|
||||
(uc)->vtable->m_util_getDevUtilCtxt( (uc), (e) )
|
||||
|
||||
#endif
|
||||
|
|
|
@ -558,13 +558,13 @@ setupBoard( CursesBoardGlobals* bGlobals )
|
|||
XP_U16 fontWidth, fontHt;
|
||||
getFromDict( cGlobals, &fontWidth, &fontHt );
|
||||
BoardDims dims;
|
||||
board_figureLayout( board, cGlobals->gi,
|
||||
board_figureLayout( board, NULL_XWE, cGlobals->gi,
|
||||
0, 0, width, height, 100,
|
||||
150, 200, /* percents */
|
||||
width*75/100,
|
||||
fontWidth, fontHt,
|
||||
XP_FALSE, &dims );
|
||||
board_applyLayout( board, &dims );
|
||||
board_applyLayout( board, NULL_XWE, &dims );
|
||||
XP_LOGF( "%s(): calling board_draw()", __func__ );
|
||||
board_invalAll( board );
|
||||
board_draw( board, NULL_XWE );
|
||||
|
@ -710,7 +710,7 @@ cursesUserError( CursesBoardGlobals* bGlobals, const char* format, ... )
|
|||
} /* cursesUserError */
|
||||
|
||||
static void
|
||||
curses_util_notifyPickTileBlank( XW_UtilCtxt* uc, XP_U16 playerNum,
|
||||
curses_util_notifyPickTileBlank( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XP_U16 playerNum,
|
||||
XP_U16 XP_UNUSED(col), XP_U16 XP_UNUSED(row),
|
||||
const XP_UCHAR** texts, XP_U16 nTiles )
|
||||
{
|
||||
|
@ -728,6 +728,7 @@ curses_util_notifyPickTileBlank( XW_UtilCtxt* uc, XP_U16 playerNum,
|
|||
|
||||
static void
|
||||
curses_util_informNeedPickTiles( XW_UtilCtxt* XP_UNUSED(uc),
|
||||
XWEnv XP_UNUSED(xwe),
|
||||
XP_Bool XP_UNUSED(isInitial),
|
||||
XP_U16 XP_UNUSED(player),
|
||||
XP_U16 XP_UNUSED(nToPick),
|
||||
|
@ -750,7 +751,7 @@ curses_util_informNeedPickTiles( XW_UtilCtxt* XP_UNUSED(uc),
|
|||
}
|
||||
|
||||
static void
|
||||
curses_util_userError( XW_UtilCtxt* uc, UtilErrID id )
|
||||
curses_util_userError( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), UtilErrID id )
|
||||
{
|
||||
CursesBoardGlobals* globals = (CursesBoardGlobals*)uc->closure;
|
||||
XP_Bool silent;
|
||||
|
@ -784,6 +785,7 @@ ask_move( gpointer data )
|
|||
|
||||
static void
|
||||
curses_util_informNeedPassword( XW_UtilCtxt* XP_UNUSED(uc),
|
||||
XWEnv XP_UNUSED(xwe),
|
||||
XP_U16 XP_UNUSED_DBG(playerNum),
|
||||
const XP_UCHAR* XP_UNUSED_DBG(name) )
|
||||
{
|
||||
|
@ -792,7 +794,8 @@ curses_util_informNeedPassword( XW_UtilCtxt* XP_UNUSED(uc),
|
|||
} /* curses_util_askPassword */
|
||||
|
||||
static void
|
||||
curses_util_yOffsetChange( XW_UtilCtxt* uc, XP_U16 XP_UNUSED(maxOffset),
|
||||
curses_util_yOffsetChange( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XP_U16 XP_UNUSED(maxOffset),
|
||||
XP_U16 oldOffset, XP_U16 newOffset )
|
||||
{
|
||||
if ( 0 != newOffset ) {
|
||||
|
@ -806,7 +809,8 @@ curses_util_yOffsetChange( XW_UtilCtxt* uc, XP_U16 XP_UNUSED(maxOffset),
|
|||
|
||||
#ifdef XWFEATURE_TURNCHANGENOTIFY
|
||||
static void
|
||||
curses_util_turnChanged( XW_UtilCtxt* uc, XP_S16 XP_UNUSED_DBG(newTurn) )
|
||||
curses_util_turnChanged( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XP_S16 XP_UNUSED_DBG(newTurn) )
|
||||
{
|
||||
XP_LOGF( "%s(newTurn=%d)", __func__, newTurn );
|
||||
CursesBoardGlobals* bGlobals = (CursesBoardGlobals*)uc->closure;
|
||||
|
@ -815,7 +819,7 @@ curses_util_turnChanged( XW_UtilCtxt* uc, XP_S16 XP_UNUSED_DBG(newTurn) )
|
|||
#endif
|
||||
|
||||
static void
|
||||
curses_util_notifyIllegalWords( XW_UtilCtxt* uc, BadWordInfo* bwi,
|
||||
curses_util_notifyIllegalWords( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), BadWordInfo* bwi,
|
||||
XP_U16 player, XP_Bool turnLost )
|
||||
{
|
||||
gchar* strs = g_strjoinv( "\", \"", (gchar**)bwi->words );
|
||||
|
@ -834,7 +838,7 @@ curses_util_notifyIllegalWords( XW_UtilCtxt* uc, BadWordInfo* bwi,
|
|||
|
||||
/* this needs to change!!! */
|
||||
static void
|
||||
curses_util_notifyMove( XW_UtilCtxt* uc, XWStreamCtxt* stream )
|
||||
curses_util_notifyMove( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XWStreamCtxt* stream )
|
||||
{
|
||||
CursesBoardGlobals* globals = (CursesBoardGlobals*)uc->closure;
|
||||
CommonGlobals* cGlobals = &globals->cGlobals;
|
||||
|
@ -864,7 +868,8 @@ ask_trade( gpointer data )
|
|||
}
|
||||
|
||||
static void
|
||||
curses_util_notifyTrade( XW_UtilCtxt* uc, const XP_UCHAR** tiles, XP_U16 nTiles )
|
||||
curses_util_notifyTrade( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
const XP_UCHAR** tiles, XP_U16 nTiles )
|
||||
{
|
||||
CursesBoardGlobals* globals = (CursesBoardGlobals*)uc->closure;
|
||||
formatConfirmTrade( &globals->cGlobals, tiles, nTiles );
|
||||
|
@ -872,7 +877,7 @@ curses_util_notifyTrade( XW_UtilCtxt* uc, const XP_UCHAR** tiles, XP_U16 nTiles
|
|||
}
|
||||
|
||||
static void
|
||||
curses_util_trayHiddenChange( XW_UtilCtxt* XP_UNUSED(uc),
|
||||
curses_util_trayHiddenChange( XW_UtilCtxt* XP_UNUSED(uc), XWEnv XP_UNUSED(xwe),
|
||||
XW_TrayVisState XP_UNUSED(state),
|
||||
XP_U16 XP_UNUSED(nVisibleRows) )
|
||||
{
|
||||
|
@ -888,7 +893,7 @@ cursesShowFinalScores( CursesBoardGlobals* bGlobals )
|
|||
CommonGlobals* cGlobals = &bGlobals->cGlobals;
|
||||
stream = mem_stream_make_raw( MPPARM(cGlobals->util->mpool)
|
||||
cGlobals->params->vtMgr );
|
||||
server_writeFinalScores( cGlobals->game.server, stream );
|
||||
server_writeFinalScores( cGlobals->game.server, NULL_XWE, stream );
|
||||
|
||||
text = strFromStream( stream );
|
||||
|
||||
|
@ -899,8 +904,9 @@ cursesShowFinalScores( CursesBoardGlobals* bGlobals )
|
|||
} /* cursesShowFinalScores */
|
||||
|
||||
static void
|
||||
curses_util_informMove( XW_UtilCtxt* uc, XP_S16 XP_UNUSED(turn),
|
||||
XWStreamCtxt* expl, XWStreamCtxt* XP_UNUSED(words))
|
||||
curses_util_informMove( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XP_S16 XP_UNUSED(turn), XWStreamCtxt* expl,
|
||||
XWStreamCtxt* XP_UNUSED(words))
|
||||
{
|
||||
CursesBoardGlobals* bGlobals = (CursesBoardGlobals*)uc->closure;
|
||||
if ( !!bGlobals->boardWin ) {
|
||||
|
@ -911,7 +917,7 @@ curses_util_informMove( XW_UtilCtxt* uc, XP_S16 XP_UNUSED(turn),
|
|||
}
|
||||
|
||||
static void
|
||||
curses_util_notifyDupStatus( XW_UtilCtxt* uc,
|
||||
curses_util_notifyDupStatus( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XP_Bool XP_UNUSED(amHost),
|
||||
const XP_UCHAR* msg )
|
||||
{
|
||||
|
@ -922,7 +928,7 @@ curses_util_notifyDupStatus( XW_UtilCtxt* uc,
|
|||
}
|
||||
|
||||
static void
|
||||
curses_util_informUndo( XW_UtilCtxt* uc )
|
||||
curses_util_informUndo( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe) )
|
||||
{
|
||||
CursesBoardGlobals* bGlobals = (CursesBoardGlobals*)uc->closure;
|
||||
if ( !!bGlobals->boardWin ) {
|
||||
|
@ -931,7 +937,7 @@ curses_util_informUndo( XW_UtilCtxt* uc )
|
|||
}
|
||||
|
||||
static void
|
||||
curses_util_notifyGameOver( XW_UtilCtxt* uc, XP_S16 quitter )
|
||||
curses_util_notifyGameOver( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XP_S16 quitter )
|
||||
{
|
||||
CursesBoardGlobals* bGlobals = (CursesBoardGlobals*)uc->closure;
|
||||
CommonGlobals* cGlobals = &bGlobals->cGlobals;
|
||||
|
@ -957,7 +963,8 @@ curses_util_notifyGameOver( XW_UtilCtxt* uc, XP_S16 quitter )
|
|||
} /* curses_util_notifyGameOver */
|
||||
|
||||
static void
|
||||
curses_util_informNetDict( XW_UtilCtxt* uc, XP_LangCode XP_UNUSED(lang),
|
||||
curses_util_informNetDict( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XP_LangCode XP_UNUSED(lang),
|
||||
const XP_UCHAR* XP_UNUSED_DBG(oldName),
|
||||
const XP_UCHAR* XP_UNUSED_DBG(newName),
|
||||
const XP_UCHAR* XP_UNUSED_DBG(newSum),
|
||||
|
@ -970,7 +977,7 @@ curses_util_informNetDict( XW_UtilCtxt* uc, XP_LangCode XP_UNUSED(lang),
|
|||
|
||||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
static XP_Bool
|
||||
curses_util_getTraySearchLimits( XW_UtilCtxt* XP_UNUSED(uc),
|
||||
curses_util_getTraySearchLimits( XW_UtilCtxt* XP_UNUSED(uc),XWEnv XP_UNUSED(xwe),
|
||||
XP_U16* XP_UNUSED(min), XP_U16* XP_UNUSED(max) )
|
||||
{
|
||||
XP_ASSERT(0);
|
||||
|
@ -981,7 +988,7 @@ curses_util_getTraySearchLimits( XW_UtilCtxt* XP_UNUSED(uc),
|
|||
|
||||
#ifdef XWFEATURE_HILITECELL
|
||||
static XP_Bool
|
||||
curses_util_hiliteCell( XW_UtilCtxt* uc,
|
||||
curses_util_hiliteCell( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XP_U16 XP_UNUSED(col), XP_U16 XP_UNUSED(row) )
|
||||
{
|
||||
CursesBoardGlobals* globals = (CursesBoardGlobals*)uc->closure;
|
||||
|
@ -993,19 +1000,19 @@ curses_util_hiliteCell( XW_UtilCtxt* uc,
|
|||
#endif
|
||||
|
||||
static XP_Bool
|
||||
curses_util_engineProgressCallback( XW_UtilCtxt* XP_UNUSED(uc) )
|
||||
curses_util_engineProgressCallback( XW_UtilCtxt* XP_UNUSED(uc), XWEnv XP_UNUSED(xwe) )
|
||||
{
|
||||
return XP_TRUE;
|
||||
} /* curses_util_engineProgressCallback */
|
||||
|
||||
static XP_Bool
|
||||
curses_util_altKeyDown( XW_UtilCtxt* XP_UNUSED(uc) )
|
||||
curses_util_altKeyDown( XW_UtilCtxt* XP_UNUSED(uc), XWEnv XP_UNUSED(xwe) )
|
||||
{
|
||||
return XP_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
curses_util_remSelected( XW_UtilCtxt* uc )
|
||||
curses_util_remSelected( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe) )
|
||||
{
|
||||
CursesBoardGlobals* bGlobals = (CursesBoardGlobals*)uc->closure;
|
||||
CommonGlobals* cGlobals = (CommonGlobals*)uc->closure;
|
||||
|
@ -1014,7 +1021,7 @@ curses_util_remSelected( XW_UtilCtxt* uc )
|
|||
|
||||
stream = mem_stream_make_raw( MPPARM(cGlobals->util->mpool)
|
||||
cGlobals->params->vtMgr );
|
||||
board_formatRemainingTiles( cGlobals->game.board, stream );
|
||||
board_formatRemainingTiles( cGlobals->game.board, NULL_XWE, stream );
|
||||
|
||||
text = strFromStream( stream );
|
||||
|
||||
|
@ -1024,7 +1031,7 @@ curses_util_remSelected( XW_UtilCtxt* uc )
|
|||
}
|
||||
|
||||
static void
|
||||
curses_util_timerSelected( XW_UtilCtxt* XP_UNUSED(uc),
|
||||
curses_util_timerSelected( XW_UtilCtxt* XP_UNUSED(uc), XWEnv XP_UNUSED(xwe),
|
||||
XP_Bool XP_UNUSED_DBG(inDuplicateMode),
|
||||
XP_Bool XP_UNUSED_DBG(canPause) )
|
||||
{
|
||||
|
@ -1033,7 +1040,8 @@ curses_util_timerSelected( XW_UtilCtxt* XP_UNUSED(uc),
|
|||
}
|
||||
|
||||
static void
|
||||
curses_util_bonusSquareHeld( XW_UtilCtxt* uc, XWBonusType bonus )
|
||||
curses_util_bonusSquareHeld( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XWBonusType bonus )
|
||||
{
|
||||
LOG_FUNC();
|
||||
XP_USE( uc );
|
||||
|
@ -1041,7 +1049,7 @@ curses_util_bonusSquareHeld( XW_UtilCtxt* uc, XWBonusType bonus )
|
|||
}
|
||||
|
||||
static void
|
||||
curses_util_playerScoreHeld( XW_UtilCtxt* uc, XP_U16 player )
|
||||
curses_util_playerScoreHeld( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XP_U16 player )
|
||||
{
|
||||
CursesBoardGlobals* bGlobals = (CursesBoardGlobals*)uc->closure;
|
||||
LastMoveInfo lmi;
|
||||
|
@ -1055,7 +1063,8 @@ curses_util_playerScoreHeld( XW_UtilCtxt* uc, XP_U16 player )
|
|||
|
||||
#ifdef XWFEATURE_BOARDWORDS
|
||||
static void
|
||||
curses_util_cellSquareHeld( XW_UtilCtxt* uc, XWStreamCtxt* words )
|
||||
curses_util_cellSquareHeld( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XWStreamCtxt* words )
|
||||
{
|
||||
XP_USE( uc );
|
||||
catOnClose( words, NULL_XWE, NULL );
|
||||
|
@ -1064,7 +1073,7 @@ curses_util_cellSquareHeld( XW_UtilCtxt* uc, XWStreamCtxt* words )
|
|||
#endif
|
||||
|
||||
static void
|
||||
curses_util_informWordsBlocked( XW_UtilCtxt* XP_UNUSED(uc),
|
||||
curses_util_informWordsBlocked( XW_UtilCtxt* XP_UNUSED(uc), XWEnv XP_UNUSED(xwe),
|
||||
XP_U16 XP_UNUSED_DBG(nBadWords),
|
||||
XWStreamCtxt* XP_UNUSED(words),
|
||||
const XP_UCHAR* XP_UNUSED_DBG(dictName) )
|
||||
|
@ -1074,7 +1083,8 @@ curses_util_informWordsBlocked( XW_UtilCtxt* XP_UNUSED(uc),
|
|||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
static XWStreamCtxt*
|
||||
curses_util_makeStreamFromAddr(XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
|
||||
curses_util_makeStreamFromAddr(XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XP_PlayerAddr channelNo )
|
||||
{
|
||||
CursesBoardGlobals* globals = (CursesBoardGlobals*)uc->closure;
|
||||
LaunchParams* params = globals->cGlobals.params;
|
||||
|
@ -1088,7 +1098,7 @@ curses_util_makeStreamFromAddr(XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
|
|||
|
||||
#ifdef XWFEATURE_CHAT
|
||||
static void
|
||||
curses_util_showChat( XW_UtilCtxt* uc,
|
||||
curses_util_showChat( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
const XP_UCHAR* const XP_UNUSED_DBG(msg),
|
||||
XP_S16 XP_UNUSED_DBG(from), XP_U32 XP_UNUSED(timestamp) )
|
||||
{
|
||||
|
@ -1205,7 +1215,7 @@ static bool
|
|||
handleReplace( void* closure, int XP_UNUSED(key) )
|
||||
{
|
||||
CommonGlobals* cGlobals = &((CursesBoardGlobals*)closure)->cGlobals;
|
||||
if ( board_replaceTiles( cGlobals->game.board ) ) {
|
||||
if ( board_replaceTiles( cGlobals->game.board, NULL_XWE ) ) {
|
||||
board_draw( cGlobals->game.board, NULL_XWE );
|
||||
}
|
||||
return XP_TRUE;
|
||||
|
@ -1295,7 +1305,7 @@ static bool
|
|||
handleJuggle( void* closure, int XP_UNUSED(key) )
|
||||
{
|
||||
CommonGlobals* cGlobals = &((CursesBoardGlobals*)closure)->cGlobals;
|
||||
if ( board_juggleTray( cGlobals->game.board ) ) {
|
||||
if ( board_juggleTray( cGlobals->game.board, NULL_XWE ) ) {
|
||||
board_draw( cGlobals->game.board, NULL_XWE );
|
||||
}
|
||||
return XP_TRUE;
|
||||
|
@ -1309,8 +1319,8 @@ handleHide( void* closure, int XP_UNUSED(key) )
|
|||
board_getTrayVisState( cGlobals->game.board );
|
||||
|
||||
bool draw = curState == TRAY_REVEALED
|
||||
? board_hideTray( cGlobals->game.board )
|
||||
: board_showTray( cGlobals->game.board );
|
||||
? board_hideTray( cGlobals->game.board, NULL_XWE )
|
||||
: board_showTray( cGlobals->game.board, NULL_XWE );
|
||||
if ( draw ) {
|
||||
board_draw( cGlobals->game.board, NULL_XWE );
|
||||
}
|
||||
|
@ -1323,7 +1333,7 @@ static void
|
|||
checkAssignFocus( BoardCtxt* board )
|
||||
{
|
||||
if ( OBJ_NONE == board_getFocusOwner(board) ) {
|
||||
board_focusChanged( board, OBJ_BOARD, XP_TRUE );
|
||||
board_focusChanged( board, NULL_XWE, OBJ_BOARD, XP_TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1476,7 +1486,8 @@ handleShowVals( void* closure, int XP_UNUSED(key) )
|
|||
|
||||
XWStreamCtxt* stream = mem_stream_make_raw( MPPARM(cGlobals->util->mpool)
|
||||
cGlobals->params->vtMgr );
|
||||
server_formatDictCounts( bGlobals->cGlobals.game.server, stream, 5, XP_FALSE );
|
||||
server_formatDictCounts( bGlobals->cGlobals.game.server, NULL_XWE,
|
||||
stream, 5, XP_FALSE );
|
||||
const XP_U8* data = stream_getPtr( stream );
|
||||
XP_U16 len = stream_getSize( stream );
|
||||
XP_UCHAR buf[len + 1];
|
||||
|
|
|
@ -1535,7 +1535,7 @@ cursesmain( XP_Bool XP_UNUSED(isServer), LaunchParams* params )
|
|||
|
||||
endwin();
|
||||
|
||||
device_store( params->dutil );
|
||||
device_store( params->dutil, NULL_XWE );
|
||||
|
||||
if ( params->useUdp ) {
|
||||
relaycon_cleanup( params );
|
||||
|
|
|
@ -142,7 +142,7 @@ button_press_event( GtkWidget* XP_UNUSED(widget), GdkEventButton *event,
|
|||
|
||||
if ( !globals->mouseDown ) {
|
||||
globals->mouseDown = XP_TRUE;
|
||||
redraw = board_handlePenDown( globals->cGlobals.game.board,
|
||||
redraw = board_handlePenDown( globals->cGlobals.game.board, NULL_XWE,
|
||||
event->x, event->y, &handled );
|
||||
if ( redraw ) {
|
||||
board_draw( globals->cGlobals.game.board, NULL_XWE );
|
||||
|
@ -161,8 +161,8 @@ motion_notify_event( GtkWidget* XP_UNUSED(widget), GdkEventMotion *event,
|
|||
gtkSetAltState( globals, event->state );
|
||||
|
||||
if ( globals->mouseDown ) {
|
||||
handled = board_handlePenMove( globals->cGlobals.game.board, event->x,
|
||||
event->y );
|
||||
handled = board_handlePenMove( globals->cGlobals.game.board,
|
||||
NULL_XWE, event->x, event->y );
|
||||
if ( handled ) {
|
||||
board_draw( globals->cGlobals.game.board, NULL_XWE );
|
||||
disenable_buttons( globals );
|
||||
|
@ -264,7 +264,7 @@ key_press_event( GtkWidget* XP_UNUSED(widget), GdkEventKey* event,
|
|||
board_handleKeyRepeat( globals->cGlobals.game.board, NULL_XWE,
|
||||
xpkey, &handled )
|
||||
: board_handleKeyDown( globals->cGlobals.game.board,
|
||||
xpkey, &handled );
|
||||
NULL_XWE, xpkey, &handled );
|
||||
if ( draw ) {
|
||||
board_draw( globals->cGlobals.game.board, NULL_XWE );
|
||||
}
|
||||
|
@ -622,16 +622,16 @@ configure_event( GtkWidget* widget, GdkEventConfigure* XP_UNUSED(event),
|
|||
XP_ASSERT( !cGlobals->params->verticalScore ); /* not supported */
|
||||
|
||||
BoardDims dims;
|
||||
board_figureLayout( board, cGlobals->gi,
|
||||
board_figureLayout( board, NULL_XWE, cGlobals->gi,
|
||||
GTK_BOARD_LEFT, GTK_HOR_SCORE_TOP, bdWidth, bdHeight,
|
||||
110, 150, 200, bdWidth-25, 16, 16, XP_FALSE, &dims );
|
||||
board_applyLayout( board, &dims );
|
||||
board_applyLayout( board, NULL_XWE, &dims );
|
||||
|
||||
setCtrlsForTray( globals );
|
||||
board_invalAll( board );
|
||||
|
||||
XP_Bool inOut[2];
|
||||
board_zoom( board, 0, inOut );
|
||||
board_zoom( board, NULL_XWE, 0, inOut );
|
||||
setZoomButtons( globals, inOut );
|
||||
|
||||
return TRUE;
|
||||
|
@ -743,7 +743,8 @@ tile_values_impl( GtkGameGlobals* globals, bool full )
|
|||
globals,
|
||||
CHANNEL_NONE,
|
||||
catOnClose );
|
||||
server_formatDictCounts( cGlobals->game.server, stream, 5, full );
|
||||
server_formatDictCounts( cGlobals->game.server, NULL_XWE,
|
||||
stream, 5, full );
|
||||
stream_putU8( stream, '\n' );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
}
|
||||
|
@ -1134,7 +1135,7 @@ disenable_buttons( GtkGameGlobals* globals )
|
|||
}
|
||||
|
||||
GameStateInfo gsi;
|
||||
game_getState( &globals->cGlobals.game, &gsi );
|
||||
game_getState( &globals->cGlobals.game, NULL_XWE, &gsi );
|
||||
|
||||
XP_Bool canFlip = 1 < board_visTileCount( globals->cGlobals.game.board );
|
||||
gtk_widget_set_sensitive( globals->flip_button, canFlip );
|
||||
|
@ -1232,7 +1233,7 @@ handle_colors_button( GtkWidget* XP_UNUSED(widget),
|
|||
static void
|
||||
handle_juggle_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
||||
{
|
||||
if ( board_juggleTray( globals->cGlobals.game.board ) ) {
|
||||
if ( board_juggleTray( globals->cGlobals.game.board, NULL_XWE ) ) {
|
||||
board_draw( globals->cGlobals.game.board, NULL_XWE );
|
||||
}
|
||||
} /* handle_juggle_button */
|
||||
|
@ -1256,7 +1257,8 @@ handle_toggle_undo( GtkWidget* XP_UNUSED(widget),
|
|||
GtkGameGlobals* globals )
|
||||
{
|
||||
BoardCtxt* board = globals->cGlobals.game.board;
|
||||
if ( board_redoReplacedTiles( board ) || board_replaceTiles( board ) ) {
|
||||
if ( board_redoReplacedTiles( board, NULL_XWE )
|
||||
|| board_replaceTiles( board, NULL_XWE ) ) {
|
||||
board_draw( board, NULL_XWE );
|
||||
}
|
||||
}
|
||||
|
@ -1264,7 +1266,7 @@ handle_toggle_undo( GtkWidget* XP_UNUSED(widget),
|
|||
static void
|
||||
handle_trade_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
||||
{
|
||||
if ( board_beginTrade( globals->cGlobals.game.board ) ) {
|
||||
if ( board_beginTrade( globals->cGlobals.game.board, NULL_XWE ) ) {
|
||||
board_draw( globals->cGlobals.game.board, NULL_XWE );
|
||||
disenable_buttons( globals );
|
||||
}
|
||||
|
@ -1291,7 +1293,7 @@ static void
|
|||
handle_zoomin_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
||||
{
|
||||
XP_Bool inOut[2];
|
||||
if ( board_zoom( globals->cGlobals.game.board, 1, inOut ) ) {
|
||||
if ( board_zoom( globals->cGlobals.game.board, NULL_XWE, 1, inOut ) ) {
|
||||
board_draw( globals->cGlobals.game.board, NULL_XWE );
|
||||
setZoomButtons( globals, inOut );
|
||||
}
|
||||
|
@ -1301,7 +1303,7 @@ static void
|
|||
handle_zoomout_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
||||
{
|
||||
XP_Bool inOut[2];
|
||||
if ( board_zoom( globals->cGlobals.game.board, -1, inOut ) ) {
|
||||
if ( board_zoom( globals->cGlobals.game.board, NULL_XWE, -1, inOut ) ) {
|
||||
board_draw( globals->cGlobals.game.board, NULL_XWE );
|
||||
setZoomButtons( globals, inOut );
|
||||
}
|
||||
|
@ -1343,7 +1345,7 @@ scroll_value_changed( GtkAdjustment *adj, GtkGameGlobals* globals )
|
|||
/* && newValueF <= globals->cGlobals.params->nHidden ); */
|
||||
newValue = (XP_U16)newValueF;
|
||||
|
||||
if ( board_setYOffset( globals->cGlobals.game.board, newValue ) ) {
|
||||
if ( board_setYOffset( globals->cGlobals.game.board, NULL_XWE, newValue ) ) {
|
||||
board_draw( globals->cGlobals.game.board, NULL_XWE );
|
||||
}
|
||||
} /* scroll_value_changed */
|
||||
|
@ -1374,9 +1376,9 @@ handle_hide_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
|
||||
board = globals->cGlobals.game.board;
|
||||
if ( TRAY_REVEALED == board_getTrayVisState( board ) ) {
|
||||
draw = board_hideTray( board );
|
||||
draw = board_hideTray( board, NULL_XWE );
|
||||
} else {
|
||||
draw = board_showTray( board );
|
||||
draw = board_showTray( board, NULL_XWE );
|
||||
}
|
||||
if ( draw ) {
|
||||
board_draw( board, NULL_XWE );
|
||||
|
@ -1533,7 +1535,8 @@ ask_blank( gpointer data )
|
|||
return 0;
|
||||
}
|
||||
static void
|
||||
gtk_util_notifyPickTileBlank( XW_UtilCtxt* uc, XP_U16 playerNum, XP_U16 col,
|
||||
gtk_util_notifyPickTileBlank( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XP_U16 playerNum, XP_U16 col,
|
||||
XP_U16 row, const XP_UCHAR** texts, XP_U16 nTiles )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
|
@ -1587,8 +1590,8 @@ ask_tiles( gpointer data )
|
|||
BoardCtxt* board = cGlobals->game.board;
|
||||
XP_Bool draw = XP_TRUE;
|
||||
if ( cGlobals->pickIsInitial ) {
|
||||
server_tilesPicked( cGlobals->game.server, cGlobals->selPlayer,
|
||||
&newTiles );
|
||||
server_tilesPicked( cGlobals->game.server, NULL_XWE,
|
||||
cGlobals->selPlayer, &newTiles );
|
||||
} else {
|
||||
draw = board_commitTurn( cGlobals->game.board, NULL_XWE,
|
||||
XP_TRUE, XP_TRUE, &newTiles );
|
||||
|
@ -1602,8 +1605,8 @@ ask_tiles( gpointer data )
|
|||
}
|
||||
|
||||
static void
|
||||
gtk_util_informNeedPickTiles( XW_UtilCtxt* uc, XP_Bool isInitial,
|
||||
XP_U16 player, XP_U16 nToPick,
|
||||
gtk_util_informNeedPickTiles( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XP_Bool isInitial, XP_U16 player, XP_U16 nToPick,
|
||||
XP_U16 nFaces, const XP_UCHAR** faces,
|
||||
const XP_U16* counts )
|
||||
{
|
||||
|
@ -1631,7 +1634,7 @@ ask_password( gpointer data )
|
|||
XP_U16 len = VSIZE(buf);
|
||||
if ( gtkpasswdask( cGlobals->askPassName, buf, &len ) ) {
|
||||
BoardCtxt* board = cGlobals->game.board;
|
||||
if ( board_passwordProvided( board, cGlobals->selPlayer, buf ) ) {
|
||||
if ( board_passwordProvided( board, NULL_XWE, cGlobals->selPlayer, buf ) ) {
|
||||
board_draw( board, NULL_XWE );
|
||||
}
|
||||
}
|
||||
|
@ -1639,7 +1642,8 @@ ask_password( gpointer data )
|
|||
}
|
||||
|
||||
static void
|
||||
gtk_util_informNeedPassword( XW_UtilCtxt* uc, XP_U16 player, const XP_UCHAR* name )
|
||||
gtk_util_informNeedPassword( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XP_U16 player, const XP_UCHAR* name )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
CommonGlobals* cGlobals = &globals->cGlobals;
|
||||
|
@ -1676,7 +1680,8 @@ setCtrlsForTray( GtkGameGlobals* XP_UNUSED(globals) )
|
|||
} /* setCtrlsForTray */
|
||||
|
||||
static void
|
||||
gtk_util_trayHiddenChange( XW_UtilCtxt* uc, XW_TrayVisState XP_UNUSED(state),
|
||||
gtk_util_trayHiddenChange( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XW_TrayVisState XP_UNUSED(state),
|
||||
XP_U16 XP_UNUSED(nVisibleRows) )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
|
@ -1684,7 +1689,7 @@ gtk_util_trayHiddenChange( XW_UtilCtxt* uc, XW_TrayVisState XP_UNUSED(state),
|
|||
} /* gtk_util_trayHiddenChange */
|
||||
|
||||
static void
|
||||
gtk_util_yOffsetChange( XW_UtilCtxt* uc, XP_U16 maxOffset,
|
||||
gtk_util_yOffsetChange( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XP_U16 maxOffset,
|
||||
XP_U16 XP_UNUSED(oldOffset),
|
||||
XP_U16 newOffset )
|
||||
{
|
||||
|
@ -1700,7 +1705,7 @@ gtk_util_yOffsetChange( XW_UtilCtxt* uc, XP_U16 maxOffset,
|
|||
|
||||
#ifdef XWFEATURE_TURNCHANGENOTIFY
|
||||
static void
|
||||
gtk_util_turnChanged( XW_UtilCtxt* uc, XP_S16 XP_UNUSED(newTurn) )
|
||||
gtk_util_turnChanged( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XP_S16 XP_UNUSED(newTurn) )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
linuxSaveGame( &globals->cGlobals );
|
||||
|
@ -1716,7 +1721,7 @@ gtkShowFinalScores( const GtkGameGlobals* globals, XP_Bool ignoreTimeout )
|
|||
|
||||
stream = mem_stream_make_raw( MPPARM(cGlobals->util->mpool)
|
||||
cGlobals->params->vtMgr );
|
||||
server_writeFinalScores( cGlobals->game.server, stream );
|
||||
server_writeFinalScores( cGlobals->game.server, NULL_XWE, stream );
|
||||
|
||||
text = strFromStream( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
|
@ -1738,7 +1743,7 @@ gtkShowFinalScores( const GtkGameGlobals* globals, XP_Bool ignoreTimeout )
|
|||
} /* gtkShowFinalScores */
|
||||
|
||||
static void
|
||||
gtk_util_notifyDupStatus( XW_UtilCtxt* uc, XP_Bool XP_UNUSED(amHost),
|
||||
gtk_util_notifyDupStatus( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XP_Bool XP_UNUSED(amHost),
|
||||
const XP_UCHAR* msg )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
|
@ -1746,7 +1751,7 @@ gtk_util_notifyDupStatus( XW_UtilCtxt* uc, XP_Bool XP_UNUSED(amHost),
|
|||
}
|
||||
|
||||
static void
|
||||
gtk_util_informMove( XW_UtilCtxt* uc, XP_S16 XP_UNUSED(turn),
|
||||
gtk_util_informMove( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XP_S16 XP_UNUSED(turn),
|
||||
XWStreamCtxt* expl, XWStreamCtxt* words )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
|
@ -1756,7 +1761,7 @@ gtk_util_informMove( XW_UtilCtxt* uc, XP_S16 XP_UNUSED(turn),
|
|||
}
|
||||
|
||||
static void
|
||||
gtk_util_informUndo( XW_UtilCtxt* uc )
|
||||
gtk_util_informUndo( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe) )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
(void)gtkask_timeout( globals->window, "Remote player undid a move",
|
||||
|
@ -1764,7 +1769,7 @@ gtk_util_informUndo( XW_UtilCtxt* uc )
|
|||
}
|
||||
|
||||
static void
|
||||
gtk_util_notifyGameOver( XW_UtilCtxt* uc, XP_S16 quitter )
|
||||
gtk_util_notifyGameOver( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XP_S16 quitter )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
CommonGlobals* cGlobals = &globals->cGlobals;
|
||||
|
@ -1787,7 +1792,8 @@ gtk_util_notifyGameOver( XW_UtilCtxt* uc, XP_S16 quitter )
|
|||
} /* gtk_util_notifyGameOver */
|
||||
|
||||
static void
|
||||
gtk_util_informNetDict( XW_UtilCtxt* uc, XP_LangCode XP_UNUSED(lang),
|
||||
gtk_util_informNetDict( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
XP_LangCode XP_UNUSED(lang),
|
||||
const XP_UCHAR* oldName,
|
||||
const XP_UCHAR* newName, const XP_UCHAR* newSum,
|
||||
XWPhoniesChoice phoniesAction )
|
||||
|
@ -1812,7 +1818,7 @@ gtk_util_informNetDict( XW_UtilCtxt* uc, XP_LangCode XP_UNUSED(lang),
|
|||
|
||||
#ifdef XWFEATURE_HILITECELL
|
||||
static XP_Bool
|
||||
gtk_util_hiliteCell( XW_UtilCtxt* uc, XP_U16 col, XP_U16 row )
|
||||
gtk_util_hiliteCell( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XP_U16 col, XP_U16 row )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
#ifndef DONT_ABORT_ENGINE
|
||||
|
@ -1837,14 +1843,14 @@ gtk_util_hiliteCell( XW_UtilCtxt* uc, XP_U16 col, XP_U16 row )
|
|||
#endif
|
||||
|
||||
static XP_Bool
|
||||
gtk_util_altKeyDown( XW_UtilCtxt* uc )
|
||||
gtk_util_altKeyDown( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe) )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
return globals->altKeyDown;
|
||||
}
|
||||
|
||||
static XP_Bool
|
||||
gtk_util_engineProgressCallback( XW_UtilCtxt* XP_UNUSED(uc) )
|
||||
gtk_util_engineProgressCallback( XW_UtilCtxt* XP_UNUSED(uc), XWEnv XP_UNUSED(xwe) )
|
||||
{
|
||||
#ifdef DONT_ABORT_ENGINE
|
||||
return XP_TRUE; /* keep going */
|
||||
|
@ -1871,7 +1877,8 @@ ask_bad_words( gpointer data )
|
|||
}
|
||||
|
||||
static void
|
||||
gtk_util_notifyIllegalWords( XW_UtilCtxt* uc, BadWordInfo* bwi, XP_U16 player,
|
||||
gtk_util_notifyIllegalWords( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
BadWordInfo* bwi, XP_U16 player,
|
||||
XP_Bool turnLost )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
|
@ -1901,7 +1908,7 @@ gtk_util_notifyIllegalWords( XW_UtilCtxt* uc, BadWordInfo* bwi, XP_U16 player,
|
|||
} /* gtk_util_notifyIllegalWords */
|
||||
|
||||
static void
|
||||
gtk_util_remSelected( XW_UtilCtxt* uc )
|
||||
gtk_util_remSelected( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe) )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
XWStreamCtxt* stream;
|
||||
|
@ -1909,7 +1916,7 @@ gtk_util_remSelected( XW_UtilCtxt* uc )
|
|||
|
||||
stream = mem_stream_make_raw( MEMPOOL
|
||||
globals->cGlobals.params->vtMgr );
|
||||
board_formatRemainingTiles( globals->cGlobals.game.board, stream );
|
||||
board_formatRemainingTiles( globals->cGlobals.game.board, NULL_XWE, stream );
|
||||
text = strFromStream( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
|
||||
|
@ -1918,7 +1925,7 @@ gtk_util_remSelected( XW_UtilCtxt* uc )
|
|||
}
|
||||
|
||||
static void
|
||||
gtk_util_timerSelected( XW_UtilCtxt* uc, XP_Bool inDuplicateMode,
|
||||
gtk_util_timerSelected( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XP_Bool inDuplicateMode,
|
||||
XP_Bool canPause )
|
||||
{
|
||||
if ( inDuplicateMode ) {
|
||||
|
@ -1933,7 +1940,7 @@ gtk_util_timerSelected( XW_UtilCtxt* uc, XP_Bool inDuplicateMode,
|
|||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
static XWStreamCtxt*
|
||||
gtk_util_makeStreamFromAddr(XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
|
||||
gtk_util_makeStreamFromAddr(XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XP_PlayerAddr channelNo )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
|
||||
|
@ -1946,7 +1953,8 @@ gtk_util_makeStreamFromAddr(XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
|
|||
|
||||
#ifdef XWFEATURE_CHAT
|
||||
static void
|
||||
gtk_util_showChat( XW_UtilCtxt* uc, const XP_UCHAR* const msg, XP_S16 from,
|
||||
gtk_util_showChat( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
const XP_UCHAR* const msg, XP_S16 from,
|
||||
XP_U32 timestamp )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
|
@ -1963,7 +1971,7 @@ gtk_util_showChat( XW_UtilCtxt* uc, const XP_UCHAR* const msg, XP_S16 from,
|
|||
|
||||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
static XP_Bool
|
||||
gtk_util_getTraySearchLimits( XW_UtilCtxt* XP_UNUSED(uc),
|
||||
gtk_util_getTraySearchLimits( XW_UtilCtxt* XP_UNUSED(uc), XWEnv XP_UNUSED(xwe),
|
||||
XP_U16* XP_UNUSED(min), XP_U16* max )
|
||||
{
|
||||
*max = askNTiles( MAX_TRAY_TILES, *max );
|
||||
|
@ -1973,7 +1981,7 @@ gtk_util_getTraySearchLimits( XW_UtilCtxt* XP_UNUSED(uc),
|
|||
|
||||
#ifndef XWFEATURE_MINIWIN
|
||||
static void
|
||||
gtk_util_bonusSquareHeld( XW_UtilCtxt* uc, XWBonusType bonus )
|
||||
gtk_util_bonusSquareHeld( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XWBonusType bonus )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
gchar* msg = g_strdup_printf( "bonusSquareHeld(bonus=%d)", bonus );
|
||||
|
@ -1982,7 +1990,7 @@ gtk_util_bonusSquareHeld( XW_UtilCtxt* uc, XWBonusType bonus )
|
|||
}
|
||||
|
||||
static void
|
||||
gtk_util_playerScoreHeld( XW_UtilCtxt* uc, XP_U16 player )
|
||||
gtk_util_playerScoreHeld( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XP_U16 player )
|
||||
{
|
||||
LOG_FUNC();
|
||||
|
||||
|
@ -2000,7 +2008,7 @@ gtk_util_playerScoreHeld( XW_UtilCtxt* uc, XP_U16 player )
|
|||
|
||||
#ifdef XWFEATURE_BOARDWORDS
|
||||
static void
|
||||
gtk_util_cellSquareHeld( XW_UtilCtxt* uc, XWStreamCtxt* words )
|
||||
gtk_util_cellSquareHeld( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XWStreamCtxt* words )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
const XP_U8* bytes = stream_getPtr( words );
|
||||
|
@ -2012,7 +2020,7 @@ gtk_util_cellSquareHeld( XW_UtilCtxt* uc, XWStreamCtxt* words )
|
|||
#endif
|
||||
|
||||
static void
|
||||
gtk_util_informWordsBlocked( XW_UtilCtxt* uc, XP_U16 nBadWords,
|
||||
gtk_util_informWordsBlocked( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XP_U16 nBadWords,
|
||||
XWStreamCtxt* words, const XP_UCHAR* dict )
|
||||
{
|
||||
XP_U16 len = stream_getSize( words );
|
||||
|
@ -2026,7 +2034,7 @@ gtk_util_informWordsBlocked( XW_UtilCtxt* uc, XP_U16 nBadWords,
|
|||
}
|
||||
|
||||
static void
|
||||
gtk_util_userError( XW_UtilCtxt* uc, UtilErrID id )
|
||||
gtk_util_userError( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), UtilErrID id )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
XP_Bool silent;
|
||||
|
@ -2055,7 +2063,7 @@ ask_move( gpointer data )
|
|||
}
|
||||
|
||||
static void
|
||||
gtk_util_notifyMove( XW_UtilCtxt* uc, XWStreamCtxt* stream )
|
||||
gtk_util_notifyMove( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XWStreamCtxt* stream )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
CommonGlobals* cGlobals = &globals->cGlobals;
|
||||
|
@ -2086,7 +2094,8 @@ ask_trade( gpointer data )
|
|||
}
|
||||
|
||||
static void
|
||||
gtk_util_notifyTrade( XW_UtilCtxt* uc, const XP_UCHAR** tiles, XP_U16 nTiles )
|
||||
gtk_util_notifyTrade( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
const XP_UCHAR** tiles, XP_U16 nTiles )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||
formatConfirmTrade( &globals->cGlobals, tiles, nTiles );
|
||||
|
|
|
@ -922,7 +922,7 @@ gtkmain( LaunchParams* params )
|
|||
if ( params->runSMSTest ) {
|
||||
CommonGlobals cGlobals = {.params = params };
|
||||
setupUtil( &cGlobals );
|
||||
smsproto_runTests( params->mpool, cGlobals.params->dutil );
|
||||
smsproto_runTests( params->mpool, NULL_XWE, cGlobals.params->dutil );
|
||||
linux_util_vt_destroy( cGlobals.util );
|
||||
free( cGlobals.util );
|
||||
}
|
||||
|
@ -933,7 +933,7 @@ gtkmain( LaunchParams* params )
|
|||
}
|
||||
|
||||
gtk_main();
|
||||
device_store( params->dutil );
|
||||
device_store( params->dutil, NULL_XWE );
|
||||
/* closeGamesDB( params->pDb ); */
|
||||
/* params->pDb = NULL; */
|
||||
relaycon_cleanup( params );
|
||||
|
|
|
@ -71,7 +71,7 @@ nplayers_menu_changed( GtkComboBox* combo, GtkNewGameState* state )
|
|||
gint index = gtk_combo_box_get_active( GTK_COMBO_BOX(combo) );
|
||||
if ( index >= 0 ) {
|
||||
NGValue value = { .ng_u16 = index + 1 };
|
||||
newg_attrChanged( state->newGameCtxt, NG_ATTR_NPLAYERS, value );
|
||||
newg_attrChanged( state->newGameCtxt, NULL_XWE, NG_ATTR_NPLAYERS, value );
|
||||
}
|
||||
} /* nplayers_menu_changed */
|
||||
|
||||
|
@ -88,7 +88,7 @@ role_combo_changed( GtkComboBox* combo, gpointer gp )
|
|||
value.ng_role = role;
|
||||
|
||||
if ( state->isNewGame ) {
|
||||
newg_attrChanged( state->newGameCtxt, NG_ATTR_ROLE, value );
|
||||
newg_attrChanged( state->newGameCtxt, NULL_XWE, NG_ATTR_ROLE, value );
|
||||
} else if ( state->loaded ) {
|
||||
/* put it back */
|
||||
gtk_combo_box_set_active( GTK_COMBO_BOX(combo), state->role );
|
||||
|
@ -243,7 +243,7 @@ on_timer_changed( GtkEditable *editable, gpointer data )
|
|||
XP_ASSERT( GTK_ENTRY(state->timerField) == GTK_ENTRY(editable) );
|
||||
gchar* text = gtk_editable_get_chars( editable, 0, -1 );
|
||||
NGValue value = { .ng_u16 = atoi(text) };
|
||||
newg_attrChanged( state->newGameCtxt, NG_ATTR_TIMER, value );
|
||||
newg_attrChanged( state->newGameCtxt, NULL_XWE, NG_ATTR_TIMER, value );
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -264,7 +264,7 @@ static void
|
|||
handle_duplicate_toggled( GtkWidget* item, GtkNewGameState* state )
|
||||
{
|
||||
NGValue value = { .ng_bool = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(item) ) };
|
||||
newg_attrChanged( state->newGameCtxt, NG_ATTR_DUPLICATE, value );
|
||||
newg_attrChanged( state->newGameCtxt, NULL_XWE, NG_ATTR_DUPLICATE, value );
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -703,12 +703,12 @@ gtkNewGameDialog( GtkGameGlobals* globals, CurGameInfo* gi, CommsAddrRec* addr,
|
|||
|
||||
dialog = makeNewGameDialog( &state );
|
||||
|
||||
newg_load( state.newGameCtxt, gi );
|
||||
newg_load( state.newGameCtxt, NULL_XWE, gi );
|
||||
state.loaded = XP_TRUE;
|
||||
|
||||
gtk_main();
|
||||
if ( !state.cancelled && !state.revert ) {
|
||||
if ( newg_store( state.newGameCtxt, gi, XP_TRUE ) ) {
|
||||
if ( newg_store( state.newGameCtxt, NULL_XWE, gi, XP_TRUE ) ) {
|
||||
gi->boardSize = state.nCols;
|
||||
replaceStringIfDifferent( globals->cGlobals.util->mpool,
|
||||
&gi->dictName, state.dict );
|
||||
|
|
|
@ -25,40 +25,41 @@
|
|||
#include "gamesdb.h"
|
||||
#include "LocalizedStrIncludes.h"
|
||||
|
||||
static XP_U32 linux_dutil_getCurSeconds( XW_DUtilCtxt* duc );
|
||||
static const XP_UCHAR* linux_dutil_getUserString( XW_DUtilCtxt* duc, XP_U16 code );
|
||||
static const XP_UCHAR* linux_dutil_getUserQuantityString( XW_DUtilCtxt* duc, XP_U16 code,
|
||||
static XP_U32 linux_dutil_getCurSeconds( XW_DUtilCtxt* duc, XWEnv xwe );
|
||||
static const XP_UCHAR* linux_dutil_getUserString( XW_DUtilCtxt* duc, XWEnv xwe, XP_U16 code );
|
||||
static const XP_UCHAR* linux_dutil_getUserQuantityString( XW_DUtilCtxt* duc, XWEnv xwe, XP_U16 code,
|
||||
XP_U16 quantity );
|
||||
|
||||
static void linux_dutil_storeStream( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
||||
static void linux_dutil_storeStream( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||
XWStreamCtxt* data );
|
||||
static void linux_dutil_loadStream( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
||||
static void linux_dutil_loadStream( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||
XWStreamCtxt* inOut );
|
||||
static void linux_dutil_storePtr( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
||||
static void linux_dutil_storePtr( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||
const void* data, XP_U16 len );
|
||||
static void linux_dutil_loadPtr( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
||||
static void linux_dutil_loadPtr( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||
void* data, XP_U16* lenp );
|
||||
|
||||
|
||||
#ifdef XWFEATURE_SMS
|
||||
static XP_Bool linux_dutil_phoneNumbersSame( XW_DUtilCtxt* duc,
|
||||
static XP_Bool linux_dutil_phoneNumbersSame( XW_DUtilCtxt* duc, XWEnv xwe,
|
||||
const XP_UCHAR* p1,
|
||||
const XP_UCHAR* p2 );
|
||||
#endif
|
||||
|
||||
#ifdef XWFEATURE_DEVID
|
||||
static const XP_UCHAR* linux_dutil_getDevID( XW_DUtilCtxt* duc, DevIDType* typ );
|
||||
static void linux_dutil_deviceRegistered( XW_DUtilCtxt* duc, DevIDType typ,
|
||||
static const XP_UCHAR* linux_dutil_getDevID( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType* typ );
|
||||
static void linux_dutil_deviceRegistered( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType typ,
|
||||
const XP_UCHAR* idRelay );
|
||||
#endif
|
||||
|
||||
#ifdef COMMS_CHECKSUM
|
||||
static XP_UCHAR* linux_dutil_md5sum( XW_DUtilCtxt* duc, const XP_U8* ptr,
|
||||
static XP_UCHAR* linux_dutil_md5sum( XW_DUtilCtxt* duc, XWEnv xwe, const XP_U8* ptr,
|
||||
XP_U16 len );
|
||||
#endif
|
||||
|
||||
static void
|
||||
linux_dutil_notifyPause( XW_DUtilCtxt* XP_UNUSED(duc), XP_U32 XP_UNUSED_DBG(gameID),
|
||||
linux_dutil_notifyPause( XW_DUtilCtxt* XP_UNUSED(duc), XWEnv XP_UNUSED(xwe),
|
||||
XP_U32 XP_UNUSED_DBG(gameID),
|
||||
DupPauseType XP_UNUSED_DBG(pauseTyp),
|
||||
XP_U16 XP_UNUSED_DBG(pauser),
|
||||
const XP_UCHAR* XP_UNUSED_DBG(name),
|
||||
|
@ -69,7 +70,7 @@ linux_dutil_notifyPause( XW_DUtilCtxt* XP_UNUSED(duc), XP_U32 XP_UNUSED_DBG(game
|
|||
}
|
||||
|
||||
static void
|
||||
linux_dutil_onDupTimerChanged( XW_DUtilCtxt* XP_UNUSED(duc),
|
||||
linux_dutil_onDupTimerChanged( XW_DUtilCtxt* XP_UNUSED(duc), XWEnv XP_UNUSED(xwe),
|
||||
XP_U32 XP_UNUSED_DBG(gameID),
|
||||
XP_U32 XP_UNUSED_DBG(oldVal),
|
||||
XP_U32 XP_UNUSED_DBG(newVal) )
|
||||
|
@ -125,13 +126,14 @@ void dutils_free( XW_DUtilCtxt** XP_UNUSED_DBG(ducp) )
|
|||
}
|
||||
|
||||
static XP_U32
|
||||
linux_dutil_getCurSeconds( XW_DUtilCtxt* XP_UNUSED(duc) )
|
||||
linux_dutil_getCurSeconds( XW_DUtilCtxt* XP_UNUSED(duc), XWEnv XP_UNUSED(xwe) )
|
||||
{
|
||||
return linux_getCurSeconds();
|
||||
}
|
||||
|
||||
static const XP_UCHAR*
|
||||
linux_dutil_getUserString( XW_DUtilCtxt* XP_UNUSED(uc), XP_U16 code )
|
||||
linux_dutil_getUserString( XW_DUtilCtxt* XP_UNUSED(uc),
|
||||
XWEnv XP_UNUSED(xwe), XP_U16 code )
|
||||
{
|
||||
switch( code ) {
|
||||
case STRD_REMAINING_TILES_ADD:
|
||||
|
@ -216,29 +218,30 @@ linux_dutil_getUserString( XW_DUtilCtxt* XP_UNUSED(uc), XP_U16 code )
|
|||
} /* linux_dutil_getUserString */
|
||||
|
||||
static const XP_UCHAR*
|
||||
linux_dutil_getUserQuantityString( XW_DUtilCtxt* duc, XP_U16 code,
|
||||
linux_dutil_getUserQuantityString( XW_DUtilCtxt* duc, XWEnv xwe, XP_U16 code,
|
||||
XP_U16 XP_UNUSED(quantity) )
|
||||
{
|
||||
return linux_dutil_getUserString( duc, code );
|
||||
return linux_dutil_getUserString( duc, xwe, code );
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dutil_storeStream( XW_DUtilCtxt* duc, const XP_UCHAR* key, XWStreamCtxt* stream )
|
||||
linux_dutil_storeStream( XW_DUtilCtxt* duc, XWEnv xwe,
|
||||
const XP_UCHAR* key, XWStreamCtxt* stream )
|
||||
{
|
||||
const void* ptr = stream_getPtr( stream );
|
||||
XP_U16 len = stream_getSize( stream );
|
||||
linux_dutil_storePtr( duc, key, ptr, len );
|
||||
linux_dutil_storePtr( duc, xwe, key, ptr, len );
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dutil_loadStream( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
||||
linux_dutil_loadStream( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* key,
|
||||
XWStreamCtxt* stream )
|
||||
{
|
||||
XP_U16 len = 0;
|
||||
linux_dutil_loadPtr( duc, key, NULL, &len );
|
||||
linux_dutil_loadPtr( duc, xwe, key, NULL, &len );
|
||||
if ( 0 < len ) {
|
||||
XP_U8 buf[len];
|
||||
linux_dutil_loadPtr( duc, key, buf, &len );
|
||||
linux_dutil_loadPtr( duc, xwe, key, buf, &len );
|
||||
|
||||
stream_putBytes( stream, buf, len );
|
||||
}
|
||||
|
@ -247,7 +250,7 @@ linux_dutil_loadStream( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
|||
}
|
||||
|
||||
static void
|
||||
linux_dutil_storePtr( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
||||
linux_dutil_storePtr( XW_DUtilCtxt* duc, XWEnv XP_UNUSED(xwe), const XP_UCHAR* key,
|
||||
const void* data, const XP_U16 len )
|
||||
{
|
||||
LaunchParams* params = (LaunchParams*)duc->closure;
|
||||
|
@ -259,7 +262,7 @@ linux_dutil_storePtr( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
|||
}
|
||||
|
||||
static void
|
||||
linux_dutil_loadPtr( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
||||
linux_dutil_loadPtr( XW_DUtilCtxt* duc, XWEnv XP_UNUSED(xwe), const XP_UCHAR* key,
|
||||
void* data, XP_U16* lenp )
|
||||
{
|
||||
LaunchParams* params = (LaunchParams*)duc->closure;
|
||||
|
@ -294,8 +297,8 @@ linux_dutil_loadPtr( XW_DUtilCtxt* duc, const XP_UCHAR* key,
|
|||
|
||||
#ifdef XWFEATURE_SMS
|
||||
static XP_Bool
|
||||
linux_dutil_phoneNumbersSame( XW_DUtilCtxt* duc, const XP_UCHAR* p1,
|
||||
const XP_UCHAR* p2 )
|
||||
linux_dutil_phoneNumbersSame( XW_DUtilCtxt* duc, XWEnv XP_UNUSED(xwe),
|
||||
const XP_UCHAR* p1, const XP_UCHAR* p2 )
|
||||
{
|
||||
LOG_FUNC();
|
||||
XP_USE( duc );
|
||||
|
@ -307,14 +310,14 @@ linux_dutil_phoneNumbersSame( XW_DUtilCtxt* duc, const XP_UCHAR* p1,
|
|||
|
||||
#ifdef XWFEATURE_DEVID
|
||||
static const XP_UCHAR*
|
||||
linux_dutil_getDevID( XW_DUtilCtxt* duc, DevIDType* typ )
|
||||
linux_dutil_getDevID( XW_DUtilCtxt* duc, XWEnv XP_UNUSED(xwe), DevIDType* typ )
|
||||
{
|
||||
LaunchParams* params = (LaunchParams*)duc->closure;
|
||||
return linux_getDevID( params, typ );
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dutil_deviceRegistered( XW_DUtilCtxt* duc, DevIDType typ,
|
||||
linux_dutil_deviceRegistered( XW_DUtilCtxt* duc, XWEnv XP_UNUSED(xwe), DevIDType typ,
|
||||
const XP_UCHAR* idRelay )
|
||||
{
|
||||
/* Script discon_ok2.sh is grepping for these strings in logs, so don't
|
||||
|
@ -340,7 +343,8 @@ linux_dutil_deviceRegistered( XW_DUtilCtxt* duc, DevIDType typ,
|
|||
|
||||
#ifdef COMMS_CHECKSUM
|
||||
static XP_UCHAR*
|
||||
linux_dutil_md5sum( XW_DUtilCtxt* duc, const XP_U8* ptr, XP_U16 len )
|
||||
linux_dutil_md5sum( XW_DUtilCtxt* duc, XWEnv XP_UNUSED(xwe),
|
||||
const XP_U8* ptr, XP_U16 len )
|
||||
{
|
||||
gchar* sum = g_compute_checksum_for_data( G_CHECKSUM_MD5, ptr, len );
|
||||
XP_U16 sumlen = 1 + strlen( sum );
|
||||
|
|
|
@ -433,7 +433,7 @@ gameGotBuf( CommonGlobals* cGlobals, XP_Bool hasDraw, const XP_U8* buf,
|
|||
before giving the server another shot. So just call the idle
|
||||
proc. */
|
||||
if ( hasDraw && redraw ) {
|
||||
util_requestTime( cGlobals->util );
|
||||
util_requestTime( cGlobals->util, NULL_XWE );
|
||||
} else {
|
||||
for ( int ii = 0; ii < 4; ++ii ) {
|
||||
redraw = server_do( game->server, NULL_XWE ) || redraw;
|
||||
|
@ -547,7 +547,7 @@ catFinalScores( const CommonGlobals* cGlobals, XP_S16 quitter )
|
|||
cGlobals->gi->players[quitter].name );
|
||||
stream_catString( stream, buf );
|
||||
}
|
||||
server_writeFinalScores( cGlobals->game.server, stream );
|
||||
server_writeFinalScores( cGlobals->game.server, NULL_XWE, stream );
|
||||
stream_putU8( stream, '\n' );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
} /* printFinalScores */
|
||||
|
@ -1142,7 +1142,7 @@ linShiftFocus( CommonGlobals* cGlobals, XP_Key key, const BoardObjectType* order
|
|||
curIndex %= 3;
|
||||
|
||||
nxt = order[curIndex];
|
||||
handled = board_focusChanged( board, nxt, XP_TRUE );
|
||||
handled = board_focusChanged( board, NULL_XWE, nxt, XP_TRUE );
|
||||
|
||||
if ( !!nxtP ) {
|
||||
*nxtP = nxt;
|
||||
|
@ -1442,7 +1442,7 @@ linux_relay_ioproc( GIOChannel* source, GIOCondition condition, gpointer data )
|
|||
that on the screen before giving the server another
|
||||
shot. So just call the idle proc. */
|
||||
if ( redraw ) {
|
||||
util_requestTime( cGlobals->util );
|
||||
util_requestTime( cGlobals->util, NULL_XWE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1730,7 +1730,7 @@ streamClosed( XWStreamCtxt* stream, XP_PlayerAddr addr, void* closure )
|
|||
} /* streamClosed */
|
||||
|
||||
static XWStreamCtxt*
|
||||
linux_util_makeStreamFromAddr( XW_UtilCtxt* uctx, XP_U16 channelNo )
|
||||
linux_util_makeStreamFromAddr( XW_UtilCtxt* uctx, XWEnv XP_UNUSED(xwe), XP_U16 channelNo )
|
||||
{
|
||||
#if 1
|
||||
/* XWStreamCtxt* stream = linux_mem_stream_make( uctx->closure, channelNo, */
|
||||
|
@ -1773,7 +1773,7 @@ linuxFireTimer( CommonGlobals* cGlobals, XWTimerReason why )
|
|||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
static void
|
||||
linux_util_informMissing( XW_UtilCtxt* XP_UNUSED(uc),
|
||||
linux_util_informMissing( XW_UtilCtxt* XP_UNUSED(uc), XWEnv XP_UNUSED(xwe),
|
||||
XP_Bool XP_UNUSED_DBG(isServer),
|
||||
const CommsAddrRec* XP_UNUSED_DBG(addr),
|
||||
XP_U16 XP_UNUSED_DBG(nDevs),
|
||||
|
@ -1784,7 +1784,7 @@ linux_util_informMissing( XW_UtilCtxt* XP_UNUSED(uc),
|
|||
}
|
||||
|
||||
static void
|
||||
linux_util_addrChange( XW_UtilCtxt* uc,
|
||||
linux_util_addrChange( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),
|
||||
const CommsAddrRec* XP_UNUSED(oldAddr),
|
||||
const CommsAddrRec* newAddr )
|
||||
{
|
||||
|
@ -1835,7 +1835,7 @@ changeRolesIdle( gpointer data )
|
|||
}
|
||||
|
||||
static void
|
||||
linux_util_setIsServer( XW_UtilCtxt* uc, XP_Bool isServer )
|
||||
linux_util_setIsServer( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe),XP_Bool isServer )
|
||||
{
|
||||
XP_LOGF( "%s(isServer=%d)", __func__, isServer );
|
||||
CommonGlobals* cGlobals = (CommonGlobals*)uc->closure;
|
||||
|
@ -2207,7 +2207,8 @@ listDicts( const LaunchParams *params )
|
|||
}
|
||||
|
||||
static void
|
||||
linux_util_formatPauseHistory( XW_UtilCtxt* XP_UNUSED(uc), XWStreamCtxt* stream,
|
||||
linux_util_formatPauseHistory( XW_UtilCtxt* XP_UNUSED(uc), XWEnv XP_UNUSED(xwe),
|
||||
XWStreamCtxt* stream,
|
||||
DupPauseType typ, XP_S16 turn,
|
||||
XP_U32 whenPrev, XP_U32 whenCur, const XP_UCHAR* msg )
|
||||
{
|
||||
|
@ -2310,7 +2311,7 @@ slowrob_timer_func( gpointer data )
|
|||
#endif
|
||||
|
||||
static void
|
||||
linux_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why,
|
||||
linux_util_setTimer( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XWTimerReason why,
|
||||
XP_U16 XP_UNUSED_STANDALONE(when),
|
||||
XWTimerProc proc, void* closure )
|
||||
{
|
||||
|
@ -2360,7 +2361,7 @@ linux_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why,
|
|||
} /* linux_util_setTimer */
|
||||
|
||||
static void
|
||||
linux_util_clearTimer( XW_UtilCtxt* uc, XWTimerReason why )
|
||||
linux_util_clearTimer( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XWTimerReason why )
|
||||
{
|
||||
CommonGlobals* cGlobals = (CommonGlobals*)uc->closure;
|
||||
cGlobals->timerInfo[why].proc = NULL;
|
||||
|
@ -2387,7 +2388,7 @@ idle_func( gpointer data )
|
|||
} /* idle_func */
|
||||
|
||||
static void
|
||||
linux_util_requestTime( XW_UtilCtxt* uc )
|
||||
linux_util_requestTime( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe) )
|
||||
{
|
||||
CommonGlobals* cGlobals = (CommonGlobals*)uc->closure;
|
||||
cGlobals->idleID = g_idle_add( idle_func, cGlobals );
|
||||
|
|
|
@ -246,8 +246,9 @@ parseAndDispatch( LaunchParams* params, uint8_t* buf, int len,
|
|||
{
|
||||
LinSMSData* storage = getStorage( params );
|
||||
const XP_UCHAR* fromPhone = addr->u.sms.phone;
|
||||
SMSMsgArray* arr = smsproto_prepInbound( storage->protoState, fromPhone,
|
||||
storage->myPort, buf, len );
|
||||
SMSMsgArray* arr =
|
||||
smsproto_prepInbound( storage->protoState, NULL_XWE, fromPhone,
|
||||
storage->myPort, buf, len );
|
||||
if ( NULL != arr ) {
|
||||
XP_ASSERT( arr->format == FORMAT_LOC );
|
||||
for ( XP_U16 ii = 0; ii < arr->nMsgs; ++ii ) {
|
||||
|
@ -286,7 +287,7 @@ linux_sms_init( LaunchParams* params, const gchar* myPhone, XP_U16 myPort,
|
|||
storage->myPort = myPort;
|
||||
storage->procs = procs;
|
||||
storage->procClosure = procClosure;
|
||||
storage->protoState = smsproto_init( MPPARM(params->mpool) params->dutil );
|
||||
storage->protoState = smsproto_init( MPPARM(params->mpool) NULL_XWE, params->dutil );
|
||||
|
||||
formatQueuePath( myPhone, myPort, storage->myQueue, sizeof(storage->myQueue) );
|
||||
XP_LOGFF( " my queue: %s", storage->myQueue );
|
||||
|
@ -317,7 +318,7 @@ linux_sms_invite( LaunchParams* params, const NetLaunchInfo* nli,
|
|||
XP_U16 waitSecs;
|
||||
const XP_Bool forceOld = XP_TRUE; /* Send NOW in case test app kills us */
|
||||
SMSMsgArray* arr
|
||||
= smsproto_prepOutbound( storage->protoState, INVITE, nli->gameID, ptr,
|
||||
= smsproto_prepOutbound( storage->protoState, NULL_XWE, INVITE, nli->gameID, ptr,
|
||||
len, toPhone, toPort, forceOld, &waitSecs );
|
||||
XP_ASSERT( !!arr || !forceOld );
|
||||
sendOrRetry( params, arr, INVITE, waitSecs, toPhone, toPort,
|
||||
|
@ -332,7 +333,7 @@ linux_sms_send( LaunchParams* params, const XP_U8* buf,
|
|||
{
|
||||
LinSMSData* storage = getStorage( params );
|
||||
XP_U16 waitSecs;
|
||||
SMSMsgArray* arr = smsproto_prepOutbound( storage->protoState, DATA, gameID,
|
||||
SMSMsgArray* arr = smsproto_prepOutbound( storage->protoState, NULL_XWE, DATA, gameID,
|
||||
buf, buflen, phone, port,
|
||||
XP_TRUE, &waitSecs );
|
||||
sendOrRetry( params, arr, DATA, waitSecs, phone, port, gameID, msgNo );
|
||||
|
@ -382,7 +383,8 @@ retrySend( gpointer data )
|
|||
RetryClosure* closure = (RetryClosure*)data;
|
||||
LinSMSData* storage = getStorage( closure->params );
|
||||
XP_U16 waitSecs;
|
||||
SMSMsgArray* arr = smsproto_prepOutbound( storage->protoState, closure->cmd,
|
||||
SMSMsgArray* arr = smsproto_prepOutbound( storage->protoState, NULL_XWE,
|
||||
closure->cmd,
|
||||
closure->gameID, NULL, 0,
|
||||
closure->phone, closure->port,
|
||||
XP_TRUE, &waitSecs );
|
||||
|
|
|
@ -239,7 +239,7 @@ parseBonusFile( XP_U16 nCols, const char* bonusFile )
|
|||
}
|
||||
|
||||
static XWBonusType
|
||||
linux_util_getSquareBonus( XW_UtilCtxt* uc, XP_U16 nCols,
|
||||
linux_util_getSquareBonus( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe), XP_U16 nCols,
|
||||
XP_U16 col, XP_U16 row )
|
||||
{
|
||||
static XWBonusType* parsedFile = NULL;
|
||||
|
@ -278,7 +278,7 @@ linux_util_getSquareBonus( XW_UtilCtxt* uc, XP_U16 nCols,
|
|||
} /* linux_util_getSquareBonus */
|
||||
|
||||
static XW_DUtilCtxt*
|
||||
linux_util_getDevUtilCtxt( XW_UtilCtxt* uc )
|
||||
linux_util_getDevUtilCtxt( XW_UtilCtxt* uc, XWEnv XP_UNUSED(xwe) )
|
||||
{
|
||||
CommonGlobals* cGlobals = (CommonGlobals*)uc->closure;
|
||||
return cGlobals->params->dutil;
|
||||
|
|
Loading…
Reference in a new issue