empserver/include
Markus Armbruster 40eb78eb74 Fix confused and buggy bridge splashing code
A bridge (span or tower) must be splashed when it gets damaged below
SCT_MINEFF.  Likewise when its last supporting sector (bridge head or
tower) gets damaged below SCT_MINEFF, unless EASY_BRIDGES is enabled.
We need to check this whenever a bridge head, span or tower gets
damaged.  This is done in three places, and all of them screw up:

* checksect() ignores damage to bridge heads.  It also leaves writing
  back the sector it checks to the caller, which never happens when
  it's called from sct_postread().

  Note that checksect() drowns all planes on bridges it splashes.
  Functions that need to exempt flying planes from such a fate have to
  splash bridges themselves.

* sect_damage() ignores damage to bridge towers, and damage to bridge
  spans unless EASY_BRIDGES is enabled.  It then runs checksect(),
  which compensates for these omissions, but happily drowns the planes
  sect_damage() attempts to protect.

* eff_bomb() ignores damage to bridge heads.  Collateral damage makes
  sect_damage() run, which compensates for the omission.

This causes the following bugs:

* Efficiency damage going through sect_damage() can drown planes it
  shouldn't.  This affects pinpoint bombing when collateral damage
  splashes a bridge, and strategic bombing.  The drowned planes then
  crash and burn when they attempt to land at their (just splashed)
  base.

* Efficiency damage to bridge heads not going through sect_damage()
  fails to collapse unsupported bridges.  This affects pin-bombing
  efficiency without collateral damage, and ground combat.  Also deity
  commands edit, setsector and add, but that could be regarded as a
  feature.

* If the sector file somehow ends up with an inefficient bridge span,
  it collapses on every read again and again, until it collapses on a
  write.  Related problems exist with other actions of checksect(),
  and they're not addressed here.

* If the sector file somehow ends up with adjacent inefficient bridge
  towers, checksect() on any of them recurses infinitely:

  - checksect() inefficient tower T1
    - knockdown() T1, but don't write that back to the sector file
    - bridgefall() T1; this reads all adjacent sectors, including
      inefficient towert T2
      - checksect() T2
        - knockdown() T2, but don't write that back to the sector file
	- bridgefall() T1; this reads adjacent sectors including T1
	  - checksect() T1
	    ...

This commit creates a new function bridge_damaged() to splash any
bridges that became inefficient or unsupported after damage to a
sector.  To avoid the inifinite recursion, we call it in
sct_prewrite() instead of checksect().

No uses knockdown() outside bridgefall.c remain, so give it internal
linkage.
2008-02-16 20:57:38 +01:00
..
budg.h Update copyright notice 2008-01-19 10:15:37 +01:00
com.h Update copyright notice 2008-01-19 10:15:37 +01:00
combat.h Update copyright notice 2008-01-19 10:15:37 +01:00
commands.h Update copyright notice 2008-01-19 10:15:37 +01:00
commodity.h Update copyright notice 2008-01-19 10:15:37 +01:00
damage.h Update copyright notice 2008-01-19 10:15:37 +01:00
distribute.h Update copyright notice 2008-01-19 10:15:37 +01:00
econfig-spec.h Make econfig keys data and info work for relative names 2008-02-07 08:01:54 +01:00
empio.h Update copyright notice 2008-01-19 10:15:37 +01:00
empobj.h Update copyright notice 2008-01-19 10:15:37 +01:00
empthread.h Update copyright notice 2008-01-19 10:15:37 +01:00
file.h Clean up initialization of empfile[] 2008-02-10 11:40:57 +01:00
game.h Update copyright notice 2008-01-19 10:15:37 +01:00
ioqueue.h Update copyright notice 2008-01-19 10:15:37 +01:00
item.h Update copyright notice 2008-01-19 10:15:37 +01:00
journal.h Update copyright notice 2008-01-19 10:15:37 +01:00
land.h Get rid of the need to fix up lchr[]. 2008-02-07 08:01:54 +01:00
loan.h Update copyright notice 2008-01-19 10:15:37 +01:00
lost.h Update copyright notice 2008-01-19 10:15:37 +01:00
lwp.h Semaphores are no longer used, remove: 2007-02-08 12:29:16 +00:00
map.h Get rid of src/lib/gen/copy.c 2008-02-03 07:44:20 +01:00
match.h Update copyright notice 2008-01-19 10:15:37 +01:00
misc.h Update copyright notice 2008-01-19 10:15:37 +01:00
mission.h Update copyright notice 2008-01-19 10:15:37 +01:00
nat.h Update copyright notice 2008-01-19 10:15:37 +01:00
news.h Update copyright notice 2008-01-19 10:15:37 +01:00
nsc.h Clean up initialization of nat_ca[] 2008-02-10 11:40:57 +01:00
nuke.h Update copyright notice 2008-01-19 10:15:37 +01:00
optlist.h Make econfig keys data and info work for relative names 2008-02-07 08:01:54 +01:00
path.h Update copyright notice 2008-01-19 10:15:37 +01:00
plague.h Update copyright notice 2008-01-19 10:15:37 +01:00
plane.h Update copyright notice 2008-01-19 10:15:37 +01:00
player.h Update copyright notice 2008-01-19 10:15:37 +01:00
power.h Update copyright notice 2008-01-19 10:15:37 +01:00
product.h Update copyright notice 2008-01-19 10:15:37 +01:00
proto.h Update copyright notice 2008-01-19 10:15:37 +01:00
prototypes.h Fix confused and buggy bridge splashing code 2008-02-16 20:57:38 +01:00
queue.h Update copyright notice 2008-01-19 10:15:37 +01:00
retreat.h Update copyright notice 2008-01-19 10:15:37 +01:00
sect.h Update copyright notice 2008-01-19 10:15:37 +01:00
server.h Update copyright notice 2008-01-19 10:15:37 +01:00
service.h Update copyright notice 2008-01-19 10:15:37 +01:00
ship.h Update copyright notice 2008-01-19 10:15:37 +01:00
tel.h Update copyright notice 2008-01-19 10:15:37 +01:00
trade.h Update copyright notice 2008-01-19 10:15:37 +01:00
treaty.h Update copyright notice 2008-01-19 10:15:37 +01:00
types.h Update copyright notice 2008-01-19 10:15:37 +01:00
unit.h Update copyright notice 2008-01-19 10:15:37 +01:00
update.h Update copyright notice 2008-01-19 10:15:37 +01:00
version.h Update copyright notice 2008-01-19 10:15:37 +01:00
xy.h Update copyright notice 2008-01-19 10:15:37 +01:00