can read and write struct allies.

This commit is contained in:
Enno Rehling 2018-10-30 18:45:13 +01:00
parent a26438c175
commit 54307d3b50
2 changed files with 10 additions and 6 deletions

View file

@ -105,16 +105,20 @@ void allies_write(gamedata * data, const allies *alist)
write_faction_reference(NULL, data->store);
}
void allies_read(gamedata * data, allies **sfp)
void allies_read(gamedata * data, allies **p_al)
{
for (;;) {
int aid, state;
faction *f;
int aid, status;
READ_INT(data->store, &aid);
/* TODO: deal with unresolved factions, somehow */
if (aid >=0) {
if (aid <= 0) {
break;
}
READ_INT(data->store, &state);
f = findfaction(aid);
if (!f) f = faction_create(aid);
READ_INT(data->store, &status);
allies_set(p_al, f, status);
}
}

View file

@ -23,7 +23,7 @@ static void test_ally(CuTest * tc)
test_teardown();
}
static void test_allies_clone(CuTest * tc)
static void test_ally_clone(CuTest * tc)
{
struct ally * al = NULL, *ac;
struct faction * f;
@ -63,8 +63,8 @@ CuSuite *get_ally_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_ally);
SUITE_ADD_TEST(suite, test_ally_clone);
SUITE_ADD_TEST(suite, test_allies);
SUITE_ADD_TEST(suite, test_allies_clone);
return suite;
}