]> git.pond.sub.org Git - empserver/log
empserver
14 years agoMake CANT_HAPPEN() more obvious for static analysis
Markus Armbruster [Fri, 15 Jan 2010 19:02:11 +0000 (20:02 +0100)]
Make CANT_HAPPEN() more obvious for static analysis

Local analysis can now easily find out what's up.  Before,
whole-program analysis was required.  The Clang Static Analyzer
complained about code that is actually fine.

14 years agoFix getpath() not to crash when path exceeds MAX_PATH_LEN
Markus Armbruster [Thu, 14 Jan 2010 21:39:42 +0000 (22:39 +0100)]
Fix getpath() not to crash when path exceeds MAX_PATH_LEN

Trivial for players to trigger.  Broken in commit 0b0612ea, v4.3.16.
Spotted by the Clang Static Analyzer.

14 years agoFix oops on escort, recon, and launch of satellite
Markus Armbruster [Wed, 13 Jan 2010 20:21:58 +0000 (21:21 +0100)]
Fix oops on escort, recon, and launch of satellite

Broken in commit 528df9ac, v4.3.23.  pln_equip() recovered fine.

14 years agoUpdate copyright notice
Markus Armbruster [Sun, 10 Jan 2010 07:53:25 +0000 (08:53 +0100)]
Update copyright notice

14 years agoFix trailing whitespace
Markus Armbruster [Sun, 10 Jan 2010 07:47:40 +0000 (08:47 +0100)]
Fix trailing whitespace

14 years agoStop ship and land unit movement on interdiction with no damage
Markus Armbruster [Sat, 9 Jan 2010 15:21:40 +0000 (16:21 +0100)]
Stop ship and land unit movement on interdiction with no damage

Movement stops when shp_interdict() or lnd_interdict() report
interdiction.  However, they reported it only when there was
interdiction damage.

Zero interdiction damage commonly happens when interdicting missiles
miss, or all bombers abort.  Stopping regardless of damage makes more
sense there.

Moreover, not stopping is buggy: do_unit_move() needs to take care not
to wipe out updates made by interdiction to the moving ships or land
units.  It does so only when it stops.  Updates made by interdiction
without interdiction damage could get wiped out, triggering a seqno
mismatch oops.

Known ways moving ships and land units can get updated by interdiction
despite there is no interdiction damage:

* Interdicting bombers get intercepted by planes based on a navigating
  carrier, carrier gets charged petrol.  The bug wipes out the petrol
  use.

* Marching land units get interdicted by planes, but all planes miss.
  Sufficiently large collateral damage to the sector can still damage
  the land units.  The bug wipes out the damage to land units.

To make shp_interdict() and lnd_interdict() report interdiction
regardless of damage, change lnd_missile_interdiction(),
lnd_fort_interdiction(), lnd_mission_interdiction(),
shp_missile_interdiction(), shp_fort_interdiction(),
shp_mission_interdiction() to return whether there was interdiction.
Before, they returned whether there was damage.

Change unit_interdict(), perform_mission(), perform_mission_land(),
perform_mission_ship(), perform_mission_msl(), and
perform_mission_bomb() to return -1 for no interdiction, so that
callers can distinguish no interdiction from interdiction with no
damage.

14 years agoClean up poorly chosen loop control variable names
Markus Armbruster [Sat, 9 Jan 2010 13:51:59 +0000 (14:51 +0100)]
Clean up poorly chosen loop control variable names

Calling a counting loop's control variable q or z is tasteless
bordering on actively misleading.

14 years agoSimplify perform_mission()
Markus Armbruster [Sat, 9 Jan 2010 13:22:51 +0000 (14:22 +0100)]
Simplify perform_mission()

14 years agoRemove struct genlist member cp
Markus Armbruster [Sat, 9 Jan 2010 12:49:34 +0000 (13:49 +0100)]
Remove struct genlist member cp

14 years agoRemove perform_mission_land(), perform_mission_ship() parameter md
Markus Armbruster [Sat, 9 Jan 2010 12:46:33 +0000 (13:46 +0100)]
Remove perform_mission_land(), perform_mission_ship() parameter md

14 years agoSplit up perform_mission()
Markus Armbruster [Sat, 9 Jan 2010 12:26:16 +0000 (13:26 +0100)]
Split up perform_mission()

Move code out of perform_mission() into new perform_mission_land(),
perform_mission_ship(), perform_mission_msl(), perform_mission_bomb().

14 years agoMake lnd_mission_interdiction() apply damage
Markus Armbruster [Sat, 9 Jan 2010 08:44:12 +0000 (09:44 +0100)]
Make lnd_mission_interdiction() apply damage

To make lnd_mission_interdiction() work just like
shp_mission_interdiction().

14 years agoNew lnd_mission_interdiction()
Markus Armbruster [Sat, 9 Jan 2010 08:40:01 +0000 (09:40 +0100)]
New lnd_mission_interdiction()

Factored out of lnd_interdict().  No functional change.

14 years agoNew shp_mission_interdiction()
Markus Armbruster [Sat, 9 Jan 2010 08:39:15 +0000 (09:39 +0100)]
New shp_mission_interdiction()

