]> git.pond.sub.org Git - empserver/log
empserver
6 years agoUpdate copyright notice
Markus Armbruster [Sat, 8 Jul 2017 18:46:53 +0000 (20:46 +0200)]
Update copyright notice

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoMerge branch 'readline'
Markus Armbruster [Sat, 8 Jul 2017 18:43:29 +0000 (20:43 +0200)]
Merge branch 'readline'

6 years agorelations: Move relations state from struct natstr to relatstr
Markus Armbruster [Mon, 31 Oct 2016 17:05:07 +0000 (18:05 +0100)]
relations: Move relations state from struct natstr to relatstr

Relations state is relatively bulky: it's a big chunk of struct
natstr, and adds 200 bytes per country to xdump nat.

Relations change rarely.  Rewriting it to disk on every nation update
and retransmitting it in every xdump nat is wasteful.

To avoid this waste, move relations state to its own struct relatstr.

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>
6 years agorelations: Create EF_RELAT table of struct relatstr
Markus Armbruster [Mon, 31 Oct 2016 16:42:34 +0000 (17:42 +0100)]
relations: Create EF_RELAT table of struct relatstr

New struct relatstr is basically empty so far.  The next commit will
move relations state from struct natstr to struct relatstr.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agonat: Move putnat() into nat_reset() and simplify
Markus Armbruster [Mon, 31 Oct 2016 16:20:05 +0000 (17:20 +0100)]
nat: Move putnat() into nat_reset() and simplify

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agorelations: Eliminate getrel()
Markus Armbruster [Mon, 31 Oct 2016 14:29:21 +0000 (15:29 +0100)]
relations: Eliminate getrel()

Most uses of getrel() have been replaced by the safer relations_with()
in commit 0c60e57..67b9135, v4.3.27.  Eliminate the remaining ones:

* Convert rela() to use relations_with().  The case of relations to
  self, where the two differ, doesn't occur.  The code becomes more
  easier to understand, even.

* relations_with() is then getrel()'s last user.  Inline.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agorelations: Inline relatename() into its only caller rela()
Markus Armbruster [Mon, 31 Oct 2016 14:26:26 +0000 (15:26 +0100)]
relations: Inline relatename() into its only caller rela()

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agorelations: Encapsulate relates[] in relations_string()
Markus Armbruster [Mon, 31 Oct 2016 14:24:09 +0000 (15:24 +0100)]
relations: Encapsulate relates[] in relations_string()

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agorelations: New enum relations
Markus Armbruster [Mon, 31 Oct 2016 13:54:21 +0000 (14:54 +0100)]
relations: New enum relations

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agorelations: Inline putrel() into its only caller setrel()
Markus Armbruster [Mon, 31 Oct 2016 13:17:27 +0000 (14:17 +0100)]
relations: Inline putrel() into its only caller setrel()

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoreject: Change nat_accepts()'s first parameter to natid
Markus Armbruster [Mon, 31 Oct 2016 12:58:16 +0000 (13:58 +0100)]
reject: Change nat_accepts()'s first parameter to natid

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoreject: Move reject state from struct natstr to rejectstr
Markus Armbruster [Mon, 31 Oct 2016 12:48:48 +0000 (13:48 +0100)]
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>
6 years agoreject: Create EF_REJECT table of struct rejectstr
Markus Armbruster [Mon, 31 Oct 2016 12:26:37 +0000 (13:26 +0100)]
reject: Create EF_REJECT table of struct rejectstr

New struct rejectstr is basically empty so far.  The next commit will
move reject state from struct natstr to struct rejectstr.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoreject: Simplify printing of new state
Markus Armbruster [Mon, 31 Oct 2016 11:55:08 +0000 (12:55 +0100)]
reject: Simplify printing of new state

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoreject: New enum rej_comm for REJ_TELE & friends
Markus Armbruster [Mon, 31 Oct 2016 10:44:04 +0000 (11:44 +0100)]
reject: New enum rej_comm for REJ_TELE & friends

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoreject: Replace getrejects() by nat_accepts()
Markus Armbruster [Mon, 31 Oct 2016 10:39:05 +0000 (11:39 +0100)]
reject: Replace getrejects() by nat_accepts()

All callers of getrejects() also check whether the sender is a deity.
Factor out the common code into nat_accepts(), and drop getrejects().

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoaccept: Fix rejection check for divine senders
Markus Armbruster [Mon, 31 Oct 2016 10:31:10 +0000 (11:31 +0100)]
accept: Fix rejection check for divine senders

Communications from deities can't be rejected, but the accept command
fails to consider that detail.  Should not normally matter, because
the reject command doesn't let you reject deities.  Fix it anyway.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoreject: Clean up typed_wu()'s check for deity
Markus Armbruster [Mon, 31 Oct 2016 10:18:02 +0000 (11:18 +0100)]
reject: Clean up typed_wu()'s check for deity

When sending a telegram, typed_wu() checks whether the recipient is
rejecting telegrams.  The check tacitly assumes from == player->cnum.
Happens to be the case, but clean it up anyway.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agowire: Fix announcement rejection for and from deities
Markus Armbruster [Mon, 31 Oct 2016 09:56:24 +0000 (10:56 +0100)]
wire: Fix announcement rejection for and from deities

Announcement rejection is completely broken for deities.
Additionally, deity announcements aren't exempted from rejection, but
that should not normally matter, because the reject command doesn't
let you reject deities.

Broken when announcements were separated from telegrams in Empire 3.
Fix to test the sender's instead of the player's divinity.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoreject: Exempt bulletins on relation change with deity
Markus Armbruster [Mon, 31 Oct 2016 09:20:30 +0000 (10:20 +0100)]
reject: Exempt bulletins on relation change with deity

Bulletins notifying on a relations change can be rejected just like a
telegram from the country initiating the change, except for one
inconsistency: telegrams from deities are exempt, but bulletins on a
relation change by a deity aren't.  Inconsistent since rejecting was
added in Merc Empire.

Change setrel() to treat relation change bulletins the same as tele()
treats telegrams.

