Fix opening games and messages saved by last shipping version on Palm

by checking version and loading new fields conditionally.  (Not yet
tested for current wince version.)
This commit is contained in:
ehouse 2006-10-05 01:17:03 +00:00
parent 715d01b8a4
commit 878acbc759
6 changed files with 64 additions and 36 deletions

View file

@ -201,6 +201,7 @@ board_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model,
{
BoardCtxt* board;
XP_U16 i;
XP_U16 version = stream_getVersion( stream );
board = board_make( MPPARM(mpool) model, server, draw, util );
@ -211,7 +212,9 @@ board_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model,
board->showColors = (XP_Bool)stream_getBits( stream, 1 );
board->showCellValues = (XP_Bool)stream_getBits( stream, 1 );
#ifdef KEYBOARD_NAV
board->focussed = (BoardObjectType)stream_getBits( stream, 2 );
if ( version >= STREAM_VERS_RELAY ) {
board->focussed = (BoardObjectType)stream_getBits( stream, 2 );
}
#endif
XP_ASSERT( !!server );
@ -228,13 +231,15 @@ board_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model,
MAX_TRAY_TILES );
board->tradeInProgress[i] = (XP_Bool)stream_getBits( stream, 1 );
#ifdef KEYBOARD_NAV
board->bdCursor[i].col = stream_getBits( stream, 4 );
board->bdCursor[i].row = stream_getBits( stream, 4 );
board->trayCursorLoc[i] = stream_getBits( stream, 3 );
if ( version >= STREAM_VERS_RELAY ) {
board->bdCursor[i].col = stream_getBits( stream, 4 );
board->bdCursor[i].row = stream_getBits( stream, 4 );
board->trayCursorLoc[i] = stream_getBits( stream, 3 );
}
#endif
#ifdef XWFEATURE_SEARCHLIMIT
if ( stream_getVersion( stream ) >= STREAM_VERS_41b4 ) {
if ( version >= STREAM_VERS_41B4 ) {
board->hasHintRect[i] = stream_getBits( stream, 1 );
} else {
board->hasHintRect[i] = XP_FALSE;

View file

@ -244,7 +244,7 @@ addrFromStream( CommsAddrRec* addrP, XWStreamCtxt* stream )
{
CommsAddrRec addr;
addr.conType = stream_getBits( stream, 3 );
addr.conType = stream_getU8( stream );
switch( addr.conType ) {
case COMMS_CONN_UNUSED:
@ -290,19 +290,37 @@ comms_makeFromStream( MPFORMAL XWStreamCtxt* stream, XW_UtilCtxt* util,
XP_U16 nAddrRecs, nPlayersHere, nPlayersTotal;
AddressRecord** prevsAddrNext;
MsgQueueElem** prevsQueueNext;
XP_U16 version = stream_getVersion( stream );
CommsAddrRec addr;
short i;
isServer = stream_getU8( stream );
nPlayersHere = (XP_U16)stream_getBits( stream, 4 );
nPlayersTotal = (XP_U16)stream_getBits( stream, 4 );
if ( version < STREAM_VERS_RELAY ) {
XP_MEMSET( &addr, 0, sizeof(addr) );
addr.conType = COMMS_CONN_IR; /* all there was back then */
} else {
addrFromStream( &addr, stream );
}
if ( addr.conType == COMMS_CONN_RELAY ) {
nPlayersHere = (XP_U16)stream_getBits( stream, 4 );
nPlayersTotal = (XP_U16)stream_getBits( stream, 4 );
} else {
nPlayersHere = 0;
nPlayersTotal = 0;
}
comms = comms_make( MPPARM(mpool) util, isServer,
nPlayersHere, nPlayersTotal,
sendproc, closure );
XP_MEMCPY( &comms->addr, &addr, sizeof(comms->addr) );
comms->connID = stream_getU32( stream );
comms->nextChannelNo = stream_getU16( stream );
comms->r.myHostID = stream_getU8( stream );
stringFromStreamHere( stream, comms->r.connName, sizeof(comms->r.connName) );
if ( addr.conType == COMMS_CONN_RELAY ) {
comms->r.myHostID = stream_getU8( stream );
stringFromStreamHere( stream, comms->r.connName,
sizeof(comms->r.connName) );
}
#ifdef DEBUG
comms->nUniqueBytes = stream_getU16( stream );
@ -313,16 +331,16 @@ comms_makeFromStream( MPFORMAL XWStreamCtxt* stream, XW_UtilCtxt* util,
prevsAddrNext = &comms->recs;
for ( i = 0; i < nAddrRecs; ++i ) {
AddressRecord* rec = (AddressRecord*)XP_MALLOC( mpool, sizeof(*rec));
CommsAddrRec* addr;
XP_MEMSET( rec, 0, sizeof(*rec) );
addr = &rec->addr;
addrFromStream( addr, stream );
addrFromStream( &rec->addr, stream );
rec->nextMsgID = stream_getU16( stream );
rec->lastMsgReceived = stream_getU16( stream );
rec->channelNo = stream_getU16( stream );
rec->r.hostID = stream_getU8( stream ); /* unneeded unless RELAY */
if ( rec->addr.conType == COMMS_CONN_RELAY ) {
rec->r.hostID = stream_getU8( stream );
}
#ifdef DEBUG
rec->lastACK = stream_getU16( stream );
@ -350,8 +368,6 @@ comms_makeFromStream( MPFORMAL XWStreamCtxt* stream, XW_UtilCtxt* util,
prevsQueueNext = &msg->next;
}
addrFromStream( &comms->addr, stream );
#ifdef DEBUG
XP_ASSERT( stream_getU32( stream ) == cEND );
#endif
@ -380,7 +396,7 @@ addrToStream( XWStreamCtxt* stream, CommsAddrRec* addrP )
CommsAddrRec addr;
XP_MEMCPY( &addr, addrP, sizeof(addr) );
stream_putBits( stream, 3, addr.conType );
stream_putU8( stream, addr.conType );
switch( addr.conType ) {
#ifdef DEBUG
@ -420,13 +436,18 @@ comms_writeToStream( CommsCtxt* comms, XWStreamCtxt* stream )
MsgQueueElem* msg;
stream_putU8( stream, (XP_U8)comms->isServer );
stream_putBits( stream, 4, comms->r.nPlayersHere );
stream_putBits( stream, 4, comms->r.nPlayersTotal );
addrToStream( stream, &comms->addr );
if ( comms->addr.conType == COMMS_CONN_RELAY ) {
stream_putBits( stream, 4, comms->r.nPlayersHere );
stream_putBits( stream, 4, comms->r.nPlayersTotal );
}
stream_putU32( stream, comms->connID );
stream_putU16( stream, comms->nextChannelNo );
stream_putU8( stream, comms->r.myHostID );
stringToStream( stream, comms->r.connName );
if ( comms->addr.conType == COMMS_CONN_RELAY ) {
stream_putU8( stream, comms->r.myHostID );
stringToStream( stream, comms->r.connName );
}
#ifdef DEBUG
stream_putU16( stream, comms->nUniqueBytes );
@ -446,7 +467,9 @@ comms_writeToStream( CommsCtxt* comms, XWStreamCtxt* stream )
stream_putU16( stream, (XP_U16)rec->nextMsgID );
stream_putU16( stream, (XP_U16)rec->lastMsgReceived );
stream_putU16( stream, rec->channelNo );
stream_putU8( stream, rec->r.hostID ); /* unneeded unless RELAY */
if ( rec->addr.conType == COMMS_CONN_RELAY ) {
stream_putU8( stream, rec->r.hostID ); /* unneeded unless RELAY */
}
#ifdef DEBUG
stream_putU16( stream, rec->lastACK );
stream_putU16( stream, rec->nUniqueBytes );
@ -461,8 +484,6 @@ comms_writeToStream( CommsCtxt* comms, XWStreamCtxt* stream )
stream_putBytes( stream, msg->msg, msg->len );
}
addrToStream( stream, &comms->addr );
#ifdef DEBUG
stream_putU32( stream, cEND );
#endif

View file

@ -34,10 +34,10 @@ typedef XP_U8 XWHostID;
typedef enum {
COMMS_CONN_UNUSED, /* I want errors on uninited case */
COMMS_CONN_IR,
COMMS_CONN_IP_NOUSE,
COMMS_CONN_RELAY,
COMMS_CONN_BT,
COMMS_CONN_IR,
LAST_____FOO
} CommsConnType;

View file

@ -374,7 +374,7 @@ gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi )
gi->phoniesAction = (XWPhoniesChoice)stream_getBits( stream, 2 );
gi->timerEnabled = stream_getBits( stream, 1 );
if ( strVersion >= STREAM_VERS_41b4 ) {
if ( strVersion >= STREAM_VERS_41B4 ) {
gi->allowPickTiles = stream_getBits( stream, 1 );
gi->allowHintRect = stream_getBits( stream, 1 );
} else {

View file

@ -30,11 +30,12 @@
extern "C" {
#endif
#define CUR_STREAM_VERS 0x03
#define STREAM_VERS_41b4 0x02
#define STREAM_VERS_RELAY 0x03
#define STREAM_VERS_41B4 0x02
#define STREAM_VERS_405 0x01
#define CUR_STREAM_VERS STREAM_VERS_RELAY
typedef struct LocalPlayer {
XP_UCHAR* name;
XP_UCHAR* password;

View file

@ -238,7 +238,7 @@ getNV( XWStreamCtxt* stream, ServerNonvolatiles* nv, XP_U16 nPlayers )
(void)stream_getBits( stream, 3 ); /* was npassesinrow */
nv->nDevices = (XP_U8)stream_getBits( stream, NDEVICES_NBITS );
if ( stream_getVersion( stream ) > STREAM_VERS_41b4 ) {
if ( stream_getVersion( stream ) > STREAM_VERS_41B4 ) {
++nv->nDevices;
}
@ -443,7 +443,7 @@ server_initClientConnection( ServerCtxt* server, XWStreamCtxt* stream )
XP_ASSERT( i++ < MAX_NUM_PLAYERS );
stream_putBits( stream, 1, lp->isRobot );
stream_putBits( stream, 1, lp->isRobot ); /* better not to send this */
/* The first nPlayers players are the ones we'll use. The local flag
doesn't matter when for SERVER_ISCLIENT. */
@ -952,8 +952,8 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream )
/* version */
XP_U8 streamVersion = stream_getU8( stream );
XP_ASSERT( streamVersion == CUR_STREAM_VERS );
if ( streamVersion != CUR_STREAM_VERS ) {
XP_ASSERT( streamVersion == STREAM_VERS_41B4 );
if ( streamVersion != STREAM_VERS_41B4 ) {
return XP_FALSE;
}
stream_setVersion( stream, streamVersion );
@ -1090,8 +1090,9 @@ server_sendInitialMessage( ServerCtxt* server )
stream_open( stream );
stream_putBits( stream, XWPROTO_NBITS, XWPROTO_CLIENT_SETUP );
/* write version for server's benefit */
stream_putU8( stream, CUR_STREAM_VERS );
/* write version for server's benefit; use old version until format
changes */
stream_putU8( stream, STREAM_VERS_41B4 );
XP_STATUSF( "putting gameID %lx into msg", gameID );
stream_putU32( stream, gameID );
@ -2339,7 +2340,7 @@ server_formatDictCounts( ServerCtxt* server, XWStreamCtxt* stream,
XP_U16 nChars, nPrinted;
XP_UCHAR buf[48];
XP_UCHAR* fmt = util_getUserString( server->vol.util, STRS_VALUES_HEADER );
XP_UCHAR* dname;
const XP_UCHAR* dname;
XP_ASSERT( !!server->vol.model );