contact: Avoid unnecessary nation updates

Make setcont() update the nation only when it actually changes the
contact value.  For added benefit, map all non-zero values to one when
option LOSE_CONTACT is disabled.

This saves I/O, in particular xdump bandwidth.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-10-23 18:38:56 +02:00
parent 00d0664bcd
commit e61c332295

View file

@ -123,9 +123,12 @@ setcont(natid us, natid them, int contact)
if (CANT_HAPPEN(contact > 255))
contact = 255;
if (np->nat_contact[them] < contact)
if (!opt_LOSE_CONTACT)
contact = !!contact;
if (np->nat_contact[them] < contact) {
np->nat_contact[them] = contact;
putnat(np);
}
}
void