don't write gameID as 32 bits when it's bound for old-version client,

and assert based only on the lower 16 bits in case came from
old-version client.  Fixes crashes testing mid-game upgrade from beta
43.
This commit is contained in:
Eric House 2012-05-07 07:02:43 -07:00
parent c17826ffbf
commit 08f03af2cc
3 changed files with 15 additions and 5 deletions

View file

@ -36,7 +36,7 @@
#ifndef XWFEATURE_STANDALONE_ONLY
#ifndef INITIAL_CLIENT_VERS
# define INITIAL_CLIENT_VERS 1
# define INITIAL_CLIENT_VERS 2
#endif
#ifdef COMMS_HEARTBEAT
@ -1123,7 +1123,8 @@ gameID( const CommsCtxt* comms )
gameID = comms->util->gameInfo->gameID;
}
XP_ASSERT( 0 == comms->connID
|| comms->connID == comms->util->gameInfo->gameID );
|| (comms->connID & 0xFFFF)
== (comms->util->gameInfo->gameID & 0xFFFF) );
/* Most of the time these will be the same, but early in a game they won't
be. Would be nice not to have to use gameID. */
return gameID;

View file

@ -196,7 +196,7 @@ game_makeFromStream( MPFORMAL XWStreamCtxt* stream, XWGame* game,
XP_Bool hasComms;
#endif
strVersion = stream_getU8( stream );
XP_DEBUGF( "strVersion = %d", (XP_U16)strVersion );
XP_DEBUGF( "%s: strVersion = 0x%x", __func__, (XP_U16)strVersion );
if ( strVersion > CUR_STREAM_VERS ) {
XP_LOGF( "%s: aborting; stream version too new!", __func__ );
@ -506,6 +506,7 @@ gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi )
XP_U16 nColsNBits;
#ifdef STREAM_VERS_BIGBOARD
XP_U16 strVersion = stream_getVersion( stream );
XP_LOGF( "%s: strVersion = 0x%x", __func__, strVersion );
XP_ASSERT( STREAM_SAVE_PREVWORDS <= strVersion );
nColsNBits = STREAM_VERS_BIGBOARD > strVersion ? NUMCOLS_NBITS_4
: NUMCOLS_NBITS_5;
@ -525,7 +526,15 @@ gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi )
stream_putBits( stream, 1, gi->allowHintRect );
stream_putBits( stream, 1, gi->confirmBTConnect );
stream_putU32( stream, gi->gameID );
if ( 0 ) {
#ifdef STREAM_VERS_BIGBOARD
} else if ( STREAM_VERS_BIGBOARD <= strVersion ) {
stream_putU32( stream, gi->gameID );
#endif
} else {
stream_putU16( stream, gi->gameID );
}
stream_putU8( stream, gi->dictLang );
stream_putU16( stream, gi->gameSeconds );

View file

@ -649,7 +649,7 @@ setStreamVersion( ServerCtxt* server )
streamVersion = devVersion;
}
}
XP_LOGF( "%s: setting streamVersion: %d", __func__, streamVersion );
XP_LOGF( "%s: setting streamVersion: 0x%x", __func__, streamVersion );
server->nv.streamVersion = streamVersion;
}