mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
remove comms/transport from using thread->env map
This commit is contained in:
parent
2343c34a44
commit
eb9ef738e4
33 changed files with 709 additions and 682 deletions
|
@ -30,7 +30,7 @@
|
|||
|
||||
|
||||
/* callback for streams */
|
||||
void and_send_on_close( XWStreamCtxt* stream, void* closure );
|
||||
void and_send_on_close( XWStreamCtxt* stream, XWEnv xwe, void* closure );
|
||||
XWStreamCtxt* and_empty_stream( MPFORMAL AndGameGlobals* globals );
|
||||
|
||||
typedef struct _SetInfo {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-mode: C; compile-command: "cd ..; ../scripts/ndkbuild.sh -j3"; -*- */
|
||||
/* -*-mode: C; compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */
|
||||
/*
|
||||
* Copyright 2001-2010 by Eric House (xwords@eehouse.org). All rights
|
||||
* Copyright 2001 - 2020 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -25,7 +25,6 @@
|
|||
|
||||
typedef struct _AndTransportProcs {
|
||||
TransportProcs tp;
|
||||
EnvThreadInfo* ti;
|
||||
jobject jxport;
|
||||
MPSLOT
|
||||
} AndTransportProcs;
|
||||
|
@ -52,12 +51,12 @@ makeJAddr( JNIEnv* env, const CommsAddrRec* addr )
|
|||
}
|
||||
|
||||
static XP_U32
|
||||
and_xport_getFlags( void* closure )
|
||||
and_xport_getFlags( XWEnv xwe, void* closure )
|
||||
{
|
||||
jint result = COMMS_XPORT_FLAGS_NONE;
|
||||
AndTransportProcs* aprocs = (AndTransportProcs*)closure;
|
||||
if ( NULL != aprocs->jxport ) {
|
||||
JNIEnv* env = ENVFORME( aprocs->ti );
|
||||
JNIEnv* env = xwe;
|
||||
const char* sig = "()I";
|
||||
jmethodID mid = getMethodID( env, aprocs->jxport, "getFlags", sig );
|
||||
|
||||
|
@ -67,15 +66,15 @@ and_xport_getFlags( void* closure )
|
|||
}
|
||||
|
||||
static XP_S16
|
||||
and_xport_send( const XP_U8* buf, XP_U16 len, const XP_UCHAR* msgNo,
|
||||
const CommsAddrRec* addr, CommsConnType conType,
|
||||
XP_U32 gameID, void* closure )
|
||||
and_xport_send( XWEnv xwe, const XP_U8* buf, XP_U16 len,
|
||||
const XP_UCHAR* msgNo, const CommsAddrRec* addr,
|
||||
CommsConnType conType, XP_U32 gameID, void* closure )
|
||||
{
|
||||
jint result = -1;
|
||||
LOG_FUNC();
|
||||
AndTransportProcs* aprocs = (AndTransportProcs*)closure;
|
||||
if ( NULL != aprocs->jxport ) {
|
||||
JNIEnv* env = ENVFORME( aprocs->ti );
|
||||
JNIEnv* env = xwe;
|
||||
const char* sig = "([BLjava/lang/String;L" PKG_PATH("jni/CommsAddrRec")
|
||||
";L" PKG_PATH("jni/CommsAddrRec$CommsConnType") ";I)I";
|
||||
|
||||
|
@ -101,17 +100,19 @@ and_xport_send( const XP_U8* buf, XP_U16 len, const XP_UCHAR* msgNo,
|
|||
}
|
||||
|
||||
static void
|
||||
and_xport_relayStatus( void* XP_UNUSED(closure), CommsRelayState XP_UNUSED(newState) )
|
||||
and_xport_relayStatus( XWEnv XP_UNUSED(xwe), void* XP_UNUSED(closure),
|
||||
CommsRelayState XP_UNUSED(newState) )
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
and_xport_relayConnd( void* closure, XP_UCHAR* const room, XP_Bool reconnect,
|
||||
XP_U16 devOrder, XP_Bool allHere, XP_U16 nMissing )
|
||||
and_xport_relayConnd( XWEnv xwe, void* closure, XP_UCHAR* const room,
|
||||
XP_Bool reconnect, XP_U16 devOrder, XP_Bool allHere,
|
||||
XP_U16 nMissing )
|
||||
{
|
||||
AndTransportProcs* aprocs = (AndTransportProcs*)closure;
|
||||
if ( NULL != aprocs->jxport ) {
|
||||
JNIEnv* env = ENVFORME( aprocs->ti );
|
||||
JNIEnv* env = xwe;
|
||||
const char* sig = "(Ljava/lang/String;IZI)V";
|
||||
jmethodID mid = getMethodID( env, aprocs->jxport, "relayConnd", sig );
|
||||
|
||||
|
@ -123,13 +124,14 @@ and_xport_relayConnd( void* closure, XP_UCHAR* const room, XP_Bool reconnect,
|
|||
}
|
||||
|
||||
static XP_Bool
|
||||
and_xport_sendNoConn( const XP_U8* buf, XP_U16 len, const XP_UCHAR* msgNo,
|
||||
const XP_UCHAR* relayID, void* closure )
|
||||
and_xport_sendNoConn( XWEnv xwe, const XP_U8* buf, XP_U16 len,
|
||||
const XP_UCHAR* msgNo, const XP_UCHAR* relayID,
|
||||
void* closure )
|
||||
{
|
||||
jboolean result = false;
|
||||
AndTransportProcs* aprocs = (AndTransportProcs*)closure;
|
||||
if ( NULL != aprocs && NULL != aprocs->jxport ) {
|
||||
JNIEnv* env = ENVFORME( aprocs->ti );
|
||||
JNIEnv* env = xwe;
|
||||
|
||||
const char* sig = "([BLjava/lang/String;Ljava/lang/String;)Z";
|
||||
jmethodID mid = getMethodID( env, aprocs->jxport,
|
||||
|
@ -146,11 +148,11 @@ and_xport_sendNoConn( const XP_U8* buf, XP_U16 len, const XP_UCHAR* msgNo,
|
|||
}
|
||||
|
||||
static void
|
||||
and_xport_countChanged( void* closure, XP_U16 count )
|
||||
and_xport_countChanged( XWEnv xwe, void* closure, XP_U16 count )
|
||||
{
|
||||
AndTransportProcs* aprocs = (AndTransportProcs*)closure;
|
||||
if ( NULL != aprocs && NULL != aprocs->jxport ) {
|
||||
JNIEnv* env = ENVFORME( aprocs->ti );
|
||||
JNIEnv* env = xwe;
|
||||
const char* sig = "(I)V";
|
||||
jmethodID mid = getMethodID( env, aprocs->jxport, "countChanged", sig );
|
||||
(*env)->CallVoidMethod( env, aprocs->jxport, mid, count );
|
||||
|
@ -158,11 +160,11 @@ and_xport_countChanged( void* closure, XP_U16 count )
|
|||
}
|
||||
|
||||
static void
|
||||
and_xport_relayError( void* closure, XWREASON relayErr )
|
||||
and_xport_relayError( XWEnv xwe, void* closure, XWREASON relayErr )
|
||||
{
|
||||
AndTransportProcs* aprocs = (AndTransportProcs*)closure;
|
||||
if ( NULL != aprocs->jxport ) {
|
||||
JNIEnv* env = ENVFORME( aprocs->ti );
|
||||
JNIEnv* env = xwe;
|
||||
jmethodID mid;
|
||||
const char* sig =
|
||||
"(L" PKG_PATH("jni/TransportProcs$XWRELAY_ERROR") ";)V";
|
||||
|
@ -177,16 +179,14 @@ and_xport_relayError( void* closure, XWREASON relayErr )
|
|||
}
|
||||
|
||||
TransportProcs*
|
||||
makeXportProcs( MPFORMAL EnvThreadInfo* ti, jobject jxport )
|
||||
makeXportProcs( MPFORMAL JNIEnv* env, jobject jxport )
|
||||
{
|
||||
AndTransportProcs* aprocs = NULL;
|
||||
|
||||
JNIEnv* env = ENVFORME( ti );
|
||||
aprocs = (AndTransportProcs*)XP_CALLOC( mpool, sizeof(*aprocs) );
|
||||
if ( NULL != jxport ) {
|
||||
aprocs->jxport = (*env)->NewGlobalRef( env, jxport );
|
||||
}
|
||||
aprocs->ti = ti;
|
||||
MPASSIGN( aprocs->mpool, mpool );
|
||||
|
||||
#ifdef COMMS_XPORT_FLAGSPROC
|
||||
|
@ -204,10 +204,9 @@ makeXportProcs( MPFORMAL EnvThreadInfo* ti, jobject jxport )
|
|||
}
|
||||
|
||||
void
|
||||
destroyXportProcs( TransportProcs** xport )
|
||||
destroyXportProcs( TransportProcs** xport, JNIEnv* env )
|
||||
{
|
||||
AndTransportProcs* aprocs = (AndTransportProcs*)*xport;
|
||||
JNIEnv* env = ENVFORME( aprocs->ti );
|
||||
if ( NULL != aprocs->jxport ) {
|
||||
(*env)->DeleteGlobalRef( env, aprocs->jxport );
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
|
||||
#include "comms.h"
|
||||
|
||||
TransportProcs* makeXportProcs( MPFORMAL EnvThreadInfo* ti, jobject jxport );
|
||||
TransportProcs* makeXportProcs( MPFORMAL JNIEnv* env, jobject jxport );
|
||||
|
||||
void destroyXportProcs( TransportProcs** xport );
|
||||
void destroyXportProcs( TransportProcs** xport, JNIEnv* env );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -648,11 +648,11 @@ Java_org_eehouse_android_xw4_jni_XwJNI_gi_1to_1stream
|
|||
XWStreamCtxt* stream = mem_stream_make( MPPARM(mpool) globalState->vtMgr,
|
||||
NULL, 0, NULL );
|
||||
|
||||
game_saveToStream( NULL, gi, stream, 0 );
|
||||
game_saveToStream( NULL, env, gi, stream, 0 );
|
||||
destroyGI( MPPARM(mpool) &gi );
|
||||
|
||||
result = streamToBArray( env, stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, env );
|
||||
releaseMPool( globalState );
|
||||
return result;
|
||||
}
|
||||
|
@ -679,7 +679,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_gi_1from_1stream
|
|||
|
||||
gi_disposePlayerInfo( MPPARM(mpool) &gi );
|
||||
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, env );
|
||||
releaseMPool( globalState );
|
||||
}
|
||||
|
||||
|
@ -703,7 +703,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_nli_1to_1stream
|
|||
nli_saveToStream( &nli, stream );
|
||||
|
||||
result = streamToBArray( env, stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, env );
|
||||
releaseMPool( globalState );
|
||||
return result;
|
||||
}
|
||||
|
@ -727,7 +727,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_nli_1from_1stream
|
|||
XP_LOGF( "%s: game_makeFromStream failed", __func__ );
|
||||
}
|
||||
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, env );
|
||||
releaseMPool( globalState );
|
||||
}
|
||||
|
||||
|
@ -1024,7 +1024,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeNewGame
|
|||
dctx = makeDraw( MPPARM(mpool) env, j_draw );
|
||||
}
|
||||
globals->dctx = dctx;
|
||||
globals->xportProcs = makeXportProcs( MPPARM(mpool) ti, j_procs );
|
||||
globals->xportProcs = makeXportProcs( MPPARM(mpool) env, j_procs );
|
||||
CommonPrefs cp = {0};
|
||||
loadCommonPrefs( env, &cp, j_cp );
|
||||
|
||||
|
@ -1065,7 +1065,7 @@ JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_game_1dispose
|
|||
game_dispose( &state->game, env );
|
||||
|
||||
destroyDraw( &globals->dctx, env );
|
||||
destroyXportProcs( &globals->xportProcs );
|
||||
destroyXportProcs( &globals->xportProcs, env );
|
||||
destroyUtil( &globals->util );
|
||||
vtmgr_destroy( MPPARM(mpool) globals->vtMgr );
|
||||
|
||||
|
@ -1095,7 +1095,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeFromStream
|
|||
if ( !!jdraw ) {
|
||||
globals->dctx = makeDraw( MPPARM(mpool) env, jdraw );
|
||||
}
|
||||
globals->xportProcs = makeXportProcs( MPPARM(mpool) ti, jprocs );
|
||||
globals->xportProcs = makeXportProcs( MPPARM(mpool) env, jprocs );
|
||||
|
||||
XWStreamCtxt* stream = streamFromJStream( MPPARM(mpool) env,
|
||||
globals->vtMgr, jstream );
|
||||
|
@ -1106,7 +1106,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeFromStream
|
|||
globals->gi, dict, &dicts,
|
||||
globals->util, globals->dctx, &cp,
|
||||
globals->xportProcs );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, env );
|
||||
dict_unref( dict, env ); /* game owns it now */
|
||||
dict_unref_all( &dicts, env );
|
||||
|
||||
|
@ -1140,7 +1140,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1saveToStream
|
|||
state->lastSavedSize,
|
||||
NULL, 0, NULL );
|
||||
|
||||
game_saveToStream( &state->game, gi, stream, ++state->curSaveCount );
|
||||
game_saveToStream( &state->game, env, gi, stream, ++state->curSaveCount );
|
||||
|
||||
if ( NULL != jgi ) {
|
||||
destroyGI( MPPARM(mpool) &gi );
|
||||
|
@ -1148,7 +1148,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1saveToStream
|
|||
|
||||
state->lastSavedSize = stream_getSize( stream );
|
||||
result = streamToBArray( env, stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, env );
|
||||
|
||||
XWJNI_END();
|
||||
return result;
|
||||
|
@ -1159,7 +1159,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1saveSucceeded
|
|||
( JNIEnv* env, jclass C, GamePtrType gamePtr )
|
||||
{
|
||||
XWJNI_START();
|
||||
game_saveSucceeded( &state->game, state->curSaveCount );
|
||||
game_saveSucceeded( &state->game, env, state->curSaveCount );
|
||||
XWJNI_END();
|
||||
}
|
||||
|
||||
|
@ -1350,7 +1350,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1handlePenUp
|
|||
{
|
||||
jboolean result;
|
||||
XWJNI_START();
|
||||
result = board_handlePenUp( state->game.board, xx, yy );
|
||||
result = board_handlePenUp( state->game.board, env, xx, yy );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
@ -1495,7 +1495,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1commitTurn
|
|||
newTilesP = &newTiles;
|
||||
}
|
||||
|
||||
result = board_commitTurn( state->game.board, phoniesConfirmed,
|
||||
result = board_commitTurn( state->game.board, env, phoniesConfirmed,
|
||||
turnConfirmed, newTilesP );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
|
@ -1539,7 +1539,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1reset
|
|||
(JNIEnv* env, jclass C, GamePtrType gamePtr )
|
||||
{
|
||||
XWJNI_START();
|
||||
server_reset( state->game.server, state->game.comms );
|
||||
server_reset( state->game.server, env, state->game.comms );
|
||||
XWJNI_END();
|
||||
}
|
||||
|
||||
|
@ -1548,7 +1548,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1handleUndo
|
|||
(JNIEnv* env, jclass C, GamePtrType gamePtr)
|
||||
{
|
||||
XWJNI_START();
|
||||
server_handleUndo( state->game.server, 0 );
|
||||
server_handleUndo( state->game.server, env, 0 );
|
||||
XWJNI_END();
|
||||
}
|
||||
|
||||
|
@ -1559,7 +1559,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1do
|
|||
jboolean result;
|
||||
XWJNI_START();
|
||||
XP_ASSERT( !!state->game.server );
|
||||
result = server_do( state->game.server );
|
||||
result = server_do( state->game.server, env );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
@ -1639,7 +1639,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1formatRemainingTiles
|
|||
NULL, 0, NULL );
|
||||
board_formatRemainingTiles( state->game.board, stream );
|
||||
result = streamToJString( env, stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, env );
|
||||
|
||||
XWJNI_END();
|
||||
return result;
|
||||
|
@ -1654,7 +1654,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1formatDictCounts
|
|||
XWStreamCtxt* stream = and_empty_stream( MPPARM(mpool) globals );
|
||||
server_formatDictCounts( state->game.server, stream, nCols, XP_FALSE );
|
||||
result = streamToJString( env, stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, env );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
@ -1680,7 +1680,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_model_1writeGameHistory
|
|||
model_writeGameHistory( state->game.model, env, stream,
|
||||
state->game.server, gameOver );
|
||||
result = streamToJString( env, stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, env );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
@ -1740,19 +1740,19 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1writeFinalScores
|
|||
XWStreamCtxt* stream = and_empty_stream( MPPARM(mpool) globals );
|
||||
server_writeFinalScores( state->game.server, stream );
|
||||
result = streamToJString( env, stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, env );
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
and_send_on_close( XWStreamCtxt* stream, void* closure )
|
||||
and_send_on_close( XWStreamCtxt* stream, XWEnv xwe, void* closure )
|
||||
{
|
||||
AndGameGlobals* globals = (AndGameGlobals*)closure;
|
||||
JNIState* state = (JNIState*)globals->state;
|
||||
|
||||
XP_ASSERT( !!state->game.comms );
|
||||
comms_send( state->game.comms, stream );
|
||||
comms_send( state->game.comms, xwe, stream );
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
|
@ -1764,7 +1764,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1initClientConnection
|
|||
XWJNI_START_GLOBALS();
|
||||
XWStreamCtxt* stream = and_empty_stream( MPPARM(mpool) globals );
|
||||
stream_setOnCloseProc( stream, and_send_on_close );
|
||||
result = server_initClientConnection( state->game.server, stream );
|
||||
result = server_initClientConnection( state->game.server, env, stream );
|
||||
XWJNI_END();
|
||||
LOG_RETURNF( "%s", boolToStr(result) );
|
||||
return result;
|
||||
|
@ -1777,7 +1777,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1start
|
|||
XWJNI_START();
|
||||
CommsCtxt* comms = state->game.comms;
|
||||
if ( !!comms ) {
|
||||
comms_start( comms );
|
||||
comms_start( comms, env );
|
||||
}
|
||||
XWJNI_END();
|
||||
}
|
||||
|
@ -1789,7 +1789,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1stop
|
|||
XWJNI_START();
|
||||
CommsCtxt* comms = state->game.comms;
|
||||
if ( !!comms ) {
|
||||
comms_stop( comms );
|
||||
comms_stop( comms, env );
|
||||
}
|
||||
XWJNI_END();
|
||||
}
|
||||
|
@ -1800,7 +1800,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1resetSame
|
|||
{
|
||||
XWJNI_START();
|
||||
if ( !!state->game.comms ) {
|
||||
comms_resetSame( state->game.comms );
|
||||
comms_resetSame( state->game.comms, env );
|
||||
}
|
||||
XWJNI_END();
|
||||
}
|
||||
|
@ -1827,7 +1827,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getAddrs
|
|||
if ( !!state->game.comms ) {
|
||||
CommsAddrRec addrs[MAX_NUM_PLAYERS];
|
||||
XP_U16 count = VSIZE(addrs);
|
||||
comms_getAddrs( state->game.comms, addrs, &count );
|
||||
comms_getAddrs( state->game.comms, env, addrs, &count );
|
||||
|
||||
jclass clas = (*env)->FindClass( env, PKG_PATH("jni/CommsAddrRec") );
|
||||
result = (*env)->NewObjectArray( env, count, clas, NULL );
|
||||
|
@ -1853,7 +1853,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1augmentHostAddr
|
|||
if ( state->game.comms ) {
|
||||
CommsAddrRec addr = {0};
|
||||
getJAddrRec( env, &addr, jaddr );
|
||||
comms_augmentHostAddr( state->game.comms, &addr );
|
||||
comms_augmentHostAddr( state->game.comms, env, &addr );
|
||||
} else {
|
||||
XP_LOGF( "%s: no comms this game", __func__ );
|
||||
}
|
||||
|
@ -1879,7 +1879,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1receiveMessage
|
|||
|
||||
result = game_receiveMessage( &state->game, env, stream, addrp );
|
||||
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, env );
|
||||
|
||||
XWJNI_END();
|
||||
return result;
|
||||
|
@ -1938,7 +1938,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize
|
|||
case COMMS_CONN_SMS: {
|
||||
CommsAddrRec addrs[MAX_NUM_PLAYERS];
|
||||
XP_U16 count = VSIZE(addrs);
|
||||
comms_getAddrs( comms, addrs, &count );
|
||||
comms_getAddrs( comms, env, addrs, &count );
|
||||
|
||||
const XP_UCHAR* addrps[count];
|
||||
for ( int ii = 0; ii < count; ++ii ) {
|
||||
|
@ -2127,10 +2127,10 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1resendAll
|
|||
XP_ASSERT( !!comms );
|
||||
CommsConnType filter =
|
||||
NULL == jFilter ? COMMS_CONN_NONE : jEnumToInt( env, jFilter );
|
||||
result = comms_resendAll( comms, filter, force );
|
||||
result = comms_resendAll( comms, env, filter, force );
|
||||
if ( thenAck ) {
|
||||
#ifdef XWFEATURE_COMMSACK
|
||||
comms_ackAny( comms );
|
||||
comms_ackAny( comms, env );
|
||||
#endif
|
||||
}
|
||||
XWJNI_END();
|
||||
|
@ -2144,11 +2144,12 @@ typedef struct _GotOneClosure {
|
|||
} GotOneClosure;
|
||||
|
||||
static void
|
||||
onGotOne( void* closure, XP_U8* msg, XP_U16 len, MsgID XP_UNUSED(msgID) )
|
||||
onGotOne( void* closure, XWEnv xwe, XP_U8* msg, XP_U16 len, MsgID XP_UNUSED(msgID) )
|
||||
{
|
||||
GotOneClosure* goc = (GotOneClosure*)closure;
|
||||
XP_ASSERT( goc->env == xwe );
|
||||
if ( goc->count < VSIZE(goc->msgs) ) {
|
||||
jbyteArray arr = makeByteArray( goc->env, len, (const jbyte*)msg );
|
||||
jbyteArray arr = makeByteArray( xwe, len, (const jbyte*)msg );
|
||||
goc->msgs[goc->count++] = arr;
|
||||
} else {
|
||||
XP_ASSERT( 0 );
|
||||
|
@ -2163,7 +2164,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getPending
|
|||
XWJNI_START();
|
||||
GotOneClosure goc = { .env = env, .count = 0 };
|
||||
XP_ASSERT( !!state->game.comms );
|
||||
comms_getPending( state->game.comms, onGotOne, &goc );
|
||||
comms_getPending( state->game.comms, env, onGotOne, &goc );
|
||||
|
||||
result = makeByteArrayArray( env, goc.count );
|
||||
for ( int ii = 0; ii < goc.count; ++ii ) {
|
||||
|
@ -2182,7 +2183,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1ackAny
|
|||
{
|
||||
XWJNI_START();
|
||||
XP_ASSERT( !!state->game.comms );
|
||||
(void)comms_ackAny( state->game.comms );
|
||||
(void)comms_ackAny( state->game.comms, env );
|
||||
XWJNI_END();
|
||||
}
|
||||
#endif
|
||||
|
@ -2195,7 +2196,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1transportFailed
|
|||
XP_ASSERT( !!state->game.comms );
|
||||
|
||||
CommsConnType typ = jEnumToInt( env, failedTyp );
|
||||
(void)comms_transportFailed( state->game.comms, typ );
|
||||
(void)comms_transportFailed( state->game.comms, env, typ );
|
||||
XWJNI_END();
|
||||
}
|
||||
|
||||
|
@ -2241,7 +2242,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getStats
|
|||
NULL, 0, NULL );
|
||||
comms_getStats( state->game.comms, stream );
|
||||
result = streamToJString( env, stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, env );
|
||||
}
|
||||
XWJNI_END();
|
||||
#endif
|
||||
|
@ -2309,7 +2310,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1endGame
|
|||
{
|
||||
XWJNI_START();
|
||||
XP_ASSERT( !!state->game.server );
|
||||
server_endGame( state->game.server );
|
||||
server_endGame( state->game.server, env );
|
||||
XWJNI_END();
|
||||
}
|
||||
|
||||
|
@ -2320,7 +2321,7 @@ JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_board_1pause
|
|||
XP_ASSERT( !!state->game.board );
|
||||
|
||||
const char* msg = (*env)->GetStringUTFChars( env, jmsg, NULL );
|
||||
board_pause( state->game.board, msg );
|
||||
board_pause( state->game.board, env, msg );
|
||||
(*env)->ReleaseStringUTFChars( env, jmsg, msg );
|
||||
|
||||
XWJNI_END();
|
||||
|
@ -2332,7 +2333,7 @@ JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_board_1unpause
|
|||
XWJNI_START();
|
||||
XP_ASSERT( !!state->game.board );
|
||||
const char* msg = (*env)->GetStringUTFChars( env, jmsg, NULL );
|
||||
board_unpause( state->game.board, msg );
|
||||
board_unpause( state->game.board, env, msg );
|
||||
(*env)->ReleaseStringUTFChars( env, jmsg, msg );
|
||||
XWJNI_END();
|
||||
}
|
||||
|
@ -2345,7 +2346,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1sendChat
|
|||
XWJNI_START();
|
||||
XP_ASSERT( !!state->game.server );
|
||||
const char* msg = (*env)->GetStringUTFChars( env, jmsg, NULL );
|
||||
board_sendChat( state->game.board, msg );
|
||||
board_sendChat( state->game.board, env, msg );
|
||||
(*env)->ReleaseStringUTFChars( env, jmsg, msg );
|
||||
XWJNI_END();
|
||||
}
|
||||
|
|
|
@ -825,16 +825,16 @@ board_visTileCount( const BoardCtxt* board )
|
|||
}
|
||||
|
||||
void
|
||||
board_pause( BoardCtxt* board, const XP_UCHAR* msg )
|
||||
board_pause( BoardCtxt* board, XWEnv xwe, const XP_UCHAR* msg )
|
||||
{
|
||||
server_pause( board->server, board->selPlayer, msg );
|
||||
server_pause( board->server, xwe, board->selPlayer, msg );
|
||||
board_invalAll( board );
|
||||
}
|
||||
|
||||
void
|
||||
board_unpause( BoardCtxt* board, const XP_UCHAR* msg )
|
||||
board_unpause( BoardCtxt* board, XWEnv xwe, const XP_UCHAR* msg )
|
||||
{
|
||||
server_unpause( board->server, board->selPlayer, msg );
|
||||
server_unpause( board->server, xwe, board->selPlayer, msg );
|
||||
setTimerIf( board );
|
||||
board_invalAll( board );
|
||||
}
|
||||
|
@ -884,9 +884,9 @@ board_canHint( const BoardCtxt* board )
|
|||
}
|
||||
|
||||
void
|
||||
board_sendChat( const BoardCtxt* board, const XP_UCHAR* msg )
|
||||
board_sendChat( const BoardCtxt* board, XWEnv xwe, const XP_UCHAR* msg )
|
||||
{
|
||||
server_sendChat( board->server, msg, board->selPlayer );
|
||||
server_sendChat( board->server, xwe, msg, board->selPlayer );
|
||||
}
|
||||
|
||||
static XP_U16
|
||||
|
@ -1066,7 +1066,7 @@ boardNotifyTrade( BoardCtxt* board, const TrayTileSet* tiles )
|
|||
}
|
||||
|
||||
XP_Bool
|
||||
board_commitTurn( BoardCtxt* board, XP_Bool phoniesConfirmed,
|
||||
board_commitTurn( BoardCtxt* board, XWEnv xwe, XP_Bool phoniesConfirmed,
|
||||
XP_Bool turnConfirmed /* includes trade */,
|
||||
TrayTileSet* newTiles )
|
||||
{
|
||||
|
@ -1107,7 +1107,7 @@ board_commitTurn( BoardCtxt* board, XP_Bool phoniesConfirmed,
|
|||
must be called first() */
|
||||
(void)board_endTrade( board );
|
||||
|
||||
(void)server_commitTrade( board->server, &selTiles,
|
||||
(void)server_commitTrade( board->server, xwe, &selTiles,
|
||||
newTiles );
|
||||
}
|
||||
} else {
|
||||
|
@ -1135,7 +1135,7 @@ board_commitTurn( BoardCtxt* board, XP_Bool phoniesConfirmed,
|
|||
info.proc = saveBadWords;
|
||||
info.closure = &bwl;
|
||||
}
|
||||
legal = model_checkMoveLegal( model, selPlayer, stream,
|
||||
legal = model_checkMoveLegal( model, xwe, selPlayer, stream,
|
||||
warn? &info:(WordNotifierInfo*)NULL);
|
||||
}
|
||||
|
||||
|
@ -1157,7 +1157,7 @@ board_commitTurn( BoardCtxt* board, XP_Bool phoniesConfirmed,
|
|||
model_getNumTilesInTray( model, selPlayer );
|
||||
if ( !server_askPickTiles( board->server, selPlayer, newTiles,
|
||||
nToPick ) ) {
|
||||
result = server_commitMove( board->server, selPlayer,
|
||||
result = server_commitMove( board->server, xwe, selPlayer,
|
||||
newTiles )
|
||||
|| result;
|
||||
/* invalidate all tiles in case we'll be drawing this tray
|
||||
|
@ -1174,7 +1174,7 @@ board_commitTurn( BoardCtxt* board, XP_Bool phoniesConfirmed,
|
|||
}
|
||||
|
||||
if ( NULL != stream ) {
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, xwe );
|
||||
}
|
||||
|
||||
if ( result ) {
|
||||
|
@ -1363,7 +1363,7 @@ timerFiredForPen( BoardCtxt* board, XWEnv xwe )
|
|||
dragDropEnd( board, board->penDownX, board->penDownY, NULL );
|
||||
}
|
||||
}
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, xwe );
|
||||
}
|
||||
#endif
|
||||
if ( !listWords ) {
|
||||
|
@ -3024,8 +3024,8 @@ penMoved( const BoardCtxt* board, XP_U16 curCol, XP_U16 curRow )
|
|||
}
|
||||
|
||||
static XP_Bool
|
||||
handlePenUpInternal( BoardCtxt* board, XP_U16 xx, XP_U16 yy, XP_Bool isPen,
|
||||
XP_Bool altDown )
|
||||
handlePenUpInternal( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy,
|
||||
XP_Bool isPen, XP_Bool altDown )
|
||||
{
|
||||
XP_Bool draw = XP_FALSE;
|
||||
BoardObjectType prevObj = board->penDownObject;
|
||||
|
@ -3081,7 +3081,7 @@ handlePenUpInternal( BoardCtxt* board, XP_U16 xx, XP_U16 yy, XP_Bool isPen,
|
|||
if ( board->trayVisState != TRAY_REVEALED ) {
|
||||
draw = askRevealTray( board ) || draw;
|
||||
} else {
|
||||
draw = handlePenUpTray( board, xx, yy ) || draw;
|
||||
draw = handlePenUpTray( board, xwe, xx, yy ) || draw;
|
||||
}
|
||||
break;
|
||||
case OBJ_TIMER:
|
||||
|
@ -3098,9 +3098,9 @@ handlePenUpInternal( BoardCtxt* board, XP_U16 xx, XP_U16 yy, XP_Bool isPen,
|
|||
} /* handlePenUpInternal */
|
||||
|
||||
XP_Bool
|
||||
board_handlePenUp( BoardCtxt* board, XP_U16 x, XP_U16 y )
|
||||
board_handlePenUp( BoardCtxt* board, XWEnv xwe, XP_U16 xx, XP_U16 yy )
|
||||
{
|
||||
return handlePenUpInternal( board, x, y, XP_TRUE, XP_FALSE );
|
||||
return handlePenUpInternal( board, xwe, xx, yy, XP_TRUE, XP_FALSE );
|
||||
}
|
||||
|
||||
XP_Bool
|
||||
|
@ -3206,7 +3206,7 @@ handleFocusKeyUp( BoardCtxt* board, XP_Key key, XP_Bool preflightOnly,
|
|||
} /* handleFocusKeyUp */
|
||||
|
||||
XP_Bool
|
||||
board_handleKeyRepeat( BoardCtxt* board, XP_Key key, XP_Bool* handled )
|
||||
board_handleKeyRepeat( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* handled )
|
||||
{
|
||||
XP_Bool draw;
|
||||
|
||||
|
@ -3215,7 +3215,7 @@ board_handleKeyRepeat( BoardCtxt* board, XP_Key key, XP_Bool* handled )
|
|||
draw = XP_FALSE;
|
||||
} else {
|
||||
XP_Bool upHandled, downHandled;
|
||||
draw = board_handleKeyUp( board, key, &upHandled );
|
||||
draw = board_handleKeyUp( board, xwe, key, &upHandled );
|
||||
draw = board_handleKeyDown( board, key, &downHandled ) || draw;
|
||||
*handled = upHandled || downHandled;
|
||||
}
|
||||
|
@ -3265,7 +3265,7 @@ board_handleKeyDown( BoardCtxt* XP_UNUSED_KEYBOARD_NAV(board),
|
|||
} /* board_handleKeyDown */
|
||||
|
||||
XP_Bool
|
||||
board_handleKeyUp( BoardCtxt* board, XP_Key key, XP_Bool* pHandled )
|
||||
board_handleKeyUp( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* pHandled )
|
||||
{
|
||||
XP_Bool redraw = XP_FALSE;
|
||||
XP_Bool handled = XP_FALSE;
|
||||
|
@ -3319,7 +3319,7 @@ board_handleKeyUp( BoardCtxt* board, XP_Key key, XP_Bool* pHandled )
|
|||
if ( board->focusHasDived ) {
|
||||
XP_U16 xx, yy;
|
||||
if ( focusToCoords( board, &xx, &yy ) ) {
|
||||
redraw = handlePenUpInternal( board, xx, yy, XP_FALSE, altDown );
|
||||
redraw = handlePenUpInternal( board, xwe, xx, yy, XP_FALSE, altDown );
|
||||
handled = XP_TRUE;
|
||||
}
|
||||
} else {
|
||||
|
@ -3359,14 +3359,14 @@ board_handleKeyUp( BoardCtxt* board, XP_Key key, XP_Bool* pHandled )
|
|||
} /* board_handleKeyUp */
|
||||
|
||||
XP_Bool
|
||||
board_handleKey( BoardCtxt* board, XP_Key key, XP_Bool* handled )
|
||||
board_handleKey( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* handled )
|
||||
{
|
||||
XP_Bool handled1;
|
||||
XP_Bool handled2;
|
||||
XP_Bool draw;
|
||||
|
||||
draw = board_handleKeyDown( board, key, &handled1 );
|
||||
draw = board_handleKeyUp( board, key, &handled2 ) || draw;
|
||||
draw = board_handleKeyUp( board, xwe, key, &handled2 ) || draw;
|
||||
if ( !!handled ) {
|
||||
*handled = handled1 || handled2;
|
||||
}
|
||||
|
|
|
@ -126,14 +126,14 @@ XP_U16 board_getYOffset( const BoardCtxt* board );
|
|||
|
||||
XP_Bool board_curTurnSelected( const BoardCtxt* board );
|
||||
XP_U16 board_visTileCount( const BoardCtxt* board );
|
||||
void board_pause( BoardCtxt* board, const XP_UCHAR* msg );
|
||||
void board_unpause( BoardCtxt* board, const XP_UCHAR* msg );
|
||||
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_canTogglePending( const BoardCtxt* board );
|
||||
XP_Bool board_canHint( const BoardCtxt* board );
|
||||
void board_sendChat( const BoardCtxt* board, const XP_UCHAR* msg );
|
||||
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 );
|
||||
|
@ -176,7 +176,7 @@ XP_Bool board_setBlankValue( BoardCtxt* board, XP_U16 XP_UNUSED(player),
|
|||
|
||||
void board_resetEngine( BoardCtxt* board );
|
||||
|
||||
XP_Bool board_commitTurn( BoardCtxt* board, XP_Bool phoniesConfirmed,
|
||||
XP_Bool board_commitTurn( BoardCtxt* board, XWEnv xwe, XP_Bool phoniesConfirmed,
|
||||
XP_Bool turnConfirmed, TrayTileSet* newTiles );
|
||||
|
||||
void board_pushTimerSave( BoardCtxt* board );
|
||||
|
@ -188,16 +188,16 @@ void board_formatRemainingTiles( BoardCtxt* board, XWStreamCtxt* stream );
|
|||
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_handlePenUp( BoardCtxt* board, 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
|
||||
|
||||
#ifdef KEY_SUPPORT
|
||||
XP_Bool board_handleKey( BoardCtxt* board, XP_Key key, XP_Bool* handled );
|
||||
XP_Bool board_handleKey( BoardCtxt* board, XWEnv xwe, XP_Key key, XP_Bool* handled );
|
||||
|
||||
XP_Bool board_handleKeyUp( BoardCtxt* board, 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_handleKeyRepeat( BoardCtxt* board, 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 gained );
|
||||
|
|
|
@ -243,7 +243,7 @@ struct BoardCtxt {
|
|||
#define TRADE_IN_PROGRESS(b) ((b)->selInfo->tradeInProgress==XP_TRUE)
|
||||
|
||||
/* tray-related functions */
|
||||
XP_Bool handlePenUpTray( BoardCtxt* board, XP_U16 x, XP_U16 y );
|
||||
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_U16 indexForBits( XP_U8 bits );
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -117,34 +117,34 @@ typedef struct _CommsAddrRec {
|
|||
} u;
|
||||
} CommsAddrRec;
|
||||
|
||||
typedef XP_S16 (*TransportSend)( const XP_U8* buf, XP_U16 len,
|
||||
typedef XP_S16 (*TransportSend)( XWEnv xwe, const XP_U8* buf, XP_U16 len,
|
||||
const XP_UCHAR* msgNo,
|
||||
const CommsAddrRec* addr,
|
||||
CommsConnType conType,
|
||||
XP_U32 gameID, void* closure );
|
||||
#ifdef COMMS_HEARTBEAT
|
||||
typedef void (*TransportReset)( void* closure );
|
||||
typedef void (*TransportReset)( XWEnv xwe, void* closure );
|
||||
#endif
|
||||
|
||||
#ifdef XWFEATURE_RELAY
|
||||
typedef void (*RelayStatusProc)( void* closure, CommsRelayState newState );
|
||||
typedef void (*RelayConndProc)( void* closure, XP_UCHAR* const room,
|
||||
typedef void (*RelayStatusProc)( XWEnv xwe, void* closure, CommsRelayState newState );
|
||||
typedef void (*RelayConndProc)( XWEnv xwe, void* closure, XP_UCHAR* const room,
|
||||
XP_Bool reconnect,
|
||||
XP_U16 devOrder, /* 1 means created room, etc. */
|
||||
XP_Bool allHere, XP_U16 nMissing );
|
||||
typedef void (*RelayErrorProc)( void* closure, XWREASON relayErr );
|
||||
typedef XP_Bool (*RelayNoConnProc)( const XP_U8* buf, XP_U16 len,
|
||||
typedef void (*RelayErrorProc)( XWEnv xwe, void* closure, XWREASON relayErr );
|
||||
typedef XP_Bool (*RelayNoConnProc)( XWEnv xwe, const XP_U8* buf, XP_U16 len,
|
||||
const XP_UCHAR* msgNo,
|
||||
const XP_UCHAR* relayID, void* closure );
|
||||
# ifdef RELAY_VIA_HTTP
|
||||
typedef void (*RelayRequestJoinProc)( void* closure, const XP_UCHAR* devID,
|
||||
typedef void (*RelayRequestJoinProc)( XWEnv xwe, void* closure, const XP_UCHAR* devID,
|
||||
const XP_UCHAR* room, XP_U16 nPlayersHere,
|
||||
XP_U16 nPlayersTotal, XP_U16 seed,
|
||||
XP_U16 lang );
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef void (*MsgCountChange)( void* closure, XP_U16 msgCount );
|
||||
typedef void (*MsgCountChange)( XWEnv xwe, void* closure, XP_U16 msgCount );
|
||||
|
||||
typedef enum {
|
||||
COMMS_XPORT_FLAGS_NONE = 0
|
||||
|
@ -152,7 +152,7 @@ typedef enum {
|
|||
} CommsTransportFlags;
|
||||
|
||||
#ifdef COMMS_XPORT_FLAGSPROC
|
||||
typedef XP_U32 (*FlagsProc)( void* closure );
|
||||
typedef XP_U32 (*FlagsProc)( XWEnv xwe, void* closure );
|
||||
#endif
|
||||
|
||||
typedef struct _TransportProcs {
|
||||
|
@ -178,7 +178,7 @@ typedef struct _TransportProcs {
|
|||
void* closure;
|
||||
} TransportProcs;
|
||||
|
||||
CommsCtxt* comms_make( MPFORMAL XW_UtilCtxt* util,
|
||||
CommsCtxt* comms_make( MPFORMAL XWEnv xwe, XW_UtilCtxt* util,
|
||||
XP_Bool isServer,
|
||||
XP_U16 nPlayersHere, XP_U16 nPlayersTotal,
|
||||
const TransportProcs* procs, XP_U16 forceChannel
|
||||
|
@ -187,10 +187,10 @@ CommsCtxt* comms_make( MPFORMAL XW_UtilCtxt* util,
|
|||
#endif
|
||||
);
|
||||
|
||||
void comms_reset( CommsCtxt* comms, XP_Bool isServer,
|
||||
void comms_reset( CommsCtxt* comms, XWEnv xwe, XP_Bool isServer,
|
||||
XP_U16 nPlayersHere, XP_U16 nPlayersTotal );
|
||||
void comms_resetSame( CommsCtxt* comms );
|
||||
void comms_transportFailed( CommsCtxt* comms, CommsConnType failed );
|
||||
void comms_resetSame( CommsCtxt* comms, XWEnv xwe );
|
||||
void comms_transportFailed( CommsCtxt* comms, XWEnv xwe, CommsConnType failed );
|
||||
|
||||
void comms_destroy( CommsCtxt* comms );
|
||||
|
||||
|
@ -207,9 +207,9 @@ XP_Bool comms_checkAddr( DeviceRole role, const CommsAddrRec* addr,
|
|||
XW_UtilCtxt* util );
|
||||
|
||||
void comms_getAddr( const CommsCtxt* comms, CommsAddrRec* addr );
|
||||
void comms_augmentHostAddr( CommsCtxt* comms, const CommsAddrRec* addr );
|
||||
void comms_getAddrs( const CommsCtxt* comms, CommsAddrRec addr[],
|
||||
XP_U16* nRecs );
|
||||
void comms_augmentHostAddr( CommsCtxt* comms, XWEnv xwe, const CommsAddrRec* addr );
|
||||
void comms_getAddrs( const CommsCtxt* comms, XWEnv xwe,
|
||||
CommsAddrRec addr[], XP_U16* nRecs );
|
||||
XP_Bool comms_formatRelayID( const CommsCtxt* comms, XP_U16 indx,
|
||||
XP_UCHAR* buf, XP_U16* lenp );
|
||||
|
||||
|
@ -224,28 +224,30 @@ CommsConnTypes comms_getConTypes( const CommsCtxt* comms );
|
|||
void comms_dropHostAddr( CommsCtxt* comms, CommsConnType typ );
|
||||
XP_Bool comms_getIsServer( const CommsCtxt* comms );
|
||||
|
||||
CommsCtxt* comms_makeFromStream( MPFORMAL XWStreamCtxt* stream,
|
||||
CommsCtxt* comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream,
|
||||
XW_UtilCtxt* util,
|
||||
const TransportProcs* procs,
|
||||
XP_U16 forceChannel );
|
||||
void comms_start( CommsCtxt* comms );
|
||||
void comms_stop( CommsCtxt* comms );
|
||||
void comms_writeToStream( CommsCtxt* comms, XWStreamCtxt* stream,
|
||||
void comms_start( CommsCtxt* comms, XWEnv xwe );
|
||||
void comms_stop( CommsCtxt* comms, XWEnv xwe );
|
||||
void comms_writeToStream( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream,
|
||||
XP_U16 saveToken );
|
||||
void comms_saveSucceeded( CommsCtxt* comms, XP_U16 saveToken );
|
||||
void comms_saveSucceeded( CommsCtxt* comms, XWEnv xwe, XP_U16 saveToken );
|
||||
|
||||
void addrFromStream( CommsAddrRec* addr, XWStreamCtxt* stream );
|
||||
void addrToStream( XWStreamCtxt* stream, const CommsAddrRec* addr );
|
||||
|
||||
XP_S16 comms_send( CommsCtxt* comms, XWStreamCtxt* stream );
|
||||
XP_S16 comms_resendAll( CommsCtxt* comms, CommsConnType filter, XP_Bool force );
|
||||
XP_S16 comms_send( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream );
|
||||
XP_S16 comms_resendAll( CommsCtxt* comms, XWEnv xwe, CommsConnType filter,
|
||||
XP_Bool force );
|
||||
|
||||
typedef void (*PendingMsgProc)( void* closure, XP_U8* msg, XP_U16 len, MsgID msgID );
|
||||
void comms_getPending( CommsCtxt* comms, PendingMsgProc proc, void* closure );
|
||||
typedef void (*PendingMsgProc)( void* closure, XWEnv xwe, XP_U8* msg,
|
||||
XP_U16 len, MsgID msgID );
|
||||
void comms_getPending( CommsCtxt* comms, XWEnv xwe, PendingMsgProc proc, void* closure );
|
||||
XP_U16 comms_getChannelSeed( CommsCtxt* comms );
|
||||
|
||||
#ifdef XWFEATURE_COMMSACK
|
||||
void comms_ackAny( CommsCtxt* comms );
|
||||
void comms_ackAny( CommsCtxt* comms, XWEnv xwe );
|
||||
#endif
|
||||
|
||||
typedef struct _CommsMsgState {
|
||||
|
@ -257,11 +259,12 @@ typedef struct _CommsMsgState {
|
|||
#endif
|
||||
} CommsMsgState;
|
||||
|
||||
XP_Bool comms_checkIncomingStream( CommsCtxt* comms, XWStreamCtxt* stream,
|
||||
XP_Bool comms_checkIncomingStream( CommsCtxt* comms, XWEnv xwe,
|
||||
XWStreamCtxt* stream,
|
||||
const CommsAddrRec* addr,
|
||||
CommsMsgState* state );
|
||||
void comms_msgProcessed( CommsCtxt* comms, CommsMsgState* state,
|
||||
XP_Bool rejected );
|
||||
void comms_msgProcessed( CommsCtxt* comms, XWEnv xwe,
|
||||
CommsMsgState* state, XP_Bool rejected );
|
||||
XP_Bool comms_checkComplete( const CommsAddrRec* const addr );
|
||||
|
||||
XP_Bool comms_canChat( const CommsCtxt* comms );
|
||||
|
|
|
@ -57,7 +57,7 @@ load( XW_DUtilCtxt* dutil )
|
|||
} else {
|
||||
XP_LOGF( "%s(): empty stream!!", __func__ );
|
||||
}
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL );
|
||||
}
|
||||
|
||||
return state;
|
||||
|
@ -71,7 +71,7 @@ device_store( XW_DUtilCtxt* dutil )
|
|||
XWStreamCtxt* stream = mkStream( dutil );
|
||||
stream_putU16( stream, state->devCount );
|
||||
dutil_storeStream( dutil, KEY_DEVSTATE, stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL );
|
||||
|
||||
XP_FREEP( dutil->mpool, &dutil->devCtxt );
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ game_makeNewGame( MPFORMAL XWEnv xwe, XWGame* game, CurGameInfo* gi,
|
|||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
if ( gi->serverRole != SERVER_STANDALONE ) {
|
||||
game->comms = comms_make( MPPARM(mpool) util,
|
||||
game->comms = comms_make( MPPARM(mpool) xwe, util,
|
||||
gi->serverRole != SERVER_ISCLIENT,
|
||||
nPlayersHere, nPlayersTotal,
|
||||
procs, gi->forceChannel
|
||||
|
@ -159,7 +159,7 @@ game_makeNewGame( MPFORMAL XWEnv xwe, XWGame* game, CurGameInfo* gi,
|
|||
} /* game_makeNewGame */
|
||||
|
||||
XP_Bool
|
||||
game_reset( MPFORMAL XWGame* game, CurGameInfo* gi, XW_UtilCtxt* util,
|
||||
game_reset( MPFORMAL XWGame* game, XWEnv xwe, CurGameInfo* gi, XW_UtilCtxt* util,
|
||||
CommonPrefs* cp, const TransportProcs* procs )
|
||||
{
|
||||
XP_ASSERT( util == game->util );
|
||||
|
@ -182,11 +182,11 @@ game_reset( MPFORMAL XWGame* game, CurGameInfo* gi, XW_UtilCtxt* util,
|
|||
comms_destroy( game->comms );
|
||||
game->comms = NULL;
|
||||
} else {
|
||||
comms_reset( game->comms, gi->serverRole != SERVER_ISCLIENT,
|
||||
comms_reset( game->comms, xwe, gi->serverRole != SERVER_ISCLIENT,
|
||||
nPlayersHere, nPlayersTotal );
|
||||
}
|
||||
} else if ( gi->serverRole != SERVER_STANDALONE ) {
|
||||
game->comms = comms_make( MPPARM(mpool) util,
|
||||
game->comms = comms_make( MPPARM(mpool) xwe, util,
|
||||
gi->serverRole != SERVER_ISCLIENT,
|
||||
nPlayersHere, nPlayersTotal, procs,
|
||||
gi->forceChannel
|
||||
|
@ -202,7 +202,7 @@ game_reset( MPFORMAL XWGame* game, CurGameInfo* gi, XW_UtilCtxt* util,
|
|||
#endif
|
||||
|
||||
model_setSize( game->model, gi->boardSize );
|
||||
server_reset( game->server,
|
||||
server_reset( game->server, xwe,
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
game->comms
|
||||
#else
|
||||
|
@ -278,7 +278,7 @@ game_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, XWGame* game,
|
|||
}
|
||||
|
||||
if ( hasComms ) {
|
||||
game->comms = comms_makeFromStream( MPPARM(mpool) stream, util,
|
||||
game->comms = comms_makeFromStream( MPPARM(mpool) xwe, stream, util,
|
||||
procs, gi->forceChannel );
|
||||
} else {
|
||||
game->comms = NULL;
|
||||
|
@ -318,14 +318,14 @@ game_saveNewGame( MPFORMAL XWEnv xwe, const CurGameInfo* gi, XW_UtilCtxt* util,
|
|||
#endif
|
||||
);
|
||||
|
||||
game_saveToStream( &newGame, &newGI, out, 1 );
|
||||
game_saveSucceeded( &newGame, 1 );
|
||||
game_saveToStream( &newGame, xwe, &newGI, out, 1 );
|
||||
game_saveSucceeded( &newGame, xwe, 1 );
|
||||
game_dispose( &newGame, xwe );
|
||||
gi_disposePlayerInfo( MPPARM(mpool) &newGI );
|
||||
}
|
||||
|
||||
void
|
||||
game_saveToStream( const XWGame* game, const CurGameInfo* gi,
|
||||
game_saveToStream( const XWGame* game, XWEnv xwe, const CurGameInfo* gi,
|
||||
XWStreamCtxt* stream, XP_U16 saveToken )
|
||||
{
|
||||
stream_putU8( stream, CUR_STREAM_VERS );
|
||||
|
@ -340,7 +340,7 @@ game_saveToStream( const XWGame* game, const CurGameInfo* gi,
|
|||
XP_ASSERT( !game->comms );
|
||||
#endif
|
||||
if ( !!game->comms ) {
|
||||
comms_writeToStream( game->comms, stream, saveToken );
|
||||
comms_writeToStream( game->comms, xwe, stream, saveToken );
|
||||
}
|
||||
|
||||
model_writeToStream( game->model, stream );
|
||||
|
@ -350,10 +350,10 @@ game_saveToStream( const XWGame* game, const CurGameInfo* gi,
|
|||
} /* game_saveToStream */
|
||||
|
||||
void
|
||||
game_saveSucceeded( const XWGame* game, XP_U16 saveToken )
|
||||
game_saveSucceeded( const XWGame* game, XWEnv xwe, XP_U16 saveToken )
|
||||
{
|
||||
if ( !!game->comms ) {
|
||||
comms_saveSucceeded( game->comms, saveToken );
|
||||
comms_saveSucceeded( game->comms, xwe, saveToken );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,14 +363,14 @@ game_receiveMessage( XWGame* game, XWEnv xwe, XWStreamCtxt* stream,
|
|||
{
|
||||
ServerCtxt* server = game->server;
|
||||
CommsMsgState commsState;
|
||||
XP_Bool result = comms_checkIncomingStream( game->comms, stream, retAddr,
|
||||
XP_Bool result = comms_checkIncomingStream( game->comms, xwe, stream, retAddr,
|
||||
&commsState );
|
||||
if ( result ) {
|
||||
(void)server_do( server );
|
||||
(void)server_do( server, xwe );
|
||||
|
||||
result = server_receiveMessage( server, xwe, stream );
|
||||
}
|
||||
comms_msgProcessed( game->comms, &commsState, !result );
|
||||
comms_msgProcessed( game->comms, xwe, &commsState, !result );
|
||||
|
||||
if ( result ) {
|
||||
/* in case MORE work's pending. Multiple calls are required in at
|
||||
|
@ -379,7 +379,7 @@ game_receiveMessage( XWGame* game, XWEnv xwe, XWStreamCtxt* stream,
|
|||
robot move. That's because comms can't detect a duplicate initial
|
||||
packet (in validateInitialMessage()). */
|
||||
for ( int ii = 0; ii < 5; ++ii ) {
|
||||
(void)server_do( server );
|
||||
(void)server_do( server, xwe );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -429,7 +429,7 @@ game_dispose( XWGame* game, XWEnv xwe )
|
|||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
if ( !!game->comms ) {
|
||||
comms_stop( game->comms );
|
||||
comms_stop( game->comms, xwe );
|
||||
comms_destroy( game->comms );
|
||||
game->comms = NULL;
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ game_dispose( XWGame* game, XWEnv xwe )
|
|||
game->model = NULL;
|
||||
}
|
||||
if ( !!game->server ) {
|
||||
server_destroy( game->server );
|
||||
server_destroy( game->server, xwe );
|
||||
game->server = NULL;
|
||||
}
|
||||
} /* game_dispose */
|
||||
|
|
|
@ -68,8 +68,9 @@ void game_makeNewGame( MPFORMAL XWEnv xwe, XWGame* game, CurGameInfo* gi,
|
|||
,XP_U16 gameSeed
|
||||
#endif
|
||||
);
|
||||
XP_Bool game_reset( MPFORMAL XWGame* game, CurGameInfo* gi, XW_UtilCtxt* util,
|
||||
CommonPrefs* cp, const TransportProcs* procs );
|
||||
XP_Bool game_reset( MPFORMAL XWGame* game, XWEnv xwe, CurGameInfo* gi,
|
||||
XW_UtilCtxt* util, CommonPrefs* cp,
|
||||
const TransportProcs* procs );
|
||||
void game_changeDict( MPFORMAL XWGame* game, XWEnv xwe, CurGameInfo* gi,
|
||||
DictionaryCtxt* dict );
|
||||
|
||||
|
@ -82,9 +83,9 @@ XP_Bool game_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream,
|
|||
void game_saveNewGame( MPFORMAL XWEnv xwe, const CurGameInfo* gi, XW_UtilCtxt* util,
|
||||
const CommonPrefs* cp, XWStreamCtxt* out );
|
||||
|
||||
void game_saveToStream( const XWGame* game, const CurGameInfo* gi,
|
||||
void game_saveToStream( const XWGame* game, XWEnv xwe, const CurGameInfo* gi,
|
||||
XWStreamCtxt* stream, XP_U16 saveToken );
|
||||
void game_saveSucceeded( const XWGame* game, XP_U16 saveToken );
|
||||
void game_saveSucceeded( const XWGame* game, XWEnv xwe, XP_U16 saveToken );
|
||||
|
||||
XP_Bool game_receiveMessage( XWGame* game, XWEnv xwe, XWStreamCtxt* stream,
|
||||
const CommsAddrRec* retAddr );
|
||||
|
|
|
@ -370,14 +370,14 @@ mem_stream_open( XWStreamCtxt* p_sctx )
|
|||
} /* mem_stream_open */
|
||||
|
||||
static void
|
||||
mem_stream_close( XWStreamCtxt* p_sctx )
|
||||
mem_stream_close( XWStreamCtxt* p_sctx, XWEnv xwe )
|
||||
{
|
||||
MemStreamCtxt* stream = (MemStreamCtxt*)p_sctx;
|
||||
|
||||
XP_ASSERT( stream->isOpen );
|
||||
|
||||
if ( !!stream->onClose ) {
|
||||
(*stream->onClose)( p_sctx, stream->closure );
|
||||
(*stream->onClose)( p_sctx, xwe, stream->closure );
|
||||
}
|
||||
stream->isOpen = XP_FALSE;
|
||||
} /* mem_stream_close */
|
||||
|
@ -493,12 +493,12 @@ mem_stream_setPos( XWStreamCtxt* p_sctx, PosWhich which, XWStreamPos newpos )
|
|||
} /* mem_stream_setPos */
|
||||
|
||||
static void
|
||||
mem_stream_destroy( XWStreamCtxt* p_sctx )
|
||||
mem_stream_destroy( XWStreamCtxt* p_sctx, XWEnv xwe )
|
||||
{
|
||||
MemStreamCtxt* stream = (MemStreamCtxt*)p_sctx;
|
||||
|
||||
if ( stream->isOpen ) {
|
||||
stream_close( p_sctx );
|
||||
stream_close( p_sctx, xwe );
|
||||
}
|
||||
|
||||
XP_FREEP( stream->mpool, &stream->buf );
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*MemStreamCloseCallback)( XWStreamCtxt* stream,
|
||||
void* closure );
|
||||
typedef void (*MemStreamCloseCallback)( XWStreamCtxt* stream,
|
||||
XWEnv env, void* closure );
|
||||
|
||||
XWStreamCtxt* mem_stream_make_raw( MPFORMAL VTableMgr* vtmgr);
|
||||
|
||||
|
|
|
@ -62,10 +62,10 @@ static void setModelTileRaw( ModelCtxt* model, XP_U16 col, XP_U16 row,
|
|||
static void makeTileTrade( ModelCtxt* model, XP_S16 player,
|
||||
const TrayTileSet* oldTiles,
|
||||
const TrayTileSet* newTiles );
|
||||
static XP_S16 commitTurn( ModelCtxt* model, XP_S16 turn,
|
||||
static XP_S16 commitTurn( ModelCtxt* model, XWEnv xwe, XP_S16 turn,
|
||||
const TrayTileSet* newTiles, XWStreamCtxt* stream,
|
||||
WordNotifierInfo* wni, XP_Bool useStack );
|
||||
static void buildModelFromStack( ModelCtxt* model, StackCtxt* stack,
|
||||
static void buildModelFromStack( ModelCtxt* model, XWEnv xwe, StackCtxt* stack,
|
||||
XP_Bool useStack, XP_U16 initial,
|
||||
XWStreamCtxt* stream, WordNotifierInfo* wni,
|
||||
MovePrintFuncPre mpfpr,
|
||||
|
@ -179,7 +179,7 @@ model_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream,
|
|||
closure = &state;
|
||||
#endif
|
||||
|
||||
buildModelFromStack( model, model->vol.stack, XP_FALSE, 0,
|
||||
buildModelFromStack( model, xwe, model->vol.stack, XP_FALSE, 0,
|
||||
(XWStreamCtxt*)NULL, (WordNotifierInfo*)NULL,
|
||||
pre, post, closure );
|
||||
|
||||
|
@ -444,12 +444,12 @@ model_getSquareBonus( const ModelCtxt* model, XP_U16 col, XP_U16 row )
|
|||
}
|
||||
|
||||
static XP_U16
|
||||
makeAndCommit( ModelCtxt* model, XP_U16 turn, const MoveInfo* mi,
|
||||
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 );
|
||||
XP_U16 moveScore = commitTurn( model, turn, tiles,
|
||||
XP_U16 moveScore = commitTurn( model, xwe, turn, tiles,
|
||||
stream, wni, useStack );
|
||||
return moveScore;
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ model_cloneDupeTrays( ModelCtxt* model )
|
|||
}
|
||||
|
||||
static void
|
||||
modelAddEntry( ModelCtxt* model, XP_U16 indx, const StackEntry* entry,
|
||||
modelAddEntry( ModelCtxt* model, XWEnv xwe, XP_U16 indx, const StackEntry* entry,
|
||||
XP_Bool useStack, XWStreamCtxt* stream,
|
||||
WordNotifierInfo* wni, MovePrintFuncPre mpf_pre,
|
||||
MovePrintFuncPost mpf_post, void* closure )
|
||||
|
@ -490,7 +490,7 @@ modelAddEntry( ModelCtxt* model, XP_U16 indx, const StackEntry* entry,
|
|||
|
||||
switch ( entry->moveType ) {
|
||||
case MOVE_TYPE:
|
||||
moveScore = makeAndCommit( model, entry->playerNum, &entry->u.move.moveInfo,
|
||||
moveScore = makeAndCommit( model, xwe, entry->playerNum, &entry->u.move.moveInfo,
|
||||
&entry->u.move.newTiles, stream, useStack, wni );
|
||||
if ( model->vol.gi->inDuplicateMode ) {
|
||||
XP_ASSERT( DUP_PLAYER == entry->playerNum );
|
||||
|
@ -518,7 +518,7 @@ modelAddEntry( ModelCtxt* model, XP_U16 indx, const StackEntry* entry,
|
|||
model_makeTurnFromMoveInfo( model, entry->playerNum,
|
||||
&entry->u.phony.moveInfo);
|
||||
/* do something here to cause it to print */
|
||||
(void)getCurrentMoveScoreIfLegal( model, entry->playerNum, stream,
|
||||
(void)getCurrentMoveScoreIfLegal( model, xwe, entry->playerNum, stream,
|
||||
wni, &moveScore );
|
||||
moveScore = 0;
|
||||
model_resetCurrentTurn( model, entry->playerNum );
|
||||
|
@ -537,14 +537,14 @@ modelAddEntry( ModelCtxt* model, XP_U16 indx, const StackEntry* entry,
|
|||
} /* modelAddEntry */
|
||||
|
||||
static void
|
||||
buildModelFromStack( ModelCtxt* model, StackCtxt* stack, XP_Bool useStack,
|
||||
buildModelFromStack( ModelCtxt* model, XWEnv xwe, StackCtxt* stack, XP_Bool useStack,
|
||||
XP_U16 initial, XWStreamCtxt* stream,
|
||||
WordNotifierInfo* wni, MovePrintFuncPre mpf_pre,
|
||||
MovePrintFuncPost mpf_post, void* closure )
|
||||
{
|
||||
StackEntry entry;
|
||||
for ( XP_U16 ii = initial; stack_getNthEntry( stack, ii, &entry ); ++ii ) {
|
||||
modelAddEntry( model, ii, &entry, useStack, stream, wni,
|
||||
modelAddEntry( model, xwe, ii, &entry, useStack, stream, wni,
|
||||
mpf_pre, mpf_post, closure );
|
||||
stack_freeEntry( stack, &entry );
|
||||
}
|
||||
|
@ -1845,13 +1845,13 @@ invalidateScores( ModelCtxt* model )
|
|||
* in their trays.
|
||||
*/
|
||||
static XP_S16
|
||||
commitTurn( ModelCtxt* model, XP_S16 turn, const TrayTileSet* newTiles,
|
||||
commitTurn( ModelCtxt* model, XWEnv xwe, XP_S16 turn, const TrayTileSet* newTiles,
|
||||
XWStreamCtxt* stream, WordNotifierInfo* wni, XP_Bool useStack )
|
||||
{
|
||||
XP_S16 score = -1;
|
||||
|
||||
#ifdef DEBUG
|
||||
XP_ASSERT( getCurrentMoveScoreIfLegal( model, turn, (XWStreamCtxt*)NULL,
|
||||
XP_ASSERT( getCurrentMoveScoreIfLegal( model, xwe, turn, (XWStreamCtxt*)NULL,
|
||||
(WordNotifierInfo*)NULL, &score ) );
|
||||
invalidateScore( model, turn );
|
||||
#endif
|
||||
|
@ -1900,7 +1900,7 @@ commitTurn( ModelCtxt* model, XP_S16 turn, const TrayTileSet* newTiles,
|
|||
++model->vol.nTilesOnBoard;
|
||||
}
|
||||
|
||||
(void)getCurrentMoveScoreIfLegal( model, turn, stream, wni, &score );
|
||||
(void)getCurrentMoveScoreIfLegal( model, xwe, turn, stream, wni, &score );
|
||||
XP_ASSERT( score >= 0 );
|
||||
if ( ! model->vol.gi->inDuplicateMode ) {
|
||||
player->score += score;
|
||||
|
@ -1920,19 +1920,19 @@ commitTurn( ModelCtxt* model, XP_S16 turn, const TrayTileSet* newTiles,
|
|||
} /* commitTurn */
|
||||
|
||||
XP_Bool
|
||||
model_commitTurn( ModelCtxt* model, XP_S16 turn, TrayTileSet* newTiles )
|
||||
model_commitTurn( ModelCtxt* model, XWEnv xwe, XP_S16 turn, TrayTileSet* newTiles )
|
||||
{
|
||||
XP_S16 score = commitTurn( model, turn, newTiles, NULL, NULL, XP_TRUE );
|
||||
XP_S16 score = commitTurn( model, xwe, turn, newTiles, NULL, NULL, XP_TRUE );
|
||||
return 0 <= score;
|
||||
} /* model_commitTurn */
|
||||
|
||||
void
|
||||
model_commitDupeTurn( ModelCtxt* model, const MoveInfo* moveInfo,
|
||||
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 );
|
||||
(void)commitTurn( model, DUP_PLAYER, newTiles, NULL, NULL, XP_FALSE );
|
||||
(void)commitTurn( model, xwe, DUP_PLAYER, newTiles, NULL, NULL, XP_FALSE );
|
||||
dupe_adjustScores( model, XP_TRUE, nScores, scores );
|
||||
invalidateScores( model );
|
||||
|
||||
|
@ -2424,7 +2424,7 @@ printMovePost( ModelCtxt* model, XP_U16 XP_UNUSED(moveN),
|
|||
} /* printMovePost */
|
||||
|
||||
static void
|
||||
copyStack( const ModelCtxt* model, StackCtxt* destStack,
|
||||
copyStack( const ModelCtxt* model, XWEnv xwe, StackCtxt* destStack,
|
||||
const StackCtxt* srcStack )
|
||||
{
|
||||
XWStreamCtxt* stream =
|
||||
|
@ -2434,7 +2434,7 @@ copyStack( const ModelCtxt* model, StackCtxt* destStack,
|
|||
stack_writeToStream( (StackCtxt*)srcStack, stream );
|
||||
stack_loadFromStream( destStack, stream );
|
||||
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, xwe );
|
||||
} /* copyStack */
|
||||
|
||||
static ModelCtxt*
|
||||
|
@ -2448,7 +2448,7 @@ makeTmpModel( const ModelCtxt* model, XWEnv xwe, XWStreamCtxt* stream,
|
|||
tmpModel->loaner = model;
|
||||
model_setNPlayers( tmpModel, model->nPlayers );
|
||||
|
||||
buildModelFromStack( tmpModel, model->vol.stack, XP_FALSE, 0, stream,
|
||||
buildModelFromStack( tmpModel, xwe, model->vol.stack, XP_FALSE, 0, stream,
|
||||
(WordNotifierInfo*)NULL, mpf_pre, mpf_post, closure );
|
||||
|
||||
return tmpModel;
|
||||
|
@ -2501,7 +2501,7 @@ scoreLastMove( ModelCtxt* model, XWEnv xwe, MoveInfo* moveInfo, XP_U16 howMany,
|
|||
XP_U16 turn;
|
||||
XP_S16 moveNum = -1;
|
||||
|
||||
copyStack( model, tmpModel->vol.stack, model->vol.stack );
|
||||
copyStack( model, xwe, tmpModel->vol.stack, model->vol.stack );
|
||||
|
||||
if ( !model_undoLatestMoves( tmpModel, NULL, howMany, &turn,
|
||||
&moveNum ) ) {
|
||||
|
@ -2620,7 +2620,7 @@ model_listWordsThrough( ModelCtxt* model, XWEnv xwe, XP_U16 col, XP_U16 row,
|
|||
{
|
||||
XP_Bool found = XP_FALSE;
|
||||
ModelCtxt* tmpModel = makeTmpModel( model, xwe, NULL, NULL, NULL, NULL );
|
||||
copyStack( model, tmpModel->vol.stack, model->vol.stack );
|
||||
copyStack( model, xwe, tmpModel->vol.stack, model->vol.stack );
|
||||
|
||||
XP_Bool isHorizontal;
|
||||
if ( tilesInLine( model, turn, &isHorizontal ) ) {
|
||||
|
@ -2629,10 +2629,10 @@ model_listWordsThrough( ModelCtxt* model, XWEnv xwe, XP_U16 col, XP_U16 row,
|
|||
model_makeTurnFromMoveInfo( tmpModel, turn, &moveInfo );
|
||||
|
||||
/* Might not be a legal move. If isn't, don't add it! */
|
||||
if ( getCurrentMoveScoreIfLegal( tmpModel, turn, (XWStreamCtxt*)NULL,
|
||||
if ( getCurrentMoveScoreIfLegal( tmpModel, xwe, turn, (XWStreamCtxt*)NULL,
|
||||
(WordNotifierInfo*)NULL, NULL ) ) {
|
||||
TrayTileSet newTiles = {.nTiles = 0};
|
||||
commitTurn( tmpModel, turn, &newTiles, NULL, NULL, XP_TRUE );
|
||||
commitTurn( tmpModel, xwe, turn, &newTiles, NULL, NULL, XP_TRUE );
|
||||
} else {
|
||||
model_resetCurrentTurn( tmpModel, turn );
|
||||
}
|
||||
|
@ -2666,7 +2666,7 @@ model_listWordsThrough( ModelCtxt* model, XWEnv xwe, XP_U16 col, XP_U16 row,
|
|||
XP_ASSERT( 0 );
|
||||
break;
|
||||
}
|
||||
modelAddEntry( tmpModel, nEntriesAfter++, &entry, XP_FALSE, NULL, &ni,
|
||||
modelAddEntry( tmpModel, xwe, nEntriesAfter++, &entry, XP_FALSE, NULL, &ni,
|
||||
NULL, NULL, NULL );
|
||||
}
|
||||
XP_LOGFF( "nWords: %d", lwtInfo.nWords );
|
||||
|
|
|
@ -202,9 +202,10 @@ void model_getCurrentMoveTile( ModelCtxt* model, XP_S16 turn, XP_S16* index,
|
|||
Tile* tile, XP_U16* col, XP_U16* row,
|
||||
XP_Bool* isBlank );
|
||||
|
||||
XP_Bool model_commitTurn( ModelCtxt* model, XP_S16 player,
|
||||
XP_Bool model_commitTurn( ModelCtxt* model, XWEnv xwe, XP_S16 player,
|
||||
TrayTileSet* newTiles );
|
||||
void model_commitDupeTurn( ModelCtxt* model, const MoveInfo* moveInfo,
|
||||
void model_commitDupeTurn( ModelCtxt* model, XWEnv xwe,
|
||||
const MoveInfo* moveInfo,
|
||||
XP_U16 nScores, XP_U16* scores,
|
||||
TrayTileSet* newTiles );
|
||||
void model_commitDupeTrade( ModelCtxt* model, const TrayTileSet* oldTiles,
|
||||
|
@ -300,16 +301,16 @@ typedef struct WordNotifierInfo {
|
|||
void* closure;
|
||||
} WordNotifierInfo;
|
||||
|
||||
XP_Bool getCurrentMoveScoreIfLegal( ModelCtxt* model, XP_S16 turn,
|
||||
XWStreamCtxt* stream,
|
||||
XP_Bool getCurrentMoveScoreIfLegal( ModelCtxt* model, XWEnv xwe,
|
||||
XP_S16 turn, XWStreamCtxt* stream,
|
||||
WordNotifierInfo* wni, XP_S16* score );
|
||||
XP_S16 model_getPlayerScore( ModelCtxt* model, XP_S16 player );
|
||||
|
||||
XP_Bool model_getPlayersLastScore( ModelCtxt* model, XWEnv xwe, XP_S16 player,
|
||||
LastMoveInfo* info );
|
||||
#ifdef XWFEATURE_BOARDWORDS
|
||||
XP_Bool model_listWordsThrough( ModelCtxt* model, XWEnv xwe, XP_U16 col, XP_U16 row,
|
||||
XP_S16 turn, XWStreamCtxt* stream );
|
||||
XP_Bool model_listWordsThrough( ModelCtxt* model, XWEnv xwe, XP_U16 col,
|
||||
XP_U16 row, XP_S16 turn, XWStreamCtxt* stream );
|
||||
#endif
|
||||
|
||||
/* Have there been too many passes (so game should end)? */
|
||||
|
@ -322,7 +323,7 @@ void model_setSquareBonuses( ModelCtxt* model, XWBonusType* bonuses,
|
|||
XP_U16 nBonuses );
|
||||
#endif
|
||||
|
||||
XP_Bool model_checkMoveLegal( ModelCtxt* model, XP_S16 player,
|
||||
XP_Bool model_checkMoveLegal( ModelCtxt* model, XWEnv xwe, XP_S16 player,
|
||||
XWStreamCtxt* stream,
|
||||
WordNotifierInfo* notifyInfo );
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ void
|
|||
stack_destroy( StackCtxt* stack )
|
||||
{
|
||||
if ( !!stack->data ) {
|
||||
stream_destroy( stack->data );
|
||||
stream_destroy( stack->data, NULL );
|
||||
}
|
||||
/* Ok to close with a dirty stack, e.g. if not saving a deleted game */
|
||||
// ASSERT_NOT_DIRTY( stack );
|
||||
|
@ -201,7 +201,7 @@ stack_copy( const StackCtxt* stack )
|
|||
stack->nPlayers, stack->inDuplicateMode );
|
||||
stack_loadFromStream( newStack, stream );
|
||||
stack_setBitsPerTile( newStack, stack->bitsPerTile );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL );
|
||||
return newStack;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ static XP_U16 find_end( const ModelCtxt* model, XP_U16 col, XP_U16 row,
|
|||
XP_Bool isHorizontal );
|
||||
static XP_U16 find_start( const ModelCtxt* model, XP_U16 col, XP_U16 row,
|
||||
XP_Bool isHorizontal );
|
||||
static XP_S16 checkScoreMove( ModelCtxt* model, XP_S16 turn,
|
||||
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,
|
||||
|
@ -77,7 +77,7 @@ static void formatSummary( XWStreamCtxt* stream, const ModelCtxt* model,
|
|||
* invalidate the score.
|
||||
*/
|
||||
static void
|
||||
scoreCurrentMove( ModelCtxt* model, XP_S16 turn, XWStreamCtxt* stream,
|
||||
scoreCurrentMove( ModelCtxt* model, XWEnv xwe, XP_S16 turn, XWStreamCtxt* stream,
|
||||
WordNotifierInfo* notifyInfo )
|
||||
{
|
||||
PlayerCtxt* player = &model->players[turn];
|
||||
|
@ -86,7 +86,7 @@ scoreCurrentMove( ModelCtxt* model, XP_S16 turn, XWStreamCtxt* stream,
|
|||
XP_ASSERT( !player->curMoveValid );
|
||||
|
||||
/* recalc goes here */
|
||||
score = checkScoreMove( model, turn, (EngineCtxt*)NULL, stream,
|
||||
score = checkScoreMove( model, xwe, turn, (EngineCtxt*)NULL, stream,
|
||||
XP_TRUE, notifyInfo );
|
||||
XP_ASSERT( score >= 0 || score == ILLEGAL_MOVE_SCORE );
|
||||
|
||||
|
@ -113,11 +113,11 @@ adjustScoreForUndone( ModelCtxt* model, const MoveInfo* mi, XP_U16 turn )
|
|||
} /* adjustScoreForUndone */
|
||||
|
||||
XP_Bool
|
||||
model_checkMoveLegal( ModelCtxt* model, XP_S16 turn, XWStreamCtxt* stream,
|
||||
model_checkMoveLegal( ModelCtxt* model, XWEnv xwe, XP_S16 turn, XWStreamCtxt* stream,
|
||||
WordNotifierInfo* notifyInfo )
|
||||
{
|
||||
XP_S16 score;
|
||||
score = checkScoreMove( model, turn, (EngineCtxt*)NULL, stream, XP_FALSE,
|
||||
score = checkScoreMove( model, xwe, turn, (EngineCtxt*)NULL, stream, XP_FALSE,
|
||||
notifyInfo );
|
||||
return score != ILLEGAL_MOVE_SCORE;
|
||||
} /* model_checkMoveLegal */
|
||||
|
@ -129,13 +129,13 @@ invalidateScore( ModelCtxt* model, XP_S16 turn )
|
|||
} /* invalidateScore */
|
||||
|
||||
XP_Bool
|
||||
getCurrentMoveScoreIfLegal( ModelCtxt* model, XP_S16 turn,
|
||||
getCurrentMoveScoreIfLegal( ModelCtxt* model, XWEnv xwe, XP_S16 turn,
|
||||
XWStreamCtxt* stream,
|
||||
WordNotifierInfo* wni, XP_S16* scoreP )
|
||||
{
|
||||
PlayerCtxt* player = &model->players[turn];
|
||||
if ( !player->curMoveValid ) {
|
||||
scoreCurrentMove( model, turn, stream, wni );
|
||||
scoreCurrentMove( model, xwe, turn, stream, wni );
|
||||
}
|
||||
|
||||
if ( !!scoreP ) {
|
||||
|
@ -251,7 +251,7 @@ blockCheck( const WNParams* wnp, void* closure )
|
|||
* Negative score means illegal.
|
||||
*/
|
||||
static XP_S16
|
||||
checkScoreMove( ModelCtxt* model, XP_S16 turn, EngineCtxt* engine,
|
||||
checkScoreMove( ModelCtxt* model, XWEnv xwe, XP_S16 turn, EngineCtxt* engine,
|
||||
XWStreamCtxt* stream, XP_Bool silent,
|
||||
WordNotifierInfo* notifyInfo )
|
||||
{
|
||||
|
@ -300,7 +300,7 @@ checkScoreMove( ModelCtxt* model, XP_S16 turn, EngineCtxt* engine,
|
|||
DictionaryCtxt* dict = model_getPlayerDict( model, turn );
|
||||
util_informWordsBlocked( model->vol.util, bcs.nBadWords,
|
||||
bcs.stream, dict_getName( dict ) );
|
||||
stream_destroy( bcs.stream );
|
||||
stream_destroy( bcs.stream, xwe );
|
||||
}
|
||||
} else {
|
||||
score = tmpScore;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -39,8 +39,8 @@ ServerCtxt* server_makeFromStream( MPFORMAL XWStreamCtxt* stream,
|
|||
|
||||
void server_writeToStream( const ServerCtxt* server, XWStreamCtxt* stream );
|
||||
|
||||
void server_reset( ServerCtxt* server, CommsCtxt* comms );
|
||||
void server_destroy( ServerCtxt* server );
|
||||
void server_reset( ServerCtxt* server, XWEnv xwe, CommsCtxt* comms );
|
||||
void server_destroy( ServerCtxt* server, XWEnv xwe );
|
||||
|
||||
void server_prefsChanged( ServerCtxt* server, const CommonPrefs* cp );
|
||||
|
||||
|
@ -71,7 +71,7 @@ XP_U16 server_secondsUsedBy( ServerCtxt* server, XP_U16 playerNum );
|
|||
|
||||
/* It might make more sense to have the board supply the undo method clients
|
||||
call... */
|
||||
XP_Bool server_handleUndo( ServerCtxt* server, XP_U16 limit );
|
||||
XP_Bool server_handleUndo( ServerCtxt* server, XWEnv xwe, XP_U16 limit );
|
||||
|
||||
/* signed because negative number means nobody's turn yet */
|
||||
XP_S16 server_getCurrentTurn( const ServerCtxt* server, XP_Bool* isLocal );
|
||||
|
@ -82,8 +82,8 @@ XP_S16 server_getTimerSeconds( const ServerCtxt* server, 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 );
|
||||
void server_pause( ServerCtxt* server, XP_S16 turn, const XP_UCHAR* msg );
|
||||
void server_unpause( ServerCtxt* server, XP_S16 turn, const XP_UCHAR* msg );
|
||||
void server_pause( ServerCtxt* server, XWEnv xwe, XP_S16 turn, const XP_UCHAR* msg );
|
||||
void server_unpause( ServerCtxt* server, XWEnv xwe, XP_S16 turn, const XP_UCHAR* msg );
|
||||
|
||||
/* return bitvector marking players still not arrived in networked game */
|
||||
XP_U16 server_getMissingPlayers( const ServerCtxt* server );
|
||||
|
@ -98,15 +98,16 @@ void server_tilesPicked( ServerCtxt* server, XP_U16 player,
|
|||
|
||||
XP_U16 server_getPendingRegs( const ServerCtxt* server );
|
||||
|
||||
XP_Bool server_do( ServerCtxt* server );
|
||||
XP_Bool server_do( ServerCtxt* server, XWEnv xwe );
|
||||
|
||||
XP_Bool server_commitMove( ServerCtxt* server, XP_U16 player,
|
||||
XP_Bool server_commitMove( ServerCtxt* server, XWEnv xwe, XP_U16 player,
|
||||
TrayTileSet* newTiles );
|
||||
XP_Bool server_commitTrade( ServerCtxt* server, const TrayTileSet* oldTiles,
|
||||
XP_Bool server_commitTrade( ServerCtxt* server, XWEnv xwe,
|
||||
const TrayTileSet* oldTiles,
|
||||
TrayTileSet* newTiles );
|
||||
|
||||
/* call this when user wants to end the game */
|
||||
void server_endGame( ServerCtxt* server );
|
||||
void server_endGame( ServerCtxt* server, XWEnv xwe );
|
||||
|
||||
/* called when running as either client or server */
|
||||
XP_Bool server_receiveMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* incoming );
|
||||
|
@ -114,11 +115,13 @@ XP_Bool server_receiveMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* inco
|
|||
/* client-side messages. Client (platform code)owns the stream used to talk
|
||||
* to the server, and passes it in. */
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
XP_Bool server_initClientConnection( ServerCtxt* server, XWStreamCtxt* stream );
|
||||
XP_Bool server_initClientConnection( ServerCtxt* server, XWEnv xwe,
|
||||
XWStreamCtxt* stream );
|
||||
#endif
|
||||
|
||||
#ifdef XWFEATURE_CHAT
|
||||
void server_sendChat( ServerCtxt* server, const XP_UCHAR* msg, XP_S16 from );
|
||||
void server_sendChat( ServerCtxt* server, XWEnv xwe,
|
||||
const XP_UCHAR* msg, XP_S16 from );
|
||||
#endif
|
||||
|
||||
void server_formatDictCounts( ServerCtxt* server, XWStreamCtxt* stream,
|
||||
|
|
|
@ -89,6 +89,7 @@ struct SMSProto {
|
|||
|
||||
static int nextMsgID( SMSProto* state );
|
||||
static XWStreamCtxt* mkStream( SMSProto* state );
|
||||
static void destroyStream( XWStreamCtxt* stream );
|
||||
static SMSMsgArray* toNetMsgs( SMSProto* state, ToPhoneRec* rec, XP_Bool forceOld );
|
||||
static ToPhoneRec* getForPhone( SMSProto* state, const XP_UCHAR* phone,
|
||||
XP_Bool create );
|
||||
|
@ -361,7 +362,7 @@ smsproto_prepInbound( SMSProto* state, const XP_UCHAR* fromPhone,
|
|||
}
|
||||
}
|
||||
}
|
||||
stream_destroy( msgStream );
|
||||
destroyStream( msgStream );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -372,7 +373,7 @@ smsproto_prepInbound( SMSProto* state, const XP_UCHAR* fromPhone,
|
|||
}
|
||||
}
|
||||
|
||||
stream_destroy( stream );
|
||||
destroyStream( stream );
|
||||
|
||||
XP_LOGFF( "=> %p (len=%d)", result, (!!result) ? result->nMsgs : 0 );
|
||||
logResult( state, result, __func__ );
|
||||
|
@ -518,7 +519,7 @@ addToOutRec( SMSProto* state, ToPhoneRec* rec, SMS_CMD cmd,
|
|||
mRec->msgNet.len = len;
|
||||
mRec->msgNet.data = XP_MALLOC( state->mpool, len );
|
||||
XP_MEMCPY( mRec->msgNet.data, stream_getPtr(stream), len );
|
||||
stream_destroy( stream );
|
||||
destroyStream( stream );
|
||||
|
||||
mRec->createSeconds = nowSeconds;
|
||||
|
||||
|
@ -701,7 +702,7 @@ savePartials( SMSProto* state )
|
|||
state->lastStoredSize = newSize;
|
||||
}
|
||||
|
||||
stream_destroy( stream );
|
||||
destroyStream( stream );
|
||||
|
||||
LOG_RETURN_VOID();
|
||||
} /* savePartials */
|
||||
|
@ -736,7 +737,7 @@ restorePartials( SMSProto* state )
|
|||
}
|
||||
}
|
||||
}
|
||||
stream_destroy( stream );
|
||||
destroyStream( stream );
|
||||
}
|
||||
|
||||
static SMSMsgArray*
|
||||
|
@ -785,7 +786,7 @@ completeMsgs( SMSProto* state, SMSMsgArray* arr, const XP_UCHAR* fromPhone,
|
|||
XP_FREEP( state->mpool, &msg.data );
|
||||
}
|
||||
}
|
||||
stream_destroy( stream );
|
||||
destroyStream( stream );
|
||||
|
||||
freeMsgIDRec( state, rec, fromPhoneIndex, msgIDIndex );
|
||||
}
|
||||
|
@ -886,6 +887,12 @@ mkStream( SMSProto* state )
|
|||
return stream;
|
||||
}
|
||||
|
||||
static void
|
||||
destroyStream( XWStreamCtxt* stream )
|
||||
{
|
||||
stream_destroy( stream, NULL );
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
smsproto_runTests( MPFORMAL XW_DUtilCtxt* dutil )
|
||||
|
|
|
@ -31,7 +31,7 @@ extern "C" {
|
|||
/****************************** prototypes ******************************/
|
||||
static void drawPendingScore( BoardCtxt* board, XWEnv xwe, XP_S16 turnScore,
|
||||
XP_Bool hasCursor );
|
||||
static XP_S16 figurePendingScore( const BoardCtxt* board );
|
||||
static XP_S16 figurePendingScore( const BoardCtxt* board, XWEnv xwe );
|
||||
static XP_U16 countTilesToShow( BoardCtxt* board );
|
||||
static void figureDividerRect( BoardCtxt* board, XP_Rect* rect );
|
||||
|
||||
|
@ -138,7 +138,7 @@ drawTray( BoardCtxt* board, XWEnv xwe )
|
|||
const XP_S16 turn = board->selPlayer;
|
||||
PerTurnInfo* pti = board->selInfo;
|
||||
|
||||
XP_S16 turnScore = figurePendingScore( board );
|
||||
XP_S16 turnScore = figurePendingScore( board, xwe );
|
||||
|
||||
if ( draw_trayBegin( board->draw, xwe, &board->trayBounds, turn,
|
||||
turnScore, dfsFor( board, OBJ_TRAY ) ) ) {
|
||||
|
@ -322,10 +322,10 @@ countTilesToShow( BoardCtxt* board )
|
|||
} /* countTilesToShow */
|
||||
|
||||
static XP_S16
|
||||
figurePendingScore( const BoardCtxt* board )
|
||||
figurePendingScore( const BoardCtxt* board, XWEnv xwe )
|
||||
{
|
||||
XP_S16 turnScore;
|
||||
(void)getCurrentMoveScoreIfLegal( board->model, board->selPlayer,
|
||||
(void)getCurrentMoveScoreIfLegal( board->model, xwe, board->selPlayer,
|
||||
(XWStreamCtxt*)NULL,
|
||||
(WordNotifierInfo*)NULL,
|
||||
&turnScore );
|
||||
|
@ -416,7 +416,7 @@ getSelTiles( const BoardCtxt* board, TileBit selBits, TrayTileSet* selTiles )
|
|||
}
|
||||
|
||||
static XP_Bool
|
||||
handleActionInTray( BoardCtxt* board, XP_S16 index, XP_Bool onDivider )
|
||||
handleActionInTray( BoardCtxt* board, XWEnv xwe, XP_S16 index, XP_Bool onDivider )
|
||||
{
|
||||
XP_Bool result = XP_FALSE;
|
||||
PerTurnInfo* pti = board->selInfo;
|
||||
|
@ -459,7 +459,7 @@ handleActionInTray( BoardCtxt* board, XP_S16 index, XP_Bool onDivider )
|
|||
}
|
||||
#endif
|
||||
} else if ( index == -(MAX_TRAY_TILES) ) { /* pending score tile */
|
||||
result = board_commitTurn( board, XP_FALSE, XP_FALSE, NULL );
|
||||
result = board_commitTurn( board, xwe, XP_FALSE, XP_FALSE, NULL );
|
||||
#if defined XWFEATURE_TRAYUNDO_ALL
|
||||
} else if ( index < 0 ) { /* other empty area */
|
||||
/* it better be true */
|
||||
|
@ -476,11 +476,11 @@ handleActionInTray( BoardCtxt* board, XP_S16 index, XP_Bool onDivider )
|
|||
} /* handleActionInTray */
|
||||
|
||||
XP_Bool
|
||||
handlePenUpTray( BoardCtxt* board, XP_U16 x, XP_U16 y )
|
||||
handlePenUpTray( BoardCtxt* board, XWEnv xwe, XP_U16 x, XP_U16 y )
|
||||
{
|
||||
XP_Bool onDivider;
|
||||
XP_S16 index = pointToTileIndex( board, x, y, &onDivider );
|
||||
return handleActionInTray( board, index, onDivider );
|
||||
return handleActionInTray( board, xwe, index, onDivider );
|
||||
} /* handlePenUpTray */
|
||||
|
||||
XP_U16
|
||||
|
|
|
@ -55,7 +55,7 @@ typedef XP_U8 PosWhich;
|
|||
|
||||
|
||||
typedef struct StreamCtxVTable {
|
||||
void (*m_stream_destroy)( XWStreamCtxt* dctx );
|
||||
void (*m_stream_destroy)( XWStreamCtxt* dctx, XWEnv xwe );
|
||||
|
||||
XP_U8 (*m_stream_getU8)( DBG_PROC_FORMAL XWStreamCtxt* dctx );
|
||||
void (*m_stream_getBytes)( DBG_PROC_FORMAL XWStreamCtxt* dctx, void* where,
|
||||
|
@ -85,7 +85,7 @@ typedef struct StreamCtxVTable {
|
|||
XWStreamPos newpos );
|
||||
|
||||
void (*m_stream_open)( XWStreamCtxt* dctx );
|
||||
void (*m_stream_close)( XWStreamCtxt* dctx );
|
||||
void (*m_stream_close)( XWStreamCtxt* dctx, XWEnv xwe );
|
||||
|
||||
XP_U16 (*m_stream_getSize)( const XWStreamCtxt* dctx );
|
||||
XP_U32 (*m_stream_getHash)( const XWStreamCtxt* dctx, XWStreamPos pos );
|
||||
|
@ -111,8 +111,8 @@ struct XWStreamCtxt {
|
|||
};
|
||||
|
||||
|
||||
#define stream_destroy(sc) \
|
||||
(sc)->vtable->m_stream_destroy(sc)
|
||||
#define stream_destroy(sc,e) \
|
||||
(sc)->vtable->m_stream_destroy(sc,(e))
|
||||
|
||||
#define stream_getU8(sc) \
|
||||
(sc)->vtable->m_stream_getU8(DBG_PROC (sc))
|
||||
|
@ -164,8 +164,8 @@ struct XWStreamCtxt {
|
|||
#define stream_open(sc) \
|
||||
(sc)->vtable->m_stream_open((sc))
|
||||
|
||||
#define stream_close(sc) \
|
||||
(sc)->vtable->m_stream_close((sc))
|
||||
#define stream_close(sc, e) \
|
||||
(sc)->vtable->m_stream_close((sc), (e))
|
||||
|
||||
#define stream_getSize(sc) \
|
||||
(sc)->vtable->m_stream_getSize((sc))
|
||||
|
|
|
@ -117,16 +117,16 @@ static bool handleRootKeyHide( void* closure, int key );
|
|||
#endif
|
||||
static bool handleInvite( void* closure, int key );
|
||||
|
||||
static void relay_connd_curses( void* closure, XP_UCHAR* const room,
|
||||
static void relay_connd_curses( XWEnv xwe, void* closure, XP_UCHAR* const room,
|
||||
XP_Bool reconnect, XP_U16 devOrder,
|
||||
XP_Bool allHere, XP_U16 nMissing );
|
||||
static void relay_status_curses( void* closure, CommsRelayState state );
|
||||
static void relay_error_curses( void* closure, XWREASON relayErr );
|
||||
static XP_Bool relay_sendNoConn_curses( const XP_U8* msg, XP_U16 len,
|
||||
static void relay_status_curses( XWEnv xwe, void* closure, CommsRelayState state );
|
||||
static void relay_error_curses( XWEnv xwe, void* closure, XWREASON relayErr );
|
||||
static XP_Bool relay_sendNoConn_curses( XWEnv xwe, const XP_U8* msg, XP_U16 len,
|
||||
const XP_UCHAR* msgNo,
|
||||
const XP_UCHAR* relayID, void* closure );
|
||||
static void curses_countChanged( void* closure, XP_U16 newCount );
|
||||
static XP_U32 curses_getFlags( void* closure );
|
||||
static void curses_countChanged( XWEnv xwe, void* closure, XP_U16 newCount );
|
||||
static XP_U32 curses_getFlags( XWEnv xwe, void* closure );
|
||||
#ifdef RELAY_VIA_HTTP
|
||||
static void relay_requestJoin_curses( void* closure, const XP_UCHAR* devID,
|
||||
const XP_UCHAR* room, XP_U16 nPlayersHere,
|
||||
|
@ -178,7 +178,7 @@ cb_open( CursesBoardState* cbState, sqlite3_int64 rowid, const cb_dims* dims )
|
|||
|
||||
CommonGlobals* cGlobals = &bGlobals->cGlobals;
|
||||
if ( !!cGlobals->game.comms ) {
|
||||
comms_resendAll( cGlobals->game.comms, COMMS_CONN_NONE, XP_FALSE );
|
||||
comms_resendAll( cGlobals->game.comms, NULL_XWE, COMMS_CONN_NONE, XP_FALSE );
|
||||
}
|
||||
if ( bGlobals->cGlobals.params->forceInvite ) {
|
||||
(void)ADD_ONETIME_IDLE( inviteIdle, bGlobals);
|
||||
|
@ -773,7 +773,7 @@ ask_move( gpointer data )
|
|||
if (0 == cursesask(bGlobals->boardWin, cGlobals->question,
|
||||
VSIZE(answers)-1, answers) ) {
|
||||
BoardCtxt* board = cGlobals->game.board;
|
||||
if ( board_commitTurn( board, XP_TRUE, XP_TRUE, NULL ) ) {
|
||||
if ( board_commitTurn( board, NULL_XWE, XP_TRUE, XP_TRUE, NULL ) ) {
|
||||
board_draw( board, NULL_XWE );
|
||||
linuxSaveGame( &bGlobals->cGlobals );
|
||||
}
|
||||
|
@ -855,7 +855,7 @@ ask_trade( gpointer data )
|
|||
if (0 == cursesask( bGlobals->boardWin, cGlobals->question,
|
||||
VSIZE(buttons), buttons ) ) {
|
||||
BoardCtxt* board = cGlobals->game.board;
|
||||
if ( board_commitTurn( board, XP_TRUE, XP_TRUE, NULL ) ) {
|
||||
if ( board_commitTurn( board, NULL_XWE, XP_TRUE, XP_TRUE, NULL ) ) {
|
||||
board_draw( board, NULL_XWE );
|
||||
linuxSaveGame( cGlobals );
|
||||
}
|
||||
|
@ -895,7 +895,7 @@ cursesShowFinalScores( CursesBoardGlobals* bGlobals )
|
|||
(void)ca_inform( bGlobals->boardWin, text );
|
||||
|
||||
free( text );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
} /* cursesShowFinalScores */
|
||||
|
||||
static void
|
||||
|
@ -949,7 +949,7 @@ curses_util_notifyGameOver( XW_UtilCtxt* uc, XP_S16 quitter )
|
|||
sleep( params->quitAfter );
|
||||
handleQuit( bGlobals->cbState->aGlobals, 0 );
|
||||
} else if ( params->undoWhenDone ) {
|
||||
server_handleUndo( cGlobals->game.server, 0 );
|
||||
server_handleUndo( cGlobals->game.server, NULL_XWE, 0 );
|
||||
} else if ( !params->skipGameOver && !!bGlobals->boardWin ) {
|
||||
/* This is modal. Don't show if quitting */
|
||||
cursesShowFinalScores( bGlobals );
|
||||
|
@ -1058,7 +1058,7 @@ static void
|
|||
curses_util_cellSquareHeld( XW_UtilCtxt* uc, XWStreamCtxt* words )
|
||||
{
|
||||
XP_USE( uc );
|
||||
catOnClose( words, NULL );
|
||||
catOnClose( words, NULL_XWE, NULL );
|
||||
fprintf( stderr, "\n" );
|
||||
}
|
||||
#endif
|
||||
|
@ -1183,7 +1183,7 @@ handleBackspace( void* closure, int XP_UNUSED(key) )
|
|||
{
|
||||
CommonGlobals* cGlobals = &((CursesBoardGlobals*)closure)->cGlobals;
|
||||
XP_Bool handled;
|
||||
if ( board_handleKey( cGlobals->game.board,
|
||||
if ( board_handleKey( cGlobals->game.board, NULL_XWE,
|
||||
XP_CURSOR_KEY_DEL, &handled ) ) {
|
||||
board_draw( cGlobals->game.board, NULL_XWE );
|
||||
}
|
||||
|
@ -1195,7 +1195,7 @@ handleUndo( void* closure, int XP_UNUSED(key) )
|
|||
{
|
||||
CursesBoardGlobals* bGlobals = (CursesBoardGlobals*)closure;
|
||||
CommonGlobals* cGlobals = &bGlobals->cGlobals;
|
||||
if ( server_handleUndo( cGlobals->game.server, 0 ) ) {
|
||||
if ( server_handleUndo( cGlobals->game.server, NULL_XWE, 0 ) ) {
|
||||
board_draw( cGlobals->game.board, NULL_XWE );
|
||||
}
|
||||
return XP_TRUE;
|
||||
|
@ -1284,7 +1284,8 @@ handleCommit( void* closure, int XP_UNUSED(key) )
|
|||
{
|
||||
CursesBoardGlobals* bGlobals = (CursesBoardGlobals*)closure;
|
||||
CommonGlobals* cGlobals = &bGlobals->cGlobals;
|
||||
if ( board_commitTurn( cGlobals->game.board, XP_FALSE, XP_FALSE, NULL ) ) {
|
||||
if ( board_commitTurn( cGlobals->game.board, NULL_XWE, XP_FALSE,
|
||||
XP_FALSE, NULL ) ) {
|
||||
board_draw( cGlobals->game.board, NULL_XWE );
|
||||
}
|
||||
return XP_TRUE;
|
||||
|
@ -1333,7 +1334,8 @@ handleFocusKey( CursesBoardGlobals* bGlobals, XP_Key key )
|
|||
checkAssignFocus( cGlobals->game.board );
|
||||
|
||||
XP_Bool handled;
|
||||
XP_Bool draw = board_handleKey( cGlobals->game.board, key, &handled );
|
||||
XP_Bool draw = board_handleKey( cGlobals->game.board, NULL_XWE,
|
||||
key, &handled );
|
||||
if ( !handled ) {
|
||||
BoardObjectType nxt;
|
||||
BoardObjectType order[] = { OBJ_BOARD, OBJ_SCORE, OBJ_TRAY };
|
||||
|
@ -1448,7 +1450,7 @@ handleSpace( void* closure, int XP_UNUSED(key) )
|
|||
BoardCtxt* board = bGlobals->cGlobals.game.board;
|
||||
checkAssignFocus( board );
|
||||
XP_Bool handled;
|
||||
(void)board_handleKey( board, XP_RAISEFOCUS_KEY, &handled );
|
||||
(void)board_handleKey( board, NULL_XWE, XP_RAISEFOCUS_KEY, &handled );
|
||||
board_draw( board, NULL_XWE );
|
||||
return XP_TRUE;
|
||||
} /* handleSpace */
|
||||
|
@ -1460,7 +1462,7 @@ handleRet( void* closure, int key )
|
|||
BoardCtxt* board = bGlobals->cGlobals.game.board;
|
||||
XP_Bool handled;
|
||||
XP_Key xpKey = (key & ALT_BIT) == 0 ? XP_RETURN_KEY : XP_ALTRETURN_KEY;
|
||||
if ( board_handleKey( board, xpKey, &handled ) ) {
|
||||
if ( board_handleKey( board, NULL_XWE, xpKey, &handled ) ) {
|
||||
board_draw( board, NULL_XWE );
|
||||
}
|
||||
return XP_TRUE;
|
||||
|
@ -1482,7 +1484,7 @@ handleShowVals( void* closure, int XP_UNUSED(key) )
|
|||
buf[len] = '\0';
|
||||
|
||||
(void)ca_inform( bGlobals->boardWin, buf );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
|
||||
return XP_TRUE;
|
||||
}
|
||||
|
@ -1491,7 +1493,7 @@ handleShowVals( void* closure, int XP_UNUSED(key) )
|
|||
#endif
|
||||
|
||||
static void
|
||||
relay_connd_curses( void* XP_UNUSED(closure), XP_UCHAR* const XP_UNUSED(room),
|
||||
relay_connd_curses( XWEnv XP_UNUSED(xwe), void* XP_UNUSED(closure), XP_UCHAR* const XP_UNUSED(room),
|
||||
XP_Bool XP_UNUSED(reconnect), XP_U16 XP_UNUSED(devOrder),
|
||||
XP_Bool XP_UNUSED_DBG(allHere),
|
||||
XP_U16 XP_UNUSED_DBG(nMissing) )
|
||||
|
@ -1501,7 +1503,8 @@ relay_connd_curses( void* XP_UNUSED(closure), XP_UCHAR* const XP_UNUSED(room),
|
|||
}
|
||||
|
||||
static void
|
||||
relay_error_curses( void* XP_UNUSED(closure), XWREASON XP_UNUSED_DBG(relayErr) )
|
||||
relay_error_curses( XWEnv XP_UNUSED(xwe), void* XP_UNUSED(closure),
|
||||
XWREASON XP_UNUSED_DBG(relayErr) )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
XP_LOGF( "%s(%s)", __func__, XWREASON2Str( relayErr ) );
|
||||
|
@ -1509,7 +1512,7 @@ relay_error_curses( void* XP_UNUSED(closure), XWREASON XP_UNUSED_DBG(relayErr) )
|
|||
}
|
||||
|
||||
static XP_Bool
|
||||
relay_sendNoConn_curses( const XP_U8* msg, XP_U16 len,
|
||||
relay_sendNoConn_curses( XWEnv XP_UNUSED(xwe), const XP_U8* msg, XP_U16 len,
|
||||
const XP_UCHAR* XP_UNUSED(msgNo),
|
||||
const XP_UCHAR* relayID, void* closure )
|
||||
{
|
||||
|
@ -1540,21 +1543,23 @@ relay_requestJoin_curses( void* closure, const XP_UCHAR* devID, const XP_UCHAR*
|
|||
#endif
|
||||
|
||||
static void
|
||||
curses_countChanged( void* XP_UNUSED(closure), XP_U16 XP_UNUSED_DBG(newCount) )
|
||||
curses_countChanged( XWEnv XP_UNUSED(xwe), void* XP_UNUSED(closure),
|
||||
XP_U16 XP_UNUSED_DBG(newCount) )
|
||||
{
|
||||
XP_LOGF( "%s(newCount=%d)", __func__, newCount );
|
||||
}
|
||||
|
||||
#ifdef COMMS_XPORT_FLAGSPROC
|
||||
static XP_U32
|
||||
curses_getFlags( void* XP_UNUSED(closure) )
|
||||
curses_getFlags( XWEnv XP_UNUSED(xwe), void* XP_UNUSED(closure) )
|
||||
{
|
||||
return COMMS_XPORT_FLAGS_HASNOCONN;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
relay_status_curses( void* XP_UNUSED(closure), CommsRelayState XP_UNUSED_DBG(state) )
|
||||
relay_status_curses( XWEnv XP_UNUSED(xwe), void* XP_UNUSED(closure),
|
||||
CommsRelayState XP_UNUSED_DBG(state) )
|
||||
{
|
||||
/* CommonGlobals* cGlobals = (CommonGlobals*)closure; */
|
||||
// bGlobals->commsRelayState = state;
|
||||
|
|
|
@ -261,7 +261,7 @@ writeNewGameToDB( XWStreamCtxt* stream, sqlite3* pDb )
|
|||
}
|
||||
|
||||
void
|
||||
writeToDB( XWStreamCtxt* stream, void* closure )
|
||||
writeToDB( XWStreamCtxt* stream, XWEnv XP_UNUSED(xwe), void* closure )
|
||||
{
|
||||
CommonGlobals* cGlobals = (CommonGlobals*)closure;
|
||||
sqlite3_int64 selRow = cGlobals->rowid;
|
||||
|
@ -298,7 +298,7 @@ addSnapshot( CommonGlobals* cGlobals )
|
|||
removeSurface( dctx );
|
||||
cGlobals->rowid = writeBlobColumnStream( stream, cGlobals->params->pDb,
|
||||
cGlobals->rowid, "snap" );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
}
|
||||
|
||||
LOG_RETURN_VOID();
|
||||
|
|
|
@ -55,7 +55,7 @@ typedef struct _GameInfo {
|
|||
sqlite3* openGamesDB( const char* dbName );
|
||||
void closeGamesDB( sqlite3* pDb );
|
||||
|
||||
void writeToDB( XWStreamCtxt* stream, void* closure );
|
||||
void writeToDB( XWStreamCtxt* stream, XWEnv xwe, void* closure );
|
||||
sqlite3_int64 writeNewGameToDB( XWStreamCtxt* stream, sqlite3* pDb );
|
||||
|
||||
void summarize( CommonGlobals* cGlobals );
|
||||
|
|
|
@ -184,8 +184,7 @@ button_release_event( GtkWidget* XP_UNUSED(widget), GdkEventMotion *event,
|
|||
|
||||
if ( globals->mouseDown ) {
|
||||
redraw = board_handlePenUp( globals->cGlobals.game.board,
|
||||
event->x,
|
||||
event->y );
|
||||
NULL_XWE, event->x, event->y );
|
||||
if ( redraw ) {
|
||||
board_draw( globals->cGlobals.game.board, NULL_XWE );
|
||||
disenable_buttons( globals );
|
||||
|
@ -262,10 +261,10 @@ key_press_event( GtkWidget* XP_UNUSED(widget), GdkEventKey* event,
|
|||
|
||||
if ( xpkey != XP_KEY_NONE ) {
|
||||
XP_Bool draw = globals->keyDown ?
|
||||
board_handleKeyRepeat( globals->cGlobals.game.board, xpkey,
|
||||
&handled )
|
||||
: board_handleKeyDown( globals->cGlobals.game.board, xpkey,
|
||||
&handled );
|
||||
board_handleKeyRepeat( globals->cGlobals.game.board, NULL_XWE,
|
||||
xpkey, &handled )
|
||||
: board_handleKeyDown( globals->cGlobals.game.board,
|
||||
xpkey, &handled );
|
||||
if ( draw ) {
|
||||
board_draw( globals->cGlobals.game.board, NULL_XWE );
|
||||
}
|
||||
|
@ -287,8 +286,8 @@ key_release_event( GtkWidget* XP_UNUSED(widget), GdkEventKey* event,
|
|||
|
||||
if ( xpkey != XP_KEY_NONE ) {
|
||||
XP_Bool draw;
|
||||
draw = board_handleKeyUp( globals->cGlobals.game.board, xpkey,
|
||||
&handled );
|
||||
draw = board_handleKeyUp( globals->cGlobals.game.board, NULL_XWE,
|
||||
xpkey, &handled );
|
||||
#ifdef KEYBOARD_NAV
|
||||
if ( movesCursor && !handled ) {
|
||||
BoardObjectType order[] = { OBJ_SCORE, OBJ_BOARD, OBJ_TRAY };
|
||||
|
@ -318,7 +317,7 @@ key_release_event( GtkWidget* XP_UNUSED(widget), GdkEventKey* event,
|
|||
#endif
|
||||
|
||||
static void
|
||||
relay_status_gtk( void* closure, CommsRelayState state )
|
||||
relay_status_gtk( XWEnv XP_UNUSED(xwe), void* closure, CommsRelayState state )
|
||||
{
|
||||
XP_LOGF( "%s got status: %s", __func__, CommsRelayState2Str(state) );
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)closure;
|
||||
|
@ -331,7 +330,7 @@ relay_status_gtk( void* closure, CommsRelayState state )
|
|||
}
|
||||
|
||||
static void
|
||||
relay_connd_gtk( void* closure, XP_UCHAR* const room,
|
||||
relay_connd_gtk( XWEnv XP_UNUSED(xwe), void* closure, XP_UCHAR* const room,
|
||||
XP_Bool XP_UNUSED(reconnect), XP_U16 devOrder,
|
||||
XP_Bool allHere, XP_U16 nMissing )
|
||||
{
|
||||
|
@ -380,7 +379,7 @@ invoke_new_game_conns( gpointer data )
|
|||
}
|
||||
|
||||
static void
|
||||
relay_error_gtk( void* closure, XWREASON relayErr )
|
||||
relay_error_gtk( XWEnv XP_UNUSED(xwe), void* closure, XWREASON relayErr )
|
||||
{
|
||||
LOG_FUNC();
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)closure;
|
||||
|
@ -413,7 +412,7 @@ relay_error_gtk( void* closure, XWREASON relayErr )
|
|||
}
|
||||
|
||||
static XP_Bool
|
||||
relay_sendNoConn_gtk( const XP_U8* msg, XP_U16 len,
|
||||
relay_sendNoConn_gtk( XWEnv XP_UNUSED(xwe), const XP_U8* msg, XP_U16 len,
|
||||
const XP_UCHAR* XP_UNUSED(msgNo),
|
||||
const XP_UCHAR* relayID, void* closure )
|
||||
{
|
||||
|
@ -460,7 +459,7 @@ relay_requestJoin_gtk( void* closure, const XP_UCHAR* devID, const XP_UCHAR* roo
|
|||
|
||||
#ifdef COMMS_XPORT_FLAGSPROC
|
||||
static XP_U32
|
||||
gtk_getFlags( void* closure )
|
||||
gtk_getFlags( XWEnv XP_UNUSED(xwe), void* closure )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)closure;
|
||||
# ifdef RELAY_VIA_HTTP
|
||||
|
@ -474,7 +473,7 @@ gtk_getFlags( void* closure )
|
|||
#endif
|
||||
|
||||
static void
|
||||
countChanged_gtk( void* closure, XP_U16 newCount )
|
||||
countChanged_gtk( XWEnv XP_UNUSED(xwe), void* closure, XP_U16 newCount )
|
||||
{
|
||||
GtkGameGlobals* globals = (GtkGameGlobals*)closure;
|
||||
gchar buf[128];
|
||||
|
@ -643,7 +642,7 @@ destroy_board_window( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
{
|
||||
LOG_FUNC();
|
||||
if ( !!globals->cGlobals.game.comms ) {
|
||||
comms_stop( globals->cGlobals.game.comms );
|
||||
comms_stop( globals->cGlobals.game.comms, NULL_XWE );
|
||||
}
|
||||
linuxSaveGame( &globals->cGlobals );
|
||||
windowDestroyed( globals );
|
||||
|
@ -666,7 +665,7 @@ on_board_window_shown( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
if ( loadInviteAddrs( stream, cGlobals->params->pDb, cGlobals->rowid ) ) {
|
||||
CommsAddrRec addr = {0};
|
||||
addrFromStream( &addr, stream );
|
||||
comms_augmentHostAddr( cGlobals->game.comms, &addr );
|
||||
comms_augmentHostAddr( cGlobals->game.comms, NULL_XWE, &addr );
|
||||
|
||||
XP_U16 nRecs = stream_getU8( stream );
|
||||
XP_LOGF( "%s: got invite info: %d records", __func__, nRecs );
|
||||
|
@ -681,7 +680,7 @@ on_board_window_shown( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
send_invites( cGlobals, 1, 0, relayID, NULL );
|
||||
}
|
||||
}
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
}
|
||||
} /* on_board_window_shown */
|
||||
|
||||
|
@ -746,7 +745,7 @@ tile_values_impl( GtkGameGlobals* globals, bool full )
|
|||
catOnClose );
|
||||
server_formatDictCounts( cGlobals->game.server, stream, 5, full );
|
||||
stream_putU8( stream, '\n' );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
}
|
||||
|
||||
} /* tile_values */
|
||||
|
@ -781,7 +780,7 @@ dump_board( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
CHANNEL_NONE,
|
||||
catOnClose );
|
||||
model_writeToTextStream( globals->cGlobals.game.model, stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -797,7 +796,7 @@ final_scores( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
"Are you sure you want to resign?",
|
||||
GTK_BUTTONS_YES_NO, NULL ) ) {
|
||||
globals->cGlobals.manualFinal = XP_TRUE;
|
||||
server_endGame( globals->cGlobals.game.server );
|
||||
server_endGame( globals->cGlobals.game.server, NULL_XWE );
|
||||
gameOver = TRUE;
|
||||
}
|
||||
|
||||
|
@ -831,12 +830,12 @@ new_game_impl( GtkGameGlobals* globals, XP_Bool fireConnDlg )
|
|||
#endif
|
||||
};
|
||||
|
||||
(void)game_reset( MEMPOOL &cGlobals->game, gi, cGlobals->util,
|
||||
(void)game_reset( MEMPOOL &cGlobals->game, NULL_XWE, gi, cGlobals->util,
|
||||
&cGlobals->cp, &procs );
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
if ( !!cGlobals->game.comms ) {
|
||||
comms_augmentHostAddr( cGlobals->game.comms, &addr );
|
||||
comms_augmentHostAddr( cGlobals->game.comms, NULL_XWE, &addr );
|
||||
} else if ( gi->serverRole != SERVER_STANDALONE ) {
|
||||
XP_ASSERT(0);
|
||||
}
|
||||
|
@ -845,7 +844,7 @@ new_game_impl( GtkGameGlobals* globals, XP_Bool fireConnDlg )
|
|||
tryConnectToServer( cGlobals );
|
||||
}
|
||||
#endif
|
||||
(void)server_do( cGlobals->game.server ); /* assign tiles, etc. */
|
||||
(void)server_do( cGlobals->game.server, NULL_XWE ); /* assign tiles, etc. */
|
||||
board_invalAll( cGlobals->game.board );
|
||||
board_draw( cGlobals->game.board, NULL_XWE );
|
||||
}
|
||||
|
@ -868,7 +867,7 @@ game_info( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
server_do in case one's become a robot. */
|
||||
CurGameInfo* gi = globals->cGlobals.gi;
|
||||
if ( gtkNewGameDialog( globals, gi, &addr, XP_FALSE, XP_FALSE ) ) {
|
||||
if ( server_do( globals->cGlobals.game.server ) ) {
|
||||
if ( server_do( globals->cGlobals.game.server, NULL_XWE ) ) {
|
||||
board_draw( globals->cGlobals.game.board, NULL_XWE );
|
||||
}
|
||||
}
|
||||
|
@ -952,7 +951,7 @@ handle_resend( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
{
|
||||
CommsCtxt* comms = globals->cGlobals.game.comms;
|
||||
if ( comms != NULL ) {
|
||||
comms_resendAll( comms, COMMS_CONN_NONE, XP_TRUE );
|
||||
comms_resendAll( comms, NULL_XWE, COMMS_CONN_NONE, XP_TRUE );
|
||||
}
|
||||
} /* handle_resend */
|
||||
|
||||
|
@ -962,7 +961,7 @@ handle_ack( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
{
|
||||
CommsCtxt* comms = globals->cGlobals.game.comms;
|
||||
if ( comms != NULL ) {
|
||||
comms_ackAny( comms );
|
||||
comms_ackAny( comms, NULL_XWE );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -980,7 +979,7 @@ handle_commstats( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
globals,
|
||||
CHANNEL_NONE, catOnClose );
|
||||
comms_getStats( comms, stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
}
|
||||
} /* handle_commstats */
|
||||
#endif
|
||||
|
@ -995,7 +994,7 @@ handle_memstats( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
globals,
|
||||
CHANNEL_NONE, catOnClose );
|
||||
mpool_stats( MEMPOOL stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
|
||||
} /* handle_memstats */
|
||||
|
||||
|
@ -1241,7 +1240,7 @@ handle_juggle_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
static void
|
||||
handle_undo_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
||||
{
|
||||
if ( server_handleUndo( globals->cGlobals.game.server, 0 ) ) {
|
||||
if ( server_handleUndo( globals->cGlobals.game.server, NULL_XWE, 0 ) ) {
|
||||
board_draw( globals->cGlobals.game.board, NULL_XWE );
|
||||
}
|
||||
} /* handle_undo_button */
|
||||
|
@ -1274,7 +1273,7 @@ handle_trade_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
static void
|
||||
handle_done_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
||||
{
|
||||
if ( board_commitTurn( globals->cGlobals.game.board, XP_FALSE,
|
||||
if ( board_commitTurn( globals->cGlobals.game.board, NULL_XWE, XP_FALSE,
|
||||
XP_FALSE, NULL ) ) {
|
||||
board_draw( globals->cGlobals.game.board, NULL_XWE );
|
||||
disenable_buttons( globals );
|
||||
|
@ -1314,7 +1313,7 @@ handle_chat_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
{
|
||||
gchar* msg = gtkGetChatMessage( globals );
|
||||
if ( NULL != msg ) {
|
||||
board_sendChat( globals->cGlobals.game.board, msg );
|
||||
board_sendChat( globals->cGlobals.game.board, NULL_XWE, msg );
|
||||
g_free( msg );
|
||||
}
|
||||
}
|
||||
|
@ -1323,14 +1322,14 @@ handle_chat_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
static void
|
||||
handle_pause_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
||||
{
|
||||
board_pause( globals->cGlobals.game.board, "whatever" );
|
||||
board_pause( globals->cGlobals.game.board, NULL_XWE, "whatever" );
|
||||
disenable_buttons( globals );
|
||||
}
|
||||
|
||||
static void
|
||||
handle_unpause_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
||||
{
|
||||
board_unpause( globals->cGlobals.game.board, "whatever" );
|
||||
board_unpause( globals->cGlobals.game.board, NULL_XWE, "whatever" );
|
||||
disenable_buttons( globals );
|
||||
}
|
||||
|
||||
|
@ -1387,8 +1386,8 @@ handle_hide_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
static void
|
||||
handle_commit_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
||||
{
|
||||
if ( board_commitTurn( globals->cGlobals.game.board, XP_FALSE,
|
||||
XP_FALSE, NULL ) ) {
|
||||
if ( board_commitTurn( globals->cGlobals.game.board, NULL_XWE,
|
||||
XP_FALSE, XP_FALSE, NULL ) ) {
|
||||
board_draw( globals->cGlobals.game.board, NULL_XWE );
|
||||
}
|
||||
} /* handle_commit_button */
|
||||
|
@ -1439,7 +1438,7 @@ send_invites( CommonGlobals* cGlobals, XP_U16 nPlayers,
|
|||
nli_saveToStream( &nli, stream );
|
||||
NetLaunchInfo tmp;
|
||||
nli_makeFromStream( &tmp, stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
XP_ASSERT( 0 == memcmp( &nli, &tmp, sizeof(nli) ) );
|
||||
}
|
||||
#endif
|
||||
|
@ -1591,8 +1590,8 @@ ask_tiles( gpointer data )
|
|||
server_tilesPicked( cGlobals->game.server, cGlobals->selPlayer,
|
||||
&newTiles );
|
||||
} else {
|
||||
draw = board_commitTurn( cGlobals->game.board, XP_TRUE, XP_TRUE,
|
||||
&newTiles );
|
||||
draw = board_commitTurn( cGlobals->game.board, NULL_XWE,
|
||||
XP_TRUE, XP_TRUE, &newTiles );
|
||||
}
|
||||
|
||||
if ( draw ) {
|
||||
|
@ -1720,7 +1719,7 @@ gtkShowFinalScores( const GtkGameGlobals* globals, XP_Bool ignoreTimeout )
|
|||
server_writeFinalScores( cGlobals->game.server, stream );
|
||||
|
||||
text = strFromStream( stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
|
||||
XP_U16 timeout = (ignoreTimeout || cGlobals->manualFinal)
|
||||
? 0 : cGlobals->params->askTimeout;
|
||||
|
@ -1780,7 +1779,7 @@ gtk_util_notifyGameOver( XW_UtilCtxt* uc, XP_S16 quitter )
|
|||
sleep( cGlobals->params->quitAfter );
|
||||
destroy_board_window( NULL, globals );
|
||||
} else if ( cGlobals->params->undoWhenDone ) {
|
||||
server_handleUndo( cGlobals->game.server, 0 );
|
||||
server_handleUndo( cGlobals->game.server, NULL_XWE, 0 );
|
||||
board_draw( cGlobals->game.board, NULL_XWE );
|
||||
} else if ( !cGlobals->params->skipGameOver ) {
|
||||
gtkShowFinalScores( globals, XP_TRUE );
|
||||
|
@ -1866,7 +1865,7 @@ ask_bad_words( gpointer data )
|
|||
|
||||
if ( GTK_RESPONSE_YES == gtkask( globals->window, cGlobals->question,
|
||||
GTK_BUTTONS_YES_NO, NULL ) ) {
|
||||
board_commitTurn( cGlobals->game.board, XP_TRUE, XP_FALSE, NULL );
|
||||
board_commitTurn( cGlobals->game.board, NULL_XWE, XP_TRUE, XP_FALSE, NULL );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1912,7 +1911,7 @@ gtk_util_remSelected( XW_UtilCtxt* uc )
|
|||
globals->cGlobals.params->vtMgr );
|
||||
board_formatRemainingTiles( globals->cGlobals.game.board, stream );
|
||||
text = strFromStream( stream );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
|
||||
(void)gtkask( globals->window, text, GTK_BUTTONS_OK, NULL );
|
||||
free( text );
|
||||
|
@ -2048,7 +2047,7 @@ ask_move( gpointer data )
|
|||
gint chosen = gtkask( globals->window, cGlobals->question, buttons, NULL );
|
||||
if ( GTK_RESPONSE_OK == chosen || chosen == GTK_RESPONSE_YES ) {
|
||||
BoardCtxt* board = cGlobals->game.board;
|
||||
if ( board_commitTurn( board, XP_TRUE, XP_TRUE, NULL ) ) {
|
||||
if ( board_commitTurn( board, NULL_XWE, XP_TRUE, XP_TRUE, NULL ) ) {
|
||||
board_draw( board, NULL_XWE );
|
||||
}
|
||||
}
|
||||
|
@ -2079,7 +2078,7 @@ ask_trade( gpointer data )
|
|||
cGlobals->question,
|
||||
GTK_BUTTONS_YES_NO, NULL ) ) {
|
||||
BoardCtxt* board = cGlobals->game.board;
|
||||
if ( board_commitTurn( board, XP_TRUE, XP_TRUE, NULL ) ) {
|
||||
if ( board_commitTurn( board, NULL_XWE, XP_TRUE, XP_TRUE, NULL ) ) {
|
||||
board_draw( board, NULL_XWE );
|
||||
}
|
||||
}
|
||||
|
@ -2620,7 +2619,7 @@ loadGameNoDraw( GtkGameGlobals* globals, LaunchParams* params,
|
|||
XP_LOGF( "%s: game loaded", __func__ );
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
if ( !!globals->cGlobals.game.comms ) {
|
||||
comms_resendAll( globals->cGlobals.game.comms, COMMS_CONN_NONE,
|
||||
comms_resendAll( globals->cGlobals.game.comms, NULL_XWE, COMMS_CONN_NONE,
|
||||
XP_FALSE );
|
||||
}
|
||||
#endif
|
||||
|
@ -2628,7 +2627,7 @@ loadGameNoDraw( GtkGameGlobals* globals, LaunchParams* params,
|
|||
game_dispose( &cGlobals->game, NULL_XWE );
|
||||
}
|
||||
}
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
return loaded;
|
||||
}
|
||||
|
||||
|
|
|
@ -348,7 +348,7 @@ make_rematch( GtkAppGlobals* apg, const CommonGlobals* cGlobals )
|
|||
cGlobals->util, &cGlobals->cp, stream );
|
||||
|
||||
sqlite3_int64 rowID = writeNewGameToDB( stream, params->pDb );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
gi_disposePlayerInfo( MPPARM(cGlobals->util->mpool) &gi );
|
||||
|
||||
/* If it's a multi-device game, save enough information with it than when
|
||||
|
@ -362,7 +362,7 @@ make_rematch( GtkAppGlobals* apg, const CommonGlobals* cGlobals )
|
|||
|
||||
CommsAddrRec addrs[4];
|
||||
XP_U16 nRecs = VSIZE(addrs);
|
||||
comms_getAddrs( comms, addrs, &nRecs );
|
||||
comms_getAddrs( comms, NULL_XWE, addrs, &nRecs );
|
||||
|
||||
stream_putU8( stream, nRecs );
|
||||
for ( int ii = 0; ii < nRecs; ++ii ) {
|
||||
|
@ -378,7 +378,7 @@ make_rematch( GtkAppGlobals* apg, const CommonGlobals* cGlobals )
|
|||
addrToStream( stream, &addrs[ii] );
|
||||
}
|
||||
saveInviteAddrs( stream, params->pDb, rowID );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
}
|
||||
|
||||
open_row( apg, rowID, XP_TRUE );
|
||||
|
|
|
@ -135,7 +135,7 @@ tryConnectToServer( CommonGlobals* cGlobals )
|
|||
mem_stream_make( MPPARM(cGlobals->util->mpool) params->vtMgr,
|
||||
cGlobals, CHANNEL_NONE,
|
||||
sendOnClose );
|
||||
(void)server_initClientConnection( cGlobals->game.server,
|
||||
(void)server_initClientConnection( cGlobals->game.server, NULL_XWE,
|
||||
stream );
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ linuxOpenGame( CommonGlobals* cGlobals, const TransportProcs* procs,
|
|||
stream = mem_stream_make_raw( MPPARM(cGlobals->util->mpool)
|
||||
params->vtMgr );
|
||||
if ( !loadGame( stream, params->pDb, cGlobals->rowid ) ) {
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE);
|
||||
stream = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ linuxOpenGame( CommonGlobals* cGlobals, const TransportProcs* procs,
|
|||
cGlobals->draw,
|
||||
&cGlobals->cp, procs );
|
||||
XP_LOGF( "%s: loaded gi at %p", __func__, &cGlobals->gi );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
}
|
||||
|
||||
if ( !opened /* && canMakeFromGI( cGlobals->gi )*/ ) {
|
||||
|
@ -313,14 +313,14 @@ linuxOpenGame( CommonGlobals* cGlobals, const TransportProcs* procs,
|
|||
1 + XP_STRLEN(params->connInfo.relay.invite) );
|
||||
addr.u.ip_relay.seeksPublicRoom = params->connInfo.relay.seeksPublicRoom;
|
||||
addr.u.ip_relay.advertiseRoom = params->connInfo.relay.advertiseRoom;
|
||||
comms_augmentHostAddr( cGlobals->game.comms, &addr ); /* sends stuff */
|
||||
comms_augmentHostAddr( cGlobals->game.comms, NULL_XWE, &addr ); /* sends stuff */
|
||||
}
|
||||
|
||||
if ( !!returnAddrP ) {
|
||||
/* This may trigger network activity */
|
||||
CommsCtxt* comms = cGlobals->game.comms;
|
||||
if ( !!comms ) {
|
||||
comms_augmentHostAddr( cGlobals->game.comms, &returnAddr );
|
||||
comms_augmentHostAddr( cGlobals->game.comms, NULL_XWE, &returnAddr );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -346,10 +346,10 @@ linuxOpenGame( CommonGlobals* cGlobals, const TransportProcs* procs,
|
|||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
if ( !!cGlobals->game.comms ) {
|
||||
comms_start( cGlobals->game.comms );
|
||||
comms_start( cGlobals->game.comms, NULL_XWE );
|
||||
}
|
||||
#endif
|
||||
server_do( cGlobals->game.server );
|
||||
server_do( cGlobals->game.server, NULL_XWE );
|
||||
linuxSaveGame( cGlobals ); /* again, to include address etc. */
|
||||
}
|
||||
return opened;
|
||||
|
@ -426,7 +426,7 @@ gameGotBuf( CommonGlobals* cGlobals, XP_Bool hasDraw, const XP_U8* buf,
|
|||
if ( redraw ) {
|
||||
linuxSaveGame( cGlobals );
|
||||
}
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
|
||||
/* if there's something to draw resulting from the message, we
|
||||
need to give the main loop time to reflect that on the screen
|
||||
|
@ -436,7 +436,7 @@ gameGotBuf( CommonGlobals* cGlobals, XP_Bool hasDraw, const XP_U8* buf,
|
|||
util_requestTime( cGlobals->util );
|
||||
} else {
|
||||
for ( int ii = 0; ii < 4; ++ii ) {
|
||||
redraw = server_do( game->server ) || redraw;
|
||||
redraw = server_do( game->server, NULL_XWE ) || redraw;
|
||||
}
|
||||
}
|
||||
if ( hasDraw && redraw ) {
|
||||
|
@ -460,7 +460,7 @@ requestMsgsIdle( gpointer data )
|
|||
}
|
||||
|
||||
void
|
||||
writeToFile( XWStreamCtxt* stream, void* closure )
|
||||
writeToFile( XWStreamCtxt* stream, XWEnv XP_UNUSED(xwe), void* closure )
|
||||
{
|
||||
void* buf;
|
||||
int fd;
|
||||
|
@ -492,7 +492,8 @@ writeToFile( XWStreamCtxt* stream, void* closure )
|
|||
} /* writeToFile */
|
||||
|
||||
void
|
||||
catOnClose( XWStreamCtxt* stream, void* XP_UNUSED(closure) )
|
||||
catOnClose( XWStreamCtxt* stream, XWEnv XP_UNUSED(xwe),
|
||||
void* XP_UNUSED(closure) )
|
||||
{
|
||||
XP_U16 nBytes;
|
||||
char* buffer;
|
||||
|
@ -508,11 +509,11 @@ catOnClose( XWStreamCtxt* stream, void* XP_UNUSED(closure) )
|
|||
} /* catOnClose */
|
||||
|
||||
void
|
||||
sendOnClose( XWStreamCtxt* stream, void* closure )
|
||||
sendOnClose( XWStreamCtxt* stream, XWEnv XP_UNUSED(xwe), void* closure )
|
||||
{
|
||||
CommonGlobals* cGlobals = (CommonGlobals*)closure;
|
||||
XP_LOGF( "%s called with msg of len %d", __func__, stream_getSize(stream) );
|
||||
(void)comms_send( cGlobals->game.comms, stream );
|
||||
(void)comms_send( cGlobals->game.comms, NULL_XWE, stream );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -527,7 +528,7 @@ catGameHistory( CommonGlobals* cGlobals )
|
|||
model_writeGameHistory( cGlobals->game.model, NULL_XWE, stream,
|
||||
cGlobals->game.server, gameOver );
|
||||
stream_putU8( stream, '\n' );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
}
|
||||
} /* catGameHistory */
|
||||
|
||||
|
@ -548,7 +549,7 @@ catFinalScores( const CommonGlobals* cGlobals, XP_S16 quitter )
|
|||
}
|
||||
server_writeFinalScores( cGlobals->game.server, stream );
|
||||
stream_putU8( stream, '\n' );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
} /* printFinalScores */
|
||||
|
||||
XP_UCHAR*
|
||||
|
@ -592,12 +593,12 @@ linuxSaveGame( CommonGlobals* cGlobals )
|
|||
cGlobals, 0, onClose );
|
||||
stream_open( outStream );
|
||||
|
||||
game_saveToStream( &cGlobals->game, cGlobals->gi,
|
||||
game_saveToStream( &cGlobals->game, NULL_XWE, cGlobals->gi,
|
||||
outStream, ++cGlobals->curSaveToken );
|
||||
cGlobals->lastStreamSize = stream_getSize( outStream );
|
||||
stream_destroy( outStream );
|
||||
stream_destroy( outStream, NULL_XWE );
|
||||
|
||||
game_saveSucceeded( &cGlobals->game, cGlobals->curSaveToken );
|
||||
game_saveSucceeded( &cGlobals->game, NULL_XWE, cGlobals->curSaveToken );
|
||||
XP_LOGF( "%s: saved", __func__ );
|
||||
|
||||
} else {
|
||||
|
@ -624,7 +625,7 @@ handle_messages_from( CommonGlobals* cGlobals, const TransportProcs* procs,
|
|||
NULL /*draw*/,
|
||||
&cGlobals->cp, procs );
|
||||
XP_ASSERT( opened );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
|
||||
unsigned short len;
|
||||
for ( ; ; ) {
|
||||
|
@ -648,7 +649,7 @@ handle_messages_from( CommonGlobals* cGlobals, const TransportProcs* procs,
|
|||
params->vtMgr );
|
||||
stream_putBytes( stream, buf, len );
|
||||
(void)game_receiveMessage( &cGlobals->game, NULL_XWE, stream, NULL );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
}
|
||||
|
||||
LOG_RETURN_VOID();
|
||||
|
@ -671,7 +672,7 @@ read_pipe_then_close( CommonGlobals* cGlobals, const TransportProcs* procs )
|
|||
NULL /*draw*/,
|
||||
&cGlobals->cp, procs );
|
||||
XP_ASSERT( opened );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
|
||||
int fd = open( params->pipe, O_RDWR );
|
||||
XP_ASSERT( fd >= 0 );
|
||||
|
@ -698,7 +699,7 @@ read_pipe_then_close( CommonGlobals* cGlobals, const TransportProcs* procs )
|
|||
params->vtMgr );
|
||||
stream_putBytes( stream, buf, len );
|
||||
(void)game_receiveMessage( &cGlobals->game, NULL_XWE, stream, NULL );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
}
|
||||
|
||||
/* 0-length packet closes it off */
|
||||
|
@ -772,7 +773,7 @@ secondTimerFired( gpointer data )
|
|||
if ( 0 != undoRatio ) {
|
||||
if ( (XP_RANDOM() % 1000) < undoRatio ) {
|
||||
XP_LOGFF( "calling server_handleUndo()" );
|
||||
if ( server_handleUndo( game->server, 1 ) ) {
|
||||
if ( server_handleUndo( game->server, NULL_XWE, 1 ) ) {
|
||||
board_draw( game->board, NULL_XWE );
|
||||
}
|
||||
}
|
||||
|
@ -1433,7 +1434,7 @@ linux_relay_ioproc( GIOChannel* source, GIOCondition condition, gpointer data )
|
|||
addr_addType( &addr, COMMS_CONN_RELAY );
|
||||
redraw = game_receiveMessage( &cGlobals->game, NULL_XWE, inboundS, &addr );
|
||||
|
||||
stream_destroy( inboundS );
|
||||
stream_destroy( inboundS, NULL_XWE );
|
||||
}
|
||||
|
||||
/* if there's something to draw resulting from the
|
||||
|
@ -1500,7 +1501,7 @@ linux_tcp_reset( CommonGlobals* globals )
|
|||
# endif
|
||||
|
||||
void
|
||||
linux_reset( void* closure )
|
||||
linux_reset( XWEnv xwe, void* closure )
|
||||
{
|
||||
CommonGlobals* globals = (CommonGlobals*)closure;
|
||||
CommsConnType conType = globals->params->conType;
|
||||
|
@ -1523,9 +1524,9 @@ linux_reset( void* closure )
|
|||
#endif
|
||||
|
||||
XP_S16
|
||||
linux_send( const XP_U8* buf, XP_U16 buflen, const XP_UCHAR* msgNo,
|
||||
const CommsAddrRec* addrRec, CommsConnType conType, XP_U32 gameID,
|
||||
void* closure )
|
||||
linux_send( XWEnv XP_UNUSED(xwe), const XP_U8* buf, XP_U16 buflen,
|
||||
const XP_UCHAR* msgNo, const CommsAddrRec* addrRec, CommsConnType conType,
|
||||
XP_U32 gameID, void* closure )
|
||||
{
|
||||
XP_LOGF( "%s(mid=%s)", __func__, msgNo );
|
||||
XP_S16 nSent = -1;
|
||||
|
@ -1644,7 +1645,7 @@ linux_relay_receive( CommonGlobals* cGlobals, int sock, unsigned char* buf, int
|
|||
if ( nRead != 2 ) {
|
||||
linux_close_socket( cGlobals );
|
||||
|
||||
comms_transportFailed( cGlobals->game.comms, COMMS_CONN_RELAY );
|
||||
comms_transportFailed( cGlobals->game.comms, NULL_XWE, COMMS_CONN_RELAY );
|
||||
nRead = -1;
|
||||
} else {
|
||||
unsigned short packetSize = ntohs( tmp );
|
||||
|
@ -1697,7 +1698,7 @@ linux_relay_receive( CommonGlobals* cGlobals, int sock, unsigned char* buf, int
|
|||
|
||||
if ( -1 == nRead ) {
|
||||
linux_close_socket( cGlobals );
|
||||
comms_transportFailed( cGlobals->game.comms, COMMS_CONN_RELAY );
|
||||
comms_transportFailed( cGlobals->game.comms, NULL_XWE, COMMS_CONN_RELAY );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1822,14 +1823,14 @@ changeRolesIdle( gpointer data )
|
|||
{
|
||||
CommonGlobals* cGlobals = (CommonGlobals*)data;
|
||||
ServerCtxt* server = cGlobals->game.server;
|
||||
server_reset( server, cGlobals->game.comms );
|
||||
server_reset( server, NULL_XWE, cGlobals->game.comms );
|
||||
if ( SERVER_ISCLIENT == cGlobals->gi->serverRole ) {
|
||||
XWStreamCtxt* stream =
|
||||
mem_stream_make( MPPARM(cGlobals->util->mpool) cGlobals->params->vtMgr,
|
||||
cGlobals, CHANNEL_NONE, sendOnClose );
|
||||
(void)server_initClientConnection( server, stream );
|
||||
(void)server_initClientConnection( server, NULL_XWE, stream );
|
||||
}
|
||||
(void)server_do( server );
|
||||
(void)server_do( server, NULL_XWE );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2377,7 +2378,7 @@ idle_func( gpointer data )
|
|||
cGlobals->idleID = 0; /* 0 is illegal event source ID */
|
||||
|
||||
ServerCtxt* server = cGlobals->game.server;
|
||||
if ( !!server && server_do( server ) ) {
|
||||
if ( !!server && server_do( server, NULL_XWE ) ) {
|
||||
if ( !!cGlobals->game.board ) {
|
||||
board_draw( cGlobals->game.board, NULL_XWE );
|
||||
}
|
||||
|
|
|
@ -38,9 +38,9 @@ typedef struct LinuxBMStruct {
|
|||
} LinuxBMStruct;
|
||||
|
||||
int initListenerSocket( int port );
|
||||
XP_S16 linux_send( const XP_U8* buf, XP_U16 buflen, const XP_UCHAR* msgNo,
|
||||
const CommsAddrRec* addrRec, CommsConnType conType,
|
||||
XP_U32 gameID, void* closure );
|
||||
XP_S16 linux_send( XWEnv xwe, const XP_U8* buf, XP_U16 buflen,
|
||||
const XP_UCHAR* msgNo, const CommsAddrRec* addrRec,
|
||||
CommsConnType conType, XP_U32 gameID, void* closure );
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
# define LINUX_SEND linux_send
|
||||
#else
|
||||
|
@ -61,14 +61,14 @@ XWStreamCtxt* stream_from_msgbuf( CommonGlobals* cGlobals,
|
|||
XP_UCHAR* strFromStream( XWStreamCtxt* stream );
|
||||
|
||||
void catGameHistory( CommonGlobals* cGlobals );
|
||||
void catOnClose( XWStreamCtxt* stream, void* closure );
|
||||
void sendOnClose( XWStreamCtxt* stream, void* closure );
|
||||
void catOnClose( XWStreamCtxt* stream, XWEnv xwe, void* closure );
|
||||
void sendOnClose( XWStreamCtxt* stream, XWEnv xwe, void* closure );
|
||||
|
||||
void catFinalScores( const CommonGlobals* cGlobals, XP_S16 quitter );
|
||||
XP_Bool file_exists( const char* fileName );
|
||||
XWStreamCtxt* streamFromFile( CommonGlobals* cGlobals, char* name );
|
||||
XWStreamCtxt* streamFromDB( CommonGlobals* cGlobals );
|
||||
void writeToFile( XWStreamCtxt* stream, void* closure );
|
||||
void writeToFile( XWStreamCtxt* stream, XWEnv xwe, void* closure );
|
||||
XP_Bool getDictPath( const LaunchParams *params, const char* name,
|
||||
char* result, int resultLen );
|
||||
GSList* listDicts( const LaunchParams *params );
|
||||
|
|
|
@ -237,7 +237,7 @@ nliFromData( LaunchParams* params, const SMSMsgLoc* msg, NetLaunchInfo* nliOut )
|
|||
#endif
|
||||
nli_makeFromStream( nliOut, stream );
|
||||
XP_ASSERT( success );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -322,7 +322,7 @@ linux_sms_invite( LaunchParams* params, const NetLaunchInfo* nli,
|
|||
XP_ASSERT( !!arr || !forceOld );
|
||||
sendOrRetry( params, arr, INVITE, waitSecs, toPhone, toPort,
|
||||
nli->gameID, "invite" );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
}
|
||||
|
||||
XP_S16
|
||||
|
|
|
@ -584,7 +584,7 @@ writeNoConnMsgs( CommonGlobals* cGlobals, int fd )
|
|||
#endif
|
||||
write( fd, stream_getPtr( stream ), siz );
|
||||
XP_ASSERT( nwritten == siz );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
}
|
||||
g_list_free( keys );
|
||||
g_hash_table_unref( hash );
|
||||
|
|
|
@ -346,7 +346,7 @@ relaycon_invite( LaunchParams* params, XP_U32 destRelayDevID,
|
|||
XP_ASSERT( indx + len < sizeof(tmpbuf) );
|
||||
const XP_U8* ptr = stream_getPtr( stream );
|
||||
indx += writeBytes( &tmpbuf[indx], sizeof(tmpbuf) - indx, ptr, len );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL_XWE );
|
||||
|
||||
sendIt( storage, tmpbuf, indx, 0.5 );
|
||||
LOG_RETURN_VOID();
|
||||
|
@ -690,7 +690,7 @@ process( RelayConStorage* storage, XP_U8* buf, ssize_t nRead )
|
|||
NetLaunchInfo invit;
|
||||
XP_Bool success = nli_makeFromStream( &invit, stream );
|
||||
XP_LOGF( "sender: %d", sender );
|
||||
stream_destroy( stream );
|
||||
stream_destroy( stream, NULL );
|
||||
|
||||
if ( success ) {
|
||||
(*storage->procs.inviteReceived)( storage->procsClosure,
|
||||
|
|
Loading…
Reference in a new issue