Should not normally matter, because the reject command doesn't let you
reject deities.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agooffer: Exempt all deities from reject, not just POGO
Markus Armbruster [Sun, 30 Oct 2016 06:08:32 +0000 (07:08 +0100)]
offer: Exempt all deities from reject, not just POGO

Fix do_loan() to check !player->god instead of player->cnum != 0.
Screwed up when rejecting was added in Merc Empire.

Should not normally matter, because the reject command doesn't let you
reject deities.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoreject: Inline putreject() into its only caller setrej()
Markus Armbruster [Sat, 29 Oct 2016 15:13:04 +0000 (17:13 +0200)]
reject: Inline putreject() into its only caller setrej()

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoaccept: Print YES and NO right- instead of left-justified
Markus Armbruster [Sat, 29 Oct 2016 09:25:56 +0000 (11:25 +0200)]
accept: Print YES and NO right- instead of left-justified

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoaccept: Don't rely on rejection flag encoding
Markus Armbruster [Sat, 29 Oct 2016 09:19:19 +0000 (11:19 +0200)]
accept: Don't rely on rejection flag encoding

Instead of enumerating all eight combinations of the three flags in a
table, simply print each flag on its own, and drop the table.  The old
table depends on the flag encoding, the new code doesn't.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoaccept: Factor out rejection flags printing
Markus Armbruster [Sat, 29 Oct 2016 09:11:30 +0000 (11:11 +0200)]
accept: Factor out rejection flags printing

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agocontact: Change in_contact()'s first parameter to natid
Markus Armbruster [Sat, 29 Oct 2016 07:06:12 +0000 (09:06 +0200)]
contact: Change in_contact()'s first parameter to natid

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agocontact: Move contact state from struct natstr to contactstr
Markus Armbruster [Tue, 25 Oct 2016 17:38:02 +0000 (19:38 +0200)]
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>
6 years agocontact: Create EF_CONTACT table of struct contactstr
Markus Armbruster [Tue, 25 Oct 2016 17:33:19 +0000 (19:33 +0200)]
contact: Create EF_CONTACT table of struct contactstr

New struct contactstr is basically empty so far.  The next commit will
move contact state from struct natstr to struct contactstr.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agocontact: Rename getcontact() to in_contact()
Markus Armbruster [Sun, 23 Oct 2016 16:45:27 +0000 (18:45 +0200)]
contact: Rename getcontact() to in_contact()

The next commit will create a contact file, and the macro to get a
contact entry will be named getcontact().  Rename the existing
getcontact() out of the way.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agocontact: Avoid unnecessary nation updates
Markus Armbruster [Sun, 23 Oct 2016 16:38:56 +0000 (18:38 +0200)]
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>
6 years agocontact: Inline putcontact() into its only caller setcont()
Markus Armbruster [Sun, 23 Oct 2016 15:52:17 +0000 (17:52 +0200)]
contact: Inline putcontact() into its only caller setcont()

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agocontact: Initialize contact state properly
Markus Armbruster [Sun, 23 Oct 2016 15:36:23 +0000 (17:36 +0200)]
contact: Initialize contact state properly

A country must always be in contact of itself when option HIDDEN is
enabled.  The code ensures this by establishing contact whenever a
player logs in, in init_nats().  This is not the proper place.  Game
state should be initialized in empfile's oninit() callback, in this
case nat_oninit().  Do that, and drop the putcontact() from
init_nats().

Note that option LOSE_CONTACT only affects contact to other countries:
agecontact() doesn't age the country's contact to itself.

Use the opportunity to initialize contact so that getcontact() works
even when HIDDEN is disabled.  Just cleanup, it isn't actually called
then.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoupdate: Fix excessively fast contact aging
Markus Armbruster [Sat, 22 Oct 2016 15:24:14 +0000 (17:24 +0200)]
update: Fix excessively fast contact aging

When option LOSE_CONTACT is enabled, contact is lost after a few
updates.  The remaining number of updates is to be decremented by one
each update.  However, it's actually decremented every time an active
nation is updated.  This makes countries lose contact much too fast,
typically every update.  Broken in commit ac25058, v4.3.0.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoedit: Don't show contact information
Markus Armbruster [Sat, 22 Oct 2016 15:16:49 +0000 (17:16 +0200)]
edit: Don't show contact information

Interactive edit shows what can be edited, with edit keys and current
values.  When option HIDDEN is enabled, "edit c" additionally shows
contact information like "Countries contacted: 1(6) 2(6) 4(5) ".
Lists the numbers of contacted countries and, in parenthesis, how many
updates contact is going to last if option LOSE_CONTACT is enabled.

The line was added along with option HIDDEN in Empire 2.  As long as
editing contact isn't implemented, it doesn't belong here.  Drop it.
If deities need contact information, we'll have to show it elsewhere.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agotests/smoke: Omit redundant data from fairland.xdump
Markus Armbruster [Sat, 24 Sep 2016 09:00:52 +0000 (11:00 +0200)]
tests/smoke: Omit redundant data from fairland.xdump

Belatedly update fairland.xdump for commit f4f0482, v4.3.33.

The commit made empdump omit redundant data, shortening the
final.xdump.  The matching manual update to fairland.xdump was
forgotten.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agosubs/control: Grant bonus for capability security
Markus Armbruster [Mon, 19 Sep 2016 18:45:56 +0000 (20:45 +0200)]
subs/control: Grant bonus for capability security

Grant land units with security capability the same bonus as in convert
and shoot: multiply by (1 + eff/100).

military_control()'s code to count military is now functionally
equivalent to security_strength(), except it has no use for its second
parameter.  Change security_strength() to permit a null argument, and
reuse it in military_control().

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agosubs/control: Fix to ignore embarked land units
Markus Armbruster [Mon, 19 Sep 2016 18:35:30 +0000 (20:35 +0200)]
subs/control: Fix to ignore embarked land units

