New stream version makes standalone and multi-device build formats the

same so new Wince can open files saved by current version.  Tweaks to
build with relay and heartbeat turned on.
This commit is contained in:
ehouse 2009-01-03 23:54:25 +00:00
parent 863f79bfb9
commit e32e231dd5
6 changed files with 49 additions and 26 deletions

View file

@ -1,6 +1,7 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
/*
* Copyright 2001-2007 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
@ -1023,7 +1024,8 @@ btIpPreProcess( CommsCtxt* comms, XWStreamCtxt* stream )
static XP_Bool
preProcess( CommsCtxt* comms, XWStreamCtxt* stream,
XP_Bool* XP_UNUSED_RELAY(usingRelay), XWHostID* XP_UNUSED_RELAY(senderID) )
XP_Bool* XP_UNUSED_RELAY(usingRelay),
XWHostID* XP_UNUSED_RELAY(senderID) )
{
XP_Bool consumed = XP_FALSE;
switch ( comms->addr.conType ) {

View file

@ -1,6 +1,7 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
/*
* Copyright 1997 - 2000 by Eric House (xwords@eehouse.org). All rights reserved.
* Copyright 1997 - 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
@ -103,7 +104,7 @@ typedef XP_S16 XP_PlayerAddr;
typedef enum {
TIMER_PENDOWN = 1, /* ARM doesn't like ids of 0... */
TIMER_TIMERTICK,
#if defined RELAY_HEARTBEAT || defined COMMS_HEARTBEAT
#if defined XWFEATURE_RELAY || defined COMMS_HEARTBEAT
TIMER_HEARTBEAT,
#endif

View file

@ -1,6 +1,7 @@
/* -*-mode: C; fill-column: 76; c-basic-offset: 4; -*- */
/*
* Copyright 2001 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
@ -188,25 +189,33 @@ game_makeFromStream( MPFORMAL XWStreamCtxt* stream, XWGame* game,
gi_readFromStream( MPPARM(mpool) stream, gi );
#ifndef XWFEATURE_STANDALONE_ONLY
hasComms = stream_getU8( stream );
/* Previous stream versions didn't save anything if built
* standalone. Now we always save something. But we need to know
* if the previous version didn't save. PREV_WAS_STANDALONE_ONLY
* tells us that.
*/
hasComms = XP_FALSE;
if ( STREAM_VERS_ALWAYS_MULTI <= strVersion /* new stream */
#ifndef PREV_WAS_STANDALONE_ONLY
|| XP_TRUE /* old, but saved this anyway */
#endif
) {
hasComms = stream_getU8( stream );
}
if ( hasComms ) {
game->comms = comms_makeFromStream( MPPARM(mpool) stream, util,
sendProc, IF_CH(resetProc) closure );
sendProc, IF_CH(resetProc)
closure );
} else {
game->comms = NULL;
}
#endif
XP_ASSERT( !!dict );
game->model = model_makeFromStream( MPPARM(mpool) stream, dict, util );
game->server = server_makeFromStream( MPPARM(mpool) stream,
game->model,
#ifndef XWFEATURE_STANDALONE_ONLY
game->comms,
#else
(CommsCtxt*)NULL,
#endif
game->model, game->comms,
util, gi->nPlayers );
game->board = board_makeFromStream( MPPARM(mpool) stream, game->model,
@ -230,12 +239,13 @@ game_saveToStream( const XWGame* game, const CurGameInfo* gi,
gi_writeToStream( stream, gi );
#ifndef XWFEATURE_STANDALONE_ONLY
stream_putU8( stream, (XP_U8)!!game->comms );
#ifdef XWFEATURE_STANDALONE_ONLY
XP_ASSERT( !game->comms );
#endif
if ( !!game->comms ) {
comms_writeToStream( game->comms, stream );
}
#endif
model_writeToStream( game->model, stream );
server_writeToStream( game->server, stream );

View file

@ -1,6 +1,7 @@
/* -*-mode: C; fill-column: 76; c-basic-offset: 4; -*- */
/*
* Copyright 2001 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
@ -30,6 +31,8 @@
extern "C" {
#endif
#define STREAM_VERS_ALWAYS_MULTI 0x07 /* stream format same for multi and
one-device game builds */
#define STREAM_VERS_MODEL_NO_DICT 0x06
#define STREAM_VERS_BLUETOOTH 0x05
#define STREAM_VERS_KEYNAV 0x04
@ -37,7 +40,7 @@ extern "C" {
#define STREAM_VERS_41B4 0x02
#define STREAM_VERS_405 0x01
#define CUR_STREAM_VERS STREAM_VERS_MODEL_NO_DICT
#define CUR_STREAM_VERS STREAM_VERS_ALWAYS_MULTI
typedef struct LocalPlayer {
XP_UCHAR* name;

View file

@ -1,6 +1,7 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
/*
* Copyright 1997 - 2002 by Eric House (xwords@eehouse.org). All rights reserved.
* Copyright 1997-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
@ -308,9 +309,13 @@ server_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model,
}
}
#ifndef XWFEATURE_STANDALONE_ONLY
server->lastMoveSource = (XP_U16)stream_getBits( stream, 2 );
if ( STREAM_VERS_ALWAYS_MULTI <= stream_getVersion(stream)
#ifndef PREV_WAS_STANDALONE_ONLY
|| XP_TRUE
#endif
) {
server->lastMoveSource = (XP_U16)stream_getBits( stream, 2 );
}
XP_ASSERT( stream_getU32( stream ) == sEND );
@ -343,6 +348,8 @@ server_writeToStream( ServerCtxt* server, XWStreamCtxt* stream )
#ifndef XWFEATURE_STANDALONE_ONLY
stream_putBits( stream, 2, server->lastMoveSource );
#else
stream_putBits( stream, 2, 0 );
#endif
#ifdef DEBUG

View file

@ -1,6 +1,6 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
/*
* Copyright 1997 - 2007 by Eric House (xwords@eehouse.org). All rights reserved.
* Copyright 1997-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
@ -155,7 +155,7 @@ typedef struct UtilVtable {
void (*m_util_remSelected)(XW_UtilCtxt* uc);
#if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH
#ifndef XWFEATURE_STANDALONE_ONLY
void (*m_util_addrChange)( XW_UtilCtxt* uc, const CommsAddrRec* oldAddr,
const CommsAddrRec* newAddr );
#endif
@ -248,8 +248,8 @@ struct XW_UtilCtxt {
#define util_remSelected( uc ) \
(uc)->vtable->m_util_remSelected((uc))
#if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH
#define util_addrChange( uc, addro, addrn ) \
#ifndef XWFEATURE_STANDALONE_ONLY
# define util_addrChange( uc, addro, addrn ) \
(uc)->vtable->m_util_addrChange((uc), (addro), (addrn))
#endif