Commit graph

3477 commits

Author SHA1 Message Date
7c6e56bd02 Fix assault not to send bogus telex to country 0
Happened when a spy got caught sneaking ashore and shot.
2009-03-10 20:50:47 +01:00
c16ed9c405 Bump version to 4.3.22 2009-03-10 20:50:01 +01:00
2fb427b676 Fix distclean to remove generated files distributed in client tarball 2009-03-10 13:08:15 +01:00
82b5e3c29a Really fix bomb not to wipe out plane updates
Commit f07e6901 didn't fix it completely.
2009-03-10 12:51:44 +01:00
009fc1403c Update change log again for 4.3.21 2009-03-09 22:35:18 +01:00
d0db465382 Fix swapsector not to wipe out concurrent updates.
Make swaps() bail out if any of the sectors changed while edit() slept
for input.
2009-03-09 22:32:10 +01:00
8df262bada Update change log again for 4.3.21 2009-03-09 21:33:30 +01:00
aa734fa7b1 Fix outdated comment 2009-03-09 21:33:23 +01:00
b510ee5345 Fix crash dump not to mess up streams
Crash dump forks a child to call abort().  abort() may flush or close
streams.  This is unwelcome, because it can mess up streams in the
parent.  Observed with the journal.  Could theoretically also affect
commands info, read, turn, and wire; announcement expiry, and reading
of econfig and schedule.

Fix by using SIGABRT instead.

Note that flushing streams before fork() is not a sufficient fix,
because closing a stream can still move the file descriptor's file
position.  Do it anyway, to ensure any buffered output is visible to
post_crash_dump_hook.
2009-03-09 21:25:46 +01:00
84008cf870 Update change log again for 4.3.21 2009-03-08 18:24:32 +01:00
f07e6901cb Fix bomb not to wipe out plane updates while asking for targets
The commands to fly planes read the planes into a plane list, and
write them back when they land.  If a plane changes in the file while
it is in that plane list, the changes get wiped out when the plane
lands, triggering a seqno oops.

This is not an issue as long as the complete sortie runs
uninterrupted, because that code takes care to update flying planes
only through the appropriate plane list.

However, the bomb command suspends the planes on a pinpoint bombing
run mid-air over the target sector to let the player choose targets.
This lets code run that *can* update flying planes, for instance the
edit command.

Fix by aborting changed planes, taking care not to clobber the
changes.
2009-03-08 18:19:25 +01:00
f10af4dea0 Fix bombing of submarines with mixed force
When bombing ships with a force containing both planes with and
without capability ASW, pin_bomb() could fail to report presence of
submarines, and could refuse to bomb ships when there were only
submarines.  The culprit is pin_bomb()'s check for capability ASW: it
checked whether the first plane in the plane list was capable instead
of checking whether any plane in the list was capable.
2009-03-08 17:36:37 +01:00
f760150d8f Rename plane_caps() to pln_caps() and give it external linkage 2009-03-08 17:14:59 +01:00
fa03ba9aad Update change log for 4.3.21 2009-03-08 14:44:29 +01:00
e03eaeae23 Fix a bug in attack that could wipe out land unit updates
A victorious attacker can move attacking land units into the newly
conquered sector or leave them behind.  Normally, the player is asked
what to do, but when the land unit's army has already been told to
stay behind, or the command has been aborted, the land unit stays
behind without asking.  In that case, a copy of the land unit made
right after the victory was written back.  Any updates since the
victory were wiped out, triggering a seqno mismatch oops.

