do not use late resolution for factions, ever

This commit is contained in:
Enno Rehling 2018-11-01 09:53:23 +01:00
parent da3b21d59b
commit d9167b8a59
6 changed files with 9 additions and 20 deletions

View file

@ -98,7 +98,7 @@ static int obs_read(variant *var, void *owner, struct gamedata *data)
obs_data *od = (obs_data *)var->v; obs_data *od = (obs_data *)var->v;
UNUSED_ARG(owner); 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->skill);
READ_INT(data->store, &od->timer); READ_INT(data->store, &od->timer);
return AT_READ_OK; return AT_READ_OK;

View file

@ -54,7 +54,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/parser.h> #include <util/parser.h>
#include <util/password.h> #include <util/password.h>
#include <util/path.h> #include <util/path.h>
#include <util/resolve.h>
#include <util/rng.h> #include <util/rng.h>
#include <util/strings.h> #include <util/strings.h>
#include <util/variant.h> #include <util/variant.h>
@ -331,20 +330,14 @@ bool checkpasswd(const faction * f, const char *passwd)
return true; return true;
} }
void resolve_faction(faction *f) int read_faction_reference(gamedata * data, faction **fp)
{
resolve(RESOLVE_FACTION | f->no, f);
}
int read_faction_reference(gamedata * data, faction **fp, resolve_fun fun)
{ {
int id; int id;
READ_INT(data->store, &id); READ_INT(data->store, &id);
if (id > 0) { if (id > 0) {
*fp = findfaction(id); *fp = findfaction(id);
if (*fp == NULL) { if (*fp == NULL) {
*fp = NULL; *fp = faction_create(id);
ur_add(RESOLVE_FACTION | id, (void **)fp, fun);
} }
} }
else { else {

View file

@ -133,10 +133,7 @@ extern "C" {
void write_faction_reference(const struct faction *f, void write_faction_reference(const struct faction *f,
struct storage *store); struct storage *store);
int read_faction_reference(struct gamedata *data, struct faction **fp, resolve_fun fun); int read_faction_reference(struct gamedata *data, struct faction **fp);
#define RESOLVE_FACTION (TYP_FACTION << 24)
void resolve_faction(struct faction *f);
void renumber_faction(faction * f, int no); void renumber_faction(faction * f, int no);
void free_factions(void); void free_factions(void);

View file

@ -123,7 +123,7 @@ static void read_alliances(gamedata *data)
READ_INT(store, &al->flags); READ_INT(store, &al->flags);
} }
if (data->version >= ALLIANCELEADER_VERSION) { if (data->version >= ALLIANCELEADER_VERSION) {
read_faction_reference(data, &al->_leader, NULL); read_faction_reference(data, &al->_leader);
READ_INT(store, &id); READ_INT(store, &id);
} }
else { else {
@ -248,7 +248,7 @@ static void read_owner(gamedata *data, region_owner ** powner)
owner->flags = 0; owner->flags = 0;
} }
if (data->version >= OWNER_3_VERSION) { 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) { else if (data->version >= OWNER_2_VERSION) {
int id; int id;
@ -261,7 +261,7 @@ static void read_owner(gamedata *data, region_owner ** powner)
else { else {
owner->last_owner = NULL; owner->last_owner = NULL;
} }
read_faction_reference(data, &owner->owner, NULL); read_faction_reference(data, &owner->owner);
*powner = owner; *powner = owner;
} }
else { else {
@ -1087,7 +1087,6 @@ faction *read_faction(gamedata * data)
if (data->version >= REGIONOWNER_VERSION) { if (data->version >= REGIONOWNER_VERSION) {
read_spellbook(FactionSpells() ? &f->spellbook : 0, data, get_spell_level_faction, (void *)f); read_spellbook(FactionSpells() ? &f->spellbook : 0, data, get_spell_level_faction, (void *)f);
} }
resolve_faction(f);
return f; return f;
} }

View file

@ -87,7 +87,7 @@ static int changefaction_read(trigger * t, gamedata *data)
changefaction_data *td = (changefaction_data *)t->data.v; changefaction_data *td = (changefaction_data *)t->data.v;
read_unit_reference(data, &td->unit, NULL); 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 = { trigger_type tt_changefaction = {

View file

@ -94,7 +94,7 @@ static int createunit_read(trigger * t, gamedata *data)
int id; int id;
int result = AT_READ_OK; int result = AT_READ_OK;
id = read_faction_reference(data, &td->f, NULL); id = read_faction_reference(data, &td->f);
if (id <= 0) { if (id <= 0) {
result = AT_READ_FAIL; result = AT_READ_FAIL;
} }