Commit graph

5266 commits

Author SHA1 Message Date
607f15a6f6 load unload lload lunload: Fix for areas starting with a digit
load and lload skip foreign ships unless explicitly named, and
suppress some error messages for ships not explicitly named.  Makes
sense, except the check for "explicitly named" is flawed: it checks
whether the argument starts with a digit.  Works as intended for lists
like 1/2/3.  Broken for areas that happen to start with a digit, such
as 0:9,0:5.  Visible in the load-tend test.

Screwed up when the feature was added in Empire 2.

Fix the obvious way: test for NS_LIST instead.  While there, drop the
p && *p guard, because it's always true after snxtitem().

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
581732dcd1 unload lunload: Say "Can't unload" instead of "Can't load"
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
3aa6c1b263 load: Replace variable load_unload by variable loading
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
7d2c09668c ltend: Reject zero amount more nicely
Unlike tend, ltend does nothing silently when asked to tend zero
commodities.  This may leave the player guessing why the command did
nothing.  Report the reason and fail the command, just like tend does.
While there, improve the prompt to match tend's.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
70008c1b9f tend: Fail more nicely when target can't take more commodities
We silently ignore target ships that can't take any more of the tended
commodity.  This may leave the player guessing why the command did
nothing.  Report the reason like this:

    cs   cargo ship (#150) can't hold more guns

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
be5b167ce6 tend: Report "cannot hold any" when tending to target, too
We report

    frg  frigate (#170) cannot hold any uncompensated workers

only when tending from target to tender, not for the other direction.
Report it there, too.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
a0dc5cbf16 tend: Refuse to give away civilians more nicely
Foreign target ships are silently ignored when tending civilians.
This may leave the player guessing why the command did nothing.
Report the reason similar to load does:

    Your civilians refuse to board cs   cargo ship (#162)!

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
2a8a6a5933 tend: Factor can_tend_to() out of tend(), tend_land()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
f3e093e915 tend: Fail more nicely when ships can't tend
Target ships that can't be tended at all are silently ignored.  This
may leave the player guessing why the command did nothing.  Report
them, but only when explicitly named.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
55643423f6 tend ltend: Fix to skip dead ships and land units for deities
Tending to a dead ship destroys, and tending from a dead ship revives.
Has always been that way.  Not actually a problem for ltend anymore,
because the dead can't carry or be carried since commit 64a53c90f0,
v4.3.17.

Fix by checking !own in addition to !player->owner

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
333cd7d6d3 tend: Factor can_tend_to() out of tend(), tend_land()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
18f3b84390 tend: Fix the amount tended in bulletin to recipient
The bulletin reports the total amount tended to all ships so far.
Broken in commit 1de48e53da (v4.3.0), not fixed in commit 7cc14a2c9a
(v4.3.1).  Fix the bulletin to report the amount tended to this ship.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
6035487287 tend ltend: Improve "cannot hold any" message
Report the exact ship, like

    frg  frigate (#170) cannot hold any uncompensated workers

instead of reporting just the ship type, like

    A frg  frigate cannot hold any uncompensated workers

This is a bit more useful when tending to more than one ship.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
f4dc2e1e79 tend ltend: Handle "cannot hold commodity" consistently
Transferring commodities from tenders to targets continues with the
next tender when a target can't hold this kind of commodity.
Transferring them from targets to tenders fails (ltend) or stops
tending (tend) when a tender can't hold this kind of commodity.  Has
always been that way.

Change the latter to continue with the next tender.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
3dc22e8497 tend ltend: Handle "don't have commodity" consistently
Transferring commodities from tenders to targets fails when a tender
doesn't have any.  Transferring them from targets to tenders continues
with the next target when a target doesn't have any.  Has always been
that way.

Change the former to continue with the next tender.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
1bde4df2bd tend ltend: Reject foreign tenders and land units more nicely
We silently ignore foreign ships and land units.  This may leave the
player guessing why the command did nothing.  Report explicitly named
ones like this

    You don't own ship #160!

except for tend's target ships.  Nice reporting is a bit more involved
there, because you can tend to foreign target ships as long as they're
friendly.  Left for later.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
eb5ed8802a ltend: Fail more nicely when land unit isn't on tender
Land units not on the tender are silently ignored.  This may leave the
player guessing why the command did nothing.  Reporting them all would
be annoying; I just changed tend to report only explicitly named ones.
Make ltend behave the same.

This does add a related annoyance: ltend can complain "not on ship"
when tending explicitly selected land units from multiple ships.
Tolerable.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
15a43a780a tend: Suppress "not on ship" unless land unit is selected by UID
The quickest way to tend all land units on a ship is to select all
land units with '*'.  However, tend then prints a "not on ship"
message for every land unit not on the tender, as the load-tend test
demonstrates.  Annoying.  Suppress this message unless the land unit
was explictly selected by UID.  Similar to how load and unload
suppress messages, only they get the condition wrong (to be fixed
soon).

A related annoyance remains, also visible in the load-tend test: tend
can still complain "not on ship" many times when tending explicitly
selected land units from multiple ships.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
3064731af4 tend: Don't tend land units to multiple target ships
Each land unit is tended to each target ship in turn, and ends up on
the last one that can take it..  The load-tend test demonstrates this
with command "tend land 173 s 150/165":

    spy  infiltrator #320 transferred from sbc  cargo submarine (#173) to cs   cargo ship (#150)
    spy  infiltrator #320 transferred from sbc  cargo submarine (#173) to ls   landing ship (#165)
    spy  infiltrator #321 is not on sbc  cargo submarine (#173)!
    spy  infiltrator #322 transferred from sbc  cargo submarine (#173) to cs   cargo ship (#150)
    spy  infiltrator #322 transferred from sbc  cargo submarine (#173) to ls   landing ship (#165)

Has been that way ever since Empire 2 added tending of land units.

Fix by breaking tend_land()'s loop over all target ships after a
successful transfer.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:17 +01:00
68945c8ff8 tests/load-tend: New; exercises load and tend commands
Exercise load, unload, lload, lunload, tend, and ltend.

Notable coverage gaps:

* Effect on land unit fortification

* Effect on mission and retreat orders

* Ships, land units and planes on sale (option MARKET 1)

* Transmission of plague (option NO_PLAGUE 0)

* Land units loading and unloading civilians (need a custom land unit
  type capable of carrying civilians)

* load refusing to load x-light planes (need a custom ship type that
  can carry helo but not x-light)

* load and lload refusing to load land units carrying land units, and
  lload refusing to load land units onto land units that are being
  carried (need a custom non-heavy land unit type that can carry land
  units)

* tend refusing to tend non-light land units to non-supply ships, or
  to supply ships without room (need custom a non-light assault land
  unit type)

This test exposes bugs.  They're marked "BUG:" in the test input.
There are also oddities marked "odd:", and usability issues marked
"usability:".

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:25:15 +01:00
fd303fc6b3 edit: Implement editing of missile fortification
The edit command doesn't support editing plane fortification.  Has
always been that way.  Implement it as key 'F'.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:23:45 +01:00
4746d22c3e tests/actofgod: Test integer values more thoroughly
For integer values, we test lower bound - 1, lower bound, upper bound,
upper bound + 1.  Additionally test lower bound + 1, upper bound -1.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:23:45 +01:00
5363ef85d4 tests/actofgod: Fix owner of plane 7/8
Planes 7/8 aren't visible in output, because the test neglects to set
their owner.  Messed up in commit commit efec441, v4.3.33.  Correct
that oversight.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:23:45 +01:00
16e565ed5f edit: Implement editing bars on ships and land units
The edit command doesn't support editing bars on ships and land units.
Has always been that way.  The stock game's ships have always been
unable to load bars.  Not the case for land units.

Unfortunately, the obvious key 'b' for bars was burned on plague time
in 4.0.17.  Use key 'B' instead.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:23:45 +01:00
647dc66a40 tests/actofgod: Test give and edit for each item type
The test covers only 'c' and 'l' with give, 'm' and 'g' with edit.
Cover the other item types, too.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:23:45 +01:00
2902cc22c4 edit: Print ship and land unit items with field width 5
print_items() uses field widths between 3 and 5.  They go back all the
way to Empire 1, and are fine for the stock game.  Widen the narrower
ones to 5, because a consistent field width looks tidier, and can
avoid misaligned columns with customized ships and land units.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:23:45 +01:00
6e320cc625 edit: Factor print_items() out of print_land(), print_ship()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-05 07:23:45 +01:00
60429028e7 update/revolt: Fix land unit casualties
Fix the bug demonstrated by the previous commit:
take_casualties_from_lands() limits total casualties to @each.  It
should limit each land unit's casualties, and only if !may_kill.  This
can lead to fewer casualties than called for; oops in
take_casualties().  Broken in commit 025e9cc25, v4.4.0.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2018-04-29 10:33:48 +02:00
d111522fe8 Update copyright notice
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2018-04-29 10:33:19 +02:00
9fcd254538 tests/update: Demonstrate take_casualties_from_lands() bug
Tweak military in land units to demonstrate that
take_casualties_from_lands() can kill fewer military than it should.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2018-04-10 16:48:20 +02:00
5dee2b16d5 tests/update: Belatedly update for commit 35ecc008c
Commit 35ecc008c fixed take_casualties() to destroy land units only
when casualties demand it.  This test demonstrated the change: inf#29
no longer dies.  Good.  However, this lost coverage of land units
dying in a sucessful defense.  Bad.

I could tweak inf#29 to get destroyed again, but that would lose
coverage of the bug fixed by commit 35ecc008c.  Make linf#28 die
instead.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2018-04-10 16:47:54 +02:00
fffff8680b info/Empire4.4: Fix a botched 4.4.0 change log entry
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-10 17:40:07 +02:00
11756fc9c9 ef_verify: Fix error message in verify_land_chr()
It points to the wrong table.  Screwed up in commit 33800fc.  Correct
the pasto.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-03 17:59:03 +02:00
689652d1b0 info/Empire4.4: Update release date once more
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-03 17:59:00 +02:00
664f640979 info/retreat info/lretreat: Fix truncated glossary list items
Text after the first space is missing in the formatted output.  That's
because .L takes just one argument, but we pass several.  Broken in
commit 4e0d02b, v4.3.33.  Fix by quoting the argument text.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-03 11:11:50 +02:00
e6d2615648 scripts/backup: Fix initialization of $email
Mostly harmless in practice, since $email is typically unset.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-03 10:44:02 +02:00
f0dbddd590 scripts/savecore: Amend the hint on core_pattern, drop stray ';'
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-03 10:41:05 +02:00
30382d9d03 scripts src/scripts: Clean up inconsistent shell variable quoting
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-09-03 10:37:11 +02:00
0447b529bd Make: Make src/scripts/gen-tarball-version a bit nicer
When autoconf is stale, include a reminder how to fix that in the
error message.

While there, cd to $nv like we do in src/scripts/gen-client-configure
for slightly terser code.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-03 10:28:06 +02:00
b0bea7418a Make: Fix src/scripts/tarball argument parsing
The test for -x uses non-portable operator ==.  Screwed up in commit
63c6dd6.  Fix by using getopts instead.

Missing mandatory arguments aren't diagnosed.  Screwed up in initial
commit 1991652, v4.3.0.  Fix by checking shift's return status.

The error message for missing argument of -C neglects to print $0 and
uses echo in a non-portable way.  Also screwed up in commit 1991652.
Fix the obvious way.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-03 10:26:47 +02:00
8e8bed5865 configure: Fix botched fix of .tarball-version access
Commit ece998e fixed .tarball-version access from separate build tree
by adding $srcdir/ to it.  That's wrong in m4_esyscmd(), because there
it runs at autoconf time, where $srcdir isn't necessary and doesn't
exist.  Revert that part.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-03 07:39:11 +02:00
e87bef161f client: Belatedly add dependencies for fnameat.o
Forgotten in commit a0220e8.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-02 23:08:09 +02:00
5e1b590867 Make: Support shallow git clones for testing
Since commit 1ec9b94, we derive the version number from git tags with
build-aux/git-version-gen.  When a shallow clone doesn't include a
suitable tag, this fails, and make refuses to build anything.  Since
Travis uses git-clone --depth=50, it'll break as soon as we've got
more than 50 commits since the last release.

Support arbitrarily shallow clones for limited purposes like testing
by falling back from a proper V.N-H version number to UNKNOWN-H.

To guard against use of such builds for other purposes, log a warning
on server startup, and print one on player login.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-02 17:51:37 +02:00
41ce9e37fd Bind Travis notifications to main mirror
Signed-off-by: Gerd Flaig <gefla@pond.sub.org>
Message-Id: <877exhmdk6.fsf@oxygen.pond.sub.org>
[Comment clarified slightly]
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-02 15:37:01 +02:00
ec513bb2aa README: Advise on lack of readline
Missed in commit f1fc0df.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-02 15:03:45 +02:00
3a13ba1f1f client: Add a missing #include <string.h>
play.c needs <string.h> since commit f1fc0df.  My version of
<readline/readline.h> pulls it in, but at least Apple's (derived from
NetBSD's) doesn't, and we get warnings then.  Add the missing

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-02 15:01:17 +02:00
ece998e064 configure: Fix .tarball-version access from separate build tree
configure reads .tarball-version when the source tree isn't
git-controlled.  Fails when the build tree is separate.  Fix it to
read $srcdir/.tarball-version.

The occurence in Make.mk isn't wrong, because VPATH applies there.
Change it anyway, for consistency and a bit of extra robustness.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-02 15:00:14 +02:00
74396d7fbf info/Empire4.4: Update release date
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-01 20:21:09 +02:00
6d1e4dcdfa info/Update-sequence: Explicitly document prepare order
Sectors, ships, planes and land units are always visited in the same
order, but it doesn't hurt to be explicit.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2017-09-01 20:17:15 +02:00
6ab4848cc7 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>
2017-08-27 11:31:58 +02:00