Commit graph

315 commits

Author SHA1 Message Date
689f435aff (opt_GRAB_THINGS, Options, get_materials): Remove option GRAB_THINGS. 2004-03-11 08:53:27 +00:00
9ad7afbf17 (dodistribute): Work directly on item arrays instead of copies made by
getvec().  This is safe, because the old code made single copies and
always flushed them back into the unit structures.
2004-03-10 18:32:42 +00:00
d68a0b96c6 (dodeliver): Remove parameter vec, work with sp->sct_item[] instead.
This is safe, because the only caller passed a copy of the latter
created with getvec(), and dodeliver() doesn't change it.  Caller
changed.  Return value no longer needed, remove.
2004-03-10 18:25:05 +00:00
a46cee180a (populace): Remove parameter vec, work with sp->sct_item[] instead.
This is safe, because the only caller passed a copy of the latter
created with getvec(), and populace() doesn't change it.
(tax): Replace getvec() by direct, read-only item access.
2004-03-10 17:59:37 +00:00
5fb761ab45 (pln_equip, mission_pln_equip): Work directly on item arrays instead
of copies made by getvec().  This is safe, because the old code made
single copies and always flushed them back into the unit structures
before flushing those.  Simplify.
2004-03-10 13:35:54 +00:00
e3390b9e0d (pln_equip, mission_pln_equip): Rename item to itype. Use struct
ichrstr member i_vtype instead of pointer arithmetic to map from
`struct ichrstr *' to item type.  No functional changes.
2004-03-10 13:22:48 +00:00
522f1cdf9a (sd, shp_missile_defense): Replace getvec() by direct, read-only item
access.  This is correct, because the old code doesn't use the copy
after it changes the original in the unit structure.
(dd): Remove call of getvec() that has no effect.
2004-03-10 13:16:46 +00:00
364f452a3c (quiet_bigdef): Work directly on item arrays instead of copies made by
getvec().  This is safe, because the old code made single copies and
always flushed them back into the unit structures before flushing
those, in use_ammo(), or discarded both the copy and the unit
structure.
2004-03-10 12:52:24 +00:00
7a59ab4784 Spelling fix. Closes #913151. 2004-03-10 07:24:56 +00:00
361dc5d209 Spelling fix. Closes #912922. 2004-03-10 07:20:56 +00:00
9d30b2d0f6 (scra): Work directly on item arrays instead of copies made by
getvec().  This is safe, because the old code made single copies and
always flushed them back into the unit structures before flushing
those.  To do: obey ITEM_MAX.
2004-03-09 19:32:43 +00:00
ab482ecd39 (grin): Stop grinding before grind puts more than ITEM_MAX bar
constituents in sector.  Work directly on item arrays instead of
copies made by getvec().  This is safe, because the old code made
single copies and always flushed them back into the unit structures
before flushing those.
2004-03-09 19:31:30 +00:00
2a3b29ebe1 (improve, shoo, spy, buildeff): Work directly on item arrays instead
of copies made by getvec().  This is safe, because the old code made
single copies and always flushed them back into the unit structures
before flushing those.
2004-03-09 19:26:02 +00:00
4ad649950e (buil): Work directly on item arrays instead of copies made by
getvec().  This is safe, because the old code made single copies and
always flushed them back into the unit structures before flushing
those.
(build_ship, build_land, build_bridge, build_nuke, build_plane,
build_tower): Change parameter type to match uncopied item arrays.
2004-03-09 14:52:21 +00:00
67ad7ad66a New option -f. 2004-03-09 14:38:59 +00:00
e3eadcd899 Utility programs land', ore' and `perfect' haven't been built by
default for ages (at least 4.2.0 '98).  Unsurprisingly, they don't
compile anymore.  Remove them.
2004-03-09 14:22:57 +00:00
be626bacb1 (lwpCreate): Avoid harmless compiler warning. 2004-03-09 13:28:16 +00:00
510a57f4ea The fix in the previous rev. wasn't complete. 2004-03-09 13:20:39 +00:00
f187082daa (mobupdate): Fix argument of time(). 2004-03-09 12:33:17 +00:00
e7d75b2279 Use gcc function attribute `format' to catch bad format strings. Fix
them.  From Marc Olzheim.
Type modifier 'l' was missing in many places, probably rendering the
server useless on 64-bit hosts.
(ef_flush, ef_write, ef_extend, lwpCreate, lwpDestroy): Use conversion
specifier 'p' to print pointers.
(check_market): Fix display of loan amount.
(doland): Fix unescaped '%' (undefined behavior).
(ldump, ndump, pdump, sdump): Don't use flag '0' with conversion
specifier 's' (undefined behavior).
(dump, ldump, lost, ndump, pdump, sdump, empth_create, update_sched):
Cast time_t and pthread_t to long for printing.
(lwpStackCheck, lwpStackCheckUsed, finish_sects): Insert cast to fix
argument type on all platforms.
(prod): Remove extra argument.
(perform_mission, airdamage, retreat_land1, lwpReschedule): Format
string missed arguments.
2004-03-09 12:27:40 +00:00
735adbf41b Use short' instead of unsigned short' for item storage in places
that were missed in the original changeset.
2004-03-06 07:16:45 +00:00
f427b30f74 From Ron Koenderink:
(pr_land): Fix display of attack and defense value.
(dounit): New parameter farg.  Callers changed.  Use it to implement
attack and defense value editing.  Closes #872271.
(pr_ship): More space efficient display.
(pr_ship): Display defense value.
(doship): Implement defense value editing.
2004-03-05 19:58:07 +00:00
ed4ffe9482 (resupply_commod, s_commod, use_supply, has_supply): Work directly on
item arrays instead of copies made by getvec().  This is safe, because
the old code made single copies and always flushed them back into the
unit structures before flushing those.
2004-03-05 19:36:24 +00:00
ce40449533 (use_supply): Fix the trickery designed to avoid resupply from itself.
Currently, use_supply() is only called for artillery, where the
trickery is not needed, so this fix isn't observable.  Not sure whether
it would be needed if use_supply() were called for supply units.
2004-03-05 19:28:05 +00:00
ed7293f856 (has_supply): Fix the trickery designed to avoid resupply from itself.
Not sure the trickery is needed.  Also avoid `might be used
uninitialized' warning.
2004-03-05 18:31:22 +00:00
4ee7608b0e (s_commod): When !ACTUALLY_DOIT, recursive land unit resupply didn't
work, because the effect of the resupply was immediately undone by an
untimely getvec().
2004-03-05 17:10:25 +00:00
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