empserver
3 years agoUpdate change log timestamp for 4.3.33 v4.3.33
Markus Armbruster [Wed, 20 May 2015 18:20:40 +0000 (20:20 +0200)]
Update change log timestamp for 4.3.33

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoRevert "commands: Always put ship or land unit before retreating it"
Markus Armbruster [Sun, 17 May 2015 16:11:20 +0000 (18:11 +0200)]
Revert "commands: Always put ship or land unit before retreating it"

This reverts commit f4d8d64bb34dee75cb2485c130e125fdd3980c18.

Breaks retreat after ship got sunk by bombs or missile.

ship_bomb() and launch_missile() pass .shp_own to retreat_ship().
Wrong after putship(), because putship() resets the owner when the
ship got sunk.  retreat_ship() then oopses and fails to retreat the
surviving members of the group.

Other callers save the owner before putting the ship, and pass that.
We could change these two to do the same.  But since we're trying to
get a release out, simply revert the broken commit instead.

3 years agoTidy up some comments
Markus Armbruster [Sun, 17 May 2015 16:08:45 +0000 (18:08 +0200)]
Tidy up some comments

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoUpdate change log again for 4.3.33
Markus Armbruster [Thu, 14 May 2015 07:46:13 +0000 (09:46 +0200)]
Update change log again for 4.3.33

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoImprove portability to really outmoded compilers
Markus Armbruster [Thu, 14 May 2015 07:27:05 +0000 (09:27 +0200)]
Improve portability to really outmoded compilers

A few modernisms have crept in:

* Trailing comma in enum definition (commit 71320ed, v4.3.10)

* // comment (commit 265e71e, v4.3.11)

* <stdint.h> (commit 9102ecc, v4.3.31)

  MSC actually chokes on this one.

Avoid them.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoxundump: Pass unsigned * for scanf directive %3o, not int *
Markus Armbruster [Thu, 14 May 2015 07:03:27 +0000 (09:03 +0200)]
xundump: Pass unsigned * for scanf directive %3o, not int *

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agordsched: Pass unsigned * for scanf directive %u, not int *
Markus Armbruster [Thu, 14 May 2015 06:57:52 +0000 (08:57 +0200)]
rdsched: Pass unsigned * for scanf directive %u, not int *

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoinfo/History: Cover removal of Autonav, SAIL and TREATIES
Markus Armbruster [Sun, 5 Apr 2015 09:53:07 +0000 (11:53 +0200)]
info/History: Cover removal of Autonav, SAIL and TREATIES

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agow32/strptime: Fix for 64 bit pointers
Markus Armbruster [Sun, 5 Apr 2015 07:45:11 +0000 (09:45 +0200)]
w32/strptime: Fix for 64 bit pointers

The __UNCONST() stolen from NetBSD assumes unsigned long can hold a
pointer.  Not true with Win64's LLP64 data model.  There, we cast the
64 bit pointer to 32 bits and back.  Works only because Windows puts
the stack at a very low address, and the casts don't actually change
the pointer.

Dumb it down to a straight cast to void * for safety.

Thanks to Harald Katzer and Ron Koenderink for their help figuring out
the bug's impact.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoUpdate change log again for 4.3.33
Markus Armbruster [Fri, 13 Mar 2015 06:07:03 +0000 (07:07 +0100)]
Update change log again for 4.3.33

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoINSTALL: Refresh from automake 1.13
Markus Armbruster [Sun, 8 Mar 2015 17:23:33 +0000 (18:23 +0100)]
INSTALL: Refresh from automake 1.13

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoman: Get rid of unwanted space in SYNOPSIS
Markus Armbruster [Sun, 8 Mar 2015 16:48:17 +0000 (17:48 +0100)]
man: Get rid of unwanted space in SYNOPSIS

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoclient: New option -r for restricted mode
Marisa Giancarla [Sat, 7 Dec 2013 15:43:13 +0000 (16:43 +0100)]
client: New option -r for restricted mode

Redirections and the execute command let the user read and write files
and run programs on the local system.

Restricted mode prevents such access.  This is useful when you want to
grant somebody access to just Empire, but not to the host system's
user account that runs the client.

Signed-off-by: Marisa Giancarla <fstltna@me.com>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotorpedo mission: Print rounded, not truncated hit chance
Markus Armbruster [Sun, 8 Mar 2015 13:58:04 +0000 (14:58 +0100)]
torpedo mission: Print rounded, not truncated hit chance

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agobuild: Fix inexact calculation of required materials
Markus Armbruster [Sun, 8 Mar 2015 13:06:02 +0000 (14:06 +0100)]
build: Fix inexact calculation of required materials

sector_can_build() computes mat[i] * (effic / 100.0).  The division is
inexact.  The result gets randomly rounded, so errors are vanishingly
unlikely to screw up material consumption.

However, we require the amount rounded up to be present since commit
1227d2c.  Errors *can* screw that up.  Fix by avoiding inexact
computation for that part.

