]> git.pond.sub.org Git - empserver/log
empserver
6 years agobuild-aux/git-version-gen: Refresh from Gnulib commit d93aa1d
Markus Armbruster [Sat, 12 Aug 2017 07:59:59 +0000 (09:59 +0200)]
build-aux/git-version-gen: Refresh from Gnulib commit d93aa1d

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agotests: Normalize version numbers to 4.4.0 instead of 4.3.34
Markus Armbruster [Sat, 12 Aug 2017 07:21:03 +0000 (09:21 +0200)]
tests: Normalize version numbers to 4.4.0 instead of 4.3.34

Commit 1ec9b94 normalized version numbers in test output to 4.3.34,
because that was thought to be the next version then.  4.3.34 has
become 4.4.0 meanwhile.  Update the normalization just to avoid
mention of 4.3.34.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo/version: Update example to current output
Markus Armbruster [Sat, 12 Aug 2017 07:18:59 +0000 (09:18 +0200)]
info/version: Update example to current output

Current output of the version command, except replace version number
4.3.33.N-H-dirty by 4.4.0.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo: Update change log for 4.4.0
Markus Armbruster [Sat, 12 Aug 2017 05:51:20 +0000 (07:51 +0200)]
info: Update change log for 4.4.0

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo/xdump: Update advice on xdump evolution
Markus Armbruster [Sat, 12 Aug 2017 06:47:41 +0000 (08:47 +0200)]
info/xdump: Update advice on xdump evolution

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoDrop a a few accidentally repeated words
Markus Armbruster [Sat, 12 Aug 2017 04:06:47 +0000 (06:06 +0200)]
Drop a a few accidentally repeated words

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo: Split Empire4 into Empire4.0, Empire4.2, Empire4.3
Markus Armbruster [Fri, 11 Aug 2017 19:39:03 +0000 (21:39 +0200)]
info: Split Empire4 into Empire4.0, Empire4.2, Empire4.3

"info Empire4" has become unwieldy: more than 4000 lines, almost a
quarter of a Megabyte.  Split it up.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agodoc: Drop redundant doc/CHANGES4.X, improve README
Markus Armbruster [Fri, 11 Aug 2017 19:37:13 +0000 (21:37 +0200)]
doc: Drop redundant doc/CHANGES4.X, improve README

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agodoc: Rename CHANGES to CHANGES2.0
Markus Armbruster [Fri, 11 Aug 2017 19:22:16 +0000 (21:22 +0200)]
doc: Rename CHANGES to CHANGES2.0

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo: Consistently spell Empire 2, 3 and 4 with a space
Markus Armbruster [Fri, 11 Aug 2017 18:31:26 +0000 (20:31 +0200)]
info: Consistently spell Empire 2, 3 and 4 with a space

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo/Clients: Outdated and misleading, delete
Markus Armbruster [Fri, 11 Aug 2017 18:09:51 +0000 (20:09 +0200)]
info/Clients: Outdated and misleading, delete

The .NA header promises information on "Clients which communicate well
with the Empire4 Server".  The page doesn't really deliver.  It talks
about client support for asynchronous notifications.  It stopped
listing separate client projects in 4.0.7 (1997).  Not mentioning such
clients isn't just outdated, it's actively misleading.

Perhaps an up-to-date info page on clients would be useful, but I
can't write one right now.  Delete.

Loses a bit of information for client developers that was tacked on in
4.0.7: pointers to dump commands, and an explanation of timestamps.  I
trust client writers can find "info xdump" without this.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo: Trim .SA of change log pages to just "Server"
Markus Armbruster [Fri, 11 Aug 2017 17:54:45 +0000 (19:54 +0200)]
info: Trim .SA of change log pages to just "Server"

Looks like an attempt was made to have .SA point to info pages for
significantly changed things.  It wasn't done consistently, though,
and it's impractical for Empire 4.  Drop these references, and keep
only "Server".

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo: Improve .NA and first paragraph of change log pages
Markus Armbruster [Fri, 11 Aug 2017 17:53:15 +0000 (19:53 +0200)]
info: Improve .NA and first paragraph of change log pages