Moving stuff out of an occupied sector generally requires "military
control", i.e. you need at least one military for every ten civilians.
Military in land units count.  Even when the land unit is loaded on a
ship or land unit.  Questionable, because unload need not be possible.

Checking whether unload would be possible is not worth the trouble
here, simply ignore embarked land units.

This affects commands move, explore, sell, set and transport, as well
as the update's distribution and delivery.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoconvert shoot: Fix to ignore foreign and embarked land units
Markus Armbruster [Mon, 19 Sep 2016 18:27:19 +0000 (20:27 +0200)]
convert shoot: Fix to ignore foreign and embarked land units

Convert and shoot put land units to work regardless of ownership.
Clearly wrong for foreign, non-allied land units trapped in the
sector.

They also happily use land units loaded on ships or land units, unlike
most other commands.  Questionable, because unload need not be
possible.

Checking for ownership and load status was neglected when land units
were added in Chainsaw 3.  Non-allied land units became possible in
4.0.0.

Checking relations and whether unload would be possible is not worth
the trouble here, simply ignore all foreign and embarked land units.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoupdate/revolt: Make security bonus proportional to efficiency
Markus Armbruster [Mon, 19 Sep 2016 18:05:51 +0000 (20:05 +0200)]
update/revolt: Make security bonus proportional to efficiency

Land units with capability security get a combat bonus regardless of
efficiency.  This lets players get the benefits of a security unit at
a discount: just don't build it beyond 10%.

Multiply the combat bonus by eff/100.  Together with the previous
commit, this closes bug#64.

Note that the the strength of a security unit's commando raid is
already proportional to its efficiency.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoconvert shoot: Make security bonus proportional to efficiency
Markus Armbruster [Fri, 16 Sep 2016 11:30:47 +0000 (13:30 +0200)]
convert shoot: Make security bonus proportional to efficiency

Land units with capability security reduce the mobility cost and have
their military count double, regardless of efficiency.  This lets
players get the benefits of a security unit at a discount: just don't
build it beyond 10%.

Count security unit's military times 1 + eff/100 instead of double.
Change the mobility bonus term from number of security units to sum of
security unit efficiency / 100.  Partial fix for bug#64.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agosubs: Factor common military counting out of shoo() and conv()
Markus Armbruster [Fri, 16 Sep 2016 07:07:52 +0000 (09:07 +0200)]
subs: Factor common military counting out of shoo() and conv()

Put the new function security_strength() next to military_control(),
because that one does a similar count.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoedit: Fix missing newline in "teleported" message
Markus Armbruster [Sun, 11 Sep 2016 15:03:59 +0000 (17:03 +0200)]
edit: Fix missing newline in "teleported" message

Newline forgotten in commit ef2e2d08, v4.3.32.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoconfig: Generalize infrastructure build materials storage
Markus Armbruster [Wed, 17 Aug 2016 19:01:32 +0000 (21:01 +0200)]
config: Generalize infrastructure build materials storage

Infrastructure requires lcms and hcms to build.  The build materials
are exposed as infrastructure columns lcms, hcms (struct sctintrins
members in_lcms, in_hcms).  They are per point of efficiency.  In
contrast, sector and unit build materials are defined for 100%.

We want to define build materials for 100% now, for flexibility and
consistency, and we want to optionally support more build materials in
the future.  Replace members in_lcms and in_hcms by array in_mat[],
and provide selectors l_build and h_build.

Additionally provide selectors for all other item types, with value
zero, to help clients prepare for future additional materials.  Use
CA_DUMP_ONLY to keep them out of configuration tables until they
actually work.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoconfig: Define infra build cost and mobility use per 100%
Markus Armbruster [Wed, 17 Aug 2016 18:00:02 +0000 (20:00 +0200)]
config: Define infra build cost and mobility use per 100%

Infrastructure build cost is defined by infra column dcost (struct
sctintrins member in_dcost).  It's the cost per point of efficiency.
In contrast, sector and unit build cost is defined for 100%, by
sect-chr, ship-chr, plane-chr, land-chr, nuke-chr column cost.

Switch to build cost per 100%, for flexibility and consistency:
replace struct sctintrins member in_dcost by in_cost, and selector
dcost by cost.

With cost values that aren't multiple of 100, the build cost may have
to be rounded.  Do this exactly like we round sector build cost: the
amount is limited to money * 100 / cost rounded down, but the money
charged is actual amount * money / 100 rounded randomly.

Do the same for mobility use: replace struct sctintrins member
in_mcost by in_bmobil, and selector mcost by bmobil, with similar
rounding.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoimprove: Improve legibility a bit
Markus Armbruster [Wed, 17 Aug 2016 17:51:39 +0000 (19:51 +0200)]
improve: Improve legibility a bit

improve() uses intrchr[type] a lot.  Use new variable incp as
abbreviation.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoshow: Show infra costs in the same format as sector build costs
Markus Armbruster [Wed, 17 Aug 2016 17:08:54 +0000 (19:08 +0200)]
show: Show infra costs in the same format as sector build costs

Use similar column headings, and show cost for 100% instead of 1%.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agolboard: Don't permit boarding of embarked land units
Markus Armbruster [Sat, 6 Aug 2016 16:02:44 +0000 (18:02 +0200)]
lboard: Don't permit boarding of embarked land units

You can board land units loaded on a ship or land unit.  This makes no
sense.  Reject attempts to board land units on a ship or land unit
exactly like attempts to board land units that don't exist.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoupdate/revolt: Fix guerrilla liberating old-owned sector
Markus Armbruster [Sun, 18 Sep 2016 17:02:47 +0000 (19:02 +0200)]
update/revolt: Fix guerrilla liberating old-owned sector

Guerrilla are created loyal to the old owner.  When the sector
converts, they switch their allegiance to POGO.  This is a bit of a
hack.

When guerrilla win their fight for freedom in an old-owned sector, the
old-owner duly changes to POGO.  However, the owner doesn't.  Broken
in 4.2.6.  The "Sector X,Y has been retaken!" message is still sent to
the "new" sector owner.

