(prmptrd, uprmptrd): Oops on null prompt. getstarg() is sometimes
called with a null prompt when it is believed not to use it, and that
belief is sometimes wrong. Other users could have similar bugs. Some
systems (GNU, Windows) deal gracefully with printing null strings,
others crash.
(nat_ca, cou_ca, ef_init_srv, xdvisible): Plug major information leak:
nat_ca[] was designed for visibility to the owner only, while cou_ca[]
was designed for the public. xdvisible() implemented that for xdump.
But selectors don't care for that! Since nat_ca[] applies to
EF_NATION, it must be for public visibility. Broken in 4.2.21. Fix
by exchanging contents of nat_ca[] and and cou_ca[]. This breaks
clients relying on xdump.
(command): Don't fold conditionals to lower case. This was added
early in Chainsaw 3, most probably to make them case insensitive.
This is of debatable utility, and inconsistent with the case
sensitivity of commands and arguments. It also interferes with string
conditionals: fleet#A is folded to fleet#a, which means something
else!
Minimize redundancy between (mortal's) xdump nation and xdump country:
(ef_init_srv): Make NSC_DEITY in cou_ca mirror ~NSC_EXTRA in nat_ca,
except for cnum, which may not have either flag in either table.
(nat_ca): Make selectors stat, cname, passwd, xorg, yorg, relations,
contacts and rejects NSC_EXTRA.
(NSC_GENITEM, ship_ca, plane_ca, land_ca): Change selectors group,
fleet, wing and army from numbers to user-friendly strings. This
makes ?fleet#'a' work. Closes #928405.
(pln_mobcost): Don't limit cost to current mobility + 32. No
airworthy plane can possibly use more than 55 mobility in one sortie,
and mobility going that much negative is fine.
(plane_sona): Compute range multiplier in double rather than int, to
match the formula used for sweep chance in plane_sweep(). Rounding
intermediate values is ugly anyway.
(deliver): Change mcost from float to double, because it's used as
double but never as float. This avoids converting the value of
sector_mcost() to float and back.
(lnd_getmil, total_mil): Trivial, inline into callers and remove. The
abstraction from actual land unit mil encoding provided by them was
too leaky to be relied upon anyway.
(take_casualties): Remove superflous casts and parenthesis. Cast to
double rather than float where result usual arithmetic conversions
obviously convert the cast's result to double. No functional changes;
code is still ugly and incomprehensible.
DEFENSE_INFRA was implemented in an odd way: sct_defense was used
regardless of the option, but forced to sct_effic when disabled. This
screws up sct_defense when you disable DEFENSE_INFRA. Implement it
more like FALLOUT: use sct_defense if enabled, else sct_effic. The
change should be invisible except in xdump, which shows the real
sct_defense. Closes #804641.
(SCT_DEFENSE): New.
(dump, sinfra, sector_strength): Use it.
(eff_bomb, build_bridge, build_tower, new, buildeff, sect_damage)
(put_combat, checksect, produce_sect): Don't force sct_defense to
sct_effic when DEFENSE_INFRA is disabled.
(nati): Remove weird code to round max safe population that has no
effect unless your floating-point arithmetic is hopelessly broken.
This code appeared in Chainsaw 3.2 or so. Also remove some redundant
casts.
(nsc_type): New member NSC_HIDDEN.
(meta_type): Add its entry.
(setnum, nstr_promote, nstr_exec_val): Deal with it. nstr_exec_val()
implements opt_HIDDEN by mapping unknown values to -1.
(natstr, nat_ca): Use it for member nat_relate. This also halves its
size. Fixes very minor leak: before, player could see relations to
all countries, regardless of contact.
(nation_relations): Add entry for -1.
(powe): Rewrite computation of targets[] for power c using
snxtitem()/nxtitem(), for simplicity and more uniform syntax. Country
names no longer work when specifying more than one country (snxtitem()
restriction). As usual with nxtitem(), silently ignore unsuitable
items (the old code complained and failed). Don't skip powerless
countries for power c. Closes #1025607.
(set_target): Unused, remove.
(nuke): Players need the uid to work with nukes, show it. Show
members introduced in nuke.h rev. 1.19 and 1.20: nuk_plane, nuk_effic,
nuk_tech, nuk_stockpile. Make output similar to the other unit
reports while we're at it.
(detonate): Change parameters from carrying plane to nuke and
airburst. Leave taking nuke off the plane to caller. Use coord for
coordinate parameters.
(pln_damage): Take nuke off the plane.
(detonate): Destroy the nuke. This is required since arming doesn't
remove nukes from the nuke file anymore (arm.c rev. 1.15).
(nuk_postread): Update nuke location to match that of the plane
carrying it. This is required since arming doesn't remove nukes from
the nuke file anymore (arm.c rev. 1.15).
(nuk_prewrite): Properly destroy nuke. This is required since nuke
file contains individual nukes instead of stockpiles (nuke.h
rev. 1.19).
(pln_prewrite): Destroy nuke along with the plane carrying it. This
is required since arming doesn't remove nukes from the nuke file
anymore (arm.c rev. 1.15).
(build_ship, build_land, build_plane): Compute initial efficiency in
double rather than float, because all its uses convert it to double.
Remove redundant casts.
(nukstr): Make it a struct genitem: add members nuk_effic, nuk_mobil,
nuk_tech, nuk_stockpile, nuk_opx, nuk_opy, nuk_mission, nuk_radius.
These have no effect, yet.
(build_nuke): Initialize them.
(nuke_ca): Add genitem selectors: effic, mobil, tech, group, opx, opy,
mission, radius.
(tran_nuke): Zap mission, just in case somebody invents missions for
nukes.
(trade_desc): Show tech and efficiency, for consistency with other
units.
Change nuke storage and commands to match other units:
(nukstr): Hold one nuke instead of a stockpile: replace members nuk_n,
nuk_types by nuk_type, nuk_plane. Add nuk_land for completeness, like
nuk_ship it's not yet used.
(nuke_ca): Update accordingly: replace selectors number and types by
type and plane.
(build_nuke): Update accordingly.
(ndump, nuke): Update accordingly. Output is no longer sorted by
location, and nukes in same location no longer share id. nuke's extra
columns for nuclear plants are repeated for every nuke.
(trade_desc): Update accordingly.
(cede, grab_sect, check_nuke_ok, detonate, trade_nameof): Talk about
nukes instead of nuclear stockpiles.
(arm, disarm): Rewrite, split off new disarm(). Don't remove nuke
from the nuke file on arm. Allow usual plane syntax, not just plane
number. Change second argument from nuke type to nuke number. When
plane is already armed, ignore nuke argument and rearm (broken in
4.2.6).
(tran_nuke): Update for changed struct nukstr, make as similar as
possible to tran_plane. Change syntax to match transport plane.
(player_coms): Update arm, disarm and transport accordingly.
(prnuke, nuk_on_plane): New.
(nuk_add, nuk_delete): Stockpile management, remove.
Don't wrap global variables in a struct for no reason:
(LwpMaxfd, LwpNfds, LwpReadfds, LwpWritefds, LwpFdwait, LwpDelayq)
(LwpSelProc): New, matching members of LwpSelect, internal linkage.
(lwpSelect, LwpSelect): Remove.