]> git.pond.sub.org Git - empserver/log
empserver
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

14 years agoFactor new lnd_sabo() out of sabo()
Markus Armbruster [Sat, 1 Aug 2009 22:34:20 +0000 (18:34 -0400)]
Factor new lnd_sabo() out of sabo()

This permits giving seagun(), fortgun() and landunitgun() internal
linkage.

14 years agoFix show help text to include news and product
Markus Armbruster [Sat, 1 Aug 2009 19:27:20 +0000 (15:27 -0400)]
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.

14 years agoSlight info markup normalization
Markus Armbruster [Sun, 26 Jul 2009 17:48:22 +0000 (13:48 -0400)]
Slight info markup normalization

Consistently use \*(f, not \f, and \e, not \\.

14 years agoInfo markup fixes
Markus Armbruster [Sun, 26 Jul 2009 17:47:09 +0000 (13:47 -0400)]
Info markup fixes

14 years agoFix w32_sysdep_init() to complain to stderr, not stdout
Markus Armbruster [Sun, 19 Apr 2009 07:39:44 +0000 (09:39 +0200)]
Fix w32_sysdep_init() to complain to stderr, not stdout

14 years agoEmpty out and remove sysdep_w32.c sysdep_w32.h
Markus Armbruster [Sun, 19 Apr 2009 07:37:42 +0000 (09:37 +0200)]
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.

14 years agoUse src/lib/w32/w32sockets.c for client
Markus Armbruster [Sat, 18 Apr 2009 21:01:23 +0000 (23:01 +0200)]
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().

14 years agoUse src/lib/w32/w32io.c for client
Markus Armbruster [Sat, 18 Apr 2009 20:16:00 +0000 (22:16 +0200)]
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.

14 years agoRevert "MinGW provides random() in -liberty, no need to replace it"
Markus Armbruster [Sat, 5 Dec 2009 14:09:19 +0000 (15:09 +0100)]
Revert "MinGW provides random() in -liberty, no need to replace it"

This reverts commit 3ec807e99a8dfa6094660896d17bf20dd92e0de8.

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

14 years agoClean up w32misc.h, sysdep_w32.h not to override needlessly
Markus Armbruster [Sat, 18 Apr 2009 15:36:43 +0000 (17:36 +0200)]
Clean up w32misc.h, sysdep_w32.h not to override needlessly

14 years agoreadv() and writev() for Windows returned -1 instead of 0
Markus Armbruster [Sat, 18 Apr 2009 20:07:51 +0000 (22:07 +0200)]
readv() and writev() for Windows returned -1 instead of 0

14 years agoMinGW provides random() in -liberty, no need to replace it
Markus Armbruster [Sat, 18 Apr 2009 15:21:14 +0000 (17:21 +0200)]
MinGW provides random() in -liberty, no need to replace it

14 years agoMinGW provides getopt(), no need to replace it
Markus Armbruster [Sat, 18 Apr 2009 14:33:08 +0000 (16:33 +0200)]
MinGW provides getopt(), no need to replace it

14 years agoChange naming convention of POSIX emulation layer for Windows
Markus Armbruster [Mon, 13 Apr 2009 17:55:12 +0000 (19:55 +0200)]
Change naming convention of POSIX emulation layer for Windows

Use prefix w32 instead of posix: Rename posixfile.c, posixio.c to
w32file.c, w32io.c.  Rename posix_accept(), posix_bind(),
posix_close(), posix_fd2socket(), posix_listen(), posix_mkdir(),
posix_setsockopt(), posix_shutdown(), posix_socket() to w32_accept(),
w32_bind(), w32_fd2socket(), w32_list(), w32_mkdir(),
w32_setsockopt(), w32_shutdown(), w32_socket().

14 years agoMove Windows socket stuff out off posixio.c into w32sockets.c
Markus Armbruster [Mon, 13 Apr 2009 17:25:25 +0000 (19:25 +0200)]
Move Windows socket stuff out off posixio.c into w32sockets.c

This is so we can avoid linking utilities with socket libraries (see
commit 8b778634).

When using sockets, we need to replace close(), because Windows'
close() can't cope with socket file descriptors.  But replacing it
always would pull in the socket stuff again.  Define close() to call
function pointer w32_close_function, which is initially _close.
Rename posix_close() to w32_close_maybe_socket().  Make new
w32_socket_init() put it in w32_close_function.

Same for read() and write(): define read(), write() to call function
pointers w32_read_function, w32_write_function, initially _read(),
_write(); rename posix_read(), posix_write() to
w32_read_maybe_socket(), w32_write_maybe_socket(), and put them into
w32_read_function, w32_write_function in w32_socket_init().

Also call WSAStartup() there, and use that from loc_NTInit().
WSACleanup() now belongs next to w32_socket_init().  Don't bother,
just drop it, along with loc_NTTerm().

14 years agoInclude <winsock2.h> only through "sys/socket.h"
Markus Armbruster [Sat, 18 Apr 2009 16:16:22 +0000 (18:16 +0200)]
Include <winsock2.h> only through "sys/socket.h"

Because we need to #undef NS_ALL after <winsock2.h>, and want to do
that in just one place.

14 years agoInclude <windows.h> from service.h to make it self-contained
Markus Armbruster [Sat, 18 Apr 2009 16:13:27 +0000 (18:13 +0200)]
Include <windows.h> from service.h to make it self-contained

Remove now superfluous includes elsewhere.

14 years agoDon't fake open() and fcntl() just for ef_open()
Markus Armbruster [Mon, 13 Apr 2009 16:20:52 +0000 (18:20 +0200)]
Don't fake open() and fcntl() just for ef_open()

Put the Windows code into new open_locked() instead.  It's ugly having
that in file.c, but the fakes are ugly too, and somewhat brittle.
Remove posix_open(), F_SETLK, F_RDLCK, F_WRLCK, struct flock, and
simplify fcntl().

14 years agoRemove macro S_IRWUG
Markus Armbruster [Mon, 13 Apr 2009 15:27:08 +0000 (17:27 +0200)]
Remove macro S_IRWUG

Use its expansion instead.

14 years agoRevamp server's Windows POSIX compatibility code
Markus Armbruster [Mon, 13 Apr 2009 13:35:40 +0000 (15:35 +0200)]
Revamp server's Windows POSIX compatibility code

Unlike POSIX sockets, Windows sockets are not file descriptors, but
"OS handles", with a completely separate set of functions.

However, Windows can create a file descriptor for a socket, and return
a file descriptor's underlying handle.  Use that instead of wrapping
our own file descriptors around Windows file descriptors and sockets.

Remove the wrapping machinery: MAX_FDS, enum fdmap_io_type, struct
fdmap, fdmap[], nfd, get_fd(), free_fd(), set_fd(), lookup_handle(),
lookup_fd().

Rewrite SOCKET_FUNCTION(), posix_accept(), posix_socket(),
posix_close(), ftruncate(), posix_open(), posix_read(), posix_write(),
fcntl().

Remove FILE_FUNCTION(), posix_fstat(), posix_lseek(),
SHARED_FUNCTION(), and fileno(), because the system's functions now
work fine.

posix_fsync() is used only #ifdef _WIN32, remove it, and call
_commit() directly.

The old code stuffed WSA error codes into errno, which doesn't work.
Use new w32_set_winsock_errno() to retrieve, convert & stuff into
errno.  Adapt inet_ntop() to set the WSA error code instead of errno,
so it can use w32_set_winsock_errno().

Move EWOULDBLOCK from sys/socket.h to w32misc.h, and drop unused
ENOTSOCK, EAFNOSUPPORT.

Use SOCKET rather than int in Windows-specific code.