Simply restoring the owner change lost back then would restore a bug
that goes back to 2.3.7: takeover() doesn't run when an old-owned
sector is liberated.  So fix the bug by making that unconditional.

Land units reported captured are actually destroyed, because POGO
can't own any.  Oh well.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoupdate/revolt: De-quadruplicate land unit casualty code
Markus Armbruster [Sun, 18 Sep 2016 15:38:17 +0000 (17:38 +0200)]
update/revolt: De-quadruplicate land unit casualty code

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoupdate/revolt: Destroy land units only when casualties demand it
Markus Armbruster [Sun, 18 Sep 2016 15:09:35 +0000 (17:09 +0200)]
update/revolt: Destroy land units only when casualties demand it

take_casualties() first applies casualties without destroying land
units, and if any remain, applies them by destroying land units.  This
is wrong, because the remaining casualties may not suffice to actually
kill.  Has been that way since land units were added in Chainsaw 3.

Apply remaining casualties more carefully: destroy land units only
when efficiency falls below 10%.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoupdate/revolt: Reduce under-strength land unit damage
Markus Armbruster [Sun, 18 Sep 2016 12:22:03 +0000 (14:22 +0200)]
update/revolt: Reduce under-strength land unit damage

A land unit with mil military taking N casualties loses N * 100 / mil
points of efficiency.  A 50% inf with 20m dies when it loses more than
8m.  With 100m, it dies when it loses more than 40m.  A land unit
always dies when it loses all military.

In ordinary ground combat, they lose N * 100 / maxmil points of
efficiency, where maxmil is how many military they could load.  This
is less damage when the land unit is under-strength.  A 50% inf dies
when it loses more than 40m, regardless of how many it has.

An inefficient land unit with a sufficiently high number of military
can die before its military are all killed.  A land unit with a
sufficiently low number of military can survive loss of all its
military.  Attacking land units return to their starting position.
Defending land units stay put, and get taken over by a victorious
attacker.  Neither was possible before 4.0.0 made land unit military
loadable.

The rules for ordinary ground combat may be debatable, but it's better
to be consistent: change land unit damage in guerrilla combat to match
ordinary combat.  This reduces damage to under-strength land units.

If che lose, the sector owner profits from the reduced damage.  But if
they win, they may take over land units that got all their military
killed.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoupdate/revolt: Don't kill land units without military
Markus Armbruster [Tue, 26 Jul 2016 05:16:45 +0000 (07:16 +0200)]
update/revolt: Don't kill land units without military

Land units without military can't contribute to the fight.  They can
still get killed, and whether they are depends on their UID.

take_casualties() kills land units in UID order until the required
number of casualties is reached.  Killing a land unit without military
provides none, but take_casualties() doesn't care.  The land unit
"dies fighting guerrillas", which makes no sense when it's doesn't
have any military.

If the rebels win, they attempt to capture any surviving land units.
Spies hide or get executed instead.  Same as for any other violent
sector takeover.

Normal ground combat ignores land units without military.  Do the same
here: ignore them in take_casualties().  This protects spies and other
land units without military from the fighting, but exposes them to
capture.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoupdate/revolt: Spread only actual casualties to land units
Markus Armbruster [Sun, 18 Sep 2016 10:32:17 +0000 (12:32 +0200)]
update/revolt: Spread only actual casualties to land units

To spread C casualties among N land units, take_casualties() applies
floor(C/N)+2 to each.  Bonkers.  Has been that way since land units
were added in Chainsaw 3.

Limit casualties spread to a land unit to their remaining amount.
Should really spread proportionally to military instead of evenly; add
a TODO comment for that.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoupdate/revolt: Simplify take_casualties()
Markus Armbruster [Sun, 18 Sep 2016 15:45:59 +0000 (17:45 +0200)]
update/revolt: Simplify take_casualties()

Since the previous commit fixed the update of mc, mc + taken remain
invariant.  Don't bother changing mc, use mc - taken instead.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoupdate/revolt: Fix how land units take casualties
Markus Armbruster [Sun, 18 Sep 2016 09:54:24 +0000 (11:54 +0200)]
update/revolt: Fix how land units take casualties

take_casualties() applies a number of casualties to sector military
and land units.  It is utterly confused about land units.

Consider a land unit with efficiency eff that has mil out of maxmil
military.  Issues:

* To apply N casualties without destroying it, take_casualties() tries
  to kill N * maxmil / mil military.  Makes no sense.  It's more than
  asked for unless mil equals maxmil.  It can even be more than mil.

  It reduces efficiency by N * 100 / mil points.  Note that ordinary
  ground combat reduces by N * 100 / maxmil points.  See
  lnd_take_casualty().

  Example: the update test's inf#25 is 100% efficient and has 20m out
  of 100m.  take_casualties() tries to apply up to 22 casualties out
  of the 60 remaining casualties to apply, but decides to apply only
  12 for now, to keep efficiency above to 40%.  It reduces efficiency
  by 12 * 100 / 20 = 60 to 40%, and tries to kill 12 * 100 / 20 = 60
  mil, which kills off the 20 that actually exist.  It nevertheless
  reduces the number of casualties still to apply only by 12.

  Example: the update test's linf#28 is 100% efficient and has 20m out
  of 25m.  take_casualties() tries to apply up to 8 casualties.  It
  reduces efficiency by 8 * 100 / 20 = 40 points to 60%, and tries to
  kill 8 * 25 / 20 = 10 military.

* When it destroys a land unit, it reduces the number of casualties
  still to apply by mil * eff/100.0 instead of mil.

  Example: the update test's inf#27 is 10% efficient and has 20m out
  of 100m.  take_casualties() still has 34 casualties to apply, so it
  destroys it, killing all 20m.  But it reduces the number of
  casualties to apply only by 2.

Broken when 4.0.0 made land unit military loadable.  Not sure it fully
worked before that, but it's definitely bonkers since.

Fix it as follows:

* To apply casualties to a land unit without destroying it, limit its
  losses to its actual number of military, and so that efficiency
  stays above 40%.  Then simply kill that number.

* Reduce the number of casualties to apply by the exact number killed.

The update test now kills only 8m in linf#28.  Still two more than it
should, but that's separate bug, to be fixed next.  The fix has no
visible effect for inf#25, because that one gets destroyed later.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoupdate/revolt: Fix body count report
Markus Armbruster [Sun, 18 Sep 2016 09:27:30 +0000 (11:27 +0200)]
update/revolt: Fix body count report

The body count reflects what take_casualties() should do, not what it
actually does.  It can be quite off, as the update test's changed
output shows.  Mostly because take_casualties() is utterly confused.
That'll be fixed next.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoupdate/revolt: Fix mil count for che move after getting caught
Markus Armbruster [Sun, 18 Sep 2016 09:04:37 +0000 (11:04 +0200)]
update/revolt: Fix mil count for che move after getting caught

When military catch che, their their count isn't updated for their
losses.  The count is later used when che consider moving to an
adjacent sector.  This could conceivably make them move instead of
stay.  Broken when Chainsaw 3 added land units.  Fix it.

Note that the sector's military count includes land units, but the
adjacent sectors' doesn't.  Should be improved some day; add a TODO
comment.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoupdate/revolt: Change security unit bonus to fix body count
Markus Armbruster [Sat, 17 Sep 2016 09:24:55 +0000 (11:24 +0200)]
update/revolt: Change security unit bonus to fix body count

Both ordinary ground combat and guerrilla combat basically kill
combatants one by one randomly until one side is eliminated.  The odds
of each side taking a hit are computed from combat strengths.

Ordinary combat factors bonuses into the odds.  It doesn't mess with
the number of men.

Guerrilla combat does the same for the bonus due to relative
happiness.  It doesn't for land units with security capability: these
fight as if they had twice as many military.  Changes both odds and
number of men.  This inflates the body count reported to the sector
owner.  Visible in tests/update/journal.log, where rebels kill 110 out
of 70 military.  It also complicates take_casualties().  Has been that
way since security land units were added in Chainsaw 3.

To fix the body count and simplify take_casualties(), make capability
security affect only the odds, not the number of men.  Without further
adjustments, this would reduce guerrilla losses: fewer men mean fewer
combat rounds mean fewer chances for rebels to die.  To compensate,
increase the multiplier from two to four.  This should make security
units a bit tougher.  Document the bonus in "info Guerrilla".

More body count bugs remain.

Reusing ordinary combat rules and code for guerrilla combat would be
nice, but isn't feasible for me right now.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agotests/update: Cover guerrilla shootout
Markus Armbruster [Fri, 16 Sep 2016 16:57:28 +0000 (18:57 +0200)]
tests/update: Cover guerrilla shootout

This exposes bugs.  They're marked "BUG:" in the test input.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoattack assault paradrop: Don't disclose defender's retreats
Markus Armbruster [Sun, 24 Jul 2016 14:10:41 +0000 (16:10 +0200)]
attack assault paradrop: Don't disclose defender's retreats

When an attacking land unit fails its morale check and retreats, the
retreat message needs to be prefixed with a newline to separate it
from the casualty characters.  However, the code also prints the
newline when a defending land unit retreats, leaking the retreat to
the attacker.  For instance, a fight that forces three defending to
retreat could look like this:

    !!!!!!!!!!!!!!!!!!
    !@!!!!!!!!!!!!!@!
    !

    - Casualties -
 Yours: 2
Theirs: 34

Messed up in Empire 3.  Fix by printing the newline only when an
attacking land unit retreats.  The example becomes:

    !!!!!!!!!!!!!!!!!!!@!!!!!!!!!!!!!@!!
    - Casualties -
 Yours: 2
Theirs: 34

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoattack assault board: Fix message when attacking land unit dies
Markus Armbruster [Sun, 24 Jul 2016 13:08:14 +0000 (15:08 +0200)]
attack assault board: Fix message when attacking land unit dies

Loss of an attacking land is reported like this:

    @linf light infantry #1 dies assault 21,-3!

Bad grammar and newline missing between the "@" casualty character and
the message.  Messed up in Empire 2.  Affects only attackers, because
the code special-cases defense to avoid the bad grammar there (close,
but no cigar), and defenders don't get casualty characters printed.
Fix it to

    @
    linf light infantry #1 dies assaulting 21,-3!

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoassault: Don't send spies into combat
Markus Armbruster [Sun, 24 Jul 2016 12:02:53 +0000 (14:02 +0200)]
assault: Don't send spies into combat

The server doesn't let you send land units without offensive strength
into combat: ask_olist() simply doesn't offer them.  Good.

However, it needs to offer spies for assault, because assault is how
they sneak ashore.  To make it offer spies, which have no offensive
strength, attack_val() artificially sets their offensive strength to
one for assault.  Dirt effect: spies fight (and die) in assaults, even
though they can't otherwise attack.  Lame.  Has been that way since
spies were added in 4.0.0.

Make ask_olist() offer spies regardless of offensive strength when
assaulting, and drop the special case from attack_val().  They get
offered exactly as before.  However, since their offensive strength is
now zero, they won't enter actual combat (see the previous commit).

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoattack assault board: Really require offensive strength
Markus Armbruster [Sun, 24 Jul 2016 11:59:52 +0000 (13:59 +0200)]
attack assault board: Really require offensive strength

The server doesn't let you send land units without offensive strength
into combat: ask_olist() doesn't offer them.  But if their strength
gets somehow destroyed between ask_olist() and the actual fight, they
go anyway.

Check again before the fight, and leave land units without offensive
strength behind.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoattack assault paradrop: Spies hide rather than defend
Markus Armbruster [Sun, 24 Jul 2016 10:22:51 +0000 (12:22 +0200)]
attack assault paradrop: Spies hide rather than defend

Defending spies get spotted like any other defending land unit.  They
don't contribute to the defense (their defense value is zero), and
they always survive the fight unscathed (lacking mil, they take no
casualties).  If the sector is lost, they either hide or get executed.
Before the previous commit, they could also be damaged and captured.