We should probably review rounding of inexact values in general.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests/README: Cover info.ps and document .NA use for commands
Markus Armbruster [Sun, 8 Mar 2015 11:44:02 +0000 (12:44 +0100)]
tests/README: Cover info.ps and document .NA use for commands

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests/README: Update for replacement of info/checklist.pl
Markus Armbruster [Sun, 8 Mar 2015 11:42:00 +0000 (12:42 +0100)]
tests/README: Update for replacement of info/checklist.pl

Replaced by tests/info-test in commit 90eaf9d.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agobuild-aux: Refresh from automake 1.13
Markus Armbruster [Thu, 5 Mar 2015 20:23:46 +0000 (21:23 +0100)]
build-aux: Refresh from automake 1.13

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agom4: Refresh from autoconf-archive v2015.02.24
Markus Armbruster [Wed, 4 Mar 2015 19:07:00 +0000 (20:07 +0100)]
m4: Refresh from autoconf-archive v2015.02.24

commit dd946914edb9da25e2d8c8b2186fab5d8103f3d4
Author: Daniel Richard G <skunk@iSKUNK.ORG>
Date:   Thu Oct 3 18:56:24 2013 +0200

    AX_PTHREAD: add support for Clang

    Further details can be found at <http://savannah.gnu.org/patch/?8186>.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests: Rewrite the previous commit's sed_i helper
Markus Armbruster [Wed, 4 Mar 2015 07:15:13 +0000 (08:15 +0100)]
tests: Rewrite the previous commit's sed_i helper

Last night's version looks unnecessarily ugly in the morning.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests: Avoid non-portable sed -i
Markus Armbruster [Tue, 3 Mar 2015 19:45:03 +0000 (20:45 +0100)]
tests: Avoid non-portable sed -i

Crept in in commit 7c3186f.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests: Fix for builds outside git-controlled source tree
Markus Armbruster [Tue, 3 Mar 2015 19:09:50 +0000 (20:09 +0100)]
tests: Fix for builds outside git-controlled source tree

We run "git ls-files" in the build tree.  Doesn't work when the source
directory isn't a git repository, or the build directory is outside
the source directory.  Broken in commit 71cb2d8.

Find source files like Make.mk does: if the source tree is a git
repository, use git ls-files, else use sources.mk.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoBelatedly bump version to 4.3.33
Markus Armbruster [Mon, 2 Mar 2015 20:16:27 +0000 (21:16 +0100)]
Belatedly bump version to 4.3.33

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agobridgefall: Clean up literal 20 to SCT_MINEFF
Markus Armbruster [Sun, 1 Mar 2015 17:02:14 +0000 (18:02 +0100)]
bridgefall: Clean up literal 20 to SCT_MINEFF

Messed up in commit 4824648.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoUpdate change log for 4.3.33
Markus Armbruster [Sun, 1 Mar 2015 10:14:00 +0000 (11:14 +0100)]
Update change log for 4.3.33

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoadd: Drop syntax deprecated in 4.3.29
Markus Armbruster [Sun, 1 Mar 2015 09:02:25 +0000 (10:02 +0100)]
add: Drop syntax deprecated in 4.3.29

Deprecated in commit 373f20a: argument "new".

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agosubs/move: Drop syntax deprecated in 4.3.27
Markus Armbruster [Sun, 1 Mar 2015 08:58:55 +0000 (09:58 +0100)]
subs/move: Drop syntax deprecated in 4.3.27

Deprecated in commit 28d4847: no space between 'm' and its first
argument.  Affects explore, move, test, transport.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agomaps: Drop bmap flags syntax deprecated in 4.3.27
Markus Armbruster [Sun, 1 Mar 2015 08:47:19 +0000 (09:47 +0100)]
maps: Drop bmap flags syntax deprecated in 4.3.27

Deprecated in commit a00f9e2: 'r' with flags, and bad flags after 't'.
Affects flags argument of bmap, sbmap, pbmap, lbmap, nbmap, and
navigate and march sub-command 'B'.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoinfo/fire: Drop misinformation on damage varying with gun size
Markus Armbruster [Sun, 22 Feb 2015 09:55:40 +0000 (10:55 +0100)]
info/fire: Drop misinformation on damage varying with gun size

Goes all the way back to Empire 1, and as far as I can tell was
misleading there already.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoinfo/fire info/torpedo: Purge references to option MULTIFIRE
Markus Armbruster [Sun, 22 Feb 2015 09:49:58 +0000 (10:49 +0100)]
info/fire info/torpedo: Purge references to option MULTIFIRE

MULTIFIRE became non-optional in Chainsaw 3, more than two decades
ago.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoemp_config: Don't monkey-patch WORLD_X to be even
Markus Armbruster [Sun, 22 Feb 2015 07:04:41 +0000 (08:04 +0100)]
emp_config: Don't monkey-patch WORLD_X to be even

emp_config() silently truncates WORLD_X to even.  Drop that.  We could
flag odd WORLD_X as error, but we don't validate the other
configuration values, so why this one?  Instead document it needs to
be even.  WORLD_Y, too.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoef_verify: Polish product error message
Markus Armbruster [Sat, 21 Feb 2015 18:07:44 +0000 (19:07 +0100)]
ef_verify: Polish product error message

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoinit ef_verify: Don't monkey-patch capability VTOL, require it
Markus Armbruster [Sat, 21 Feb 2015 17:56:32 +0000 (18:56 +0100)]
init ef_verify: Don't monkey-patch capability VTOL, require it

