Commit graph

3620 commits

Author SHA1 Message Date
a269cdd7e9 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.
2009-12-13 07:46:00 +01:00
b0ba9022dc Remove unused missions from mission_pln_equip() 2009-12-12 16:30:32 +01:00
528df9acba 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.
2009-12-12 16:28:52 +01:00
cf960a573c 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.
2009-12-12 16:28:52 +01:00
3e5df7530d Fix satellite interception not to break "positioned over" line 2009-12-12 16:28:52 +01:00
3a4b50b815 Comment fix 2009-12-12 16:28:52 +01:00
7312693936 Improve message when refusing to load plane on unsuitable ship
Test more specific causes before more general ones.  Also get rid of
silly strcpy().
2009-12-12 16:28:52 +01:00
0100402e5f 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.
2009-12-12 16:28:52 +01:00
61233e47e8 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.
2009-12-12 16:28:52 +01:00
0e8bcce59c Remove redundant load checks before pln_damage()
pln_damage() copes with any load just fine.
2009-12-12 16:28:52 +01:00
54b1c04686 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.
2009-12-12 16:28:52 +01:00
d3f5fee64b 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.
2009-12-12 16:28:52 +01:00
221027aca5 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.
2009-12-12 16:28:52 +01:00
7b7fe69c46 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.
2009-12-08 08:15:51 +01:00
b2107e5301 Simplify load computation in pln_equip(), mission_pln_equip() 2009-12-08 08:15:51 +01:00
29a6baca6d 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.
2009-12-08 08:15:51 +01:00
fd4da5aab3 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.
2009-12-08 08:15:51 +01:00
5f5362cece Make sweep require capability sweep
Before, sweep accepted any plane.  Planes without capability sweep
flew an ordinary recon mission.

Partial fix for #1388263.
2009-12-08 08:15:51 +01:00
3cea4ac5be 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.
2009-12-08 08:15:51 +01:00
1c5bfa0eab Clarify flying command info pages on plane selection 2009-12-08 08:15:51 +01:00
Scott C. Zielinski
f79d1680a7 Don't let players paradrop their own sectors
Such a paradrop always failed, and the paratroopers were lost.
2009-12-08 08:15:51 +01:00
b2e6663f39 Simplify wantflags calculation in bomb(), fly(), para(), reco() 2009-12-08 08:15:51 +01:00
df1ca95a2a 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.
2009-12-08 08:15:51 +01:00
062a42fb7b 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.
2009-12-08 08:15:51 +01:00
15d355521a Remove superfluous variable ip from bomb() 2009-12-08 08:15:51 +01:00
0fe43096bc 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.
2009-12-08 08:15:51 +01:00
b1dd82fa61 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.
2009-12-08 08:15:50 +01:00
79154bf0fc Simplify reco() not to pass useless flags to pln_arm()
Flags P_S and P_I have no effect.
2009-12-08 08:15:50 +01:00
e2580b4005 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.
2009-12-08 08:15:50 +01:00
1ee0287595 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.
2009-12-08 08:15:50 +01:00
2b31f644db Enable marine msl. unconditionally, remove option PINPOINTMISSILE
Deities can still control them by customizing table plane-chr.
2009-12-08 08:15:50 +01:00
ac33576a99 Update info version example to current output 2009-12-08 08:15:50 +01:00
927abead50 Simplify satmap() to avoid compiler warning 2009-12-08 08:15:50 +01:00
e5a43ebe26 Simplify detonate() to avoid compiler warning 2009-12-08 08:15:50 +01:00
e0cb1b66b3 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.
2009-12-08 08:15:50 +01:00
8718a9428a 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.
2009-12-08 08:12:55 +01:00
c63ec06d15 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.
2009-12-08 08:11:01 +01:00
c0b2eec69d Fix workforce formula in info Innards 2009-12-05 15:19:37 +01:00
ad296698f9 Factor new lnd_sabo() out of sabo()
This permits giving seagun(), fortgun() and landunitgun() internal
linkage.
2009-12-05 15:19:37 +01:00
162c79bb73 Fix show help text to include news and product
Commit 1bca66c0 added show news and commit 71bbd642 show product
without updating the help text.  Fix that.  The prompt is now too
long, so add option '?' to show it, and change the prompt to refer to
that.
2009-12-05 15:19:37 +01:00
5705ab91b8 Slight info markup normalization
Consistently use \*(f, not \f, and \e, not \\.
2009-12-05 15:19:37 +01:00
2b237bfa89 Info markup fixes 2009-12-05 15:19:37 +01:00
9697912a90 Fix w32_sysdep_init() to complain to stderr, not stdout 2009-12-05 15:19:37 +01:00
518c8d6fbf Empty out and remove sysdep_w32.c sysdep_w32.h
Not much remains in sysdep_w32.c, and it's mostly for main.c.  Move
that there, and the rest to misc.h.
2009-12-05 15:19:37 +01:00
4d40a27542 Use src/lib/w32/w32sockets.c for client
Move client's w32_connect() to w32sockets.c.

Replace w32_recv() and w32_send() by read() and write().

Replace w32_close() by w32_close_function.

Replace call of WSAStartup() in w32_sysdep_init() by
w32_socket_init().

Remove the identical copies of fd_is_socket(),
w32_set_winsock_errno(), w32_socket().
2009-12-05 15:19:36 +01:00
1153d9c995 Use src/lib/w32/w32io.c for client
Replaces w32_writev_socket() and w32_readv_fd().  Split w32types.h off
w32misc.h, to avoid putting irrelevant stuff into client tarball.
2009-12-05 15:19:34 +01:00
c8231b120b Revert "MinGW provides random() in -liberty, no need to replace it"
This reverts commit 3ec807e99a.

Our nightly build test cases rely on the PRN sequence generated by GNU
libc's random().  We used to have such a PRNG in our tree (derived
from an old version of GNU libc's), for use under Windows.  Thus we
got the same PRN sequence on both our nightly test systems.  Commit
3ec807e9 switched to -liberty under Windows and removed our random().
Now we got a different sequence there, breaking the test cases.

Test cases still don't work on non-Windows systems where random()
doesn't match GNU libc's.  We should switch to a PRNG that produces
the same sequence everywhere.

Conflicts:

	src/lib/w32/w32misc.h
2009-12-05 15:09:19 +01:00
c9508fa588 Clean up w32misc.h, sysdep_w32.h not to override needlessly 2009-11-30 19:45:28 +01:00
bbd5cfdebb readv() and writev() for Windows returned -1 instead of 0 2009-11-30 19:45:28 +01:00
3ec807e99a MinGW provides random() in -liberty, no need to replace it 2009-11-30 19:45:28 +01:00