contact: Move contact state from struct natstr to contactstr
Contact state is relatively bulky: it's a big chunk of struct natstr, and adds almost 200 bytes per country to xdump nat for deities. Contact changes rarely. Since we avoid unnecessary updates, it doesn't change at all unless option HIDDEN is enabled. Rewriting it to disk on every nation update and retransmitting it in every deity xdump nat is wasteful. To avoid this waste, move contact state to its own struct contactstr. 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
4b4df53485
commit
c8e7548f24
19 changed files with 141 additions and 132 deletions
|
@ -29,7 +29,7 @@
|
|||
* Known contributors to this file:
|
||||
* Dave Pare, 1989
|
||||
* Ron Koenderink, 2005
|
||||
* Markus Armbruster, 2006-2011
|
||||
* Markus Armbruster, 2006-2016
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -98,19 +98,21 @@ getrejects(natid them, struct natstr *np)
|
|||
void
|
||||
agecontact(struct natstr *np)
|
||||
{
|
||||
struct contactstr con;
|
||||
int them;
|
||||
|
||||
getcontact(np->nat_cnum, &con);
|
||||
|
||||
for (them = 1; them < MAXNOC; ++them) {
|
||||
if (them != np->nat_cnum && np->nat_contact[them]) {
|
||||
--np->nat_contact[them];
|
||||
}
|
||||
if (them != np->nat_cnum && con.con_contact[them])
|
||||
con.con_contact[them]--;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
in_contact(struct natstr *np, natid them)
|
||||
{
|
||||
return np->nat_contact[them];
|
||||
return getcontactp(np->nat_cnum)->con_contact[them];
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue