New pln_att(), pln_def(), pln_acc(), pln_range_max(), pln_load()
replace the struct plnstr members with the same names.
Make plane selectors att and def virtual.
Where ordinary selectors specify a value stored in some object,
virtual selectors specify a function to call to compute a value
associated with some object.
Use them to replace the special case xdump ver by new table
EF_VERSION.
Move configkeys[] to lib/common because nsc_init() needs it to
initialize empfile[EF_VERSION].cadef.
This takes care of a number of bugs / inconsistencies:
* Resupply before fire: fire command did not require unit to be in
supply, and resupplied shells. Everywhere else (return fire,
support and interdiction) the land unit had to be in supply after
resupply of everything. Unify not to resupply anything and not to
require being in supply. This is consistent with ships and sectors.
* Resupply after fire: fire command resupplied shells after active
fire. Unify not to do that. This is consistent with ships and
sectors.
* When a land unit returned fire to multiple attackers, quiet_bigdef()
charged it ammo for each one. Finally, it was charged one shell
more by use_ammo(). Except only the first land unit got charged
there in fact, because buggy add_to_fired_queue() entered only the
first land unit into the defender list. Fix add_to_fired_queue()
and change quiet_bigdef() not to charge ammo, just like for ships
and sectors. This charges only one shell instead of the true ammo
use, which is wrong, but consistent with ships.
* lnd_support() tallied support damage unrounded. Unify to round
before tally.
This takes care of a number of bugs / inconsistencies:
* Submarines with zero mobility could interdict. Change to require
positive mobility.
* Submarines with zero firing range could not interdict. Fix by
dropping the test from perform_mission(). No ships in the stock
game are affected.
* Submarines without capability torp could fire return torpedoes and
interdict. Stock sbc, nm and msb were affected by the return fire
bug. Closes bug#950936.
* Shell resupply bugs: quiet_bigdef(), fire_torp() and
perform_mission() resupplied before checking all other requirements
and could thus get more shells than actually needed.
torp() no longer resupplies shells. It's hardly worth the bother, and
fire doesn't do it either.
anti_torp() required line of sight and used gun range for all kinds of
return fire. Require line of sight only for torpedoes, not for gun
fire and depth charges. Use torpedo range for torpedoes, gun range
for gun fire and depth charges.
This takes care of a number of bugs / inconsistencies:
* Ships with zero firing range could return fire and fire support, but
not fire actively or interdict. Fix by testing for gun limit
instead in multifire() and mission(). No ships in the stock game
are affected.
* Required gun crew was inconsistent: multifire() let N military fire
max(1,floor(N/2)) guns for active fire. Ditto perform_mission() for
interdiction. quiet_bigdef() let them fire N guns for returning gun
fire. Ditto sd() for firing support and firing at boarding parties.
fire_dchrg() let them fire floor(N/2) for returning fire to
torpedoes. Unify to let N military fire floor((N+1)/2) guns.
* Shell use was inconsistent: sd() and perform_mission() used one
shell per gun, everything else one per two guns. Unify to one shell
per two guns.
* Shell resupply bugs: multifire() got two shells regardless of actual
ammo use. quiet_bigdef() got one shell (but use_ammo() uses only
one, which is a bug). sd() and perform_mission() resupplied before
checking all other requirements and could thus get more shells than
actually needed.
Before 4.0.6, depth charges required no guns, one military, did damage
like shell fire from two guns, and used two shells. Missions were not
quite consistent with that (bug). 4.0.6 changed depth charges to work
exactly like shell fire (but without updating documentation
accordingly): require guns and gun crew, non-zero firing range, scale
damage and ammunition use with guns.
Go back to the old model, but with damage like three guns, to avoid
changing the stock game's dd now (three gun damage for two shells).
Stock game's af changes from two gun damage for one shell, and nas
from four gun damage for two shells.
Factor out common depth-charging code into shp_dchrg().
This takes care of a number of bugs / inconsistencies:
* sb() fired support even when there were not enough mil.
* Shell resupply bugs: multifire() and quiet_bigdef() resupplied
shells before checking all other requirements and could thus get
more shells than actually needed.
Rename landgun() to fortgun() for consistency.
The macros defining unit stat development in tech are somewhat
inconvenient to use. Define more convenient functions, and hide away
the macros near the function definitions.
If gcc's preprocessor chokes, it leaves an empty dependency file
behind, and doesn't touch the object file. If an old object file
exists, and is newer than the .c file, make will then consider the
object file up-to-date. This can lead to nasty version errors.
delete_old_news() and init_nreport() tested for non-zero nws_when,
which is breaks for news at the epoch. Not likely to happen, but
still wrong.
ncache() tested nws_uid, which breaks for the first entry in the news
file. This made ncache() overlook that entry in the cache, and create
a new news item instead of incrementing nws_ntm. Was always broken
that way.
Fix by testing nws_vrb instead.