Fix by moving the re-read of the land unit in ask_move_in() out of the
prompt conditional.
2009-03-08 11:54:04 +01:00
6b75c21e3c Factor obj_changed() out of check_sect_ok() & friends 2009-03-08 09:01:56 +01:00
940092ffb9 Ignore timestamps in check_loan_ok() & friends
check_loan_ok(), check_comm_ok() and check_trade_ok() should have been
changed to ignore timestamps when timestamps were added to their files
in commit a680c811, v4.3.12.
2009-03-08 09:01:40 +01:00
eea9e76bf8 Don't log out player when update aborts a command with pthreads
pthread.c's empth_select() returned -1 when empth_wakeup() interrupted
select().  The failure then got propagated all the way up, and the
player got logged out.  Fix by returning 0 in that case.  While there,
retry on EINTR, to match LWP.  Also clarify comments.
2009-03-01 13:04:48 +01:00
5073b022fd Remove unused empth_terminate()
Unused since 4.3.10.  Can be used safely only in very special
circumstances.

Removal allows simplifying pthread.c and ntthread.c some.  liblwp left
alone.
2009-03-01 10:49:48 +01:00
3e4894c7f5 Don't log out player when update aborts a command
recvclient() confused command abortion with an idle timeout.  Broken
in commit 08b94556, v4.3.20.
2009-02-25 22:53:33 +01:00
12b432163c Bump version to 4.3.21 2009-02-21 15:18:55 +01:00
d87a9eb61b Update change log again for 4.3.20 2009-02-20 19:15:01 +01:00
6d8a53f9d9 Disable LOANS and enable RAILWAYS by default 2009-02-19 22:06:41 +01:00
ee20a9cd34 Update known contributors comments 2009-02-18 21:11:33 +01:00
dd8921218b Fix make dist in a separate build directory without git, really
Make didn't remake sources.mk even though it was a phony target.  I
don't understand why.  But we can just as well create it in its only
user, dist-source.
2009-02-17 23:00:07 +01:00
6d6301afe8 Update change log for 4.3.20 2009-02-17 20:14:32 +01:00
2c0e7df5ea Fix a few inaccuracies in info supply 2009-02-17 19:32:14 +01:00
59c3913b2f Take care not to supply from self
Change s_commod() not to use the supply sink as source.  As explained
in the message of the commit before the previous one, using the sink
as source makes it impossible for callers to safely keep a copy of the
sink across a supply call.  All current users do that.  Some were safe
anyway, some were not:

* fort_fire() was safe, because a fort draws shells only when it has
  none.

* shp_fire() was unsafe for ships with capability supply and ammo use
  greater than 1.  No such ship exists in the stock game.

* shp_dchrg() was unsafe for ships with both capabilities dchrg and
  supply.  Same for shp_torp() and capability torp, and
  shp_missile_defense() and capability anti-missile.  No such ship
  exists in the stock game.

* lnd_fire(), supp() and get_dlist() were safe, because they draw
  shells only when they have less than their ammo need, and then they
  don't supply any.

* mission_pln_equip() was unsafe when equipping planes with shells in
  supply sources.

* landmine() was unsafe for land units with both capability engineer
  and supply.  No such land units exist in the stock game.

* load() and lload() were unsafe for loadable supply units, but the
  supply use there was disabled in commit 65410d16 because of another
  bug.

* ask_olist() and att_reacting_units() were safe, because
  lnd_can_attack() excludes supply units.

In the stock game, planes flying interception or support missions,
abms intercepting ballistic missiles, launch of missiles or anti-sats
could conjure up shells, triggering a seqno mismatch oops.

In games with unusual customizations, this could also happen with
supply ships firing guns or torpedoes, dropping depth charges, or
shooting down marine missiles, and in the lmine command.
2009-02-17 19:32:14 +01:00
98f24d5cf9 Redesign s_commod()
To implement the supply from self avoidance described in the previous
commit's message, s_commod() needs to be redesigned along the same
principles: take the sink as argument, update and put it.  Also take
an item limit argument, and return whether supply request was fully
met.

Update sct_supply(), shp_supply(), lnd_supply() and
lnd_could_be_supplied().  The former three become straighforward
wrappers.

supply_commod() and try_supply_commod() are now unused, remove them.
2009-02-17 19:32:14 +01:00
322f96ecb7 Redesign automatic supply interface
The automatic supply interface has design flaws that make it hard to
use correctly.  Its current uses are in fact all wrong (until commit
0179fd86, the update had a few uses that might have been correct).
Some of the bugs can only bite with land unit capability combinations
that don't exist in the stock game, though.

Automatic supply draws supplies from supply sources in range.  Since
that can update any supply source in range, all copies of potential
supply sources a caller may keep can get invalidated.  Writing back
such an invalid copy wipes out the deduction of supplies and mobility
from a source, triggering a seqno mismatch oops.

This commit redesigns the interface so that callers can safely keep a
copy of the object drawing the supplies (the "supply sink").  The idea
is to pass the sink to the supply code, so it can avoid using it as
source.  The actual avoiding will be implemented in a later commit.

Copies other than the supply sink still need to be eliminated.  See
commit 65410d16 for an example.

Other improvements to help avoid common errors:

* Supply functions are commonly used to ensure the sink has a certain
  amount of supplies.  A common error is to fetch that amount
  regardless of how many the sink already has.  It's more convenient
  for such users to pass how many they need to have instead of how
  many to get.

* A common use of supply functions is to get supplies for immediate
  use.  If that use turns out not to be possible after all, the
  supplies need to be added somewhere, which is all too easy to
  forget.  Many bugs of this kind have been fixed over time, and there
  are still some left.  This class of bugs can be avoided by adding
  the supplies to the sink automatically.

In fact, this commit fixes precisely such bugs in mission_pln_equip()
and shp_missile_defense(): plane interception and support missions,
missile interception (abms), launch of ballistic missiles and
anti-sats could all lose shells, or supply more than needed.

Replace supply_commod() by new sct_supply(), shp_supply(),
lnd_supply(), and resupply_all() by new lnd_supply_all().  Simplify
users accordingly.

There's just one use of resupply_commod() left, in landmine().  Use
lnd_supply_all() there, and remove resupply_commod().
2009-02-17 19:31:37 +01:00
6ac9ad66e1 Don't let automatic supply starve the sector containing the sink
Automatic supply always leaves enough food to avoid starvation in
supply sources, except for one case: when drawing supplies from the
sector containing the sink.

This behavior contradicted info supply.  However, do_feed() used to
rely on it (it would have wiped out food without it).  Supply use
there was removed in commit 7da69c92, so we can now fix this.

Affected by this is the automatic food supply of land units in combat,
and the food supply in commands supply, load and lload.  Except supply
is disabled due to bugs in the last two.
2009-02-17 19:30:35 +01:00
c4a0f99573 Fix mobility cost of automatic supply from remote sector
When a supply request got served completely from a remote sector after
some other source had already provided some of it, the sector was
charged mobility for the complete amount instead of just the part it
actually provided.
2009-02-17 19:30:35 +01:00
ed5ca70cb2 Disable recursive supply of land units
Its implementation in s_commod() increases lnd_seqno even when
!actually_doit, which can cause spurious seqno oopses in callers of
lnd_could_be_supplied().  I can't be bothered to clean up this mess
right now, because recursive resupply is too dumb to be really useful
anyway: each step uses the first source it finds, without
consideration of mobility cost.
2009-02-17 19:30:35 +01:00
5ea0d19c20 Fix automatic supply of defending and reacting units
Being in supply is relevant for defending and reacting units.  The
code used has_supply() to check that.

Contrary to its name, has_supply() does not check whether the land
unit has enough supplies to be in supply, but whether it has or could
draw enough.  So, defending and reacting units did not actually draw
any missing supplies.

Fix that in get_dlist() and att_reacting_units() by calling
resupply_all(), then checking with new lnd_in_supply() instead of
has_supply().  The fix of att_reacting_units() is complicated by the
fact that it is also used in the strength command, and should keep not
drawing supplies there.

