mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-13 08:01:33 +01:00
Toward a palm build whose only comms mode is relay (no IR, which was
always default.) Plays half a robot-robot game via relay as client -- that is, debugging remains.
This commit is contained in:
parent
d5cede0150
commit
ae0b8211fe
7 changed files with 67 additions and 63 deletions
|
@ -111,16 +111,23 @@ MYDEFS_COMMON += -DXWFEATURE_SEARCHLIMIT
|
|||
|
||||
#MYDEFS_COMMON += -DXWFEATURE_HINT_CONFIG
|
||||
|
||||
ifdef XWFEATURE_STANDALONE_ONLY
|
||||
MYDEFS_COMMON += -DXWFEATURE_STANDALONE_ONLY
|
||||
else
|
||||
# Turn on network play over IP via cellular modem. Very much
|
||||
# experimental at this point!
|
||||
MYDEFS_COMMON += -DXWFEATURE_RELAY
|
||||
MYDEFS_COMMON += -DXWFEATURE_RELAY -DRELAY_NAME_DEFAULT="\"localhost\""
|
||||
|
||||
# turn on bluetooth comms option for 68K and ARM
|
||||
BLUETOOTH = -DXWFEATURE_BLUETOOTH -DBT_USE_L2CAP
|
||||
#BLUETOOTH = -DXWFEATURE_BLUETOOTH -DBT_USE_L2CAP
|
||||
# -DCOMMS_HEARTBEAT
|
||||
#BLUETOOTH = -DXWFEATURE_BLUETOOTH -DBT_USE_RFCOMM
|
||||
MYDEFS_COMMON += $(BLUETOOTH)
|
||||
|
||||
#MYDEFS_COMMON += -DXWFEATURE_IR
|
||||
|
||||
endif # ifdef XWFEATURE_STANDALONE_ONLY
|
||||
|
||||
# Add menu allowing to choose to run 68K or ARM
|
||||
ifeq ($(ARCH),COMBINED)
|
||||
MYDEFS_COMMON += -DFEATURE_DUALCHOOSE
|
||||
|
@ -139,12 +146,6 @@ MYDEFS_COMMON += -DNODE_CAN_4
|
|||
|
||||
MYDEFS_COMMON += -DSVN_REV=\"$(shell svnversion -n .)\"
|
||||
|
||||
ifdef XWFEATURE_STANDALONE_ONLY
|
||||
MYDEFS_COMMON += -DXWFEATURE_STANDALONE_ONLY
|
||||
else
|
||||
MYDEFS_COMMON += -DXWFEATURE_IR
|
||||
endif
|
||||
|
||||
MYDEFS_ARM = -D__LITTLE_ENDIAN -DXW_TARGET_PNO $(MYDEFS_COMMON)
|
||||
MYDEFS_68K = -DPLATFORM_PALM -D__BIG_ENDIAN $(MYDEFS_COMMON) \
|
||||
-DAPPNAME=\"$(APPNAME)\" \
|
||||
|
|
|
@ -55,7 +55,9 @@ typedef struct ConnsDlgState {
|
|||
CommsConnType conType;
|
||||
CommsAddrRec* addr;
|
||||
XP_BtAddr btAddr; /* since there's no field, save it here */
|
||||
#ifdef XWFEATURE_BLUETOOTH
|
||||
char hostName[PALM_BT_NAME_LEN];
|
||||
#endif
|
||||
} ConnsDlgState;
|
||||
|
||||
static void
|
||||
|
@ -247,31 +249,30 @@ setupXportList( PalmAppGlobals* globals )
|
|||
{
|
||||
ConnsDlgState* state = globals->connState;
|
||||
ListData* sLd = &state->sLd;
|
||||
XP_U16 i;
|
||||
XP_U16 ii;
|
||||
XP_S16 selSel = -1;
|
||||
const XP_UCHAR* selName = NULL;
|
||||
|
||||
if ( state->nXports >= 2 ) {
|
||||
state->connTypesList = getActiveObjectPtr( XW_CONNS_TYPE_LIST_ID );
|
||||
XP_ASSERT( state->nXports >= 1 );
|
||||
state->connTypesList = getActiveObjectPtr( XW_CONNS_TYPE_LIST_ID );
|
||||
|
||||
initListData( MPPARM(globals->mpool) sLd, state->nXports );
|
||||
for ( i = 0; i < state->nXports; ++i ) {
|
||||
XportEntry* xports = &state->xports[i];
|
||||
const XP_UCHAR* xname = getResString( globals, xports->resID );
|
||||
addListTextItem( MPPARM(globals->mpool) sLd, xname );
|
||||
if ( state->conType == xports->conType ) {
|
||||
selName = xname;
|
||||
selSel = i;
|
||||
}
|
||||
initListData( MPPARM(globals->mpool) sLd, state->nXports );
|
||||
for ( ii = 0; ii < state->nXports; ++ii ) {
|
||||
XportEntry* xports = &state->xports[ii];
|
||||
const XP_UCHAR* xname = getResString( globals, xports->resID );
|
||||
addListTextItem( MPPARM(globals->mpool) sLd, xname );
|
||||
if ( state->conType == xports->conType ) {
|
||||
selName = xname;
|
||||
selSel = ii;
|
||||
}
|
||||
|
||||
XP_ASSERT( !!selName );
|
||||
setListSelection( sLd, selName );
|
||||
setListChoices( sLd, state->connTypesList, NULL );
|
||||
|
||||
setSelectorFromList( XW_CONNS_TYPE_TRIGGER_ID, state->connTypesList,
|
||||
selSel );
|
||||
}
|
||||
|
||||
XP_ASSERT( !!selName );
|
||||
setListSelection( sLd, selName );
|
||||
setListChoices( sLd, state->connTypesList, NULL );
|
||||
|
||||
setSelectorFromList( XW_CONNS_TYPE_TRIGGER_ID, state->connTypesList,
|
||||
selSel );
|
||||
} /* setupXportList */
|
||||
|
||||
static void
|
||||
|
@ -296,7 +297,6 @@ buildXportData( ConnsDlgState* state )
|
|||
++xports;
|
||||
#endif
|
||||
state->nXports = xports - state->xports;
|
||||
XP_ASSERT( state->nXports >= 2 ); /* no need for dropdown otherwise!! */
|
||||
} /* buildXportData */
|
||||
|
||||
Boolean
|
||||
|
|
|
@ -466,7 +466,9 @@ NAVIGATIONMAP
|
|||
#ifdef FEATURE_TRAY_EDIT
|
||||
ROW XW_PREFS_PICKTILES_CHECKBOX_ID
|
||||
#endif
|
||||
#ifdef XWFEATURE_BLUETOOTH
|
||||
ROW XW_PREFS_BTCONFIRM_CHECKBOX_ID
|
||||
#endif
|
||||
|
||||
/* cmd buttons */
|
||||
ROW XW_PREFS_CANCEL_BUTTON_ID
|
||||
|
|
|
@ -372,7 +372,7 @@ changeGadgetHilite( PalmAppGlobals* globals, UInt16 hiliteID )
|
|||
#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY
|
||||
/* Even if it didn't change, pop the connections form. It's only
|
||||
informational in the non-new-game case; nothing can be changed. */
|
||||
if ( (hiliteID != SERVER_STANDALONE) && (state->nXPorts > 1) ) {
|
||||
if ( hiliteID != SERVER_STANDALONE ) {
|
||||
if ( isNewGame || (hiliteID==globals->newGameState.curServerHilite) ) {
|
||||
PopupConnsForm( globals, hiliteID, &state->addr );
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2001-2005 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
* Copyright 2001-2009 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -219,10 +219,10 @@ sendLoop( PalmAppGlobals* globals, const XP_U8* buf, XP_U16 len )
|
|||
|
||||
if ( thisSent == 0 ) {
|
||||
globals->nlStuff.socket = -1; /* mark socket closed */
|
||||
return XP_FALSE;
|
||||
break;
|
||||
} else if ( thisSent < 0 ) {
|
||||
XP_LOGF( "NetLibSend => %d", err );
|
||||
return XP_FALSE;
|
||||
break;
|
||||
} else {
|
||||
totalSent += thisSent;
|
||||
if ( totalSent < len ) {
|
||||
|
@ -232,8 +232,7 @@ sendLoop( PalmAppGlobals* globals, const XP_U8* buf, XP_U16 len )
|
|||
}
|
||||
} while ( totalSent < len );
|
||||
|
||||
XP_LOGF( "sendLoop sent %d bytes", len );
|
||||
return XP_TRUE;
|
||||
return totalSent == len;
|
||||
} /* sendLoop */
|
||||
|
||||
XP_S16
|
||||
|
@ -242,10 +241,9 @@ palm_ip_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addrp,
|
|||
{
|
||||
CommsAddrRec localRec;
|
||||
CommsAddrRec* addr = &localRec;
|
||||
XP_S16 nSent = 0;
|
||||
XP_Bool resolved = XP_FALSE;
|
||||
XP_S16 nSent = -1;
|
||||
|
||||
XP_LOGF( "palm_ip_send: len=%d", len );
|
||||
XP_LOGF( "%s: len=%d", __func__, len );
|
||||
XP_ASSERT( len < MAX_MSG_LEN );
|
||||
|
||||
if ( !!addrp ) {
|
||||
|
@ -255,6 +253,7 @@ palm_ip_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addrp,
|
|||
}
|
||||
|
||||
if ( openNetLibIfNot( globals ) ) {
|
||||
XP_Bool resolved = XP_FALSE;
|
||||
if ( resolveAddressIfNot( globals, addr, &resolved ) ) {
|
||||
if ( resolved ) {
|
||||
comms_setAddr( globals->game.comms, addr );
|
||||
|
@ -270,8 +269,11 @@ palm_ip_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addrp,
|
|||
nSent = len;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
XP_LOGF( "%s: dropping because resolveAddressIfNot failed", __func__ );
|
||||
}
|
||||
}
|
||||
LOG_RETURNF( "%d", nSent );
|
||||
return nSent;
|
||||
} /* palm_ip_send */
|
||||
|
||||
|
@ -282,34 +284,30 @@ recvLoop( PalmAppGlobals* globals, XP_U8* buf, XP_U16 lenSought )
|
|||
{
|
||||
XP_U32 timeout = TimGetSeconds() + 5;
|
||||
XP_U16 totalRead = 0;
|
||||
NetSocketAddrINType fromAddr;
|
||||
void* fromAddrP;
|
||||
UInt16 fromLen;
|
||||
/* NetSocketAddrINType fromAddr; */
|
||||
/* void* fromAddrP; */
|
||||
/* UInt16 fromLen; */
|
||||
|
||||
if ( globals->romVersion >= 50 ) {
|
||||
fromAddrP = NULL;
|
||||
fromLen = 0;
|
||||
} else {
|
||||
fromAddrP = (void*)&fromAddr;
|
||||
fromLen = sizeof( fromAddr );
|
||||
}
|
||||
/* fromAddrP = NULL; */
|
||||
/* fromLen = 0; */
|
||||
|
||||
/* Be sure there's a way to timeout quickly here!!! */
|
||||
while ( totalRead < lenSought && TimGetSeconds() < timeout ) {
|
||||
while ( (totalRead < lenSought) && (TimGetSeconds() < timeout) ) {
|
||||
Err err;
|
||||
Int16 nRead = NetLibReceive( globals->nlStuff.netLibRef,
|
||||
globals->nlStuff.socket,
|
||||
buf, lenSought, 0, /* flags */
|
||||
fromAddrP, &fromLen,
|
||||
buf+totalRead, lenSought-totalRead,
|
||||
0, /* flags */
|
||||
NULL, NULL,//&fromLen,
|
||||
NETLIB_TIMEOUT, &err );
|
||||
|
||||
if ( (nRead < 0) && (err != netErrTimeout) ) {
|
||||
XP_LOGF( "NetLibReceive => %d", err );
|
||||
return XP_FALSE;
|
||||
XP_LOGF( "NetLibReceive => %x", err );
|
||||
break;
|
||||
} else if ( nRead == 0 ) {
|
||||
XP_LOGF( "NetLibReceive; socket close" );
|
||||
globals->nlStuff.socket = -1;
|
||||
return XP_FALSE;
|
||||
break;
|
||||
} else {
|
||||
totalRead += nRead;
|
||||
}
|
||||
|
@ -332,7 +330,7 @@ packetToStream( PalmAppGlobals* globals )
|
|||
if ( recvLoop( globals, buf, netlen ) ) {
|
||||
|
||||
result = mem_stream_make( MEMPOOL globals->vtMgr,
|
||||
globals, 0, NULL);
|
||||
globals, 0, NULL );
|
||||
stream_open( result );
|
||||
stream_putBytes( result, buf, netlen );
|
||||
}
|
||||
|
|
|
@ -1074,7 +1074,9 @@ startApplication( PalmAppGlobals** globalsP )
|
|||
Boolean leftyFlag;
|
||||
Int16 vers;
|
||||
UInt32 ignore;
|
||||
#if defined XWFEATURE_BLUETOOTH
|
||||
Err err;
|
||||
#endif
|
||||
MPSLOT;
|
||||
|
||||
#if defined FOR_GREMLINS
|
||||
|
@ -2019,7 +2021,7 @@ initAndStartBoard( PalmAppGlobals* globals, XP_Bool newGame )
|
|||
game_reset( MEMPOOL &globals->game, &globals->gameInfo,
|
||||
&globals->util, newGameID, &globals->gState.cp,
|
||||
palm_send, IF_CH(palm_reset) globals );
|
||||
#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY || defined XWFEATURE_IR
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
if ( !!globals->game.comms ) {
|
||||
comms_setAddr( globals->game.comms,
|
||||
&globals->newGameState.addr );
|
||||
|
@ -2033,7 +2035,11 @@ initAndStartBoard( PalmAppGlobals* globals, XP_Bool newGame )
|
|||
getSizes( globals );
|
||||
(void)positionBoard( globals );
|
||||
|
||||
#ifdef XWFEATURE_IR
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
if ( !!globals->game.comms ) {
|
||||
comms_start( globals->game.comms );
|
||||
}
|
||||
|
||||
if ( newGame && globals->gameInfo.serverRole == SERVER_ISCLIENT ) {
|
||||
XWStreamCtxt* stream;
|
||||
XP_ASSERT( !!globals->game.comms );
|
||||
|
@ -2041,11 +2047,6 @@ initAndStartBoard( PalmAppGlobals* globals, XP_Bool newGame )
|
|||
server_initClientConnection( globals->game.server, stream );
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( !!globals->game.comms ) {
|
||||
comms_start( globals->game.comms );
|
||||
}
|
||||
|
||||
/* Used to call server_do here, but if it's a robot's turn it'll run
|
||||
without drawing the board first. This allows work to get done almost
|
||||
as quickly. If the board starts flashing on launch this is why;
|
||||
|
|
|
@ -293,8 +293,12 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/* May be overridden below */
|
||||
#define XW_PREFS_LAST_PERGAME_ID XW_PREFS_PICKTILES_CHECKBOX_ID
|
||||
|
||||
#ifdef XWFEATURE_BLUETOOTH
|
||||
# define XW_PREFS_BTCONFIRM_CHECKBOX_ID 2725
|
||||
# define XW_PREFS_LAST_PERGAME_ID XW_PREFS_BTCONFIRM_CHECKBOX_ID
|
||||
#endif
|
||||
|
||||
#ifdef XWFEATURE_FIVEWAY
|
||||
|
@ -323,8 +327,6 @@
|
|||
/* # define XW_PREFS_LAST_PERGAME_ID XW_PREFS_TIMER_FIELD_ID */
|
||||
/* #endif */
|
||||
|
||||
#define XW_PREFS_LAST_PERGAME_ID XW_PREFS_BTCONFIRM_CHECKBOX_ID
|
||||
|
||||
#define XW_PREFS_CANCEL_BUTTON_ID 2726
|
||||
#define XW_PREFS_OK_BUTTON_ID 2727
|
||||
|
||||
|
|
Loading…
Reference in a new issue