Commit graph

5389 commits

Author SHA1 Message Date
7969ff8047 (s_commod): Don't zap supply unit fuel on recursive resupply. No idea
why it was coded that way; it doesn't make sense.  No supply units
using fuel exist in the stock game.
2004-03-05 16:36:55 +00:00
d35085e5c4 (s_commod): Clarify and comment the trickery required to make the
recursion work.  By the way, resuppling from supply units in unit id
order is a greedy algorithm, which is quite inappropriate for the
problem.
2004-03-05 16:30:30 +00:00
e6ffdb71ee (gen_power, addtopow): Call addtopow() directly on item arrays instead
of copies made by getvec().  This is obviously correct, since there
are no writes.
2004-03-05 13:20:11 +00:00
733aff63ed (att_move_in_off): Don't put more than ITEM_MAX food into the
assaulted sector.  Simplify some more.
2004-03-05 13:14:28 +00:00
ebb472ed58 (att_move_in_off): The lunchbox code was unnecessary general,
therefore had unreachable code.  Which was also buggy.  Simplify.
2004-03-05 13:04:12 +00:00
7d7945c3e9 Replace getvec() by direct, read-only item access in some cases where
that's obviously correct.
2004-03-05 12:05:33 +00:00
4f6e806975 [START_UNITS] (deity_build_land): Replace variable access in disabled
code missed in the previous revision.
2004-03-05 11:55:13 +00:00
b1461faea5 Replace getvec() by direct, read-only item access in some cases where
that's obviously correct.
2004-03-05 10:38:58 +00:00
99bfa19a92 (getilist, att_get_combat): Simplify. No functional changes. 2004-03-05 08:05:58 +00:00
ade0e97856 (putvec): Saturate and log error on underflow/overflow, don't just
truncate.
2004-03-05 07:59:29 +00:00
9989c5b3ec (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.
2004-03-05 07:56:50 +00:00
58e93c0ea3 (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().
2004-03-05 06:48:57 +00:00
95ef2b139d (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).
2004-03-05 06:34:34 +00:00
5ec624514a (load_comm_ship, load_comm_land): Partial rewrite for clarity. Fix
`are we loading' tests.  Closes #752493 and #965504.
2004-03-04 20:05:01 +00:00
abd1fd2c1e (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.
2004-03-04 16:19:50 +00:00
828b84d840 (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.
2004-03-04 15:54:46 +00:00
7cd66c0f70 (pln_dropoff): Restructure for clarity and to avoid `might be used
uninitialized' warning.
2004-03-04 15:45:34 +00:00
bebca811de (pln_dropoff): The previous revision screwed up output; fix. 2004-03-04 15:08:00 +00:00
5bad9875a5 (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.
2004-03-04 13:49:25 +00:00
eccc5cb7d7 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, ...
2004-03-03 16:54:22 +00:00
ba86513b01 (plague_people): Log and repair bad plague stage. 2004-03-03 13:20:46 +00:00
c530a3b980 (genobject, genchrstr): Unused, remove. 2004-03-03 10:23:07 +00:00
08e182e132 (fileinit): Invalid cast sct_init(); a call couldn't possibly work.
Luckily, it isn't called.  Remove.
(ef_fileinit): Unused, remove.
2004-03-03 10:17:53 +00:00
42290db8c8 (nameofitem, produce, check, fire_dchrg, send_reacting_units_home,
do_map_set, upd_land, nav_check_atdest, produce, upd_ship): Remove
unused parameters.  Callers changed.
2004-03-03 09:39:50 +00:00
19acc1cd07 (diss, player_coms): Command `dissolve' has been disabled at least
since the days of Chainsaw (early '90s), and the code smells bad.
Bury it.
2004-03-03 08:20:45 +00:00
3060cabc48 (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.
2004-03-02 20:59:04 +00:00
bb811df758 (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".
2004-03-01 17:21:40 +00:00
95b650396a (s_commod): Move initialization of `min' before first use.
(itemname): Unused, remove.
2004-03-01 14:23:44 +00:00
f72281b773 (shp_missile_defense): Move big assignment out of if condition for
clarity.
2004-03-01 14:21:11 +00:00
b8c9d6a029 (carriersatxy): Use &&' instead of somewhat confusing &'. 2004-03-01 14:18:37 +00:00
1f5754b5aa (player_new) [!RESOLVE_IPADDRESS]: Don't define unused local variable. 2004-03-01 14:17:58 +00:00
69d06bad46 (sctcache, bestp) [!DO_EFF_MEM_CHECKING]: cache isn't used, don't
define it.
2004-03-01 14:16:31 +00:00
21dd4cfc0f (draw_map): Fix test of player->command->c_flags. Broken code
happened to work because C_MOD is the only flag defined.
2004-03-01 14:14:39 +00:00
bbeab716f4 Remove duplicate macro definitions. 2004-03-01 14:10:11 +00:00
e1cb606dab Break excessively long line. 2004-03-01 14:07:10 +00:00
7d12f4b841 (deity_build_land) [!START_UNITS]: Unused, don't define. 2004-03-01 14:06:23 +00:00
d0cf6a0a9b Clean up switch cases: proper fall through comments, no break after
return.
2004-03-01 14:03:29 +00:00
7c52730439 Don't cast void to void. 2004-03-01 13:56:07 +00:00
262e1bafba Remove some unused junk. 2004-03-01 13:48:45 +00:00
5df329c766 Remove RCS keyword comment, it's a nuisance. 2004-03-01 13:41:10 +00:00
5fa00591fe (sccsid): Useless, as we don't use SCCS. Remove. 2004-03-01 13:33:51 +00:00
98b392d72c (CHE_MAX): Don't define twice, define once in a header.
(get_che_cnum, set_che_cnum, get_che_value, set_che_value): Remove
redundant definitions.
2004-03-01 13:32:06 +00:00
13797a2ba2 (execute): Fix botched test for empty argument. 2004-03-01 13:26:39 +00:00
0c19d70c74 (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.
2004-03-01 09:04:02 +00:00
30cb9e2a83 (interix, INTERIXCFLAGS, INTERIXLFLAGS, INTERIXMASTER): New, from Ron
Koenderink.
2004-03-01 07:10:31 +00:00
ef0ddff4c2 (safe_getcwd): New. When getcwd() is known to be able to allocate its
buffer, just call that.  Else wrap suitable allocation around it.
(main): Use it.
2004-03-01 07:07:27 +00:00
5ce301e2fb (ntinstall): Fix mkdir data. 2004-03-01 06:58:03 +00:00
b572ec19ad Fix missing include. 2004-02-29 11:41:26 +00:00
d500806bc8 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.
2004-02-29 11:41:08 +00:00
f6d7ebb480 (rea): Don't use L_SET, it's ancient BSD history, just use SEEK_SET. 2004-02-29 11:35:38 +00:00