From 88335d38f244069271599969c6fb3bfb6f7b0a34 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 26 Apr 2020 11:28:18 -0700 Subject: [PATCH] stop using thread->env mapping for util callbacks --- xwords4/android/jni/utilwrapper.c | 142 +++++---- xwords4/android/jni/utilwrapper.h | 8 +- xwords4/android/jni/xwjni.c | 52 ++-- xwords4/common/board.c | 466 +++++++++++++++--------------- xwords4/common/board.h | 60 ++-- xwords4/common/boarddrw.c | 7 +- xwords4/common/boardp.h | 17 +- xwords4/common/comms.c | 102 +++---- xwords4/common/comms.h | 4 +- xwords4/common/device.c | 10 +- xwords4/common/device.h | 4 +- xwords4/common/dragdrpp.c | 50 ++-- xwords4/common/dragdrpp.h | 7 +- xwords4/common/dutil.h | 76 ++--- xwords4/common/engine.c | 73 ++--- xwords4/common/engine.h | 2 +- xwords4/common/game.c | 34 +-- xwords4/common/game.h | 2 +- xwords4/common/model.c | 197 ++++++------- xwords4/common/model.h | 48 +-- xwords4/common/modelp.h | 3 +- xwords4/common/mscore.c | 65 +++-- xwords4/common/nwgamest.c | 34 ++- xwords4/common/nwgamest.h | 6 +- xwords4/common/scorebdp.c | 16 +- xwords4/common/scorebdp.h | 5 +- xwords4/common/server.c | 455 ++++++++++++++--------------- xwords4/common/server.h | 24 +- xwords4/common/smsproto.c | 91 +++--- xwords4/common/smsproto.h | 8 +- xwords4/common/tray.c | 8 +- xwords4/common/util.h | 238 +++++++-------- xwords4/linux/cursesboard.c | 83 +++--- xwords4/linux/cursesmain.c | 2 +- xwords4/linux/gtkboard.c | 109 +++---- xwords4/linux/gtkmain.c | 4 +- xwords4/linux/gtknewgame.c | 12 +- xwords4/linux/lindutil.c | 62 ++-- xwords4/linux/linuxmain.c | 25 +- xwords4/linux/linuxsms.c | 14 +- xwords4/linux/linuxutl.c | 4 +- 41 files changed, 1340 insertions(+), 1289 deletions(-) diff --git a/xwords4/android/jni/utilwrapper.c b/xwords4/android/jni/utilwrapper.c index c3aeb03a5..ba584c7ed 100644 --- a/xwords4/android/jni/utilwrapper.c +++ b/xwords4/android/jni/utilwrapper.c @@ -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 ); } diff --git a/xwords4/android/jni/utilwrapper.h b/xwords4/android/jni/utilwrapper.h index c81068bc7..dc192682e 100644 --- a/xwords4/android/jni/utilwrapper.h +++ b/xwords4/android/jni/utilwrapper.h @@ -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 ); diff --git a/xwords4/android/jni/xwjni.c b/xwords4/android/jni/xwjni.c index 1089da19e..07f86ef04 100644 --- a/xwords4/android/jni/xwjni.c +++ b/xwords4/android/jni/xwjni.c @@ -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) ); diff --git a/xwords4/common/board.c b/xwords4/common/board.c index 1b35188b0..adbcef66b 100644 --- a/xwords4/common/board.c +++ b/xwords4/common/board.c @@ -81,10 +81,10 @@ extern "C" { #endif /****************************** prototypes ******************************/ -static void figureBoardRect( BoardCtxt* board ); +static void figureBoardRect( BoardCtxt* board, XWEnv xwe ); static void forceRectToBoard( const BoardCtxt* board, XP_Rect* rect ); -static void boardCellChanged( void* board, XP_U16 turn, XP_U16 col, +static void boardCellChanged( XWEnv xwe, void* closure, XP_U16 turn, XP_U16 col, XP_U16 row, XP_Bool added ); static void boardTilesChanged( void* board, XP_U16 turn, XP_S16 index1, XP_S16 index2 ); @@ -92,9 +92,10 @@ static void dictChanged( void* p_board, XWEnv xwe, XP_S16 playerNum, const DictionaryCtxt* oldDict, const DictionaryCtxt* newDict ); -static void boardTurnChanged( void* board ); -static void boardGameOver( void* board, XP_S16 quitter ); -static void setArrow( BoardCtxt* board, XP_U16 row, XP_U16 col, XP_Bool* vp ); +static void boardTurnChanged( XWEnv xwe, void* closure ); +static void boardGameOver( XWEnv xwe, void* closure, XP_S16 quitter ); +static void setArrow( BoardCtxt* board, XWEnv xwe, XP_U16 row, + XP_U16 col, XP_Bool* vp ); static XP_Bool setArrowVisible( BoardCtxt* board, XP_Bool visible ); static void board_setTimerLoc( BoardCtxt* board, XP_U16 timerLeft, XP_U16 timerTop, @@ -106,36 +107,37 @@ static void invalTradeWindow( BoardCtxt* board, XP_S16 turn, XP_Bool redraw ); #endif static XP_Bool invalCellsWithTiles( BoardCtxt* board ); -static void setTimerIf( BoardCtxt* board ); +static void setTimerIf( BoardCtxt* board, XWEnv xwe ); static XP_Bool p_board_timerFired( void* closure, XWEnv xwe, XWTimerReason why ); -static XP_Bool replaceLastTile( BoardCtxt* board ); -static XP_Bool setTrayVisState( BoardCtxt* board, XW_TrayVisState newState ); -static XP_Bool advanceArrow( BoardCtxt* board ); +static XP_Bool replaceLastTile( BoardCtxt* board, XWEnv xwe ); +static XP_Bool setTrayVisState( BoardCtxt* board, XWEnv xwe, + XW_TrayVisState newState ); +static XP_Bool advanceArrow( BoardCtxt* board, XWEnv xwe ); static XP_Bool exitTradeMode( BoardCtxt* board ); static XP_Bool getArrow( const BoardCtxt* board, XP_U16* col, XP_U16* row ); static XP_Bool setArrowVisibleFor( BoardCtxt* board, XP_U16 player, XP_Bool visible ); -static XP_Bool board_moveArrow( BoardCtxt* board, XP_Key cursorKey ); +static XP_Bool board_moveArrow( BoardCtxt* board, XWEnv xwe, XP_Key cursorKey ); static XP_Bool board_setXOffset( BoardCtxt* board, XP_U16 offset ); -static XP_Bool preflight( BoardCtxt* board, XP_Bool reveal ); +static XP_Bool preflight( BoardCtxt* board, XWEnv xwe, XP_Bool reveal ); static XP_U16 MIN_TRADE_TILES( const BoardCtxt* board ); #ifdef KEY_SUPPORT -static XP_Bool moveKeyTileToBoard( BoardCtxt* board, XP_Key cursorKey, - XP_Bool* gotArrow ); +static XP_Bool moveKeyTileToBoard( BoardCtxt* board, XWEnv xwe, + XP_Key cursorKey, XP_Bool* gotArrow ); static XP_S16 keyToIndex( BoardCtxt* board, XP_Key key, Tile* blankFace ); #endif #ifdef KEYBOARD_NAV -static XP_Bool board_moveCursor( BoardCtxt* board, XP_Key cursorKey, +static XP_Bool board_moveCursor( BoardCtxt* board, XWEnv xwe, XP_Key cursorKey, XP_Bool preflightOnly, XP_Bool* up ); -static XP_Bool invalFocusOwner( BoardCtxt* board ); +static XP_Bool invalFocusOwner( BoardCtxt* board, XWEnv xwe ); #else -# define invalFocusOwner(board) 0 +# define invalFocusOwner(board, xwe) 0 #endif #ifdef XWFEATURE_SEARCHLIMIT static void clearCurHintRect( BoardCtxt* board ); @@ -148,8 +150,8 @@ static void clearCurHintRect( BoardCtxt* board ); * ****************************************************************************/ BoardCtxt* -board_make( MPFORMAL ModelCtxt* model, ServerCtxt* server, DrawCtx* draw, - XW_UtilCtxt* util ) +board_make( MPFORMAL XWEnv xwe, ModelCtxt* model, ServerCtxt* server, + DrawCtx* draw, XW_UtilCtxt* util ) { BoardCtxt* result = (BoardCtxt*)XP_MALLOC( mpool, sizeof( *result ) ); XP_ASSERT( !!server ); @@ -168,7 +170,7 @@ board_make( MPFORMAL ModelCtxt* model, ServerCtxt* server, DrawCtx* draw, result->draw = draw; result->util = util; - result->dutil = util_getDevUtilCtxt( util ); + result->dutil = util_getDevUtilCtxt( util, xwe ); result->gi = util->gameInfo; XP_ASSERT( !!result->gi ); @@ -194,16 +196,16 @@ board_make( MPFORMAL ModelCtxt* model, ServerCtxt* server, DrawCtx* draw, } /* board_make */ void -board_destroy( BoardCtxt* board, XP_Bool ownsUtil ) +board_destroy( BoardCtxt* board, XWEnv xwe, XP_Bool ownsUtil ) { if ( ownsUtil ) { - util_clearTimer( board->util, TIMER_TIMERTICK ); + util_clearTimer( board->util, xwe, TIMER_TIMERTICK ); } XP_FREE( board->mpool, board ); } /* board_destroy */ BoardCtxt* -board_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model, +board_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, ModelCtxt* model, ServerCtxt* server, DrawCtx* draw, XW_UtilCtxt* util, XP_U16 nPlayers ) { @@ -217,8 +219,8 @@ board_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model, nColsNBits = NUMCOLS_NBITS_4; #endif - board = board_make( MPPARM(mpool) model, server, draw, util ); - board_setCallbacks( board ); + board = board_make( MPPARM(mpool) xwe, model, server, draw, util ); + board_setCallbacks( board, xwe ); if ( version >= STREAM_VERS_4YOFFSET) { board->sd[SCROLL_H].offset = (XP_U16)stream_getBits( stream, 4 ); @@ -375,7 +377,7 @@ board_writeToStream( const BoardCtxt* board, XWStreamCtxt* stream ) } /* board_writeToStream */ void -board_reset( BoardCtxt* board ) +board_reset( BoardCtxt* board, XWEnv xwe ) { XP_U16 ii; XW_TrayVisState newState; @@ -395,30 +397,30 @@ board_reset( BoardCtxt* board ) board->star_row = (XP_U16)(model_numRows(board->model) / 2); newState = board->boardObscuresTray? TRAY_HIDDEN:TRAY_REVERSED; - setTrayVisState( board, newState ); + setTrayVisState( board, xwe, newState ); board_invalAll( board ); - setTimerIf( board ); + setTimerIf( board, xwe ); } /* board_reset */ void board_drawSnapshot( const BoardCtxt* curBoard, XWEnv xwe, DrawCtx* dctx, XP_U16 width, XP_U16 height ) { - BoardCtxt* newBoard = board_make( MPPARM(curBoard->mpool) + BoardCtxt* newBoard = board_make( MPPARM(curBoard->mpool) xwe, curBoard->model, curBoard->server, dctx, curBoard->util ); board_setDraw( newBoard, xwe, dctx ); /* so draw_dictChanged() will get called */ XP_U16 fontWidth = width / curBoard->gi->boardSize; - board_figureLayout( newBoard, curBoard->gi, 0, 0, width, height, + board_figureLayout( newBoard, xwe, curBoard->gi, 0, 0, width, height, 100, 0, 0, 0, fontWidth, width, XP_FALSE, NULL ); newBoard->showColors = curBoard->showColors; newBoard->showGrid = curBoard->showGrid; board_draw( newBoard, xwe ); - board_destroy( newBoard, XP_FALSE ); + board_destroy( newBoard, xwe, XP_FALSE ); } #ifdef COMMON_LAYOUT @@ -454,7 +456,7 @@ printDims( const BoardDims* dimsp ) // #define FORCE_SQUARE void -board_figureLayout( BoardCtxt* board, const CurGameInfo* gi, +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, @@ -607,15 +609,15 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi, if ( !!dimsp ) { XP_MEMCPY( dimsp, &ldims, sizeof(ldims) ); } else { - board_applyLayout( board, &ldims ); + board_applyLayout( board, xwe, &ldims ); } } /* board_figureLayout */ void -board_applyLayout( BoardCtxt* board, const BoardDims* dims ) +board_applyLayout( BoardCtxt* board, XWEnv xwe, const BoardDims* dims ) { XP_U16 margin = (dims->width - dims->boardWidth) / 2; - board_setPos( board, dims->left + margin, dims->top + dims->scoreHt, + board_setPos( board, xwe, dims->left + margin, dims->top + dims->scoreHt, dims->boardWidth, dims->boardHt, dims->maxCellSize, XP_FALSE ); @@ -625,13 +627,13 @@ board_applyLayout( BoardCtxt* board, const BoardDims* dims ) board_setTimerLoc( board, dims->scoreLeft + dims->scoreWidth, dims->top, dims->timerWidth, dims->scoreHt ); - board_setTrayLoc( board, dims->trayLeft, dims->trayTop, + board_setTrayLoc( board, xwe, dims->trayLeft, dims->trayTop, dims->trayWidth, dims->trayHt ); } #endif void -board_setCallbacks( BoardCtxt* board ) +board_setCallbacks( BoardCtxt* board, XWEnv xwe ) { model_setBoardListener( board->model, boardCellChanged, board ); model_setTrayListener( board->model, boardTilesChanged, board ); @@ -639,11 +641,11 @@ board_setCallbacks( BoardCtxt* board ) server_setTurnChangeListener( board->server, boardTurnChanged, board ); server_setGameOverListener( board->server, boardGameOver, board ); - setTimerIf( board ); + setTimerIf( board, xwe ); } void -board_setPos( BoardCtxt* board, XP_U16 left, XP_U16 top, +board_setPos( BoardCtxt* board, XWEnv xwe, XP_U16 left, XP_U16 top, XP_U16 width, XP_U16 height, XP_U16 maxCellSz, XP_Bool leftHanded ) { @@ -656,7 +658,7 @@ board_setPos( BoardCtxt* board, XP_U16 left, XP_U16 top, board->maxCellSz = maxCellSz; board->leftHanded = leftHanded; - figureBoardRect( board ); + figureBoardRect( board, xwe ); } /* board_setPos */ static void @@ -748,7 +750,7 @@ adjustXOffset( BoardCtxt* board, XP_S16 moveBy ) } /* adjustXOffset */ XP_Bool -adjustYOffset( BoardCtxt* board, XP_S16 moveBy ) +adjustYOffset( BoardCtxt* board, XWEnv xwe, XP_S16 moveBy ) { ScrollData* vsd = &board->sd[SCROLL_V]; XP_U16 nVisible = vsd->lastVisible - vsd->offset + 1; @@ -761,7 +763,7 @@ adjustYOffset( BoardCtxt* board, XP_S16 moveBy ) newOffset = nRows - nVisible; } - return board_setYOffset( board, newOffset ); + return board_setYOffset( board, xwe, newOffset ); } /* adjustYOffset */ static XP_Bool @@ -779,7 +781,7 @@ board_setXOffset( BoardCtxt* board, XP_U16 offset ) } XP_Bool -board_setYOffset( BoardCtxt* board, XP_U16 offset ) +board_setYOffset( BoardCtxt* board, XWEnv xwe, XP_U16 offset ) { ScrollData* vsd = &board->sd[SCROLL_V]; XP_U16 oldOffset = vsd->offset; @@ -793,8 +795,8 @@ board_setYOffset( BoardCtxt* board, XP_U16 offset ) if ( result ) { invalSelTradeWindow( board ); vsd->offset = offset; - figureBoardRect( board ); - util_yOffsetChange( board->util, vsd->maxOffset, + figureBoardRect( board, xwe ); + util_yOffsetChange( board->util, xwe, vsd->maxOffset, oldOffset, offset ); invalSelTradeWindow( board ); board->needsDrawing = XP_TRUE; @@ -835,7 +837,7 @@ void board_unpause( BoardCtxt* board, XWEnv xwe, const XP_UCHAR* msg ) { server_unpause( board->server, xwe, board->selPlayer, msg ); - setTimerIf( board ); + setTimerIf( board, xwe ); board_invalAll( board ); } @@ -855,9 +857,9 @@ board_canHideRack( const BoardCtxt* board ) } XP_Bool -board_canTrade( BoardCtxt* board ) +board_canTrade( BoardCtxt* board, XWEnv xwe ) { - XP_Bool result = preflight( board, XP_FALSE ) + XP_Bool result = preflight( board, xwe, XP_FALSE ) && !board->gi->inDuplicateMode && MIN_TRADE_TILES(board) <= server_countTilesInPool( board->server ); return result; @@ -913,7 +915,7 @@ canZoomIn( const BoardCtxt* board, XP_S16 newCount ) } XP_Bool -board_zoom( BoardCtxt* board, XP_S16 zoomBy, XP_Bool* canInOut ) +board_zoom( BoardCtxt* board, XWEnv xwe, XP_S16 zoomBy, XP_Bool* canInOut ) { XP_Bool changed; XP_S16 zoomCount = board->zoomCount; @@ -949,7 +951,7 @@ board_zoom( BoardCtxt* board, XP_S16 zoomBy, XP_Bool* canInOut ) vsd->offset = adjustOffset( vsd->offset, zoomBy ); board->zoomCount = zoomCount; - figureBoardRect( board ); + figureBoardRect( board, xwe ); board_invalAll( board ); } @@ -1052,7 +1054,7 @@ saveBadWords( const WNParams* wnp, void* closure ) } /* saveBadWords */ static void -boardNotifyTrade( BoardCtxt* board, const TrayTileSet* tiles ) +boardNotifyTrade( BoardCtxt* board, XWEnv xwe, const TrayTileSet* tiles ) { const XP_UCHAR* tfaces[MAX_TRAY_TILES]; XP_U16 ii; @@ -1062,7 +1064,7 @@ boardNotifyTrade( BoardCtxt* board, const TrayTileSet* tiles ) tfaces[ii] = dict_getTileString( dict, tiles->tiles[ii] ); } - util_notifyTrade( board->util, tfaces, tiles->nTiles ); + util_notifyTrade( board->util, xwe, tfaces, tiles->nTiles ); } XP_Bool @@ -1078,11 +1080,11 @@ board_commitTurn( BoardCtxt* board, XWEnv xwe, XP_Bool phoniesConfirmed, if ( board->gameOver || turn < 0 ) { /* do nothing */ } else if ( !server_isPlayersTurn( board->server, selPlayer ) ) { - util_userError( board->util, ERR_NOT_YOUR_TURN ); + util_userError( board->util, xwe, ERR_NOT_YOUR_TURN ); } else if ( 0 == model_getNumTilesTotal( model, selPlayer ) ) { /* game's over but still undoable so turn hasn't changed; do nothing */ - } else if ( phoniesConfirmed || turnConfirmed || checkRevealTray( board ) ) { + } else if ( phoniesConfirmed || turnConfirmed || checkRevealTray( board, xwe ) ) { PerTurnInfo* pti = board->pti + selPlayer; if ( pti->tradeInProgress ) { TileBit traySelBits = pti->traySelBits; @@ -1094,14 +1096,14 @@ board_commitTurn( BoardCtxt* board, XWEnv xwe, XP_Bool phoniesConfirmed, after */ if ( NO_TILES == traySelBits ) { - util_userError( board->util, ERR_NO_EMPTY_TRADE ); + util_userError( board->util, xwe, ERR_NO_EMPTY_TRADE ); } else if ( count > server_countTilesInPool(board->server) ) { - util_userError( board->util, ERR_TOO_MANY_TRADE ); + util_userError( board->util, xwe, ERR_TOO_MANY_TRADE ); } else { TrayTileSet selTiles; getSelTiles( board, traySelBits, &selTiles ); if ( turnConfirmed ) { - if ( !server_askPickTiles( board->server, selPlayer, newTiles, + if ( !server_askPickTiles( board->server, xwe, selPlayer, newTiles, selTiles.nTiles ) ) { /* server_commitTrade() changes selPlayer, so board_endTrade must be called first() */ @@ -1111,7 +1113,7 @@ board_commitTurn( BoardCtxt* board, XWEnv xwe, XP_Bool phoniesConfirmed, newTiles ); } } else { - boardNotifyTrade( board, &selTiles ); + boardNotifyTrade( board, xwe, &selTiles ); } } } else { @@ -1126,7 +1128,7 @@ board_commitTurn( BoardCtxt* board, XWEnv xwe, XP_Bool phoniesConfirmed, XP_U16 stringCode = board->gi->inDuplicateMode ? STR_SUBMIT_CONFIRM : STR_COMMIT_CONFIRM; - const XP_UCHAR* str = dutil_getUserString( board->dutil, stringCode ); + const XP_UCHAR* str = dutil_getUserString( board->dutil, xwe, stringCode ); stream_catString( stream, str ); XP_Bool warn = board->util->gameInfo->phoniesAction == PHONIES_WARN; @@ -1142,20 +1144,20 @@ board_commitTurn( BoardCtxt* board, XWEnv xwe, XP_Bool phoniesConfirmed, if ( 0 < bwl.bwi.nWords && !phoniesConfirmed ) { bwl.bwi.dictName = dict_getShortName( model_getPlayerDict( model, selPlayer ) ); - util_notifyIllegalWords( board->util, &bwl.bwi, selPlayer, XP_FALSE ); + util_notifyIllegalWords( board->util, xwe, &bwl.bwi, selPlayer, XP_FALSE ); } else if ( legal ) { /* Hide the tray so no peeking. Leave it hidden even if user cancels as otherwise another player could get around passwords and peek at tiles. */ if ( !turnConfirmed && gi_countLocalPlayers( board->gi, XP_TRUE ) > 1 ) { - result = board_hideTray( board ); + result = board_hideTray( board, xwe ); } if ( board->skipCommitConfirm || turnConfirmed ) { XP_U16 nToPick = MAX_TRAY_TILES - model_getNumTilesInTray( model, selPlayer ); - if ( !server_askPickTiles( board->server, selPlayer, newTiles, + if ( !server_askPickTiles( board->server, xwe, selPlayer, newTiles, nToPick ) ) { result = server_commitMove( board->server, xwe, selPlayer, newTiles ) @@ -1169,7 +1171,7 @@ board_commitTurn( BoardCtxt* board, XWEnv xwe, XP_Bool phoniesConfirmed, pti->traySelBits = 0x00; } } else { - util_notifyMove( board->util, stream ); + util_notifyMove( board->util, xwe, stream ); } } @@ -1191,7 +1193,7 @@ board_commitTurn( BoardCtxt* board, XWEnv xwe, XP_Bool phoniesConfirmed, * singletons that may have to be hidden or shown. */ static void -selectPlayerImpl( BoardCtxt* board, XP_U16 newPlayer, XP_Bool reveal, +selectPlayerImpl( BoardCtxt* board, XWEnv xwe, XP_U16 newPlayer, XP_Bool reveal, XP_Bool canPeek ) { XP_Bool isLocal; @@ -1200,14 +1202,14 @@ selectPlayerImpl( BoardCtxt* board, XP_U16 newPlayer, XP_Bool reveal, /* game not started yet; do nothing */ } else if ( board->selPlayer == newPlayer ) { if ( reveal ) { - checkRevealTray( board ); + checkRevealTray( board, xwe ); } } else if ( canPeek || ((newPlayer == curTurn) && isLocal)) { PerTurnInfo* newInfo = &board->pti[newPlayer]; XP_U16 oldPlayer = board->selPlayer; - model_foreachPendingCell( board->model, newPlayer, + model_foreachPendingCell( board->model, xwe, newPlayer, boardCellChanged, board ); - model_foreachPendingCell( board->model, oldPlayer, + model_foreachPendingCell( board->model, xwe, oldPlayer, boardCellChanged, board ); /* if there are pending cells on one view and not the other, then the @@ -1215,7 +1217,7 @@ selectPlayerImpl( BoardCtxt* board, XP_U16 newPlayer, XP_Bool reveal, and so needs to be invalidated so it'll get redrawn.*/ if ( (0 == model_getCurrentMoveCount( board->model, newPlayer )) != (0 == model_getCurrentMoveCount( board->model, oldPlayer )) ) { - model_foreachPrevCell( board->model, boardCellChanged, board ); + model_foreachPrevCell( board->model, xwe, boardCellChanged, board ); } /* Just in case somebody started a trade when it wasn't his turn and @@ -1245,16 +1247,16 @@ selectPlayerImpl( BoardCtxt* board, XP_U16 newPlayer, XP_Bool reveal, board_invalTrayTiles( board, ALLTILES ); board->dividerInvalid = XP_TRUE; - setTrayVisState( board, TRAY_REVERSED ); + setTrayVisState( board, xwe, TRAY_REVERSED ); } board->scoreBoardInvalid = XP_TRUE; /* if only one player, number of tiles remaining may have changed*/ } /* selectPlayerImpl */ void -board_selectPlayer( BoardCtxt* board, XP_U16 newPlayer, XP_Bool canSwitch ) +board_selectPlayer( BoardCtxt* board, XWEnv xwe, XP_U16 newPlayer, XP_Bool canSwitch ) { - selectPlayerImpl( board, newPlayer, XP_TRUE, canSwitch ); + selectPlayerImpl( board, xwe, newPlayer, XP_TRUE, canSwitch ); } /* board_selectPlayer */ void @@ -1358,9 +1360,9 @@ timerFiredForPen( BoardCtxt* board, XWEnv xwe ) listWords = model_listWordsThrough( board->model, xwe, modelCol, modelRow, board->selPlayer, stream ); if ( listWords ) { - util_cellSquareHeld( board->util, stream ); + util_cellSquareHeld( board->util, xwe, stream ); if ( dragDropInProgress( board ) ) { - dragDropEnd( board, board->penDownX, board->penDownY, NULL ); + dragDropEnd( board, xwe, board->penDownX, board->penDownY, NULL ); } } stream_destroy( stream, xwe ); @@ -1368,20 +1370,20 @@ timerFiredForPen( BoardCtxt* board, XWEnv xwe ) #endif if ( !listWords ) { XWBonusType bonus; - bonus = model_getSquareBonus( board->model, col, row ); + bonus = model_getSquareBonus( board->model, xwe, col, row ); if ( bonus != BONUS_NONE ) { #ifdef XWFEATURE_MINIWIN text = draw_getMiniWText( board->draw, (XWMiniTextType)bonus ); #else - util_bonusSquareHeld( board->util, bonus ); + util_bonusSquareHeld( board->util, xwe, bonus ); #endif } } board->penTimerFired = XP_TRUE; } } else if ( board->penDownObject == OBJ_SCORE ) { - penTimerFiredScore( board ); + penTimerFiredScore( board, xwe ); board->penTimerFired = XP_TRUE; } @@ -1403,14 +1405,14 @@ timerFiredForPen( BoardCtxt* board, XWEnv xwe ) } /* timerFiredForPen */ static void -setTimerIf( BoardCtxt* board ) +setTimerIf( BoardCtxt* board, XWEnv xwe ) { XP_Bool timerWanted = board->gi->timerEnabled && !board->gameOver && !server_canUnpause( board->server ); if ( timerWanted && !board->timerPending ) { - util_setTimer( board->util, TIMER_TIMERTICK, 0, + util_setTimer( board->util, xwe, TIMER_TIMERTICK, 0, p_board_timerFired, board ); board->timerPending = XP_TRUE; } @@ -1435,7 +1437,7 @@ timerFiredForTimer( BoardCtxt* board, XWEnv xwe ) drawTimer( board, xwe ); } } - setTimerIf( board ); + setTimerIf( board, xwe ); } /* timerFiredForTimer */ static XP_Bool @@ -1466,11 +1468,11 @@ p_tray_timerFired( void* closure, XWEnv xwe, XWTimerReason why ) #endif void -board_pushTimerSave( BoardCtxt* board ) +board_pushTimerSave( BoardCtxt* board, XWEnv xwe ) { if ( board->gi->timerEnabled ) { if ( board->timerSaveCount++ == 0 ) { - board->timerStoppedTime = dutil_getCurSeconds( board->dutil ); + board->timerStoppedTime = dutil_getCurSeconds( board->dutil, xwe ); #ifdef DEBUG board->timerStoppedTurn = server_getCurrentTurn( board->server, NULL ); @@ -1480,7 +1482,7 @@ board_pushTimerSave( BoardCtxt* board ) } /* board_pushTimerSave */ void -board_popTimerSave( BoardCtxt* board ) +board_popTimerSave( BoardCtxt* board, XWEnv xwe ) { if ( board->gi->timerEnabled ) { @@ -1493,7 +1495,7 @@ board_popTimerSave( BoardCtxt* board ) XP_ASSERT( board->timerStoppedTurn == turn ); if ( --board->timerSaveCount == 0 && turn >= 0 ) { - XP_U32 curTime = dutil_getCurSeconds( board->dutil ); + XP_U32 curTime = dutil_getCurSeconds( board->dutil, xwe ); XP_U32 elapsed; XP_ASSERT( board->timerStoppedTime != 0 ); @@ -1510,13 +1512,13 @@ board_popTimerSave( BoardCtxt* board ) * server to format. */ void -board_formatRemainingTiles( BoardCtxt* board, XWStreamCtxt* stream ) +board_formatRemainingTiles( BoardCtxt* board, XWEnv xwe, XWStreamCtxt* stream ) { XP_S16 curPlayer = board->selPlayer; if ( board->trayVisState != TRAY_REVEALED ) { curPlayer = -1; } - server_formatRemainingTiles( board->server, stream, curPlayer ); + server_formatRemainingTiles( board->server, xwe, stream, curPlayer ); } /* board_formatRemainingTiles */ static void @@ -1650,7 +1652,7 @@ figureOffset(const BoardCtxt* board, SDIndex indx, XP_U16 col ) } XP_Bool -scrollIntoView( BoardCtxt* board, XP_U16 col, XP_U16 row ) +scrollIntoView( BoardCtxt* board, XWEnv xwe, XP_U16 col, XP_U16 row ) { XP_Bool moved; XP_S16 newOffset; @@ -1659,7 +1661,7 @@ scrollIntoView( BoardCtxt* board, XP_U16 col, XP_U16 row ) moved = adjustXOffset( board, newOffset ); newOffset = figureOffset( board, SCROLL_V, row ); - moved = adjustYOffset( board, newOffset ) || moved; + moved = adjustYOffset( board, xwe, newOffset ) || moved; return moved; } /* scrollIntoView */ @@ -1688,7 +1690,7 @@ onBorderCanScroll( const BoardCtxt* board, SDIndex indx, } void -board_setTrayLoc( BoardCtxt* board, XP_U16 trayLeft, XP_U16 trayTop, +board_setTrayLoc( BoardCtxt* board, XWEnv xwe, XP_U16 trayLeft, XP_U16 trayTop, XP_U16 trayWidth, XP_U16 trayHeight ) { /* XP_LOGF( "%s(%d,%d,%d,%d)", __func__, trayLeft, trayTop, */ @@ -1711,7 +1713,7 @@ board_setTrayLoc( BoardCtxt* board, XP_U16 trayLeft, XP_U16 trayTop, board->dividerWidth = dividerWidth; - figureBoardRect( board ); + figureBoardRect( board, xwe ); } /* board_setTrayLoc */ void @@ -1857,7 +1859,7 @@ board_getActiveRect( const BoardCtxt* board, XP_Rect* rect, * be drawn with tiles face-up. */ XP_Bool -board_hideTray( BoardCtxt* board ) +board_hideTray( BoardCtxt* board, XWEnv xwe ) { XW_TrayVisState soughtState; if ( board->boardObscuresTray ) { @@ -1865,7 +1867,7 @@ board_hideTray( BoardCtxt* board ) } else { soughtState = TRAY_REVERSED; } - return setTrayVisState( board, soughtState ); + return setTrayVisState( board, xwe, soughtState ); } /* board_hideTray */ static XP_S16 @@ -1901,9 +1903,9 @@ chooseBestSelPlayer( BoardCtxt* board ) * code should flag the error. */ XP_Bool -board_showTray( BoardCtxt* board ) +board_showTray( BoardCtxt* board, XWEnv xwe ) { - return checkRevealTray( board ); + return checkRevealTray( board, xwe ); } /* board_showTray */ static XP_Bool @@ -1926,7 +1928,7 @@ board_getTrayVisState( const BoardCtxt* board ) } /* board_getTrayVisible */ static XP_Bool -setTrayVisState( BoardCtxt* board, XW_TrayVisState newState ) +setTrayVisState( BoardCtxt* board, XWEnv xwe, XW_TrayVisState newState ) { XP_Bool changed; @@ -1943,10 +1945,10 @@ setTrayVisState( BoardCtxt* board, XW_TrayVisState newState ) /* redraw cells that are pending; whether tile is visible may change */ - model_foreachPendingCell( board->model, selPlayer, + model_foreachPendingCell( board->model, xwe, selPlayer, boardCellChanged, board ); /* ditto -- if there's a pending move */ - model_foreachPrevCell( board->model, boardCellChanged, board ); + model_foreachPrevCell( board->model, xwe, boardCellChanged, board ); board_invalTrayTiles( board, ALLTILES ); board->dividerInvalid = XP_TRUE; @@ -1954,18 +1956,18 @@ setTrayVisState( BoardCtxt* board, XW_TrayVisState newState ) board->trayVisState = newState; invalSelTradeWindow( board ); - (void)invalFocusOwner( board ); /* must be done before and after rect + (void)invalFocusOwner( board, xwe ); /* must be done before and after rect recalculated */ - figureBoardRect( board ); /* comes before setYOffset since that + figureBoardRect( board, xwe ); /* comes before setYOffset since that uses rects to calc scroll */ - (void)invalFocusOwner( board ); + (void)invalFocusOwner( board, xwe ); if ( board->boardObscuresTray ) { if ( nowHidden && !trayOnTop(board) ) { board->preHideYOffset = board_getYOffset( board ); - board_setYOffset( board, 0 ); + board_setYOffset( board, xwe, 0 ); } else { - board_setYOffset( board, board->preHideYOffset ); + board_setYOffset( board, xwe, board->preHideYOffset ); } } @@ -1983,7 +1985,7 @@ setTrayVisState( BoardCtxt* board, XW_TrayVisState newState ) #endif nVisible = vsd->lastVisible - vsd->offset + 1; - util_trayHiddenChange( board->util, board->trayVisState, nVisible ); + util_trayHiddenChange( board->util, xwe, board->trayVisState, nVisible ); } return changed; } /* setTrayVisState */ @@ -2081,10 +2083,10 @@ board_toggle_showValues( BoardCtxt* board ) } /* board_toggle_showValues */ XP_Bool -board_replaceNTiles( BoardCtxt* board, XP_U16 nTiles ) +board_replaceNTiles( BoardCtxt* board, XWEnv xwe, XP_U16 nTiles ) { XP_Bool result = XP_FALSE; - while ( 0 < nTiles-- && replaceLastTile( board ) ) { + while ( 0 < nTiles-- && replaceLastTile( board, xwe ) ) { result = XP_TRUE; } @@ -2092,25 +2094,25 @@ board_replaceNTiles( BoardCtxt* board, XP_U16 nTiles ) } XP_Bool -board_replaceTiles( BoardCtxt* board ) +board_replaceTiles( BoardCtxt* board, XWEnv xwe ) { - return board_replaceNTiles( board, MAX_TRAY_TILES ); + return board_replaceNTiles( board, xwe, MAX_TRAY_TILES ); } /* board_replaceTiles */ XP_Bool -board_redoReplacedTiles( BoardCtxt* board ) +board_redoReplacedTiles( BoardCtxt* board, XWEnv xwe ) { - return model_redoPendingTiles( board->model, board->selPlayer ); + return model_redoPendingTiles( board->model, xwe, board->selPlayer ); } /* There are a few conditions that must be true for any of several actions to be allowed. Check them here. */ static XP_Bool -preflight( BoardCtxt* board, XP_Bool reveal ) +preflight( BoardCtxt* board, XWEnv xwe, XP_Bool reveal ) { return !board->gameOver && server_getCurrentTurn( board->server, NULL) >= 0 - && ( !reveal || checkRevealTray( board ) ) + && ( !reveal || checkRevealTray( board, xwe ) ) && !TRADE_IN_PROGRESS(board); } /* preflight */ @@ -2140,7 +2142,7 @@ board_requestHint( BoardCtxt* board, XWEnv xwe, *workRemainsP = XP_FALSE; /* in case we exit without calling engine */ if ( board->gi->hintsNotAllowed ) { - util_userError( board->util, ERR_CANT_HINT_WHILE_DISABLED ); + util_userError( board->util, xwe, ERR_CANT_HINT_WHILE_DISABLED ); } else { MoveInfo newMove; XP_S16 nTiles; @@ -2155,13 +2157,13 @@ board_requestHint( BoardCtxt* board, XWEnv xwe, ModelCtxt* model = board->model; XP_U16 dividerLoc = model_getDividerLoc( model, selPlayer ); - if ( !!engine && preflight( board, XP_TRUE ) ) { + if ( !!engine && preflight( board, xwe, XP_TRUE ) ) { /* undo any current move. otherwise we won't pass the full tray to the engine. Would it be better, though, to pass the whole tray regardless where its contents are? */ if ( model_getCurrentMoveCount( model, selPlayer ) > 0 ) { - model_resetCurrentTurn( model, selPlayer ); + model_resetCurrentTurn( model, xwe, selPlayer ); /* Draw's a no-op on Wince with a null hdc, but it'll draw again. Should probably define OS_INITS_DRAW on Wince...*/ #ifdef OS_INITS_DRAW @@ -2189,11 +2191,11 @@ board_requestHint( BoardCtxt* board, XWEnv xwe, wasVisible = setArrowVisible( board, XP_FALSE ); - (void)board_replaceTiles( board ); + (void)board_replaceTiles( board, xwe ); tiles = tileSet->tiles + dividerLoc; - board_pushTimerSave( board ); + board_pushTimerSave( board, xwe ); #ifdef XWFEATURE_SEARCHLIMIT XP_ASSERT( board->gi->allowHintRect || !pti->hasHintRect ); @@ -2215,8 +2217,8 @@ board_requestHint( BoardCtxt* board, XWEnv xwe, # endif #endif searchComplete = - engine_findMove( engine, model, selPlayer, XP_FALSE, XP_FALSE, - tiles, nTiles, usePrev, + engine_findMove( engine, xwe, model, selPlayer, + XP_FALSE, XP_FALSE, tiles, nTiles, usePrev, #ifdef XWFEATURE_BONUSALL allTilesBonus, #endif @@ -2225,12 +2227,12 @@ board_requestHint( BoardCtxt* board, XWEnv xwe, #endif 0, /* 0: not a robot */ &canMove, &newMove, NULL ); - board_popTimerSave( board ); + board_popTimerSave( board, xwe ); if ( searchComplete && canMove ) { // assertTilesInTiles( board, &newMove, tiles, nTiles ); juggleMoveIfDebug( &newMove ); - model_makeTurnFromMoveInfo( model, selPlayer, &newMove ); + model_makeTurnFromMoveInfo( model, xwe, selPlayer, &newMove ); } else { result = XP_FALSE; XP_STATUSF( "unable to complete hint request\n" ); @@ -2250,7 +2252,7 @@ board_requestHint( BoardCtxt* board, XWEnv xwe, } if ( !canMove ) { - util_userError( board->util, ERR_NO_HINT_FOUND ); + util_userError( board->util, xwe, ERR_NO_HINT_FOUND ); } } return result || redraw; @@ -2322,7 +2324,7 @@ figureScales( BoardCtxt* board, XP_U16* scaleHP, XP_U16* scaleVP ) } /* figureScales */ static void -figureBoardRect( BoardCtxt* board ) +figureBoardRect( BoardCtxt* board, XWEnv xwe ) { if ( board->boardBounds.width > 0 && board->trayBounds.width > 0 ) { XP_Rect boardBounds = board->boardBounds; @@ -2378,7 +2380,7 @@ figureBoardRect( BoardCtxt* board ) board->boardObscuresTray = board->trayBounds.top < wantHeight && board->trayBounds.left < (boardBounds.left + boardBounds.width); } - util_yOffsetChange( board->util, nRows - nVisible, oldYOffset, + util_yOffsetChange( board->util, xwe, nRows - nVisible, oldYOffset, vsd->offset ); vsd->lastVisible = nVisible + vsd->offset - 1; @@ -2533,15 +2535,15 @@ pointOnSomething( const BoardCtxt* board, XP_U16 xx, XP_U16 yy, * what to call it first. */ XP_Bool -moveTileToArrowLoc( BoardCtxt* board, XP_U8 index ) +moveTileToArrowLoc( BoardCtxt* board, XWEnv xwe, XP_U8 index ) { XP_Bool result; BoardArrow* arrow = &board->selInfo->boardArrow; if ( arrow->visible ) { - result = moveTileToBoard( board, arrow->col, arrow->row, + result = moveTileToBoard( board, xwe, arrow->col, arrow->row, (XP_U16)index, EMPTY_TILE ); if ( result ) { - XP_Bool moved = advanceArrow( board ); + XP_Bool moved = advanceArrow( board, xwe ); if ( !moved ) { /* If the arrow didn't move, we can't leave it in place or it'll get drawn over the new tile. */ @@ -2573,17 +2575,17 @@ makeMiniWindowForText( BoardCtxt* board, const XP_UCHAR* text, #endif XP_Bool -board_beginTrade( BoardCtxt* board ) +board_beginTrade( BoardCtxt* board, XWEnv xwe ) { XP_Bool result; - result = preflight( board, XP_TRUE ); + result = preflight( board, xwe, XP_TRUE ); if ( result ) { XP_S16 tilesLeft = server_countTilesInPool(board->server); if ( tilesLeft < MIN_TRADE_TILES( board ) ) { - util_userError( board->util, ERR_TOO_FEW_TILES_LEFT_TO_TRADE ); + util_userError( board->util, xwe, ERR_TOO_FEW_TILES_LEFT_TO_TRADE ); } else { - model_resetCurrentTurn( board->model, board->selPlayer ); + model_resetCurrentTurn( board->model, xwe, board->selPlayer ); XP_ASSERT( 0 == model_getCurrentMoveCount( board->model, board->selPlayer ) ); #ifdef XWFEATURE_MINIWIN @@ -2679,18 +2681,18 @@ clearCurHintRect( BoardCtxt* board ) #endif /* XWFEATURE_SEARCHLIMIT */ static XP_Bool -handlePenDownOnBoard( BoardCtxt* board, XP_U16 xx, XP_U16 yy ) +handlePenDownOnBoard( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy ) { XP_Bool result = XP_FALSE; if ( TRADE_IN_PROGRESS(board) && ptOnTradeWindow( board, xx, yy ) ) { /* do nothing */ } else { - util_setTimer( board->util, TIMER_PENDOWN, 0, + util_setTimer( board->util, xwe, TIMER_PENDOWN, 0, p_board_timerFired, board ); if ( !board->selInfo->tradeInProgress ) { - result = dragDropStart( board, OBJ_BOARD, xx, yy ); + result = dragDropStart( board, xwe, OBJ_BOARD, xx, yy ); } } @@ -2703,7 +2705,7 @@ handlePenDownOnBoard( BoardCtxt* board, XP_U16 xx, XP_U16 yy ) * the password compare. */ static XP_Bool -askRevealTray( BoardCtxt* board ) +askRevealTray( BoardCtxt* board, XWEnv xwe ) { XP_Bool revealed = XP_FALSE; XP_Bool reversed = board->trayVisState == TRAY_REVERSED; @@ -2717,11 +2719,11 @@ askRevealTray( BoardCtxt* board ) revealed = XP_FALSE; #ifndef XWFEATURE_STANDALONE_ONLY } else if ( !lp->isLocal ) { - util_userError( board->util, ERR_NO_PEEK_REMOTE_TILES ); + util_userError( board->util, xwe, ERR_NO_PEEK_REMOTE_TILES ); #endif } else if ( LP_IS_ROBOT(lp) ) { if ( reversed ) { - util_userError( board->util, ERR_NO_PEEK_ROBOT_TILES ); + util_userError( board->util, xwe, ERR_NO_PEEK_ROBOT_TILES ); } else { justReverse = XP_TRUE; } @@ -2729,65 +2731,67 @@ askRevealTray( BoardCtxt* board ) revealed = !player_hasPasswd( lp ); if ( !revealed ) { - util_informNeedPassword( board->util, selPlayer, lp->name ); + util_informNeedPassword( board->util, xwe, selPlayer, lp->name ); } } if ( revealed ) { - setTrayVisState( board, TRAY_REVEALED ); + setTrayVisState( board, xwe, TRAY_REVEALED ); } else if ( justReverse ) { - setTrayVisState( board, TRAY_REVERSED ); + setTrayVisState( board, xwe, TRAY_REVERSED ); } return justReverse || revealed; } /* askRevealTray */ XP_Bool -board_passwordProvided( BoardCtxt* board, XP_U16 player, const XP_UCHAR* passwd ) +board_passwordProvided( BoardCtxt* board, XWEnv xwe, XP_U16 player, + const XP_UCHAR* passwd ) { LocalPlayer* lp = &board->gi->players[player]; XP_Bool draw = player_passwordMatches( lp, passwd ); if ( draw ) { - setTrayVisState( board, TRAY_REVEALED ); + setTrayVisState( board, xwe, TRAY_REVEALED ); } else { - util_informNeedPassword( board->util, player, lp->name ); + util_informNeedPassword( board->util, xwe, player, lp->name ); } return draw; } XP_Bool -checkRevealTray( BoardCtxt* board ) +checkRevealTray( BoardCtxt* board, XWEnv xwe ) { XP_Bool result = board->trayVisState == TRAY_REVEALED; if ( !result ) { - result = askRevealTray( board ); + result = askRevealTray( board, xwe ); } return result; } /* checkRevealTray */ static XP_Bool -handleLikeDown( BoardCtxt* board, BoardObjectType onWhich, XP_U16 x, XP_U16 y ) +handleLikeDown( BoardCtxt* board, XWEnv xwe, BoardObjectType onWhich, + XP_U16 xx, XP_U16 yy ) { XP_Bool result = XP_FALSE; switch ( onWhich ) { case OBJ_BOARD: - result = handlePenDownOnBoard( board, x, y ) || result; + result = handlePenDownOnBoard( board, xwe, xx, yy ) || result; break; case OBJ_TRAY: if ( (board->trayVisState == TRAY_REVEALED) && !board->selInfo->tradeInProgress ) { #ifdef XWFEATURE_RAISETILE - util_setTimer( board->util, TIMER_PENDOWN, 0, + util_setTimer( board->util, xwe, TIMER_PENDOWN, 0, p_tray_timerFired, board ); #endif - result = dragDropStart( board, OBJ_TRAY, x, y ) || result; + result = dragDropStart( board, xwe, OBJ_TRAY, xx, yy ) || result; } break; case OBJ_SCORE: - if ( figureScoreRectTapped( board, x, y ) > CURSOR_LOC_REM ) { - util_setTimer( board->util, TIMER_PENDOWN, 0, + if ( figureScoreRectTapped( board, xx, yy ) > CURSOR_LOC_REM ) { + util_setTimer( board->util, xwe, TIMER_PENDOWN, 0, p_board_timerFired, board ); } break; @@ -2795,8 +2799,8 @@ handleLikeDown( BoardCtxt* board, BoardObjectType onWhich, XP_U16 x, XP_U16 y ) break; } - board->penDownX = x; - board->penDownY = y; + board->penDownX = xx; + board->penDownY = yy; board->penDownObject = onWhich; return result; @@ -2804,7 +2808,8 @@ handleLikeDown( BoardCtxt* board, BoardObjectType onWhich, XP_U16 x, XP_U16 y ) #ifdef POINTER_SUPPORT XP_Bool -board_handlePenDown( BoardCtxt* board, XP_U16 x, XP_U16 y, XP_Bool* handled ) +board_handlePenDown( BoardCtxt* board, XWEnv xwe, XP_U16 xx, + XP_U16 yy, XP_Bool* handled ) { XP_Bool result = XP_FALSE; XP_Bool penDidSomething; @@ -2812,7 +2817,7 @@ board_handlePenDown( BoardCtxt* board, XP_U16 x, XP_U16 y, XP_Bool* handled ) board->srcIsPen = XP_TRUE; - penDidSomething = pointOnSomething( board, x, y, &onWhich ); + penDidSomething = pointOnSomething( board, xx, yy, &onWhich ); if ( !penDidSomething ) { board->penDownObject = OBJ_NONE; @@ -2820,14 +2825,14 @@ board_handlePenDown( BoardCtxt* board, XP_U16 x, XP_U16 y, XP_Bool* handled ) #ifdef KEYBOARD_NAV /* clear focus as soon as pen touches board */ - result = invalFocusOwner( board ); + result = invalFocusOwner( board, xwe ); board->hideFocus = XP_TRUE; if ( board->boardObscuresTray ) { - figureBoardRect( board ); + figureBoardRect( board, xwe ); } #endif - result = handleLikeDown( board, onWhich, x, y ) || result; + result = handleLikeDown( board, xwe, onWhich, xx, yy ) || result; } *handled = penDidSomething; @@ -2836,10 +2841,10 @@ board_handlePenDown( BoardCtxt* board, XP_U16 x, XP_U16 y, XP_Bool* handled ) #endif XP_Bool -board_handlePenMove( BoardCtxt* board, XP_U16 xx, XP_U16 yy ) +board_handlePenMove( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy ) { XP_Bool result = dragDropInProgress(board) - && dragDropContinue( board, xx, yy ); + && dragDropContinue( board, xwe, xx, yy ); return result; } /* board_handlePenMove */ @@ -2933,7 +2938,7 @@ tryMoveArrow( BoardCtxt* board, XP_U16 col, XP_U16 row ) } /* tryMoveArrow */ static XP_Bool -tryChangeBlank( const BoardCtxt* board, XP_U16 col, XP_U16 row ) +tryChangeBlank( const BoardCtxt* board, XWEnv xwe, XP_U16 col, XP_U16 row ) { XP_Bool handled = XP_FALSE; XP_Bool isBlank, isPending; @@ -2941,7 +2946,8 @@ tryChangeBlank( const BoardCtxt* board, XP_U16 col, XP_U16 row ) &isBlank, &isPending, NULL ); handled = isBlank && isPending; if ( handled ) { - (void)model_askBlankTile( board->model, board->selPlayer, col, row ); + (void)model_askBlankTile( board->model, xwe, board->selPlayer, + col, row ); } return handled; @@ -2966,7 +2972,7 @@ holdsPendingTile( BoardCtxt* board, XP_U16 pencol, XP_U16 penrow ) * too easy to accidentally tap and there are better ways. */ static XP_Bool -tryReplaceTile( BoardCtxt* board, XP_U16 pencol, XP_U16 penrow ) +tryReplaceTile( BoardCtxt* board, XWEnv xwe, XP_U16 pencol, XP_U16 penrow ) { XP_Bool result = XP_FALSE; @@ -2974,9 +2980,9 @@ tryReplaceTile( BoardCtxt* board, XP_U16 pencol, XP_U16 penrow ) XP_U16 modcol, modrow; flipIf( board, pencol, penrow, &modcol, &modrow ); - model_moveBoardToTray( board->model, board->selPlayer, + model_moveBoardToTray( board->model, xwe, board->selPlayer, modcol, modrow, -1 ); - setArrow( board, pencol, penrow, NULL ); + setArrow( board, xwe, pencol, penrow, NULL ); result = XP_TRUE; } @@ -2984,15 +2990,15 @@ tryReplaceTile( BoardCtxt* board, XP_U16 pencol, XP_U16 penrow ) } /* tryReplaceTile */ static XP_Bool -handleActionInCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool isPen ) +handleActionInCell( BoardCtxt* board, XWEnv xwe, XP_U16 col, XP_U16 row, XP_Bool isPen ) { return XP_FALSE #ifndef DISABLE_TILE_SEL || moveSelTileToBoardXY( board, col, row ) #endif || tryMoveArrow( board, col, row ) - || tryChangeBlank( board, col, row ) - || (!isPen && tryReplaceTile( board, col, row )) + || tryChangeBlank( board, xwe, col, row ) + || (!isPen && tryReplaceTile( board, xwe, col, row )) ; } /* handleActionInCell */ #endif /* POINTER_SUPPORT || KEYBOARD_NAV */ @@ -3037,7 +3043,7 @@ handlePenUpInternal( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy, XP_Bool dragged = XP_FALSE; if ( dragDropInProgress(board) ) { - draw = dragDropEnd( board, xx, yy, &dragged ); + draw = dragDropEnd( board, xwe, xx, yy, &dragged ); } if ( dragged ) { /* do nothing further */ @@ -3057,11 +3063,12 @@ handlePenUpInternal( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy, switch( onWhich ) { case OBJ_SCORE: if ( prevObj == OBJ_SCORE ) { - draw = handlePenUpScore( board, xx, yy, altDown ) || draw; + draw = handlePenUpScore( board, xwe, xx, + yy, altDown ) || draw; } break; case OBJ_BOARD: - if ( prevObj == OBJ_BOARD && checkRevealTray(board) ) { + if ( prevObj == OBJ_BOARD && checkRevealTray( board, xwe ) ) { if ( TRADE_IN_PROGRESS(board) ) { if ( ptOnTradeWindow( board, xx, yy )) { @@ -3071,7 +3078,7 @@ handlePenUpInternal( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy, XP_U16 col, row; coordToCell( board, xx, yy, &col, &row ); if ( !penMoved( board, col, row ) ) { - draw = handleActionInCell( board, col, row, + draw = handleActionInCell( board, xwe, col, row, isPen ) || draw; } } @@ -3079,13 +3086,13 @@ handlePenUpInternal( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy, break; case OBJ_TRAY: if ( board->trayVisState != TRAY_REVEALED ) { - draw = askRevealTray( board ) || draw; + draw = askRevealTray( board, xwe ) || draw; } else { draw = handlePenUpTray( board, xwe, xx, yy ) || draw; } break; case OBJ_TIMER: - util_timerSelected( board->util, board->gi->inDuplicateMode, + util_timerSelected( board->util, xwe, board->gi->inDuplicateMode, server_canPause( board->server ) ); break; default: @@ -3176,14 +3183,14 @@ focusToCoords( BoardCtxt* board, XP_U16* xp, XP_U16* yp ) * chance not to generate a keyUp event at all. */ static XP_Bool -handleFocusKeyUp( BoardCtxt* board, XP_Key key, XP_Bool preflightOnly, +handleFocusKeyUp( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool preflightOnly, XP_Bool* pHandled ) { XP_Bool redraw = XP_FALSE; if ( board->focusHasDived ) { XP_Bool up = XP_FALSE; if ( board->focussed == OBJ_BOARD ) { - redraw = board_moveCursor( board, key, preflightOnly, &up ); + redraw = board_moveCursor( board, xwe, key, preflightOnly, &up ); } else if ( board->focussed == OBJ_SCORE ) { redraw = moveScoreCursor( board, key, preflightOnly, &up ); } else if ( board->focussed == OBJ_TRAY/* && checkRevealTray(board)*/ ) { @@ -3191,9 +3198,9 @@ handleFocusKeyUp( BoardCtxt* board, XP_Key key, XP_Bool preflightOnly, } if ( up ) { if ( !preflightOnly ) { - (void)invalFocusOwner( board ); + (void)invalFocusOwner( board, xwe ); board->focusHasDived = XP_FALSE; - (void)invalFocusOwner( board ); + (void)invalFocusOwner( board, xwe ); } } else { *pHandled = redraw; @@ -3216,19 +3223,19 @@ board_handleKeyRepeat( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* handled } else { XP_Bool upHandled, downHandled; draw = board_handleKeyUp( board, xwe, key, &upHandled ); - draw = board_handleKeyDown( board, key, &downHandled ) || draw; + draw = board_handleKeyDown( board, xwe, key, &downHandled ) || draw; *handled = upHandled || downHandled; } return draw; } static XP_Bool -unhideFocus( BoardCtxt* board ) +unhideFocus( BoardCtxt* board, XWEnv xwe ) { XP_Bool changing = board->hideFocus; if ( changing ) { board->hideFocus = XP_FALSE; - (void)invalFocusOwner( board ); + (void)invalFocusOwner( board, xwe ); } return changing; } @@ -3236,8 +3243,8 @@ unhideFocus( BoardCtxt* board ) #ifdef KEY_SUPPORT XP_Bool -board_handleKeyDown( BoardCtxt* XP_UNUSED_KEYBOARD_NAV(board), - XP_Key XP_UNUSED_KEYBOARD_NAV(key), +board_handleKeyDown( BoardCtxt* XP_UNUSED_KEYBOARD_NAV(board), + XWEnv xwe, XP_Key XP_UNUSED_KEYBOARD_NAV(key), XP_Bool* XP_UNUSED_KEYBOARD_NAV(pHandled) ) { XP_Bool draw = XP_FALSE; @@ -3250,14 +3257,14 @@ board_handleKeyDown( BoardCtxt* XP_UNUSED_KEYBOARD_NAV(board), if ( key == XP_RETURN_KEY || key == XP_ALTRETURN_KEY ) { if ( focusToCoords( board, &xx, &yy ) ) { - draw = handleLikeDown( board, board->focussed, xx, yy ); + draw = handleLikeDown( board, xwe, board->focussed, xx, yy ); *pHandled = draw; } } else if ( board->focussed != OBJ_NONE ) { if ( board->focusHasDived && (key == XP_RAISEFOCUS_KEY) ) { *pHandled = XP_TRUE; } else { - draw = handleFocusKeyUp( board, key, XP_TRUE, pHandled ) || draw; + draw = handleFocusKeyUp( board, xwe, key, XP_TRUE, pHandled ) || draw; } } #endif @@ -3282,28 +3289,28 @@ board_handleKeyUp( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* pHandled ) case XP_CURSOR_KEY_RIGHT: case XP_CURSOR_KEY_ALTRIGHT: /* If focus is hidden, all we do is show it */ - if ( unhideFocus( board ) ) { + if ( unhideFocus( board, xwe ) ) { redraw = handled = XP_TRUE; } else { - redraw = handleFocusKeyUp( board, key, XP_FALSE, &handled ); + redraw = handleFocusKeyUp( board, xwe, key, XP_FALSE, &handled ); } break; #endif case XP_CURSOR_KEY_DEL: if ( trayVisible ) { - handled = redraw = replaceLastTile( board ); + handled = redraw = replaceLastTile( board, xwe ); } break; #ifdef KEYBOARD_NAV case XP_RAISEFOCUS_KEY: - if ( unhideFocus( board ) ) { + if ( unhideFocus( board, xwe ) ) { /* do nothing */ } else if ( board->focussed != OBJ_NONE && board->focusHasDived ) { - (void)invalFocusOwner( board ); + (void)invalFocusOwner( board, xwe ); board->focusHasDived = XP_FALSE; - (void)invalFocusOwner( board ); + (void)invalFocusOwner( board, xwe ); } else { break; /* skip setting handled */ } @@ -3313,7 +3320,7 @@ board_handleKeyUp( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* pHandled ) case XP_RETURN_KEY: case XP_ALTRETURN_KEY: { XP_Bool altDown = XP_ALTRETURN_KEY == key; - if ( unhideFocus( board ) ) { + if ( unhideFocus( board, xwe ) ) { handled = XP_TRUE; } else if ( board->focussed != OBJ_NONE ) { if ( board->focusHasDived ) { @@ -3323,9 +3330,9 @@ board_handleKeyUp( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* pHandled ) handled = XP_TRUE; } } else { - (void)invalFocusOwner( board ); + (void)invalFocusOwner( board, xwe ); board->focusHasDived = XP_TRUE; - redraw = invalFocusOwner( board ); + redraw = invalFocusOwner( board, xwe ); handled = XP_TRUE; } } @@ -3343,8 +3350,8 @@ board_handleKeyUp( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* pHandled ) && handleTrayDuringTrade( board, tileIndex ); } else { XP_Bool gotArrow; - handled = moveKeyTileToBoard( board, key, &gotArrow ); - if ( handled && gotArrow && !advanceArrow( board ) ) { + handled = moveKeyTileToBoard( board, xwe, key, &gotArrow ); + if ( handled && gotArrow && !advanceArrow( board, xwe ) ) { setArrowVisible( board, XP_FALSE ); } } @@ -3365,7 +3372,7 @@ board_handleKey( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* handled ) XP_Bool handled2; XP_Bool draw; - draw = board_handleKeyDown( board, key, &handled1 ); + draw = board_handleKeyDown( board, xwe, key, &handled1 ); draw = board_handleKeyUp( board, xwe, key, &handled2 ) || draw; if ( !!handled ) { *handled = handled1 || handled2; @@ -3377,7 +3384,7 @@ board_handleKey( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* handled ) #ifdef KEYBOARD_NAV static XP_Bool -invalFocusOwner( BoardCtxt* board ) +invalFocusOwner( BoardCtxt* board, XWEnv xwe ) { XP_Bool draw = XP_TRUE; PerTurnInfo* pti = board->selInfo; @@ -3389,7 +3396,7 @@ invalFocusOwner( BoardCtxt* board ) if ( board->focusHasDived ) { BdCursorLoc loc = pti->bdCursor; invalCell( board, loc.col, loc.row ); - scrollIntoView( board, loc.col, loc.row ); + scrollIntoView( board, xwe, loc.col, loc.row ); } else { #ifdef PERIMETER_FOCUS invalPerimeter( board ); @@ -3423,7 +3430,8 @@ invalFocusOwner( BoardCtxt* board ) } /* invalFocusOwner */ XP_Bool -board_focusChanged( BoardCtxt* board, BoardObjectType typ, XP_Bool gained ) +board_focusChanged( BoardCtxt* board, XWEnv xwe, + BoardObjectType typ, XP_Bool gained ) { XP_Bool draw = XP_FALSE; /* Called when there's been a decision to advance the focus to a new @@ -3452,38 +3460,38 @@ board_focusChanged( BoardCtxt* board, BoardObjectType typ, XP_Bool gained ) /* prefer to get !gained followed by gained. If caller doesn't do that, do it for 'em. */ if ( board->focussed != OBJ_NONE ) { - draw = board_focusChanged( board, board->focussed, XP_FALSE ); + draw = board_focusChanged( board, xwe, board->focussed, XP_FALSE ); } /* Are we losing focus we currently have elsewhere? */ if ( typ != board->focussed ) { - draw = invalFocusOwner( board ) || draw; + draw = invalFocusOwner( board, xwe ) || draw; } board->focussed = typ; board->focusHasDived = XP_FALSE; if ( OBJ_TRAY == typ) { board->trayHiddenPreFocus = board->trayVisState == TRAY_HIDDEN; if ( board->trayHiddenPreFocus ) { - setTrayVisState( board, TRAY_REVERSED ); + setTrayVisState( board, xwe, TRAY_REVERSED ); } } - draw = invalFocusOwner( board ) || draw; + draw = invalFocusOwner( board, xwe ) || draw; } else { /* we're losing it; inval and clear IFF we currently have same focus, otherwise ignore */ if ( typ == board->focussed ) { - draw = invalFocusOwner( board ) || draw; + draw = invalFocusOwner( board, xwe ) || draw; board->focussed = OBJ_NONE; if ( (OBJ_TRAY == typ) && (board->trayVisState == TRAY_REVERSED) && board->trayHiddenPreFocus ) { - setTrayVisState( board, TRAY_HIDDEN ); + setTrayVisState( board, xwe, TRAY_HIDDEN ); } } } if ( draw ) { - figureBoardRect( board ); + figureBoardRect( board, xwe ); } return draw; @@ -3492,14 +3500,14 @@ board_focusChanged( BoardCtxt* board, BoardObjectType typ, XP_Bool gained ) #endif /* KEYBOARD_NAV */ static XP_Bool -advanceArrow( BoardCtxt* board ) +advanceArrow( BoardCtxt* board, XWEnv xwe ) { XP_Key key = board->selInfo->boardArrow.vert ? XP_CURSOR_KEY_DOWN : XP_CURSOR_KEY_RIGHT; XP_ASSERT( board->trayVisState == TRAY_REVEALED ); - return board_moveArrow( board, key ); + return board_moveArrow( board, xwe, key ); } /* advanceArrow */ static XP_Bool @@ -3576,7 +3584,7 @@ figureNextLoc( const BoardCtxt* board, XP_Key cursorKey, } /* figureNextLoc */ static XP_Bool -board_moveArrow( BoardCtxt* board, XP_Key cursorKey ) +board_moveArrow( BoardCtxt* board, XWEnv xwe, XP_Key cursorKey ) { XP_U16 col, row; XP_Bool changed; @@ -3586,7 +3594,7 @@ board_moveArrow( BoardCtxt* board, XP_Key cursorKey ) changed = figureNextLoc( board, cursorKey, XP_TRUE, XP_FALSE, &col, &row, NULL ); if ( changed ) { - (void)setArrow( board, col, row, NULL ); + (void)setArrow( board, xwe, col, row, NULL ); } return changed; } /* board_moveArrow */ @@ -3614,8 +3622,8 @@ stripAlt( XP_Key key, XP_Bool* wasAlt ) } /* stripAlt */ static XP_Bool -board_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool preflightOnly, - XP_Bool* up ) +board_moveCursor( BoardCtxt* board, XWEnv xwe, XP_Key cursorKey, + XP_Bool preflightOnly, XP_Bool* up ) { PerTurnInfo* pti = board->selInfo; BdCursorLoc loc = pti->bdCursor; @@ -3634,7 +3642,7 @@ board_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool preflightOnly, loc.col = col; loc.row = row; pti->bdCursor = loc; - scrollIntoView( board, col, row ); + scrollIntoView( board, xwe, col, row ); } return changed; } /* board_moveCursor */ @@ -3672,7 +3680,7 @@ rectsIntersect( const XP_Rect* rect1, const XP_Rect* rect2 ) } /* rectsIntersect */ static XP_Bool -replaceLastTile( BoardCtxt* board ) +replaceLastTile( BoardCtxt* board, XWEnv xwe ) { XP_Bool result = XP_FALSE; XP_S16 turn = board->selPlayer; @@ -3692,10 +3700,10 @@ replaceLastTile( BoardCtxt* board ) index = -1; model_getCurrentMoveTile( board->model, board->selPlayer, &index, &tile, &col, &row, &isBlank ); - model_moveBoardToTray( board->model, board->selPlayer, col, row, -1 ); + model_moveBoardToTray( board->model, xwe, board->selPlayer, col, row, -1 ); flipIf( board, col, row, &col, &row ); - setArrow( board, col, row, directionKnown? &isVertical : NULL ); + setArrow( board, xwe, col, row, directionKnown? &isVertical : NULL ); result = XP_TRUE; } @@ -3703,15 +3711,15 @@ replaceLastTile( BoardCtxt* board ) } /* replaceLastTile */ XP_Bool -moveTileToBoard( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_U16 tileIndex, - Tile blankFace ) +moveTileToBoard( BoardCtxt* board, XWEnv xwe, XP_U16 col, XP_U16 row, + XP_U16 tileIndex, Tile blankFace ) { if ( cellOccupied( board, col, row, XP_TRUE ) ) { return XP_FALSE; } flipIf( board, col, row, &col, &row ); - model_moveTrayToBoard( board->model, board->selPlayer, col, row, + model_moveTrayToBoard( board->model, xwe, board->selPlayer, col, row, tileIndex, blankFace ); return XP_TRUE; @@ -3757,7 +3765,7 @@ keyToIndex( BoardCtxt* board, XP_Key key, Tile* blankFace ) } /* keyToIndex */ static XP_Bool -moveKeyTileToBoard( BoardCtxt* board, XP_Key cursorKey, XP_Bool* gotArrow ) +moveKeyTileToBoard( BoardCtxt* board, XWEnv xwe, XP_Key cursorKey, XP_Bool* gotArrow ) { XP_U16 col, row; XP_Bool haveDest; @@ -3781,7 +3789,7 @@ moveKeyTileToBoard( BoardCtxt* board, XP_Key cursorKey, XP_Bool* gotArrow ) XP_S16 tileIndex = keyToIndex( board, cursorKey, &blankFace ); haveDest = (tileIndex >= 0) - && moveTileToBoard( board, col, row, tileIndex, blankFace ); + && moveTileToBoard( board, xwe, col, row, tileIndex, blankFace ); } return haveDest; @@ -3789,7 +3797,7 @@ moveKeyTileToBoard( BoardCtxt* board, XP_Key cursorKey, XP_Bool* gotArrow ) #endif /* #ifdef KEY_SUPPORT */ static void -setArrow( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool* vertp ) +setArrow( BoardCtxt* board, XWEnv xwe, XP_U16 col, XP_U16 row, XP_Bool* vertp ) { XP_U16 player = board->selPlayer; BoardArrow* arrow = &board->pti[player].boardArrow; @@ -3802,7 +3810,7 @@ setArrow( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool* vertp ) arrow->vert = *vertp; } - scrollIntoView( board, col, row ); + scrollIntoView( board, xwe, col, row ); } /* setArrow */ static XP_Bool @@ -3842,8 +3850,8 @@ setArrowVisibleFor( BoardCtxt* board, XP_U16 player, XP_Bool visible ) * Listener callbacks ****************************************************************************/ static void -boardCellChanged( void* p_board, XP_U16 turn, XP_U16 modelCol, XP_U16 modelRow, - XP_Bool added ) +boardCellChanged( XWEnv xwe, void* p_board, XP_U16 turn, XP_U16 modelCol, + XP_U16 modelRow, XP_Bool added ) { BoardCtxt* board = (BoardCtxt*)p_board; XP_Bool pending, found; @@ -3883,7 +3891,7 @@ boardCellChanged( void* p_board, XP_U16 turn, XP_U16 modelCol, XP_U16 modelRow, } } - scrollIntoView( board, col, row ); + scrollIntoView( board, xwe, col, row ); } invalCell( (BoardCtxt*)p_board, col, row ); @@ -3920,7 +3928,7 @@ dictChanged( void* p_board, XWEnv xwe, XP_S16 playerNum, } static void -boardTurnChanged( void* p_board ) +boardTurnChanged( XWEnv xwe, void* p_board ) { BoardCtxt* board = (BoardCtxt*)p_board; XP_S16 nextPlayer; @@ -3932,21 +3940,21 @@ boardTurnChanged( void* p_board ) nextPlayer = chooseBestSelPlayer( board ); if ( nextPlayer >= 0 ) { XP_U16 nHumans = gi_countLocalPlayers( board->gi, XP_TRUE ); - selectPlayerImpl( board, nextPlayer, nHumans <= 1, XP_TRUE ); + selectPlayerImpl( board, xwe, nextPlayer, nHumans <= 1, XP_TRUE ); } - setTimerIf( board ); + setTimerIf( board, xwe ); board->scoreBoardInvalid = XP_TRUE; } /* boardTurnChanged */ static void -boardGameOver( void* closure, XP_S16 quitter ) +boardGameOver( XWEnv xwe, void* closure, XP_S16 quitter ) { BoardCtxt* board = (BoardCtxt*)closure; board->scoreBoardInvalid = XP_TRUE; /* not sure if this will do it. */ board->gameOver = XP_TRUE; - util_notifyGameOver( board->util, quitter ); + util_notifyGameOver( board->util, xwe, quitter ); } /* boardGameOver */ static void diff --git a/xwords4/common/board.h b/xwords4/common/board.h index 5f6635ec3..71916412e 100644 --- a/xwords4/common/board.h +++ b/xwords4/common/board.h @@ -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 diff --git a/xwords4/common/boarddrw.c b/xwords4/common/boarddrw.c index 49116aa4c..886abbac5 100644 --- a/xwords4/common/boarddrw.c +++ b/xwords4/common/boarddrw.c @@ -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) ) { diff --git a/xwords4/common/boardp.h b/xwords4/common/boardp.h index bb3e07309..dd37df978 100644 --- a/xwords4/common/boardp.h +++ b/xwords4/common/boardp.h @@ -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 ); diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index cf7e04f1a..e685cfccd 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -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 ) { diff --git a/xwords4/common/comms.h b/xwords4/common/comms.h index 66e2cd0a0..f5fa4d11e 100644 --- a/xwords4/common/comms.h +++ b/xwords4/common/comms.h @@ -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 ); diff --git a/xwords4/common/device.c b/xwords4/common/device.c index 08272def0..e6fcdce1a 100644 --- a/xwords4/common/device.c +++ b/xwords4/common/device.c @@ -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 ); diff --git a/xwords4/common/device.h b/xwords4/common/device.h index 6868cb5ba..3fc804817 100644 --- a/xwords4/common/device.h +++ b/xwords4/common/device.h @@ -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 diff --git a/xwords4/common/dragdrpp.c b/xwords4/common/dragdrpp.c index 809bc686e..ddcb74cb6 100644 --- a/xwords4/common/dragdrpp.c +++ b/xwords4/common/dragdrpp.c @@ -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 { diff --git a/xwords4/common/dragdrpp.h b/xwords4/common/dragdrpp.h index e93de9de0..d13306578 100644 --- a/xwords4/common/dragdrpp.h +++ b/xwords4/common/dragdrpp.h @@ -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 ); diff --git a/xwords4/common/dutil.h b/xwords4/common/dutil.h index 31de7879e..7f69c9fc5 100644 --- a/xwords4/common/dutil.h +++ b/xwords4/common/dutil.h @@ -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 diff --git a/xwords4/common/engine.c b/xwords4/common/engine.c index 2950f4cda..40a454b5a 100644 --- a/xwords4/common/engine.c +++ b/xwords4/common/engine.c @@ -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 ); diff --git a/xwords4/common/engine.h b/xwords4/common/engine.h index 514d90db8..5f1754a78 100644 --- a/xwords4/common/engine.h +++ b/xwords4/common/engine.h @@ -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 */ diff --git a/xwords4/common/game.c b/xwords4/common/game.c index 2d17f9811..ac6667ac0 100644 --- a/xwords4/common/game.c +++ b/xwords4/common/game.c @@ -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 diff --git a/xwords4/common/game.h b/xwords4/common/game.h index 04e37dd01..60a767ccb 100644 --- a/xwords4/common/game.h +++ b/xwords4/common/game.h @@ -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, diff --git a/xwords4/common/model.c b/xwords4/common/model.c index 68d4fa2ae..eaacc81bd 100644 --- a/xwords4/common/model.c +++ b/xwords4/common/model.c @@ -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; diff --git a/xwords4/common/model.h b/xwords4/common/model.h index b04bf783a..00c20feac 100644 --- a/xwords4/common/model.h +++ b/xwords4/common/model.h @@ -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 ); diff --git a/xwords4/common/modelp.h b/xwords4/common/modelp.h index a25e78a11..ef4e51ea0 100644 --- a/xwords4/common/modelp.h +++ b/xwords4/common/modelp.h @@ -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 diff --git a/xwords4/common/mscore.c b/xwords4/common/mscore.c index d91ea034f..894f71112 100644 --- a/xwords4/common/mscore.c +++ b/xwords4/common/mscore.c @@ -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 ); diff --git a/xwords4/common/nwgamest.c b/xwords4/common/nwgamest.c index 135f6f8c5..253bde069 100644 --- a/xwords4/common/nwgamest.c +++ b/xwords4/common/nwgamest.c @@ -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 */ diff --git a/xwords4/common/nwgamest.h b/xwords4/common/nwgamest.h index a9b129317..321a4b282 100644 --- a/xwords4/common/nwgamest.h +++ b/xwords4/common/nwgamest.h @@ -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 diff --git a/xwords4/common/scorebdp.c b/xwords4/common/scorebdp.c index ca316d15f..b3ca7284e 100644 --- a/xwords4/common/scorebdp.c +++ b/xwords4/common/scorebdp.c @@ -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 } diff --git a/xwords4/common/scorebdp.h b/xwords4/common/scorebdp.h index b87125d06..f1c3fe2f6 100644 --- a/xwords4/common/scorebdp.h +++ b/xwords4/common/scorebdp.h @@ -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 diff --git a/xwords4/common/server.c b/xwords4/common/server.c index 9274cd498..be1f34ed0 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -147,7 +147,7 @@ struct ServerCtxt { #define NPASSES_OK(s) model_recentPassCountOk((s)->vol.model) /******************************* prototypes *******************************/ -static XP_Bool assignTilesToAll( ServerCtxt* server ); +static XP_Bool assignTilesToAll( ServerCtxt* server, XWEnv xwe ); static void makePoolOnce( ServerCtxt* server ); static XP_S8 getIndexForDevice( const ServerCtxt* server, @@ -155,16 +155,18 @@ static XP_S8 getIndexForDevice( const ServerCtxt* server, static XP_S8 getIndexForStream( const ServerCtxt* server, const XWStreamCtxt* stream ); -static void nextTurn( ServerCtxt* server, XP_S16 nxtTurn ); +static void nextTurn( ServerCtxt* server, XWEnv xwe, XP_S16 nxtTurn ); -static void doEndGame( ServerCtxt* server, XP_S16 quitter ); -static void endGameInternal( ServerCtxt* server, XWEnv xwe, GameEndReason why, XP_S16 quitter ); -static void badWordMoveUndoAndTellUser( ServerCtxt* server, BadWordInfo* bwi ); +static void doEndGame( ServerCtxt* server, XWEnv xwe, XP_S16 quitter ); +static void endGameInternal( ServerCtxt* server, XWEnv xwe, + GameEndReason why, XP_S16 quitter ); +static void badWordMoveUndoAndTellUser( ServerCtxt* server, XWEnv xwe, + BadWordInfo* bwi ); static XP_Bool tileCountsOk( const ServerCtxt* server ); -static void setTurn( ServerCtxt* server, XP_S16 turn ); +static void setTurn( ServerCtxt* server, XWEnv xwe, XP_S16 turn ); static XWStreamCtxt* mkServerStream( ServerCtxt* server ); -static void fetchTiles( ServerCtxt* server, XP_U16 playerNum, XP_U16 nToFetch, - const TrayTileSet* tradedTiles, +static void fetchTiles( ServerCtxt* server, XWEnv xwe, XP_U16 playerNum, + XP_U16 nToFetch, const TrayTileSet* tradedTiles, TrayTileSet* resultTiles ); static void finishMove( ServerCtxt* server, XWEnv xwe, TrayTileSet* newTiles, XP_U16 turn ); @@ -182,19 +184,19 @@ static void dupe_makeAndReportTrade( ServerCtxt* server, XWEnv xwe ); static void dupe_transmitPause( ServerCtxt* server, XWEnv xwe, DupPauseType typ, XP_U16 turn, const XP_UCHAR* msg, XP_S16 skipDev ); -static void dupe_resetTimer( ServerCtxt* server ); -static XP_Bool setDupCheckTimer( ServerCtxt* server ); +static void dupe_resetTimer( ServerCtxt* server, XWEnv xwe ); +static XP_Bool setDupCheckTimer( ServerCtxt* server, XWEnv xwe ); static void sortTilesIf( ServerCtxt* server, XP_S16 turn ); #ifndef XWFEATURE_STANDALONE_ONLY -static XWStreamCtxt* messageStreamWithHeader( ServerCtxt* server, +static XWStreamCtxt* messageStreamWithHeader( ServerCtxt* server, XWEnv xwe, XP_U16 devIndex, XW_Proto code ); -static XP_Bool handleRegistrationMsg( ServerCtxt* server, +static XP_Bool handleRegistrationMsg( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ); static XP_S8 registerRemotePlayer( ServerCtxt* server, XWStreamCtxt* stream ); static void sendInitialMessage( ServerCtxt* server, XWEnv xwe ); static void sendBadWordMsgs( ServerCtxt* server, XWEnv xwe ); -static XP_Bool handleIllegalWord( ServerCtxt* server, +static XP_Bool handleIllegalWord( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* incoming ); static void tellMoveWasLegal( ServerCtxt* server, XWEnv xwe ); static void writeProto( const ServerCtxt* server, XWStreamCtxt* stream, @@ -285,9 +287,9 @@ amServer( const ServerCtxt* server ) } static void -initServer( ServerCtxt* server ) +initServer( ServerCtxt* server, XWEnv xwe ) { - setTurn( server, -1 ); /* game isn't under way yet */ + setTurn( server, xwe, -1 ); /* game isn't under way yet */ if ( 0 ) { #ifndef XWFEATURE_STANDALONE_ONLY @@ -308,7 +310,7 @@ initServer( ServerCtxt* server ) } /* initServer */ ServerCtxt* -server_make( MPFORMAL ModelCtxt* model, CommsCtxt* comms, XW_UtilCtxt* util ) +server_make( MPFORMAL XWEnv xwe, ModelCtxt* model, CommsCtxt* comms, XW_UtilCtxt* util ) { ServerCtxt* result = (ServerCtxt*)XP_MALLOC( mpool, sizeof(*result) ); @@ -320,10 +322,10 @@ server_make( MPFORMAL ModelCtxt* model, CommsCtxt* comms, XW_UtilCtxt* util ) result->vol.model = model; result->vol.comms = comms; result->vol.util = util; - result->vol.dutil = util_getDevUtilCtxt( util ); + result->vol.dutil = util_getDevUtilCtxt( util, xwe ); result->vol.gi = util->gameInfo; - initServer( result ); + initServer( result, xwe ); } return result; } /* server_make */ @@ -452,7 +454,7 @@ writeStreamIf( XWStreamCtxt* dest, XWStreamCtxt* src ) } static void -informMissing( const ServerCtxt* server ) +informMissing( const ServerCtxt* server, XWEnv xwe ) { XP_Bool isServer = amServer( server ); const CommsCtxt* comms = server->vol.comms; @@ -467,7 +469,7 @@ informMissing( const ServerCtxt* server ) XP_U16 nDevs = isServer ? server->nv.nDevices - 1 : 0; XP_U16 nPending = isServer ? server->nv.pendingRegistrations : 0; - util_informMissing( server->vol.util, isServer, addrP, nDevs, nPending ); + util_informMissing( server->vol.util, xwe, isServer, addrP, nDevs, nPending ); } XP_U16 @@ -478,14 +480,14 @@ server_getPendingRegs( const ServerCtxt* server ) } ServerCtxt* -server_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model, +server_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, ModelCtxt* model, CommsCtxt* comms, XW_UtilCtxt* util, XP_U16 nPlayers ) { ServerCtxt* server; XP_U16 version = stream_getVersion( stream ); short ii; - server = server_make( MPPARM(mpool) model, comms, util ); + server = server_make( MPPARM(mpool) xwe, model, comms, util ); /* BAE */ getNV( stream, &server->nv, nPlayers ); if ( stream_getBits(stream, 1) != 0 ) { @@ -518,7 +520,7 @@ server_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model, server->nv.prevWordsStream = readStreamIf( server, stream ); } - informMissing( server ); + informMissing( server, xwe ); return server; } /* server_makeFromStream */ @@ -589,7 +591,7 @@ server_reset( ServerCtxt* server, XWEnv xwe, CommsCtxt* comms ) vol.comms = comms; server->vol = vol; - initServer( server ); + initServer( server, xwe ); } /* server_reset */ void @@ -720,7 +722,7 @@ sendChatTo( ServerCtxt* server, XWEnv xwe, XP_U16 devIndex, const XP_UCHAR* msg, XP_S8 from, XP_U32 timestamp ) { if ( comms_canChat( server->vol.comms ) ) { - XWStreamCtxt* stream = messageStreamWithHeader( server, devIndex, + XWStreamCtxt* stream = messageStreamWithHeader( server, xwe, devIndex, XWPROTO_CHAT ); stringToStream( stream, msg ); stream_putU8( stream, from ); @@ -745,7 +747,7 @@ sendChatToClientsExcept( ServerCtxt* server, XWEnv xwe, XP_U16 skip, void server_sendChat( ServerCtxt* server, XWEnv xwe, const XP_UCHAR* msg, XP_S16 from ) { - XP_U32 timestamp = dutil_getCurSeconds( server->vol.dutil ); + XP_U32 timestamp = dutil_getCurSeconds( server->vol.dutil, xwe ); if ( server->vol.gi->serverRole == SERVER_ISCLIENT ) { sendChatTo( server, xwe, SERVER_DEVICE, msg, from, timestamp ); } else { @@ -766,25 +768,25 @@ receiveChat( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* incoming ) sendChatToClientsExcept( server, xwe, sourceClientIndex, msg, from, timestamp ); } - util_showChat( server->vol.util, msg, from, timestamp ); + util_showChat( server->vol.util, xwe, msg, from, timestamp ); XP_FREE( server->mpool, msg ); return XP_TRUE; } #endif static void -callTurnChangeListener( const ServerCtxt* server ) +callTurnChangeListener( const ServerCtxt* server, XWEnv xwe ) { if ( server->vol.turnChangeListener != NULL ) { - (*server->vol.turnChangeListener)( server->vol.turnChangeData ); + (*server->vol.turnChangeListener)( xwe, server->vol.turnChangeData ); } } /* callTurnChangeListener */ static void -callDupTimerListener( const ServerCtxt* server, XP_S32 oldVal, XP_S32 newVal ) +callDupTimerListener( const ServerCtxt* server, XWEnv xwe, XP_S32 oldVal, XP_S32 newVal ) { if ( server->vol.timerChangeListener != NULL ) { - (*server->vol.timerChangeListener)( server->vol.timerChangeData, + (*server->vol.timerChangeListener)( xwe, server->vol.timerChangeData, server->vol.gi->gameID, oldVal, newVal ); } else { XP_LOGF( "%s(): no listener!!", __func__ ); @@ -823,7 +825,7 @@ checkResizeBoard( ServerCtxt* server ) # endif static XP_Bool -handleRegistrationMsg( ServerCtxt* server, XWStreamCtxt* stream ) +handleRegistrationMsg( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) { XP_Bool success = XP_TRUE; XP_U16 playersInMsg; @@ -838,7 +840,7 @@ handleRegistrationMsg( ServerCtxt* server, XWStreamCtxt* stream ) if ( server->nv.pendingRegistrations < playersInMsg ) { XP_LOGF( "%s: got %d players but missing only %d", __func__, playersInMsg, server->nv.pendingRegistrations ); - util_userError( server->vol.util, ERR_REG_UNEXPECTED_USER ); + util_userError( server->vol.util, xwe, ERR_REG_UNEXPECTED_USER ); success = XP_FALSE; } else { #ifdef DEBUG @@ -855,7 +857,7 @@ handleRegistrationMsg( ServerCtxt* server, XWStreamCtxt* stream ) case where there is another device yet to register -- but we need to let the board know to redraw the scoreboard with more players there. */ - callTurnChangeListener( server ); + callTurnChangeListener( server, xwe ); #ifdef DEBUG XP_ASSERT( ii == 0 || prevIndex == clientIndex ); prevIndex = clientIndex; @@ -880,10 +882,10 @@ handleRegistrationMsg( ServerCtxt* server, XWStreamCtxt* stream ) XP_ASSERT( ii == playersInMsg ); /* otherwise malformed */ setStreamVersion( server ); checkResizeBoard( server ); - (void)assignTilesToAll( server ); + (void)assignTilesToAll( server, xwe ); SETSTATE( server, XWSTATE_RECEIVED_ALL_REG ); } - informMissing( server ); + informMissing( server, xwe ); } return success; @@ -901,13 +903,13 @@ bitsPerTile( ServerCtxt* server ) } static void -dupe_setupShowTrade( ServerCtxt* server, XP_U16 nTiles ) +dupe_setupShowTrade( ServerCtxt* server, XWEnv xwe, XP_U16 nTiles ) { XP_ASSERT( inDuplicateMode(server) ); XP_ASSERT( !server->nv.prevMoveStream ); XP_UCHAR buf[128]; - const XP_UCHAR* fmt = dutil_getUserString( server->vol.dutil, STRD_DUP_TRADED ); + const XP_UCHAR* fmt = dutil_getUserString( server->vol.dutil, xwe, STRD_DUP_TRADED ); XP_SNPRINTF( buf, VSIZE(buf), fmt, nTiles ); XWStreamCtxt* stream = mkServerStream( server ); @@ -918,7 +920,7 @@ dupe_setupShowTrade( ServerCtxt* server, XP_U16 nTiles ) } static void -dupe_setupShowMove( ServerCtxt* server, XP_U16* scores ) +dupe_setupShowMove( ServerCtxt* server, XWEnv xwe, XP_U16* scores ) { XP_ASSERT( inDuplicateMode(server) ); XP_ASSERT( !server->nv.prevMoveStream ); /* firing */ @@ -941,7 +943,8 @@ dupe_setupShowMove( ServerCtxt* server, XP_U16* scores ) } /* Process everybody with that score */ - const XP_UCHAR* fmt = dutil_getUserString( server->vol.dutil, STRSD_DUP_ONESCORE ); + const XP_UCHAR* fmt = dutil_getUserString( server->vol.dutil, xwe, + STRSD_DUP_ONESCORE ); for ( XP_U16 ii = 0; ii < nPlayers; ++ii ) { if ( scores[ii] == thisMax ) { ++nDone; @@ -984,8 +987,8 @@ dupe_handleClientMoves( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) XP_U16 turn = (XP_U16)stream_getBits( stream, PLAYERNUM_NBITS ); XP_Bool forced = (XP_Bool)stream_getBits( stream, 1 ); - model_resetCurrentTurn( model, turn ); - success = model_makeTurnFromStream( model, turn, stream ); + model_resetCurrentTurn( model, xwe, turn ); + success = model_makeTurnFromStream( model, xwe, turn, stream ); XP_ASSERT( success ); /* shouldn't fail in duplicate case */ if ( success ) { XP_ASSERT( !server->nv.dupTurnsMade[turn] ); /* firing */ @@ -997,7 +1000,7 @@ dupe_handleClientMoves( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) if ( success ) { dupe_checkTurns( server, xwe ); - nextTurn( server, PICK_NEXT ); + nextTurn( server, xwe, PICK_NEXT ); } LOG_RETURNF( "%d", success ); @@ -1005,10 +1008,10 @@ dupe_handleClientMoves( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) } static void -updateOthersTiles( ServerCtxt* server ) +updateOthersTiles( ServerCtxt* server, XWEnv xwe ) { sortTilesIf( server, DUP_PLAYER ); - model_cloneDupeTrays( server->vol.model ); + model_cloneDupeTrays( server->vol.model, xwe ); } static XP_Bool @@ -1018,54 +1021,54 @@ checkDupTimerProc( void* closure, XWEnv xwe, XWTimerReason XP_UNUSED_DBG(XP_why) ServerCtxt* server = (ServerCtxt*)closure; XP_ASSERT( inDuplicateMode( server ) ); // Don't call server_do() if the timer hasn't fired yet - return setDupCheckTimer( server ) || server_do( server, xwe ); + return setDupCheckTimer( server, xwe ) || server_do( server, xwe ); } static XP_Bool -setDupCheckTimer( ServerCtxt* server ) +setDupCheckTimer( ServerCtxt* server, XWEnv xwe ) { XP_Bool set = XP_FALSE; - XP_U32 now = dutil_getCurSeconds( server->vol.dutil ); + XP_U32 now = dutil_getCurSeconds( server->vol.dutil, xwe ); if ( server->nv.dupTimerExpires > 0 && server->nv.dupTimerExpires > now ) { XP_U32 diff = server->nv.dupTimerExpires - now; XP_ASSERT( diff <= 0x7FFF ); XP_U16 whenSeconds = (XP_U16) diff; - util_setTimer( server->vol.util, TIMER_DUP_TIMERCHECK, whenSeconds, - checkDupTimerProc, server ); + util_setTimer( server->vol.util, xwe, TIMER_DUP_TIMERCHECK, + whenSeconds, checkDupTimerProc, server ); set = XP_TRUE; } return set; } static void -setDupTimerExpires( ServerCtxt* server, XP_S32 newVal ) +setDupTimerExpires( ServerCtxt* server, XWEnv xwe, XP_S32 newVal ) { XP_LOGF( "%s(%d)", __func__, newVal ); if ( newVal != server->nv.dupTimerExpires ) { XP_S32 oldVal = server->nv.dupTimerExpires; server->nv.dupTimerExpires = newVal; - callDupTimerListener( server, oldVal, newVal ); + callDupTimerListener( server, xwe, oldVal, newVal ); } } static void -dupe_resetTimer( ServerCtxt* server ) +dupe_resetTimer( ServerCtxt* server, XWEnv xwe ) { XP_S32 newVal = 0; if ( server->vol.gi->timerEnabled && 0 < server->vol.gi->gameSeconds ) { - XP_U32 now = dutil_getCurSeconds( server->vol.dutil ); + XP_U32 now = dutil_getCurSeconds( server->vol.dutil, xwe ); newVal = now + server->vol.gi->gameSeconds; } else { XP_LOGF( "%s(): doing nothing because timers disabled", __func__ ); } if ( server_canUnpause( server ) ) { - XP_U32 now = dutil_getCurSeconds( server->vol.dutil ); + XP_U32 now = dutil_getCurSeconds( server->vol.dutil, xwe ); newVal = -(newVal - now); } - setDupTimerExpires( server, newVal ); + setDupTimerExpires( server, xwe, newVal ); - setDupCheckTimer( server ); + setDupCheckTimer( server, xwe ); } XP_S32 @@ -1077,7 +1080,7 @@ server_getDupTimerExpires( const ServerCtxt* server ) /* If we're in dup mode, this is 0 if no timer otherwise the number of seconds left. */ XP_S16 -server_getTimerSeconds( const ServerCtxt* server, XP_U16 turn ) +server_getTimerSeconds( const ServerCtxt* server, XWEnv xwe, XP_U16 turn ) { XP_S16 result; if ( inDuplicateMode( server ) ) { @@ -1085,7 +1088,7 @@ server_getTimerSeconds( const ServerCtxt* server, XP_U16 turn ) if ( dupTimerExpires <= 0 ) { result = (XP_S16)-dupTimerExpires; } else { - XP_U32 now = dutil_getCurSeconds( server->vol.dutil ); + XP_U32 now = dutil_getCurSeconds( server->vol.dutil, xwe ); result = dupTimerExpires > now ? dupTimerExpires - now : 0; } XP_ASSERT( result >= 0 ); /* should never go negative */ @@ -1118,13 +1121,13 @@ server_canUnpause( const ServerCtxt* server ) } static void -pauseImpl( ServerCtxt* server ) +pauseImpl( ServerCtxt* server, XWEnv xwe ) { XP_ASSERT( server_canPause( server ) ); /* Figure out how many seconds are left on the timer, and set timer to the negative of that (since negative is the flag) */ - XP_U32 now = dutil_getCurSeconds( server->vol.dutil ); - setDupTimerExpires( server, -(server->nv.dupTimerExpires - now) ); + XP_U32 now = dutil_getCurSeconds( server->vol.dutil, xwe ); + setDupTimerExpires( server, xwe, -(server->nv.dupTimerExpires - now) ); XP_ASSERT( 0 > server->nv.dupTimerExpires ); XP_ASSERT( server_canUnpause( server ) ); } @@ -1133,11 +1136,11 @@ void server_pause( ServerCtxt* server, XWEnv xwe, XP_S16 turn, const XP_UCHAR* msg ) { XP_LOGF( "%s(turn=%d)", __func__, turn ); - pauseImpl( server ); + pauseImpl( server, xwe ); /* Figure out how many seconds are left on the timer, and set timer to the negative of that (since negative is the flag) */ dupe_transmitPause( server, xwe, PAUSED, turn, msg, -1 ); - model_noteDupePause( server->vol.model, PAUSED, turn, msg ); + model_noteDupePause( server->vol.model, xwe, PAUSED, turn, msg ); LOG_RETURN_VOID(); } @@ -1147,14 +1150,14 @@ dupe_autoPause( ServerCtxt* server, XWEnv xwe ) XP_LOGF( "%s()", __func__ ); /* Reset timer: we're starting turn over */ - dupe_resetTimer( server ); + dupe_resetTimer( server, xwe ); dupe_clearState( server ); /* Then pause us */ - pauseImpl( server ); + pauseImpl( server, xwe ); dupe_transmitPause( server, xwe, AUTOPAUSED, 0, NULL, -1 ); - model_noteDupePause( server->vol.model, AUTOPAUSED, -1, NULL ); + model_noteDupePause( server->vol.model, xwe, AUTOPAUSED, -1, NULL ); LOG_RETURN_VOID(); } @@ -1163,12 +1166,12 @@ server_unpause( ServerCtxt* server, XWEnv xwe, XP_S16 turn, const XP_UCHAR* msg { XP_LOGF( "%s(turn=%d)", __func__, turn ); XP_ASSERT( server_canUnpause( server ) ); - XP_U32 now = dutil_getCurSeconds( server->vol.dutil ); + XP_U32 now = dutil_getCurSeconds( server->vol.dutil, xwe ); /* subtract because it's negative */ - setDupTimerExpires( server, now - server->nv.dupTimerExpires ); + setDupTimerExpires( server, xwe, now - server->nv.dupTimerExpires ); XP_ASSERT( server_canPause( server ) ); dupe_transmitPause( server, xwe, UNPAUSED, turn, msg, -1 ); - model_noteDupePause( server->vol.model, UNPAUSED, turn, msg ); + model_noteDupePause( server->vol.model, xwe, UNPAUSED, turn, msg ); LOG_RETURN_VOID(); } @@ -1189,32 +1192,32 @@ dupe_handleServerMoves( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) XP_ASSERT( nScores <= MAX_NUM_PLAYERS ); scoresFromStream( stream, nScores, scores ); - dupe_resetTimer( server ); + dupe_resetTimer( server, xwe ); pool_removeTiles( server->pool, &newTiles ); model_commitDupeTurn( server->vol.model, xwe, &moveInfo, nScores, scores, &newTiles ); /* Need to remove the played tiles from all local trays */ - updateOthersTiles( server ); + updateOthersTiles( server, xwe ); - dupe_setupShowMove( server, scores ); + dupe_setupShowMove( server, xwe, scores ); dupe_clearState( server ); - nextTurn( server, PICK_NEXT ); + nextTurn( server, xwe, PICK_NEXT ); LOG_RETURN_VOID(); return XP_TRUE; } /* dupe_handleServerMoves */ static XP_Bool -dupe_handleServerTrade( ServerCtxt* server, XWStreamCtxt* stream ) +dupe_handleServerTrade( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) { TrayTileSet oldTiles, newTiles; traySetFromStream( stream, &oldTiles ); traySetFromStream( stream, &newTiles ); ModelCtxt* model = server->vol.model; - model_resetCurrentTurn( model, DUP_PLAYER ); + model_resetCurrentTurn( model, xwe, DUP_PLAYER ); model_removePlayerTiles( model, DUP_PLAYER, &oldTiles ); pool_replaceTiles( server->pool, &oldTiles ); pool_removeTiles( server->pool, &newTiles ); @@ -1222,13 +1225,13 @@ dupe_handleServerTrade( ServerCtxt* server, XWStreamCtxt* stream ) model_commitDupeTrade( model, &oldTiles, &newTiles ); model_addNewTiles( model, DUP_PLAYER, &newTiles ); - updateOthersTiles( server ); + updateOthersTiles( server, xwe ); - dupe_resetTimer( server ); - dupe_setupShowTrade( server, newTiles.nTiles ); + dupe_resetTimer( server, xwe ); + dupe_setupShowTrade( server, xwe, newTiles.nTiles ); dupe_clearState( server ); - nextTurn( server, PICK_NEXT ); + nextTurn( server, xwe, PICK_NEXT ); return XP_TRUE; } @@ -1296,7 +1299,7 @@ makeRobotMove( ServerCtxt* server, XWEnv xwe ) XP_Bool forceTrade = XP_FALSE; if ( timerEnabled ) { - time = dutil_getCurSeconds( dutil ); + time = dutil_getCurSeconds( dutil, xwe ); } #ifdef XWFEATURE_SLOW_ROBOT @@ -1316,7 +1319,7 @@ makeRobotMove( ServerCtxt* server, XWEnv xwe ) pending tiles on the board we'll have problems. It'd be best to detect this and put 'em back when that happens. But for now we'll just be paranoid. PENDING(ehouse) */ - model_resetCurrentTurn( model, turn ); + model_resetCurrentTurn( model, xwe, turn ); if ( !forceTrade ) { const TrayTileSet* tileSet = model_getPlayerTiles( model, turn ); @@ -1325,7 +1328,7 @@ makeRobotMove( ServerCtxt* server, XWEnv xwe ) #endif XP_ASSERT( !!server_getEngineFor( server, turn ) ); searchComplete = engine_findMove( server_getEngineFor( server, turn ), - model, turn, XP_FALSE, XP_FALSE, + xwe, model, turn, XP_FALSE, XP_FALSE, tileSet->tiles, tileSet->nTiles, XP_FALSE, #ifdef XWFEATURE_BONUSALL allTilesBonus, @@ -1362,7 +1365,7 @@ makeRobotMove( ServerCtxt* server, XWEnv xwe ) if ( !!stream ) { XP_UCHAR buf[64]; - str = dutil_getUserQuantityString( dutil, STRD_ROBOT_TRADED, + str = dutil_getUserQuantityString( dutil, xwe, STRD_ROBOT_TRADED, MAX_TRAY_TILES ); XP_SNPRINTF( buf, sizeof(buf), str, MAX_TRAY_TILES ); @@ -1380,7 +1383,7 @@ makeRobotMove( ServerCtxt* server, XWEnv xwe ) } #endif juggleMoveIfDebug( &newMove ); - model_makeTurnFromMoveInfo( model, turn, &newMove ); + model_makeTurnFromMoveInfo( model, xwe, turn, &newMove ); XP_LOGFF( "robot making %d tile move for player %d", newMove.nTiles, turn ); if ( !!stream ) { @@ -1401,7 +1404,7 @@ makeRobotMove( ServerCtxt* server, XWEnv xwe ) if ( timerEnabled ) { gi->players[turn].secondsUsed += - (XP_U16)(dutil_getCurSeconds( dutil ) - time); + (XP_U16)(dutil_getCurSeconds( dutil, xwe ) - time); } else { XP_ASSERT( gi->players[turn].secondsUsed == 0 ); } @@ -1412,13 +1415,13 @@ makeRobotMove( ServerCtxt* server, XWEnv xwe ) #ifdef XWFEATURE_SLOW_ROBOT static XP_Bool -wakeRobotProc( void* closure, XWEnv XP_UNUSED(xwe), XWTimerReason XP_UNUSED_DBG(why) ) +wakeRobotProc( void* closure, XWEnv xwe, XWTimerReason XP_UNUSED_DBG(why) ) { XP_ASSERT( TIMER_SLOWROBOT == why ); ServerCtxt* server = (ServerCtxt*)closure; XP_ASSERT( ROBOTWAITING(server) ); server->robotWaiting = XP_FALSE; - util_requestTime( server->vol.util ); + util_requestTime( server->vol.util, xwe ); return XP_FALSE; } #endif @@ -1438,7 +1441,7 @@ robotMovePending( const ServerCtxt* server ) #ifdef XWFEATURE_SLOW_ROBOT static XP_Bool -postponeRobotMove( ServerCtxt* server ) +postponeRobotMove( ServerCtxt* server, XWEnv xwe ) { XP_Bool result = XP_FALSE; XP_ASSERT( robotMovePending(server) ); @@ -1447,16 +1450,16 @@ postponeRobotMove( ServerCtxt* server ) XP_U16 sleepTime = figureSleepTime(server); if ( 0 != sleepTime ) { server->robotWaiting = XP_TRUE; - util_setTimer( server->vol.util, TIMER_SLOWROBOT, sleepTime, + util_setTimer( server->vol.util, xwe, TIMER_SLOWROBOT, sleepTime, wakeRobotProc, server ); result = XP_TRUE; } } return result; } -# define POSTPONEROBOTMOVE(s) postponeRobotMove(s) +# define POSTPONEROBOTMOVE(s, e) postponeRobotMove(s, e) #else -# define POSTPONEROBOTMOVE(s) XP_FALSE +# define POSTPONEROBOTMOVE(s, e) XP_FALSE #endif static void @@ -1484,7 +1487,7 @@ showPrevScore( ServerCtxt* server, XWEnv xwe ) } else { stringCode = STRS_REMOTE_MOVED; } - const XP_UCHAR* str = dutil_getUserString( dutil, stringCode ); + const XP_UCHAR* str = dutil_getUserString( dutil, xwe, stringCode ); XP_SNPRINTF( buf, sizeof(buf), str, lp->name ); str = buf; @@ -1500,7 +1503,7 @@ showPrevScore( ServerCtxt* server, XWEnv xwe ) stream_destroy( prevStream, xwe ); } - util_informMove( util, prevTurn, stream, server->nv.prevWordsStream ); + util_informMove( util, xwe, prevTurn, stream, server->nv.prevWordsStream ); stream_destroy( stream, xwe ); if ( !!server->nv.prevWordsStream ) { @@ -1512,7 +1515,7 @@ showPrevScore( ServerCtxt* server, XWEnv xwe ) } /* showPrevScore */ void -server_tilesPicked( ServerCtxt* server, XP_U16 player, +server_tilesPicked( ServerCtxt* server, XWEnv xwe, XP_U16 player, const TrayTileSet* newTilesP ) { XP_ASSERT( 0 == model_getNumTilesInTray( server->vol.model, player ) ); @@ -1522,16 +1525,16 @@ server_tilesPicked( ServerCtxt* server, XP_U16 player, TrayTileSet newTiles = *newTilesP; pool_removeTiles( server->pool, &newTiles ); - fetchTiles( server, player, MAX_TRAY_TILES, NULL, &newTiles ); + fetchTiles( server, xwe, player, MAX_TRAY_TILES, NULL, &newTiles ); XP_ASSERT( !inDuplicateMode(server) ); model_assignPlayerTiles( server->vol.model, player, &newTiles ); - util_requestTime( server->vol.util ); + util_requestTime( server->vol.util, xwe ); } static XP_Bool -informNeedPickTiles( ServerCtxt* server, XP_Bool initial, XP_U16 turn, - XP_U16 nToPick ) +informNeedPickTiles( ServerCtxt* server, XWEnv xwe, XP_Bool initial, + XP_U16 turn, XP_U16 nToPick ) { ModelCtxt* model = server->vol.model; DictionaryCtxt* dict = model_getDictionary(model); @@ -1556,7 +1559,7 @@ informNeedPickTiles( ServerCtxt* server, XP_Bool initial, XP_U16 turn, faces[tile] = dict_getTileString( dict, tile ); counts[tile] = pool_getNTilesLeftFor( server->pool, tile ); } - util_informNeedPickTiles( server->vol.util, initial, turn, + util_informNeedPickTiles( server->vol.util, xwe, initial, turn, nToPick, nFaces, faces, counts ); } } @@ -1578,11 +1581,11 @@ server_do( ServerCtxt* server, XWEnv xwe ) case XWSTATE_BEGIN: if ( server->nv.pendingRegistrations == 0 ) { /* all players on device */ - if ( assignTilesToAll( server ) ) { + if ( assignTilesToAll( server, xwe ) ) { SETSTATE( server, XWSTATE_INTURN ); - setTurn( server, 0 ); + setTurn( server, xwe, 0 ); if ( inDuplicateMode( server ) ) { - dupe_resetTimer( server ); + dupe_resetTimer( server, xwe ); } moreToDo = XP_TRUE; } @@ -1591,11 +1594,11 @@ server_do( ServerCtxt* server, XWEnv xwe ) case XWSTATE_NEEDSEND_BADWORD_INFO: XP_ASSERT( server->vol.gi->serverRole == SERVER_ISSERVER ); - badWordMoveUndoAndTellUser( server, &server->illegalWordInfo ); + badWordMoveUndoAndTellUser( server, xwe, &server->illegalWordInfo ); #ifndef XWFEATURE_STANDALONE_ONLY sendBadWordMsgs( server, xwe ); #endif - nextTurn( server, PICK_NEXT ); + nextTurn( server, xwe, PICK_NEXT ); //moreToDo = XP_TRUE; /* why? */ break; @@ -1605,14 +1608,14 @@ server_do( ServerCtxt* server, XWEnv xwe ) /* PENDING isn't INTURN_OFFDEVICE possible too? Or just INTURN? */ SETSTATE( server, XWSTATE_INTURN ); - setTurn( server, 0 ); + setTurn( server, xwe, 0 ); moreToDo = XP_TRUE; break; case XWSTATE_MOVE_CONFIRM_MUSTSEND: XP_ASSERT( server->vol.gi->serverRole == SERVER_ISSERVER ); tellMoveWasLegal( server, xwe ); /* sets state */ - nextTurn( server, PICK_NEXT ); + nextTurn( server, xwe, PICK_NEXT ); break; #endif /* XWFEATURE_STANDALONE_ONLY */ @@ -1639,7 +1642,7 @@ server_do( ServerCtxt* server, XWEnv xwe ) result = makeRobotMove( server, xwe ); /* if robot was interrupted, we need to schedule again */ moreToDo = !result || - (robotMovePending( server ) && !POSTPONEROBOTMOVE(server)); + (robotMovePending( server ) && !POSTPONEROBOTMOVE(server, xwe)); } break; @@ -1649,7 +1652,7 @@ server_do( ServerCtxt* server, XWEnv xwe ) } /* switch */ if ( moreToDo ) { - util_requestTime( server->vol.util ); + util_requestTime( server->vol.util, xwe ); } server->serverDoing = XP_FALSE; @@ -1872,7 +1875,7 @@ client_readInitialMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) #ifdef STREAM_VERS_BIGBOARD if ( '\0' != rmtDictName[0] ) { const XP_UCHAR* ourName = dict_getShortName( curDict ); - util_informNetDict( server->vol.util, + util_informNetDict( server->vol.util, xwe, dict_getLangCode( curDict ), ourName, rmtDictName, rmtDictSum, localGI.phoniesAction ); @@ -1880,7 +1883,7 @@ client_readInitialMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) #endif } else { model_setDictionary( model, xwe, newDict ); - util_userError( server->vol.util, ERR_SERVER_DICT_WINS ); + util_userError( server->vol.util, xwe, ERR_SERVER_DICT_WINS ); clearLocalRobots( server ); } dict_unref( newDict, xwe ); /* new owner will have ref'd */ @@ -1905,7 +1908,7 @@ client_readInitialMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) XP_LOGF( "%s: got %d tiles for player %d", __func__, tiles.nTiles, ii ); if ( inDuplicateMode(server ) ) { - model_assignDupeTiles( model, &tiles ); + model_assignDupeTiles( model, xwe, &tiles ); break; } else { model_assignPlayerTiles( model, ii, &tiles ); @@ -1920,8 +1923,8 @@ client_readInitialMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) /* Give board a chance to redraw self with the full compliment of known players */ - setTurn( server, 0 ); - dupe_resetTimer( server ); + setTurn( server, xwe, 0 ); + dupe_resetTimer( server, xwe ); } else { XP_LOGF( "%s: wanted 0; got %d", __func__, server->nv.addresses[0].channelNo ); @@ -1976,7 +1979,7 @@ sendInitialMessage( ServerCtxt* server, XWEnv xwe ) XP_ASSERT( server->nv.nDevices > 1 ); for ( XP_U16 deviceIndex = 1; deviceIndex < server->nv.nDevices; ++deviceIndex ) { - XWStreamCtxt* stream = messageStreamWithHeader( server, deviceIndex, + XWStreamCtxt* stream = messageStreamWithHeader( server, xwe, deviceIndex, XWPROTO_CLIENT_SETUP ); XP_ASSERT( !!stream ); @@ -2017,7 +2020,7 @@ sendInitialMessage( ServerCtxt* server, XWEnv xwe ) non-initial messages will have a non-0 connID. */ comms_setConnID( server->vol.comms, gameID ); - dupe_resetTimer( server ); + dupe_resetTimer( server, xwe ); } /* sendInitialMessage */ #endif @@ -2100,14 +2103,14 @@ codeToStr( XW_Proto code ) #endif static XWStreamCtxt* -messageStreamWithHeader( ServerCtxt* server, XP_U16 devIndex, XW_Proto code ) +messageStreamWithHeader( ServerCtxt* server, XWEnv xwe, XP_U16 devIndex, XW_Proto code ) { XWStreamCtxt* stream; XP_PlayerAddr channelNo = server->nv.addresses[devIndex].channelNo; PRINTCODE( "making", code ); - stream = util_makeStreamFromAddr( server->vol.util, channelNo ); + stream = util_makeStreamFromAddr( server->vol.util, xwe, channelNo ); stream_open( stream ); writeProto( server, stream, code ); @@ -2121,7 +2124,7 @@ sendBadWordMsgs( ServerCtxt* server, XWEnv xwe ) if ( server->illegalWordInfo.nWords > 0 ) { /* fail gracefully */ XWStreamCtxt* stream = - messageStreamWithHeader( server, server->lastMoveSource, + messageStreamWithHeader( server, xwe, server->lastMoveSource, XWPROTO_BADWORD_INFO ); stream_putBits( stream, PLAYERNUM_NBITS, server->nv.currentTurn ); @@ -2140,7 +2143,7 @@ sendBadWordMsgs( ServerCtxt* server, XWEnv xwe ) #endif static void -badWordMoveUndoAndTellUser( ServerCtxt* server, BadWordInfo* bwi ) +badWordMoveUndoAndTellUser( ServerCtxt* server, XWEnv xwe, BadWordInfo* bwi ) { XP_U16 turn; ModelCtxt* model = server->vol.model; @@ -2148,9 +2151,9 @@ badWordMoveUndoAndTellUser( ServerCtxt* server, BadWordInfo* bwi ) them the move's rejected. Then undo it on this side, replacing it with model_commitRejectedPhony(); */ - model_rejectPreviousMove( model, server->pool, &turn ); + model_rejectPreviousMove( model, xwe, server->pool, &turn ); - util_notifyIllegalWords( server->vol.util, bwi, turn, XP_TRUE ); + util_notifyIllegalWords( server->vol.util, xwe, bwi, turn, XP_TRUE ); } /* badWordMoveUndoAndTellUser */ EngineCtxt* @@ -2279,15 +2282,15 @@ curTrayAsTexts( ServerCtxt* server, XP_U16 turn, const TrayTileSet* notInTray, * meaning the remainder should be assigned randomly as usual. */ XP_Bool -server_askPickTiles( ServerCtxt* server, XP_U16 turn, TrayTileSet* newTiles, - XP_U16 nToPick ) +server_askPickTiles( ServerCtxt* server, XWEnv xwe, XP_U16 turn, + TrayTileSet* newTiles, XP_U16 nToPick ) { /* May want to allow the host to pick tiles even in duplicate mode. Not sure how that'll work! PENDING */ XP_Bool asked = newTiles == NULL && !inDuplicateMode(server) && server->vol.gi->allowPickTiles; if ( asked ) { - asked = informNeedPickTiles( server, XP_FALSE, turn, nToPick ); + asked = informNeedPickTiles( server, xwe, XP_FALSE, turn, nToPick ); } return asked; } @@ -2299,7 +2302,7 @@ server_askPickTiles( ServerCtxt* server, XP_U16 turn, TrayTileSet* newTiles, * considering, and see if the engine can find moves. */ static XP_Bool -dupe_trayAllowsMoves( ServerCtxt* server, XP_U16 turn, +dupe_trayAllowsMoves( ServerCtxt* server, XWEnv xwe, XP_U16 turn, const Tile* tiles, XP_U16 nTiles ) { ModelCtxt* model = server->vol.model; @@ -2316,7 +2319,7 @@ dupe_trayAllowsMoves( ServerCtxt* server, XP_U16 turn, XP_Bool canMove; MoveInfo newMove = {0}; XP_U16 score = 0; - XP_Bool result = engine_findMove( engine, server->vol.model, turn, + XP_Bool result = engine_findMove( engine, xwe, server->vol.model, turn, XP_TRUE, XP_TRUE, tmpTiles, nTiles + nInTray, XP_FALSE, 0, #ifdef XWFEATURE_SEARCHLIMIT @@ -2341,7 +2344,7 @@ dupe_trayAllowsMoves( ServerCtxt* server, XP_U16 turn, * cancels. Otherwise, and after cancel, pick for 'im. */ static void -fetchTiles( ServerCtxt* server, XP_U16 playerNum, XP_U16 nToFetch, +fetchTiles( ServerCtxt* server, XWEnv xwe, XP_U16 playerNum, XP_U16 nToFetch, const TrayTileSet* tradedTiles, TrayTileSet* resultTiles ) { XP_ASSERT( server->vol.gi->serverRole != SERVER_ISCLIENT || !inDuplicateMode(server) ); @@ -2421,7 +2424,7 @@ fetchTiles( ServerCtxt* server, XP_U16 playerNum, XP_U16 nToFetch, if ( !inDuplicateMode( server ) ) { break; - } else if ( dupe_trayAllowsMoves( server, playerNum, &resultTiles->tiles[0], + } else if ( dupe_trayAllowsMoves( server, xwe, playerNum, &resultTiles->tiles[0], nSoFar + nLeft ) || ++nBadTrays >= 5 ) { break; @@ -2448,7 +2451,7 @@ makePoolOnce( ServerCtxt* server ) } static XP_Bool -assignTilesToAll( ServerCtxt* server ) +assignTilesToAll( ServerCtxt* server, XWEnv xwe ) { LOG_FUNC(); XP_Bool allDone = XP_TRUE; @@ -2480,19 +2483,19 @@ assignTilesToAll( ServerCtxt* server ) for ( ii = 0; ii < nPlayers; ++ii ) { if ( 0 == model_getNumTilesInTray( model, ii ) ) { if ( pickingTiles && !LP_IS_ROBOT(&gi->players[ii]) - && informNeedPickTiles( server, XP_TRUE, ii, + && informNeedPickTiles( server, xwe, XP_TRUE, ii, MAX_TRAY_TILES ) ) { allDone = XP_FALSE; break; } if ( 0 == ii || !gi->inDuplicateMode ) { newTiles.nTiles = 0; - fetchTiles( server, ii, numAssigned, NULL, &newTiles ); + fetchTiles( server, xwe, ii, numAssigned, NULL, &newTiles ); } if ( gi->inDuplicateMode ) { XP_ASSERT( ii == DUP_PLAYER ); - model_assignDupeTiles( model, &newTiles ); + model_assignDupeTiles( model, xwe, &newTiles ); break; } else { model_assignPlayerTiles( model, ii, &newTiles ); @@ -2519,7 +2522,7 @@ getPlayerTime( ServerCtxt* server, XWStreamCtxt* stream, XP_U16 turn ) #endif static void -nextTurn( ServerCtxt* server, XP_S16 nxtTurn ) +nextTurn( ServerCtxt* server, XWEnv xwe, XP_S16 nxtTurn ) { XP_LOGFF( "(nxtTurn=%d)", nxtTurn ); CurGameInfo* gi = server->vol.gi; @@ -2554,7 +2557,7 @@ nextTurn( ServerCtxt* server, XP_S16 nxtTurn ) SETSTATE( server, XWSTATE_INTURN ); /* even if game over, if undoing */ if ( playerTilesLeft && NPASSES_OK(server) ){ - setTurn( server, nxtTurn ); + setTurn( server, xwe, nxtTurn ); } else { /* I discover that the game should end. If I'm the client, though, should I wait for the server to deduce this and send @@ -2565,7 +2568,7 @@ nextTurn( ServerCtxt* server, XP_S16 nxtTurn ) moreToDo = XP_TRUE; } else if ( currentTurn >= 0 ) { XP_LOGFF( "Doing nothing; waiting for server to end game" ); - setTurn( server, -1 ); + setTurn( server, xwe, -1 ); /* I'm the client. Do ++nothing++. */ } } @@ -2583,16 +2586,16 @@ nextTurn( ServerCtxt* server, XP_S16 nxtTurn ) server_resetEngines( server ); XP_ASSERT( server->nv.gameState != XWSTATE_GAMEOVER ); - callTurnChangeListener( server ); - util_turnChanged( server->vol.util, server->nv.currentTurn ); + callTurnChangeListener( server, xwe ); + util_turnChanged( server->vol.util, xwe, server->nv.currentTurn ); - if ( robotMovePending(server) && !POSTPONEROBOTMOVE(server) ) { + if ( robotMovePending(server) && !POSTPONEROBOTMOVE(server, xwe) ) { moreToDo = XP_TRUE; } exit: if ( moreToDo ) { - util_requestTime( server->vol.util ); + util_requestTime( server->vol.util, xwe ); } } /* nextTurn */ @@ -2666,7 +2669,7 @@ sendMoveTo( ServerCtxt* server, XWEnv xwe, XP_U16 devIndex, XP_U16 turn, XW_Proto code = gi->serverRole == SERVER_ISCLIENT? XWPROTO_MOVEMADE_INFO_CLIENT : XWPROTO_MOVEMADE_INFO_SERVER; - XWStreamCtxt* stream = messageStreamWithHeader( server, devIndex, code ); + XWStreamCtxt* stream = messageStreamWithHeader( server, xwe, devIndex, code ); #ifdef STREAM_VERS_BIGBOARD XP_U16 version = stream_getVersion( stream ); @@ -2712,7 +2715,7 @@ sendMoveTo( ServerCtxt* server, XWEnv xwe, XP_U16 devIndex, XP_U16 turn, } /* sendMoveTo */ static XP_Bool -readMoveInfo( ServerCtxt* server, XWStreamCtxt* stream, +readMoveInfo( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream, XP_U16* whoMovedP, XP_Bool* isTradeP, TrayTileSet* newTiles, TrayTileSet* tradedTiles, XP_Bool* legalP, XP_Bool* badStackP ) @@ -2726,7 +2729,7 @@ readMoveInfo( ServerCtxt* server, XWStreamCtxt* stream, if ( STREAM_VERS_BIGBOARD <= stream_getVersion( stream ) ) { XP_U32 hashReceived = stream_getU32( stream ); success = model_hashMatches( server->vol.model, hashReceived ) - || model_popToHash( server->vol.model, hashReceived, server->pool ); + || model_popToHash( server->vol.model, xwe, hashReceived, server->pool ); if ( !success ) { XP_LOGFF( "hash mismatch: %X not found", hashReceived ); @@ -2753,7 +2756,7 @@ readMoveInfo( ServerCtxt* server, XWStreamCtxt* stream, } else { legalMove = stream_getBits( stream, 1 ); success = model_makeTurnFromStream( server->vol.model, - whoMoved, stream ); + xwe, whoMoved, stream ); getPlayerTime( server, stream, whoMoved ); } @@ -2784,13 +2787,13 @@ sendMoveToClientsExcept( ServerCtxt* server, XWEnv xwe, XP_U16 whoMoved, XP_Bool } /* sendMoveToClientsExcept */ static XWStreamCtxt* -makeTradeReportIf( ServerCtxt* server, const TrayTileSet* tradedTiles ) +makeTradeReportIf( ServerCtxt* server, XWEnv xwe, const TrayTileSet* tradedTiles ) { XWStreamCtxt* stream = NULL; if ( inDuplicateMode(server) || server->nv.showRobotScores ) { XP_UCHAR tradeBuf[64]; const XP_UCHAR* tradeStr = - dutil_getUserQuantityString( server->vol.dutil, STRD_ROBOT_TRADED, + dutil_getUserQuantityString( server->vol.dutil, xwe, STRD_ROBOT_TRADED, tradedTiles->nTiles ); XP_SNPRINTF( tradeBuf, sizeof(tradeBuf), tradeStr, tradedTiles->nTiles ); @@ -2839,7 +2842,7 @@ reflectMoveAndInform( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) XP_ASSERT( gi->serverRole == SERVER_ISSERVER ); XP_Bool badStack = XP_FALSE; - success = readMoveInfo( server, stream, &whoMoved, &isTrade, &newTiles, + success = readMoveInfo( server, xwe, stream, &whoMoved, &isTrade, &newTiles, &tradedTiles, &isLegalMove, &badStack ); /* modifies model */ XP_ASSERT( !success || isLegalMove ); /* client should always report as true */ isLegalMove = XP_TRUE; @@ -2854,7 +2857,7 @@ reflectMoveAndInform( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) pool_replaceTiles( server->pool, &tradedTiles ); server->vol.showPrevMove = XP_TRUE; - mvStream = makeTradeReportIf( server, &tradedTiles ); + mvStream = makeTradeReportIf( server, xwe, &tradedTiles ); } else { nTilesMoved = model_getCurrentMoveCount( model, whoMoved ); @@ -2884,7 +2887,7 @@ reflectMoveAndInform( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) SETSTATE( server, XWSTATE_MOVE_CONFIRM_MUSTSEND ); doRequest = XP_TRUE; } else if ( nTilesLeft > 0 ) { - nextTurn( server, PICK_NEXT ); + nextTurn( server, xwe, PICK_NEXT ); } else { SETSTATE(server, XWSTATE_NEEDSEND_ENDGAME ); doRequest = XP_TRUE; @@ -2907,7 +2910,7 @@ reflectMoveAndInform( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) } if ( doRequest ) { - util_requestTime( server->vol.util ); + util_requestTime( server->vol.util, xwe ); } } else if ( badStack ) { success = XP_TRUE; /* so we don't reject the move forever */ @@ -2934,8 +2937,8 @@ reflectMove( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) XP_LOGFF( "BAD: game state: %s, not XWSTATE_INTURN", getStateStr(server->nv.gameState ) ); } else if ( server->nv.currentTurn < 0 ) { XP_LOGFF( "BAD: currentTurn %d < 0", server->nv.currentTurn ); - } else if ( ! readMoveInfo( server, stream, &whoMoved, &isTrade, &newTiles, - &tradedTiles, &isLegal, &badStack ) ) { /* modifies model */ + } else if ( ! readMoveInfo( server, xwe, stream, &whoMoved, &isTrade, + &newTiles, &tradedTiles, &isLegal, &badStack ) ) { /* modifies model */ XP_LOGFF( "BAD: readMoveInfo() failed" ); } else { moveOk = XP_TRUE; @@ -2947,7 +2950,7 @@ reflectMove( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) pool_replaceTiles( server->pool, &tradedTiles ); server->vol.showPrevMove = XP_TRUE; - mvStream = makeTradeReportIf( server, &tradedTiles ); + mvStream = makeTradeReportIf( server, xwe, &tradedTiles ); } else { server->vol.showPrevMove = XP_TRUE; mvStream = makeMoveReportIf( server, xwe, &wordsStream ); @@ -2965,7 +2968,7 @@ reflectMove( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) if ( !isLegal ) { XP_ASSERT( server->vol.gi->serverRole == SERVER_ISCLIENT ); - handleIllegalWord( server, stream ); + handleIllegalWord( server, xwe, stream ); } } else if ( badStack ) { moveOk = XP_TRUE; @@ -3079,7 +3082,7 @@ static void sendStreamToDev( ServerCtxt* server, XWEnv xwe, XP_U16 dev, XW_Proto code, XWStreamCtxt* data ) { - XWStreamCtxt* stream = messageStreamWithHeader( server, dev, code ); + XWStreamCtxt* stream = messageStreamWithHeader( server, xwe, dev, code ); const XP_U16 dataLen = stream_getSize( data ); const XP_U8* dataPtr = stream_getPtr( data ); stream_putBytes( stream, dataPtr, dataLen ); @@ -3098,19 +3101,19 @@ dupe_makeAndReportTrade( ServerCtxt* server, XWEnv xwe ) PoolContext* pool = server->pool; ModelCtxt* model = server->vol.model; - model_resetCurrentTurn( model, DUP_PLAYER ); + model_resetCurrentTurn( model, xwe, DUP_PLAYER ); TrayTileSet oldTiles = *model_getPlayerTiles( model, DUP_PLAYER ); model_removePlayerTiles( model, DUP_PLAYER, &oldTiles ); pool_replaceTiles( pool, &oldTiles ); TrayTileSet newTiles = {0}; - fetchTiles( server, DUP_PLAYER, oldTiles.nTiles, NULL, &newTiles ); + fetchTiles( server, xwe, DUP_PLAYER, oldTiles.nTiles, NULL, &newTiles ); model_commitDupeTrade( model, &oldTiles, &newTiles ); model_addNewTiles( model, DUP_PLAYER, &newTiles ); - updateOthersTiles( server ); + updateOthersTiles( server, xwe ); if ( server->vol.gi->serverRole == SERVER_ISSERVER ) { XWStreamCtxt* tmpStream = @@ -3130,9 +3133,9 @@ dupe_makeAndReportTrade( ServerCtxt* server, XWEnv xwe ) stream_destroy( tmpStream, xwe ); } - dupe_resetTimer( server ); + dupe_resetTimer( server, xwe ); - dupe_setupShowTrade( server, newTiles.nTiles ); + dupe_setupShowTrade( server, xwe, newTiles.nTiles ); LOG_RETURN_VOID(); } /* dupe_makeAndReportTrade */ @@ -3190,7 +3193,7 @@ dupe_receivePause( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) dupe_clearState( server ); } - setDupTimerExpires( server, (XP_S32)stream_getU32( stream ) ); + setDupTimerExpires( server, xwe, (XP_S32)stream_getU32( stream ) ); XP_UCHAR* msg = NULL; if ( AUTOPAUSED != pauseType ) { @@ -3204,14 +3207,14 @@ dupe_receivePause( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) dupe_transmitPause( server, xwe, pauseType, turn, msg, senderDev ); } - model_noteDupePause( server->vol.model, pauseType, turn, msg ); - callTurnChangeListener( server ); + model_noteDupePause( server->vol.model, xwe, pauseType, turn, msg ); + callTurnChangeListener( server, xwe ); const XP_UCHAR* name = NULL; if ( AUTOPAUSED != pauseType ) { name = gi->players[turn].name; } - dutil_notifyPause( server->vol.dutil, gi->gameID, pauseType, turn, + dutil_notifyPause( server->vol.dutil, xwe, gi->gameID, pauseType, turn, name, msg ); XP_FREEP( server->mpool, &msg ); @@ -3234,7 +3237,7 @@ dupe_handleStuff( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) accepted = !isServer && dupe_handleServerMoves( server, xwe, stream ); break; case DUPE_STUFF_TRADES_SERVER: - accepted = !isServer && dupe_handleServerTrade( server, stream ); + accepted = !isServer && dupe_handleServerTrade( server, xwe, stream ); break; case DUPE_STUFF_PAUSE: accepted = dupe_receivePause( server, xwe, stream ); @@ -3259,16 +3262,16 @@ dupe_commitAndReportMove( ServerCtxt* server, XWEnv xwe, XP_U16 winner, model_currentMoveToMoveInfo( model, winner, &moveInfo ); TrayTileSet newTiles = {0}; - fetchTiles( server, winner, nTiles, NULL, &newTiles ); + fetchTiles( server, xwe, winner, nTiles, NULL, &newTiles ); for ( XP_U16 player = 0; player < nPlayers; ++player ) { - model_resetCurrentTurn( model, player ); + model_resetCurrentTurn( model, xwe, player ); } model_commitDupeTurn( model, xwe, &moveInfo, nPlayers, scores, &newTiles ); - updateOthersTiles( server ); + updateOthersTiles( server, xwe ); if ( server->vol.gi->serverRole == SERVER_ISSERVER ) { XWStreamCtxt* tmpStream = @@ -3292,16 +3295,16 @@ dupe_commitAndReportMove( ServerCtxt* server, XWEnv xwe, XP_U16 winner, stream_destroy( tmpStream, xwe ); } - dupe_resetTimer( server ); + dupe_resetTimer( server, xwe ); - dupe_setupShowMove( server, scores ); + dupe_setupShowMove( server, xwe, scores ); } /* dupe_commitAndReportMove */ static void dupe_forceCommits( ServerCtxt* server, XWEnv xwe ) { if ( dupe_timerRunning() ) { - XP_U32 now = dutil_getCurSeconds( server->vol.dutil ); + XP_U32 now = dutil_getCurSeconds( server->vol.dutil, xwe ); if ( server->nv.dupTimerExpires <= now ) { ModelCtxt* model = server->vol.model; @@ -3310,7 +3313,7 @@ dupe_forceCommits( ServerCtxt* server, XWEnv xwe ) && !server->nv.dupTurnsMade[ii] ) { if ( !model_checkMoveLegal( model, xwe, ii, (XWStreamCtxt*)NULL, (WordNotifierInfo*)NULL ) ) { - model_resetCurrentTurn( model, ii ); + model_resetCurrentTurn( model, xwe, ii ); } commitMoveImpl( server, xwe, ii, NULL, XP_TRUE ); } @@ -3373,7 +3376,7 @@ dupe_checkTurns( ServerCtxt* server, XWEnv xwe ) } else if ( ! server->nv.dupTurnsSent ) { /* I need to send info for local players to host */ XWStreamCtxt* stream = - messageStreamWithHeader( server, SERVER_DEVICE, + messageStreamWithHeader( server, xwe, SERVER_DEVICE, XWPROTO_DUPE_STUFF ); addDupeStuffMark( stream, DUPE_STUFF_MOVE_CLIENT ); @@ -3401,7 +3404,7 @@ dupe_checkTurns( ServerCtxt* server, XWEnv xwe ) } /* dupe_checkTurns */ static void -dupe_postStatus( const ServerCtxt* server, XP_Bool allDone ) +dupe_postStatus( const ServerCtxt* server, XWEnv xwe, XP_Bool allDone ) { /* Standalone case: say nothing here. Should be self evident what's up.*/ @@ -3420,7 +3423,7 @@ dupe_postStatus( const ServerCtxt* server, XP_Bool allDone ) break; case SERVER_ISCLIENT: if ( allDone ) { - const XP_UCHAR* fmt = dutil_getUserString( server->vol.dutil, + const XP_UCHAR* fmt = dutil_getUserString( server->vol.dutil, xwe, STR_DUP_CLIENT_SENT ); XP_SNPRINTF( buf, VSIZE(buf), "%s", fmt ); } @@ -3434,7 +3437,7 @@ dupe_postStatus( const ServerCtxt* server, XP_Bool allDone ) ++nHere; } } - const XP_UCHAR* fmt = dutil_getUserString( server->vol.dutil, + const XP_UCHAR* fmt = dutil_getUserString( server->vol.dutil, xwe, STRDD_DUP_HOST_RECEIVED ); XP_SNPRINTF( buf, VSIZE(buf), fmt, nHere, server->vol.gi->nPlayers ); } @@ -3442,7 +3445,7 @@ dupe_postStatus( const ServerCtxt* server, XP_Bool allDone ) if ( !!buf[0] ) { XP_LOGF( "%s(): msg=%s", __func__, buf ); - util_notifyDupStatus( server->vol.util, amHost, buf ); + util_notifyDupStatus( server->vol.util, xwe, amHost, buf ); } } @@ -3456,8 +3459,8 @@ dupe_storeTurn( ServerCtxt* server, XWEnv xwe, XP_U16 turn, XP_Bool forced ) server->nv.dupTurnsForced[turn] = forced; XP_Bool allDone = dupe_checkTurns( server, xwe ); - dupe_postStatus( server, allDone ); - nextTurn( server, PICK_NEXT ); + dupe_postStatus( server, xwe, allDone ); + nextTurn( server, xwe, PICK_NEXT ); XP_LOGF( "%s(): player %d now has %d tiles", __func__, turn, model_getNumTilesInTray( server->vol.model, turn ) ); @@ -3569,7 +3572,7 @@ finishMove( ServerCtxt* server, XWEnv xwe, TrayTileSet* newTiles, XP_U16 turn ) server->vol.pickTilesCalled[turn] = XP_FALSE; XP_U16 nTilesMoved = model_getCurrentMoveCount( model, turn ); - fetchTiles( server, turn, nTilesMoved, NULL, newTiles ); + fetchTiles( server, xwe, turn, nTilesMoved, NULL, newTiles ); XP_Bool isClient = gi->serverRole == SERVER_ISCLIENT; XP_Bool isLegalMove = XP_TRUE; @@ -3591,7 +3594,7 @@ finishMove( ServerCtxt* server, XWEnv xwe, TrayTileSet* newTiles, XP_U16 turn ) sortTilesIf( server, turn ); if ( !isLegalMove && !isClient ) { - badWordMoveUndoAndTellUser( server, &server->illegalWordInfo ); + badWordMoveUndoAndTellUser( server, xwe, &server->illegalWordInfo ); /* It's ok to free these guys. I'm the server, and the move was made here, so I've notified all clients already by setting the flag (and passing the word) in sendMoveToClientsExcept. */ @@ -3603,10 +3606,10 @@ finishMove( ServerCtxt* server, XWEnv xwe, TrayTileSet* newTiles, XP_U16 turn ) } else if (isClient && (gi->phoniesAction == PHONIES_DISALLOW) && nTilesMoved > 0 ) { SETSTATE( server, XWSTATE_MOVE_CONFIRM_WAIT ); - setTurn( server, -1 ); + setTurn( server, xwe, -1 ); #endif } else { - nextTurn( server, PICK_NEXT ); + nextTurn( server, xwe, PICK_NEXT ); } XP_LOGFF( "player %d now has %d tiles", turn, model_getNumTilesInTray( model, turn ) ); @@ -3622,7 +3625,7 @@ server_commitTrade( ServerCtxt* server, XWEnv xwe, const TrayTileSet* oldTiles, } XP_U16 turn = server->nv.currentTurn; - fetchTiles( server, turn, oldTiles->nTiles, oldTiles, &newTiles ); + fetchTiles( server, xwe, turn, oldTiles->nTiles, oldTiles, &newTiles ); #ifndef XWFEATURE_STANDALONE_ONLY if ( server->vol.gi->serverRole == SERVER_ISCLIENT ) { @@ -3639,7 +3642,7 @@ server_commitTrade( ServerCtxt* server, XWEnv xwe, const TrayTileSet* oldTiles, model_makeTileTrade( server->vol.model, turn, oldTiles, &newTiles ); sortTilesIf( server, turn ); - nextTurn( server, PICK_NEXT ); + nextTurn( server, xwe, PICK_NEXT ); return XP_TRUE; } /* server_commitTrade */ @@ -3725,14 +3728,14 @@ server_getLastMoveTime( const ServerCtxt* server ) } static void -doEndGame( ServerCtxt* server, XP_S16 quitter ) +doEndGame( ServerCtxt* server, XWEnv xwe, XP_S16 quitter ) { XP_ASSERT( quitter < server->vol.gi->nPlayers ); SETSTATE( server, XWSTATE_GAMEOVER ); - setTurn( server, -1 ); + setTurn( server, xwe, -1 ); server->nv.quitter = quitter; - (*server->vol.gameOverListener)( server->vol.gameOverData, quitter ); + (*server->vol.gameOverListener)( xwe, server->vol.gameOverData, quitter ); } /* doEndGame */ static void @@ -3770,18 +3773,18 @@ endGameInternal( ServerCtxt* server, XWEnv xwe, GameEndReason XP_UNUSED(why), XP_U16 devIndex; for ( devIndex = 1; devIndex < server->nv.nDevices; ++devIndex ) { XWStreamCtxt* stream; - stream = messageStreamWithHeader( server, devIndex, + stream = messageStreamWithHeader( server, xwe, devIndex, XWPROTO_END_GAME ); putQuitter( server, stream, quitter ); stream_destroy( stream, xwe ); } #endif - doEndGame( server, quitter ); + doEndGame( server, xwe, quitter ); #ifndef XWFEATURE_STANDALONE_ONLY } else { XWStreamCtxt* stream; - stream = messageStreamWithHeader( server, SERVER_DEVICE, + stream = messageStreamWithHeader( server, xwe, SERVER_DEVICE, XWPROTO_CLIENT_REQ_END_GAME ); putQuitter( server, stream, quitter ); stream_destroy( stream, xwe ); @@ -3831,7 +3834,7 @@ tileCountsOk( const ServerCtxt* server ) } /* tileCountsOk */ static void -setTurn( ServerCtxt* server, XP_S16 turn ) +setTurn( ServerCtxt* server, XWEnv xwe, XP_S16 turn ) { XP_ASSERT( -1 == turn || (!amServer(server) || (0 == server->nv.pendingRegistrations))); @@ -3846,8 +3849,8 @@ setTurn( ServerCtxt* server, XP_S16 turn ) XP_ASSERT( turn == model_getNextTurn( server->vol.model ) ); } server->nv.currentTurn = turn; - server->nv.lastMoveTime = dutil_getCurSeconds( server->vol.dutil ); - callTurnChangeListener( server ); + server->nv.lastMoveTime = dutil_getCurSeconds( server->vol.dutil, xwe ); + callTurnChangeListener( server, xwe ); } } @@ -3856,7 +3859,7 @@ static void tellMoveWasLegal( ServerCtxt* server, XWEnv xwe ) { XWStreamCtxt* stream = - messageStreamWithHeader( server, server->lastMoveSource, + messageStreamWithHeader( server, xwe, server->lastMoveSource, XWPROTO_MOVE_CONFIRM ); stream_destroy( stream, xwe ); @@ -3865,14 +3868,14 @@ tellMoveWasLegal( ServerCtxt* server, XWEnv xwe ) } /* tellMoveWasLegal */ static XP_Bool -handleIllegalWord( ServerCtxt* server, XWStreamCtxt* incoming ) +handleIllegalWord( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* incoming ) { BadWordInfo bwi; (void)stream_getBits( incoming, PLAYERNUM_NBITS ); bwiFromStream( MPPARM(server->mpool) incoming, &bwi ); - badWordMoveUndoAndTellUser( server, &bwi ); + badWordMoveUndoAndTellUser( server, xwe, &bwi ); freeBWI( MPPARM(server->mpool) &bwi ); @@ -3881,14 +3884,14 @@ handleIllegalWord( ServerCtxt* server, XWStreamCtxt* incoming ) } /* handleIllegalWord */ static XP_Bool -handleMoveOk( ServerCtxt* server, XWStreamCtxt* XP_UNUSED(incoming) ) +handleMoveOk( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* XP_UNUSED(incoming) ) { XP_Bool accepted = XP_TRUE; XP_ASSERT( server->vol.gi->serverRole == SERVER_ISCLIENT ); XP_ASSERT( server->nv.gameState == XWSTATE_MOVE_CONFIRM_WAIT ); SETSTATE( server, XWSTATE_INTURN ); - nextTurn( server, PICK_CUR ); + nextTurn( server, xwe, PICK_CUR ); return accepted; } /* handleMoveOk */ @@ -3902,7 +3905,7 @@ sendUndoTo( ServerCtxt* server, XWEnv xwe, XP_U16 devIndex, XP_U16 nUndone, XW_Proto code = gi->serverRole == SERVER_ISCLIENT? XWPROTO_UNDO_INFO_CLIENT : XWPROTO_UNDO_INFO_SERVER; - stream = messageStreamWithHeader( server, devIndex, code ); + stream = messageStreamWithHeader( server, xwe, devIndex, code ); stream_putU16( stream, nUndone ); stream_putU16( stream, lastUndone ); @@ -3943,11 +3946,11 @@ reflectUndos( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream, XW_Proto code XP_ASSERT( 0 == stream_getSize( stream ) ); if ( 0 == newHash ) { - success = model_undoLatestMoves( model, server->pool, nUndone, &turn, + success = model_undoLatestMoves( model, xwe, server->pool, nUndone, &turn, &lastUndone ); XP_ASSERT( turn == model_getNextTurn( model ) ); } else { - success = model_popToHash( model, newHash, server->pool ); + success = model_popToHash( model, xwe, newHash, server->pool ); turn = model_getNextTurn( model ); } @@ -3962,8 +3965,8 @@ reflectUndos( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream, XW_Proto code lastUndone, newHash ); } - util_informUndo( server->vol.util ); - nextTurn( server, turn ); + util_informUndo( server->vol.util, xwe ); + nextTurn( server, xwe, turn ); } else { XP_LOGFF( "unable to pop to hash %X; dropping", newHash ); // XP_ASSERT(0); @@ -3996,7 +3999,7 @@ server_handleUndo( ServerCtxt* server, XWEnv xwe, XP_U16 limit ) there, and it will immediately move again. */ for ( ; ; ) { XP_S16 moveNum = -1; /* don't need it checked */ - if ( !model_undoLatestMoves( model, server->pool, 1, &lastTurnUndone, + if ( !model_undoLatestMoves( model, xwe, server->pool, 1, &lastTurnUndone, &moveNum ) ) { break; } @@ -4024,11 +4027,11 @@ server_handleUndo( ServerCtxt* server, XWEnv xwe, XP_U16 limit ) } #endif sortTilesIf( server, lastTurnUndone ); - nextTurn( server, lastTurnUndone ); + nextTurn( server, xwe, lastTurnUndone ); } else { /* I'm a bit nervous about this. Is this the ONLY thing that cause nUndone to come back 0? */ - util_userError( server->vol.util, ERR_CANT_UNDO_TILEASSIGN ); + util_userError( server->vol.util, xwe, ERR_CANT_UNDO_TILEASSIGN ); } LOG_RETURNF( "%s", boolToStr(result) ); @@ -4086,7 +4089,7 @@ server_receiveMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* incoming ) once the game's in progress and communication's been established. */ XP_LOGF( "%s: somebody's registering!!!", __func__ ); - accepted = handleRegistrationMsg( server, incoming ); + accepted = handleRegistrationMsg( server, xwe, incoming ); } else { XP_LOGFF( "WTF: I'm not a server!!" ); } @@ -4120,7 +4123,7 @@ server_receiveMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* incoming ) accepted = reflectMove( server, xwe, incoming ); } if ( accepted ) { - nextTurn( server, PICK_NEXT ); + nextTurn( server, xwe, PICK_NEXT ); } else { accepted = XP_TRUE; /* don't stall.... */ XP_LOGFF( "dropping move: state=%s", getStateStr(server->nv.gameState ) ); @@ -4134,14 +4137,14 @@ server_receiveMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* incoming ) break; case XWPROTO_BADWORD_INFO: - accepted = handleIllegalWord( server, incoming ); + accepted = handleIllegalWord( server, xwe, incoming ); if ( accepted && server->nv.gameState != XWSTATE_GAMEOVER ) { - nextTurn( server, PICK_CUR ); + nextTurn( server, xwe, PICK_CUR ); } break; case XWPROTO_MOVE_CONFIRM: - accepted = handleMoveOk( server, incoming ); + accepted = handleMoveOk( server, xwe, incoming ); break; case XWPROTO_CLIENT_REQ_END_GAME: { @@ -4154,7 +4157,7 @@ server_receiveMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* incoming ) case XWPROTO_END_GAME: { XP_S8 quitter; getQuitter( server, incoming, &quitter ); - doEndGame( server, quitter ); + doEndGame( server, xwe, quitter ); accepted = XP_TRUE; } break; @@ -4178,14 +4181,14 @@ server_receiveMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* incoming ) #endif void -server_formatDictCounts( ServerCtxt* server, XWStreamCtxt* stream, +server_formatDictCounts( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream, XP_U16 nCols, XP_Bool allFaces ) { DictionaryCtxt* dict; Tile tile; XP_U16 nChars, nPrinted; XP_UCHAR buf[48]; - const XP_UCHAR* fmt = dutil_getUserString( server->vol.dutil, + const XP_UCHAR* fmt = dutil_getUserString( server->vol.dutil, xwe, STRS_VALUES_HEADER ); const XP_UCHAR* langName; @@ -4240,7 +4243,7 @@ server_formatDictCounts( ServerCtxt* server, XWStreamCtxt* stream, * pool. The idea is to show him what tiles are left in play. */ void -server_formatRemainingTiles( ServerCtxt* server, XWStreamCtxt* stream, +server_formatRemainingTiles( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream, XP_S16 player ) { PoolContext* pool = server->pool; @@ -4256,7 +4259,7 @@ server_formatRemainingTiles( ServerCtxt* server, XWStreamCtxt* stream, XP_ASSERT( !!server->vol.model ); - const XP_UCHAR* fmt = dutil_getUserQuantityString( server->vol.dutil, + const XP_UCHAR* fmt = dutil_getUserQuantityString( server->vol.dutil, xwe, STRD_REMAINS_HEADER, nLeft ); XP_SNPRINTF( buf, sizeof(buf), fmt, nLeft ); @@ -4296,7 +4299,7 @@ server_formatRemainingTiles( ServerCtxt* server, XWStreamCtxt* stream, XP_ASSERT( offset < sizeof(cntsBuf) ); } - fmt = dutil_getUserQuantityString( server->vol.dutil, STRD_REMAINS_EXPL, + fmt = dutil_getUserQuantityString( server->vol.dutil, xwe, STRD_REMAINS_EXPL, nLeft ); XP_SNPRINTF( buf, sizeof(buf), fmt, nLeft ); stream_catString( stream, buf ); @@ -4346,14 +4349,14 @@ printPlayer( const ServerCtxt* server, XWStreamCtxt* stream, XP_U16 index, XP_Bool firstDone = model_getNumTilesTotal( model, index ) == 0; XP_UCHAR tmpbuf[48]; XP_U16 addSubKey = firstDone? STRD_REMAINING_TILES_ADD : STRD_UNUSED_TILES_SUB; - const XP_UCHAR* addSubString = util_getUserString( server->vol.util, addSubKey ); + const XP_UCHAR* addSubString = util_getUserString( server->vol.util, xwe, addSubKey ); XP_UCHAR* timeStr = (XP_UCHAR*)""; XP_UCHAR timeBuf[16]; if ( gi->timerEnabled ) { XP_U16 penalty = player_timePenalty( gi, index ); if ( penalty > 0 ) { XP_SNPRINTF( timeBuf, sizeof(timeBuf), - util_getUserString( server->vol.util, + util_getUserString( server->vol.util, xwe, STRD_TIME_PENALTY_SUB ), penalty ); /* positive for formatting */ timeStr = timeBuf; @@ -4378,7 +4381,7 @@ printPlayer( const ServerCtxt* server, XWStreamCtxt* stream, XP_U16 index, #endif void -server_writeFinalScores( ServerCtxt* server, XWStreamCtxt* stream ) +server_writeFinalScores( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) { ScoresArray scores; ScoresArray tilePenalties; @@ -4386,9 +4389,9 @@ server_writeFinalScores( ServerCtxt* server, XWStreamCtxt* stream ) XP_S16 quitter = server->nv.quitter; XP_Bool quitterDone = XP_FALSE; ModelCtxt* model = server->vol.model; - const XP_UCHAR* addString = dutil_getUserString( server->vol.dutil, + const XP_UCHAR* addString = dutil_getUserString( server->vol.dutil, xwe, STRD_REMAINING_TILES_ADD ); - const XP_UCHAR* subString = dutil_getUserString( server->vol.dutil, + const XP_UCHAR* subString = dutil_getUserString( server->vol.dutil, xwe, STRD_UNUSED_TILES_SUB ); XP_UCHAR* timeStr; CurGameInfo* gi = server->vol.gi; @@ -4438,7 +4441,7 @@ server_writeFinalScores( ServerCtxt* server, XWStreamCtxt* stream ) XP_U16 penalty = player_timePenalty( gi, thisIndex ); if ( penalty > 0 ) { XP_SNPRINTF( timeBuf, sizeof(timeBuf), - dutil_getUserString( server->vol.dutil, + dutil_getUserString( server->vol.dutil, xwe, STRD_TIME_PENALTY_SUB ), penalty ); /* positive for formatting */ timeStr = timeBuf; @@ -4457,12 +4460,12 @@ server_writeFinalScores( ServerCtxt* server, XWStreamCtxt* stream ) const XP_UCHAR* name = emptyStringIfNull(gi->players[thisIndex].name); if ( 0 == placeKey ) { - const XP_UCHAR* fmt = dutil_getUserString( server->vol.dutil, + const XP_UCHAR* fmt = dutil_getUserString( server->vol.dutil, xwe, STRDSD_PLACER ); XP_SNPRINTF( buf, sizeof(buf), fmt, place, name, scores.arr[thisIndex] ); } else { - const XP_UCHAR* fmt = dutil_getUserString( server->vol.dutil, + const XP_UCHAR* fmt = dutil_getUserString( server->vol.dutil, xwe, placeKey ); XP_SNPRINTF( buf, sizeof(buf), fmt, name, scores.arr[thisIndex] ); diff --git a/xwords4/common/server.h b/xwords4/common/server.h index 870d341ad..ba5a35c28 100644 --- a/xwords4/common/server.h +++ b/xwords4/common/server.h @@ -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 ); diff --git a/xwords4/common/smsproto.c b/xwords4/common/smsproto.c index 5a24be852..45ac0732f 100644 --- a/xwords4/common/smsproto.c +++ b/xwords4/common/smsproto.c @@ -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 diff --git a/xwords4/common/smsproto.h b/xwords4/common/smsproto.h index e621121af..e62684ac4 100644 --- a/xwords4/common/smsproto.h +++ b/xwords4/common/smsproto.h @@ -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 diff --git a/xwords4/common/tray.c b/xwords4/common/tray.c index 37ad0d96d..d9a3e8410 100644 --- a/xwords4/common/tray.c +++ b/xwords4/common/tray.c @@ -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; diff --git a/xwords4/common/util.h b/xwords4/common/util.h index f13493047..be5f84d32 100644 --- a/xwords4/common/util.h +++ b/xwords4/common/util.h @@ -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 diff --git a/xwords4/linux/cursesboard.c b/xwords4/linux/cursesboard.c index 449763490..4d7755dff 100644 --- a/xwords4/linux/cursesboard.c +++ b/xwords4/linux/cursesboard.c @@ -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]; diff --git a/xwords4/linux/cursesmain.c b/xwords4/linux/cursesmain.c index c4734039d..9a0e13577 100644 --- a/xwords4/linux/cursesmain.c +++ b/xwords4/linux/cursesmain.c @@ -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 ); diff --git a/xwords4/linux/gtkboard.c b/xwords4/linux/gtkboard.c index c2199a8b3..c245333d5 100644 --- a/xwords4/linux/gtkboard.c +++ b/xwords4/linux/gtkboard.c @@ -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 ); diff --git a/xwords4/linux/gtkmain.c b/xwords4/linux/gtkmain.c index 8569c3fc6..aadbf5845 100644 --- a/xwords4/linux/gtkmain.c +++ b/xwords4/linux/gtkmain.c @@ -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 ); diff --git a/xwords4/linux/gtknewgame.c b/xwords4/linux/gtknewgame.c index b6ce195f0..a915afb08 100644 --- a/xwords4/linux/gtknewgame.c +++ b/xwords4/linux/gtknewgame.c @@ -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 ); diff --git a/xwords4/linux/lindutil.c b/xwords4/linux/lindutil.c index 492c8238b..72d384db9 100644 --- a/xwords4/linux/lindutil.c +++ b/xwords4/linux/lindutil.c @@ -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 ); diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index 4ba20844f..8b9cf9f7f 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -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 ); diff --git a/xwords4/linux/linuxsms.c b/xwords4/linux/linuxsms.c index 1680c6623..28b052dda 100644 --- a/xwords4/linux/linuxsms.c +++ b/xwords4/linux/linuxsms.c @@ -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 ); diff --git a/xwords4/linux/linuxutl.c b/xwords4/linux/linuxutl.c index 90ad61ddd..8176cbc47 100644 --- a/xwords4/linux/linuxutl.c +++ b/xwords4/linux/linuxutl.c @@ -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;