version now part of stream

This commit is contained in:
ehouse 2004-06-24 05:19:31 +00:00
parent 6e5067c01d
commit 173eba64e3
4 changed files with 34 additions and 4 deletions

View file

@ -148,7 +148,9 @@ game_makeFromStream( MPFORMAL XWStreamCtxt* stream, XWGame* game,
strVersion = stream_getU8( stream );
XP_DEBUGF( "strVersion = %d", (XP_U16)strVersion );
gi_readFromStream( MPPARM(mpool) stream, strVersion, gi );
stream_setVersion( stream, strVersion );
gi_readFromStream( MPPARM(mpool) stream, gi );
#ifndef XWFEATURE_STANDALONE_ONLY
hasComms = stream_getU8( stream );
@ -312,12 +314,12 @@ gi_copy( MPFORMAL CurGameInfo* destGI, CurGameInfo* srcGI )
} /* gi_copy */
void
gi_readFromStream( MPFORMAL XWStreamCtxt* stream, XP_U16 strVersion,
CurGameInfo* gi )
gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi )
{
LocalPlayer* pl;
XP_U16 i;
XP_UCHAR* str;
XP_U16 strVersion = stream_getVersion( stream );
str = stringFromStream( MPPARM(mpool) stream );
replaceStringIfDifferent( MPPARM(mpool) &gi->dictName, str );

View file

@ -47,6 +47,7 @@ extern "C" {
MemStreamCloseCallback onClose; \
XP_U16 nBytesWritten; \
XP_U16 nBytesAllocated; \
XP_U16 version; \
XP_U8 nReadBits; \
XP_U8 nWriteBits; \
XP_Bool isOpen; \
@ -326,6 +327,21 @@ mem_stream_setAddress( XWStreamCtxt* p_sctx, XP_PlayerAddr channelNo )
stream->channelNo = channelNo;
} /* mem_stream_getAddress */
static void
mem_stream_setVersion( XWStreamCtxt* p_sctx, XP_U16 vers )
{
MemStreamCtxt* stream = (MemStreamCtxt*)p_sctx;
stream->version = vers;
} /* mem_stream_setVersion */
static XP_U16
mem_stream_getVersion( XWStreamCtxt* p_sctx )
{
MemStreamCtxt* stream = (MemStreamCtxt*)p_sctx;
return stream->version;
} /* mem_stream_getVersion */
static XWStreamPos
mem_stream_getPos( XWStreamCtxt* p_sctx, PosWhich which )
{
@ -408,6 +424,9 @@ make_vtable( MemStreamCtxt* stream )
SET_VTABLE_ENTRY( vtable, stream_getAddress, mem );
SET_VTABLE_ENTRY( vtable, stream_setAddress, mem );
SET_VTABLE_ENTRY( vtable, stream_setVersion, mem );
SET_VTABLE_ENTRY( vtable, stream_getVersion, mem );
return vtable;
} /* make_vtable */

View file

@ -918,6 +918,7 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream )
if ( streamVersion != CUR_STREAM_VERS ) {
return XP_FALSE;
}
stream_setVersion( stream, streamVersion );
gameID = stream_getBits( stream, 32 );
XP_STATUSF( "read gameID of %ld; calling comms_setConnID", gameID );
@ -925,7 +926,7 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream )
comms_setConnID( server->vol.comms, gameID );
XP_MEMSET( &localGI, 0, sizeof(localGI) );
gi_readFromStream( MPPARM(server->mpool) stream, streamVersion, &localGI );
gi_readFromStream( MPPARM(server->mpool) stream, &localGI );
localGI.serverRole = SERVER_ISCLIENT;
/* so it's not lost (HACK!). Without this, a client won't have a default

View file

@ -65,6 +65,8 @@ typedef struct StreamCtxVTable {
XP_PlayerAddr (*m_stream_getAddress)( XWStreamCtxt* dctx );
void (*m_stream_setAddress)( XWStreamCtxt* dctx, XP_PlayerAddr channelNo );
void (*m_stream_setVersion)( XWStreamCtxt* dctx, XP_U16 vers );
XP_U16 (*m_stream_getVersion)( XWStreamCtxt* dctx );
} StreamCtxVTable;
@ -133,4 +135,10 @@ struct XWStreamCtxt {
#define stream_setAddress(sc,ch) \
(sc)->vtable->m_stream_setAddress((sc),(ch))
#define stream_setVersion(sc,ch) \
(sc)->vtable->m_stream_setVersion((sc),(ch))
#define stream_getVersion(sc) \
(sc)->vtable->m_stream_getVersion((sc))
#endif /* _XWSTREAM_H_ */