collapse to shiplist function set (add,free,print,on). Fix bug where ship
uid was a unsigned char instead of short. Switch to head pointer instead
of head record with a linked list. Add a free().
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.
I_BAR, I_FOOD, I_OIL, I_LCM, I_HCM, I_UW, I_RAD, I_MAX): Turn macros
into enumeration constants.
(i_type): New. Use where appropriate. No functional changes, except
that I_NONE is now catched properly in a few places.
freshly extended trade file makes sense. When set() removes a lot,
simply zero the slot.
(set): Initialize trd_uid.
(trade_check_ok): Use check_land_ok() & friends instead of doing it by
hand, but wrong. This fixes bying planes and land units loaded on
ships that moved after loading.
(check_trade_ok): New.
(trade_check_ok): Use it. Remove unused argument lot. Callers
changed.
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.
(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.
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.
(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.
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'.
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.
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".
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().
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 *.
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.
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.
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.
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.
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.
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.
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, ...
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.
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.
(io_select, io_flush, io_iopfromfd): Unused, remove.
(io_open): Allow more than one open for the same file descriptor.
The check is the last remaining use of io_list[], and it's
unimportant.
(io_list, niop, io_init): io_list[] no longer serves any purpose,
remove. Sparse allocation of file descriptors (deplorable misfeature
of Winsock, at least some versions) is no longer a problem.
(getfdtablesize): Unused, remove. Was broken for Windows anyway.