use const where possible for game_writeToStream and others it calls.

No other code changes.
This commit is contained in:
Eric House 2012-03-11 18:28:14 -07:00
parent 2a728ce4b0
commit f51c0b39e6
8 changed files with 26 additions and 25 deletions

View file

@ -288,7 +288,7 @@ board_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model,
} /* board_makeFromStream */
void
board_writeToStream( BoardCtxt* board, XWStreamCtxt* stream )
board_writeToStream( const BoardCtxt* board, XWStreamCtxt* stream )
{
XP_U16 nPlayers, ii;
XP_U16 nColsNBits;
@ -319,8 +319,8 @@ board_writeToStream( BoardCtxt* board, XWStreamCtxt* stream )
nPlayers = board->gi->nPlayers;
for ( ii = 0; ii < nPlayers; ++ii ) {
PerTurnInfo* pti = &board->pti[ii];
BoardArrow* arrow = &pti->boardArrow;
const PerTurnInfo* pti = &board->pti[ii];
const BoardArrow* arrow = &pti->boardArrow;
stream_putBits( stream, nColsNBits, arrow->col );
stream_putBits( stream, nColsNBits, arrow->row );
stream_putBits( stream, 1, arrow->vert );

View file

@ -67,7 +67,7 @@ BoardCtxt* board_makeFromStream( MPFORMAL XWStreamCtxt* stream,
void board_destroy( BoardCtxt* board );
void board_writeToStream( BoardCtxt* board, XWStreamCtxt* stream );
void board_writeToStream( const BoardCtxt* board, XWStreamCtxt* stream );
void board_setPos( BoardCtxt* board, XP_U16 left, XP_U16 top,
XP_U16 width, XP_U16 height, XP_U16 maxCellSize,

View file

@ -333,7 +333,7 @@ mem_stream_close( XWStreamCtxt* p_sctx )
static XP_U16
mem_stream_getSize( const XWStreamCtxt* p_sctx )
{
MemStreamCtxt* stream = (MemStreamCtxt*)p_sctx;
const MemStreamCtxt* stream = (const MemStreamCtxt*)p_sctx;
XP_U16 size = stream->nBytesWritten - stream->curReadPos;
return size;
} /* mem_stream_getSize */
@ -341,14 +341,14 @@ mem_stream_getSize( const XWStreamCtxt* p_sctx )
static const XP_U8*
mem_stream_getPtr( const XWStreamCtxt* p_sctx )
{
MemStreamCtxt* stream = (MemStreamCtxt*)p_sctx;
const MemStreamCtxt* stream = (const MemStreamCtxt*)p_sctx;
return stream->buf;
} /* mem_stream_getPtr */
static XP_PlayerAddr
mem_stream_getAddress( XWStreamCtxt* p_sctx )
mem_stream_getAddress( const XWStreamCtxt* p_sctx )
{
MemStreamCtxt* stream = (MemStreamCtxt*)p_sctx;
const MemStreamCtxt* stream = (const MemStreamCtxt*)p_sctx;
return stream->channelNo;
} /* mem_stream_getAddress */
@ -357,7 +357,7 @@ mem_stream_setAddress( XWStreamCtxt* p_sctx, XP_PlayerAddr channelNo )
{
MemStreamCtxt* stream = (MemStreamCtxt*)p_sctx;
stream->channelNo = channelNo;
} /* mem_stream_getAddress */
} /* mem_stream_setAddress */
static void
mem_stream_setVersion( XWStreamCtxt* p_sctx, XP_U16 vers )
@ -367,9 +367,9 @@ mem_stream_setVersion( XWStreamCtxt* p_sctx, XP_U16 vers )
} /* mem_stream_setVersion */
static XP_U16
mem_stream_getVersion( XWStreamCtxt* p_sctx )
mem_stream_getVersion( const XWStreamCtxt* p_sctx )
{
MemStreamCtxt* stream = (MemStreamCtxt*)p_sctx;
const MemStreamCtxt* stream = (const MemStreamCtxt*)p_sctx;
return stream->version;
} /* mem_stream_getVersion */
@ -381,10 +381,10 @@ mem_stream_setOnCloseProc( XWStreamCtxt* p_sctx, MemStreamCloseCallback proc )
}
static XWStreamPos
mem_stream_getPos( XWStreamCtxt* p_sctx, PosWhich which )
mem_stream_getPos( const XWStreamCtxt* p_sctx, PosWhich which )
{
XWStreamPos result;
MemStreamCtxt* stream = (MemStreamCtxt*)p_sctx;
const MemStreamCtxt* stream = (const MemStreamCtxt*)p_sctx;
if ( which == POS_WRITE ) {
result = (stream->curWritePos << 3) | stream->nWriteBits;

View file

@ -74,7 +74,7 @@ static void setPendingCounts( ModelCtxt* model, XP_S16 turn );
static void loadPlayerCtxt( const ModelCtxt* model, XWStreamCtxt* stream,
XP_U16 version, PlayerCtxt* pc );
static void writePlayerCtxt( const ModelCtxt* model, XWStreamCtxt* stream,
PlayerCtxt* pc );
const PlayerCtxt* pc );
static XP_U16 model_getRecentPassCount( ModelCtxt* model );
static XP_Bool recordWord( const XP_UCHAR* word, XP_Bool isLegal,
#ifdef XWFEATURE_BOARDWORDS
@ -179,7 +179,7 @@ model_makeFromStream( MPFORMAL XWStreamCtxt* stream, DictionaryCtxt* dict,
} /* model_makeFromStream */
void
model_writeToStream( ModelCtxt* model, XWStreamCtxt* stream )
model_writeToStream( const ModelCtxt* model, XWStreamCtxt* stream )
{
XP_U16 ii;
#ifdef STREAM_VERS_BIGBOARD
@ -2376,10 +2376,11 @@ loadPlayerCtxt( const ModelCtxt* model, XWStreamCtxt* stream, XP_U16 version,
} /* loadPlayerCtxt */
static void
writePlayerCtxt( const ModelCtxt* model, XWStreamCtxt* stream, PlayerCtxt* pc )
writePlayerCtxt( const ModelCtxt* model, XWStreamCtxt* stream,
const PlayerCtxt* pc )
{
XP_U16 nTiles;
PendingTile* pt;
const PendingTile* pt;
XP_U16 nColsNBits;
#ifdef STREAM_VERS_BIGBOARD
nColsNBits = 16 <= model_numCols( model ) ? NUMCOLS_NBITS_5

View file

@ -106,7 +106,7 @@ ModelCtxt* model_makeFromStream( MPFORMAL XWStreamCtxt* stream,
DictionaryCtxt* dict, const PlayerDicts* dicts,
XW_UtilCtxt* util );
void model_writeToStream( ModelCtxt* model, XWStreamCtxt* stream );
void model_writeToStream( const ModelCtxt* model, XWStreamCtxt* stream );
#ifdef TEXT_MODEL
void model_writeToTextStream( const ModelCtxt* model, XWStreamCtxt* stream );

View file

@ -305,7 +305,7 @@ getNV( XWStreamCtxt* stream, ServerNonvolatiles* nv, XP_U16 nPlayers )
} /* getNV */
static void
putNV( XWStreamCtxt* stream, ServerNonvolatiles* nv, XP_U16 nPlayers )
putNV( XWStreamCtxt* stream, const ServerNonvolatiles* nv, XP_U16 nPlayers )
{
XP_U16 ii;
@ -401,7 +401,7 @@ server_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model,
} /* server_makeFromStream */
void
server_writeToStream( ServerCtxt* server, XWStreamCtxt* stream )
server_writeToStream( const ServerCtxt* server, XWStreamCtxt* stream )
{
XP_U16 i;
XP_U16 nPlayers = server->vol.gi->nPlayers;
@ -414,7 +414,7 @@ server_writeToStream( ServerCtxt* server, XWStreamCtxt* stream )
}
for ( i = 0; i < nPlayers; ++i ) {
ServerPlayer* player = &server->players[i];
const ServerPlayer* player = &server->players[i];
stream_putU8( stream, player->deviceIndex );

View file

@ -62,7 +62,7 @@ ServerCtxt* server_makeFromStream( MPFORMAL XWStreamCtxt* stream,
ModelCtxt* model, CommsCtxt* comms,
XW_UtilCtxt* util, XP_U16 nPlayers );
void server_writeToStream( ServerCtxt* server, XWStreamCtxt* stream );
void server_writeToStream( const ServerCtxt* server, XWStreamCtxt* stream );
void server_reset( ServerCtxt* server, CommsCtxt* comms );
void server_destroy( ServerCtxt* server );

View file

@ -61,7 +61,7 @@ typedef struct StreamCtxVTable {
void (*m_stream_getFromStream)( XWStreamCtxt* dctx, XWStreamCtxt* src,
XP_U16 nBytes );
XWStreamPos (*m_stream_getPos)( XWStreamCtxt* dctx, PosWhich which );
XWStreamPos (*m_stream_getPos)( const XWStreamCtxt* dctx, PosWhich which );
XWStreamPos (*m_stream_setPos)( XWStreamCtxt* dctx, PosWhich which,
XWStreamPos newpos );
@ -75,11 +75,11 @@ typedef struct StreamCtxVTable {
/* void (*m_stream_makeReturnAddr)( XWStreamCtxt* dctx, XP_PlayerAddr* addr, */
/* XP_U16* addrLen ); */
XP_PlayerAddr (*m_stream_getAddress)( XWStreamCtxt* dctx );
XP_PlayerAddr (*m_stream_getAddress)( const 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 );
XP_U16 (*m_stream_getVersion)( const XWStreamCtxt* dctx );
void (*m_stream_setOnCloseProc)( XWStreamCtxt* dctx,
MemStreamCloseCallback proc );