(sctintrins): New member in_enable. Update infra.config. Use it
instead of opt_DEFENSE_INFRA.
(improve): Test for it.
(show_sect_build): Show only enabled infrastructure.
(opt_DEFENSE_INFRA): Remove. Deities can edit infra.config instead.
(sector_mcost): New, simpler sector mobility cost formula. The cost
is a linear function of sector efficiency, with cost at 0% given by
dchstr member d_mcst and cost at 100% given by d_emcst. The latter
used to be d_mcst - 1. Mountain cost is no longer a special case.
Road infrastructure now reduces cost up to 90%, linear in road
efficiency (used to be close to that, but non-linear). Same for rail
infrastructure, but 99%. Double land unit minimum cost to 0.02.
Change land unit cost penalty in newly taken land to an extra 0.2
instead of a minimum of 0.2.
(dchrstr): New member d_emcst. sector.config updated, with some
changes: cost of mountain now ranges from 2.4 to 1.2 instead of 2.174
to 1.304, wildernes 0.4 instead of 0.6 to 0.4, highway, bridge head,
bridge span and tower from 0.4 to 0.001 instead of 0.2 to 0.001.
While I'm at it, make bridge head match highway stats (dstr and value
reduced).
(show_sect_stats): Show d_emcst.
(dchr_ca): New selector emcst for d_emcst.
(attack_val, defense_val): These functions overestimate unit strength,
because they ignore three facts. Firstly, mil casualties decrease
strength linearly, while unit casualties decrease it quadratically
(unit strength scales with mil * eff). Secondly, casualties decrease
strength proportional to the combat multiplier, hence twice as much
mil are more powerful than double multiplier. Thirdly, units break
and retreat. Change the estimate from mil * mult to mil * sqrt(mult).
Improves things in simulations, hope it works out in practice as well.
Closes #682571.
(satdisp, satdisp_sect, satdisp_units): Split satdisp() into
satdisp_sect() and satdisp_units().
(satmap): Call only satdisp_sect(). No functional change.
(aircombat): Call both, and call satdisp_units() even over sea. This
lets spy planes spot surface ships at sea. Closes #906035.
(lnd_mobtype): New.
(lnd_path): Use it.
(lnd_mobcost): Use it, remove last parameter. Callers changed. This
fixes mobility use of trains when retreating, both for retreat orders
and for failed morale checks.
(retreat_land1): Fix test for impassable terrain. Before, trains
could retreat off rail.
(lnd_take_casualty): Test for impassable terrain. Before, trains
could retreat off rail.
Make land unit attack mobility cost consistent with march cost:
(att_mobcost): New.
(ask_olist, take_move_in_mob): Use it. Attacking land units can now
use roads and suffer the newly taken penalty. No difference in most
cases, because the penalty commonly cancels the road bonus.
(get_mob_support, calc_mobcost, ask_move_in_off): Use it. No
functional change now; ensures that military's attack mobility cost
will stay consistent with move cost.
(MOB_NONE): Unused, remove.
(sector_mcost): Simplify.
(att_fight): Don't charge the defending sector any mobility when it's
already negative. Used to charge proportional to its absolute value,
which makes no sense.
(att_fight): Oops when attacker's mobility is negative rather than
charging negative mobility.
Change maximum population to 100 for plains (was 49), mountains (was
99), bridge spans and bridge towers (was 999), and to 1000 for the
other habitable sector types (was 999).
(max_population): Deal gracefully with big city 10 * d_maxpop >
ITEM_MAX: let value grow linearly from d_maxpop at 0% to the minimum
of 10 * d_maxpop and ITEM_MAX at 100%.
(shp_sweep): New parameter takemob. Charge mobility only if it's
true.
(shp_nav_one_sector): Pass false. This lets minesweepers move at the
speed their stats indicate. Closes #1498801.
(navi): Pass true. This ensures sweeping without moving still costs
mobility.
(ac_planedamage): Planes may abort when damaged below 80% efficiency.
Reduce abort chance from 100-eff to 80-eff. This should make it
easier to punch through air defense, flak in particular, and increase
the risk of getting shot down.
(FLAK_GUN_MAX): New.
(ac_doflak, ac_shipflak, ac_landflak): Use it.
(ac_shipflak, ac_landflak): Tally flak for all ships / units, then
limit to FLAK_GUN_MAX guns of average tech. Used to limit to
FLAK_GUN_MAX guns *after* ship / land unit tech factor was applied by
exiting the loop early, then reduce *again* for nation tech of whoever
owns the last ship visited. Makes no sense. Exiting the loop early
is no good, because it can skip plane spotting. This change and the
one below make low-tech ship and land unit flak more powerful;
rebalancing might be needed.
(ac_doflak, ac_landflak, ac_shipflak): Round flak randomly instead of
down. This simplifies things. In particular, you no longer have to
calculate how many low-tech ships to bunch together to get any flak.
(calc_all): Match the real update sequence. Until removal of budget
priorities (rev. 1.25), calc_all() tried to match the real sequence,
but didn't quire succeed to cope with all variations. Then it matched
until the update sequence change in src/lib/update/main.c rev. 1.25.
This is required but not sufficient for closing #1310407.
Ron Koenderink [Sat, 10 Jun 2006 04:11:16 +0000 (04:11 +0000)]
(service_main) [_WIN32]: Added the missing empth_wait_for_signal() and
shutdown() for when the server is running at WIN32 service. This fix
incorporates the changes that where done to the main thread.
(lnd_pathcost): New, factored out of lnd_mobcost().
(att_reacting_units): Use it. Fixes overcharging of inefficient
units. Broken when Empire3 changed land unit mobility use not to
depend on efficiency, except for supply units.
(lnd_sweep): Use it. No functional change.
(speed_factor): New, factored out of lnd_pathcost() and shp_mobcost().
Finally merge the journal patch:
(keep_journal): New econfig key.
(player_main): Log player login and logout.
(recvclient): Log player input.
(ef_open_srv, ef_close_srv): Log startup and shutdown.
(update_main): Log update.
Support the common SIGHUP log rotation idiom:
(empth_wait_for_shutdown, empth_wait_for_signal): Rename.
[EMPTH_LWP, EMPTH_POSIX] (empth_init, empth_wait_for_signal): Wait for
SIGHUP as well.
(main) [SIGHUP]: Reopen journal when empth_wait_for_signal() returns
SIGHUP.
(shutdwn): No longer a signal handler, no need to avoid sleeping.
This lets player threads send C_EXIT properly even when the server
shuts down on a signal.
(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.