Possible outcomes:

* Spy isn't spotted, attack fails

* Spy isn't spotted, attack succeeds, spy gets executed

* Spy isn't spotted, attack succeeds, spy hides

* Spy is spotted, attack fails

  This lets players use probing attacks to spot spies with a much
  better chance than spy or llook have.  But they can already repeat
  spy or llook to increase their detection chances as close to 100% as
  they want, so this doesn't make things materially worse.

* Spy is spotted, attack succeeds, spy gets executed

* Spy is spotted, attack succeeds, spy hides

  Since the spy has already been spotted, hiding is largely useless.
  The attacker can board the spy as soon as he has mobility.

This obviously hasn't been thought through.

Get rid of the "spy is spotted" cases by skipping spies when
collecting the list of defending land units.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoattack assault paradrop: Execute spies on takeover
Markus Armbruster [Sun, 24 Jul 2016 09:34:13 +0000 (11:34 +0200)]
attack assault paradrop: Execute spies on takeover

When the attacker takes a sector, spies try to hide.  If they fail,
they're treated like any other land unit: they attempt to
self-destruct, and if the damage isn't lethal, they get captured.
Successful self-destruct is reported as "blown up by the crew", which
makes no sense for spies.  Spies surviving self-destruct is odd, as
any damage is normally fatal for them.

Extend the special case for spies: summarily execute the ones that
fail to hide.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoassault attack board lboard paradrop spy: Fix missing newline
Markus Armbruster [Sun, 24 Jul 2016 07:51:08 +0000 (09:51 +0200)]
assault attack board lboard paradrop spy: Fix missing newline

The intelligence reports on land units lack a newline.  Broken in
commit c8e5b4f, v4.3.33.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoassault: Improve chance for spies sneaking ashore undetected
Markus Armbruster [Sun, 24 Jul 2016 07:00:02 +0000 (09:00 +0200)]
assault: Improve chance for spies sneaking ashore undetected

Spies assaulting a foreign sector have only a 10% chance to evade
detection, regardless of efficiency.  With odds like that, players
basically don't bother.

All the other spy detection checks use LND_SPY_DETECT_CHANCE(eff),
which gives 100% spies a 90% chance to evade detection.  That's
perhaps a bit to good here, so let's try LND_SPY_DETECT_CHANCE(eff/2).
A 100% spy now has a 40% chance to sneak ashore undetected.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoassault: Handle the "only spies" special case earlier
Markus Armbruster [Sun, 24 Jul 2016 06:03:35 +0000 (08:03 +0200)]
assault: Handle the "only spies" special case earlier

Since the previous commit, sneak_ashore() doesn't depend on a previous
get_oland() anymore, so the att_get_offense() is unnecessarily.  Move
it across att_get_offense() next to the other special case "assault
own sector".

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoassault: Make spies "sneaking ashore" use mobility and hit mines
Markus Armbruster [Sat, 23 Jul 2016 21:18:06 +0000 (23:18 +0200)]
assault: Make spies "sneaking ashore" use mobility and hit mines

Assaulting a foreign sector with nothing but spies is special: the
spies sneak ashore.  It is, however, more special than it should be:
the spies use no mobility and ignore landmines.  They do use mobility
and hit landmines in other assaults.  Assaulting your own sector with
nothing but spies is more costly and more risky than assaulting a
foreign one.  This makes no sense.  Has been that way since spies were
added in 4.0.0.

It's that way because sneaking ashore uses its own code to move the
spies instead of move_in_land() via att_move_in_off().  It can't use
move_in_land(), because that prints an unwanted "now occupies"
message, and destroys the list of assaulting units, which we still
need to catch and shoot spies.

Factor the code to move attacking land units to the target sector out
of move_in_land() into att_move_land(), and use that for sneaking
ashore.  This makes the spies use mobility and hit landmines even when
they sneak.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agosubs: Simplify move_in_land()
Markus Armbruster [Sat, 23 Jul 2016 21:16:07 +0000 (23:16 +0200)]
subs: Simplify move_in_land()

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoassault: Plug memory leak in spies sneaking ashore
Markus Armbruster [Sat, 23 Jul 2016 16:59:02 +0000 (18:59 +0200)]
assault: Plug memory leak in spies sneaking ashore

We free struct olist only for spies that get killed.  Leaks since
spies were added in 4.0.0.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoassault: Simplify sneak_ashore()
Markus Armbruster [Sat, 23 Jul 2016 15:36:09 +0000 (17:36 +0200)]
assault: Simplify sneak_ashore()

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoassault: Simplify only_spies()
Markus Armbruster [Sat, 23 Jul 2016 15:09:54 +0000 (17:09 +0200)]
assault: Simplify only_spies()

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoassault: Factor only_spies(), sneak_ashore() out of assa()
Markus Armbruster [Sat, 23 Jul 2016 14:49:44 +0000 (16:49 +0200)]
assault: Factor only_spies(), sneak_ashore() out of assa()

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoef_verify: Require land unit milit == 0 with capability spy
Markus Armbruster [Sat, 23 Jul 2016 07:26:44 +0000 (09:26 +0200)]
ef_verify: Require land unit milit == 0 with capability spy

The rules for spy units make little sense unless spies carry no
military.  For instance, spies die when they take casualties in ground
combat.  There seems to be a tacit assumption that spies have no
military.  I don't trust the code to behave unless this assumption is
met.  Require it before an overly adventurous deity finds out the
painful way that spies with military don't work.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agosubs: Normalize checks whether a ship just read exists
Markus Armbruster [Sat, 23 Jul 2016 08:23:20 +0000 (10:23 +0200)]
subs: Normalize checks whether a ship just read exists

A ship just read from the ship file exists unless its owner is zero.
Check that instead of whether efficiency is below minimum.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agosubs: Simplify checks whether a ship just read exists
Markus Armbruster [Sat, 23 Jul 2016 08:19:20 +0000 (10:19 +0200)]
subs: Simplify checks whether a ship just read exists

