Commit graph

726 commits

Author SHA1 Message Date
5a725c9177 (nullify_objects): Use SCT_MAXDEF instead of sct_maxno. Loop no
longer covers the extra empty slots at the end of the dchr[]; doesn't
matter.

(sct_maxno): Unused, remove.
2004-08-19 17:45:36 +00:00
0ebb14c8be (PRI_SMAINT, PRI_PMAINT, PRI_LMAINT, PRI_SBUILD, PRI_PBUILD,
PRI_LBUILD): Turn macros into enumeration constants.  Value
SCT_MAXDEF+1 was previously unused; use it.
(PRI_MAX): New; replacing the horrible SCT_MAXDEF+8.

(show_sect_build): Simply examine all sector types, don't skip the
first five.  The code ignores them just fine.

(show_sect_build, show_sect_stats, show_sect_capab): Don't try to show
sector types beyond SCT_MAXDEF.  The table has some empty extra slots,
for whatever reasons; no use examining them.
2004-08-19 16:59:36 +00:00
95d1d10591 Use plain char * instead of s_char *. Doc clarifications. 2004-08-17 19:22:43 +00:00
e1ebe41686 (M_TORP_SHELLS, SHP_TORP_SHELLS): Rename. 2004-08-17 18:45:04 +00:00
4fd7da248a (SHP_AIROPS_EFF, LND_AIROPS_EFF): New. Use it instead of literal 50. 2004-08-17 18:31:32 +00:00
8ef7f35a56 (V_CIVIL, V_MILIT, V_SHELL, V_GUN, V_PETROL, V_IRON, V_DUST, V_BAR,
V_FOOD, V_OIL, V_LCM, V_HCM, V_UW, V_RAD, V_ITEM): Remove, use item
types instead.
2004-08-17 16:12:31 +00:00
09def8f156 (show_sect_capab, V_ITEM): The difference between variable and
item types was removed some time ago.  Simplify.
(VT_ITEM, VT_TYPE, V_MAX): Unused, remove.

(show_sect_capab): Properly use ichr[] member i_mnem to print item
characters.
2004-08-17 16:07:01 +00:00
4d154753b8 (pchrstr, MAXPRCON): Simplify variable-style storage of constituents.
Store only up to MAXPRCON constituents, not MAXCHRNV; code doesn't
fully support more than three anyway.  Remove member p_nv, use item
type I_NONE for unused slots.  Rename members p_vtype, p_vamt to
p_ctype, p_camt to avoid confusion with variable-style storage.
(pchr): Initializers adapted.
(nullify_objects, materials_cost, materials_charge, prod,
show_sect_capab, grind): Adapt, simplify where possible, protect
against bad item types in pchr[].
(MAXCHRNV): Unused, remove.
2004-08-17 15:19:46 +00:00
8a0854b6b8 (mchrstr, lchrstr): Change from variable-style storage of load
capacities to straight arrays.  Users now subscript the array instead
of calling vl_find() or walking the variable data structure.
(mchr, lchr): Initializers adapted.
(vl_find): No longer used.  Remove file.
2004-08-17 14:09:04 +00:00
Ron Koenderink
a965b2d25e (prod_eff): New, factored out of produce() and prod().
(upd_ship): Oil and food production used special rules that didn't
match ordinary production and didn't make much sense.  Made them
follow ordinary production rules.  This puts uw and mil to work, and
makes ship tech and efficiency relevant to production.  Closes #917461
and #955072.
2004-08-17 13:17:50 +00:00
98a7936c08 Update for 4.2.17. 2004-08-14 20:03:08 +00:00
d993fdef90 (pln_mine, pln_dropoff): Split off aerial mining into new pln_mine().
Callers changed.

(drop): Do not disclose anything about target sector before planes
actually got there, unless the target sector is owned by the player or
an ally.  This plugs a major loophole.  Consequently, the command can
no longer always refuse to attempt to drop stuff where it won't work.
Instead, the planes fly out to try.  Other plane commands (para, bomb)
behave exactly the same.  Also closes #909859.
(pln_dropoff): Cope with planes trying to drop where they can't.

(drop): Refuse to drop civilians into allied sectors, for consistency
with other means to move around stuff.
2004-08-14 17:12:20 +00:00
1127762cc1 (pln_oneway_to_carrier_ok): New.
(fly, reco): Use it to prevent flying to a carrier that doesn't have
space for the planes.  Previously, planes that did this were
teleported home, which could be abused.

(fly): Fail if pln_sel() comes up empty, just like the other commands
to fly planes.
2004-08-13 20:22:03 +00:00
e68dba6d23 Update for 4.2.16. 2004-06-16 19:03:41 +00:00
f1e87e3542 Update for 4.2.15. 2004-05-16 15:00:22 +00:00
c2debd73fc (shp_set_tech, pln_set_tech, lnd_set_tech): New, factored out of build
and upgrade code.
(build_ship, build_plane, build_land, supgr, pupgr, lupgr): Use them.
Upgrading planes no longer sets plane range to maximum.

