Don't save dict as part of model. It's redundant as the platform code

already saves the name and passes the dict in.
This commit is contained in:
ehouse 2008-09-09 12:18:32 +00:00
parent a1f3e3d174
commit 61a3602dc5
2 changed files with 11 additions and 18 deletions

View file

@ -30,13 +30,14 @@
extern "C" {
#endif
#define STREAM_VERS_MODEL_NO_DICT 0x06
#define STREAM_VERS_BLUETOOTH 0x05
#define STREAM_VERS_KEYNAV 0x04
#define STREAM_VERS_RELAY 0x03
#define STREAM_VERS_41B4 0x02
#define STREAM_VERS_405 0x01
# define CUR_STREAM_VERS STREAM_VERS_BLUETOOTH
#define CUR_STREAM_VERS STREAM_VERS_MODEL_NO_DICT
typedef struct LocalPlayer {
XP_UCHAR* name;

View file

@ -105,30 +105,28 @@ model_makeFromStream( MPFORMAL XWStreamCtxt* stream, DictionaryCtxt* dict,
XW_UtilCtxt* util )
{
ModelCtxt* model;
DictionaryCtxt* savedDict = (DictionaryCtxt*)NULL;
XP_U16 nCols, nRows;
short i;
XP_Bool hasDict;
XP_U16 nPlayers;
XP_U16 version = stream_getVersion( stream );
XP_ASSERT( !!dict );
nCols = (XP_U16)stream_getBits( stream, NUMCOLS_NBITS );
nRows = (XP_U16)stream_getBits( stream, NUMCOLS_NBITS );
hasDict = stream_getBits( stream, 1 );
hasDict = (version >= STREAM_VERS_MODEL_NO_DICT)
? XP_FALSE : stream_getBits( stream, 1 );
nPlayers = (XP_U16)stream_getBits( stream, NPLAYERS_NBITS );
if ( hasDict ) {
savedDict = util_makeEmptyDict( util );
DictionaryCtxt* savedDict = util_makeEmptyDict( util );
dict_loadFromStream( savedDict, stream );
if ( !!dict ) {
XP_ASSERT( dict_tilesAreSame( savedDict, dict ) );
dict_destroy( savedDict );
savedDict = dict;
}
dict_destroy( savedDict );
}
model = model_make( MPPARM(mpool) savedDict, util, nCols, nRows );
model = model_make( MPPARM(mpool) dict, util, nCols, nRows );
model->nPlayers = nPlayers;
stack_loadFromStream( model->vol.stack, stream );
@ -152,20 +150,13 @@ void
model_writeToStream( ModelCtxt* model, XWStreamCtxt* stream )
{
short i;
DictionaryCtxt* dict;
stream_putBits( stream, NUMCOLS_NBITS, model->nCols );
stream_putBits( stream, NUMCOLS_NBITS, model->nRows );
dict = model_getDictionary( model );
stream_putBits( stream, 1, dict != NULL );
/* we have two bits for nPlayers, so range must be 0..3, not 1..4 */
stream_putBits( stream, NPLAYERS_NBITS, model->nPlayers );
if ( dict != NULL ) {
dict_writeToStream( model_getDictionary( model ), stream );
}
stack_writeToStream( model->vol.stack, stream );
for ( i = 0; i < model->nPlayers; ++i ) {
@ -283,6 +274,7 @@ model_setDictionary( ModelCtxt* model, DictionaryCtxt* dict )
DictionaryCtxt*
model_getDictionary( ModelCtxt* model )
{
XP_ASSERT( !!model->vol.dict );
return model->vol.dict;
} /* model_getDictionary */