Commit graph

3496 commits

Author SHA1 Message Date
9731e6692a Fix generation numbers for autonav
nav_ship() makes copies without going through ef_read(), and therefore
needs to mark them fresh by hand.
2009-04-24 23:52:00 +02:00
bdcd59155a Really, really fix bomb not to wipe out plane updates
Commit 82b5e3c2 missed escorts.
(cherry picked from commit ce7fab3868)
2009-04-19 22:06:08 +02:00
f571a37cde Fix tend land not to wipe out concurrent updates
Fix tend_land() to bail out if the tender changed while tend_land()
slept for the last argument (receiving ship).
(cherry picked from commit 1ee02194c5)
2009-04-19 22:06:08 +02:00
957f774a90 Fix return value of s_commod() when it can't draw enough
s_commod() could incorrectly claim success when the sink ended up with
at least as many supplies than were missing initially.  This caused a
number of problems:

* shp_torp() let a ship with two shells fire a torpedo, resulting in
  -1 shells, which then made item_prewrite() oops.  Affected missions
  and return fire, but not the torpedo command.

* shp_missile_defense() let a ship with one shell use missile defense,
  resulting in -1 shells, and the same item_prewrite() oops.

* Land units were considered in supply even when they had not quite
  enough supplies.  Such land units could defend without penalty,
  attack and react.  Commands load and lload weren't affected, because
  they use lnd_in_supply(), which doesn't use s_commod().

Broken in 98f24d5c, v4.3.20.
(cherry picked from commit 1329c0e544)
2009-04-16 13:07:47 +02:00
56f2ca96f7 Fix update to take dead units off carriers
upd_plane() upd_land() and left planes and land units lost to lack of
maintenance on their carriers.  Cargo lists were fine anyway, because
unit_cargo_init() ignored dead units.  But when the dead unit got
reused for building a new one, pln_prewrite() / lnd_prewrite() got
confused and attempted to take it off its carrier, which made
clink_rem() oops, because the unit wasn't on the cargo list.  No real
harm done, as oops recovery was fine.

Fix upd_plane() and upd_land() to clear the carrier.  Make
unit_cargo_init() oops when it finds dead units on carriers.
(cherry picked from commit c2c0d1ff77)
2009-04-15 23:07:26 +02:00
2900de1f63 Don't log out player when he interrupts a command
Broken in commit 3da4030a, v4.3.19.
(cherry picked from commit 475f518be1)
2009-03-22 09:03:36 +01:00
56c28caf5b Fix recipient thread in output journal
Output journaling was cherry-picked from Hvy Metal II.  However, how
threads are identified in the journal changed since then.
journal_output_1() needs updating for that.
2009-03-17 20:19:49 +01:00
b8804d1cc0 Fix typo in journaling of output lines
Screwed up in commit 9a19dc97.
2009-03-17 20:07:20 +01:00
551676d5f2 Document server time in info Hvy-Plastic 2009-03-16 19:50:08 +01:00
48ba06732c Fix assault not to send bogus telex to country 0
Happened when a spy got caught sneaking ashore and shot.
(cherry picked from commit 7c6e56bd02)
2009-03-10 20:52:36 +01:00
839c6001d3 Document disabling of anti-missile in info Hvy-Plastic 2009-03-10 20:52:26 +01:00
ddbf8c482b Change fairland island size probability distribution
Island size is randomly chosen from the interval [1..2*is+1], with
expected value is.  Use two dice to roll the size instead of one.
This makes extreme sizes much less likely.
2009-03-10 20:52:26 +01:00
8ebed5ba05 Fix generation numbers for news file
nreport() caches recent news reports in cache[], so it can collapse
multiple news reports into one.  Writing back such a collapsed news
report triggered a generation oops when the processor had been yielded
since the cached report was last written back.  But this is actually
perfectly safe, because the cache can't become stale: news file
updates either go through the cache (nreport()), or they clear the
entire cache (delete_old_news()).

Silence the oops by marking the news report fresh.

A case could be made for removing nws_generation alltogether.  Maybe
later.
2009-03-10 20:52:26 +01:00
bba8db34d0 Fix generation numbers for SAIL
fltp_to_list() makes copies without going through ef_read(), and
therefore needs to mark them fresh by hand.
2009-03-10 15:27:52 +01:00
20b31defe7 Generation numbers to catch write back of stale copies
Oops when a stale copy is written back, i.e. the processor was yielded
since the copy was made.  Such bugs are difficult to spot.  Sequence
numbers catch them when they do actual harm (they also catch different
bugs).  Generation numbers catch them even when they don't.

New ef_generation to count generations.  Call new ef_make_stale() to
step it whenever the processor may be yielded.

New struct emptypedstr member generation.  Make sure all members of
unit empobj_storage share it.  It is only used in copies; its value on
disk and in the cache is meaningless.  Set it to ef_generation by
calling new ef_mark_fresh() when making copies in ef_read() and
ef_blank().  Do the same in obj_changed() to make check_sect_ok() &
friends freshen their argument when it is unchanged.  Copies with
generation other than ef_generation are stale.

Oops in ef_write() when a stale copy is written back.
2009-03-10 15:27:52 +01:00
f8be963202 New info Hvy-Plastic 2009-03-10 15:27:52 +01:00
1bf3f557e9 Make fairland record the island number in the deity territory
Can be useful for deities when further customizing their game setup.
2009-03-10 15:27:52 +01:00
9a19dc973a Fix journalling of output ids 2009-03-10 15:27:52 +01:00
87512fb644 Journal output lines instead of chunks
Output often arrives in chunks other than lines.  Hard to read in the
journal.  Delay journalling until we got a full line or our buffer is
exhausted.  This is less precise, but it'll do for now.
2009-03-10 15:27:52 +01:00
c4687e15d5 New journal event output
To enable, set econfig key keep_journal to at least 2.  Output events
are *not* flushed to disk immediately.

Put it in Hvy Metal II now to gather real data for future testing of a
journal replay tool.
2009-03-10 15:27:51 +01:00
1c1fa720d4 New journal event command
Redundant information, but makes the journal easier to read.  The
redundancy might help making a journal replay tool robust.

Put it in Hvy Metal II now to gather some real data.
2009-03-10 15:27:51 +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