(pupgr): Just clear the mission, don't bother to clear op area.

(doship, doplane, dounit): Editing tech now updates stats, like an
upgrade command.  Proper range checking.
(warn_deprecated): New.
(pr_ship, doship): Deprecate key 'D'.
(pr_land, dounit): Deprecate key 'A' and 'D'.
2004-05-16 14:19:38 +00:00
17494e74d1 (SCT_BLD_WORK, SHP_BLD_WORK, PLN_BLD_WORK, LND_BLD_WORK,
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.
2004-05-15 13:23:39 +00:00
7f4e59fb8d (new_work, do_feed, prod, newe): Factor out calculation of work into
new_work().

(ROLLOVER_AVAIL, opt_ROLLOVER_AVAIL, opt_ROLLOVER_AVAIL, Options,
rollover_avail_max, configkeys, vers, new_work): Replace option
ROLLOVER_AVAIL by configuration parameter rollover_avail_max.
2004-05-10 20:30:38 +00:00
b665d57de1 Should have been committed yesterday, together with sona.c. 2004-05-10 20:20:50 +00:00
d7e697b1f9 (M_TORP_SHELLS): New.
(perform_mission, torp, fire_torp, quiet_bigdef, use_ammo): Use it.
Closes #917459.
2004-05-09 20:55:30 +00:00
07f5489977 (opt_SHIP_DECAY, Options, shiprepair): Remove option SHIP_DECAY. 2004-05-09 19:06:48 +00:00
ca80c373bf (comstr, buy, check_market, display_mark, reset, sell): Change comstr
member com_type from mnemo character to item type.
(whichitem): Unused, remove.

(check_market): Use full item name instead of mnemo in telegrams.

(display_mark): Separate arguments for item type and cheapest only.
Cheapest only of specific item type is not implemented.

(rese): Guard against bad com_type.  Delete some code that had no
effect.
2004-04-10 18:48:30 +00:00
988f9a8be7 (commfil, comminit, make): Unused, remove. 2004-04-10 17:07:43 +00:00
60bbb6b0c0 (buy, mark, display_mark): Move argument evaluation from
display_mark() to callers.  buy() no longer accepts "all".  It used to
display all lots, but didn't let you buy any.  Similar nonsense
happened for "" if buy() prompted for it.

(display_mark): Fix size of cheapest_items[].

(player_coms): Document mark accepting "all".
2004-04-10 08:43:19 +00:00
b0627a97cb (i_packing): New. Use where appropriate.
(NPKG, WPKG, UPKG, BPKG, NUMPKG): Turn macros into enumeration
constants.
(NPKG, WPKG, UPKG, BPKG): Move from sect.h to item.h.
2004-04-09 06:30:21 +00:00
d12359938b (iop, iop_t): Unused, remove. 2004-04-08 19:53:17 +00:00
a8a6f5649f (item_by_name): New, factored out of whatitem(). Use it to simplify
some uses of whatitem().
2004-04-08 19:26:55 +00:00
e42f7e8210 (build_ship, orde, qorde, nav_loadship, load_it, unload_it): Store
item types instead of mnemo characters in shpstr members shp_tstart[]
and shp_tend[].
(com_num): No longer used, remove.

(orde): Simplify swap code.

(prhold): New, factored out of qorde().
2004-04-08 19:14:09 +00:00
7b42409c9a (I_NONE): New. To be used as item type error value and such. 2004-04-08 19:05:42 +00:00
48175e9beb (getstring, getstarg): Use plain char * instead of s_char *. 2004-04-08 17:56:12 +00:00
83478bd79e (OFFSET): Remove, use standard offsetof().
(SETOFF): Unused, remove.
2004-04-07 17:38:43 +00:00
5d302eaad5 (strtox, strtoy): New. Use it instead of inputxy() to avoid the
double-remainder problem: x-coordinate SHRT_MAX+1 is truncated to 0 by
cast to coord, then converted by xabs().  This is wrong unless WORLD_X
divides SHRT_MAX+1.
(sarg_xy, sarg_getrange, sarg_range): Use them.
(inputxy): No longer used, remove.

(sarg_type): Use NS_UNDEF instead of 0.

(sarg_list): Change confusing loop control.  Properly diagnose
overlong lists; used to silently ignore list tail and return MAX+1,
which made a later snxtitem_list() fail.

(atoip): No longer used, remove.  Parsing was broken anyway.

(sarg_type, sarg_xy, sarg_area, sarg_range, sarg_list, sarg_getrange):
Use plain char * instead of s_char *.
2004-04-07 17:13:47 +00:00
543b0cba4f (NS_UNDEF, NS_LIST, NS_DIST, NS_AREA, NS_ALL, NS_XY, NS_GROUP): Turn
macros into enumeration constants.
(ns_seltype): New.  Use where appropriate.
2004-04-06 21:37:52 +00:00
acdee1e3b6 (weekday, daytime, daytime_range): New; replace kw_parse(). Parsing
is somewhat stricter.
(is_wday_allowed, is_daytime_allowed, is_daytime_nar,
min_to_next_daytime): New.
(demand_update_time, scheduled_update_time, next_scheduled_time,
update_time, gamehours): Use them to replace kw_parse().
(kw_parse): No longer used, remove.
2004-04-04 15:52:26 +00:00
ded3daf70d (gamehours): All callers ignore the value assigned to hour[]. Remove
parameter.  Remove calls without effect.  Other callers changed.
2004-04-04 14:20:30 +00:00
2df3f002e1 (getminleft): Parameter hours unused since the previous rev., remove.
Change parameter mpd from int * to int, because its only use is *mpd
as r-value.  Callers changed.
2004-04-04 14:07:51 +00:00
05acaece48 (kw_read, kw_find, kwtab, kw_list): Were used to evaluate the hours
file until 4.2.7.  Since then kw_read() is unused, and kw_find()
always returns NULL.  Remove.  kw_find() callers changed.
2004-04-04 13:54:30 +00:00
4366c5ac6e Selector rewrite: values other than long, interpret identifiers
according to context, to make `lstat * ?type#spy&spy>1' work.  Closes
bug#825363, #905809, #905814 and #922968.
(nsc_type, packed_nsc_type, nsc_cat, packed_nsc_cat, nsc_flags): New.
(valstr): New.  Old code encoded values in type long, which was
somewhat hard to read and could only support signed integer values.
(nscstr): Redesign.  Use valstr.  Typed operator.
(castr): Split ca_code into ca_type, ca_flags, ca_off.  Tables
changed.
(nstr_comp, nstr_exec): Redesign and rewrite.  Callers changed.  They
used the old design incorrectly, which let players smash the stack
by supplying more than NCOND conditions.
(encode, nstr_comp_val, decode, nstr_exec_val): Rename, redesign, and
rewrite.  Callers changed.
(nstr_coerce_val): New.
(var_ca, sect_ca, ship_ca, land_ca): Checking both var_ca[] and the
object's ca complicates proper recognition of unique abbreviations.
Copy contents of var_ca[] into the ca of objects, remove var_ca[].

(surv): Reject values with category other than NSC_OFF and types that
can't be coerced to NSC_LONG.  Old code happily passed values with
category NSC_VAL to code_char().  The previous version interpreted
them correctly, but earlier versions interpreted them as NSC_OFF, then
logged `bad type in decode: 0' and evaluated them into zero.

(code_char): Used to test category NSC_VAR to decide whether to
display tens or hundreds.  NSC_VAR no longer exists.  Test type
instead.  Makes more sense anyway.
2004-04-02 19:02:12 +00:00
47c8a32ae3 (debug): New.
(main): Set it on -d.
(oops, CANT_HAPPEN): New.
2004-04-02 15:40:43 +00:00
d6a2519342 Can't use gcc function attribute `format' when s_char is not plain
char; gcc chokes on it.
2004-03-22 08:51:10 +00:00
2d2a57fc0f Update for 4.2.14. 2004-03-17 07:29:39 +00:00
91cc2ddc42 Remove unused variables and such. No functional changes. 2004-03-11 22:10:19 +00:00
245b5a21e2 (getvec, putvec): No longer used, remove. 2004-03-11 22:08:16 +00:00
b62aca0ecd (produce_sect): Unless player->simulation, 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.  Else make copies by hand, not with getvec.
(starv_sects): Replace getvec() by direct, read-only item access.
(upd_buildeff, enlist, materials_charge, materials_cost, produce,
grow_people, growfood, trunc_people, do_feed, feed_people): Change
argument type to match uncopied item arrays.
(growfood): Obey ITEM_MAX.
2004-03-11 22:00:58 +00:00
c922b571db (upd_ship, upd_land, do_plague): Work directly on item arrays instead
of copies made by getvec().  This is safe, because the new code
changes the item array precisely when the old code writes back a
changed copy.
(starv_ships, starv_units): Replace getvec() by direct, read-only item
access.
(feed_ship, feed_land): Remove parameter vec, work with sp->shp_item[]
and lp->lnd_item[] instead.
(plague_people): Change argument type to match uncopied item arrays.
2004-03-11 18:10:25 +00:00
d64fa8d529 (opt_NEWPOWER, Options, gen_power): Remove nooption NEWPOWER.
(opt_NEW_STARVE, Options, feed_ship, feed_people): Remove nooption
NEW_STARVE.

(opt_NEW_WORK, Options, move, explore): Remove nooption NEW_WORK.
2004-03-11 10:36:55 +00:00
689f435aff (opt_GRAB_THINGS, Options, get_materials): Remove option GRAB_THINGS. 2004-03-11 08:53:27 +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
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