Ron Koenderink [Sat, 24 Jun 2006 17:29:40 +0000 (17:29 +0000)]
(map, unit_map, draw_map, player_coms[]):
Modify nmap command to allow mapping around a nuke.
Add new command nbmap for bmapping around a nuke.
Add a new mapping flag 'n' for adding nukes to a map.
Correct syntax description for pmap, pbmap, lmap and lbmap
in player_coms[].
Support definition of additional sector types in sector.config,
missing bits:
(budg, calc_all, update_main): Use SCT_TYPE_MAX instead of SCT_MAXDEF
to size tables.
(map_char): Update sanity check; use CANT_HAPPEN().
(show_sect_build, show_sect_stats, show_sect_capab): Use the sentinel
instead of SCT_MAXDEF.
Support definition of additional sector types in sector.config:
(SCT_TYPE_MAX): New.
(dchr): Use it instead of SCT_MAXDEF to size the table.
(SCT_EFFIC): Likewise. Move from sect.h to budg.h.
Rewrite rev. 1.69 to suppress immutable field match check when
extending any table, empty or not:
(cur_obj_is_blank): New.
(fldval_must_match): Use it instead of initialized[].
(getobj): Set it along with cur_obj.
(setstr): Move fldval_must_match() down, so that cur_obj_is_blank is
defined.
(initialized): Remove.
(SCT_MAXDEF): Make it equal the maximum sector type, not the maximum
plus one. Users changed. This indirectly fixes off-by-one loop
bounds in budg(), show_sect_build(), show_sect_stats() and
show_sect_capab(). The show bugs were harmless: the loops ran into
the sentinel, which they ignore. The budg bug was serious: the loop
ran into the entries for SCT_EFFIC. This lead to a bogus line in the
budget, printing of a null pointer, and doubled sector build cost.
Budget priorities masked this bug until rev. 1.25.
_exit() fails to terminate all threads on at least some versions of
LinuxThreads, use exit() where possible:
(shutdwn): No longer a signal handler, can safely call exit().
(main, loc_NTInit): No obvious reason for not using exit().
(bestownedpath): Back out rev. 1.22's path termination with 'h' for
now. Consistency with BestLandPath() is nice, but it makes navigate
behave differently, and that wasn't intended.
(navi, march): Simplify convoluted logic. Old code tried path finding
whenever the next direction in the path string is bad. It then passed
the whole path string to shp_path(), which makes no sense unless we're
at the beginning of it, but luckily failed in that case. Change to
try path finding right after prompting for new input.
(ask_olist): Let land units attack as long as they have positive
mobility, except for high-mobility terrain (mountains), where the
rules remain as they were: land units need to have all the mobility
charged for the attack, not counting combat and moving in to occupy.
Rationale: Making sure your land units reach attack positions with
enough mobility left is a pain in the neck. Requiring only positive
mobility is friendlier, but allows rushing of mountains.
(dchrstr): Replace int members d_mcst and d_emcst (mobility cost * 5)
by float d_mob0 and d_mob1 (straight costs). Impassable terrain now
encoded as negative d_mob0 instead of zero d_mcst. Users changed.
sect.config updated.
(dchr_ca): Replace selectors mcst and emcst by mob0 and mob1.
(show_sect_stats): Show real mobility costs.
(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.