Factored out of shp_interdict().  No functional change.

14 years agoFix att_reacting_units() to initialize ulist member eff
Markus Armbruster [Sat, 2 Jan 2010 08:27:55 +0000 (09:27 +0100)]
Fix att_reacting_units() to initialize ulist member eff

This left initial eff at zero.  No effect, because its only user
get_land() ignores efficiency increases.

14 years agoSimplify ask_olist and get_dlist() not to re-read land units
Markus Armbruster [Sat, 2 Jan 2010 08:14:55 +0000 (09:14 +0100)]
Simplify ask_olist and get_dlist() not to re-read land units

getland() is obviously redundant in get_dlist(), because the land unit
can't have changed since the previous read.

What's up with ask_olist() is less obvious.  For each capable land
unit, ask_olist() asks the player whether to attack with it.  If it
attacks, it gets copied into olist.  Since asking the player yields
the processor, these copies can become stale.  However, re-reading
fixes that just for the last one.  Moreover, the code copes with stale
copies just fine: ask_olist() is always directly followed by
att_get_offense() or att_move_in_off(), and both replace the
potentially stale copy in olist.

14 years agoRemove get_land() parameter uid
Markus Armbruster [Sun, 3 Jan 2010 20:45:10 +0000 (21:45 +0100)]
Remove get_land() parameter uid

For all remaining calls, the uid can be obtained from parameter llp.

14 years agoInline get_land()'s "first time" case into its callers
Markus Armbruster [Sat, 2 Jan 2010 07:53:25 +0000 (08:53 +0100)]
Inline get_land()'s "first time" case into its callers

ask_olist() and get_dlist() called get_land() with llp->chrp still
null, which made it initialize parts of llp instead of performing its
usual integrity check.  att_reacting_units() had the initialization
inline.  Change the other two to match, and simplify get_land().  No
functional change.

14 years agoDrop last parameter of shp_hit_mine() and lnd_hit_mine()
Markus Armbruster [Fri, 1 Jan 2010 15:55:24 +0000 (16:55 +0100)]
Drop last parameter of shp_hit_mine() and lnd_hit_mine()

14 years agoSimplify use of shp_missile_interdiction()
Markus Armbruster [Fri, 1 Jan 2010 15:38:47 +0000 (16:38 +0100)]
Simplify use of shp_missile_interdiction()

shp_missile_interdiction() does nothing when there are no suitable
targets.  Its users avoid to call it when there are none, probably to
save a few cycles.  Optimize shp_missile_interdiction() for that case,
and simplify the callers.

14 years agoMake empdump call ef_close() regardless of -n
Markus Armbruster [Fri, 1 Jan 2010 10:15:51 +0000 (11:15 +0100)]
Make empdump call ef_close() regardless of -n

Avoiding ef_close() with -n is not necessary, so don't.

14 years agoRearrange struct sctstr slightly to expose commonalities with units
Markus Armbruster [Thu, 31 Dec 2009 10:50:22 +0000 (11:50 +0100)]
Rearrange struct sctstr slightly to expose commonalities with units

Nice bonus: space needed for sectors shrinks some 4%.  Size of game
state could shrink perhaps 1-2%.

14 years agoNarrow struct sctstr member sct_mobil to char
Markus Armbruster [Thu, 31 Dec 2009 10:39:17 +0000 (11:39 +0100)]
Narrow struct sctstr member sct_mobil to char

To bring it in line with unit mobility.

14 years agoMake struct sctstr member sct_effic signed
Markus Armbruster [Thu, 31 Dec 2009 10:36:59 +0000 (11:36 +0100)]
Make struct sctstr member sct_effic signed

To bring it in line with unit efficiency.

14 years agoStreamline fortgun()'s efficiency comparison
Markus Armbruster [Thu, 31 Dec 2009 10:33:06 +0000 (11:33 +0100)]
Streamline fortgun()'s efficiency comparison

Use >= 60 instead of > 59, for consistency with similar comparisons
elsewhere.

14 years agoFix sloppy sanity check for mobility going negative in transport
Markus Armbruster [Thu, 31 Dec 2009 10:27:48 +0000 (11:27 +0100)]
Fix sloppy sanity check for mobility going negative in transport

Assignment to sct_mobil was vulnerable to integer underflow.  Should
not happen, as move_ground() never returns a cost exceeding available
mobility.

