Use `short' instead of `unsigned short'. With variables, plague stage
and time were stored unsigned and used signed, which worked. Removal
of variables dropped the conversion to signed, which broke
plague_people() (plague.c rev. 1.6): stage didn't progress correctly
due to catastrophic underflow of time.
NUK_BLD_WORK): New, to encapsulate the formula in one place.
(SCT_MINEFF): New. Use it instead of literal 20.
(buil): Use CANT_HAPPEN() for internal error.
(build_ship, build_land, build_bridge, build_nuke, build_plane,
build_tower): Simplify avail calculation.
(lupgr, supgr, pupgr): Charge 15% of total build avail instead of an
undocumented amount computed from build lcm and hcm.
(build_ship, build_land, build_bridge, build_nuke, build_plane,
build_tower, lupgr, supgr, pupgr): Fix reporting of required avail
when there's not enough. Closes#942823.
(lupgr, supgr, pupgr): Code printed cost rounded down, but required
and charged unrounded cost. Confusing. Round cost down, like the
build command. Closes#942811.
(UPGR_COST, UPGR_EFF, lupgr, supgr, pupgr): New UPGR_COST, UPGR_COST replace
literal values.
(show_bridge, show_tower): Don't claim bridge building requires
`workers' (whatever that is), since it doesn't.
item storage. Rationale: Permitted values are 0..M, where M depends
on the container. The largest M is ITEM_MAX (9999). Benign
overflow/underflow occurs at those limits. Catastrophic
overflow/underflow occurs at the limits of the underlying data type.
For `unsigned short', any underflow is catastrophic. For `short',
benign undeflow happens long before catastrophic underflow. Moreover,
unsigned arithmetic tends to trip up unwary programmers.
(give, deliver_it): Use it instead of 9990.
(load_comm_ship, load_comm_land, rese): Use it instead of 9999.
(thre): Use it instead of 10000.
(check_market, explore, move, pln_dropoff): Use it instead of 32767.
(unload_it): Use it instead of 99999 (which couldn't possibly work,
but what do you expect from the autonav code).
(doland, detonate, spread_fallout): Use it. With variables, fallout
beyond the capacity of variables (65535) was ignored, except in
doland(), where it saturated at 9999, and spread_fallout, where it
could overflow. Now it always saturates at FALLOUT_MAX.
(doland, mine, landmine, setsector, pln_dropoff): Use it. With
variables, mining beyond the capacity of variables (65535) was
ignored. Now the mines saturate at MINES_MAX.
Simplify. Split into member sct_che (number) and sct_che_target.
Users changed.
(get_che_cnum, set_che_cnum, get_che_value, get_che_value): Che
encoding/decoding functions; remove.
(CHE_MAX): Move from var.h to sect.h.
(prsect, doland): Print / edit the new field.
To save space, the ancients invented `variables': a collection of
key-value pairs, missing means zero value, space for `enough' keys.
This complicates the code, as assigning to a `variable' can fail for
lack of space. Over time, `enough' increased, and for quite some time
now `variables' have been *wasting* space. This changeset replaces
them, except in struct mchrstr, struct lchrstr and struct pchrstr,
where they are read-only, and will be replaced later. It is only a
first step; further cleanup is required. To simplify and minimize
this necessarily huge changeset, the new item[] arrays have an unused
slot 0, and the old variable types V_CIVIL, ... are still defined, but
must have the same values as the item types I_CIVIL, ...
between headers. Code is now fully prototyped and compiles cleanly
with gcc -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs
-Wredundant-decls. Closes#723788.
thread entrypoints:
(lwpSelect, shutdown_sequence): Parameters didn't match thread entry
point prototype.
(lwpEntryPoint): Arguments didn't match thread entry point prototype.
Change linkage of functions without prototype declaration to static
where possible.
Remove some superflous declarations, replace others by suitable
includes.