mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
deal with older stream version
This commit is contained in:
parent
f210af7da3
commit
8991604df6
1 changed files with 18 additions and 5 deletions
|
@ -24,6 +24,7 @@
|
||||||
#include "comms.h"
|
#include "comms.h"
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "game.h"
|
||||||
#include "xwstream.h"
|
#include "xwstream.h"
|
||||||
#include "memstream.h"
|
#include "memstream.h"
|
||||||
|
|
||||||
|
@ -51,6 +52,8 @@ typedef struct AddressRecord {
|
||||||
XP_PlayerAddr channelNo;
|
XP_PlayerAddr channelNo;
|
||||||
} AddressRecord;
|
} AddressRecord;
|
||||||
|
|
||||||
|
#define ADDRESSRECORD_SIZE_68K 20
|
||||||
|
|
||||||
struct CommsCtxt {
|
struct CommsCtxt {
|
||||||
XW_UtilCtxt* util;
|
XW_UtilCtxt* util;
|
||||||
|
|
||||||
|
@ -206,11 +209,21 @@ comms_makeFromStream( MPFORMAL XWStreamCtxt* stream, XW_UtilCtxt* util,
|
||||||
XP_MEMSET( rec, 0, sizeof(*rec) );
|
XP_MEMSET( rec, 0, sizeof(*rec) );
|
||||||
|
|
||||||
addr = &rec->addr;
|
addr = &rec->addr;
|
||||||
|
|
||||||
|
if ( stream_getVersion(stream) <= STREAM_VERS_405 ) {
|
||||||
|
unsigned char trash[ADDRESSRECORD_SIZE_68K];
|
||||||
|
/* Older versions used sizeof and wrote out the whole struct using
|
||||||
|
stream_putBytes. Size under 68K was 20. */
|
||||||
|
/* now discard the bytes */
|
||||||
|
stream_getBytes( stream, trash, ADDRESSRECORD_SIZE_68K );
|
||||||
|
addr->conType = COMMS_CONN_IR;
|
||||||
|
} else {
|
||||||
addr->conType = stream_getU8( stream );
|
addr->conType = stream_getU8( stream );
|
||||||
if ( addr->conType == COMMS_CONN_IP ) {
|
if ( addr->conType == COMMS_CONN_IP ) {
|
||||||
addr->u.ip.ipAddr = stream_getU32( stream );
|
addr->u.ip.ipAddr = stream_getU32( stream );
|
||||||
addr->u.ip.port = stream_getU16( stream );
|
addr->u.ip.port = stream_getU16( stream );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rec->nextMsgID = stream_getU16( stream );
|
rec->nextMsgID = stream_getU16( stream );
|
||||||
rec->lastMsgReceived = stream_getU16( stream );
|
rec->lastMsgReceived = stream_getU16( stream );
|
||||||
|
|
Loading…
Reference in a new issue