14 years agoGeneration numbers to catch write back of stale copies
Markus Armbruster [Thu, 31 Dec 2009 12:14:36 +0000 (13:14 +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
increment it whenever the processor may be yielded.

New struct emptypedstr member generation.  To conserve space, make it
a bit-field of twelve bits, i.e. generations are only recorded modulo
2^12.  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.  Copies with generation other than ef_generation are
stale.  Stale copies that are a multiple of 2^12 generations old can't
be detected, but that is sufficiently improbable.

Set generation to ef_generation by calling new ef_mark_fresh() when
making copies in ef_read() and ef_blank().  nav_ship() and
fltp_to_list() make copies without going through ef_read(), and
therefore need to call ef_mark_fresh() as well.  Also call it in
obj_changed() to make check_sect_ok() & friends freshen their argument
when it is unchanged.

New must_be_fresh() oopses when its argument is stale.  Call it in
ef_write() to catch write back of stale copies.

14 years agoStore sequence numbers more compactly
Markus Armbruster [Thu, 31 Dec 2009 09:30:54 +0000 (10:30 +0100)]
Store sequence numbers more compactly

Store them and ef_type in bit-fields.

Allocate eight bits for ef_type.  Values range from 0 to EF_GAME
(currently 16), so this is plenty.

Allocate twelve bits for sequence numbers.  Sequence number mismatches
are now missed when the numbers are equal modulo 2^12.  Still
sufficiently improbable.

Common machines store the bit-fields in a 32 bit word.  There are
twelve bits left in that word for future use.  Total savings 16 bits,
which is exactly what the previous commit spent on wider uids on
common machines.

14 years agoStore uids as int to support more sectors and units
Markus Armbruster [Wed, 30 Dec 2009 13:07:51 +0000 (14:07 +0100)]
Store uids as int to support more sectors and units

Before, they were stored as short.  Wider uids use more space, but the
next commit will recover it by narrowing other members.

The use of short has always limited the number of ships, planes, land
units and nukes to SHRT_MAX (commonly 32768).  Only the most extreme
games ever came close.

Commit 49780e2c (v4.3.12) added struct sctstr member sct_uid to make
struct empobj member uid work for sectors.  This made the limit apply
to sectors as well.  We've had games with more than 32768 sectors.

14 years agoFix new_seqno()'s recovery from seqno mismatch
Markus Armbruster [Thu, 31 Dec 2009 11:12:39 +0000 (12:12 +0100)]
Fix new_seqno()'s recovery from seqno mismatch

A sequence number mismatch occurs when an invalid copy (with a stale
sequence number) gets written.  To continue after the error, we need
to use the current sequence number.  But new_seqno() used the larger
one of the two, which is correct only as long as sequence numbers do
not overflow.  Overflow is rather unlikely, though.

14 years agoRecord news more compactly
Markus Armbruster [Thu, 31 Dec 2009 08:18:37 +0000 (09:18 +0100)]
Record news more compactly

Member nws_uid is unused since the commit before previous.  Remove it.

Member nws_seqno is of marginal value, because we write news only
through ncache[], and thus aren't prone to the errors sequence numbers
can catch.  Remove it.

Make timestamp selector virtual, computing nws_when + nws_duration,
and remove member nws_timestamp.  Impact:

* In ncache(), the removed timestamp equals nws_when + nws_duration,
  both for new news and updated news.  No change.

* delete_old_news() becomes invisible.  Before, its move of unexpired
  news to the beginning of the news file touched all the timestamps.
  That was unwanted, because the move does not change news, only their
  storage.  Improvement.

* empdump no longer flags the imported news changed via the timestamp.
  This is somewhat unfortunate.  Document as bug.

With these members removed, struct nwsstr no longer matches struct
emptypedstr, so clear news table flag EFF_TYPED and remove union
empobj_storage member news.  This loses the automatic maintenance of
member ef_type via struct emptypedstr.  Remove ef_type as well.

This shrinks struct nwsstr from 20 to 12 bytes on common 32 bit
machines, and from 32 to 16 bytes on common 64 bit machines.  Since
the server doesn't map the whole news file (EFF_MAP is off), this
reduces I/O, while the table's memory use remains the same.

Historical note: struct nwsstr is now pretty much what it was back in
BSD Empire 1.1.  Members ef_type and nws_uid go back to Empire 3 (for
C_SYNC?).  v4.3.12 added member nws_timestamp, which doubled the size
on common 64 bit machines.  v4.3.15 added nws_seqno.

14 years agoNew news selector duration
Markus Armbruster [Thu, 31 Dec 2009 08:17:54 +0000 (09:17 +0100)]
New news selector duration

Backed by new struct nwsstr member nws_duration.  Time between first
and last occurence of the news recorded in this item, in seconds.

14 years agoRevert "Get rid of struct newscache"
Markus Armbruster [Thu, 31 Dec 2009 06:36:47 +0000 (07:36 +0100)]
Revert "Get rid of struct newscache"

This reverts commit 832574b6dee87f4efb56945c62e5d2fadec27288.

To prepare for removal of struct nwsstr member nws_uid.

Conflicts:

src/lib/subs/nreport.c

14 years agoRemove unused members of struct lndstr, lonstr, nukstr, trtstr
Markus Armbruster [Wed, 30 Dec 2009 12:49:41 +0000 (13:49 +0100)]
Remove unused members of struct lndstr, lonstr, nukstr, trtstr

struct lndstr member lnd_flags is a leftover from Empire3's C_SYNC,
which was ripped out in 4.0.0.

struct lonstr member l_sel, struct nuk_str members nuk_ship, nuk_land,
and struct trtstr member trt_bond have been there basically forever
without any use.

14 years agoConsistently use int for sector and unit uid parameters
Markus Armbruster [Wed, 30 Dec 2009 11:44:01 +0000 (12:44 +0100)]
Consistently use int for sector and unit uid parameters

14 years agoConsistently use int for file type parameters and locals
Markus Armbruster [Tue, 29 Dec 2009 12:09:01 +0000 (13:09 +0100)]
Consistently use int for file type parameters and locals

14 years agoConsistently use int for mission type parameters
Markus Armbruster [Tue, 29 Dec 2009 12:06:35 +0000 (13:06 +0100)]
Consistently use int for mission type parameters

14 years agoFix launch not to wipe out target sector updates
Markus Armbruster [Sat, 26 Dec 2009 13:02:50 +0000 (14:02 +0100)]
Fix launch not to wipe out target sector updates

Launching ABMs updates their base, in mission_pln_equip().  The update
got wiped out when launch_missile() wrote back the target sector,
triggering a seqno mismatch oops.  Harmless with the stock game's
ABMs, because they use neither shells nor petrol.

Fix by re-reading the target sector.

14 years agoFix launch not to wipe out target ship updates
Markus Armbruster [Sat, 26 Dec 2009 10:28:25 +0000 (11:28 +0100)]
Fix launch not to wipe out target ship updates

Ships can expend shells to defend against missiles, in
shp_missile_defense().  Any shell use by the target ship got wiped out
when launch_missile() wrote back the target ship, triggering a seqno
mismatch oops.

Fix by re-reading the target ship.

14 years agoBump version to 4.3.24
Markus Armbruster [Sat, 26 Dec 2009 09:20:21 +0000 (10:20 +0100)]
Bump version to 4.3.24

14 years agoFix nightly build v4.3.23
Markus Armbruster [Mon, 14 Dec 2009 05:56:23 +0000 (06:56 +0100)]
Fix nightly build

Commit 5f89f8cb added pre_update.econfig with incorrect permissions.

14 years agoUpdate change log for 4.3.23
Markus Armbruster [Sun, 13 Dec 2009 16:37:13 +0000 (17:37 +0100)]
Update change log for 4.3.23

14 years agoUpdate known contributors comments
Markus Armbruster [Sun, 13 Dec 2009 14:10:07 +0000 (15:10 +0100)]
Update known contributors comments

14 years agoBelatedly update make dependencies for standalone client build
Markus Armbruster [Sun, 13 Dec 2009 07:58:07 +0000 (08:58 +0100)]
Belatedly update make dependencies for standalone client build

main.$O was out of date since commit 518c8d6f.

14 years agoDon't patch constants.c for nightly, use econfig
Ron J Koenderink [Fri, 4 Dec 2009 02:21:22 +0000 (20:21 -0600)]
Don't patch constants.c for nightly, use econfig

14 years agoFix info navigate on missile interdiction targets
Markus Armbruster [Wed, 14 Oct 2009 23:19:00 +0000 (19:19 -0400)]
Fix info navigate on missile interdiction targets

Missile interdiction targets only "valuable" ships since Empire 3.

14 years agoFix info Mobility not to claim missions get a bonus
Markus Armbruster [Wed, 14 Oct 2009 23:10:48 +0000 (19:10 -0400)]
Fix info Mobility not to claim missions get a bonus

Bonus was dropped in v4.0.0.

14 years agoMake transport chopper not light
Markus Armbruster [Wed, 14 Oct 2009 00:19:39 +0000 (20:19 -0400)]
Make transport chopper not light

Capability light has no effect for choppers since commit 041ad4ce,
v4.3.11.

14 years agoFix messages in msl_launch()
Markus Armbruster [Mon, 12 Oct 2009 02:32:44 +0000 (22:32 -0400)]
Fix messages in msl_launch()

14 years agoDon't intercept tactical and marine missiles targeting planes
Markus Armbruster [Mon, 12 Oct 2009 02:18:26 +0000 (22:18 -0400)]
Don't intercept tactical and marine missiles targeting planes

Missiles attacking ground targets (sectors, ships or land units) can
be intercepted, missiles targeting planes can't.  Except msl_launch()
checked the missile's capabilities instead of its target, and thus
intercepted missiles that *could* target ground even when they
targeted planes.

This broke the missile interception code's assumption that
interceptors aren't intercepted, and crashed the server through
infinite recursion: tactical abm #1 intercepts, tactical abm #2
intercepts #1, #1 intercepts #2, ...

Same bug in msl_hit() printed "incoming missile" for missiles that
could target ground but do target planes.

Broken in Empire 2.  Bug can't bite with the stock game's planes.

14 years agoFix and enable collateral damage for missing missiles
Markus Armbruster [Sun, 11 Oct 2009 16:04:16 +0000 (12:04 -0400)]
Fix and enable collateral damage for missing missiles

Collateral damage was disabled, because after msl_hit() reported a
miss, the missile may or may not have reached the target.

Fix by splitting msl_launch() off msl_hit().

Drop the disabled collateral damage code for sector targets, because
sectors can't be missed.  Enable it for ships and land units.

Since msl_launch() returns whether the missile is sub-launched, drop
launch_missile() parameter sublaunch, and simplify its caller.

14 years agoNews reported victim as actor for sub-launched anti-sat and ABM
Markus Armbruster [Tue, 13 Oct 2009 23:33:33 +0000 (19:33 -0400)]
News reported victim as actor for sub-launched anti-sat and ABM

If the intercepted missile was sub-launched as well, this disclosed
its owner.

The stock game's anti-sats and ABMs can't be sub-launched.

14 years agoClarify how perform_mission() uses missiles
Markus Armbruster [Sun, 11 Oct 2009 15:58:00 +0000 (11:58 -0400)]
Clarify how perform_mission() uses missiles

Interdiction of ships and land units with missiles happens elsewhere.
Oops when perform_mission() strays on that turf.

14 years agoRefactor missile interception code
Markus Armbruster [Sat, 10 Oct 2009 22:26:31 +0000 (18:26 -0400)]
Refactor missile interception code

Keep only the common part in msl_intercept(), and give it internal
linkage.  Wrap new msl_abm_intercept() and msl_asat_intercept() around
it.  They are simpler to use.

14 years agoFix defense value of intercepted missiles and satellites
Markus Armbruster [Sat, 10 Oct 2009 22:15:22 +0000 (18:15 -0400)]
Fix defense value of intercepted missiles and satellites

Use the plane's defense value, not the plane type's base value.

14 years agoFix missiles interdicting ships outside range or op area
Markus Armbruster [Sat, 10 Oct 2009 21:07:27 +0000 (17:07 -0400)]
Fix missiles interdicting ships outside range or op area

Ship interdiction works sector by sector.  Interdicting missiles
targeted all ships not yet interdicted, not just the ones in the
current sector.  This could lead to interdiction outside missile range
or op area.

14 years agoGet rid of msl_launch_mindam()
Markus Armbruster [Sat, 10 Oct 2009 20:32:18 +0000 (16:32 -0400)]
Get rid of msl_launch_mindam()

It's awkward, especially in shp_missile_interdiction().  Inline into
callers and simplify.

14 years agoSimplify control logic in msl_intercept()
Markus Armbruster [Sat, 10 Oct 2009 16:23:38 +0000 (12:23 -0400)]
Simplify control logic in msl_intercept()

14 years agoDon't attempt to hide owner of sub-launched satellite
Markus Armbruster [Sat, 10 Oct 2009 15:54:49 +0000 (11:54 -0400)]
Don't attempt to hide owner of sub-launched satellite

The attempt was pointless, because the recipient of the message could
see the owner on skywatch, and the news reported it as well.

14 years agoFix typo in info Selector
Markus Armbruster [Sat, 10 Oct 2009 15:07:29 +0000 (11:07 -0400)]
Fix typo in info Selector

14 years agoMove msl_equip() to callers, internal linkage
Markus Armbruster [Mon, 5 Oct 2009 11:27:43 +0000 (07:27 -0400)]
Move msl_equip() to callers, internal linkage

14 years agoMove "Releasing RV's" message into detonate()
Markus Armbruster [Mon, 5 Oct 2009 11:25:45 +0000 (07:25 -0400)]
Move "Releasing RV's" message into detonate()

14 years agoLimit nukes to strategic missions
Markus Armbruster [Mon, 5 Oct 2009 11:02:40 +0000 (07:02 -0400)]
Limit nukes to strategic missions

Before Empire 2, nukes could be delivered only with bomb (special
mission 'n', airburst only) and launch (targeting sectors or
satellites only).

Empire 2 made nukes available for any kind of bombing, and for any
missile strike on sectors or ships.  This included interdiction and
support missions.  Nuclear-tipped anti-sats and bomb mission n were
removed.

Unfortunately, this was done in a messy way, which led to
inconsistencies and bugs.  The problem is that ordinary damage affects
just the target, while nuke damage affects an area.  Code dealing with
plane damage was designed for the former.  Instead of rewriting it to
cope with area damage cleanly, nuke damage got shoehorned into
pln_damage(), the function to compute conventional plane damage, as a
side effect: computing damage blasted sectors in the area.

If the plane carried a nuke, pln_damage() returned zero (conventional)
damage.  Without further logic, this simply bypassed the code to apply
damage to the target.  This worked out okay when the target already
got damaged correctly by the side effect.

However, some targets are immune to the side effect: when interdicting
a move or explore command, the commodities being moved are not in any
sector.

For other targets, damage has effects other than damaging the target:
offensive and defensive support don't apply the (conventional) damage
to the target sector.  Instead, they turn it into a combat bonus.
Without further logic, nuclear damage doesn't contribute to that.

To make all that work, pln_damage() returned the nuclear damage for
ground zero as well.  Because a plane does either conventional or
nuclear damage, one of them is always zero.

Most callers simply ignored the nuclear damage, and applied only the
conventional damage.

Bug: land units and ships failed to retreat when pin-bombed or
missiled with a nuke.  That's because they received zero conventional
damage.

The mission code flies planes and missiles and tallies their damage.
This mission damage included nuclear damage at ground zero (except for
missiles sometimes, see below), to make support and commodity
interdiction work.  Unfortunately, this broke other things.

Bug: when bombers interdicted ships or land units, nukes first damaged
the ships or land units by the side effect, then again through mission
damage.  Interdicting missiles had a special case to avoid this.

Bug: when interdicting move, explore or transport, nukes first damaged
the sector by the side effect, then again through mission damage's
collateral damage.

There may well be more bugs hiding in this mess.

The mess is not worth fixing.  While the idea of interdicting and
supporting with nukes sounds kind of cool, I believe it's pretty
irrelevant in actual play.

Instead, go back to a variation of the original rules: nukes can be
delivered only through bomb mission 's' and launch at sectors.

Make arm reject marine missiles in addition to satellites, ABMs and
SAMs, and clear the mission.  Make mission reject planes armed with
nukes.  Oops when they show up in mission_pln_equip() anyway.

Make pln_equip() allow planes with nukes only for missions 's' and
't'.

Clean up pln_damage() to just compute damage, without side effect.
Change strat_bomb() and launch_missile() to detonate nukes.  Simplify
the other callers.  Parameter mission of msl_launch_mindam() is now
unused, remove it.

Missiles exploding on launch no longer set off their nukes.  That was
pretty ridiculous anyway.

14 years agoRemove unused missions from mission_pln_equip()
Markus Armbruster [Mon, 5 Oct 2009 09:46:20 +0000 (05:46 -0400)]
Remove unused missions from mission_pln_equip()

14 years agoImprove launch diagnostic messages, switch off supply
Markus Armbruster [Mon, 5 Oct 2009 09:40:39 +0000 (05:40 -0400)]
Improve launch diagnostic messages, switch off supply

msl_equip() used mission_pln_equip(), which is for automatic defenses,
and therefore silent.  Its users launch_as(), launch_missile() and
launch_sat() printed failure diagnostics based on assumptions on what
could go wrong.

Switch to the appropriate function for commands, pln_equip(), and
remove the guesswork.  Implement mission 'i' there.  When launching
from a foreign base, its owner now gets informed.  Unimportant at this
time, as players can't easily deploy missiles in foreign bases.

This change also switches off automatic supply for launch.  Consistent
with bomb.

14 years agoMake anti-sat launch consistent with interception
Markus Armbruster [Sun, 4 Oct 2009 22:42:15 +0000 (18:42 -0400)]
Make anti-sat launch consistent with interception

When a manually launched anti-sat hits, it now always destroys the
satellite.  This matches what it does when it intercepts
automatically.  Before, it only damaged the satellite.

14 years agoFix satellite interception not to break "positioned over" line
Markus Armbruster [Sun, 4 Oct 2009 22:00:14 +0000 (18:00 -0400)]
Fix satellite interception not to break "positioned over" line

14 years agoComment fix
Markus Armbruster [Sun, 4 Oct 2009 21:12:22 +0000 (17:12 -0400)]
Comment fix

14 years agoImprove message when refusing to load plane on unsuitable ship
Markus Armbruster [Sun, 4 Oct 2009 20:44:06 +0000 (16:44 -0400)]
Improve message when refusing to load plane on unsuitable ship

Test more specific causes before more general ones.  Also get rid of
silly strcpy().

14 years agoDon't permit nukes on satellites, ABMs and SAMs
Markus Armbruster [Sun, 4 Oct 2009 18:54:39 +0000 (14:54 -0400)]
Don't permit nukes on satellites, ABMs and SAMs

Before, satellites could be disarmed and armed even in orbit.  Nukes
on satellites went along into orbit, where they did nothing in
particular.

Nukes on ABMs and SAMs were lost without effect when their missile
intercepted.

The stock game is not affected, because its satellites, ABMs and SAMs
all have zero load.

14 years agoDrop capabilities stealth and half-stealth
Markus Armbruster [Sun, 4 Oct 2009 17:13:36 +0000 (13:13 -0400)]
Drop capabilities stealth and half-stealth

These were leftovers from Chainsaw, and their only remaining effect
was a flak bonus.

The got replaced except for flak by plane selector stealth under
Chainsaw option STEALTHV, which became mandatory in Empire 2.  It is
unclear why STEALTHV didn't cover flak.  No planes with these
capabilities have existed in the stock game since Empire 2.

14 years agoRemove redundant load checks before pln_damage()
Markus Armbruster [Sat, 3 Oct 2009 20:32:03 +0000 (16:32 -0400)]
Remove redundant load checks before pln_damage()

pln_damage() copes with any load just fine.

14 years agoSimplify how plane cargo is tracked
Markus Armbruster [Sat, 3 Oct 2009 20:25:50 +0000 (16:25 -0400)]
Simplify how plane cargo is tracked

Fold struct plist members bombs (used for bombing runs) and misc (used
for everything else) into a single member load.

14 years agoPenalize fighter combat value for any load, not just bombs
Markus Armbruster [Sat, 3 Oct 2009 20:02:17 +0000 (16:02 -0400)]
Penalize fighter combat value for any load, not just bombs

This can affect only planes with capabilities intercept and either
cargo or mine.  No such planes exist in the stock game.

14 years agoFix bomb for non-tactical cargo bomber
Markus Armbruster [Sat, 3 Oct 2009 19:57:49 +0000 (15:57 -0400)]
Fix bomb for non-tactical cargo bomber

The various bombing functions silently skipped planes not carrying
bombs.  This sanity check was wrong: it checked capabilities "tactical
or not cargo" instead of "tactical or bomber", and failed for
non-tactical cargo bombers.  No such planes exist in the stock game.
The broken check comes from Chainsaw; it replaced an equally wrong
"not cargo" check.

Because pln_sel() lets only suitable planes go on a bombing run, the
broken sanity check is unnecessary.  Drop it.

14 years agoRevise rules for cargo plane loads
Markus Armbruster [Sun, 27 Sep 2009 22:03:13 +0000 (18:03 -0400)]
Revise rules for cargo plane loads

There are three ways to fly cargo: transport (fly command with a
commodity argument), cargo drops (drop command that isn't a sea mine
drop), and paradrops.

A cargo flight can be either an airlift or an airdrop.  Airlifts carry
more cargo than airdrops.  A cargo drop or paradrop with a non-VTOL
plane is an airdrop.  Anything else is an airlift.

Before, paradrop always behaved like an airdrop, regardless of VTOL,
and drop always like an airlift.  This made little sense.

Effect of the change on the stock game: paradrop with tc carries twice
the punch, and np/tr/jt can drop less than they can fly.  In
particular, tr can't drop guns anymore, and jt can drop only one
instead of three.

14 years agoSimplify load computation in pln_equip(), mission_pln_equip()
Markus Armbruster [Sun, 27 Sep 2009 21:35:13 +0000 (17:35 -0400)]
Simplify load computation in pln_equip(), mission_pln_equip()

14 years agoSimplify plane selection for drop, fly, recon and sweep
Markus Armbruster [Sun, 27 Sep 2009 19:07:57 +0000 (15:07 -0400)]
Simplify plane selection for drop, fly, recon and sweep

Plane flying commands first select the planes to fly the mission and
their escorts, then equip them.  They all fail when no planes to fly
the mission can be equipped.

Unlike bomb and paradrop, commands drop, fly, recon and sweep had an
additional check that made them fail when no planes to fly the mission
could be selected.  Because "none selected" implies "none equipped",
the additional check is redundant.  Remove it.

While there, break lines in calls of pln_sel() more tastefully.

14 years agoMake bomb require capability bomber or tactical
Markus Armbruster [Sun, 27 Sep 2009 18:44:39 +0000 (14:44 -0400)]
Make bomb require capability bomber or tactical

Before, bomb selected any plane, but planes with zero load could not
be equipped.  Cargo planes could be equipped fine, and they flew bombs
to the target, where they silently vanished.

Closes#1388263.

14 years agoMake sweep require capability sweep
Markus Armbruster [Sun, 27 Sep 2009 17:53:40 +0000 (13:53 -0400)]
Make sweep require capability sweep

Before, sweep accepted any plane.  Planes without capability sweep
flew an ordinary recon mission.

Partial fix for #1388263.

14 years agoMake drop require capability cargo
Markus Armbruster [Sun, 27 Sep 2009 17:32:34 +0000 (13:32 -0400)]
Make drop require capability cargo

Before, drop worked like fly: it accepted any plane, but planes
without capability cargo dropped nothing.

Partial fix for #1388263.

14 years agoClarify flying command info pages on plane selection
Markus Armbruster [Sun, 27 Sep 2009 17:12:36 +0000 (13:12 -0400)]
Clarify flying command info pages on plane selection

14 years agoDon't let players paradrop their own sectors
Scott C. Zielinski [Sun, 27 Sep 2009 16:39:54 +0000 (12:39 -0400)]
Don't let players paradrop their own sectors

Such a paradrop always failed, and the paratroopers were lost.

14 years agoSimplify wantflags calculation in bomb(), fly(), para(), reco()
Markus Armbruster [Sun, 27 Sep 2009 15:10:08 +0000 (11:10 -0400)]
Simplify wantflags calculation in bomb(), fly(), para(), reco()

14 years agoClean up outmoded tests for paradrop capability
Markus Armbruster [Sun, 27 Sep 2009 14:55:33 +0000 (10:55 -0400)]
Clean up outmoded tests for paradrop capability

Initially, paradrop capability was implied both by capability cargo
and by capability VTOL.  Chainsaw changed para() to require cargo, and
added compile-time option PARAFLAG to additionally require new
capability para.  The optional PARAFLAG rule became mandatory in
Empire 2.

Chainsaw left the old tests for "cargo or VTOL" in place.  Because
para() checked "cargo and para" first, the old tests for "cargo or
VTOL" always passed, so they had no effect.

Clean them up anyway.

14 years agoMake passing paradrop & mine cargo to pln_arm() & friends optional
Markus Armbruster [Sun, 27 Sep 2009 13:31:50 +0000 (09:31 -0400)]
Make passing paradrop & mine cargo to pln_arm() & friends optional

These missions imply the cargo type, just like bombing missions.  Use
the implied type instead of cargo type parameter ip there.  Parameter
ip is now optional except for missions 't' (transport) and 'd' (drop).

Simplify para() not to pass the optional cargo type.  Leave drop()
alone, because always passing the type is simpler there.

14 years agoRemove superfluous variable ip from bomb()
Markus Armbruster [Sun, 27 Sep 2009 13:20:10 +0000 (09:20 -0400)]
Remove superfluous variable ip from bomb()

14 years agoSimplify calling of pln_arm() & friends
Markus Armbruster [Mon, 14 Sep 2009 01:35:17 +0000 (21:35 -0400)]
Simplify calling of pln_arm() & friends

pln_arm(), pln_equip(), mission_pln_arm() mission_pln_equip() took a
mission parameter encoding the kind of sortie (strategic bomb,
pinpoint bomb, transport, ...), a flag parameter to further specify
the plane's role, and a parameter ip to specify the load.

The flags argument was always either P_F (intercept), P_F | P_ESC
(escort), or zero (any other role).

With non-zero flags, mission and ip argument were not used in any way.

Use mission 'e' and null load for escorts, and remove flags.
Intercept can still be identified by mission zero.

Also change pln_mobcost() to take a mission parameter instead of
flags, so that pln_arm() and mission_pln_arm() can simply pass on
their mission.

14 years agoFix pln_equip()'s check for foreign civilians
Markus Armbruster [Sun, 27 Sep 2009 00:43:01 +0000 (20:43 -0400)]
Fix pln_equip()'s check for foreign civilians

Check the true load instead of the ip parameter.  Makes a difference
only when callers pass a bogus ip that isn't actually used.  Happens
for escorts, but then the call can only be reached for deities,
because for mortals the transports fail before the escorts.

14 years agoSimplify reco() not to pass useless flags to pln_arm()
Markus Armbruster [Mon, 14 Sep 2009 01:13:31 +0000 (21:13 -0400)]
Simplify reco() not to pass useless flags to pln_arm()

Flags P_S and P_I have no effect.

14 years agoStreamline missile hit chance messages
Markus Armbruster [Sun, 13 Sep 2009 17:44:07 +0000 (13:44 -0400)]
Streamline missile hit chance messages

Don't print hit chance for nuclear warheads, it's always 100%.
Instead, print "Arming nuclear warheads" there.  That message is now
printed after interception instead of before.

14 years agoChange launch of anti-sat to take plane# argument
Markus Armbruster [Sun, 13 Sep 2009 17:19:19 +0000 (13:19 -0400)]
Change launch of anti-sat to take plane# argument

Before, it took a sector argument, and targeted the lowest-numbered
satellite there.  Rather inconvenient when your own satellite masks
one of the enemy's.

Moreover, the command could be abused to find all sectors with
satellites.  Now it can "only" be abused to find satellite ids, and
whether they're in range.  Still not ideal, but tolerable.

14 years agoEnable marine msl. unconditionally, remove option PINPOINTMISSILE
Markus Armbruster [Sun, 13 Sep 2009 15:37:17 +0000 (11:37 -0400)]
Enable marine msl. unconditionally, remove option PINPOINTMISSILE

Deities can still control them by customizing table plane-chr.

14 years agoUpdate info version example to current output
Markus Armbruster [Sun, 13 Sep 2009 15:31:06 +0000 (11:31 -0400)]
Update info version example to current output

14 years agoSimplify satmap() to avoid compiler warning
Markus Armbruster [Mon, 7 Sep 2009 19:31:32 +0000 (15:31 -0400)]
Simplify satmap() to avoid compiler warning

14 years agoSimplify detonate() to avoid compiler warning
Markus Armbruster [Mon, 7 Sep 2009 19:30:57 +0000 (15:30 -0400)]
Simplify detonate() to avoid compiler warning

14 years agoFix value of detonate() when target sector takes no damage
Markus Armbruster [Mon, 7 Sep 2009 19:20:41 +0000 (15:20 -0400)]
Fix value of detonate() when target sector takes no damage

This can happen when hitting a sanctuary, or for ridiculously impotent
nukes: groundburst for dam < 5, airburst for dam < 7.  detonate()
returned unpredictable value then.

This screwed up interdiction damage, except for missiles interdicting
ships or land units.  Since nothing can move into a sanctuary, the bug
bit only with ridiculously impotent nukes.

14 years agoFix prod() to limit level production to resource contents
Markus Armbruster [Mon, 7 Sep 2009 19:18:17 +0000 (15:18 -0400)]
Fix prod() to limit level production to resource contents

This could make production command mispredict resource-depleting level
production.  Stock game is not affected.  In fact, such a product
would be highly unusual.

14 years agoFix use of invalid pointer when depleting resource "none"
Markus Armbruster [Mon, 7 Sep 2009 19:18:17 +0000 (15:18 -0400)]
Fix use of invalid pointer when depleting resource "none"

prod() and produce() dereferenced resource uninitialized for products
depleting resource "none" (p_nrdep != 0 && p_nrndx == 0).  The latter
even wrote to it.

Depleting "none" makes no sense, and the depletion is now ignored.
Before, it could conceivably crash the server or corrupt the game.

14 years agoFix workforce formula in info Innards
Markus Armbruster [Sun, 6 Sep 2009 20:03:21 +0000 (16:03 -0400)]
Fix workforce formula in info Innards