(empth_init_signals): Don't catch SIGINT and SIGTERM.
(empth_wait_for_shutdown): New.
(main): Use it to wait for shutdown signal, then shut down. Closes
#770492.
(empth_exit): Remove the weird special case for main thread.
Implement empth_wait_for_shutdown() for EMPTH_LWP:
[EMPTH_LWP] (lwpInitSigWait, lwpSigWait, lwpSigWakeup): New.
Declaration of lwpSigWait was accidentally committed in the previous
revision of lwp.h.
[EMPTH_LWP] (lwpInitSystem): New parameter waitset, pass it on to
lwpInitSigWait().
[EMPTH_LWP] (lwpReschedule): Call lwpSigWakeup().
[EMPTH_LWP] (empth_init): Declare signals needed by
empth_wait_for_shutdown().
(empth_wait_for_shutdown): Implement on top of lwpSigWait().
Implement empth_wait_for_shutdown() for EMPTH_POSIX:
[EMPTH_POSIX] (empth_init): Block signals, so that
empth_wait_for_shutdown() can use sigwait() safely.
(empth_wait_for_shutdown): Implement on top of sigwait().
Implement empth_wait_for_shutdown() for EMPTH_W32:
(empth_wait_for_shutdown): Implement on top of loc_BlockMainThread().
(lwpReschedule): Remove code permitting SIGALRM to be catched safely,
because there's no handler for it.
(LCOUNT, oldmask): Remove.
(lwpEntryPoint): Don't initialize oldmask. Should have been done in
lwpInitSystem() anyway.
(P_SHELL, P_GUN, P_PETROL, P_IRON, P_DUST, P_BAR, P_FOOD, P_OIL)
(P_LCM, P_HCM, P_TLEV, P_RLEV, P_ELEV, P_HLEV, P_URAN): Use -1 instead
of 0 for `no product', shift down product indexes and update
product.config and sector.config accordingly.
(budg, prod, show_sect_capab, produce, produce_sect): Adapt test for
no product.
(ef_elt_byname): Remove the hack to hide pchr[0].
(prod_eff): Oops on no product.
Move signal stuff into src/lib/empthread/, no functional change:
(empth_init_signals): New, factored out of start_server(). Call from
empth_init().
(panic): Move to posix.c, internal linkage.
(empth_obj): Add new posix.o
(empth_start, empth_alarm) [EMPTH_POSIX]: Clean up pointless messing
with signal handlers.
(empth_init, empth_wakeup) [EMPTH_POSIX]: Clean up a bit.
4.0.2 made land unit mobility costs differ significantly from normal
move costs, but failed to make A* use these costs. This broke land
unit path finding. Fix:
(MOB_ROAD, MOB_MOVE, MOB_MARCH): Split MOB_ROAD into MOB_MOVE and
MOB_MARCH. Users changed.
(lnd_mobcost, sector_mcost): Move minimum mobcost logic to
sector_mcost(), where it is visible to A*. Also fixes unit reaction
path cost.
(lnd_path): Fix confusing message: don't claim there's no path when
all we really know is that there's no railway.
(ichr, pchr, dchr, intrchr): Move initializer to new builtin config
files item.config, product.config, sect.config, infra.config.
(empfile): Declare the new config files. Reorder table entries so
that read_builtin_tables() reads the config files in the right order.
(bigcity_dchr, opt_BIG_CITY, init_dchr): Remove. Deities can edit
sect.config instead.
Don't check values for immutable fields match when initializing an
empty table:
(initialized): New.
(xundump): Set it.
(fldval_must_match): Ignore NSC_CONST when it's clear.
(pchrstr, pchr_ca, pchr, sctstr, dchr_ca, dchr): Replace pchrstr
member p_effic by sctstr member d_peffic. Tables updated.
(show_sect_capab): Adapted.
(prod_eff): Adapted; requires changing first parameter to sector type.
Callers changed.
(P_MDUST): Remove, because pchr[P_MDUST] now identical to
pchr[P_DUST].
Allow symbolic references not just to symbol tables:
(xunsymbol1): Use ef_elt_byname().
(setsym): Accept any table reference, not just to symbol table.
(symval): New.
(setsym, add2symset): Use it.
(mtsymset): Last remaining user of getsymtab(); inline and simplify.
(getsymtab): Remove.
Symbolic names for table entries in conditionals, closes #928376:
(ef_elt_byname): New.
(nstr_match_val): Use it to generalize to arbitrary table with
uniquely named elements. Use ca_type to find table, remove parameter
type. Callers changed.
(nstr_mkselval): Adapt sanity check accordingly.
(NSC_TYPEID): No longer needed, remove, users changed to use
appropriate integer type instead. This fixes signedness of sector
selectors des and newdes.
(meta_type): Remove entry for NSC_TYPEID.
(nstr_coerce_val): Can't detect typeid - integer mismatch anymore.
Was nice to have; perhaps revive it later.
(prexpense, budg): Printing brackets around expenses that won't
actually be paid in full didn't take the update sequence into account,
and wasn't implemented for sector building, military payroll and
capital maintenance. Remove the feature, as fixing is hardly worth
the trouble. This renders prexpense() trivial; inline and remove.
Change set with nuke.h rev. 1.21 was incomplete (harmless because the
missing bits were consistent):
(build_nuke): Assign 0 instead of space.
(nuke): Update printing of group.
(food_needed): New.
(feed_ship, feed_land): Use it.
(do_feed): Use it. Estimate of food needed was one too large for
integer food needs. Used to round fractional food need to nearest
instead of up for supply_commod(), which could cause starvation.
(s_commod, get_minimum): Use it. Estimate of food needed was one too
large for integer food needs. s_commod() used to reserve one more
than get_minimum() would have returned; it's now the same.
(famine_victims): New.
(feed_people): Use it. This rounds victim fractions down instead of
up. It also dosn't flush needs <=1 to zero. Doesn't change
starvation, as do_feed() always produces at least one emergency food.
Does change food consumption.
(starve_some): New.
(feed_people): Use it.
(feed_ship): Use feed_people(). This rounds victim fractions down
instead of up.
(feed_land): Use feed_people(). Rounding of victim fractions
unchanged. Feeds all people not just mil; closes #913997.
(starv_people): New.
(starv_sects, starv_ships, starv_units): Use it. Fixes starve land to
talk about people instead of mil.
(starv_sects): Use famine_victims() rather than feed_people(). Take
emergency food into account, because feed_people() doesn't. Don't aim
for one extra food, for consistency with starv_ships() and
starv_units().
(feed_people): Remove useless parameter. Simplify.
(starv_ships, starv_ships): Use famine_victims() rather than
feed_ship() and feed_land().
(feed_ship, feed_land): Remove useless parameters. Internal linkage.
Simplify.
(feed_land): Call resupply_commod() only if there's a food shortage.
Don't scrounge lnd_ship for food, resupply_commod() already does.
(prmptrd, uprmptrd): Oops on null prompt. getstarg() is sometimes
called with a null prompt when it is believed not to use it, and that
belief is sometimes wrong. Other users could have similar bugs. Some
systems (GNU, Windows) deal gracefully with printing null strings,
others crash.
(nat_ca, cou_ca, ef_init_srv, xdvisible): Plug major information leak:
nat_ca[] was designed for visibility to the owner only, while cou_ca[]
was designed for the public. xdvisible() implemented that for xdump.
But selectors don't care for that! Since nat_ca[] applies to
EF_NATION, it must be for public visibility. Broken in 4.2.21. Fix
by exchanging contents of nat_ca[] and and cou_ca[]. This breaks
clients relying on xdump.
(command): Don't fold conditionals to lower case. This was added
early in Chainsaw 3, most probably to make them case insensitive.
This is of debatable utility, and inconsistent with the case
sensitivity of commands and arguments. It also interferes with string
conditionals: fleet#A is folded to fleet#a, which means something
else!
Minimize redundancy between (mortal's) xdump nation and xdump country:
(ef_init_srv): Make NSC_DEITY in cou_ca mirror ~NSC_EXTRA in nat_ca,
except for cnum, which may not have either flag in either table.
(nat_ca): Make selectors stat, cname, passwd, xorg, yorg, relations,
contacts and rejects NSC_EXTRA.
(NSC_GENITEM, ship_ca, plane_ca, land_ca): Change selectors group,
fleet, wing and army from numbers to user-friendly strings. This
makes ?fleet#'a' work. Closes #928405.
(pln_mobcost): Don't limit cost to current mobility + 32. No
airworthy plane can possibly use more than 55 mobility in one sortie,
and mobility going that much negative is fine.
(plane_sona): Compute range multiplier in double rather than int, to
match the formula used for sweep chance in plane_sweep(). Rounding
intermediate values is ugly anyway.
(deliver): Change mcost from float to double, because it's used as
double but never as float. This avoids converting the value of
sector_mcost() to float and back.
(lnd_getmil, total_mil): Trivial, inline into callers and remove. The
abstraction from actual land unit mil encoding provided by them was
too leaky to be relied upon anyway.
(take_casualties): Remove superflous casts and parenthesis. Cast to
double rather than float where result usual arithmetic conversions
obviously convert the cast's result to double. No functional changes;
code is still ugly and incomprehensible.