Ships with efficiency below the minimum have their owner set to zero
on write to the ship file.  Therefore, a ship just read from the ship
file exists unless its owner is zero.  Additionally checking
efficiency is redundant.  Same for planes and land units.  Drop
obviously redundant efficiency checks.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agosubs: Tighten the check for destroyed defending land unit
Markus Armbruster [Sat, 23 Jul 2016 08:09:46 +0000 (10:09 +0200)]
subs: Tighten the check for destroyed defending land unit

get_dland() tests efficiency to find out whether the defending land
unit is gone.  Doesn't work when somebody else has since built a new
one with the same UID.  Not sure that can happen.  Check for a change
of owner instead.  Matches get_oland().

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agofire: Plug memory leak when missile defense sinks firing ships
Markus Armbruster [Fri, 22 Jul 2016 04:46:15 +0000 (06:46 +0200)]
fire: Plug memory leak when missile defense sinks firing ships

do_defdam() iterates over the list firing ships, applies return fire
to each, and frees its list element.  When it finds a ship that has
been sunk already, it skips it.  This also skips the free, leaking the
list element.  The leak goes back to flawed bug fix in Empire 2.

As far as I can see, missile defense is the only way a ship can be
sunk there.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agosubs: Drop unused spy detection roll from unitsatxy()
Markus Armbruster [Thu, 21 Jul 2016 19:00:47 +0000 (21:00 +0200)]
subs: Drop unused spy detection roll from unitsatxy()

The die roll was added in 4.0.17 to hide spies from bombers.  However,
players could roll dice as often as they wanted, by typing '?' at the
target prompt.  The broken die roll is unreachable since commit
7688aed disallowed bombing of spies.  Drop it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agolost: Fix to track more than one lost sector per owner
Markus Armbruster [Mon, 18 Jul 2016 19:14:30 +0000 (21:14 +0200)]
lost: Fix to track more than one lost sector per owner

makelost() overwrites an existing entry for the same thing, else
creates a new one.  It calls findlost() to find existing entries.
findlost() means to look up by coordinates if it's looking for a
sector entry, and by ID if it's looking for a ship, plane, land unit
or nuke entry.  It actually does both for sectors.  Since callers pass
zero ID for sectors, sector entries always match, so at most one gets
created, and additional ones overwrite it.

Broken since the lost table was introduced in 4.0.7.  Fix the flawed
comparison in findlost().

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agonews: Merge news more aggressively
Markus Armbruster [Mon, 27 Jun 2016 19:35:23 +0000 (21:35 +0200)]
news: Merge news more aggressively

News reporting merges news items into recent items with same actor,
action and victim, as long as the merged number of times doesn't
exceed 65535 (127 before the previous commit).

This complicates incremental xdump a bit: when the client sees a row,
it's not obvious which of the previously dumped rows it replaces.
Actually, rows with the same actor, action, victim and time replace in
xdump order.

Merge news item regardless of the number of times; saturate the number
at 65535.  Now the replacement is obvious, because there can only be
one news item with the same actor, action, victim and time.

This also rate-limits floods of identical news should they happen for
some reason.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agonews: Raise the limit for "number of times" from 127 to 65535
Markus Armbruster [Mon, 27 Jun 2016 19:34:42 +0000 (21:34 +0200)]
news: Raise the limit for "number of times" from 127 to 65535

News reporting merges news items into recent items with same contents,
until their count reaches 127.  Raise that limit to 65535, by making
struct nwsstr member nws_ntm unsigned short.  Size of struct nwsstr
stays the same on all common machines.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agonews: Rewrite code for "The Bottom Line"
Markus Armbruster [Mon, 27 Jun 2016 19:05:10 +0000 (21:05 +0200)]
news: Rewrite code for "The Bottom Line"

This is one of the lamest ways to sort I've seen in my career: find
the maximum, then for each value from the maximum down, search for
that value.  O(max * MAXNOC^2).  Dates back to Empire 2.

The one advantage this contraption has is it "sorts" in place.  But
memory's cheap.  Fill an array with the data to sort, and sort it with
qsort().  To avoid overtaxing the stack in the (unlikely!) worst case
of everybody taking sectors from everybody, allocate it dynamically.

Also flip sectors_taken[] from short to unsigned short.  Aside: in
theory, the count can overflow, but sector deltas exceeding 65535
don't occur in practice, and if news misreported them, we'd live.  Not
worth complicating the code.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agonews: De-duplicate the loop over news items
Markus Armbruster [Mon, 27 Jun 2016 05:12:06 +0000 (07:12 +0200)]
news: De-duplicate the loop over news items

Duplicated to detect empty pages in Empire 2.  Easy enough to fold
into the other loop, so do that.

While there, oops on invalid struct nwsstr member nws_ntm.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agotests/smoke: Run news
Markus Armbruster [Mon, 27 Jun 2016 05:05:54 +0000 (07:05 +0200)]
tests/smoke: Run news

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agotravis: Limit to branches changeling, fever, master, travis
Markus Armbruster [Mon, 27 Jun 2016 03:53:53 +0000 (05:53 +0200)]
travis: Limit to branches changeling, fever, master, travis

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agonsc: Drop deprecated nat and country selector hostname
Markus Armbruster [Sun, 26 Jun 2016 13:30:02 +0000 (15:30 +0200)]
nsc: Drop deprecated nat and country selector hostname

Deprecated since commit 199388b, v4.3.33.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoconfigure Make: More detailed version information
Markus Armbruster [Sun, 26 Jun 2016 09:36:04 +0000 (11:36 +0200)]
configure Make: More detailed version information

Version information is in output of commands version, xdump version,
and in program output for option -v.  Looks like this:

    Wolfpack Empire 4.3.33

The version number is defined in configure.ac, and incremented
manually.  It identifies only the base release (here: 4.3.33).  Fine
when this is an unmodified released version.  Pretty much useless
during development.