The .NA show up in "info Server", like this:

   Chainsaw !   Changes from KSU Empire to Chainsaw code
    Empire2 !   Changes from the Chainsaw server to the Empire2 Server
    Empire3     Changes from the Empire2 server to the Empire3 Server
    Empire4 !   Changes from the Empire3 server to the Empire4 Server
[...]
       Merc     Changes from KSU code to Merc code
 Old-empire !   Differences from 1.2 to UCB Empire

Tweak them to look like this:

   Chainsaw !   Changes from KSU Empire to Chainsaw (1992-93)
    Empire2 !   Changes from Chainsaw to Empire 2 (1995)
    Empire3     Changes in Empire 3 (1995-96)
    Empire4 !   Changes in Empire 4 (1996-present)
[...]
       Merc     Changes from KSU code to Merc code (1992)
 Old-empire !   Differences from 1.2 to UCB Empire

The first paragraph of Empire2.t refers to "the new Empire 2" server.
Drop "new", because it clearly ain't anymore.  Same for Empire3.t.

The first paragraph of Empire4.t claims "several changes/fixes" have
been made.  Umm, that's only tenuously connected to reality by now.
Rewrite the paragraph.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo/Wolfpack: Redundant, delete
Markus Armbruster [Fri, 11 Aug 2017 17:34:28 +0000 (19:34 +0200)]
info/Wolfpack: Redundant, delete

The .TH and .NA header promise information about "Wolfpack Code" and
"The Wolfpack Project", but the body doesn't really deliver.  It's
basically the first paragraph of Empire4.t plus pointers to Options.t
and Empire.t.  Has been that way since it was added in 4.0.2.
History.t covers the Wolfpack project more usefully, so delete this
one.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo: Drop outdated bug report instructions
Markus Armbruster [Fri, 11 Aug 2017 17:04:12 +0000 (19:04 +0200)]
info: Drop outdated bug report instructions

Ken Stevens stopped maintaining Empire many years ago, but "info
Empire2" and "info Empire3" still direct users to him.  Drop that.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agotrade: Don't increase negative mobility to zero on trade
Markus Armbruster [Thu, 10 Aug 2017 04:45:42 +0000 (06:45 +0200)]
trade: Don't increase negative mobility to zero on trade

check_trade() sets plane and land unit mobility to zero on trade.
Even when it's negative.  Fix to leave it alone then.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo/Chainsaw: Rename from CHANGES.CHAINSAW
Markus Armbruster [Thu, 10 Aug 2017 04:19:10 +0000 (06:19 +0200)]
info/Chainsaw: Rename from CHANGES.CHAINSAW

No need to shout.  Name it like we do for other server versions instead.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo/Plane-types: Document helo takeoff/landing in mountains
Markus Armbruster [Sat, 5 Aug 2017 19:28:17 +0000 (21:28 +0200)]
info/Plane-types: Document helo takeoff/landing in mountains

Forgotten in commit 6157b6c.  While there, fix the references to "show
ship stats" headings, and say "to paradrop" instead of "to paratroop".

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoUse printf %d instead of %i, just for consistency
Markus Armbruster [Sat, 5 Aug 2017 19:15:15 +0000 (21:15 +0200)]
Use printf %d instead of %i, just for consistency

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoSpell ID and UID consistently all-caps
Markus Armbruster [Sat, 5 Aug 2017 19:14:20 +0000 (21:14 +0200)]
Spell ID and UID consistently all-caps

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo/territory: Drop the "id" from "territory id number"
Markus Armbruster [Sat, 5 Aug 2017 19:10:24 +0000 (21:10 +0200)]
info/territory: Drop the "id" from "territory id number"

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoman/fairland: Don't explain the default seed value
Markus Armbruster [Sat, 5 Aug 2017 19:03:34 +0000 (21:03 +0200)]
man/fairland: Don't explain the default seed value

