(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.
(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.