(sctstr, shpstr, lndstr): Use `short' instead of `unsigned short' for
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.
(deli, do_demo, lnd_sweep, guerrilla): Saturate items at ITEM_MAX.
With variables, item increases beyond the capacity of variables
(65535) were ignored here.
This should cover all item changes not going through putvec().
(ITEM_MAX): New, value 9999.
(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).
(FALLOUT_MAX): New.
(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.
(MINES_MAX): New.
(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.
(sctstr): Member sct_che encoded number of che and their target.
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.
Sectors need space for items, deliveries and distribution thresholds.
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, ...
(trade_desc): Ignore non-items when printing load. It used to print
the plague as item, which indexed ichr[] out of bounds, which leads to
crash or bogus output.
(genitem, ship, plane, land): Remove unused member sell & equivalents.
(genitem_ca, ship_ca, plane_ca, land_ca): Remove selector "sell".
(comstr, trdstr): Members trd_price, com_price have no effect. Use
them instead of trd_maxprice, com_maxprice and remove the latter.
(commodity_ca, trade_ca): Remove selector "maxprice".
(mult, player_coms): Command `mult' is disabled since 4.0.0 ('96), and
its code is obviously not in working order. Remove.
(minmult, maxmult, configkeys): Unused configuration parameters,
remove.
(tradedesc): Remove code related to mult that had no effect.
(multread, commread, commwrite, commamt, commset, multset, commprice):
Dangerous, because code bypasses ef_read() & friends, remove.
(diss): Commodity cleanup uses the above, remove. Command is disabled
and unlikely to work anyway.
inet_ntoa() is available on all machines that matter, and defining it
ourselves without adequate auto-configuration creates more problems
than it solves. In particular since we defined it with the wrong
type.
(commodity_ca): "xloc", "yloc", "xsell", "ysel" and "price" weren't
NSC_DEITY. Wrong, but commodity_ca[] is currently unused. Also
rename "xloc", "yloc" to "xsell", "ysell".
(sect_ca, genitem_ca, ship_ca, plane_ca, land_ca, nuke_ca, treaty_ca,
loan_ca, news_ca, lost_ca, commodity_ca, trade_ca, nat_ca, map_ca):
NSC_OFF was lost during Empire3, rendering the codes confusing and
harder to use. Tack it back on.
(encode, code_char): No need to fool around with NSC_OFF anymore.
These files were split a long time ago, for technical reasons which
since vanished (linking into different programs). Undo the split,
because the stuff really belongs together.
(sct_typematch): New. Use it instead of typematch() where
appropriate.
(typematch): Prefer exact match to partial match. Use plain char
instead of s_char.
(stmtch, mineq): Document. Move declaration from prototypes.h to
match.h. Use plain char instead of s_char. The code has several
thousand type errors due to s_char vs plain char; s_char must go.
(stmtch): Rewrite for clarity.
Close #803753:
(map_char): New.
(draw_map): Use it. Wilderness and plains owned by other players are
now displayed as '?'.
(radmap2): Display wilderness and plains as '?'.
(satmap): Call satdisp() for all sectors owned by other players.
Don't declare things in more than one place. Move some declarations
between headers. Code is now fully prototyped and compiles cleanly
with gcc -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs
-Wredundant-decls. Closes #723788.
Declare tags.c variables in tags.h. Declare stuff with external
linkage that is not in any other header in misc.h. Remove some
redundant declarations elsewhere.
(prompt, doredir, dopipe, doexecute, output, screen, parsedelay):
Static linkage.
(effadv_list, effadv, rejects, rejectname, telnames, rea, numnames,
tennames, numstr): Replace by static local variables in their only
user.
(relates): Move from global/misc.c to common/nat.c.
(att_mode): Move from global/misc.c to subs/attsub.c.
(deli): Partial rewrite for clarity, motivated by a `might be used
unitialized' warning. Funcional change: you can now change direction
without threshold (matches documentation, clarify it anyway). Change
prompt for the third argument to reflect that. Also provide context
when prompting for the fourth argument; this is sorely needed we
didn't prompt for the third argument.