remove global.data_version from border.read

remove global.encoding
github issue #479
This commit is contained in:
Enno Rehling 2016-02-13 14:29:44 +01:00
parent 3e584245c0
commit 73a6b96bc7
6 changed files with 15 additions and 16 deletions

View File

@ -101,8 +101,7 @@ static int tolua_storage_tostring(lua_State * L)
{
gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0);
char name[64];
_snprintf(name, sizeof(name), "<storage enc=%d ver=%d>", data->encoding,
data->version);
_snprintf(name, sizeof(name), "<gamedata %p ver=%d>", data, data->version);
lua_pushstring(L, name);
return 1;
}

View File

@ -218,8 +218,9 @@ border_type *find_bordertype(const char *name)
return bt;
}
void b_read(connection * b, storage * store)
void b_read(connection * b, gamedata * data)
{
storage * store = data->store;
int n, result = 0;
switch (b->type->datatype) {
case VAR_NONE:
@ -530,8 +531,9 @@ static const char *b_nameroad(const connection * b, const region * r,
return buffer;
}
static void b_readroad(connection * b, storage * store)
static void b_readroad(connection * b, gamedata * data)
{
storage * store = data->store;
int n;
READ_INT(store, &n);
b->data.sa[0] = (short)n;
@ -657,8 +659,9 @@ int read_borders(gamedata *data)
nextborder--; /* new_border erhöht den Wert */
b->id = bid;
assert(bid <= nextborder);
if (type->read)
type->read(b, store);
if (type->read) {
type->read(b, data);
}
if (data->version < NOBORDERATTRIBS_VERSION) {
attrib *a = NULL;
int result = read_attribs(data, &a, b);

View File

@ -53,7 +53,7 @@ extern "C" {
/* constructor: initialize the connection. allocate extra memory if needed */
void(*destroy) (connection *);
/* destructor: remove all extra memory for destruction */
void(*read) (connection *, struct storage *);
void(*read) (connection *, struct gamedata *);
void(*write) (const connection *, struct storage *);
bool(*block) (const connection *, const struct unit *,
const struct region * r);
@ -119,7 +119,7 @@ extern "C" {
void age_borders(void);
/* provide default implementations for some member functions: */
void b_read(connection * b, struct storage *store);
void b_read(connection * b, struct gamedata *store);
void b_write(const connection * b, struct storage *store);
bool b_blockall(const connection *, const struct unit *,
const struct region *);

View File

@ -1498,7 +1498,6 @@ int readgame(const char *filename, bool backup)
assert(gdata.version >= MIN_VERSION || !"unsupported data format");
assert(gdata.version <= MAX_VERSION || !"unsupported data format");
gdata.encoding = enc_gamedata;
fstream_init(&strm, F);
binstore_init(&store, &strm);
gdata.store = &store;
@ -1834,7 +1833,6 @@ int writegame(const char *filename)
}
gdata.store = &store;
gdata.encoding = enc_gamedata;
gdata.version = RELEASE_VERSION;
global.data_version = RELEASE_VERSION; // FIXME: no code that is writing should need this
n = STREAM_VERSION;

View File

@ -174,15 +174,15 @@ static void wall_destroy(connection * b)
free(b->data.v);
}
static void wall_read(connection * b, storage * store)
static void wall_read(connection * b, gamedata * data)
{
static wall_data dummy;
wall_data *fd = b->data.v ? (wall_data *)b->data.v : &dummy;
read_reference(&fd->mage, store, read_unit_reference, resolve_unit);
READ_INT(store, &fd->force);
if (global.data_version >= NOBORDERATTRIBS_VERSION) {
READ_INT(store, &fd->countdown);
read_reference(&fd->mage, data->store, read_unit_reference, resolve_unit);
READ_INT(data->store, &fd->force);
if (data->version >= NOBORDERATTRIBS_VERSION) {
READ_INT(data->store, &fd->countdown);
}
fd->active = true;
}

View File

@ -11,7 +11,6 @@ typedef struct gamedata {
struct storage *store;
stream strm;
int version;
int encoding;
} gamedata;
void gamedata_init(gamedata *data, struct storage *store, int version);