forked from github/server
do not use late resolution for factions, ever
This commit is contained in:
parent
da3b21d59b
commit
d9167b8a59
6 changed files with 9 additions and 20 deletions
|
@ -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;
|
||||
|
|
|
@ -54,7 +54,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <util/parser.h>
|
||||
#include <util/password.h>
|
||||
#include <util/path.h>
|
||||
#include <util/resolve.h>
|
||||
#include <util/rng.h>
|
||||
#include <util/strings.h>
|
||||
#include <util/variant.h>
|
||||
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue