Commit graph

5413 commits

Author SHA1 Message Date
0d6130246c ef_verify: Reject invalid plane flag combinations
Any plane may have capabilities VTOL, helo, light.

Capability missile requires VTOL.

Anti-ballistic missiles have capabilities missile, SDI.

Anti-satellite missiles have capabilities missile, satellite.

Surface-to-air missiles have capabilities missile, intercept.

Anti-ship missiles have capabilities missile, marine, and may have
tactical.

Surface-to-surface missiles have capability missile, and may have
tactical.

Satellites have capability satellite, and may have spy, image.

Ordinary planes may have capabilities bomber, tactical, intercept,
cargo, spy, image, ASW, para, escort, mine, sweep.  Capability para
requires cargo; see para().

Only "missile requires VTOL" is enforced.  Enforce the rest.

Excluding P_O when asking for P_N is now redundant.  Drop that from
msl_abm_intercept().

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
0d53d1a6e9 launch interception: Drop support for ABM, a-sat consuming shells
Their impact on the target does not depend on shell load (it sometimes
did for a-sats until commit cf960a573 "Make anti-sat launch consistent
with interception", v4.3.23).  The shell use is logistical busy-work,
and economically irrelevant.  Remove it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
10060390f5 config: Change asat not to consume shells
The asat's impact on the target does not depend on its shell load (it
sometimes did until commit cf960a573 "Make anti-sat launch consistent
with interception", v4.3.23).  The shell use is logistical busy-work,
and economically irrelevant.  Remove it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
a677cc31d7 mission: Don't permit marine missiles on support missions
Marine missiles can't actually support, see perform_mission().  Make
the mission command reject them.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
8a65621275 mission: Fix an error message pasto going back to Chainsaw 3
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
6f3f78481d mission: Don't permit SAMs on escort missions
The mission code doesn't treat SAMs specially: they take off, fly out,
maybe fight, fly home, and land.  Landing triggers the oops in
pln_put1().

Letting SAMs escort makes no sense.  Fix the mission command to reject
them.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
1c7d9a67f6 info/Plane-types: Document SAM, ABM and a-sat missile abilities
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
9dfe007701 info: Clean up references to long-gone options
Option DEFENSE_INFRA was replaced in commit 4d1dd6fa6, v4.3.6.  Point
to the replacement instead.

Options SHIPCHOPPERS and XLIGHT were made non-optional in Empire 2.
Don't mention them.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
75e9b97ba0 retreat: Drop unused parameter @code
Unused since commit beedf8dce "retreat: Rewrite automatic retreat code
to fix its many bugs", v4.3.33.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
16f0a07725 lwp: Include signal.h instead of ucontext.h where possible
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
eb0721507e subs/attsub: Drop a stale comment
Stale since commit 6ac9ad66e (v4.3.20) silently dropped dead code for
supply of military.  Dead since commit 689f435af (v4.2.14) dropped
option GRAB_THINGS.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
e5bccdd52e assault attack board lboard paradrop: Fix defending land unit supply
get_dlist() collects defending land units in a list, and resupplies
them.  Bug: it uses a local copy instead of the one in the list.  When
att_fight() writes back the list, the commodities supplied get wiped
out, triggering a seqno oops.  Broken in commit 62b9399cd "subs:
Factor lnd_insque() out of lnd_sel(), ask_olist(), ...", v4.3.33.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
8fc2c0ffa2 Update copyright notice
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
1e64ece1f5 Drop macros AGREE_FREE, AGREE_PROPOSED, AGREE_SIGNED
Commit 555de3100 (v4.3.0) added these macros so xdump tables loan and
treaty can share an agreement_statuses table.  Treaties are gone since
commit a109de948 (v4.3.33).  Drop the macros.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
5ed11ffd57 doc/coding: Improve section "Portability" a bit
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
259200777e include: Move sarg.c stuff to nsc.h to avoid incomplete enum
Portability issue: prototypes.h uses enum ns_seltype, defined in
nsc.h.  GCC is fine with that; it supports incomplete enum types as an
extension.  Broken in commit 157ae8ec2 "Clean up superfluous include
of nsc.h in prototypes.h", v4.3.27.  Moving sarg.c stuff to nsc.h
fixes it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
528d644f02 common/pathfind: A more portable DPRINTF()
C99 requires at least one argument for the "..." in a variadic macro.
GCC and Clang don't care, but warn with -pedantic.  Solaris cc warns.

The warning is easy to avoid, so do it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:29 +01:00
e18d1dc589 configure: Move terminfo check next to readline check
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
e23d0f6259 m4/my_lib_readline: Fix check for additional libraries
MY_LIB_READLINE tries each readline-compatible library with a sequence
of additional libraries, starting with none.  If the check with none
fails, all the others checks reuse the cached result, and also fail.
Broken in commit 1cbda2c7d "client: Rewrite readline configuration",
v4.4.0.

Avoid the unwanted chaching.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
882379f883 Make: Use SHELL to run test scripts, since /bin/sh may suck
The test scripts need a POSIX-compliant Bourne shell.  /bin/sh isn't
on some systems, such as Solaris.  Run them with $(SHELL).

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
3f0718885a Make: Get SHELL from Autoconf
The default SHELL isn't POSIX on some systems, such as Solaris.  Use
the one Autoconf chooses instead of the default.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
f3c1edf8d2 Make: Slighly less verbose "make check" output
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
1a10b41ae8 info/Empire4.3: Work around "nroff: Out of temp file space"
Solaris 10's nroff can't deal with the lengthy .NF ... .FI: it
complains, writes truncated output, and terminates
successfully (*boggle*).  Split the .NF ... .FI in two.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
13362acc46 configure: Test GCC-specific compiler flags only when using GCC
Commit 23373d01d "configure: Test compiler flags" (v4.4.0) made
configure test whether compiler flags work, to let us use flags that
work only for some compilers.

Unfortunately, the Sun C compiler accepts invalid options with a
warning, breaking the test.  Observed on Solaris 10.

Fix by testing the compiler flags only when AC_PROG_CC detected GCC.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
6cff488537 bomb: Pass NULL instead of 0 to pln_damage()
Neglected in commit 820d755e5 "subs: Change pln_damage()'s parameter
noisy to string prefix", v4.3.33.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
e312e4f8d6 bomb launch interdiction: Fix crash on bombs missing target
plane damage() prints @noisy with snprintf() even when it's null.  It
doesn't actually use the output then.  Some systems (GNU, Windows)
deal gracefully with printing null strings, others crash.  @noisy is
null when bombers or missiles miss and do collateral damage.  Affects
bomb, launch, and interdiction missions.  Broken in commit 820d755e5
"subs: Change pln_damage()'s parameter noisy to string prefix",
v4.3.33.

Fix by guarding the snprintf().

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
77d3da4f09 Clarify build requirements
Document the need for the XSI Extension.  Don't list curses as
required, it's actually optional.  Correct advice for Solaris.  Add
advice for AIX.  Drop references to C89; we actually require C99, and
POSIX.1-2001 provides it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
deee99a01d Fix build for systems that don't provide POSIX.1-2001 by default
We require POSIX.1-2001.  Some systems provide it only with feature
test macro _POSIX_C_SOURCE defined to 200112L.  Since we don't define
it, the build fails there.  Observed on Solaris 10.

We actually require the XSI extension.  The GNU C Library provides it
by default.  With _POSIX_C_SOURCE 200112L, however, you have to define
feature test macro _XOPEN_SOURCE to get it.  But then _POSIX_C_SOURCE
is redundant.

Make configure put #define _XOPEN_SOURCE 600 into config.h.  Drop the
two existing #define _XOPEN_SOURCE 500 in .c files.

Now Solaris cc refuses to play ball unless switched to C99.  Replace
AC_PROG_CC by AC_PROG_CC_STDC to mollify it.

Unfortunately, use of _XOPEN_SOURCE exposes bugs in AIX libc and old
versions of GNU libc:

* AIX defines struct in6_addr's member s6_addr as a macro expanding
  into the actual member.  Without _ALL_SOURCE (the default), the
  expansion is wrong and doesn't compile.  Observed with AIX V7.2.

* GNU lib's IN6_IS_ADDR_V4MAPPED() is unusable without
  _DEFAULT_SOURCE (default) or _GNU_SOURCE.  Observed with Debian 8.
  Tracked at <https://sourceware.org/bugzilla/show_bug.cgi?id=16421>,
  fixed in version 2.25.

Affects just sockaddr_ntop()'s special case from commit 372cdb136 "Use
IPv4 format for IPv4-mapped addresses", v4.3.31.  Disable the special
case and use IPv6 format on such systems.  This is a very minor
usability regression.  Could be avoided, I guess, but it's not worth
the trouble.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
ab93877534 client: Drop use of getpass()
getpass() is traditional Unix, but has been withdrawn from POSIX.  We
still use it when it's available, and fall back to portable code only
when it's not.

The portable code behaves differently: it reads stdin instead of
/dev/tty, and in noncanonical mode.

Simplify things: always use the replacement.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
53b2271d1d client: Make get_password() not echo with POSIX && !HAVE_GETPASS
getpass() is traditional Unix, but has been withdrawn from POSIX.  We
provide a replacement in case it's missing.  The one for Windows
suppresses echo, like getpass() does.  Implement that for POSIX.  The
other differences to getpass() remain.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
ea762c1f08 client: Factor set_echo_if_tty() out of get_password()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
e551b6198d client: Move get_password() from login.c to getpass.c
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
f98747ae0e client: New get_password()
I'm going to drop use of getpass().  As a first step, weaken the bond
by hiding it in a separate function.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
057ca5b340 client: Reorder misc.h, and point to the .c
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
8a04586048 lwp: Simplify lwpSigWait() interface
lwpSigWait() was designed to resemble sigwait().  It doesn't anymore.
Drop the awkward argument, and use the return value instead.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
d89bda9998 lwp: Rename two variables for clarity
Rename LwpSigCaught to LwpPendingSig, and lwpCatchAwaitedSig() to
lwpHandleAwaitedSig().

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
8a1d9fbb4b lwp: Rewrite signal wait code for portability and safety
LWP's use of sigset_t is problematic.

To iterate over a sigset_t, it uses NSIG, which is not portable: BSD
and System V provide it, but it's not POSIX.

To record signals caught, it updates a sigset_t variable from a signal
handler.  The variable isn't volatile, because we'd have to cast away
volatile for sigaddset().

Replace sigset_t by an array of signal numbers terminated with 0.

Since lwpInitSigWait() needs to store the signal set for
lwpCatchAwaitedSig() anyway, there is no need to pass it to
lwpSigWait().  Drop its parameter.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
bfb558dee3 lwp: Fix signal wait screwup for multiple different signals
lwpSigWait() clears LwpSigCheck even when signals remain in
LwpSigCaught.  The next empth_wait_for_signal() will then wait until
another one gets caught.  Broken in commit fe2de3d74, v4.3.10.

Fix by clearing it only when LwpSigCaught is empty.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
7481482656 lwp: Fix handling of sigismember() failure
sigismember() fails when passed an invalid or unsupported signal
number.  lwpInitSigWait() and lwpGetSig() treat sigismember() failure
like "is a member".  lwpInitSigWait() will then sigaction()
unsuccessfully.  Harmless.  lwpGetSig() returns the bad signal number
when it's greater than any caught signal's number.  The bad signal
number then gets returned to main(), which shuts down the server.

Fix by treating failure like "is not a member".

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
5315db952d lwp: Fix unsafe update of LwpSigCaught
lwpCatchAwaitedSig() is not reentrant.  lwpInitSigWait() attempts to
protect it by setting an appropriate signal mask, but screws up.  This
could conceivably lose signals.  Messed up when it got added in commit
7183516d9, v4.3.6.  Fix it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
85ad194648 lwp: Drop inappropriate oops in lwpSigWait()
lwpSigWait()'s contract specifies failure, which means oopsing is
wrong.  Harmless, as its only caller empth_wait_for_signal() oopses on
failure.  Drop it anyway.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
1ebee96036 info: Use S_ISREG() instead of S_IFREG for readability
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
e91b4e3b6e info: Add #include <strings.h> for portability
We get strncasecmp() from <string.h>.  This is a BSDism; POSIX
provides it in <strings.h>.  Missed in commit 8fdd0259f2, v4.2.19.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
c3eb998396 Make: Fix build with tool chains that require depcomp
Commit fad8e7f7b "Move auxiliary build tools to build-aux/" moved
depcomp, but neglected to adjust Make.mk.  This broke the build with
tool chains that actually use depcomp.  Modern GCC and Clang don't.
Fix the obvious way.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
f06473fbb4 build-aux/git-version-gen: Refresh from Gnulib commit 4f78c231f4
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
d5ce86dfc8 build-aux INSTALL: Refresh from automake 1.16.3
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
5a828769de m4: Refresh macros from autoconf-archive commit fd1d25c148
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
ada4678128 config: Enlarge configuration tables that have variable size
Configuration tables product, sect-chr, ship-chr, plane-chr, land-chr,
nuke-chr have a bit of extra space deities can use for customizing
their games.  Give them more: enlarge product from 23 to 31
entries (plus one sentinel), sect-chr from 39 to 63, ship-chr from 47
to 127, plane-chr from 47 to 127, land-chr from 31 to 127, and
nuke-chr from 20 to 63.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
e379edc648 config: Drop configuration table size macros
Macros LND_TYPE_MAX, N_MAXNUKE, PLN_TYPE_MAX, P_MAX, SCT_TYPE_MAX,
SHP_TYPE_MAX are only used to size a single array each.  Eliminate.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00
a374e6435d Avoid SCT_TYPE_MAX, use ARRAY_SIZE() instead
The next commit will get rid of SCT_TYPE_MAX.  Prepare.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2021-01-17 21:24:28 +01:00