Rename has_supply() to lnd_could_be_supplied().  Replace its uses
immediately after resupply_all() by lnd_in_supply().
2009-02-17 19:30:35 +01:00
07561b4772 Don't resupply supply unit after use as supply source
Running supply recursively here is problematic, because it can draw
supplies from the outer supply's destination, which can then end up
with less than it asked for.

Serving as supply source never puts a unit that is in supply out of
supply.  So, the recursive supply here denies the sink its supplies to
put a supply unit somewhere else back in supply.  That's robbing Peter
to pay Paul.  Drop it.
2009-02-17 19:30:35 +01:00
2b7163f10a Remove special case supply of land units from ships carrying them
The common supply code does not supply a land unit from the ship
carrying it, only resupply_all() does that, since 4.3.14.  It would be
nice to fix the inconsistency by always supplying land units that way,
but that's relatively costly now, because of the supply code's design.
Just drop it for now.

Affects load and lload (except resupply is disabled there because it's
buggy), supply, assault and board.
2009-02-17 19:30:35 +01:00
d58b306780 Don't suggest only supply ships can tend in info tend and ltend 2009-02-17 19:30:35 +01:00
c42c96f976 Don't lie about shell supply in info fire
It claimed ships and land units don't need shells if they can draw
them from a supply source.  That was never true for ships, I believe,
and became wrong for land units in commit f6c87d21.
2009-02-17 19:30:35 +01:00
9dd9679377 Clean up info lmine a bit 2009-02-17 19:30:34 +01:00
fbaef4794e Fix lmine for engineers that don't use ammo
landmine() used resupply_commod() to get shells, but that doesn't get
any unless the engineer uses ammo.  Use supply_commod() instead.
2009-02-17 19:30:13 +01:00
bc2989a3b3 Don't permit landmine laying in foreign sectors 2009-02-17 19:28:33 +01:00
8fa4f6d507 Fix lmine's "out of" messages
Don't claim "now out of supply" when actually out of mobility.

Don't claim "out of supply" when actually out of shells.  A land unit
is out of supply when out of shells, but not necessarily the other way
round.
2009-02-17 19:24:10 +01:00
a302d7613e Make sure lmine can't lay seamines even when sector changes
Reading the sector again invalidates the sector type check.  Bug can
currently bite only when the deity redesignates the sector.  Call
check_sect_ok() instead.
2009-02-16 20:57:26 +01:00
82ddc64e35 Make lmine report lack of mobility more nicely 2009-02-15 12:54:19 +01:00
41f3e67e8b Don't let engineer mine while it is on a ship or land unit 2009-02-15 12:54:19 +01:00
7da69c92e0 Don't use automatic supply to avoid starvation at the update
Food supply during update adds complexity to the update.  How much
good it does to players is highly doubtful; certainly nobody can rely
on it.  It isn't covered by the starvation command.  Starving ships or
land units can steal enough food from their sector to make it starve,
too.  Finally, the supply code is notoriously hard to use correctly.
We don't know of issues with the update's use, but we haven't
convinced ourselves that there aren't any either.
2009-02-15 12:51:05 +01:00
c0b300d875 Sectors and ships no longer need shells to fire flak
4.0.9 changed flak not to use up shells, but they still had to be
present.  Drop that, because it doesn't really provide any value.
Moreover, this gets rid of the buggy flak shell supply code (seqno
mismatch oopses, lost supplies).
2009-02-14 14:17:44 +01:00
7cce3124bf Use IPv4 and v6 only when suitable interfaces are configured
Only on systems supporting AI_ADDRCONFIG.
2009-02-12 07:41:13 +01:00
00b5cb2b8a Update info Interception for air defense integration
Was missed in commit 6564ff22.  While there, delete details on fuel
use that became wrong in Empire 3.
2009-02-11 20:10:01 +01:00
8b6540eecb Fix info turn not to suggest that turn off just disables login
Basically a rewrite.
2009-02-08 20:49:42 +01:00