empserver
13 months agotravis: Specify dist to fix Linux build v4.4.0-rc2
Markus Armbruster [Sat, 26 Aug 2017 07:11:27 +0000 (09:11 +0200)]
travis: Specify dist to fix Linux build

The build fails on Travis since we require autoconf 2.69 (commit
db055a).  Travis still defaults to Ubuntu Precise, and Precise's
autoconf is too old.  We could revert commit db055a and rely on Travis
to keep things working with old autoconf.  But Precise reached end of
life a couple of months ago, and I suspect it's only a matter of time
until Travis drops it, too.

Fix the build on Travis by requesting Trusty.  Its end of life is
planned for April 2019.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
13 months agotravis: Configure notifications
Gerd Flaig [Thu, 24 Aug 2017 11:43:10 +0000 (13:43 +0200)]
travis: Configure notifications

Notifications go to the mailing list and to the IRC channel.

Signed-off-by: Gerd Flaig <gefla@pond.sub.org>
Message-Id: <871so1nqcx.fsf@oxygen.pond.sub.org>
[Commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
14 months agoDrop superfluous #include
Markus Armbruster [Tue, 22 Aug 2017 18:12:42 +0000 (20:12 +0200)]
Drop superfluous #include

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
14 months agoMake: Make "make dist" catch stale configure
Markus Armbruster [Sun, 13 Aug 2017 12:18:37 +0000 (14:18 +0200)]
Make: Make "make dist" catch stale configure

As commit 1ec9b94 explains, the version reported by configure is fixed
at configure generation time.  "make dist" happily distributes a stale
one.  Not terrible, because all that's stale is the output of
configure --version, just embarrassing.

Make gen-tarball-version fail when the configure --version doesn't
match the tarball version.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
14 months agoMake: Fix configure generated for dist-client
Markus Armbruster [Sun, 13 Aug 2017 12:11:06 +0000 (14:11 +0200)]
Make: Fix configure generated for dist-client

Commit 1ec9b94 broke regeneration of configure for dist-client: it
uses .tarball-version, which exists only in the tarball, not in the
source tree.

Generating the client's autoconf stuff into the source tree is a
questionable idea anyway, as it won't run there.  Generate it while
building the tarball instead.

Bonus: doesn't distribute a useless .dirty-stamp.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
14 months agoMake: Move .tarball-version generation out of src/scripts/tarball
Markus Armbruster [Sun, 13 Aug 2017 12:00:16 +0000 (14:00 +0200)]
Make: Move .tarball-version generation out of src/scripts/tarball

Commit 1ec9b94 made src/scripts/tarball generate .tarball-version and
.dirty-stamp.  Hardcoding it like that there is a bit ugly.

Move it into a separate tweak script that is run right before tar.
We'll tweak some more in the next commits.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
14 months agosrc/scripts/tarball: Clean up to prepare for the next commit
Markus Armbruster [Sun, 13 Aug 2017 11:38:10 +0000 (13:38 +0200)]
src/scripts/tarball: Clean up to prepare for the next commit

We don't save $1 in a variable, only $1-$2.  Okay, because we don't
need $1 by itself.  However, the next commit will.  So save it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
14 months agoDrop stale comment from .gitignore
Markus Armbruster [Sun, 13 Aug 2017 11:25:03 +0000 (13:25 +0200)]
Drop stale comment from .gitignore

Commit e597257 folded $(bld_distgen) into $(src_distgen), but
neglected to update comments in .gitignore.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
14 months agoMake: Drop unused variable VERSION
Markus Armbruster [Sun, 13 Aug 2017 08:50:27 +0000 (10:50 +0200)]
Make: Drop unused variable VERSION

Missed in commit 1ec9b94.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
14 months agoMake: Fix "make dist" to remake stale files in $(srcdir) v4.4.0-rc1
Markus Armbruster [Sat, 12 Aug 2017 08:13:29 +0000 (10:13 +0200)]
Make: Fix "make dist" to remake stale files in $(srcdir)

Broken in commit bb0f3a6.  VPATH claims another victim.

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

14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>