reject: Move reject state from struct natstr to rejectstr
Reject state is relatively bulky: it's a big chunk of struct natstr, and adds almost 200 bytes per country to xdump nat. Reject state changes rarely. Rewriting it to disk on every nation update and retransmitting it in every xdump nat is wasteful. To avoid this waste, move reject state to its own struct rejectstr. This is of course an xdump compatibility break. We're not maintaining xdump compatibility in this release. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
f35f16c0a2
commit
eaa678c903
18 changed files with 149 additions and 150 deletions
|
@ -93,7 +93,7 @@ int
|
|||
nat_accepts(struct natstr *np, natid them, enum rej_comm what)
|
||||
{
|
||||
return getnatp(them)->nat_stat == STAT_GOD
|
||||
|| !(np->nat_rejects[them] & bit(what));
|
||||
|| !(getrejectp(np->nat_cnum)->rej_rejects[them] & bit(what));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -638,8 +638,6 @@ struct castr cou_ca[] = {
|
|||
EF_BAD, 0, CA_DUMP},
|
||||
{"relations", fldoff(nat_relate), NSC_UCHAR, MAXNOC, NULL,
|
||||
EF_NATION_RELATIONS, NSC_HIDDEN, CA_DUMP_NONE},
|
||||
{"rejects", fldoff(nat_rejects), NSC_UCHAR, MAXNOC, NULL,
|
||||
EF_NATION_REJECTS, NSC_BITS, CA_DUMP_NONE},
|
||||
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0, CA_DUMP}
|
||||
#undef CURSTR
|
||||
};
|
||||
|
@ -664,6 +662,8 @@ struct castr reject_ca[] = {
|
|||
{"uid", fldoff(rej_uid), NSC_INT, 0, NULL, EF_REJECT, 0, CA_DUMP},
|
||||
{"timestamp", fldoff(rej_timestamp), NSC_TIME, 0, NULL,
|
||||
EF_BAD, 0, CA_DUMP_NONE},
|
||||
{"rejects", fldoff(rej_rejects), NSC_UCHAR, MAXNOC, NULL,
|
||||
EF_NATION_REJECTS, NSC_BITS, CA_DUMP},
|
||||
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0, CA_DUMP}
|
||||
#undef CURSTR
|
||||
};
|
||||
|
|
|
@ -134,13 +134,13 @@ setcont(natid us, natid them, int contact)
|
|||
void
|
||||
setrej(natid us, natid them, int reject, enum rej_comm what)
|
||||
{
|
||||
struct natstr *np = getnatp(us);
|
||||
struct rejectstr *rejp = getrejectp(us);
|
||||
|
||||
if (CANT_HAPPEN(!np))
|
||||
if (CANT_HAPPEN(!rejp))
|
||||
return;
|
||||
if (reject)
|
||||
np->nat_rejects[them] |= bit(what);
|
||||
rejp->rej_rejects[them] |= bit(what);
|
||||
else
|
||||
np->nat_rejects[them] &= ~bit(what);
|
||||
putnat(np);
|
||||
rejp->rej_rejects[them] &= ~bit(what);
|
||||
putreject(rejp);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue