Commit graph

3086 commits

Author SHA1 Message Date
67a9a8d96a Fix mapper to work with current code
4.2.0 broke over.awk.
2008-07-04 17:31:33 -04:00
801780043f Fix flying commands not to let planes do double duty as escorts
Commit 7ca4f412 (v4.3.12) marked planes flying a sortie with
PLN_LAUNCHED, and made pln_arm() reject planes with that flag set.
This was designed to reject escorts that were already flying as
bombers.  It didn't work, because the test for PLN_LAUNCHED used a
stale copy of the plane created by pln_sel().  Fix by getting a fresh
copy.

The bug always existed, but the botched fix in commit 7ca4f412 made it
worse.  Before, ac_encounter() dropped escorts that were also bombers,
so the bug merely wasted plane fuel.  After, such planes were
effectively duplicated, and damage to one of them, usually the bomber,
was wiped out.  Abusable.
2008-06-28 11:24:43 -04:00
b0644e822c Fix seqno mismatch and use-after-free in shp_sweep()
The code wrote the swept sector after calling shp_check_one_mines().
This failed to use up the mine that hit the minesweeper, and triggered
a seqno mismatch oops.

The code wrote the minesweeper after calling shp_check_one_mines().
This used freed memory when the minesweeper got sunk there.

Broken in 4.0.17.  Fix by moving both calls before
shp_check_one_mines().
2008-06-28 09:24:32 -04:00
6d38a04930 Don't let non-light units board ships that can't carry them
ask_olist() let non-light land units board ships that can carry only
light units.  If the board succeeds, the non-light unit move onto the
ship and then are stuck there.
2008-06-17 20:17:15 +02:00
85bb88c26c Limit BTU production to 1000 civilians instead of 999
This makes the limit again equal maximum population of a capital
sector, which changed in commit 6bbd7ffd, v4.3.6.
2008-06-15 08:49:26 +02:00
4a67080656 Update info BTU on Empire clock and work percentage
Work percentage should have been documented in commit 233fce87,
v4.3.0.

Empire clock should have been documented in commit d3e0597f, v4.3.10.
2008-06-15 08:49:26 +02:00
860369ec7e Update info Citizens on census showing old owner
This was forgotten in commit 6b434ee3, v4.3.0.
2008-06-15 08:49:25 +02:00
3735f04b73 Make spy command require sector military
Spies shot were only deduced from sector military; land units were
immune to losses; in fact they needn't have any military to spy.

Fix by requiring and using only sector military.  Closes #758483.
2008-06-15 08:49:25 +02:00
ab2b930b5b Let spy report on unoccupied sectors
Make spy() not skip sectors without civilians, military and land
units.  There could be other interesting things to report there:
efficiency, gold bars, planes...
2008-06-15 08:49:21 +02:00
a233ecfea9 Remove columns lnd, pln from spy report to fix spy unit leak
The values in these columns were computed by count_sect_units() and
count_sect_planes(), which included land units and planes in the count
that aren't shown by prunits() and prplanes(), namely own and embarked
units.  Confusing.  Moreover, count_sect_planes() and prunits() rolled
dice separately for spy units.  This could leak the presence of spies
even when prunits() didn't show them.

All fixable, but not worth the trouble; just remove the counts.
2008-06-14 18:55:29 +02:00
c658d1e08d Simplify prunits() and prplanes()
Drop redundant conditional.  No functional change.
2008-06-14 18:28:44 +02:00
dbd886ae2e New player_relstr(), factored out out of prunits() and prplanes()
No functional change.
2008-06-14 18:20:48 +02:00
4025c242ff Have the complete spy report code in one place
Move prunits() and prplanes() from spyline()'s caller into spyline().
Rename spyline() to spy_report().  No functional change.
2008-06-14 18:07:01 +02:00
89e33f6218 Simplify control flow in spy()
Rearrange so that we make contact (each way) and print the spy report
in just one place.  No functional change.
2008-06-14 17:51:26 +02:00
ee6927122c Fix spy to make contact when spy succeeds due to recon unit
If you have a recon unit, you get a spy report whether the spy is
caught or not.  But you made contact only when he wasn't caught.  Fix
that.
2008-06-14 17:40:57 +02:00
3e251b474f Fix ship interdiction targeting ships not at sea
perform_mission() needs to know whether it is targeting ships or
something else, because the rules differ: submarines interdict only
ships, land units get their damage reduced when interdicting ships,
and different news are generated.

The old code assumed it was targeting ships when the target sector was
sea.  Wrong when interdicting ships in harbors, bridges and such.
This has always been broken.  Except when checking a submarine's
target: there it tested argument s, which is gross, but at least it
works.  That code was added in v4.0.8.

Replace the broken test by the gross hack everywhere.  This fixes news
and damage from land units when ships get interdicted in non-sea
sectors.
2008-06-08 11:35:04 +02:00
e1d7f9bf8e Fix land unit return fire damage to ships inconsistency
Land units firing at ships have their damage reduced based on their
accuracy.  This wasn't done when returning fire in quiet_bigdef().
Fix that.
2008-06-08 11:06:40 +02:00
c75e567b9e Remove commented out useless sub interdiction check
Submarines can only interdict ships.  The check for that was replaced
in v4.0.9.  The old check was commented out.  It should have been
removed instead.
2008-06-06 21:31:55 +02:00
22175c1722 Rewrite show_mission()'s conditional for clarity
No functional change, except oops on bad mission.
2008-06-06 21:31:55 +02:00
e0b164a283 Fix article in value of mission_name() for MI_OSUPPORT argument
While there, oops on bad argument.
2008-06-06 21:31:55 +02:00
984ffce95e Improve info mission
Remove confusing columns Op-sect and Radius from table of available
missions.  Add their code letters.

Fix efficiency required for artillery units to fire.
2008-06-06 21:31:55 +02:00
53d9843432 Remove inconsistent shelling damage reduction for range
Firing damage reduction for range is a feature that was always there
and never really documented.  Different ways to fire reduced damage
differently for range, or not at all.  Fix that by dropping the
reduction everywhere.

The reduction happened randomly, with probability p = (d/m)^2, where d
is the distance to the target, and m is the maximum firing range.  The
fire command printed "Wind deflects shells" when it happened.

The old fire command (before MULTIFIRE) either halved damage (50%
chance), or reduced it by a factor of 1-p.

MULTIFIRE's fire command halved damage.  v4.0.2 reduced that loss to
10-20%.

Interdiction halved damage, but only when firing from ships.

Other ways to fire (support, return fire, interdiction from forts and
land units) did not reduce damage for range.
2008-06-06 21:31:55 +02:00
fa7e3aa9be Comment why collateral damage for missing missile is disabled
It was added in 4.0.17, and disabled in 4.0.18.  info Empire4 proudly
notes the former, but not the latter.
2008-06-06 21:31:55 +02:00
d2250f43e9 Remove commented out flushwu() from update_main()
flushwu() is gone since Empire2.
2008-06-06 21:31:55 +02:00
e16ef01111 Remove disabled MOB_ACCESS hack to immobilize newly built ships
The hack made navigate require 21% efficiency or etu_per_update
mobility.  It was disabled since 4.2.7, when newly built ships got
negative mobility.
2008-06-06 21:28:27 +02:00
441c8a2b7b Remove commented out trade sanity check
It's been commented out for ages, and it's a place where it can't
really protect sanity anyway.
2008-06-06 21:25:28 +02:00
1c9bd0cdd2 Remove some useless commented out code
Wasn't used in any released version.
2008-06-06 21:25:28 +02:00
2d953804ba Remove commented out code for giving away planes on landing
Commented out in v4.0.0, and not likely to come back.
2008-06-06 21:25:24 +02:00
1f7d8879ca Document delivery of civilians and military
People can be delivered since v4.0.0 (the check that disabled that was
commented out), and cutoff shows these deliveries since v4.0.2.  The
change was documented in info Empire4, but info pages weren't updated.
Do that, and remove the commented out code.
2008-06-02 07:02:26 +02:00
6e998a46e2 Replace commented out code in coll() by a suitable comment 2008-05-31 18:25:35 +02:00
64f44e9904 Fix ground combat to report defending land units
Commit 092a52f2 (v4.3.4) removed the code to estimate defense, because
the use of the estimate had been disabled since v4.0.0.  This
accidentally removed the reporting of defending units, because
get_dlist() reported them when called for an estimate, and not when
called for real.

Fix by removing the unused estimate capability from get_dlist().  It
now reports defending units always.
2008-05-31 17:30:20 +02:00
aacd0fb754 Avoid seqno mismatch oops in recursive land unit supply
Before s_commod() attempts to recursively supply a supply unit it
wants to use as supply source, it zaps the unit's load.  When
actually_doit is false, it later restores the old load by overwriting
the change with a saved copy of the unit.  That triggers a seqno
mismatch oops.

Avoid that by copying the new sequence number to the saved copy.
2008-05-28 22:30:36 +02:00
7f17369491 Don't run supply machinery to get zero units
Change supply_commod() and try_supply_commod() not to call s_commod()
when zero units are wanted.

This isn't just for efficiency, it's also for limiting exposure to
supply bugs a bit.
2008-05-28 07:35:22 +02:00
84c4ddd994 Bump version to 4.3.16 2008-05-27 22:24:40 +02:00
c7ac4ced21 Improve info on anti, bomb, lookout, starvation and sweep
Add command anti to subject Occupation, bomb to Combat, lookout to
Detection, and starvation to Updates.

Cross-reference recon from sweep.
2008-05-18 11:41:53 +02:00
ebf50dce54 Update change log for 4.3.15 2008-05-18 11:41:51 +02:00
8d85979a82 Update known contributors comments 2008-05-18 10:59:04 +02:00
5942bbb6fb Remove edit country key 'U' deprecated in 4.3.10 2008-05-18 08:51:22 +02:00
536ef0b0a2 Add sequence numbers to game state
This oopses on output dependency violations, e.g. two threads doing a
read-modify-write without synchronization, or the one thread nesting
several read-modify-writes.  Such bugs are difficult to spot, and tend
to be abusable.  I figure we have quite a few of them.

New struct emptypedstr member seqno.  Make sure all members of unit
empobj_storage share it.  Initialize it in files: main() and
file_sct_init().  Set it in ef_blank() and new ef_set_uid() by calling
new get_seqno().  Use ef_set_uid() when copying objects: swaps(),
doland(), doship(), doplane(), dounit(), delete_old_news().  Step it
in ef_write() by calling new new_seqno().

Factor do_read() out of fillcache() to make it available for
get_seqno().
2008-05-17 22:50:30 +02:00
087c0aae36 Simplify write_sects() sector loop nest
No functional change.
2008-05-17 22:24:27 +02:00
ba1a320ce2 Make fairland obey file locks
Do that by making it use file.h instead of stdio.

This doesn't overwrite the sector file completely anymore, it just
sets sct_type, sct_newtype, sct_elev and sct_coastal.  You really need
to run files first now.
2008-05-17 20:10:45 +02:00
d2a7bb6b6f Make fairland finish argument parsing before reading econfig 2008-05-17 19:52:38 +02:00
967122ae0b Fix files utility not to set timestamps
Commit f33b96b1 (v4.3.12) made files again set timestamps.  That was
intentionally suppressed in commit 990eb46b (v4.3.10), because it
facilitates attacks against the PRNG.  Commit 8f98e53a (v4.3.0) had
added it as a feature.

Fix by making files's main() pass new flag EFF_NOTIME to ef_open().
Implement the flag in do_write().
2008-05-17 19:35:22 +02:00
2a125c5463 Simplify empfile timestamping
do_write() sets the timestamp from a parameter.  All callers pass
time(), and don't use that value themselves.  Call time() in do_write
and remove the parameter.
2008-05-17 19:01:59 +02:00
d39a1f11cc Update timestamps in privately mapped tables, too
Commit f33b96b1 made ef_flush(), ef_write() and ef_extend() update
timestamps automatically.  Change ef_write() and ef_extend() to do
that even when table is privately mapped, by making do_write() cope
with privately mapped tables.  Current users don't care, but it's a
saner interface.
2008-05-17 18:56:38 +02:00
c3d5771054 Fix ef_write() for privately mapped non-file-backed table
Commit f8dcb7b0 promised that combination to work, but got it wrong.
It hasn't been used, so no real harm done.
2008-05-17 18:48:48 +02:00
5750107b65 Make server check game state file sizes on startup
Certain tables have a fixed size depending on configuration: EF_SECTOR
has WORLD_SZ() elements, EF_NATION, EF_MAP and EF_BMAP have MAXNOC
elements, and EF_REALM has MAXNOC * MAXNOR elements.  Bad things
happen if the files backing them are shorter.

Pass expected size to ef_open(), and make it fail when the actual size
differs.
2008-05-17 17:00:57 +02:00
b37ebbbde3 Fix starvation not to starve one more than it should
Commit 109dad1b (v4.3.5) promised to round victim fractions down, but
got it wrong for odd population when exactly half of it rounded down
could be fed.  This could starve the last man on a boat or land unit.
Fix famine_victims().
2008-05-17 08:50:56 +02:00
9a7628f05b Add command test to info subject Transportation 2008-05-15 19:41:32 +02:00
0cc474bd6d Fix crash bug in satellite maps
The value of diffx() had the wrong sign when the arguments differed by
WORLD_X / 2.  Same for diffy() and WORLD_Y / 2.  satmap() used them to
find the vector from map center to ship or land unit to put on the
map, and got incorrect values for ships and land units directly
opposite to the center in x or y.  The bug made satmap() read a
pointer out bounds of its malloced radbuf[], and then write through
that with unpredictable consequences.

Broken in 4.2.12.  The original bug was in Empire 1.1: it
miscalculated where to put ships on the map (no crash).  An incomplete
fix for radmap() and satmap() appeared in Chainsaw 2 (still no crash).
radmap() got fixed correctly in Chainsaw 3, but satmap() was
forgotten.  That one got "fixed" in 4.2.7, and again in 4.2.12, but
both "fixes" were flawed and could crash.

Fix by backing out the flawed fixes and adopting the fix from radmap()
instead.
2008-05-13 08:36:06 +02:00