A plane with capability missile must have capability VTOL.  When it's
missing, global_init() silently adds it.

Drop that.  Check for it in ef_verify_config() instead.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoinit ef_verify: Don't monkey-patch capability miss, require it
Markus Armbruster [Sat, 21 Feb 2015 17:19:39 +0000 (18:19 +0100)]
init ef_verify: Don't monkey-patch capability miss, require it

A ship with non-zero nplanes must have capability plane or miss.  When
one doesn't, global_init() silently adds capability miss.

Drop that.  Check for it in ef_verify_config() instead.  Fix up
ship.config accordingly.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoef_verify: Require ship glim != 0 with capability dchrg
Markus Armbruster [Sat, 21 Feb 2015 17:12:07 +0000 (18:12 +0100)]
ef_verify: Require ship glim != 0 with capability dchrg

Because the fire command doesn't work with zero glim (commit a109de9).

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotorpedo: Suppress bulletin when player torpedoes his own ship
Markus Armbruster [Sun, 15 Feb 2015 14:22:01 +0000 (15:22 +0100)]
torpedo: Suppress bulletin when player torpedoes his own ship

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotorpedo: Print "Starting our attack run" regardless of target
Markus Armbruster [Sun, 15 Feb 2015 14:06:14 +0000 (15:06 +0100)]
torpedo: Print "Starting our attack run" regardless of target

Instead of printing it only when the target owned by somebody else.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotorpedo: Let torpedo hit land only when target is in range
Markus Armbruster [Sun, 15 Feb 2015 13:25:39 +0000 (14:25 +0100)]
torpedo: Let torpedo hit land only when target is in range

Telling the player his torpedo "slams into land" can give a clue on
the direction to the target.  No good when the target is out of range,
because we shouldn't tell the player more than that then.

Screwed up in 4.2.2.  Fix by checking range before line of sight.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoinfo/torpedo: Fix misinformation on submarine identification
Markus Armbruster [Sun, 15 Feb 2015 08:57:13 +0000 (09:57 +0100)]
info/torpedo: Fix misinformation on submarine identification

Claims the victim of a torpedo attack gets told the attacking ship's
number.  This hasn't been the case for submarines since Empire 2.3.
Recent commits again reveal the attacking submarine's number, but only
when it gets hit by return fire.  Update info accordingly.

Reported-by: Neeraj Jain <thisisfranz@gmail.com>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoinfo/torpedo: Cover return torpedoes, drop depth charge details
Markus Armbruster [Sun, 15 Feb 2015 08:52:51 +0000 (09:52 +0100)]
info/torpedo: Cover return torpedoes, drop depth charge details

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotorpedo fire: Reveal sub hit by return fire or depth charge
Markus Armbruster [Sun, 15 Feb 2015 07:58:20 +0000 (08:58 +0100)]
torpedo fire: Reveal sub hit by return fire or depth charge

This partly reverts a change made in Empire 2.3 to tell a submarine's
opponent only that he's dealing with a "sub" instead of the
submarine's UID and type.  Hiding submarines is done by prsub().
Uses:

* Command torpedo: defender depth charges or torpedoes an attacking
  submarine

  If you can attack a submarine reactively, you should be able to
  attack it actively, too.  But that requires its UID.  Reveal it
  again, but keep the type hidden.

* Command fire: defender fires back at a submarine using its deck gun

  Submarines need to surface to fire deck guns, so they shouldn't be
  treated any different than surface ships.  Revert Empire 2.3's
  change entirely there, i.e. defender learns type as well as UID.

* Command torpedo: attacking submarine hits its target

  Keep the submarine hidden.

* Commands torpedo and fire: attacking ship hits a submarine

  The attacker passed the UID as command argument, so it doesn't
  matter whether we print it or not.  Printing it is simpler to code,
  so do that.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotorpedo: New variable sub_mcp to make code more concise
Markus Armbruster [Sun, 15 Feb 2015 07:47:43 +0000 (08:47 +0100)]
torpedo: New variable sub_mcp to make code more concise

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests/torpedo: New; exercises torpedo command
Markus Armbruster [Sat, 14 Feb 2015 17:20:01 +0000 (18:20 +0100)]
tests/torpedo: New; exercises torpedo command

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests/fire: Cover firing at unused / sunk ships
Markus Armbruster [Sat, 14 Feb 2015 10:15:23 +0000 (11:15 +0100)]
tests/fire: Cover firing at unused / sunk ships

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests/fire: Cover firing with foreign assets
Markus Armbruster [Sat, 14 Feb 2015 10:14:11 +0000 (11:14 +0100)]
tests/fire: Cover firing with foreign assets

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agofire: Clean up damage sanity check and printing of range
Markus Armbruster [Sun, 8 Feb 2015 11:45:52 +0000 (12:45 +0100)]
fire: Clean up damage sanity check and printing of range

