forked from github/server
can read and write struct allies.
This commit is contained in:
parent
a26438c175
commit
54307d3b50
2 changed files with 10 additions and 6 deletions
|
@ -105,16 +105,20 @@ void allies_write(gamedata * data, const allies *alist)
|
||||||
write_faction_reference(NULL, data->store);
|
write_faction_reference(NULL, data->store);
|
||||||
}
|
}
|
||||||
|
|
||||||
void allies_read(gamedata * data, allies **sfp)
|
void allies_read(gamedata * data, allies **p_al)
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int aid, state;
|
faction *f;
|
||||||
|
int aid, status;
|
||||||
READ_INT(data->store, &aid);
|
READ_INT(data->store, &aid);
|
||||||
/* TODO: deal with unresolved factions, somehow */
|
/* TODO: deal with unresolved factions, somehow */
|
||||||
if (aid >=0) {
|
if (aid <= 0) {
|
||||||
break;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ static void test_ally(CuTest * tc)
|
||||||
test_teardown();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_allies_clone(CuTest * tc)
|
static void test_ally_clone(CuTest * tc)
|
||||||
{
|
{
|
||||||
struct ally * al = NULL, *ac;
|
struct ally * al = NULL, *ac;
|
||||||
struct faction * f;
|
struct faction * f;
|
||||||
|
@ -63,8 +63,8 @@ CuSuite *get_ally_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_ally);
|
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);
|
||||||
SUITE_ADD_TEST(suite, test_allies_clone);
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue