Markus Armbruster [Fri, 24 Apr 2009 21:52:00 +0000 (23:52 +0200)]
Fix generation numbers for autonav
nav_ship() makes copies without going through ef_read(), and therefore
needs to mark them fresh by hand.
Markus Armbruster [Sat, 18 Apr 2009 12:41:24 +0000 (14:41 +0200)]
Really, really fix bomb not to wipe out plane updates
Commit
82b5e3c2 missed escorts.
(cherry picked from commit
ce7fab3868c657c4b1240d3b303caa1bd78408ff)
Markus Armbruster [Sat, 18 Apr 2009 06:41:28 +0000 (08:41 +0200)]
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
1ee02194c517e773888f2644c5dde30ac14f6f20)
Markus Armbruster [Thu, 16 Apr 2009 11:06:32 +0000 (13:06 +0200)]
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
1329c0e5441c592fa8e963ba1f70b655a1db2841)
Markus Armbruster [Wed, 15 Apr 2009 21:06:54 +0000 (23:06 +0200)]
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
c2c0d1ff77fef3adb0b8517c494838119b9b236f)
Markus Armbruster [Sun, 22 Mar 2009 07:58:10 +0000 (08:58 +0100)]
Don't log out player when he interrupts a command
Broken in commit
3da4030a, v4.3.19.
(cherry picked from commit
475f518be1154bac54c72bb9f543078779478e29)
Markus Armbruster [Tue, 17 Mar 2009 19:19:49 +0000 (20:19 +0100)]
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.
Markus Armbruster [Tue, 17 Mar 2009 19:07:20 +0000 (20:07 +0100)]
Fix typo in journaling of output lines
Screwed up in commit
9a19dc97.
Markus Armbruster [Mon, 16 Mar 2009 18:50:08 +0000 (19:50 +0100)]
Document server time in info Hvy-Plastic
Markus Armbruster [Tue, 10 Mar 2009 19:50:47 +0000 (20:50 +0100)]
Fix assault not to send bogus telex to country 0
Happened when a spy got caught sneaking ashore and shot.
(cherry picked from commit
7c6e56bd02d5a1dcfca6324bc1e4f788a42c8fcd)
Markus Armbruster [Tue, 10 Mar 2009 19:48:05 +0000 (20:48 +0100)]
Document disabling of anti-missile in info Hvy-Plastic
Markus Armbruster [Mon, 9 Mar 2009 20:22:03 +0000 (21:22 +0100)]
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.
Markus Armbruster [Sun, 8 Mar 2009 17:49:06 +0000 (18:49 +0100)]
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.
Markus Armbruster [Mon, 2 Mar 2009 08:06:31 +0000 (09:06 +0100)]
Fix generation numbers for SAIL
fltp_to_list() makes copies without going through ef_read(), and
therefore needs to mark them fresh by hand.
Markus Armbruster [Sun, 1 Mar 2009 17:56:41 +0000 (18:56 +0100)]
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.
Markus Armbruster [Mon, 23 Feb 2009 20:56:49 +0000 (21:56 +0100)]
New info Hvy-Plastic
Markus Armbruster [Sat, 5 Apr 2008 14:09:24 +0000 (16:09 +0200)]
Make fairland record the island number in the deity territory
Can be useful for deities when further customizing their game setup.
Markus Armbruster [Sat, 2 Aug 2008 13:04:16 +0000 (09:04 -0400)]
Fix journalling of output ids
Markus Armbruster [Wed, 30 Jul 2008 12:26:34 +0000 (08:26 -0400)]
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.
Markus Armbruster [Wed, 30 Jul 2008 00:38:48 +0000 (20:38 -0400)]
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.
Markus Armbruster [Tue, 29 Jul 2008 11:48:28 +0000 (07:48 -0400)]
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.
Markus Armbruster [Tue, 10 Mar 2009 12:08:15 +0000 (13:08 +0100)]
Fix distclean to remove generated files distributed in client tarball
Markus Armbruster [Tue, 10 Mar 2009 11:51:44 +0000 (12:51 +0100)]
Really fix bomb not to wipe out plane updates
Commit
f07e6901 didn't fix it completely.
Markus Armbruster [Mon, 9 Mar 2009 21:35:18 +0000 (22:35 +0100)]
Update change log again for 4.3.21
Markus Armbruster [Mon, 9 Mar 2009 21:31:49 +0000 (22:31 +0100)]
Fix swapsector not to wipe out concurrent updates.
Make swaps() bail out if any of the sectors changed while edit() slept
for input.
Markus Armbruster [Mon, 9 Mar 2009 20:33:30 +0000 (21:33 +0100)]
Update change log again for 4.3.21
Markus Armbruster [Mon, 9 Mar 2009 20:33:23 +0000 (21:33 +0100)]
Fix outdated comment
Markus Armbruster [Mon, 9 Mar 2009 20:10:44 +0000 (21:10 +0100)]
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.
Markus Armbruster [Sun, 8 Mar 2009 17:24:32 +0000 (18:24 +0100)]
Update change log again for 4.3.21
Markus Armbruster [Sun, 8 Mar 2009 17:19:25 +0000 (18:19 +0100)]
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.
Markus Armbruster [Sun, 8 Mar 2009 16:36:37 +0000 (17:36 +0100)]
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.
Markus Armbruster [Sun, 8 Mar 2009 16:14:59 +0000 (17:14 +0100)]
Rename plane_caps() to pln_caps() and give it external linkage
Markus Armbruster [Sun, 8 Mar 2009 13:33:00 +0000 (14:33 +0100)]
Update change log for 4.3.21
Markus Armbruster [Sun, 8 Mar 2009 10:54:04 +0000 (11:54 +0100)]
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.
Markus Armbruster [Sun, 1 Mar 2009 17:11:49 +0000 (18:11 +0100)]
Factor obj_changed() out of check_sect_ok() & friends
Markus Armbruster [Sun, 1 Mar 2009 17:10:45 +0000 (18:10 +0100)]
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.
Markus Armbruster [Sun, 1 Mar 2009 10:34:50 +0000 (11:34 +0100)]
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.
Markus Armbruster [Sun, 1 Mar 2009 09:49:48 +0000 (10:49 +0100)]
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.
Markus Armbruster [Wed, 25 Feb 2009 21:52:39 +0000 (22:52 +0100)]
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.
Markus Armbruster [Sat, 21 Feb 2009 14:18:55 +0000 (15:18 +0100)]
Bump version to 4.3.21
Markus Armbruster [Fri, 20 Feb 2009 18:15:01 +0000 (19:15 +0100)]
Update change log again for 4.3.20
Markus Armbruster [Thu, 19 Feb 2009 21:06:41 +0000 (22:06 +0100)]
Disable LOANS and enable RAILWAYS by default
Markus Armbruster [Wed, 18 Feb 2009 20:11:33 +0000 (21:11 +0100)]
Update known contributors comments
Markus Armbruster [Tue, 17 Feb 2009 22:00:07 +0000 (23:00 +0100)]
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.
Markus Armbruster [Tue, 17 Feb 2009 18:59:43 +0000 (19:59 +0100)]
Update change log for 4.3.20
Markus Armbruster [Sun, 15 Feb 2009 16:41:58 +0000 (17:41 +0100)]
Fix a few inaccuracies in info supply
Markus Armbruster [Sun, 15 Feb 2009 07:47:43 +0000 (08:47 +0100)]
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.
Markus Armbruster [Sat, 14 Feb 2009 22:30:15 +0000 (23:30 +0100)]
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.
Markus Armbruster [Sat, 14 Feb 2009 18:00:01 +0000 (19:00 +0100)]
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().
Markus Armbruster [Sun, 15 Feb 2009 13:38:09 +0000 (14:38 +0100)]
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.
Markus Armbruster [Sun, 15 Feb 2009 13:20:12 +0000 (14:20 +0100)]
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.
Markus Armbruster [Sun, 15 Feb 2009 08:15:53 +0000 (09:15 +0100)]
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.
Markus Armbruster [Sat, 14 Feb 2009 17:37:34 +0000 (18:37 +0100)]
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().
Markus Armbruster [Sun, 15 Feb 2009 06:30:23 +0000 (07:30 +0100)]
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.
Markus Armbruster [Sun, 15 Feb 2009 06:48:12 +0000 (07:48 +0100)]
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.
Markus Armbruster [Sat, 14 Feb 2009 14:45:55 +0000 (15:45 +0100)]
Don't suggest only supply ships can tend in info tend and ltend
Markus Armbruster [Sat, 14 Feb 2009 14:45:05 +0000 (15:45 +0100)]
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.
Markus Armbruster [Sun, 15 Feb 2009 16:29:00 +0000 (17:29 +0100)]
Clean up info lmine a bit
Markus Armbruster [Sat, 14 Feb 2009 09:02:47 +0000 (10:02 +0100)]
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.
Markus Armbruster [Sat, 14 Feb 2009 14:11:26 +0000 (15:11 +0100)]
Don't permit landmine laying in foreign sectors
Markus Armbruster [Sat, 14 Feb 2009 08:58:44 +0000 (09:58 +0100)]
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.
Markus Armbruster [Sat, 14 Feb 2009 08:18:34 +0000 (09:18 +0100)]
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.
Markus Armbruster [Sat, 14 Feb 2009 08:08:06 +0000 (09:08 +0100)]
Make lmine report lack of mobility more nicely
Markus Armbruster [Sat, 14 Feb 2009 08:06:51 +0000 (09:06 +0100)]
Don't let engineer mine while it is on a ship or land unit
Markus Armbruster [Thu, 12 Feb 2009 06:39:46 +0000 (07:39 +0100)]
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.
Markus Armbruster [Wed, 11 Feb 2009 19:46:27 +0000 (20:46 +0100)]
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).
Markus Armbruster [Wed, 11 Feb 2009 20:09:18 +0000 (21:09 +0100)]
Use IPv4 and v6 only when suitable interfaces are configured
Only on systems supporting AI_ADDRCONFIG.
Markus Armbruster [Wed, 11 Feb 2009 19:10:01 +0000 (20:10 +0100)]
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.
Markus Armbruster [Sun, 8 Feb 2009 19:49:27 +0000 (20:49 +0100)]
Fix info turn not to suggest that turn off just disables login
Basically a rewrite.
Markus Armbruster [Sun, 8 Feb 2009 19:44:37 +0000 (20:44 +0100)]
Restructure turn() for simpler control flow
Also make it less chatty, and don't suggest that turn off just
disables login.
Markus Armbruster [Sun, 8 Feb 2009 16:04:03 +0000 (17:04 +0100)]
Fix turn off for empty message
Always failed with an empty message, due to misuse of fwrite().
Broken in commit
df7dc203, v4.2.20.
Markus Armbruster [Sun, 8 Feb 2009 19:47:59 +0000 (20:47 +0100)]
Fix the previous commit to clear PF_DOWN
Markus Armbruster [Sun, 8 Feb 2009 13:54:02 +0000 (14:54 +0100)]
Avoid repeated hours and game down status notifications
may_play_now() tells deities about hours restriction and game down
status. It runs at login and before and after each command. Getting
notified that often is annoying.
Avoid repetition by remembering notification in new player flags
PF_HOURS and PF_DOWN. Add a notification when hours restriction has
been lifted. Ensure the notification is printed before the prompt,
not before the command, by calling may_play_now() from command() only
for mortals. Safe, because may_play_now() always returns true for
deities anyway.
Markus Armbruster [Sun, 8 Feb 2009 12:20:57 +0000 (13:20 +0100)]
Inline gamedown() into only user may_play_now() and simplify
Markus Armbruster [Sun, 8 Feb 2009 10:33:10 +0000 (11:33 +0100)]
Move show_first_tel() from player.c to rea.c
Markus Armbruster [Sun, 8 Feb 2009 10:31:18 +0000 (11:31 +0100)]
Don't check MAXTELSIZE in typed_wu()
The previous commit lifted the MAXTELSIZE restriction for telegram
files. Note that getele() is still limited by it.
Markus Armbruster [Sun, 8 Feb 2009 10:13:25 +0000 (11:13 +0100)]
Factor out code to read mailboxes, and make read more robust
New tel_read_header(), tel_read_body(). Use them in rea(),
show_first_tel(), copy_and_expire().
rea() now stops when it encounters a corrupt telegram, and logs the
problem. Before, error detection was incomplete, and errors were not
logged. Corrupt mailboxes could make it crash.
show_first_tel() and copy_and_expire() can now cope with telegrams of
arbitrary length, like rea(), and sanity-check the header fields they
don't actually use.
Markus Armbruster [Sat, 7 Feb 2009 19:05:33 +0000 (20:05 +0100)]
Remove superflous #include "tel.h"
Markus Armbruster [Sat, 7 Feb 2009 18:58:59 +0000 (19:58 +0100)]
Make struct telstr members tel_type and tel_length unsigned
They are simpler to use that way.
Markus Armbruster [Sat, 7 Feb 2009 18:51:22 +0000 (19:51 +0100)]
Don't log out deity when gamedown() can't read downfil
Broken in commit
c7e2442d. Fix by factoring show_first_tel() out of
gamedown() and show_motd().
Markus Armbruster [Sat, 7 Feb 2009 19:12:12 +0000 (20:12 +0100)]
Don't fail motd command when motdfil can't be read
Not the player's business. Simply treat it as no MOTD.
Markus Armbruster [Sat, 7 Feb 2009 18:49:21 +0000 (19:49 +0100)]
Don't write junk to unused bytes of downfil and motdfil
These files don't use all members of struct telstr. turn() neglected
to initialized the unused ones and struct telstr's holes. Fix that.
Markus Armbruster [Sat, 7 Feb 2009 17:24:03 +0000 (18:24 +0100)]
Store game down flag in the game table
This avoids the silly opening of downfil all the time.
For what it's worth, it also makes the information visible in xdump,
as new game selector down.
Markus Armbruster [Sun, 8 Feb 2009 13:16:57 +0000 (14:16 +0100)]
Move update_timeused() from may_play_now() back to callers
This backs out a small part of commit
d1ff2a60, for clarity.
While there, oops when may_play_now() is called with incorrect natp
argument.
Markus Armbruster [Sun, 8 Feb 2009 08:30:41 +0000 (09:30 +0100)]
Fix reject accept
Instead of accepting the listed nations, rejected the nation listed
last, and accepted all the others. Broken in commit
6844c94b, v4.3.4.
Markus Armbruster [Sat, 7 Feb 2009 15:43:11 +0000 (16:43 +0100)]
Update copyright notice
Markus Armbruster [Sat, 7 Feb 2009 15:37:20 +0000 (16:37 +0100)]
Streamline copyright notice in lwp.h
Should have been done along with the rest of LWP, in commit
2aea9269.
Ron Koenderink [Sun, 8 Feb 2009 02:09:30 +0000 (20:09 -0600)]
Fix update thread not successfully waking up with LWP
Commit
08b945568 broke empth_sleep() for LWP: it returned zero even
when woken up early.
Ron Koenderink [Thu, 5 Feb 2009 02:53:26 +0000 (20:53 -0600)]
Prevent command from executing after game is down
Move the gamedown() check from status to may_play_now() so it is
checked upon login, before a command is executed and after command
completion. This fixes the situation where a player to could execute
one more command after the game was down.
Report to the deities that the game is down.
Remove to duplicate gamedown message.
Markus Armbruster [Mon, 2 Feb 2009 07:08:38 +0000 (08:08 +0100)]
Fix empth_select() for funny flag arguments
EMPTH_POSIX and EMPTH_W32 implementations rejected values other than a
single flag. Such values aren't used now, but it violates the
contract all the same.
Ron Koenderink [Sun, 1 Feb 2009 17:43:22 +0000 (11:43 -0600)]
Add maximum logged in time check for nation state NEW
Markus Armbruster [Sun, 1 Feb 2009 17:06:09 +0000 (18:06 +0100)]
Fix pthread's empth_select() not to change the timeout
Commit
08b94556 introduced the timeout parameter. The empthread
implementation could change it, at least on some systems, and its user
worked around a possible change. However, that behavior was not
documented, and it's inconvenient. Fix the pthread implementation,
and remove the workaround.
Markus Armbruster [Fri, 26 Sep 2008 01:51:21 +0000 (21:51 -0400)]
Integrate air defense missions into interception
The ancients designed interception dead simple: when you overfly a
sector, you get intercepted by the sector owner. Fine print
interception rules govern which planes intercept.
Then complexity got piled on top of it.
Chainsaw 2 added an extra interception by surface ship owners, in the
target sector only.
Chainsaw 3 added an extra interception by land unit owners, in the
target sector only (Empire 4 later merged this extra land unit
interception with the extra surface ship interception).
Chainsaw 3 added an entirely separate kind of interception: air
defense missions. When you enter a sector in some air defense op
area, you get intercepted. Fine print air defense rules govern which
planes intercept. These rules differ significantly from the
interception fine print.
Additional complexity comes from these facts:
* Air defense mission interception happens in addition to non-mission
interception. You can boost your total interception by setting up
air defense. Which means you must set it up, or forgo an advantage.
* Air defense planes are not available for non-mission interception
duty. You need to decide on a split.
* In contrast to non-mission interception, interceptors flying air
defense get intercepted.
Moreover, the air defense code breaks one of the plane code's design
assumptions, namely that just one plane sortie is active at a time.
The air defense sortie runs while the sortie it intercepts is in
progress. This leads to two interceptions being active at the same
time: the one intercepting the original sortie, and the one
intercepting the air defense sortie. The same plane can fly in both
interceptions, and damage received in the interception of the air
defense sortie is wiped out, triggering a seqno mismatch oops.
The previous commit already simplified non-mission interception: you
get intercepted by anyone who owns the sector, or a surface ship or a
land unit there, whether it's the target sector or not.
Now simplify mission interception, by merging air defense back into
ordinary interception: when you overfly a sector, you get intercepted
by anyone who owns the sector, or a surface ship or land unit there,
or has an air defense mission covering the sector. That's all. No
multiple interceptions, no separate air defense rules.
Remove air_defense(). Simplify ac_encounter() and sam_intercept()
accordingly; both lose their last parameter.
Change sam_intercept() and ac_intercept() to intercept in mission op
areas. New parameter only_mission to suppress non-mission
interception. Pass zero when the intercepting country owns the sector
or a surface ship or land unit in the sector.
ac_encounter() can't efficiently predict whether a country intercepts,
so it needs to call ac_intercept() unconditionally. This kills the
optimization to collect interceptors only when needed; simplify
accordingly, replacing getilist() by getilists().
Markus Armbruster [Thu, 25 Sep 2008 14:22:53 +0000 (10:22 -0400)]
Intercept the same all along the flight path
In each sector, any country owning the sector, a surface ship or a
land unit gets to intercept.
Before, only the sector owner got to intercept, except for the target
sector. There, any country owning surface ships or land units got to
intercept in addition to the sector owner. Thus, a sector owner with
surface ships or land units there got to intercept twice.
Info Intercept claimed you get to intercept once for ships and once
again for land units, which was wrong since 4.0.9.
Info bomb suggested that flak fires only in the target sector, which
was wrong since 4.2.8. Drop that.
Markus Armbruster [Thu, 25 Sep 2008 14:05:07 +0000 (10:05 -0400)]
Make ships and land units spot planes along the flight path
Sectors already spotted overflying planes in every sector along the
flight path, but ships and land units did that only in the target
sector, once if you got any ships there, in ac_encounter(), once if
you got any land units there, in ac_encounter(), once for ships firing
flak, in ac_shipflak(), and once for land units firing flak, in
ac_landflak(). Remove all that, and generalize ac_encounter()'s code
for sectors to spot planes to include ships and land units. Unlike
before, ships and land units don't spot allied planes.
Markus Armbruster [Thu, 25 Sep 2008 13:10:41 +0000 (09:10 -0400)]
Change when planes spot ships and land units
Planes now spot ships and land units only when flying recon or sweep,
and along all of their flight path instead of just the target sector.
It still takes a spy plane to identify ships and land units.
Before, non-spy planes spotted ships and land units only in the target
sector, regardless of type of sortie, once for all ships and land
units, in ac_encounter(), once for ships firing flak, in
ac_shipflak(), and once for land units firing flak, in ac_landflak().
Remove all that.
Markus Armbruster [Thu, 25 Sep 2008 11:35:42 +0000 (07:35 -0400)]
Replace unfriendly[] by rel[] in ac_encounter()
Use it to replace the getrel() in the check for allied.
Markus Armbruster [Thu, 25 Sep 2008 02:09:59 +0000 (22:09 -0400)]
Intercept planes at their assembly point
Change ac_encounter() to start intercepting and running air defense
missions at the assembly point instead of the first sector entered
from there.
This also fixes a coding bug: when the flight path was empty, evaded
was used uninitialized when checking whether to intercept over the
target. The compiler even warned about that. Since the uninitialized
evaded typically read non-zero, interception triggered by ships and
land units didn't work. Abusable: if you managed to make your target
sector an assembly point, e.g. by placing an own or allied ship there,
you could bomb it without getting intercepted or taking flak.
Markus Armbruster [Wed, 24 Sep 2008 23:31:15 +0000 (19:31 -0400)]
Remove useless strncpy() in ac_encounter()
Markus Armbruster [Wed, 24 Sep 2008 22:49:54 +0000 (18:49 -0400)]
Fix SAM interception for intercepts other than the first
A country's SAMs launched only in the first interception of a sortie.
That was because ac_intercept() made sam_intercept() delete all SAMs
from the list of available interceptors. sam_intercept() also deleted
any SAMs out of range. Don't do that, delete unused SAMs along with
other unused interceptors on return from ac_encounter().