forked from github/server
convert another test to read_/write_game
This commit is contained in:
parent
3c272fd53f
commit
63408501b9
|
@ -1540,8 +1540,8 @@ int read_game(gamedata *data) {
|
|||
global.data_turn = turn;
|
||||
log_debug(" - reading turn %d\n", turn);
|
||||
rng_init(turn);
|
||||
READ_INT(store, &nread); /* max_unique_id = ignore */
|
||||
READ_INT(store, &nextborder);
|
||||
READ_INT(store, NULL); /* max_unique_id = ignore */
|
||||
READ_INT(store, NULL);
|
||||
|
||||
/* Planes */
|
||||
planes = NULL;
|
||||
|
@ -1619,7 +1619,7 @@ int read_game(gamedata *data) {
|
|||
/* Regionen */
|
||||
|
||||
READ_INT(store, &nread);
|
||||
assert(nread < MAXREGIONS);
|
||||
assert(nread < MAXREGIONS && nread>=0);
|
||||
if (rmax < 0) {
|
||||
rmax = nread;
|
||||
}
|
||||
|
@ -1884,7 +1884,7 @@ int write_game(gamedata *data) {
|
|||
|
||||
WRITE_INT(store, turn);
|
||||
WRITE_INT(store, 0 /* max_unique_id */);
|
||||
WRITE_INT(store, nextborder);
|
||||
WRITE_INT(store, 0 /* nextborder */);
|
||||
|
||||
/* Write planes */
|
||||
WRITE_SECTION(store);
|
||||
|
|
|
@ -152,6 +152,11 @@ static void test_readwrite_dead_faction_group(CuTest *tc) {
|
|||
static void test_readwrite_dead_faction_regionowner(CuTest *tc) {
|
||||
faction *f;
|
||||
region *r;
|
||||
gamedata data;
|
||||
storage store;
|
||||
|
||||
mstream_init(&data.strm);
|
||||
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||
|
||||
test_cleanup();
|
||||
config_set("rules.region_owners", "1");
|
||||
|
@ -161,10 +166,13 @@ static void test_readwrite_dead_faction_regionowner(CuTest *tc) {
|
|||
destroyfaction(&factions);
|
||||
CuAssertTrue(tc, !f->_alive);
|
||||
remove_empty_units();
|
||||
writegame("test.dat");
|
||||
write_game(&data);
|
||||
free_gamedata();
|
||||
f = NULL;
|
||||
readgame("test.dat", false);
|
||||
data.strm.api->rewind(data.strm.handle);
|
||||
read_game(&data);
|
||||
mstream_done(&data.strm);
|
||||
gamedata_done(&data);
|
||||
f = factions;
|
||||
CuAssertPtrEquals(tc, 0, f);
|
||||
r = regions;
|
||||
|
|
Loading…
Reference in New Issue