Repeated for ship, sector and land unit firing.  The latter prints
range only when the sanity check succeeds.

Factor out, changing ship and sector to behave like land unit firing.

When the sanity check fails, print "Jammed!" instead of "Klick!",
because "Klick!" suggests no shells.  Used to be printed exactly then,
but the condition first became impossible (Chainsaw), then generalized
to "can't fire for whatever reason" (commit 22c6fd8, v4.3.12).

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoRevert "Permit ships that can drop depth charges, but not fire"
Markus Armbruster [Sun, 8 Feb 2015 11:38:55 +0000 (12:38 +0100)]
Revert "Permit ships that can drop depth charges, but not fire"

This reverts commit 9b0b0dc7729b7fadc09d5769cc1128341b3c3d33.

The fire command drops depth charges when the target is a submarine in
range and firing ship has the capability.  Else, it blindly fires
guns.  It used to reject ships that can't use guns, even when they
could use depth charges, but commit 9b0b0dc (v4.3.31) lifted that
restruction.  No such ships exist in the stock game.

If the firing ship can't fire guns, shp_fire() returns -1, triggering
an oops.  Broken in commit 0757042.

Avoiding dependence of depth charge on gun fire capability is
pleasing, but nevertheless a bad idea without test coverage.  Creating
the necessary tests isn't worth it, so put back the traditional
restriction instead.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agofire: Print "Kaboom" even when the target is out of range
Markus Armbruster [Sun, 8 Feb 2015 11:29:22 +0000 (12:29 +0100)]
fire: Print "Kaboom" even when the target is out of range

To make shell use more obvious.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agofire: Simplify logic to use depth charges rather than guns
Markus Armbruster [Sun, 8 Feb 2015 11:20:56 +0000 (12:20 +0100)]
fire: Simplify logic to use depth charges rather than guns

Meaning of targ_sub changes from "target is a submarine" to "attacking
the target with depth charges".

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agofire: Drop a sanity check that can't fail
Markus Armbruster [Sun, 8 Feb 2015 11:09:05 +0000 (12:09 +0100)]
fire: Drop a sanity check that can't fail

Can't fail since commit 66165f3, v4.3.14.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agofire: Always clear mission when firing
Markus Armbruster [Sat, 7 Feb 2015 16:57:54 +0000 (17:57 +0100)]
fire: Always clear mission when firing

Mission is cleared only when firing at a target that is out of range.
Screwed up when missions were added in Chainsaw.  Always clear it when
firing.  Matches torpedo.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests/fire: Cover mission clearing
Markus Armbruster [Sat, 7 Feb 2015 16:34:32 +0000 (17:34 +0100)]
tests/fire: Cover mission clearing

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests/fire: Show all ships, planes, land units after the test
Markus Armbruster [Sat, 7 Feb 2015 16:28:39 +0000 (17:28 +0100)]
tests/fire: Show all ships, planes, land units after the test

Instead of just the damaged ones.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agofire: Fix artillery splashing the bridge span under itself
Markus Armbruster [Sat, 7 Feb 2015 14:49:03 +0000 (15:49 +0100)]
fire: Fix artillery splashing the bridge span under itself

multifire() writes back the firing sector after applying damage.  When
an artillery unit on a bridge span commits suicide by shelling down
the supporting bridge heads, this writeback puts the bridge span right
back (less the land units and planes on it), triggering a seqno oops.
On the next update of the bridge head, the bridge span falls again.
Broken in commit fe5b266, v4.3.14.

The problematic write back is superfluous.  Remove it along with a few
equally superfluous ones.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoboard: Fix mobility cost when defender's efficiency < 100%
Markus Armbruster [Tue, 3 Feb 2015 06:44:23 +0000 (07:44 +0100)]
board: Fix mobility cost when defender's efficiency < 100%

The cost is meant to be proportional to efficiency / 100, but the code
truncates the fraction to zero.  Broken in Empire 2.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoconvert: Drop broken code to charge security unit mobility
Markus Armbruster [Sun, 1 Feb 2015 16:48:58 +0000 (17:48 +0100)]
convert: Drop broken code to charge security unit mobility

Conversion is easier when land units with capability security are
present.  Each such land unit is charged 10 mobility.  The mobility
charge is undocumented.

Land unit mobility is charged even when conversion turns out to be
impossible, say because the sector has no mobility.  I call this a
bug.  Has been that way since security land units were added in
Chainsaw 3.

Except the mobility charge doesn't actually work anymore: the changed
land unit is never written back.  Broken in commit 82c9166, v4.3.16.
Fix this bug would be trivial, but would bring back the bug described
above, and fixing that one is harder, and doesn't feel worthwhile.

Remove the broken charging of land unit mobility instead.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agobomb: Fix damage to mobility when bombing planes
Markus Armbruster [Sun, 1 Feb 2015 16:24:51 +0000 (17:24 +0100)]
bomb: Fix damage to mobility when bombing planes

A bombed plane's mobility is multiplied by dam/100.0, i.e. the higher
the damage, the lower the mobility loss.  Has always been broken.  Fix
by computing the new mobility with damage(), like we do elsewhere.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agocommands: Always put ship or land unit before retreating it
Markus Armbruster [Mon, 12 Jan 2015 21:19:32 +0000 (22:19 +0100)]
commands: Always put ship or land unit before retreating it

boar() puts before retreating, the other callers afterwards.  Subtle
difference, because putting resets the owner of the dead to POGO.

Until the commit before previous, retreat didn't fully work after put.
Now it does.  The subtle difference between boar() and the other
callers still exists.  It's better to do it the same everywhere, as
subtle differences invite bugs.  Since changing boar() is not
practical, change the others.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agosonar: Drop a redundant putship()
Markus Armbruster [Mon, 12 Jan 2015 21:13:36 +0000 (22:13 +0100)]
sonar: Drop a redundant putship()

The old retreat_ship() took care not to put its ship argument (it
still put other ships in a group retreat).  Callers put it
unconditionally to make the change to the ship permanent.

The current retreat code puts all ships it changes, rendering sona()'s
putship() redundant.  Drop it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoretreat: Fix group retreat after failed board sinks ship
Markus Armbruster [Mon, 12 Jan 2015 20:19:02 +0000 (21:19 +0100)]
retreat: Fix group retreat after failed board sinks ship

Group retreat still doesn't work, because when boar() passes a sunk
ship to retreat_ship(), its owner has been reset to POGO already.
This makes it impossible to find the group to retreat.  Instead, it
attempts to retreat ships that sank in the same sector with group
retreat orders and with the same fleet letter assigned.  If any exist,
shp_may_nav() oopses, and prevents actual retreat of these ghosts.

The other retreat conditions don't have this problem, because they
call putship(), which resets the owner, only after retreat_ship().

Making boar() work the same is not practical.  Instead, add an owner
parameter to retreat_ship(), and for symmetry also to retreat_land().

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoRevert "retreat: Oops on retreating ghosts"
Markus Armbruster [Mon, 12 Jan 2015 19:13:44 +0000 (20:13 +0100)]
Revert "retreat: Oops on retreating ghosts"

This reverts commit c3a839934f159b72b510cecb45c8c396efb38119.

The commit message's claim that the code never actually retreats
ghosts is wrong: boar() does.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Conflicts:
src/lib/subs/retreat.c

3 years agoboard: Don't retreat ship#0 after failed board sinks ship
Markus Armbruster [Mon, 12 Jan 2015 19:07:17 +0000 (20:07 +0100)]
board: Don't retreat ship#0 after failed board sinks ship

The root cause is in put_combat(): after it sinks the ship, it calls
att_get_combat(), which treats a combat object with a dead ship as an
error, tells the attacker "not in the same sector!", and "recovers" by
putting the combat object into an error state.  Too hard for me to fix
right now, so put in a FIXME comment.

The error state trips up retreat.  boar() uses the victim's ship
number in the combat object to find the ship it may have to retreat.
Putting the combat object into an error state sets this number to
zero.  If that ship exists, and isn't owned by the attacker, and has
RET_BOARDED set, it retreats.  Oops.  Broken when Empire 2 factored
out common combat code.

Fix by saving the ship number while it's still valid.

This uncovers the next bug: we now pass a dead ship to retreat_ship().
Oopses since commit f743f37.  Its commit message says "Harmless, but
avoid it anyway."  Going to revert.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests/retreat: Cover retreat after failed board sinks victim
Markus Armbruster [Mon, 12 Jan 2015 18:37:55 +0000 (19:37 +0100)]
tests/retreat: Cover retreat after failed board sinks victim

Should trigger group retreat, but doesn't; marked "BUG:" in the test
input.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotorpedo: Fix news on owner of ships sunk by return torpedoes
Markus Armbruster [Sun, 11 Jan 2015 16:53:05 +0000 (17:53 +0100)]
torpedo: Fix news on owner of ships sunk by return torpedoes

fire_torp() reads targ->shp_own after putship().  If targ sank, its
owner is POGO by then.  Screwed up when return torpedoes were added in
Chainsaw.  Fix by reporting news before putship().

torp() is correct, because it gets the owner from a local variable.
Change it like fire_torp() anyway.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotorpedo: Don't disclose uid, type, owner of torpedoed subs
Markus Armbruster [Sun, 11 Jan 2015 16:50:09 +0000 (17:50 +0100)]
torpedo: Don't disclose uid, type, owner of torpedoed subs

torp() reports target uid and type to the player.  Hide for submarine
targets, just like we hide attacking submarine details in bulletins to
the target's owner.

torp() and fire_torp() leak submarine owners through the news.
Suppress news for submarine targets.  This is consistent with fire:
mfir() doesn't report depth-charging, and quiet_bigdef() doesn't
report return torpedoes.

Historical note: the code has always hidden submarine uid, type and
owner in places, and leaked them in others.  When capability sub-torp
was added in Chainsaw, no attention was paid to hiding.  When Empire 2
hid attacking submarines, it did nothing for submarine targets.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agobomb: Drop empty line after a ship's "blam-blam"
Markus Armbruster [Sun, 11 Jan 2015 14:12:17 +0000 (15:12 +0100)]
bomb: Drop empty line after a ship's "blam-blam"

It's only printed for ships.  Looks misplaced when it's followed by
"sunk" or other damage reports.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agobomb: Include position when reporting bombed land unit
Markus Armbruster [Sun, 11 Jan 2015 14:05:34 +0000 (15:05 +0100)]
bomb: Include position when reporting bombed land unit

Use the exact same format as for ships.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agobomb: Suppress bulletin when player bombs his own assets
Markus Armbruster [Sun, 11 Jan 2015 14:02:16 +0000 (15:02 +0100)]
bomb: Suppress bulletin when player bombs his own assets

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agobomb: Fix to report bombing of plane to owner once, not twice
Markus Armbruster [Sun, 11 Jan 2015 13:59:54 +0000 (14:59 +0100)]
bomb: Fix to report bombing of plane to owner once, not twice

Has always been broken that way.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agosubs: Make correctness of some wu() uses more obvious
Markus Armbruster [Sun, 11 Jan 2015 13:12:37 +0000 (14:12 +0100)]
subs: Make correctness of some wu() uses more obvious

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoassault attack paradrop: Fix inconsistent support formatting
Markus Armbruster [Sun, 11 Jan 2015 12:52:27 +0000 (13:52 +0100)]
assault attack paradrop: Fix inconsistent support formatting

With offensive support but no defensive support, there's no empty line
separating the support table from the text that follows.  Fix that.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agosubs: De-duplicate formatting in intelligence_report()
Markus Armbruster [Sun, 11 Jan 2015 12:38:40 +0000 (13:38 +0100)]
subs: De-duplicate formatting in intelligence_report()

Every piece is formatted either with pr(), or with sprintf() for later
sending with wu().  The output is actually identical.  Format with
sprintf() always, and then either pr() or wu() the results.

While there, change the first parameter's type from int to natid.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agosubs: Oops when a telegram doesn't end with a newline
Markus Armbruster [Sun, 11 Jan 2015 12:24:08 +0000 (13:24 +0100)]
subs: Oops when a telegram doesn't end with a newline

Telegrams should always end with a newline.  The common cause for a
missing newline is misuse of wu() to print partial lines.  Almost
always works, as the read command merges telegrams arriving in quick
succession.  But if the telegrams are more than five seconds apart
(clock jumped somehow), we get a telegram header in the middle of a
line.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agosubs: Clean up misuse of wu() around mission bomb damage
Markus Armbruster [Sun, 11 Jan 2015 12:06:54 +0000 (13:06 +0100)]
subs: Clean up misuse of wu() around mission bomb damage

Don't use multiple calls of wu() to print a single line, because that
creates a separate bulletin for each part.  The read command normally
merges the bulletins, but if the bulletins are more than five seconds
apart (clock jumped somehow), we get a bulletin header in the middle
of a line.  Unlikely to happen, but it also messes up pln_damage()'s
line wrapping (see commit e002bf2).  Clean it up.

The wu() misuse was introduced in Empire 2.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agosubs: Change pln_damage()'s parameter noisy to string prefix
Markus Armbruster [Sun, 11 Jan 2015 11:59:24 +0000 (12:59 +0100)]
subs: Change pln_damage()'s parameter noisy to string prefix

No functional change for now.  The next commit will put it to use.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoupdate: Clean up misuse of wu() in prod_nat()
Markus Armbruster [Sun, 11 Jan 2015 11:25:03 +0000 (12:25 +0100)]
update: Clean up misuse of wu() in prod_nat()

Don't use multiple calls of wu() to print a single line, because that
creates a separate telegram for each part.  The read command normally
merges the telegrams, but if they are more than five seconds apart
(clock jumped somehow), we get a telegram header in the middle of a
line.  Unlikely to happen, but clean it up anyway.

The misuse has always been there.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agobomb: Fix to reject attempts to bomb unused planes
Markus Armbruster [Sun, 11 Jan 2015 09:35:22 +0000 (10:35 +0100)]
bomb: Fix to reject attempts to bomb unused planes

Report "not spotted", like we do for unused ships and land units.
Missed in commit 23d52a4, v4.3,16.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoretreat lretreat: Be less loquacious when changing orders
Markus Armbruster [Sat, 10 Jan 2015 09:23:48 +0000 (10:23 +0100)]
retreat lretreat: Be less loquacious when changing orders

Instead of listing all the ships or land units ordered, just print how
many got ordered, and describe the order, like this:

    [0:640] Command : retr 2/3 bg itb
    2 ships ordered to retreat along path bg when injured, torpedoed, bombed
    [0:640] Command : retr 2 h
    1 ship ordered not to retreat

fleetadd doesn't list the ships it reassigns, either.  On the other
hand, stop lists the sectors it stops.  Perhaps it should be gagged,
too.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests: Wean off deprecated retreat syntax
Markus Armbruster [Sat, 10 Jan 2015 13:25:52 +0000 (14:25 +0100)]
tests: Wean off deprecated retreat syntax

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoretreat lretreat: Deprecate pseudo-condition 'c'
Markus Armbruster [Sat, 10 Jan 2015 13:16:00 +0000 (14:16 +0100)]
retreat lretreat: Deprecate pseudo-condition 'c'