How the default seed value is computed is an implementation detail of
no interest to the user.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoSpell the plural of an acronym consistently without apostrophe
Markus Armbruster [Sat, 5 Aug 2017 17:11:02 +0000 (19:11 +0200)]
Spell the plural of an acronym consistently without apostrophe

Opinions differ on how to pluralize acronyms[*], but let's be
consistent: say "BTUs", not "BTU's".

[*] https://en.wikipedia.org/wiki/Acronym#Representing_plurals_and_possessives

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoUse all-caps for a few acronyms and for "OK"
Markus Armbruster [Sat, 5 Aug 2017 16:52:17 +0000 (18:52 +0200)]
Use all-caps for a few acronyms and for "OK"

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoExpand a few unnecessary abbreviations in output text
Markus Armbruster [Sat, 5 Aug 2017 16:48:22 +0000 (18:48 +0200)]
Expand a few unnecessary abbreviations in output text

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agonavigate march: Say "to sweep mines" instead of "to minesweep"
Markus Armbruster [Sat, 5 Aug 2017 16:32:41 +0000 (18:32 +0200)]
navigate march: Say "to sweep mines" instead of "to minesweep"

The choice of "to minesweep" in "`d' to drop mines, and `m' to
minesweep" is obviously intentional.  But saying it in standard
English instead is at least as clear, so do that.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoCorrect spelling as one word and as two words
Markus Armbruster [Sat, 5 Aug 2017 16:29:36 +0000 (18:29 +0200)]
Correct spelling as one word and as two words

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoSpell harbor consistently
Markus Armbruster [Sat, 5 Aug 2017 15:04:23 +0000 (17:04 +0200)]
Spell harbor consistently

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoSpell BTU and ETU consistently
Markus Armbruster [Sun, 30 Jul 2017 14:55:04 +0000 (16:55 +0200)]
Spell BTU and ETU consistently

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoSpelling corrections
Markus Armbruster [Sun, 30 Jul 2017 14:49:03 +0000 (16:49 +0200)]
Spelling corrections

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoFix up a few identifier references in comments
Markus Armbruster [Mon, 24 Jul 2017 19:20:04 +0000 (21:20 +0200)]
Fix up a few identifier references in comments

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agobtu: Undo damage done to file comment in commit 9f25de3
Markus Armbruster [Mon, 24 Jul 2017 19:10:51 +0000 (21:10 +0200)]
btu: Undo damage done to file comment in commit 9f25de3

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoinfo/Mobility: Belatedly remove security unit mobility use
Markus Armbruster [Sat, 22 Jul 2017 09:41:45 +0000 (11:41 +0200)]
info/Mobility: Belatedly remove security unit mobility use

Missed in commit 39884af, v4.3.33.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agolwp: LwpCurrent can't be null, drop useless check
Markus Armbruster [Mon, 10 Jul 2017 18:39:02 +0000 (20:39 +0200)]
lwp: LwpCurrent can't be null, drop useless check

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agopowe: Delete dead assignment in gen_power().
Markus Armbruster [Mon, 10 Jul 2017 18:00:33 +0000 (20:00 +0200)]
powe: Delete dead assignment in gen_power().

It's been dead ever since commit 5635fc2 added it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoshow: Clean up long vs. int in fmttime2822() for Windows
Markus Armbruster [Sun, 9 Jul 2017 14:39:47 +0000 (16:39 +0200)]
show: Clean up long vs. int in fmttime2822() for Windows

fmttime2822() prints long with format %d, and passes long to abs().
Harmless, because both int and long are 32 bits in the Windows API.
Clean it up anyway.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
6 years agoMake: Fix distclean for separate build tree
Markus Armbruster [Sun, 9 Jul 2017 09:54:07 +0000 (11:54 +0200)]
Make: Fix distclean for separate build tree

Fix removal of autoconf-generated files in src/client/.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
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>