Commit graph

3069 commits

Author SHA1 Message Date
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
7680acc39f Fix XNORM() and YNORM()
Broken in commit 5f764285 (v4.3.12) for negative multiples of WORLD_X
and WORLD_Y, respectively.

This could theoretically lead to buffer overruns and other
unpleasantness.  None have been reproduced, though.
2008-05-12 18:45:11 +02:00
238b9afc3b Catch selectors that make xundump oops early
Oops in new verify_ca(), which runs during initialization.
2008-05-12 12:39:38 +02:00
a38625d9a4 Make xundump oops on virtual selectors
Commit da8a1dae (v4.3.12) introduced virtual selectors, but neglected
to update xundump.  Xundump can't work for them, because they don't
provide a setter method.

This didn't actually break anything, because all virtual selectors
have flag NSC_EXTRA set, or are in table EF_VERSION, which xundump
refuses to touch.

Make deffld() oops on virtual selector, just to be safe.
2008-05-12 11:26:41 +02:00
3b4de2feb1 Remove option FUEL
The abstract idea of tying ships and land units to a logistical tether
is sound, the concrete implementation as option FUEL is flawed.  It
adds too much busy-work to the game to be enjoyable.  It hasn't been
enabled in a public game for years.  The code implementing it is ugly,
repetitive, and a burden to maintain.

Remove selector fuel from ship_ca[] and land_ca[], and selectors
fuelc, fuelu from mchr_ca[] and lchr_ca[].  Remove fields fuelc, fuelu
from ship.config and land.config.

Remove command fuel from player_coms[].

Deprecate edit key 'B' in doship(), dounit(), and don't show it in
pr_ship(), pr_land().

Drop opt_FUEL code from build_ship(), shi(), sdump(), ship_damage(),
show_ship_stats(), do_mob_ship(), nav_ship(), build_land(), land(),
ldump(), land_damage(), show_land_stats(), do_mob_land(),
resupply_all(), resupply_commod(), get_minimum(), has_supply(),
unit_list(), vers().

Remove opt_FUEL, fuel_mult, struct shpstr member shp_fuel, struct
mchrstr members m_fuelc and m_fuelu, M_OILER, struct lndstr member
lnd_fuel, struct lchrstr members l_fuelc and l_fuelu, fuel(), and
auto_fuel_ship().
2008-05-12 09:25:20 +02:00
3cc80e83c3 Remove unused num_shipsatxy() 2008-05-11 13:45:30 +02:00
286388dcdc Fix pin bomb not to report subs when there are none
pin_bomb() computed the number of foreign subs as number of ships less
number of foreign surface ships.  This counted own surface ships as
subs.

Change it to count foreign subs directly.  Closes #906040.

However, shipsatxy(), the function for counting foreign ships, also
lists them.  Add a parameter to suppress that, and change its callers.
2008-05-11 13:44:29 +02:00
221e88f106 Distinguish between sacking and obliterating a capital
Make caploss() transfer money, loans and market lots to the player
only if he actually took the capital, not if he obliterated it to
deity.

To make this work, caploss() needs to be called after the sector is
updated for damage and change of ownership.  Change callers
accordingly.

Closes #914049.
2008-05-11 10:48:30 +02:00
f6308422c3 Fix transfer of loans and market lots on sack of capital
Fix caploss() to transfer only signed loans.  Before, it transferred
any loan with a non-zero duration, which included loan offers, and
could claim to tranfer nonexistent loans.

Fix caploss() not to claim transfer of nonexistant market lots when
country 0 sacks a capital.
2008-05-11 10:30:32 +02:00
a16af46af9 Fix test for capital in caploss() to check country status
Test for STAT_ACTIVE instead of non-zero country number.  Inactive
countries have no capital they could lose!
2008-05-11 10:20:40 +02:00
ba5c360ca7 Remove useless call of caploss() from detonate()
The call has no effect, because by that time caploss() already ran
from sct_prewrite().
2008-05-11 10:05:25 +02:00
bb7c8665e4 Start the Empire clock on first break or update
Before, the Empire clock started at the epoch, which effectively made
it not tick before the first update.
2008-05-10 21:52:19 +02:00
dc8a7fe3ef Remove useless sanctuary break logic from designate
Don't call bsanct() when desi() is redesignating a sanctuary.  It's
pointless, because only deities can redesignate sanctuaries, and
bsanct() does nothing for them.
2008-05-10 19:09:20 +02:00
0a61f8eb78 Fix some argument prompts to end in one space
Corrects first argument of collect and show, and second argument of
assault, follow, mine, lmine and mobquota.
2008-05-10 18:52:29 +02:00
a1f4dc9592 Fix edit l, s, u, p not to wipe out concurrent updates
Make edit() bail out if the edited object changed while edit() slept
for input.
2008-05-10 08:40:48 +02:00
3dbb4dbb93 Fix xdump nat for relations
Commit ee863c5d (v4.3.12) got opt_HIDDEN backwards in nstr_exec_val().
2008-05-10 08:36:45 +02:00
27c3466aa5 Fix origin command not to prompt twice for its argument
Broken in commit b69173ee, v4.3.0.
2008-05-07 22:05:22 +02:00
db031971aa Bump version to 4.3.15 2008-05-07 21:58:15 +02:00