It's redundant; retreat path 'h' cancels orders just fine.  Document
that instead.  'c' still works, and I don't plan to break it as long
as it doesn't get in the way, which seems unlikely.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoretreat lretreat: Change query syntax to match mission
Markus Armbruster [Sat, 10 Jan 2015 12:43:23 +0000 (13:43 +0100)]
retreat lretreat: Change query syntax to match mission

Optional arguments can save typing.  Mandatory arguments are more
easily discoverable: just run the command and answer its prompts.
Empire traditionally uses optional arguments only for expert features.
Consider mission:

    [0:640] Command : mission
    Ship, plane or land unit (p,sh,la)? s
    ship(s)? 0
    Mission (int, sup, osup, dsup, esc, res, air, query, clear)? int
    operations point? .
    frg  frigate Early Bird(#0) on an interdiction mission, centered on 21,-3, radius 0
    1 ship

Compare retreat:

    [0:638] Command : retreat
    ship(s)? 0
    shp#     ship type       x,y   fl path       as flt?  flags
       0 frg  frigate       21,-3
    1 ship

Arguments are not discoverable this way.

Change retreat to work like mission: make the second argument
mandatory, and if it's 'q', show retreat orders, else treat it as path
and ask for conditions:

    [0:637] Command : retreat
    ship(s)? 0
    Retreat path, or q to query? jj
    Retreat conditions ('?' to list available ones)? i
    shp#     ship type       x,y   fl path       as flt?  flags
       0 frg  frigate       21,-3     jj                  i
    1 ship

To reduce smart client and script breakage, keep retreat with one
argument working as before, but print a deprecation warning.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoretreat lretreat: Strip trailing 'h' from retreat path
Markus Armbruster [Sat, 10 Jan 2015 09:03:33 +0000 (10:03 +0100)]
retreat lretreat: Strip trailing 'h' from retreat path

Has no effect now.  Before the recent rewrite of automatic retreat, it
could be used to trigger group retreat while staying put.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoinfo torpedo: Say "torpedo", not "torp"
Markus Armbruster [Sat, 10 Jan 2015 08:08:25 +0000 (09:08 +0100)]
info torpedo: Say "torpedo", not "torp"

Documentation and player output should use proper words.  "torp" ain't
one.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoretreat lretreat edit xdump: Change "torped" to "torpedoed"
Markus Armbruster [Sat, 10 Jan 2015 07:52:59 +0000 (08:52 +0100)]
retreat lretreat edit xdump: Change "torped" to "torpedoed"

"torped" comes from symbol table retreat_flags.  Visible in output of
edit, retreat, lretreat and xdump.  Tolerable in edit, but player
commands like retreat should really use proper words.

Fixing it in retreat_flags changes xdump output, thus risks breaking
clients.  Do it anyway, since no known client recognizes this
particular symbol value.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agosymbol: New symbol_set_fmt() parameter sep, use for show
Markus Armbruster [Sat, 10 Jan 2015 07:39:48 +0000 (08:39 +0100)]
symbol: New symbol_set_fmt() parameter sep, use for show

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agosymbol: Make actofgod.c's fmtflags() public as symbol_set_fmt()
Markus Armbruster [Sat, 10 Jan 2015 07:29:55 +0000 (08:29 +0100)]
symbol: Make actofgod.c's fmtflags() public as symbol_set_fmt()

Move to nstreval.c, rename, external linkage.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agobomb: Fix ship list header for ASW planes
Markus Armbruster [Sat, 10 Jan 2015 06:22:05 +0000 (07:22 +0100)]
bomb: Fix ship list header for ASW planes

The code to list ships got triplicated in Chainsaw.  Empire 2 screwed
up one copy in its global replace of owner by player->owner.

Fix it by de-duplicating.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agosubs: Drop a few superfluous variables
Markus Armbruster [Sat, 10 Jan 2015 06:19:14 +0000 (07:19 +0100)]
subs: Drop a few superfluous variables

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agolaunch name trade: Check for getstarg() failure immediately
Markus Armbruster [Fri, 9 Jan 2015 15:25:34 +0000 (16:25 +0100)]
launch name trade: Check for getstarg() failure immediately

Rather than after post-yield sanity checking.  Just to make it obvious
that we are handling getstarg() failure.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests: Fix crash when getstarg() fails
Markus Armbruster [Fri, 9 Jan 2015 15:19:13 +0000 (16:19 +0100)]
tests: Fix crash when getstarg() fails

Screwed up when test-suite-only command __cmd was added in commit
e852d45.  Should never happen with the intended use.  Fix it anyway.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoretreat lretreat: Fix crash when getstarg() fails
Markus Armbruster [Fri, 9 Jan 2015 15:12:29 +0000 (16:12 +0100)]
retreat lretreat: Fix crash when getstarg() fails

Broken in commit 40ec33b.  Mitigating factor: can only happen when the
player gives an empty argument, e.g. retreat 0 "".

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoretreat: Rewrite automatic retreat code to fix its many bugs
Markus Armbruster [Wed, 7 Jan 2015 18:38:53 +0000 (19:38 +0100)]
retreat: Rewrite automatic retreat code to fix its many bugs

Much of the retreat code duplicates navigate and march code.  Worse,
retreat's version is full of bugs:

* Land units can sometimes retreat when they couldn't march: while on
  the trading block (forbidden with march since 4.0.9), crewless
  (likewise since 4.0.0), kidnapped in a foreign sector (inconsistent
  since land units were added in Chainsaw 3), loaded on a ship
  (likewise) or a land unit (inconsistent since trains were added in
  4.0.0).

* Ships can retreat while on the trading block (forbidden with
  navigate since 4.0.9)

* Land units can't retreat into foreign sectors even though they could
  march there, namely when sector is allied or the land unit is a spy.
  They can march there since 4.0.0.

* Land units keep their fortification on retreat.  Has been that way
  since retreat was added in Chainsaw.

Then there's group retreat.  It's basically crazy:

* It triggers retreat for everyone in the same fleet or army, one
  after the other, regardless of retreat path, conditions (including
  group retreat), or even location.  The latter is quite abusable
  since retreats aren't interdicted.  Has been that way since retreat
  was added in Chainsaw.

* Group retreat fails to trigger when the originally retreating ship
  or land unit has no retreat path left when it's done.  Broken in
  commit b860123.

Finally, the reporting to the owner is sub-par:

* When a retreat is cut short by insufficient mobility or
  obstructions, its end sector isn't reported, leaving the player
  guessing.

* Non-retreats can be confusingly reported as retreat to the same
  sector.  Can happen when the retreat path starts with 'h' (obscure
  feature to suppress a single retreat), or when a group retreat
  includes a ship or land unit without retreat orders.

* Interaction with mines during retreat is reported before the retreat
  itself, which can be quite confusing.

* Sweeping landmines isn't reported at all.

* Much code and much bulletin text is dedicated to reporting what
  caused the retreat, even though it should be perfectly obvious.

Rewrite this on top of common navigate and march code.  Reuse of
common code fixes the "can retreat when it couldn't navigate/march"
and the "can't retreat into sectors it could navigate or march into"
bugs, and improves the reporting.

One special case isn't a bug fix but a rule change: mountains.  The
old code forbids that explicitly, and it's clearly intentional, if
undocumented.  The new code allows it by not doing anything special.

Turn group retreat into an actual group retreat: everyone in the same
fleet and sector with the the same retreat path and group retreat
condition joins the group.  The group retreats together, just like in
navigate and march.

Take care to always report the end sector.  When retreat is
impossible, report "can't retreat".  When retreat is partial, report
"and stays in X,Y".  When it's complete, report "stopped at X,Y".

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests/retreat: Test mission clearing more thoroughly
Markus Armbruster [Wed, 7 Jan 2015 16:45:26 +0000 (17:45 +0100)]
tests/retreat: Test mission clearing more thoroughly

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests/retreat: Cover spies
Markus Armbruster [Wed, 7 Jan 2015 14:26:04 +0000 (15:26 +0100)]
tests/retreat: Cover spies

This exposes yet another bug.  It's marked "BUG:" in the test input.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests/retreat: Cover trains
Markus Armbruster [Wed, 7 Jan 2015 13:54:21 +0000 (14:54 +0100)]
tests/retreat: Cover trains

This exposes yet another bug.  It's marked "BUG:" in the test input.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests/retreat: Cover canals
Markus Armbruster [Wed, 7 Jan 2015 13:36:53 +0000 (14:36 +0100)]
tests/retreat: Cover canals

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agotests/retreat: Cover ships and land units on sale
Markus Armbruster [Wed, 7 Jan 2015 13:29:32 +0000 (14:29 +0100)]
tests/retreat: Cover ships and land units on sale

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

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoretreat: Don't report a destroyed ship/land unit couldn't retreat
Markus Armbruster [Wed, 7 Jan 2015 13:16:01 +0000 (14:16 +0100)]
retreat: Don't report a destroyed ship/land unit couldn't retreat

Commit df8a1ff redone without breaking stuff.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
3 years agoRevert "retreat: Don't report a destroyed ship/land unit couldn't retreat"
Markus Armbruster [Wed, 7 Jan 2015 13:12:40 +0000 (14:12 +0100)]
Revert "retreat: Don't report a destroyed ship/land unit couldn't retreat"

This reverts commit df8a1ffc1bf77567e4972810d5c729a73fcb42e6.

Because it breaks group retreat.  Trivial conflicts due to the removal
of option SAIL.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Conflicts:
src/lib/subs/retreat.c
tests/retreat/journal.log

3 years agotests/retreat: Improve group retreat coverage
Markus Armbruster [Wed, 7 Jan 2015 11:12:04 +0000 (12:12 +0100)]
tests/retreat: Improve group retreat coverage

This exposes more bugs.  They're marked "BUG:" in the test input.  A
few bugs get masked, but I'll unmask them again in the next commit.

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