Add a suffix to the version number that describes it further:

    V               Unmodified release V (same as before)
    V.N-H           Modified release built from a clean git tree
                    N is the number of additional commits, and
                    H is the abbreviated commit hash
    V.N-H-dirty     Same, but the working tree is dirty
    V-dirty         Modified release built from a tarball

A git tree is clean when the contents of its files are unchanged.
Changing only the their timestamps doesn't count.  It does count when
building from a tarball, because tracking contents isn't implemented
there.

Also use this suffixed version for tarball names.

The version reported by configure is fixed at configure generation
time, i.e. it is usually out of date during development.  Ensuring a
release tarball contains one with a current version is manual for now.
Running autoconf -f should do the trick.

Elsewhere, the version is determined at build time, so it is always
current.

Dirty tracking isn't implemented in the standalone client build.  If
you start with a clean tarball, the version will not change from V to
V-dirty when you build with modifications.

Steal build-aux/git-version-gen from autoconf 2.69 to help with
computing the version string.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoconfigure: Bump required autoconf version to 2.69
Markus Armbruster [Sun, 26 Jun 2016 08:58:07 +0000 (10:58 +0200)]
configure: Bump required autoconf version to 2.69

2.69 is more than four years old now.  Nobody has tested with 2.64 in
quite some time.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agobuild-aux: Refresh from automake 1.15
Markus Armbruster [Sun, 26 Jun 2016 08:35:24 +0000 (10:35 +0200)]
build-aux: Refresh from automake 1.15

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agonsc filetable: Get rid of untidy use of PACKAGE_STRING
Markus Armbruster [Sun, 26 Jun 2016 06:42:57 +0000 (08:42 +0200)]
nsc filetable: Get rid of untidy use of PACKAGE_STRING

Table version selector version shows the version string stored in
version[].  Its implementation is a bit of a hack:
empfile[EF_VERSION].cache is set to version[], so it gets passed as
context object to nstr_eval().  This permits reading version[] with an
NSC_STRINGY selector at offset 0, which is what nsc_init()'s
version_ca0 is.

Both empfile[] and version_ca need the size of version[].  Since
version.h provides only an incomplete type for version[], they use
sizeof(PACKAGE_STRING), which isn't exactly clean.

Redo version_ca0 as virtual selector.  Takes a bit more code, but it's
easier to understand.

The context object is now unused.  Setting empfile[EF_VERSION].cache
to a null pointer would trip assertions, so make it point to a dummy.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoxdump: Make meta-type numbers portable, get rid of meta-type "c"
Markus Armbruster [Sun, 26 Jun 2016 06:00:20 +0000 (08:00 +0200)]
xdump: Make meta-type numbers portable, get rid of meta-type "c"

The xdump field data types are abstract symbols "d", "f", "s" and "c".
However, the abstraction leaks: we dump the enum nsc_type ca_type
values verbatim in meta table field "type", and have symbol table
meta-type map all integer types to "d", and both floating-point types
to "f".  Not a problem for well-behaved clients, since all they do
with the dumped value is referencing table meta-type.  It is a problem
for version-test: since the integer type compatible with an
enumeration type is implementation-defined, the type value of
selectors of enumeration type can vary between compilers.  It also
makes table meta-type a somewhat ugly exception to the rule that a
symbol table maps integers to names 1:1.

Virtual selectors let us seal the abstraction: dump the promoted
ca_type value.

The integer types get all promoted to NSC_LONG.  This takes care of
version-test.

The floating-point types get all promoted to NSC_DOUBLE.  Makes sense.

NSC_STRINGY gets promoted to NSC_STRING.  This changes all field data
types "c" to "s".  Getting rid of "c" is a welcome simplification,
because now the meaning of meta type field "len" no longer depends on
"type", but always means that the array is dumped as that many fields.
We lose string length limit information, though.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoef_verify: Run verify_row() even for tables without selectors
Markus Armbruster [Sun, 26 Jun 2016 04:51:25 +0000 (06:51 +0200)]
ef_verify: Run verify_row() even for tables without selectors

verify_table() skips verify_row() when the table doesn't have
selectors.  But verify_row()'s test for corrupt headers in EFF_TYPED
tables doesn't require selectors.  Harmless, since the two tables that
don't have selectors (EF_MAP and EF_BMAP) aren't EFF_TYPED.  Clean it
up anyway.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoef_verify: Fix test for undumpable tables
Markus Armbruster [Sun, 26 Jun 2016 04:33:36 +0000 (06:33 +0200)]
ef_verify: Fix test for undumpable tables

Virtual selectors can't be used in xundump, since we lack a setter to
go with ca_get().  verify_ca() verifies they don't occur in tables
that can be xundumped.

When I restricted xundump to tables with a file name (commit 029d929,
v4.3.28), I neglected to update the test in verify_ca().

Factor out the correct test into xundumpable().  Use it to fix
verify_ca().

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoMake: Tidy up distribution and cleaning of generated makefiles
Markus Armbruster [Sat, 25 Jun 2016 11:13:15 +0000 (13:13 +0200)]
Make: Tidy up distribution and cleaning of generated makefiles

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo/toc: Tidy up last line
Markus Armbruster [Sat, 25 Jun 2016 11:02:36 +0000 (13:02 +0200)]
info/toc: Tidy up last line

mksubj.pl neglects to terminate info/toc's last line with a newline.
info-test doesn't care.  Tidy up anyway.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoMake: Drop $(ttop), use its value directly
Markus Armbruster [Sat, 25 Jun 2016 11:01:01 +0000 (13:01 +0200)]
Make: Drop $(ttop), use its value directly

info/TOP.t is easier to understand than $(ttop).

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo/Update-sequence: Belatedly update for removal of SLOW_WAR
Markus Armbruster [Sat, 25 Jun 2016 08:26:19 +0000 (10:26 +0200)]
info/Update-sequence: Belatedly update for removal of SLOW_WAR

Missed in commit 439f111, v4.3.27.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoupdate: Move sector type test into bank_income()
Markus Armbruster [Sun, 17 Jul 2016 09:16:42 +0000 (11:16 +0200)]
update: Move sector type test into bank_income()

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>