Commit graph

294 commits

Author SHA1 Message Date
55ff194f7f (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().
2006-06-08 20:43:13 +00:00
5e66e5bdee (ef_verify): Check pchr[].p_level matches pchr[].p_type. 2006-06-08 20:22:58 +00:00
1ca0b5cb2b 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.
2006-06-08 20:11:26 +00:00
f284b0beab (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.
2006-06-05 17:44:25 +00:00
5ad86bc7ce 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.
2006-06-04 17:41:12 +00:00
6ab05ae8a1 Path finding for trains never worked; it ignored the need for rail:
(sector_mcost, bp_neighbors): Fix for MOB_RAIL and sct_rail == 0.
Closes #781528.
2006-06-04 17:27:17 +00:00
20c02295a6 (BestDistPath): All callers pass MOB_ROAD to parameter mob_type,
remove it.  Callers changed.
2006-06-04 16:49:24 +00:00
3aea20e1de (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.
2006-06-04 09:34:39 +00:00
a835a4b4d3 Fix the previous revision. 2006-06-04 09:01:51 +00:00
8fa0dcbe17 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.
2006-06-04 08:37:37 +00:00
b7922c9bd8 Fix rev. 1.11. 2006-06-04 08:33:03 +00:00
0b1f561e97 Comments, whitespace. 2006-06-02 05:49:29 +00:00
568b9d6639 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.

(xunsymbol1, xunsymbol): Rename.
2006-06-01 19:15:30 +00:00
a1546476bf (xunsymbol1): Fix diagnostics. 2006-06-01 19:06:56 +00:00
6fadcf6e8e (buil): Use ef_elt_byname() instead of typematch().
(typematch): Unused, remove.
2006-06-01 18:57:03 +00:00
c432e3107d 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.
2006-06-01 18:48:42 +00:00
15635c25ae (getid): Restrict identifier syntax: outlaw conditional operators <>=#
and meta-character ".
2006-06-01 18:09:40 +00:00
2faa68c6e3 (xufld, setstr): Improve diagnostics. 2006-06-01 18:06:03 +00:00
0c1bd8e98b (add, plane_bomb, pinflak_planedamage, doship, dounit, doplane, laun)
(launch_sat, scra, scut, scuttle_ship, scuttle_land, knockdown)
(ac_planedamage, detonate, attack_val, defense_val, air_damage)
(msl_intercept, msl_launch_mindam, pln_prewrite, shp_prewrite):
Simplify unit destruction: just zero efficiency, leave makelost()
etc. to the prewrite callback.
2006-05-27 19:25:12 +00:00
cc1df4e88a (verify_fail): New parameter idx. Use it to print array index when
applicable.  Callers changed.
2006-05-24 18:32:13 +00:00
4c4fdca42b Line breaks and other formatting issues. No functional changes. 2006-05-21 13:05:24 +00:00
cd73a47dfa Remove superflous casts and parenthesis. 2006-05-21 12:24:30 +00:00
9d8674f1a2 (sectdamage): Simplify. 2006-05-21 08:56:17 +00:00
36c73ca99a (landdamage): Code to guard against zero land_mob_max was broken.
Remove it, as fixing it isn't worth it.  Remove superflous casts.
2006-05-21 07:59:19 +00:00
ed1b47c05a (mapindex, mapbuf): Change element type to unsigned short, because 16
bits suffice.

(bestownedpath): Use diroff[] and dirch[].  No functional change.
(dirchar, dx, dy): Remove.
2006-05-20 14:18:29 +00:00
dd4a175532 (tfactfire): Unused since src/lib/subs/landgun.c rev. 1.12, remove. 2006-05-20 13:02:40 +00:00
d906fd6b99 DEFENSE_INFRA was implemented in an odd way: sct_defense was used
regardless of the option, but forced to sct_effic when disabled.  This
screws up sct_defense when you disable DEFENSE_INFRA.  Implement it
more like FALLOUT: use sct_defense if enabled, else sct_effic.  The
change should be invisible except in xdump, which shows the real
sct_defense.  Closes #804641.
(SCT_DEFENSE): New.
(dump, sinfra, sector_strength): Use it.
(eff_bomb, build_bridge, build_tower, new, buildeff, sect_damage)
(put_combat, checksect, produce_sect): Don't force sct_defense to
sct_effic when DEFENSE_INFRA is disabled.
2006-05-20 11:53:20 +00:00
75604d817c (nsc_type): New member NSC_HIDDEN.
(meta_type): Add its entry.
(setnum, nstr_promote, nstr_exec_val): Deal with it.  nstr_exec_val()
implements opt_HIDDEN by mapping unknown values to -1.
(natstr, nat_ca): Use it for member nat_relate.  This also halves its
size.  Fixes very minor leak: before, player could see relations to
all countries, regardless of contact.
(nation_relations): Add entry for -1.
2006-05-18 19:02:04 +00:00
6844c94b4a (natstr, add, getrejects, putreject): Simplify rejections storage.
The space savings of nibble storage are not worth the hassle,
especially for xdump.

(nat_ca): New selector rejects.
2006-05-18 18:43:38 +00:00
5b4b3a13cb Break lines more tastefully. 2006-05-14 07:52:20 +00:00
75e35f932f (knockdown): Destroy nukes on collapsing bridges. Before, you could
rescue them by building a new bridge or arming them on naval planes.
2006-05-13 07:24:10 +00:00
29c61d574c (bp_lbcost): Don't convert the cost from double to float and back.
Simplify.
2006-05-07 09:19:21 +00:00
97be5018e2 (hap_req): New.
(nati, populace): Use it.

(populace, nati): Change hap, pct from float to double, because they
are used as double.

(nati): Print happiness needed with just two decimals, like the other
levels.
2006-05-06 11:07:35 +00:00
2e40a4bb90 Change nuke storage and commands to match other units:
(nukstr): Hold one nuke instead of a stockpile: replace members nuk_n,
nuk_types by nuk_type, nuk_plane.  Add nuk_land for completeness, like
nuk_ship it's not yet used.
(nuke_ca): Update accordingly: replace selectors number and types by
type and plane.
(build_nuke): Update accordingly.
(ndump, nuke): Update accordingly.  Output is no longer sorted by
location, and nukes in same location no longer share id.  nuke's extra
columns for nuclear plants are repeated for every nuke.
(trade_desc): Update accordingly.
(cede, grab_sect, check_nuke_ok, detonate, trade_nameof): Talk about
nukes instead of nuclear stockpiles.
(arm, disarm): Rewrite, split off new disarm().  Don't remove nuke
from the nuke file on arm.  Allow usual plane syntax, not just plane
number.  Change second argument from nuke type to nuke number.  When
plane is already armed, ignore nuke argument and rearm (broken in
4.2.6).
(tran_nuke): Update for changed struct nukstr, make as similar as
possible to tran_plane.  Change syntax to match transport plane.
(player_coms): Update arm, disarm and transport accordingly.
(prnuke, nuk_on_plane): New.
(nuk_add, nuk_delete): Stockpile management, remove.
2006-05-06 07:20:21 +00:00
a292d6f98a Fix insufficiently parenthesized macro expansions. 2006-04-30 16:08:45 +00:00
e28851b8e9 Normalize unsigned int to just unsigned. 2006-04-30 12:26:07 +00:00
0c8c169f88 (s_char): Remove. Use signed char for small integers, plain char for
characters.
2006-04-29 16:25:17 +00:00
0a3a73cf3d Recent s_char purge changed element types to s_char *, but missed
patterns malloc(N * sizeof(s_char *)), fix.
2006-04-29 16:14:48 +00:00
a988b907fc s_char purge directed by compiler warnings. 2006-04-29 06:41:45 +00:00
25fd374d53 Update known contributors comment. 2006-04-26 18:14:54 +00:00
6fee3f4535 (CANT_REACH): New. Use it instead of CANT_HAPPEN() where possible.
(oops): Cope with NULL argument passed by CANT_REACH().
2006-04-17 17:36:07 +00:00
f576dd6694 (verify_row): uid check was too strict. 2006-04-05 18:47:02 +00:00
11e09910aa Fix the previous revision. 2006-04-05 18:15:07 +00:00
6fdac645ba (bestownedpath, owned_and_navigable): Terrain parameter isn't really
used, remove it.  Use null bigmap argument to ignore terrain (flying),
non-null for navigation.  Callers changed.
2006-04-05 09:50:45 +00:00
abb9ae2338 (bestownedpath): Return NULL on long path instead of "?". Terminate
returned path with 'h'.  This makes BestShipPath() and BestAirPath()
more similar to BestLandPath().  Simplify callers.
2006-04-05 09:30:38 +00:00
9c27a771b3 (BestAirPath): Some callers assumed non-null return value must be the
first argument.  Fix them.  Simplify bestownedpath().
2006-04-05 09:13:03 +00:00
462bc9e7b2 (owned_and_navigable): Rework rev. 1.18: do check the real sector, but
only if it's owned or allied.  Check it before the bmap, and do it
just like shp_check_nav() does (should use common code).
2006-04-05 08:51:50 +00:00
8d68043668 (bestownedpath): Fix test of end sector for terrain string starting
with 'R'.  Broken in 4.2.2.  No such terrain strings occur.
2006-03-29 16:12:00 +00:00
7f37ecb680 (owned_and_navigable): Do not check the real sector, only the bmap.
Checking the real sector leaks information, which can be abused to
test whether an arbitrary sector is unfriendly or an inefficient
harbor or bridge, at the cost of some ship mobility (I think).
Initially broken ca. 1993, went through several changes, but the leak
survived them all.
2006-03-29 16:06:30 +00:00
8383f33229 (as_data): Use void * for userdata member and userdata parameter of
callbacks.  Users changed.
2006-03-28 21:00:00 +00:00