From d9167b8a5919f97a78afd7e24c36bbb5d5b0ae09 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 1 Nov 2018 09:53:23 +0100 Subject: [PATCH] do not use late resolution for factions, ever --- src/attributes/attributes.c | 2 +- src/kernel/faction.c | 11 ++--------- src/kernel/faction.h | 5 +---- src/kernel/save.c | 7 +++---- src/triggers/changefaction.c | 2 +- src/triggers/createunit.c | 2 +- 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/attributes/attributes.c b/src/attributes/attributes.c index 400282ae7..12cb9131f 100644 --- a/src/attributes/attributes.c +++ b/src/attributes/attributes.c @@ -98,7 +98,7 @@ static int obs_read(variant *var, void *owner, struct gamedata *data) obs_data *od = (obs_data *)var->v; UNUSED_ARG(owner); - read_faction_reference(data, &od->f, NULL); + read_faction_reference(data, &od->f); READ_INT(data->store, &od->skill); READ_INT(data->store, &od->timer); return AT_READ_OK; diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 9265d4a8e..f36ef5f8c 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -54,7 +54,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include #include #include #include @@ -331,20 +330,14 @@ bool checkpasswd(const faction * f, const char *passwd) return true; } -void resolve_faction(faction *f) -{ - resolve(RESOLVE_FACTION | f->no, f); -} - -int read_faction_reference(gamedata * data, faction **fp, resolve_fun fun) +int read_faction_reference(gamedata * data, faction **fp) { int id; READ_INT(data->store, &id); if (id > 0) { *fp = findfaction(id); if (*fp == NULL) { - *fp = NULL; - ur_add(RESOLVE_FACTION | id, (void **)fp, fun); + *fp = faction_create(id); } } else { diff --git a/src/kernel/faction.h b/src/kernel/faction.h index 04070c91a..0c579603a 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -133,10 +133,7 @@ extern "C" { void write_faction_reference(const struct faction *f, struct storage *store); - int read_faction_reference(struct gamedata *data, struct faction **fp, resolve_fun fun); - -#define RESOLVE_FACTION (TYP_FACTION << 24) - void resolve_faction(struct faction *f); + int read_faction_reference(struct gamedata *data, struct faction **fp); void renumber_faction(faction * f, int no); void free_factions(void); diff --git a/src/kernel/save.c b/src/kernel/save.c index 8c4b408c9..928c1938a 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -123,7 +123,7 @@ static void read_alliances(gamedata *data) READ_INT(store, &al->flags); } if (data->version >= ALLIANCELEADER_VERSION) { - read_faction_reference(data, &al->_leader, NULL); + read_faction_reference(data, &al->_leader); READ_INT(store, &id); } else { @@ -248,7 +248,7 @@ static void read_owner(gamedata *data, region_owner ** powner) owner->flags = 0; } if (data->version >= OWNER_3_VERSION) { - read_faction_reference(data, &owner->last_owner, NULL); + read_faction_reference(data, &owner->last_owner); } else if (data->version >= OWNER_2_VERSION) { int id; @@ -261,7 +261,7 @@ static void read_owner(gamedata *data, region_owner ** powner) else { owner->last_owner = NULL; } - read_faction_reference(data, &owner->owner, NULL); + read_faction_reference(data, &owner->owner); *powner = owner; } else { @@ -1087,7 +1087,6 @@ faction *read_faction(gamedata * data) if (data->version >= REGIONOWNER_VERSION) { read_spellbook(FactionSpells() ? &f->spellbook : 0, data, get_spell_level_faction, (void *)f); } - resolve_faction(f); return f; } diff --git a/src/triggers/changefaction.c b/src/triggers/changefaction.c index 8aa73168d..8b1ead479 100644 --- a/src/triggers/changefaction.c +++ b/src/triggers/changefaction.c @@ -87,7 +87,7 @@ static int changefaction_read(trigger * t, gamedata *data) changefaction_data *td = (changefaction_data *)t->data.v; read_unit_reference(data, &td->unit, NULL); - return read_faction_reference(data, &td->faction, NULL) > 0 ? AT_READ_OK : AT_READ_FAIL; + return read_faction_reference(data, &td->faction) > 0 ? AT_READ_OK : AT_READ_FAIL; } trigger_type tt_changefaction = { diff --git a/src/triggers/createunit.c b/src/triggers/createunit.c index d4dd8f983..5adabc7ea 100644 --- a/src/triggers/createunit.c +++ b/src/triggers/createunit.c @@ -94,7 +94,7 @@ static int createunit_read(trigger * t, gamedata *data) int id; int result = AT_READ_OK; - id = read_faction_reference(data, &td->f, NULL); + id = read_faction_reference(data, &td->f); if (id <= 0) { result = AT_READ_FAIL; }