mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
parent
d293517e7c
commit
15a2897112
34 changed files with 155 additions and 182 deletions
|
@ -232,8 +232,7 @@ static void
|
||||||
splitFaces_via_java( JNIEnv* env, AndDictionaryCtxt* ctxt, const XP_U8* ptr,
|
splitFaces_via_java( JNIEnv* env, AndDictionaryCtxt* ctxt, const XP_U8* ptr,
|
||||||
int nFaceBytes, int nFaces, XP_Bool isUTF8 )
|
int nFaceBytes, int nFaces, XP_Bool isUTF8 )
|
||||||
{
|
{
|
||||||
const size_t facesBufSize = nFaces*16;
|
XP_UCHAR facesBuf[nFaces*16]; /* seems a reasonable upper bound... */
|
||||||
XP_UCHAR facesBuf[facesBufSize]; /* seems a reasonable upper bound... */
|
|
||||||
int indx = 0;
|
int indx = 0;
|
||||||
int offsets[nFaces];
|
int offsets[nFaces];
|
||||||
int nBytes;
|
int nBytes;
|
||||||
|
@ -268,7 +267,7 @@ splitFaces_via_java( JNIEnv* env, AndDictionaryCtxt* ctxt, const XP_U8* ptr,
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteLocalRef( env, jstrs );
|
deleteLocalRef( env, jstrs );
|
||||||
XP_ASSERT( indx < facesBufSize );
|
XP_ASSERT( indx < VSIZE(facesBuf) );
|
||||||
}
|
}
|
||||||
deleteLocalRef( env, jstrarr );
|
deleteLocalRef( env, jstrarr );
|
||||||
|
|
||||||
|
@ -573,7 +572,7 @@ makeDicts( MPFORMAL JNIEnv *env, DictMgrCtxt* dictMgr, JNIUtilCtxt* jniutil,
|
||||||
jsize len = (*env)->GetArrayLength( env, jdicts );
|
jsize len = (*env)->GetArrayLength( env, jdicts );
|
||||||
XP_ASSERT( len == (*env)->GetArrayLength( env, jnames ) );
|
XP_ASSERT( len == (*env)->GetArrayLength( env, jnames ) );
|
||||||
|
|
||||||
for ( int ii = 0; ii <= MAX_NUM_PLAYERS; ++ii ) {
|
for ( int ii = 0; ii <= VSIZE(dicts->dicts); ++ii ) {
|
||||||
DictionaryCtxt* dict = NULL;
|
DictionaryCtxt* dict = NULL;
|
||||||
if ( ii < len ) {
|
if ( ii < len ) {
|
||||||
jobject jdict = (*env)->GetObjectArrayElement( env, jdicts, ii );
|
jobject jdict = (*env)->GetObjectArrayElement( env, jdicts, ii );
|
||||||
|
@ -591,7 +590,7 @@ makeDicts( MPFORMAL JNIEnv *env, DictMgrCtxt* dictMgr, JNIUtilCtxt* jniutil,
|
||||||
if ( 0 == ii ) {
|
if ( 0 == ii ) {
|
||||||
*dictp = dict;
|
*dictp = dict;
|
||||||
} else {
|
} else {
|
||||||
XP_ASSERT( ii-1 < MAX_NUM_PLAYERS );
|
XP_ASSERT( ii-1 < VSIZE( dicts->dicts ) );
|
||||||
dicts->dicts[ii-1] = dict;
|
dicts->dicts[ii-1] = dict;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -576,9 +576,9 @@ getJAddrRec( JNIEnv* env, CommsAddrRec* addr, jobject jaddr )
|
||||||
case COMMS_CONN_RELAY:
|
case COMMS_CONN_RELAY:
|
||||||
addr->u.ip_relay.port = getInt( env, jaddr, "ip_relay_port" );
|
addr->u.ip_relay.port = getInt( env, jaddr, "ip_relay_port" );
|
||||||
getString( env, jaddr, "ip_relay_hostName", addr->u.ip_relay.hostName,
|
getString( env, jaddr, "ip_relay_hostName", addr->u.ip_relay.hostName,
|
||||||
MAX_HOSTNAME_LEN + 1 );
|
VSIZE(addr->u.ip_relay.hostName) );
|
||||||
getString( env, jaddr, "ip_relay_invite", addr->u.ip_relay.invite,
|
getString( env, jaddr, "ip_relay_invite", addr->u.ip_relay.invite,
|
||||||
MAX_INVITE_LEN + 1 );
|
VSIZE(addr->u.ip_relay.invite) );
|
||||||
addr->u.ip_relay.seeksPublicRoom =
|
addr->u.ip_relay.seeksPublicRoom =
|
||||||
getBool( env, jaddr, "ip_relay_seeksPublicRoom" );
|
getBool( env, jaddr, "ip_relay_seeksPublicRoom" );
|
||||||
addr->u.ip_relay.advertiseRoom =
|
addr->u.ip_relay.advertiseRoom =
|
||||||
|
@ -587,19 +587,19 @@ getJAddrRec( JNIEnv* env, CommsAddrRec* addr, jobject jaddr )
|
||||||
break;
|
break;
|
||||||
case COMMS_CONN_SMS:
|
case COMMS_CONN_SMS:
|
||||||
getString( env, jaddr, "sms_phone", addr->u.sms.phone,
|
getString( env, jaddr, "sms_phone", addr->u.sms.phone,
|
||||||
MAX_PHONE_LEN + 1 );
|
VSIZE(addr->u.sms.phone) );
|
||||||
// XP_LOGF( "%s: got SMS; phone=%s", __func__, addr->u.sms.phone );
|
// XP_LOGF( "%s: got SMS; phone=%s", __func__, addr->u.sms.phone );
|
||||||
addr->u.sms.port = getInt( env, jaddr, "sms_port" );
|
addr->u.sms.port = getInt( env, jaddr, "sms_port" );
|
||||||
break;
|
break;
|
||||||
case COMMS_CONN_BT:
|
case COMMS_CONN_BT:
|
||||||
getString( env, jaddr, "bt_hostName", addr->u.bt.hostName,
|
getString( env, jaddr, "bt_hostName", addr->u.bt.hostName,
|
||||||
MAX_HOSTNAME_LEN + 1 );
|
VSIZE(addr->u.bt.hostName) );
|
||||||
getString( env, jaddr, "bt_btAddr", addr->u.bt.btAddr.chars,
|
getString( env, jaddr, "bt_btAddr", addr->u.bt.btAddr.chars,
|
||||||
MAX_BTADDR_STR_LEN );
|
VSIZE(addr->u.bt.btAddr.chars) );
|
||||||
break;
|
break;
|
||||||
case COMMS_CONN_P2P:
|
case COMMS_CONN_P2P:
|
||||||
getString( env, jaddr, "p2p_addr", addr->u.p2p.mac_addr,
|
getString( env, jaddr, "p2p_addr", addr->u.p2p.mac_addr,
|
||||||
MAX_P2P_MAC_LEN + 1 );
|
VSIZE(addr->u.p2p.mac_addr) );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
XP_ASSERT(0);
|
XP_ASSERT(0);
|
||||||
|
|
|
@ -323,7 +323,7 @@ and_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, XP_U16 when,
|
||||||
{
|
{
|
||||||
UTIL_CBK_HEADER("setTimer", "(III)V" );
|
UTIL_CBK_HEADER("setTimer", "(III)V" );
|
||||||
|
|
||||||
XP_ASSERT( why < NUM_TIMERS_PLUS_ONE );
|
XP_ASSERT( why < VSIZE(util->timerStorage) );
|
||||||
TimerStorage* storage = &util->timerStorage[why];
|
TimerStorage* storage = &util->timerStorage[why];
|
||||||
storage->proc = proc;
|
storage->proc = proc;
|
||||||
storage->closure = closure;
|
storage->closure = closure;
|
||||||
|
@ -388,7 +388,7 @@ and_dutil_getUserString( XW_DUtilCtxt* duc, XP_U16 stringCode )
|
||||||
XP_UCHAR* result = "";
|
XP_UCHAR* result = "";
|
||||||
DUTIL_CBK_HEADER("getUserString", "(I)Ljava/lang/String;" );
|
DUTIL_CBK_HEADER("getUserString", "(I)Ljava/lang/String;" );
|
||||||
int index = stringCode - 1; /* see LocalizedStrIncludes.h */
|
int index = stringCode - 1; /* see LocalizedStrIncludes.h */
|
||||||
XP_ASSERT( index < N_AND_USER_STRINGS );
|
XP_ASSERT( index < VSIZE( dutil->userStrings ) );
|
||||||
|
|
||||||
XP_ASSERT( 0 == (dutil->userStringsBits & (1 << index)) );
|
XP_ASSERT( 0 == (dutil->userStringsBits & (1 << index)) );
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ and_dutil_getUserQuantityString( XW_DUtilCtxt* duc, XP_U16 stringCode, XP_U16 qu
|
||||||
XP_UCHAR* result = "";
|
XP_UCHAR* result = "";
|
||||||
DUTIL_CBK_HEADER("getUserQuantityString", "(II)Ljava/lang/String;" );
|
DUTIL_CBK_HEADER("getUserQuantityString", "(II)Ljava/lang/String;" );
|
||||||
int index = stringCode - 1; /* see LocalizedStrIncludes.h */
|
int index = stringCode - 1; /* see LocalizedStrIncludes.h */
|
||||||
XP_ASSERT( index < N_AND_USER_STRINGS );
|
XP_ASSERT( index < VSIZE( dutil->userStrings ) );
|
||||||
XP_UCHAR** ptrs;
|
XP_UCHAR** ptrs;
|
||||||
|
|
||||||
dutil->userStringsBits |= 1 << index;
|
dutil->userStringsBits |= 1 << index;
|
||||||
|
@ -908,7 +908,7 @@ destroyDUtil( XW_DUtilCtxt** dutilp )
|
||||||
(*env)->DeleteGlobalRef( env, dutil->jdutil );
|
(*env)->DeleteGlobalRef( env, dutil->jdutil );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int ii = 0; ii < N_AND_USER_STRINGS; ++ii ) {
|
for ( int ii = 0; ii < VSIZE(dutil->userStrings); ++ii ) {
|
||||||
XP_UCHAR* ptr = dutil->userStrings[ii];
|
XP_UCHAR* ptr = dutil->userStrings[ii];
|
||||||
if ( NULL != ptr ) {
|
if ( NULL != ptr ) {
|
||||||
if ( 0 == (dutil->userStringsBits & (1 << ii)) ) {
|
if ( 0 == (dutil->userStringsBits & (1 << ii)) ) {
|
||||||
|
|
|
@ -329,8 +329,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_cleanGlobals
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GI_INTS_SIZE 6
|
static const SetInfo gi_ints[] = {
|
||||||
static const SetInfo gi_ints[GI_INTS_SIZE] = {
|
|
||||||
ARR_MEMBER( CurGameInfo, nPlayers )
|
ARR_MEMBER( CurGameInfo, nPlayers )
|
||||||
,ARR_MEMBER( CurGameInfo, gameSeconds )
|
,ARR_MEMBER( CurGameInfo, gameSeconds )
|
||||||
,ARR_MEMBER( CurGameInfo, boardSize )
|
,ARR_MEMBER( CurGameInfo, boardSize )
|
||||||
|
@ -339,16 +338,14 @@ static const SetInfo gi_ints[GI_INTS_SIZE] = {
|
||||||
,ARR_MEMBER( CurGameInfo, forceChannel )
|
,ARR_MEMBER( CurGameInfo, forceChannel )
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GI_BOOLS_SIZE 4
|
static const SetInfo gi_bools[] = {
|
||||||
static const SetInfo gi_bools[GI_BOOLS_SIZE] = {
|
|
||||||
ARR_MEMBER( CurGameInfo, hintsNotAllowed )
|
ARR_MEMBER( CurGameInfo, hintsNotAllowed )
|
||||||
,ARR_MEMBER( CurGameInfo, timerEnabled )
|
,ARR_MEMBER( CurGameInfo, timerEnabled )
|
||||||
,ARR_MEMBER( CurGameInfo, allowPickTiles )
|
,ARR_MEMBER( CurGameInfo, allowPickTiles )
|
||||||
,ARR_MEMBER( CurGameInfo, allowHintRect )
|
,ARR_MEMBER( CurGameInfo, allowHintRect )
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PL_INTS_SIZE 2
|
static const SetInfo pl_ints[] = {
|
||||||
static const SetInfo pl_ints[PL_INTS_SIZE] = {
|
|
||||||
ARR_MEMBER( LocalPlayer, robotIQ )
|
ARR_MEMBER( LocalPlayer, robotIQ )
|
||||||
,ARR_MEMBER( LocalPlayer, secondsUsed )
|
,ARR_MEMBER( LocalPlayer, secondsUsed )
|
||||||
};
|
};
|
||||||
|
@ -357,10 +354,10 @@ static CurGameInfo*
|
||||||
makeGI( MPFORMAL JNIEnv* env, jobject jgi )
|
makeGI( MPFORMAL JNIEnv* env, jobject jgi )
|
||||||
{
|
{
|
||||||
CurGameInfo* gi = (CurGameInfo*)XP_CALLOC( mpool, sizeof(*gi) );
|
CurGameInfo* gi = (CurGameInfo*)XP_CALLOC( mpool, sizeof(*gi) );
|
||||||
VDECL( XP_UCHAR, buf, 256 ); /* in case needs whole path */
|
XP_UCHAR buf[256]; /* in case needs whole path */
|
||||||
|
|
||||||
getInts( env, (void*)gi, jgi, gi_ints, GI_INTS_SIZE );
|
getInts( env, (void*)gi, jgi, gi_ints, VSIZE(gi_ints) );
|
||||||
getBools( env, (void*)gi, jgi, gi_bools, GI_BOOLS_SIZE );
|
getBools( env, (void*)gi, jgi, gi_bools, VSIZE(gi_bools) );
|
||||||
|
|
||||||
/* Unlike on other platforms, gi is created without a call to
|
/* Unlike on other platforms, gi is created without a call to
|
||||||
game_makeNewGame, which sets gameID. So check here if it's still unset
|
game_makeNewGame, which sets gameID. So check here if it's still unset
|
||||||
|
@ -393,7 +390,7 @@ makeGI( MPFORMAL JNIEnv* env, jobject jgi )
|
||||||
jobject jlp = (*env)->GetObjectArrayElement( env, jplayers, ii );
|
jobject jlp = (*env)->GetObjectArrayElement( env, jplayers, ii );
|
||||||
XP_ASSERT( !!jlp );
|
XP_ASSERT( !!jlp );
|
||||||
|
|
||||||
getInts( env, (void*)lp, jlp, pl_ints, PL_INTS_SIZE );
|
getInts( env, (void*)lp, jlp, pl_ints, VSIZE(pl_ints) );
|
||||||
|
|
||||||
lp->isLocal = getBool( env, jlp, "isLocal" );
|
lp->isLocal = getBool( env, jlp, "isLocal" );
|
||||||
|
|
||||||
|
@ -414,8 +411,7 @@ makeGI( MPFORMAL JNIEnv* env, jobject jgi )
|
||||||
return gi;
|
return gi;
|
||||||
} /* makeGI */
|
} /* makeGI */
|
||||||
|
|
||||||
#define NLI_INTS_SIZE 7
|
static const SetInfo nli_ints[] = {
|
||||||
static const SetInfo nli_ints[NLI_INTS_SIZE] = {
|
|
||||||
ARR_MEMBER( NetLaunchInfo, _conTypes ),
|
ARR_MEMBER( NetLaunchInfo, _conTypes ),
|
||||||
ARR_MEMBER( NetLaunchInfo, lang ),
|
ARR_MEMBER( NetLaunchInfo, lang ),
|
||||||
ARR_MEMBER( NetLaunchInfo, forceChannel ),
|
ARR_MEMBER( NetLaunchInfo, forceChannel ),
|
||||||
|
@ -425,13 +421,11 @@ static const SetInfo nli_ints[NLI_INTS_SIZE] = {
|
||||||
ARR_MEMBER( NetLaunchInfo, osVers ),
|
ARR_MEMBER( NetLaunchInfo, osVers ),
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NLI_BOOLS_SIZE 1
|
static const SetInfo nli_bools[] = {
|
||||||
static const SetInfo nli_bools[NLI_BOOLS_SIZE] = {
|
|
||||||
ARR_MEMBER( NetLaunchInfo, isGSM )
|
ARR_MEMBER( NetLaunchInfo, isGSM )
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NLI_STRS_SIZE 7
|
static const SetInfo nli_strs[] = {
|
||||||
static const SetInfo nli_strs[NLI_STRS_SIZE] = {
|
|
||||||
ARR_MEMBER( NetLaunchInfo, dict ),
|
ARR_MEMBER( NetLaunchInfo, dict ),
|
||||||
ARR_MEMBER( NetLaunchInfo, gameName ),
|
ARR_MEMBER( NetLaunchInfo, gameName ),
|
||||||
ARR_MEMBER( NetLaunchInfo, room ),
|
ARR_MEMBER( NetLaunchInfo, room ),
|
||||||
|
@ -444,17 +438,17 @@ static const SetInfo nli_strs[NLI_STRS_SIZE] = {
|
||||||
static void
|
static void
|
||||||
loadNLI( JNIEnv* env, NetLaunchInfo* nli, jobject jnli )
|
loadNLI( JNIEnv* env, NetLaunchInfo* nli, jobject jnli )
|
||||||
{
|
{
|
||||||
getInts( env, (void*)nli, jnli, nli_ints, NLI_INTS_SIZE );
|
getInts( env, (void*)nli, jnli, nli_ints, VSIZE(nli_ints) );
|
||||||
getBools( env, (void*)nli, jnli, nli_bools, NLI_BOOLS_SIZE );
|
getBools( env, (void*)nli, jnli, nli_bools, VSIZE(nli_bools) );
|
||||||
getStrings( env, (void*)nli, jnli, nli_strs, NLI_STRS_SIZE );
|
getStrings( env, (void*)nli, jnli, nli_strs, VSIZE(nli_strs) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setNLI( JNIEnv* env, jobject jnli, const NetLaunchInfo* nli )
|
setNLI( JNIEnv* env, jobject jnli, const NetLaunchInfo* nli )
|
||||||
{
|
{
|
||||||
setInts( env, jnli, (void*)nli, nli_ints, NLI_INTS_SIZE );
|
setInts( env, jnli, (void*)nli, nli_ints, VSIZE(nli_ints) );
|
||||||
setBools( env, jnli, (void*)nli, nli_bools, NLI_BOOLS_SIZE );
|
setBools( env, jnli, (void*)nli, nli_bools, VSIZE(nli_bools) );
|
||||||
setStrings( env, jnli, (void*)nli, nli_strs, NLI_STRS_SIZE );
|
setStrings( env, jnli, (void*)nli, nli_strs, VSIZE(nli_strs) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -462,8 +456,8 @@ setJGI( JNIEnv* env, jobject jgi, const CurGameInfo* gi )
|
||||||
{
|
{
|
||||||
// set fields
|
// set fields
|
||||||
|
|
||||||
setInts( env, jgi, (void*)gi, gi_ints, GI_INTS_SIZE );
|
setInts( env, jgi, (void*)gi, gi_ints, VSIZE(gi_ints) );
|
||||||
setBools( env, jgi, (void*)gi, gi_bools, GI_BOOLS_SIZE );
|
setBools( env, jgi, (void*)gi, gi_bools, VSIZE(gi_bools) );
|
||||||
|
|
||||||
setString( env, jgi, "dictName", gi->dictName );
|
setString( env, jgi, "dictName", gi->dictName );
|
||||||
|
|
||||||
|
@ -482,7 +476,7 @@ setJGI( JNIEnv* env, jobject jgi, const CurGameInfo* gi )
|
||||||
jobject jlp = (*env)->GetObjectArrayElement( env, jplayers, ii );
|
jobject jlp = (*env)->GetObjectArrayElement( env, jplayers, ii );
|
||||||
XP_ASSERT( !!jlp );
|
XP_ASSERT( !!jlp );
|
||||||
|
|
||||||
setInts( env, jlp, (void*)lp, pl_ints, PL_INTS_SIZE );
|
setInts( env, jlp, (void*)lp, pl_ints, VSIZE(pl_ints) );
|
||||||
|
|
||||||
setBool( env, jlp, "isLocal", lp->isLocal );
|
setBool( env, jlp, "isLocal", lp->isLocal );
|
||||||
setString( env, jlp, "name", lp->name );
|
setString( env, jlp, "name", lp->name );
|
||||||
|
@ -498,8 +492,7 @@ setJGI( JNIEnv* env, jobject jgi, const CurGameInfo* gi )
|
||||||
} /* setJGI */
|
} /* setJGI */
|
||||||
|
|
||||||
#ifdef COMMON_LAYOUT
|
#ifdef COMMON_LAYOUT
|
||||||
#define BD_INTS_SIZE 16
|
static const SetInfo bd_ints[] = {
|
||||||
static const SetInfo bd_ints[BD_INTS_SIZE] = {
|
|
||||||
ARR_MEMBER( BoardDims, left )
|
ARR_MEMBER( BoardDims, left )
|
||||||
,ARR_MEMBER( BoardDims, top )
|
,ARR_MEMBER( BoardDims, top )
|
||||||
,ARR_MEMBER( BoardDims, width )
|
,ARR_MEMBER( BoardDims, width )
|
||||||
|
@ -521,13 +514,13 @@ static const SetInfo bd_ints[BD_INTS_SIZE] = {
|
||||||
static void
|
static void
|
||||||
dimsJToC( JNIEnv* env, BoardDims* out, jobject jdims )
|
dimsJToC( JNIEnv* env, BoardDims* out, jobject jdims )
|
||||||
{
|
{
|
||||||
getInts( env, (void*)out, jdims, bd_ints, BD_INTS_SIZE );
|
getInts( env, (void*)out, jdims, bd_ints, VSIZE(bd_ints) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dimsCtoJ( JNIEnv* env, jobject jdims, const BoardDims* in )
|
dimsCtoJ( JNIEnv* env, jobject jdims, const BoardDims* in )
|
||||||
{
|
{
|
||||||
setInts( env, jdims, (void*)in, bd_ints, BD_INTS_SIZE );
|
setInts( env, jdims, (void*)in, bd_ints, VSIZE(bd_ints) );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1256,7 +1249,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1zoom
|
||||||
XWJNI_START();
|
XWJNI_START();
|
||||||
XP_Bool canInOut[2];
|
XP_Bool canInOut[2];
|
||||||
result = board_zoom( state->game.board, zoomBy, canInOut );
|
result = board_zoom( state->game.board, zoomBy, canInOut );
|
||||||
VDECL( jboolean, canZoom, 2 ) = { canInOut[0], canInOut[1] };
|
jboolean canZoom[2] = { canInOut[0], canInOut[1] };
|
||||||
setBoolArray( env, jCanZoom, VSIZE(canZoom), canZoom );
|
setBoolArray( env, jCanZoom, VSIZE(canZoom), canZoom );
|
||||||
XWJNI_END();
|
XWJNI_END();
|
||||||
return result;
|
return result;
|
||||||
|
@ -1791,7 +1784,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getAddrs
|
||||||
XWJNI_START();
|
XWJNI_START();
|
||||||
XP_ASSERT( state->game.comms );
|
XP_ASSERT( state->game.comms );
|
||||||
if ( !!state->game.comms ) {
|
if ( !!state->game.comms ) {
|
||||||
VDECL( CommsAddrRec, addrs, MAX_NUM_PLAYERS );
|
CommsAddrRec addrs[MAX_NUM_PLAYERS];
|
||||||
XP_U16 count = VSIZE(addrs);
|
XP_U16 count = VSIZE(addrs);
|
||||||
comms_getAddrs( state->game.comms, addrs, &count );
|
comms_getAddrs( state->game.comms, addrs, &count );
|
||||||
|
|
||||||
|
@ -1884,7 +1877,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize
|
||||||
for ( XP_U32 st = 0; addr_iter( &addr, &typ, &st ); ) {
|
for ( XP_U32 st = 0; addr_iter( &addr, &typ, &st ); ) {
|
||||||
switch( typ ) {
|
switch( typ ) {
|
||||||
case COMMS_CONN_RELAY: {
|
case COMMS_CONN_RELAY: {
|
||||||
VDECL( XP_UCHAR, buf, 128 );
|
XP_UCHAR buf[128];
|
||||||
XP_U16 len = VSIZE(buf);
|
XP_U16 len = VSIZE(buf);
|
||||||
if ( comms_getRelayID( comms, buf, &len ) ) {
|
if ( comms_getRelayID( comms, buf, &len ) ) {
|
||||||
XP_ASSERT( '\0' == buf[len-1] ); /* failed! */
|
XP_ASSERT( '\0' == buf[len-1] ); /* failed! */
|
||||||
|
@ -1897,7 +1890,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize
|
||||||
case COMMS_CONN_BT:
|
case COMMS_CONN_BT:
|
||||||
case COMMS_CONN_P2P:
|
case COMMS_CONN_P2P:
|
||||||
case COMMS_CONN_SMS: {
|
case COMMS_CONN_SMS: {
|
||||||
VDECL( CommsAddrRec, addrs, MAX_NUM_PLAYERS );
|
CommsAddrRec addrs[MAX_NUM_PLAYERS];
|
||||||
XP_U16 count = VSIZE(addrs);
|
XP_U16 count = VSIZE(addrs);
|
||||||
comms_getAddrs( comms, addrs, &count );
|
comms_getAddrs( comms, addrs, &count );
|
||||||
|
|
||||||
|
@ -2017,15 +2010,12 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1getGi
|
||||||
XWJNI_END();
|
XWJNI_END();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GSI_INTS_SIZE 3
|
static const SetInfo gsi_ints[] = {
|
||||||
static const SetInfo gsi_ints[GSI_INTS_SIZE] = {
|
|
||||||
ARR_MEMBER( GameStateInfo, visTileCount ),
|
ARR_MEMBER( GameStateInfo, visTileCount ),
|
||||||
ARR_MEMBER( GameStateInfo, nPendingMessages ),
|
ARR_MEMBER( GameStateInfo, nPendingMessages ),
|
||||||
ARR_MEMBER( GameStateInfo, trayVisState ),
|
ARR_MEMBER( GameStateInfo, trayVisState ),
|
||||||
};
|
};
|
||||||
|
static const SetInfo gsi_bools[] = {
|
||||||
#define GSI_BOOLS_SIZE 10
|
|
||||||
static const SetInfo gsi_bools[GSI_BOOLS_SIZE] = {
|
|
||||||
ARR_MEMBER( GameStateInfo,canHint ),
|
ARR_MEMBER( GameStateInfo,canHint ),
|
||||||
ARR_MEMBER( GameStateInfo, canUndo ),
|
ARR_MEMBER( GameStateInfo, canUndo ),
|
||||||
ARR_MEMBER( GameStateInfo, canRedo ),
|
ARR_MEMBER( GameStateInfo, canRedo ),
|
||||||
|
@ -2046,8 +2036,8 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1getState
|
||||||
GameStateInfo info;
|
GameStateInfo info;
|
||||||
game_getState( &state->game, &info );
|
game_getState( &state->game, &info );
|
||||||
|
|
||||||
setInts( env, jgsi, (void*)&info, gsi_ints, GSI_INTS_SIZE );
|
setInts( env, jgsi, (void*)&info, gsi_ints, VSIZE(gsi_ints) );
|
||||||
setBools( env, jgsi, (void*)&info, gsi_bools, GSI_BOOLS_SIZE );
|
setBools( env, jgsi, (void*)&info, gsi_bools, VSIZE(gsi_bools) );
|
||||||
|
|
||||||
XWJNI_END();
|
XWJNI_END();
|
||||||
}
|
}
|
||||||
|
@ -2340,7 +2330,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getCounts
|
||||||
LengthsArray lens;
|
LengthsArray lens;
|
||||||
if ( 0 < dict_countWords( &iter, &lens ) ) {
|
if ( 0 < dict_countWords( &iter, &lens ) ) {
|
||||||
XP_ASSERT( sizeof(jint) == sizeof(lens.lens[0]) );
|
XP_ASSERT( sizeof(jint) == sizeof(lens.lens[0]) );
|
||||||
result = makeIntArray( env, MAX_COLS_DICT+1, (jint*)&lens.lens,
|
result = makeIntArray( env, VSIZE(lens.lens), (jint*)&lens.lens,
|
||||||
sizeof(lens.lens[0]) );
|
sizeof(lens.lens[0]) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2358,7 +2348,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getPrefixes
|
||||||
|
|
||||||
XP_U16 depth = data->depth;
|
XP_U16 depth = data->depth;
|
||||||
for ( int ii = 0; ii < data->idata.count; ++ii ) {
|
for ( int ii = 0; ii < data->idata.count; ++ii ) {
|
||||||
VDECL( XP_UCHAR, buf, 16 );
|
XP_UCHAR buf[16];
|
||||||
(void)dict_tilesToString( data->dict,
|
(void)dict_tilesToString( data->dict,
|
||||||
&data->idata.prefixes[depth*ii],
|
&data->idata.prefixes[depth*ii],
|
||||||
depth, buf, VSIZE(buf) );
|
depth, buf, VSIZE(buf) );
|
||||||
|
@ -2394,7 +2384,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1nthWord
|
||||||
DictIterData* data = (DictIterData*)closure;
|
DictIterData* data = (DictIterData*)closure;
|
||||||
if ( NULL != data ) {
|
if ( NULL != data ) {
|
||||||
if ( dict_getNthWord( &data->iter, nn, data->depth, &data->idata ) ) {
|
if ( dict_getNthWord( &data->iter, nn, data->depth, &data->idata ) ) {
|
||||||
VDECL( XP_UCHAR, buf, 64 );
|
XP_UCHAR buf[64];
|
||||||
dict_wordToString( &data->iter, buf, VSIZE(buf) );
|
dict_wordToString( &data->iter, buf, VSIZE(buf) );
|
||||||
result = (*env)->NewStringUTF( env, buf );
|
result = (*env)->NewStringUTF( env, buf );
|
||||||
}
|
}
|
||||||
|
|
|
@ -2254,7 +2254,7 @@ figureScale( BoardCtxt* board, XP_U16 count, XP_U16 dimension, ScrollData* sd )
|
||||||
|
|
||||||
sd->lastVisible = count - board->zoomCount + sd->offset - 1;
|
sd->lastVisible = count - board->zoomCount + sd->offset - 1;
|
||||||
|
|
||||||
if ( figureDims( sd->dims, MAX_COLS, nVis,
|
if ( figureDims( sd->dims, VSIZE(sd->dims), nVis,
|
||||||
scale, spares ) ) {
|
scale, spares ) ) {
|
||||||
board_invalAll( board );
|
board_invalAll( board );
|
||||||
}
|
}
|
||||||
|
@ -2344,7 +2344,7 @@ figureBoardRect( BoardCtxt* board )
|
||||||
|
|
||||||
vsd->lastVisible = nVisible + vsd->offset - 1;
|
vsd->lastVisible = nVisible + vsd->offset - 1;
|
||||||
|
|
||||||
if ( figureDims( vsd->dims, MAX_COLS, nVisible,
|
if ( figureDims( vsd->dims, VSIZE(vsd->dims), nVisible,
|
||||||
vsd->scale, extra ) ) {
|
vsd->scale, extra ) ) {
|
||||||
board_invalAll( board );
|
board_invalAll( board );
|
||||||
}
|
}
|
||||||
|
|
|
@ -395,7 +395,7 @@ drawCell( BoardCtxt* board, const XP_U16 col, const XP_U16 row, XP_Bool skipBlan
|
||||||
/* This 'while' is only here so I can 'break' below */
|
/* This 'while' is only here so I can 'break' below */
|
||||||
while ( board->trayVisState == TRAY_HIDDEN ||
|
while ( board->trayVisState == TRAY_HIDDEN ||
|
||||||
!rectContainsRect( &board->trayBounds, &cellRect ) ) {
|
!rectContainsRect( &board->trayBounds, &cellRect ) ) {
|
||||||
VDECL(XP_UCHAR, ch, 4) = {'\0'};
|
XP_UCHAR ch[4] = {'\0'};
|
||||||
XP_S16 owner = -1;
|
XP_S16 owner = -1;
|
||||||
XP_Bool invert = XP_FALSE;
|
XP_Bool invert = XP_FALSE;
|
||||||
XP_Bitmaps bitmaps;
|
XP_Bitmaps bitmaps;
|
||||||
|
@ -470,7 +470,7 @@ drawCell( BoardCtxt* board, const XP_U16 col, const XP_U16 row, XP_Bool skipBlan
|
||||||
tile, value, owner, bonus, hintAtts,
|
tile, value, owner, bonus, hintAtts,
|
||||||
flags );
|
flags );
|
||||||
#ifdef LOG_CELL_DRAW
|
#ifdef LOG_CELL_DRAW
|
||||||
VDECL( XP_UCHAR, buf, 64 );
|
XP_UCHAR buf[64];
|
||||||
XP_LOGF( "%s(col=%d, row=%d, flags=%s)=>%s", __func__, col, row,
|
XP_LOGF( "%s(col=%d, row=%d, flags=%s)=>%s", __func__, col, row,
|
||||||
formatFlags(buf, VSIZE(buf), flags), success?"true":"false" );
|
formatFlags(buf, VSIZE(buf), flags), success?"true":"false" );
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -734,8 +734,8 @@ comms_makeFromStream( MPFORMAL XWStreamCtxt* stream, XW_UtilCtxt* util,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( STREAM_VERS_DISABLEDS <= version ) {
|
if ( STREAM_VERS_DISABLEDS <= version ) {
|
||||||
for ( int typ = 0; typ < COMMS_CONN_NTYPES; ++typ ) {
|
for ( int typ = 0; typ < VSIZE(comms->disableds); ++typ ) {
|
||||||
for ( int ii = 0; ii < 2; ++ii ) {
|
for ( int ii = 0; ii < VSIZE(comms->disableds[0]); ++ii ) {
|
||||||
comms->disableds[typ][ii] = 0 != stream_getBits( stream, 1 );
|
comms->disableds[typ][ii] = 0 != stream_getBits( stream, 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -929,8 +929,8 @@ comms_writeToStream( CommsCtxt* comms, XWStreamCtxt* stream,
|
||||||
stream_putBytes( stream, msg->msg, msg->len );
|
stream_putBytes( stream, msg->msg, msg->len );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int typ = 0; typ < COMMS_CONN_NTYPES; ++typ ) {
|
for ( int typ = 0; typ < VSIZE(comms->disableds); ++typ ) {
|
||||||
for ( int ii = 0; ii < 2; ++ii ) {
|
for ( int ii = 0; ii < VSIZE(comms->disableds[0]); ++ii ) {
|
||||||
stream_putBits( stream, 1, comms->disableds[typ][ii] ? 1 : 0 );
|
stream_putBits( stream, 1, comms->disableds[typ][ii] ? 1 : 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,7 @@ typedef enum {
|
||||||
/* on Palm BtLibDeviceAddressType is a 48-bit quantity. Linux's typeis the
|
/* on Palm BtLibDeviceAddressType is a 48-bit quantity. Linux's typeis the
|
||||||
same size. Goal is something all platforms support */
|
same size. Goal is something all platforms support */
|
||||||
typedef struct XP_BtAddr { XP_U8 bits[6]; } XP_BtAddr;
|
typedef struct XP_BtAddr { XP_U8 bits[6]; } XP_BtAddr;
|
||||||
#define MAX_BTADDR_STR_LEN 18
|
typedef struct XP_BtAddrStr { XP_UCHAR chars[18]; } XP_BtAddrStr;
|
||||||
typedef struct XP_BtAddrStr { XP_UCHAR chars[MAX_BTADDR_STR_LEN]; } XP_BtAddrStr;
|
|
||||||
|
|
||||||
#ifdef COMMS_HEARTBEAT
|
#ifdef COMMS_HEARTBEAT
|
||||||
# define IF_CH(a) a,
|
# define IF_CH(a) a,
|
||||||
|
|
|
@ -40,10 +40,7 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define VSIZE(_arr) __name_of ## _arr
|
#define VSIZE(arr) (sizeof(arr)/sizeof(arr[0]))
|
||||||
#define VDECL(_type, _arr, _count) \
|
|
||||||
enum {VSIZE(_arr) = _count}; \
|
|
||||||
_type _arr[VSIZE(_arr)]
|
|
||||||
|
|
||||||
#ifndef MAX_ROWS
|
#ifndef MAX_ROWS
|
||||||
# define MAX_ROWS 16
|
# define MAX_ROWS 16
|
||||||
|
|
|
@ -97,7 +97,7 @@ dbg_logstream( const XWStreamCtxt* stream, const char* func, int line )
|
||||||
stream_copyBits( stream, end, NULL, &len );
|
stream_copyBits( stream, end, NULL, &len );
|
||||||
XP_U8 buf[len];
|
XP_U8 buf[len];
|
||||||
stream_copyBits( stream, end, buf, &len );
|
stream_copyBits( stream, end, buf, &len );
|
||||||
VDECL( char, comment, 128 );
|
char comment[128];
|
||||||
XP_SNPRINTF( comment, VSIZE(comment), "%s line %d", func, line );
|
XP_SNPRINTF( comment, VSIZE(comment), "%s line %d", func, line );
|
||||||
LOG_HEX( buf, len, comment );
|
LOG_HEX( buf, len, comment );
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -107,7 +107,7 @@ dmgr_put( DictMgrCtxt* dmgr, const XP_UCHAR* key, DictionaryCtxt* dict )
|
||||||
|
|
||||||
XP_S16 loc = findFor( dmgr, key );
|
XP_S16 loc = findFor( dmgr, key );
|
||||||
if ( NOT_FOUND == loc ) { /* reuse the last one */
|
if ( NOT_FOUND == loc ) { /* reuse the last one */
|
||||||
moveToFront( dmgr, DMGR_MAX_DICTS - 1 );
|
moveToFront( dmgr, VSIZE(dmgr->pairs) - 1 );
|
||||||
DictPair* pair = dmgr->pairs; /* the head */
|
DictPair* pair = dmgr->pairs; /* the head */
|
||||||
dict_unref( pair->dict );
|
dict_unref( pair->dict );
|
||||||
pair->dict = dict_ref( dict );
|
pair->dict = dict_ref( dict );
|
||||||
|
@ -126,7 +126,7 @@ findFor( DictMgrCtxt* dmgr, const XP_UCHAR* key )
|
||||||
{
|
{
|
||||||
XP_S16 result = NOT_FOUND;
|
XP_S16 result = NOT_FOUND;
|
||||||
XP_U16 ii;
|
XP_U16 ii;
|
||||||
for ( ii = 0; ii < DMGR_MAX_DICTS; ++ii ) {
|
for ( ii = 0; ii < VSIZE(dmgr->pairs); ++ii ) {
|
||||||
DictPair* pair = &dmgr->pairs[ii];
|
DictPair* pair = &dmgr->pairs[ii];
|
||||||
if ( !!pair->key && 0 == XP_STRCMP( key, pair->key ) ) {
|
if ( !!pair->key && 0 == XP_STRCMP( key, pair->key ) ) {
|
||||||
result = ii;
|
result = ii;
|
||||||
|
@ -151,7 +151,7 @@ static void
|
||||||
printInOrder( const DictMgrCtxt* dmgr )
|
printInOrder( const DictMgrCtxt* dmgr )
|
||||||
{
|
{
|
||||||
XP_U16 ii;
|
XP_U16 ii;
|
||||||
for ( ii = 0; ii < DMGR_MAX_DICTS; ++ii ) {
|
for ( ii = 0; ii < VSIZE(dmgr->pairs); ++ii ) {
|
||||||
const XP_UCHAR* name = dmgr->pairs[ii].key;
|
const XP_UCHAR* name = dmgr->pairs[ii].key;
|
||||||
XP_LOGF( "%s: dict[%d]: %s", __func__, ii,
|
XP_LOGF( "%s: dict[%d]: %s", __func__, ii,
|
||||||
(NULL == name)? "<empty>" : name );
|
(NULL == name)? "<empty>" : name );
|
||||||
|
|
|
@ -454,7 +454,7 @@ dict_loadFromStream( DictionaryCtxt* dict, XWStreamCtxt* stream )
|
||||||
XP_U16 maxCountBits, maxValueBits;
|
XP_U16 maxCountBits, maxValueBits;
|
||||||
XP_U16 ii, nSpecials;
|
XP_U16 ii, nSpecials;
|
||||||
XP_UCHAR* localTexts[32];
|
XP_UCHAR* localTexts[32];
|
||||||
VDECL( XP_U8, utf8, MAX_UNIQUE_TILES );
|
XP_U8 utf8[MAX_UNIQUE_TILES];
|
||||||
|
|
||||||
XP_ASSERT( !dict->destructor );
|
XP_ASSERT( !dict->destructor );
|
||||||
dict->destructor = common_destructor;
|
dict->destructor = common_destructor;
|
||||||
|
|
|
@ -223,8 +223,6 @@ typedef struct DrawCtxVTable {
|
||||||
const XP_Rect* rect, void** closure );
|
const XP_Rect* rect, void** closure );
|
||||||
#endif
|
#endif
|
||||||
#ifndef DRAW_LINK_DIRECT
|
#ifndef DRAW_LINK_DIRECT
|
||||||
|
|
||||||
void* tableEnd;
|
|
||||||
} DrawCtxVTable; /* */
|
} DrawCtxVTable; /* */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,7 @@ typedef struct MoveIterationData {
|
||||||
|
|
||||||
/* one bit per tile that's possible here *\/ */
|
/* one bit per tile that's possible here *\/ */
|
||||||
typedef XP_U32 CrossBits;
|
typedef XP_U32 CrossBits;
|
||||||
#define NUM_CBITS 2
|
typedef struct Crosscheck { CrossBits bits[2]; } Crosscheck;
|
||||||
typedef struct Crosscheck { CrossBits bits[NUM_CBITS]; } Crosscheck;
|
|
||||||
|
|
||||||
struct EngineCtxt {
|
struct EngineCtxt {
|
||||||
const ModelCtxt* model;
|
const ModelCtxt* model;
|
||||||
|
@ -278,7 +277,7 @@ print_savedMoves( const EngineCtxt* engine, const char* label )
|
||||||
{
|
{
|
||||||
int ii;
|
int ii;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
VDECL(char, buf, (NUM_SAVED_ENGINE_MOVES*10) + 3) = {0};
|
char buf[(NUM_SAVED_ENGINE_MOVES*10) + 3] = {0};
|
||||||
for ( ii = 0; ii < engine->nMovesToSave; ++ii ) {
|
for ( ii = 0; ii < engine->nMovesToSave; ++ii ) {
|
||||||
if ( 0 < engine->miData.savedMoves[ii].score ) {
|
if ( 0 < engine->miData.savedMoves[ii].score ) {
|
||||||
pos += XP_SNPRINTF( &buf[pos], VSIZE(buf)-pos, "[%d]: %d; ",
|
pos += XP_SNPRINTF( &buf[pos], VSIZE(buf)-pos, "[%d]: %d; ",
|
||||||
|
@ -726,7 +725,8 @@ figureCrosschecks( EngineCtxt* engine, XP_U16 x, XP_U16 y, XP_U16* scoreP,
|
||||||
XP_ASSERT( tile < MAX_UNIQUE_TILES );
|
XP_ASSERT( tile < MAX_UNIQUE_TILES );
|
||||||
tiles[0] = tile;
|
tiles[0] = tile;
|
||||||
if ( lookup( dict, in_edge, tiles, 0, tilesAfter ) ) {
|
if ( lookup( dict, in_edge, tiles, 0, tilesAfter ) ) {
|
||||||
XP_ASSERT( (tile >> 5) < NUM_CBITS );
|
XP_ASSERT( (tile >> 5)
|
||||||
|
< (VSIZE(check->bits)) );
|
||||||
check->bits[tile>>5] |= (1L << (tile & 0x1F));
|
check->bits[tile>>5] |= (1L << (tile & 0x1F));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -551,7 +551,7 @@ model_setPlayerDicts( ModelCtxt* model, const PlayerDicts* dicts )
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
DictionaryCtxt* gameDict = model_getDictionary( model );
|
DictionaryCtxt* gameDict = model_getDictionary( model );
|
||||||
#endif
|
#endif
|
||||||
for ( ii = 0; ii < MAX_NUM_PLAYERS; ++ii ) {
|
for ( ii = 0; ii < VSIZE(dicts->dicts); ++ii ) {
|
||||||
DictionaryCtxt* oldDict = model->vol.dicts.dicts[ii];
|
DictionaryCtxt* oldDict = model->vol.dicts.dicts[ii];
|
||||||
DictionaryCtxt* newDict = dicts->dicts[ii];
|
DictionaryCtxt* newDict = dicts->dicts[ii];
|
||||||
if ( oldDict != newDict ) {
|
if ( oldDict != newDict ) {
|
||||||
|
@ -573,7 +573,7 @@ model_getDictionary( const ModelCtxt* model )
|
||||||
{
|
{
|
||||||
XP_U16 ii;
|
XP_U16 ii;
|
||||||
DictionaryCtxt* result = model->vol.dict;
|
DictionaryCtxt* result = model->vol.dict;
|
||||||
for ( ii = 0; !result && ii < MAX_NUM_PLAYERS; ++ii ) {
|
for ( ii = 0; !result && ii < VSIZE(model->vol.dicts.dicts); ++ii ) {
|
||||||
result = model->vol.dicts.dicts[ii];
|
result = model->vol.dicts.dicts[ii];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -594,7 +594,7 @@ static void
|
||||||
model_unrefDicts( ModelCtxt* model )
|
model_unrefDicts( ModelCtxt* model )
|
||||||
{
|
{
|
||||||
XP_U16 ii;
|
XP_U16 ii;
|
||||||
for ( ii = 0; ii < MAX_NUM_PLAYERS; ++ii ) {
|
for ( ii = 0; ii < VSIZE(model->vol.dicts.dicts); ++ii ) {
|
||||||
dict_unref( model->vol.dicts.dicts[ii] );
|
dict_unref( model->vol.dicts.dicts[ii] );
|
||||||
model->vol.dicts.dicts[ii] = NULL;
|
model->vol.dicts.dicts[ii] = NULL;
|
||||||
}
|
}
|
||||||
|
@ -611,7 +611,7 @@ getPendingTileFor( const ModelCtxt* model, XP_U16 turn, XP_U16 col, XP_U16 row,
|
||||||
const PendingTile* pendings;
|
const PendingTile* pendings;
|
||||||
XP_U16 ii;
|
XP_U16 ii;
|
||||||
|
|
||||||
XP_ASSERT( turn < MAX_NUM_PLAYERS );
|
XP_ASSERT( turn < VSIZE(model->players) );
|
||||||
|
|
||||||
player = &model->players[turn];
|
player = &model->players[turn];
|
||||||
pendings = player->pendingTiles;
|
pendings = player->pendingTiles;
|
||||||
|
@ -2064,7 +2064,7 @@ printMovePre( ModelCtxt* model, XP_U16 XP_UNUSED(moveN), const StackEntry* entry
|
||||||
{
|
{
|
||||||
if ( entry->moveType != ASSIGN_TYPE ) {
|
if ( entry->moveType != ASSIGN_TYPE ) {
|
||||||
const XP_UCHAR* format;
|
const XP_UCHAR* format;
|
||||||
VDECL( XP_UCHAR, buf, 64 );
|
XP_UCHAR buf[64];
|
||||||
XP_UCHAR traybuf[MAX_TRAY_TILES+1];
|
XP_UCHAR traybuf[MAX_TRAY_TILES+1];
|
||||||
MovePrintClosure* closure = (MovePrintClosure*)p_closure;
|
MovePrintClosure* closure = (MovePrintClosure*)p_closure;
|
||||||
XWStreamCtxt* stream = closure->stream;
|
XWStreamCtxt* stream = closure->stream;
|
||||||
|
@ -2293,7 +2293,7 @@ scoreLastMove( ModelCtxt* model, MoveInfo* moveInfo, XP_U16 howMany,
|
||||||
model_destroy( tmpModel );
|
model_destroy( tmpModel );
|
||||||
|
|
||||||
lmi->score = score;
|
lmi->score = score;
|
||||||
XP_SNPRINTF( lmi->word, MAX_COLS+1, "%s", data.word );
|
XP_SNPRINTF( lmi->word, VSIZE(lmi->word), "%s", data.word );
|
||||||
} /* scoreLastMove */
|
} /* scoreLastMove */
|
||||||
|
|
||||||
static XP_U16
|
static XP_U16
|
||||||
|
|
|
@ -493,7 +493,7 @@ static void
|
||||||
cleanupServer( ServerCtxt* server )
|
cleanupServer( ServerCtxt* server )
|
||||||
{
|
{
|
||||||
XP_U16 ii;
|
XP_U16 ii;
|
||||||
for ( ii = 0; ii < MAX_NUM_PLAYERS; ++ii ){
|
for ( ii = 0; ii < VSIZE(server->players); ++ii ){
|
||||||
ServerPlayer* player = &server->players[ii];
|
ServerPlayer* player = &server->players[ii];
|
||||||
if ( player->engine != NULL ) {
|
if ( player->engine != NULL ) {
|
||||||
engine_destroy( player->engine );
|
engine_destroy( player->engine );
|
||||||
|
@ -1346,8 +1346,8 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream )
|
||||||
XP_U32 gameID;
|
XP_U32 gameID;
|
||||||
PoolContext* pool;
|
PoolContext* pool;
|
||||||
#ifdef STREAM_VERS_BIGBOARD
|
#ifdef STREAM_VERS_BIGBOARD
|
||||||
VDECL( XP_UCHAR, rmtDictName,128 );
|
XP_UCHAR rmtDictName[128];
|
||||||
VDECL( XP_UCHAR, rmtDictSum, 64 );
|
XP_UCHAR rmtDictSum[64];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* version; any dependencies here? */
|
/* version; any dependencies here? */
|
||||||
|
@ -3172,11 +3172,10 @@ server_figureFinishBonus( const ServerCtxt* server, XP_U16 turn )
|
||||||
if ( 0 < nOthers ) {
|
if ( 0 < nOthers ) {
|
||||||
Tile tile;
|
Tile tile;
|
||||||
const DictionaryCtxt* dict = model_getDictionary( server->vol.model );
|
const DictionaryCtxt* dict = model_getDictionary( server->vol.model );
|
||||||
const size_t numFaces = dict_numTileFaces( dict );
|
XP_U16 counts[dict_numTileFaces( dict )];
|
||||||
XP_U16 counts[numFaces];
|
|
||||||
XP_MEMSET( counts, 0, sizeof(counts) );
|
XP_MEMSET( counts, 0, sizeof(counts) );
|
||||||
model_countAllTrayTiles( server->vol.model, counts, turn );
|
model_countAllTrayTiles( server->vol.model, counts, turn );
|
||||||
for ( tile = 0; tile < numFaces; ++tile ) {
|
for ( tile = 0; tile < VSIZE(counts); ++tile ) {
|
||||||
XP_U16 count = counts[tile];
|
XP_U16 count = counts[tile];
|
||||||
if ( 0 < count ) {
|
if ( 0 < count ) {
|
||||||
result += count * dict_getTileValue( dict, tile );
|
result += count * dict_getTileValue( dict, tile );
|
||||||
|
|
|
@ -668,7 +668,7 @@ restorePartials( SMSProto* state )
|
||||||
&& PARTIALS_FORMAT == stream_getU8( stream ) ) {
|
&& PARTIALS_FORMAT == stream_getU8( stream ) ) {
|
||||||
int nFromPhones = stream_getU8( stream );
|
int nFromPhones = stream_getU8( stream );
|
||||||
for ( int ii = 0; ii < nFromPhones; ++ii ) {
|
for ( int ii = 0; ii < nFromPhones; ++ii ) {
|
||||||
VDECL( XP_UCHAR, phone, 32 );
|
XP_UCHAR phone[32];
|
||||||
(void)stringFromStreamHere( stream, phone, VSIZE(phone) );
|
(void)stringFromStreamHere( stream, phone, VSIZE(phone) );
|
||||||
int nMsgIDs = stream_getU8( stream );
|
int nMsgIDs = stream_getU8( stream );
|
||||||
XP_LOGF( "%s(): got %d message records for phone %s", __func__,
|
XP_LOGF( "%s(): got %d message records for phone %s", __func__,
|
||||||
|
@ -861,7 +861,7 @@ smsproto_runTests( MPFORMAL XW_DUtilCtxt* dutil )
|
||||||
SMSProto* state = smsproto_init( mpool, dutil );
|
SMSProto* state = smsproto_init( mpool, dutil );
|
||||||
|
|
||||||
const int smallSiz = 20;
|
const int smallSiz = 20;
|
||||||
VDECL(char*, phones, 4) = {"1234", "3456", "5467", "9877"};
|
const char* phones[] = {"1234", "3456", "5467", "9877"};
|
||||||
const char* buf = "asoidfaisdfoausdf aiousdfoiu asodfu oiuasdofi oiuaosiduf oaisudf oiasd f"
|
const char* buf = "asoidfaisdfoausdf aiousdfoiu asodfu oiuasdofi oiuaosiduf oaisudf oiasd f"
|
||||||
";oiaisdjfljiojaklj asdlkjalskdjf laksjd flkjasdlfkj aldsjkf lsakdjf lkjsad flkjsd fl;kj"
|
";oiaisdjfljiojaklj asdlkjalskdjf laksjd flkjasdlfkj aldsjkf lsakdjf lkjsad flkjsd fl;kj"
|
||||||
"asdifaoaosidfoiauosidufoaus doifuoaiusdoifu aoisudfoaisd foia sdoifuasodfu aosiud foiuas odfiu asd"
|
"asdifaoaosidfoiauosidufoaus doifuoaiusdoifu aoisudfoaisd foia sdoifuasodfu aosiud foiuas odfiu asd"
|
||||||
|
@ -869,7 +869,7 @@ smsproto_runTests( MPFORMAL XW_DUtilCtxt* dutil )
|
||||||
;
|
;
|
||||||
const XP_Bool forceOld = XP_TRUE;
|
const XP_Bool forceOld = XP_TRUE;
|
||||||
|
|
||||||
VDECL( SMSMsgArray*, arrs, VSIZE(phones) );
|
SMSMsgArray* arrs[VSIZE(phones)];
|
||||||
for ( int ii = 0; ii < VSIZE(arrs); ++ii ) {
|
for ( int ii = 0; ii < VSIZE(arrs); ++ii ) {
|
||||||
arrs[ii] = NULL;
|
arrs[ii] = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -409,7 +409,7 @@ getSelTiles( const BoardCtxt* board, TileBit selBits, TrayTileSet* selTiles )
|
||||||
for ( index = 0; selBits != 0; selBits >>= 1, ++index ) {
|
for ( index = 0; selBits != 0; selBits >>= 1, ++index ) {
|
||||||
if ( 0 != (selBits & 0x01) ) {
|
if ( 0 != (selBits & 0x01) ) {
|
||||||
Tile tile = model_getPlayerTile( model, turn, index );
|
Tile tile = model_getPlayerTile( model, turn, index );
|
||||||
XP_ASSERT( nTiles < MAX_TRAY_TILES );
|
XP_ASSERT( nTiles < VSIZE(selTiles->tiles) );
|
||||||
selTiles->tiles[nTiles++] = tile;
|
selTiles->tiles[nTiles++] = tile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ curses_draw_measureRemText( DrawCtx* XP_UNUSED(dctx),
|
||||||
XP_U16* width, XP_U16* height )
|
XP_U16* width, XP_U16* height )
|
||||||
{
|
{
|
||||||
char buf[64];
|
char buf[64];
|
||||||
VDECL( char*, lines, 2 ) = {0};
|
char* lines[2] = {0};
|
||||||
formatRemText( nTilesLeft, rect, buf, lines );
|
formatRemText( nTilesLeft, rect, buf, lines );
|
||||||
|
|
||||||
*width = 0;
|
*width = 0;
|
||||||
|
@ -170,7 +170,7 @@ curses_draw_drawRemText( DrawCtx* p_dctx, const XP_Rect* rInner,
|
||||||
CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx;
|
CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx;
|
||||||
char buf[32];
|
char buf[32];
|
||||||
|
|
||||||
VDECL( char*, lines, 2 ) = {0};
|
char* lines[2] = {0};
|
||||||
formatRemText( nTilesLeft, rInner, buf, lines );
|
formatRemText( nTilesLeft, rInner, buf, lines );
|
||||||
int ii;
|
int ii;
|
||||||
for ( ii = 0; ii < VSIZE(lines) && !!lines[ii]; ++ii ) {
|
for ( ii = 0; ii < VSIZE(lines) && !!lines[ii]; ++ii ) {
|
||||||
|
@ -270,7 +270,7 @@ curses_draw_measureScoreText( DrawCtx* XP_UNUSED(p_dctx),
|
||||||
XP_U16* width, XP_U16* height )
|
XP_U16* width, XP_U16* height )
|
||||||
{
|
{
|
||||||
XP_UCHAR buf[100];
|
XP_UCHAR buf[100];
|
||||||
VDECL( char*, lines, 3 ) = {0};
|
char* lines[3] = {0};
|
||||||
formatScoreText( buf, dsi, rect, lines );
|
formatScoreText( buf, dsi, rect, lines );
|
||||||
|
|
||||||
int ii;
|
int ii;
|
||||||
|
@ -295,7 +295,7 @@ curses_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner,
|
||||||
curses_draw_clearRect( p_dctx, rOuter );
|
curses_draw_clearRect( p_dctx, rOuter );
|
||||||
|
|
||||||
/* print the name and turn/remoteness indicator */
|
/* print the name and turn/remoteness indicator */
|
||||||
VDECL( char*, lines, 3 ) = {0};
|
char* lines[3] = {0};
|
||||||
formatScoreText( buf, dsi, rInner, lines );
|
formatScoreText( buf, dsi, rInner, lines );
|
||||||
int ii;
|
int ii;
|
||||||
for ( ii = 0; ii < VSIZE(lines) && !!lines[ii]; ++ii ) {
|
for ( ii = 0; ii < VSIZE(lines) && !!lines[ii]; ++ii ) {
|
||||||
|
|
|
@ -57,7 +57,7 @@ curses_askLetter( CursesAppGlobals* globals, XP_UCHAR* query,
|
||||||
short curSelButton = 1; /* force draw by being different */
|
short curSelButton = 1; /* force draw by being different */
|
||||||
short maxWidth;
|
short maxWidth;
|
||||||
short numCtlButtons;
|
short numCtlButtons;
|
||||||
VDECL( const char*, ctlButtons, 2 ) = { "Ok", "Cancel" };
|
const char* ctlButtons[] = { "Ok", "Cancel" };
|
||||||
XP_Bool dismissed = XP_FALSE;
|
XP_Bool dismissed = XP_FALSE;
|
||||||
FormatInfo fi;
|
FormatInfo fi;
|
||||||
int len;
|
int len;
|
||||||
|
|
|
@ -221,7 +221,7 @@ cursesUserError( CursesAppGlobals* globals, const char* format, ... )
|
||||||
|
|
||||||
vsprintf( buf, format, ap );
|
vsprintf( buf, format, ap );
|
||||||
|
|
||||||
VDECL( const char*, buttons, 1 ) = {"OK"};
|
const char* buttons[] = {"OK"};
|
||||||
(void)cursesask( globals, buf, VSIZE(buttons), buttons );
|
(void)cursesask( globals, buf, VSIZE(buttons), buttons );
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
@ -285,7 +285,7 @@ ask_move( gpointer data )
|
||||||
{
|
{
|
||||||
CursesAppGlobals* globals = (CursesAppGlobals*)data;
|
CursesAppGlobals* globals = (CursesAppGlobals*)data;
|
||||||
CommonGlobals* cGlobals = &globals->cGlobals;
|
CommonGlobals* cGlobals = &globals->cGlobals;
|
||||||
VDECL( const char*, answers, 3 ) = {"Ok", "Cancel", NULL};
|
const char* answers[] = {"Ok", "Cancel", NULL};
|
||||||
|
|
||||||
if (0 == cursesask(globals, cGlobals->question, VSIZE(answers)-1, answers) ) {
|
if (0 == cursesask(globals, cGlobals->question, VSIZE(answers)-1, answers) ) {
|
||||||
BoardCtxt* board = cGlobals->game.board;
|
BoardCtxt* board = cGlobals->game.board;
|
||||||
|
@ -304,7 +304,7 @@ curses_util_notifyMove( XW_UtilCtxt* uc, XWStreamCtxt* stream )
|
||||||
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
|
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
|
||||||
CommonGlobals* cGlobals = &globals->cGlobals;
|
CommonGlobals* cGlobals = &globals->cGlobals;
|
||||||
XP_U16 len = stream_getSize( stream );
|
XP_U16 len = stream_getSize( stream );
|
||||||
XP_ASSERT( len <= QUESTION_LEN );
|
XP_ASSERT( len <= VSIZE(cGlobals->question) );
|
||||||
stream_getBytes( stream, cGlobals->question, len );
|
stream_getBytes( stream, cGlobals->question, len );
|
||||||
(void)g_idle_add( ask_move, globals );
|
(void)g_idle_add( ask_move, globals );
|
||||||
} /* curses_util_userQuery */
|
} /* curses_util_userQuery */
|
||||||
|
@ -315,7 +315,7 @@ ask_trade( gpointer data )
|
||||||
CursesAppGlobals* globals = (CursesAppGlobals*)data;
|
CursesAppGlobals* globals = (CursesAppGlobals*)data;
|
||||||
CommonGlobals* cGlobals = &globals->cGlobals;
|
CommonGlobals* cGlobals = &globals->cGlobals;
|
||||||
|
|
||||||
VDECL( const char*, buttons, 2 ) = { "Ok", "Cancel" };
|
const char* buttons[] = { "Ok", "Cancel" };
|
||||||
if (0 == cursesask( globals, cGlobals->question, VSIZE(buttons), buttons ) ) {
|
if (0 == cursesask( globals, cGlobals->question, VSIZE(buttons), buttons ) ) {
|
||||||
BoardCtxt* board = cGlobals->game.board;
|
BoardCtxt* board = cGlobals->game.board;
|
||||||
if ( board_commitTurn( board, XP_TRUE, XP_TRUE, NULL ) ) {
|
if ( board_commitTurn( board, XP_TRUE, XP_TRUE, NULL ) ) {
|
||||||
|
@ -353,7 +353,7 @@ cursesShowFinalScores( CursesAppGlobals* globals )
|
||||||
|
|
||||||
text = strFromStream( stream );
|
text = strFromStream( stream );
|
||||||
|
|
||||||
VDECL( const char*, buttons, 1 ) = { "Ok" };
|
const char* buttons[] = { "Ok" };
|
||||||
(void)cursesask( globals, text, VSIZE(buttons), buttons );
|
(void)cursesask( globals, text, VSIZE(buttons), buttons );
|
||||||
|
|
||||||
free( text );
|
free( text );
|
||||||
|
@ -366,7 +366,7 @@ curses_util_informMove( XW_UtilCtxt* uc, XP_S16 XP_UNUSED(turn),
|
||||||
{
|
{
|
||||||
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
|
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
|
||||||
char* question = strFromStream( expl );
|
char* question = strFromStream( expl );
|
||||||
VDECL( const char*, buttons, 1 ) = { "Ok" };
|
const char* buttons[] = { "Ok" };
|
||||||
(void)cursesask( globals, question, VSIZE(buttons), buttons );
|
(void)cursesask( globals, question, VSIZE(buttons), buttons );
|
||||||
free( question );
|
free( question );
|
||||||
}
|
}
|
||||||
|
@ -1412,7 +1412,7 @@ curses_util_remSelected( XW_UtilCtxt* uc )
|
||||||
|
|
||||||
text = strFromStream( stream );
|
text = strFromStream( stream );
|
||||||
|
|
||||||
VDECL( const char*, buttons, 1 ) = { "Ok" };
|
const char* buttons[] = { "Ok" };
|
||||||
(void)cursesask( globals, text, VSIZE(buttons), buttons );
|
(void)cursesask( globals, text, VSIZE(buttons), buttons );
|
||||||
|
|
||||||
free( text );
|
free( text );
|
||||||
|
@ -1795,7 +1795,7 @@ cursesErrorMsgRcvd( void* closure, const XP_UCHAR* msg )
|
||||||
} else {
|
} else {
|
||||||
g_free( globals->lastErr );
|
g_free( globals->lastErr );
|
||||||
globals->lastErr = g_strdup( msg );
|
globals->lastErr = g_strdup( msg );
|
||||||
VDECL( const char*, buttons, 1 ) = { "Ok" };
|
const char* buttons[] = { "Ok" };
|
||||||
(void)cursesask( globals, msg, VSIZE(buttons), buttons );
|
(void)cursesask( globals, msg, VSIZE(buttons), buttons );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2015,7 +2015,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XWFEATURE_SMS
|
#ifdef XWFEATURE_SMS
|
||||||
VDECL( gchar, buf, 32 );
|
gchar buf[32];
|
||||||
const gchar* myPhone = params->connInfo.sms.myPhone;
|
const gchar* myPhone = params->connInfo.sms.myPhone;
|
||||||
if ( !!myPhone ) {
|
if ( !!myPhone ) {
|
||||||
db_store( params->pDb, KEY_SMSPHONE, myPhone );
|
db_store( params->pDb, KEY_SMSPHONE, myPhone );
|
||||||
|
@ -2023,7 +2023,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
|
||||||
params->connInfo.sms.myPhone = myPhone = buf;
|
params->connInfo.sms.myPhone = myPhone = buf;
|
||||||
}
|
}
|
||||||
XP_U16 myPort = params->connInfo.sms.port;
|
XP_U16 myPort = params->connInfo.sms.port;
|
||||||
VDECL( gchar, portbuf, 8 );
|
gchar portbuf[8];
|
||||||
if ( 0 < myPort ) {
|
if ( 0 < myPort ) {
|
||||||
sprintf( portbuf, "%d", myPort );
|
sprintf( portbuf, "%d", myPort );
|
||||||
db_store( params->pDb, KEY_SMSPORT, portbuf );
|
db_store( params->pDb, KEY_SMSPORT, portbuf );
|
||||||
|
|
|
@ -222,7 +222,7 @@ summarize( CommonGlobals* cGlobals )
|
||||||
|
|
||||||
// gchar* connvia = "local";
|
// gchar* connvia = "local";
|
||||||
gchar connvia[128] = {0};
|
gchar connvia[128] = {0};
|
||||||
VDECL( XP_UCHAR, relayID, 32 ) = {0};
|
XP_UCHAR relayID[32] = {0};
|
||||||
|
|
||||||
if ( !!game->comms ) {
|
if ( !!game->comms ) {
|
||||||
nMissing = server_getMissingPlayers( game->server );
|
nMissing = server_getMissingPlayers( game->server );
|
||||||
|
@ -341,7 +341,7 @@ getRelayIDsToRowsMap( sqlite3* pDb )
|
||||||
switch( sqlite3_step( ppStmt ) ) {
|
switch( sqlite3_step( ppStmt ) ) {
|
||||||
case SQLITE_ROW: /* have data */
|
case SQLITE_ROW: /* have data */
|
||||||
{
|
{
|
||||||
VDECL( XP_UCHAR, relayID, 32 );
|
XP_UCHAR relayID[32];
|
||||||
int len = VSIZE(relayID);
|
int len = VSIZE(relayID);
|
||||||
getColumnText( ppStmt, 0, relayID, &len );
|
getColumnText( ppStmt, 0, relayID, &len );
|
||||||
gpointer key = g_strdup( relayID );
|
gpointer key = g_strdup( relayID );
|
||||||
|
|
|
@ -1113,7 +1113,7 @@ change_dictionary( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
||||||
CommonGlobals* cGlobals = &globals->cGlobals;
|
CommonGlobals* cGlobals = &globals->cGlobals;
|
||||||
LaunchParams* params = cGlobals->params;
|
LaunchParams* params = cGlobals->params;
|
||||||
GSList* dicts = listDicts( params );
|
GSList* dicts = listDicts( params );
|
||||||
VDECL( gchar, buf, 265 );
|
gchar buf[265];
|
||||||
gchar* name = gtkaskdict( dicts, buf, VSIZE(buf) );
|
gchar* name = gtkaskdict( dicts, buf, VSIZE(buf) );
|
||||||
if ( !!name ) {
|
if ( !!name ) {
|
||||||
DictionaryCtxt* dict =
|
DictionaryCtxt* dict =
|
||||||
|
@ -1662,7 +1662,7 @@ send_invites( CommonGlobals* cGlobals, XP_U16 nPlayers,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( '\0' != addrs->u.sms.phone[0] && 0 < addrs->u.sms.port ) {
|
if ( '\0' != addrs->u.sms.phone[0] && 0 < addrs->u.sms.port ) {
|
||||||
VDECL( gchar, gameName, 64 );
|
gchar gameName[64];
|
||||||
snprintf( gameName, VSIZE(gameName), "Game %d", cGlobals->gi->gameID );
|
snprintf( gameName, VSIZE(gameName), "Game %d", cGlobals->gi->gameID );
|
||||||
|
|
||||||
linux_sms_invite( cGlobals->params, &nli,
|
linux_sms_invite( cGlobals->params, &nli,
|
||||||
|
@ -1844,7 +1844,7 @@ ask_password( gpointer data )
|
||||||
{
|
{
|
||||||
GtkGameGlobals* globals = (GtkGameGlobals*)data;
|
GtkGameGlobals* globals = (GtkGameGlobals*)data;
|
||||||
CommonGlobals* cGlobals = &globals->cGlobals;
|
CommonGlobals* cGlobals = &globals->cGlobals;
|
||||||
VDECL( XP_UCHAR, buf, 32 );
|
XP_UCHAR buf[32];
|
||||||
XP_U16 len = VSIZE(buf);
|
XP_U16 len = VSIZE(buf);
|
||||||
if ( gtkpasswdask( cGlobals->askPassName, buf, &len ) ) {
|
if ( gtkpasswdask( cGlobals->askPassName, buf, &len ) ) {
|
||||||
BoardCtxt* board = cGlobals->game.board;
|
BoardCtxt* board = cGlobals->game.board;
|
||||||
|
@ -2003,7 +2003,7 @@ gtk_util_informNetDict( XW_UtilCtxt* uc, XP_LangCode XP_UNUSED(lang),
|
||||||
{
|
{
|
||||||
if ( 0 != strcmp( oldName, newName ) ) {
|
if ( 0 != strcmp( oldName, newName ) ) {
|
||||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||||
VDECL( gchar, buf, 512 );
|
gchar buf[512];
|
||||||
int offset = snprintf( buf, VSIZE(buf),
|
int offset = snprintf( buf, VSIZE(buf),
|
||||||
"dict changing from %s to %s (sum=%s).",
|
"dict changing from %s to %s (sum=%s).",
|
||||||
oldName, newName, newSum );
|
oldName, newName, newSum );
|
||||||
|
@ -2298,7 +2298,7 @@ gtk_util_showChat( XW_UtilCtxt* uc, const XP_UCHAR* const msg, XP_S16 from,
|
||||||
XP_U32 timestamp )
|
XP_U32 timestamp )
|
||||||
{
|
{
|
||||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||||
VDECL( XP_UCHAR, buf, 1024 );
|
XP_UCHAR buf[1024];
|
||||||
XP_UCHAR* name = "<unknown>";
|
XP_UCHAR* name = "<unknown>";
|
||||||
if ( 0 <= from ) {
|
if ( 0 <= from ) {
|
||||||
name = globals->cGlobals.gi->players[from].name;
|
name = globals->cGlobals.gi->players[from].name;
|
||||||
|
@ -2338,7 +2338,7 @@ gtk_util_playerScoreHeld( XW_UtilCtxt* uc, XP_U16 player )
|
||||||
LastMoveInfo lmi;
|
LastMoveInfo lmi;
|
||||||
if ( model_getPlayersLastScore( globals->cGlobals.game.model,
|
if ( model_getPlayersLastScore( globals->cGlobals.game.model,
|
||||||
player, &lmi ) ) {
|
player, &lmi ) ) {
|
||||||
VDECL( XP_UCHAR, buf, 128 );
|
XP_UCHAR buf[128];
|
||||||
formatLMI( &lmi, buf, VSIZE(buf) );
|
formatLMI( &lmi, buf, VSIZE(buf) );
|
||||||
(void)gtkask( globals->window, buf, GTK_BUTTONS_OK, NULL );
|
(void)gtkask( globals->window, buf, GTK_BUTTONS_OK, NULL );
|
||||||
}
|
}
|
||||||
|
@ -2393,7 +2393,7 @@ gtk_util_notifyMove( XW_UtilCtxt* uc, XWStreamCtxt* stream )
|
||||||
/* XP_Bool freeMe = XP_FALSE; */
|
/* XP_Bool freeMe = XP_FALSE; */
|
||||||
|
|
||||||
XP_U16 len = stream_getSize( stream );
|
XP_U16 len = stream_getSize( stream );
|
||||||
XP_ASSERT( len <= QUESTION_LEN );
|
XP_ASSERT( len <= VSIZE(cGlobals->question) );
|
||||||
stream_getBytes( stream, cGlobals->question, len );
|
stream_getBytes( stream, cGlobals->question, len );
|
||||||
(void)g_idle_add( ask_move, globals );
|
(void)g_idle_add( ask_move, globals );
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ conTypeToPageNum( const GtkConnsState* state, CommsConnType conType )
|
||||||
pageNum = ii;
|
pageNum = ii;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
XP_ASSERT( ii < COMMS_CONN_NTYPES );
|
XP_ASSERT( ii < VSIZE(state->pageData) );
|
||||||
}
|
}
|
||||||
return pageNum;
|
return pageNum;
|
||||||
}
|
}
|
||||||
|
|
|
@ -745,7 +745,7 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
|
||||||
XP_Bool clearBack )
|
XP_Bool clearBack )
|
||||||
{
|
{
|
||||||
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
||||||
VDECL( XP_UCHAR, numbuf, 3 );
|
XP_UCHAR numbuf[3];
|
||||||
XP_Rect insetR = *rect;
|
XP_Rect insetR = *rect;
|
||||||
XP_Bool isCursor = (flags & CELL_ISCURSOR) != 0;
|
XP_Bool isCursor = (flags & CELL_ISCURSOR) != 0;
|
||||||
XP_Bool valHidden = (flags & CELL_VALHIDDEN) != 0;
|
XP_Bool valHidden = (flags & CELL_VALHIDDEN) != 0;
|
||||||
|
@ -1113,13 +1113,13 @@ formatScoreText( PangoLayout* layout, XP_UCHAR* buf, XP_U16 bufLen,
|
||||||
XP_U16 nTilesLeft = dsi->nTilesLeft;
|
XP_U16 nTilesLeft = dsi->nTilesLeft;
|
||||||
XP_Bool isTurn = dsi->isTurn;
|
XP_Bool isTurn = dsi->isTurn;
|
||||||
XP_S16 maxWidth = bounds->width;
|
XP_S16 maxWidth = bounds->width;
|
||||||
VDECL( XP_UCHAR, numBuf, 16 );
|
XP_UCHAR numBuf[16];
|
||||||
int width, height;
|
int width, height;
|
||||||
*nLines = 1;
|
*nLines = 1;
|
||||||
|
|
||||||
XP_SNPRINTF( numBuf, VSIZE(numBuf), "%d", score );
|
XP_SNPRINTF( numBuf, VSIZE(numBuf), "%d", score );
|
||||||
if ( (nTilesLeft < MAX_TRAY_TILES) && (nTilesLeft > 0) ) {
|
if ( (nTilesLeft < MAX_TRAY_TILES) && (nTilesLeft > 0) ) {
|
||||||
VDECL( XP_UCHAR, tmp, 10 );
|
XP_UCHAR tmp[10];
|
||||||
XP_SNPRINTF( tmp, VSIZE(tmp), ":%d", nTilesLeft );
|
XP_SNPRINTF( tmp, VSIZE(tmp), ":%d", nTilesLeft );
|
||||||
(void)XP_STRCAT( numBuf, tmp );
|
(void)XP_STRCAT( numBuf, tmp );
|
||||||
}
|
}
|
||||||
|
@ -1134,7 +1134,7 @@ formatScoreText( PangoLayout* layout, XP_UCHAR* buf, XP_U16 bufLen,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reformat name + ':' until it fits */
|
/* Reformat name + ':' until it fits */
|
||||||
VDECL( XP_UCHAR, name, MAX_SCORE_LEN ) = { 0 };
|
XP_UCHAR name[MAX_SCORE_LEN] = { 0 };
|
||||||
if ( isTurn && maxWidth > 0 ) {
|
if ( isTurn && maxWidth > 0 ) {
|
||||||
XP_U16 len = 1 + XP_STRLEN( dsi->name ); /* +1 for "\0" */
|
XP_U16 len = 1 + XP_STRLEN( dsi->name ); /* +1 for "\0" */
|
||||||
if ( scoreIsVertical ) {
|
if ( scoreIsVertical ) {
|
||||||
|
@ -1181,7 +1181,7 @@ gtk_draw_measureScoreText( DrawCtx* p_dctx, const XP_Rect* bounds,
|
||||||
XP_U16* widthP, XP_U16* heightP )
|
XP_U16* widthP, XP_U16* heightP )
|
||||||
{
|
{
|
||||||
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
||||||
VDECL( XP_UCHAR, buf, 36 );
|
XP_UCHAR buf[36];
|
||||||
PangoLayout* layout;
|
PangoLayout* layout;
|
||||||
int lineHeight = GTK_HOR_SCORE_HEIGHT, nLines;
|
int lineHeight = GTK_HOR_SCORE_HEIGHT, nLines;
|
||||||
|
|
||||||
|
@ -1191,9 +1191,9 @@ gtk_draw_measureScoreText( DrawCtx* p_dctx, const XP_Rect* bounds,
|
||||||
*heightP = nLines * lineHeight;
|
*heightP = nLines * lineHeight;
|
||||||
|
|
||||||
XP_U16 playerNum = dsi->playerNum;
|
XP_U16 playerNum = dsi->playerNum;
|
||||||
XP_ASSERT( playerNum < MAX_NUM_PLAYERS );
|
XP_ASSERT( playerNum < VSIZE(dctx->scoreCache) );
|
||||||
XP_SNPRINTF( dctx->scoreCache[playerNum].str,
|
XP_SNPRINTF( dctx->scoreCache[playerNum].str,
|
||||||
MAX_SCORE_LEN+1, "%s", buf );
|
VSIZE(dctx->scoreCache[playerNum].str), "%s", buf );
|
||||||
dctx->scoreCache[playerNum].fontHt = lineHeight;
|
dctx->scoreCache[playerNum].fontHt = lineHeight;
|
||||||
} /* gtk_draw_measureScoreText */
|
} /* gtk_draw_measureScoreText */
|
||||||
|
|
||||||
|
@ -1203,7 +1203,7 @@ gtk_draw_score_pendingScore( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||||
XP_S16 curTurn, CellFlags flags )
|
XP_S16 curTurn, CellFlags flags )
|
||||||
{
|
{
|
||||||
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
||||||
VDECL( XP_UCHAR, buf, 5 );
|
XP_UCHAR buf[5];
|
||||||
XP_U16 ht;
|
XP_U16 ht;
|
||||||
XP_Rect localR;
|
XP_Rect localR;
|
||||||
GdkRGBA* cursor = ((flags & CELL_ISCURSOR) != 0)
|
GdkRGBA* cursor = ((flags & CELL_ISCURSOR) != 0)
|
||||||
|
@ -1259,7 +1259,7 @@ gtk_draw_drawTimer( DrawCtx* p_dctx, const XP_Rect* rInner,
|
||||||
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
||||||
XP_Bool hadCairo = haveCairo( dctx );
|
XP_Bool hadCairo = haveCairo( dctx );
|
||||||
if ( hadCairo || initCairo( dctx ) ) {
|
if ( hadCairo || initCairo( dctx ) ) {
|
||||||
VDECL( XP_UCHAR, buf, 10 );
|
XP_UCHAR buf[10];
|
||||||
|
|
||||||
gtkFormatTimerText( buf, VSIZE(buf), secondsLeft );
|
gtkFormatTimerText( buf, VSIZE(buf), secondsLeft );
|
||||||
|
|
||||||
|
@ -1406,10 +1406,8 @@ gtkDrawCtxtMake( GtkWidget* drawing_area, GtkGameGlobals* globals )
|
||||||
|
|
||||||
dctx->vtable = g_malloc( sizeof(*(((GtkDrawCtx*)dctx)->vtable)) );
|
dctx->vtable = g_malloc( sizeof(*(((GtkDrawCtx*)dctx)->vtable)) );
|
||||||
|
|
||||||
void** ptr = (void**)dctx->vtable;
|
for ( int ii = 0; ii < VSIZE(dctx->vtable); ++ii ) {
|
||||||
void** tableEnd = (void**)&dctx->vtable->tableEnd;
|
((void**)(dctx->vtable))[ii] = draw_doNothing; /* bad? */
|
||||||
while ( ptr < tableEnd ) {
|
|
||||||
*ptr++ = draw_doNothing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, gtk );
|
SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, gtk );
|
||||||
|
|
|
@ -76,7 +76,7 @@ conTypeToPageNum( const GtkInviteState* state, CommsConnType conType )
|
||||||
pageNum = ii;
|
pageNum = ii;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
XP_ASSERT( ii < COMMS_CONN_NTYPES );
|
XP_ASSERT( ii < VSIZE(state->pageData) );
|
||||||
}
|
}
|
||||||
return pageNum;
|
return pageNum;
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,7 +350,7 @@ make_rematch( GtkAppGlobals* apg, const CommonGlobals* cGlobals )
|
||||||
comms_getAddr( comms, &addr );
|
comms_getAddr( comms, &addr );
|
||||||
addrToStream( stream, &addr );
|
addrToStream( stream, &addr );
|
||||||
|
|
||||||
VDECL( CommsAddrRec, addrs, 4 );
|
CommsAddrRec addrs[4];
|
||||||
XP_U16 nRecs = VSIZE(addrs);
|
XP_U16 nRecs = VSIZE(addrs);
|
||||||
comms_getAddrs( comms, addrs, &nRecs );
|
comms_getAddrs( comms, addrs, &nRecs );
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ setWindowTitle( GtkAppGlobals* apg )
|
||||||
GtkWidget* window = apg->window;
|
GtkWidget* window = apg->window;
|
||||||
LaunchParams* params = apg->params;
|
LaunchParams* params = apg->params;
|
||||||
|
|
||||||
VDECL( gchar, title, 128 ) = {0};
|
gchar title[128] = {0};
|
||||||
if ( !!params->dbName ) {
|
if ( !!params->dbName ) {
|
||||||
strcat( title, params->dbName );
|
strcat( title, params->dbName );
|
||||||
}
|
}
|
||||||
|
@ -696,7 +696,7 @@ relayInviteReceived( void* closure, NetLaunchInfo* invite )
|
||||||
GtkAppGlobals* apg = (GtkAppGlobals*)closure;
|
GtkAppGlobals* apg = (GtkAppGlobals*)closure;
|
||||||
|
|
||||||
XP_U32 gameID = invite->gameID;
|
XP_U32 gameID = invite->gameID;
|
||||||
VDECL( sqlite3_int64, rowids, 1 );
|
sqlite3_int64 rowids[1];
|
||||||
int nRowIDs = VSIZE(rowids);
|
int nRowIDs = VSIZE(rowids);
|
||||||
getRowsForGameID( apg->params->pDb, gameID, rowids, &nRowIDs );
|
getRowsForGameID( apg->params->pDb, gameID, rowids, &nRowIDs );
|
||||||
|
|
||||||
|
@ -782,7 +782,7 @@ smsMsgReceivedGTK( void* closure, const CommsAddrRec* from, XP_U32 gameID,
|
||||||
GtkAppGlobals* apg = (GtkAppGlobals*)closure;
|
GtkAppGlobals* apg = (GtkAppGlobals*)closure;
|
||||||
LaunchParams* params = apg->params;
|
LaunchParams* params = apg->params;
|
||||||
|
|
||||||
VDECL( sqlite3_int64, rowids, 4 );
|
sqlite3_int64 rowids[4];
|
||||||
int nRowIDs = VSIZE(rowids);
|
int nRowIDs = VSIZE(rowids);
|
||||||
getRowsForGameID( params->pDb, gameID, rowids, &nRowIDs );
|
getRowsForGameID( params->pDb, gameID, rowids, &nRowIDs );
|
||||||
XP_LOGF( "%s: found %d rows for gameID %d", __func__, nRowIDs, gameID );
|
XP_LOGF( "%s: found %d rows for gameID %d", __func__, nRowIDs, gameID );
|
||||||
|
@ -888,7 +888,7 @@ gtkmain( LaunchParams* params )
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XWFEATURE_SMS
|
#ifdef XWFEATURE_SMS
|
||||||
VDECL( gchar, buf, 32 );
|
gchar buf[32];
|
||||||
const gchar* myPhone = params->connInfo.sms.myPhone;
|
const gchar* myPhone = params->connInfo.sms.myPhone;
|
||||||
if ( !!myPhone ) {
|
if ( !!myPhone ) {
|
||||||
db_store( params->pDb, KEY_SMSPHONE, myPhone );
|
db_store( params->pDb, KEY_SMSPHONE, myPhone );
|
||||||
|
@ -896,7 +896,7 @@ gtkmain( LaunchParams* params )
|
||||||
params->connInfo.sms.myPhone = myPhone = buf;
|
params->connInfo.sms.myPhone = myPhone = buf;
|
||||||
}
|
}
|
||||||
XP_U16 myPort = params->connInfo.sms.port;
|
XP_U16 myPort = params->connInfo.sms.port;
|
||||||
VDECL( gchar, portbuf, 8 );
|
gchar portbuf[8];
|
||||||
if ( 0 < myPort ) {
|
if ( 0 < myPort ) {
|
||||||
sprintf( portbuf, "%d", myPort );
|
sprintf( portbuf, "%d", myPort );
|
||||||
db_store( params->pDb, KEY_SMSPORT, portbuf );
|
db_store( params->pDb, KEY_SMSPORT, portbuf );
|
||||||
|
|
|
@ -216,7 +216,8 @@ addPhoniesCombo( GtkNewGameState* state, GtkWidget* parent )
|
||||||
FALSE, TRUE, 0 );
|
FALSE, TRUE, 0 );
|
||||||
GtkWidget* phoniesCombo = gtk_combo_box_text_new();
|
GtkWidget* phoniesCombo = gtk_combo_box_text_new();
|
||||||
|
|
||||||
VDECL( const char*, ptxts, 3 ) = { "IGNORE", "WARN", "DISALLOW" };
|
const char* ptxts[] = { "IGNORE", "WARN", "DISALLOW" };
|
||||||
|
|
||||||
for ( int ii = 0; ii < VSIZE(ptxts); ++ii ) {
|
for ( int ii = 0; ii < VSIZE(ptxts); ++ii ) {
|
||||||
gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT(phoniesCombo),
|
gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT(phoniesCombo),
|
||||||
ptxts[ii] );
|
ptxts[ii] );
|
||||||
|
@ -239,7 +240,7 @@ makeNewGameDialog( GtkNewGameState* state )
|
||||||
GtkWidget* hbox;
|
GtkWidget* hbox;
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||||
GtkWidget* roleCombo;
|
GtkWidget* roleCombo;
|
||||||
VDECL( char*, roles, 3 ) = { "Standalone", "Host", "Guest" };
|
char* roles[] = { "Standalone", "Host", "Guest" };
|
||||||
#endif
|
#endif
|
||||||
GtkWidget* nPlayersCombo;
|
GtkWidget* nPlayersCombo;
|
||||||
GtkWidget* boardSizeCombo;
|
GtkWidget* boardSizeCombo;
|
||||||
|
|
|
@ -268,7 +268,7 @@ initFromDictFile( LinuxDictionaryCtxt* dctx, const LaunchParams* params,
|
||||||
XP_Bool isUTF8 = XP_FALSE;
|
XP_Bool isUTF8 = XP_FALSE;
|
||||||
XP_Bool hasHeader = XP_FALSE;
|
XP_Bool hasHeader = XP_FALSE;
|
||||||
const XP_U8* ptr;
|
const XP_U8* ptr;
|
||||||
VDECL( char, path, 256 );
|
char path[256];
|
||||||
|
|
||||||
if ( !getDictPath( params, fileName, path, VSIZE(path) ) ) {
|
if ( !getDictPath( params, fileName, path, VSIZE(path) ) ) {
|
||||||
XP_LOGF( "%s: path=%s", __func__, path );
|
XP_LOGF( "%s: path=%s", __func__, path );
|
||||||
|
|
|
@ -327,7 +327,7 @@ catFinalScores( const CommonGlobals* cGlobals, XP_S16 quitter )
|
||||||
cGlobals->params->vtMgr,
|
cGlobals->params->vtMgr,
|
||||||
NULL, CHANNEL_NONE, catOnClose );
|
NULL, CHANNEL_NONE, catOnClose );
|
||||||
if ( -1 != quitter ) {
|
if ( -1 != quitter ) {
|
||||||
VDECL( XP_UCHAR, buf, 128 );
|
XP_UCHAR buf[128];
|
||||||
XP_SNPRINTF( buf, VSIZE(buf), "Player %s resigned\n",
|
XP_SNPRINTF( buf, VSIZE(buf), "Player %s resigned\n",
|
||||||
cGlobals->gi->players[quitter].name );
|
cGlobals->gi->players[quitter].name );
|
||||||
stream_catString( stream, buf );
|
stream_catString( stream, buf );
|
||||||
|
@ -818,7 +818,7 @@ static CmdInfoRec CmdInfoRecs[] = {
|
||||||
static struct option*
|
static struct option*
|
||||||
make_longopts()
|
make_longopts()
|
||||||
{
|
{
|
||||||
int count = N_CMDS;
|
int count = VSIZE( CmdInfoRecs );
|
||||||
struct option* result = calloc( count+1, sizeof(*result) );
|
struct option* result = calloc( count+1, sizeof(*result) );
|
||||||
int ii;
|
int ii;
|
||||||
for ( ii = 0; ii < count; ++ii ) {
|
for ( ii = 0; ii < count; ++ii ) {
|
||||||
|
@ -841,7 +841,7 @@ usage( char* appName, char* msg )
|
||||||
fprintf( stderr, "usage: %s \n", appName );
|
fprintf( stderr, "usage: %s \n", appName );
|
||||||
|
|
||||||
int maxWidth = 0;
|
int maxWidth = 0;
|
||||||
for ( ii = 0; ii < N_CMDS; ++ii ) {
|
for ( ii = 0; ii < VSIZE(CmdInfoRecs); ++ii ) {
|
||||||
const CmdInfoRec* rec = &CmdInfoRecs[ii];
|
const CmdInfoRec* rec = &CmdInfoRecs[ii];
|
||||||
int width = strlen(rec->param) + 1;
|
int width = strlen(rec->param) + 1;
|
||||||
if ( rec->hasArg ) {
|
if ( rec->hasArg ) {
|
||||||
|
@ -852,7 +852,7 @@ usage( char* appName, char* msg )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ii = 0; ii < N_CMDS; ++ii ) {
|
for ( ii = 0; ii < VSIZE(CmdInfoRecs); ++ii ) {
|
||||||
const CmdInfoRec* rec = &CmdInfoRecs[ii];
|
const CmdInfoRec* rec = &CmdInfoRecs[ii];
|
||||||
char buf[120];
|
char buf[120];
|
||||||
snprintf( buf, sizeof(buf), "--%s %s", rec->param,
|
snprintf( buf, sizeof(buf), "--%s %s", rec->param,
|
||||||
|
@ -1624,7 +1624,7 @@ static void
|
||||||
testGetNthWord( const DictionaryCtxt* dict, char** XP_UNUSED_DBG(words),
|
testGetNthWord( const DictionaryCtxt* dict, char** XP_UNUSED_DBG(words),
|
||||||
XP_U16 depth, IndexData* data, XP_U16 min, XP_U16 max )
|
XP_U16 depth, IndexData* data, XP_U16 min, XP_U16 max )
|
||||||
{
|
{
|
||||||
VDECL( XP_UCHAR, buf, 64 );
|
XP_UCHAR buf[64];
|
||||||
XP_U32 ii, jj;
|
XP_U32 ii, jj;
|
||||||
DictIter iter;
|
DictIter iter;
|
||||||
|
|
||||||
|
@ -1678,7 +1678,7 @@ walk_dict_test( MPFORMAL const DictionaryCtxt* dict,
|
||||||
XP_U32 count = dict_countWords( &iter, &lens );
|
XP_U32 count = dict_countWords( &iter, &lens );
|
||||||
|
|
||||||
XP_U32 sum = 0;
|
XP_U32 sum = 0;
|
||||||
for ( jj = 0; jj < MAX_COLS_DICT+1; ++jj ) {
|
for ( jj = 0; jj < VSIZE(lens.lens); ++jj ) {
|
||||||
sum += lens.lens[jj];
|
sum += lens.lens[jj];
|
||||||
XP_LOGF( "%d words of length %ld", lens.lens[jj], jj );
|
XP_LOGF( "%d words of length %ld", lens.lens[jj], jj );
|
||||||
}
|
}
|
||||||
|
@ -1692,7 +1692,7 @@ walk_dict_test( MPFORMAL const DictionaryCtxt* dict,
|
||||||
gotOne;
|
gotOne;
|
||||||
gotOne = dict_getNextWord( &iter ) ) {
|
gotOne = dict_getNextWord( &iter ) ) {
|
||||||
XP_ASSERT( dict_getPosition( &iter ) == jj );
|
XP_ASSERT( dict_getPosition( &iter ) == jj );
|
||||||
VDECL( XP_UCHAR, buf, 64 );
|
XP_UCHAR buf[64];
|
||||||
dict_wordToString( &iter, buf, VSIZE(buf) );
|
dict_wordToString( &iter, buf, VSIZE(buf) );
|
||||||
# ifdef PRINT_ALL
|
# ifdef PRINT_ALL
|
||||||
fprintf( stderr, "%.6ld: %s\n", jj, buf );
|
fprintf( stderr, "%.6ld: %s\n", jj, buf );
|
||||||
|
@ -1708,7 +1708,7 @@ walk_dict_test( MPFORMAL const DictionaryCtxt* dict,
|
||||||
gotOne;
|
gotOne;
|
||||||
++jj, gotOne = dict_getPrevWord( &iter ) ) {
|
++jj, gotOne = dict_getPrevWord( &iter ) ) {
|
||||||
XP_ASSERT( dict_getPosition(&iter) == count-jj-1 );
|
XP_ASSERT( dict_getPosition(&iter) == count-jj-1 );
|
||||||
VDECL( XP_UCHAR, buf, 64 );
|
XP_UCHAR buf[64];
|
||||||
dict_wordToString( &iter, buf, VSIZE(buf) );
|
dict_wordToString( &iter, buf, VSIZE(buf) );
|
||||||
# ifdef PRINT_ALL
|
# ifdef PRINT_ALL
|
||||||
fprintf( stderr, "%.6ld: %s\n", jj, buf );
|
fprintf( stderr, "%.6ld: %s\n", jj, buf );
|
||||||
|
@ -1750,13 +1750,13 @@ walk_dict_test( MPFORMAL const DictionaryCtxt* dict,
|
||||||
XP_ASSERT( 0 );
|
XP_ASSERT( 0 );
|
||||||
}
|
}
|
||||||
XP_ASSERT( word.index == indices[ii] );
|
XP_ASSERT( word.index == indices[ii] );
|
||||||
VDECL( XP_UCHAR, buf1, 64 );
|
XP_UCHAR buf1[64];
|
||||||
dict_wordToString( dict, &word, buf1, VSIZE(buf1) );
|
dict_wordToString( dict, &word, buf1, VSIZE(buf1) );
|
||||||
VDECL( XP_UCHAR, buf2, 64 ) = {0};
|
XP_UCHAR buf2[64] = {0};
|
||||||
if ( ii > 0 && dict_getNthWord( dict, &word, indices[ii]-1 ) ) {
|
if ( ii > 0 && dict_getNthWord( dict, &word, indices[ii]-1 ) ) {
|
||||||
dict_wordToString( dict, &word, buf2, VSIZE(buf2) );
|
dict_wordToString( dict, &word, buf2, VSIZE(buf2) );
|
||||||
}
|
}
|
||||||
VDECL( char, prfx, 8 );
|
char prfx[8];
|
||||||
dict_tilesToString( dict, &prefixes[depth*ii], depth, prfx,
|
dict_tilesToString( dict, &prefixes[depth*ii], depth, prfx,
|
||||||
VSIZE(prfx) );
|
VSIZE(prfx) );
|
||||||
fprintf( stderr, "%d: index: %ld; prefix: %s; word: %s (prev: %s)\n",
|
fprintf( stderr, "%d: index: %ld; prefix: %s; word: %s (prev: %s)\n",
|
||||||
|
@ -1774,8 +1774,8 @@ walk_dict_test( MPFORMAL const DictionaryCtxt* dict,
|
||||||
gchar* prefix = (gchar*)g_slist_nth_data( testPrefixes, ii );
|
gchar* prefix = (gchar*)g_slist_nth_data( testPrefixes, ii );
|
||||||
XP_S16 lenMatched = dict_findStartsWith( &iter, prefix );
|
XP_S16 lenMatched = dict_findStartsWith( &iter, prefix );
|
||||||
if ( 0 <= lenMatched ) {
|
if ( 0 <= lenMatched ) {
|
||||||
VDECL( XP_UCHAR, buf, 32 );
|
XP_UCHAR buf[32];
|
||||||
VDECL( XP_UCHAR, bufPrev, 32 ) = {0};
|
XP_UCHAR bufPrev[32] = {0};
|
||||||
dict_wordToString( &iter, buf, VSIZE(buf) );
|
dict_wordToString( &iter, buf, VSIZE(buf) );
|
||||||
|
|
||||||
/* This doesn't work with synonyms like "L-L" for "L·L" */
|
/* This doesn't work with synonyms like "L-L" for "L·L" */
|
||||||
|
@ -1832,7 +1832,7 @@ dumpDict( DictionaryCtxt* dict )
|
||||||
for ( XP_Bool result = dict_firstWord( &iter );
|
for ( XP_Bool result = dict_firstWord( &iter );
|
||||||
result;
|
result;
|
||||||
result = dict_getNextWord( &iter ) ) {
|
result = dict_getNextWord( &iter ) ) {
|
||||||
VDECL( XP_UCHAR, buf, 32 );
|
XP_UCHAR buf[32];
|
||||||
dict_wordToString( &iter, buf, VSIZE(buf) );
|
dict_wordToString( &iter, buf, VSIZE(buf) );
|
||||||
fprintf( stdout, "%s\n", buf );
|
fprintf( stdout, "%s\n", buf );
|
||||||
}
|
}
|
||||||
|
@ -1841,7 +1841,7 @@ dumpDict( DictionaryCtxt* dict )
|
||||||
static void
|
static void
|
||||||
trimDictPath( const char* input, char* buf, int bufsiz, char** path, char** dict )
|
trimDictPath( const char* input, char* buf, int bufsiz, char** path, char** dict )
|
||||||
{
|
{
|
||||||
VDECL( char, unlinked, 256 );
|
char unlinked[256];
|
||||||
XP_ASSERT( strlen(input) < VSIZE(unlinked) );
|
XP_ASSERT( strlen(input) < VSIZE(unlinked) );
|
||||||
ssize_t siz = readlink( input, unlinked, VSIZE(unlinked) );
|
ssize_t siz = readlink( input, unlinked, VSIZE(unlinked) );
|
||||||
if ( 0 <= siz ) {
|
if ( 0 <= siz ) {
|
||||||
|
@ -1883,7 +1883,7 @@ getDictPath( const LaunchParams *params, const char* name,
|
||||||
result[0] = '\0';
|
result[0] = '\0';
|
||||||
for ( iter = params->dictDirs; !!iter; iter = iter->next ) {
|
for ( iter = params->dictDirs; !!iter; iter = iter->next ) {
|
||||||
const char* path = iter->data;
|
const char* path = iter->data;
|
||||||
VDECL( char, buf, 256 );
|
char buf[256];
|
||||||
int len = snprintf( buf, VSIZE(buf), "%s/%s.xwd", path, name );
|
int len = snprintf( buf, VSIZE(buf), "%s/%s.xwd", path, name );
|
||||||
if ( len < VSIZE(buf) && file_exists( buf ) ) {
|
if ( len < VSIZE(buf) && file_exists( buf ) ) {
|
||||||
snprintf( result, resultLen, "%s", buf );
|
snprintf( result, resultLen, "%s", buf );
|
||||||
|
@ -2064,7 +2064,7 @@ main( int argc, char** argv )
|
||||||
GSList* testPrefixes = NULL;
|
GSList* testPrefixes = NULL;
|
||||||
char* testMinMax = NULL;
|
char* testMinMax = NULL;
|
||||||
#endif
|
#endif
|
||||||
VDECL( char, dictbuf, 256 );
|
char dictbuf[256];
|
||||||
char* dict;
|
char* dict;
|
||||||
char* path;
|
char* path;
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ linux_debugf( const char* format, ... )
|
||||||
void
|
void
|
||||||
linux_backtrace( void )
|
linux_backtrace( void )
|
||||||
{
|
{
|
||||||
VDECL( void*, buffer, 128 );
|
void* buffer[128];
|
||||||
int nFound = backtrace( buffer, VSIZE(buffer) );
|
int nFound = backtrace( buffer, VSIZE(buffer) );
|
||||||
XP_ASSERT( nFound < VSIZE(buffer) );
|
XP_ASSERT( nFound < VSIZE(buffer) );
|
||||||
char** traces = backtrace_symbols( buffer, nFound );
|
char** traces = backtrace_symbols( buffer, nFound );
|
||||||
|
@ -105,13 +105,10 @@ linux_util_makeEmptyDict( XW_UtilCtxt* XP_UNUSED_DBG(uctx) )
|
||||||
#define TL BONUS_TRIPLE_LETTER
|
#define TL BONUS_TRIPLE_LETTER
|
||||||
#define TW BONUS_TRIPLE_WORD
|
#define TW BONUS_TRIPLE_WORD
|
||||||
|
|
||||||
#define SC_BOARD_SIZE 36
|
|
||||||
#define SEVENTEEN_BOARD_SIZE 45
|
|
||||||
|
|
||||||
static XWBonusType*
|
static XWBonusType*
|
||||||
bonusesFor( XP_U16 boardSize, XP_U16* len )
|
bonusesFor( XP_U16 boardSize, XP_U16* len )
|
||||||
{
|
{
|
||||||
static XWBonusType scrabbleBoard[SC_BOARD_SIZE] = {
|
static XWBonusType scrabbleBoard[] = {
|
||||||
TW,//EM,EM,DL,EM,EM,EM,TW,
|
TW,//EM,EM,DL,EM,EM,EM,TW,
|
||||||
EM,DW,//EM,EM,EM,TL,EM,EM,
|
EM,DW,//EM,EM,EM,TL,EM,EM,
|
||||||
|
|
||||||
|
@ -125,7 +122,7 @@ bonusesFor( XP_U16 boardSize, XP_U16* len )
|
||||||
TW,EM,EM,DL,EM,EM,EM,DW,
|
TW,EM,EM,DL,EM,EM,EM,DW,
|
||||||
}; /* scrabbleBoard */
|
}; /* scrabbleBoard */
|
||||||
|
|
||||||
static XWBonusType seventeen[SEVENTEEN_BOARD_SIZE] = {
|
static XWBonusType seventeen[] = {
|
||||||
TW,//EM,EM,DL,EM,EM,EM,TW,
|
TW,//EM,EM,DL,EM,EM,EM,TW,
|
||||||
EM,DW,//EM,EM,EM,TL,EM,EM,
|
EM,DW,//EM,EM,EM,TL,EM,EM,
|
||||||
|
|
||||||
|
@ -143,10 +140,10 @@ bonusesFor( XP_U16 boardSize, XP_U16* len )
|
||||||
XWBonusType* result = NULL;
|
XWBonusType* result = NULL;
|
||||||
if ( boardSize == 15 ) {
|
if ( boardSize == 15 ) {
|
||||||
result = scrabbleBoard;
|
result = scrabbleBoard;
|
||||||
*len = SC_BOARD_SIZE;
|
*len = VSIZE(scrabbleBoard);
|
||||||
} else if ( boardSize == 17 ) {
|
} else if ( boardSize == 17 ) {
|
||||||
result = seventeen;
|
result = seventeen;
|
||||||
*len = SEVENTEEN_BOARD_SIZE;
|
*len = VSIZE(seventeen);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -484,7 +481,7 @@ formatConfirmTrade( CommonGlobals* cGlobals, const XP_UCHAR** tiles,
|
||||||
}
|
}
|
||||||
tileBuf[offset-2] = '\0';
|
tileBuf[offset-2] = '\0';
|
||||||
|
|
||||||
snprintf( cGlobals->question, QUESTION_LEN,
|
snprintf( cGlobals->question, VSIZE(cGlobals->question),
|
||||||
"Are you sure you want to trade the selected tiles (%s)?",
|
"Are you sure you want to trade the selected tiles (%s)?",
|
||||||
tileBuf );
|
tileBuf );
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,6 @@ typedef struct _TimerInfo {
|
||||||
typedef void (*OnSaveFunc)( void* closure, sqlite3_int64 rowid,
|
typedef void (*OnSaveFunc)( void* closure, sqlite3_int64 rowid,
|
||||||
XP_Bool firstTime );
|
XP_Bool firstTime );
|
||||||
|
|
||||||
#define QUESTION_LEN 256*4
|
|
||||||
struct CommonGlobals {
|
struct CommonGlobals {
|
||||||
LaunchParams* params;
|
LaunchParams* params;
|
||||||
CommonPrefs cp;
|
CommonPrefs cp;
|
||||||
|
@ -224,7 +223,7 @@ struct CommonGlobals {
|
||||||
|
|
||||||
/* Saved state from util method to response method */
|
/* Saved state from util method to response method */
|
||||||
XP_U16 selPlayer;
|
XP_U16 selPlayer;
|
||||||
char question[QUESTION_LEN];
|
char question[256*4];
|
||||||
const XP_UCHAR* askPassName;
|
const XP_UCHAR* askPassName;
|
||||||
XP_U16 nTiles;
|
XP_U16 nTiles;
|
||||||
XP_U16 nToPick;
|
XP_U16 nToPick;
|
||||||
|
|
|
@ -32,8 +32,6 @@
|
||||||
#define MAX_MOVE_CHECK_MS ((XP_U16)(1000 * 60 * 60 * 24))
|
#define MAX_MOVE_CHECK_MS ((XP_U16)(1000 * 60 * 60 * 24))
|
||||||
#define RELAY_API_PROTO "http"
|
#define RELAY_API_PROTO "http"
|
||||||
|
|
||||||
#define HOST_LEN 64
|
|
||||||
|
|
||||||
typedef struct _RelayConStorage {
|
typedef struct _RelayConStorage {
|
||||||
pthread_t mainThread;
|
pthread_t mainThread;
|
||||||
guint moveCheckerID;
|
guint moveCheckerID;
|
||||||
|
@ -52,7 +50,7 @@ typedef struct _RelayConStorage {
|
||||||
uint32_t nextID;
|
uint32_t nextID;
|
||||||
XWPDevProto proto;
|
XWPDevProto proto;
|
||||||
LaunchParams* params;
|
LaunchParams* params;
|
||||||
XP_UCHAR host[HOST_LEN];
|
XP_UCHAR host[64];
|
||||||
int nextTaskID;
|
int nextTaskID;
|
||||||
} RelayConStorage;
|
} RelayConStorage;
|
||||||
|
|
||||||
|
@ -261,7 +259,7 @@ relaycon_init( LaunchParams* params, const RelayConnProcs* procs,
|
||||||
pthread_mutex_init( &storage->gotDataMutex, NULL );
|
pthread_mutex_init( &storage->gotDataMutex, NULL );
|
||||||
g_timeout_add( 50, gotDataTimer, storage );
|
g_timeout_add( 50, gotDataTimer, storage );
|
||||||
|
|
||||||
XP_ASSERT( XP_STRLEN(host) < HOST_LEN );
|
XP_ASSERT( XP_STRLEN(host) < VSIZE(storage->host) );
|
||||||
XP_MEMCPY( storage->host, host, XP_STRLEN(host) + 1 );
|
XP_MEMCPY( storage->host, host, XP_STRLEN(host) + 1 );
|
||||||
} else {
|
} else {
|
||||||
storage->socket = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
|
storage->socket = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
|
||||||
|
|
|
@ -281,8 +281,6 @@ typedef unsigned short CookieID;
|
||||||
|
|
||||||
#define COOKIE_ID_NONE 0
|
#define COOKIE_ID_NONE 0
|
||||||
|
|
||||||
#ifndef VSIZE
|
#define VSIZE(arr) (sizeof(arr)/sizeof(arr[0]))
|
||||||
# define VSIZE(arr) (sizeof(arr)/sizeof(arr[0]))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue