Commit graph

1014 commits

Author SHA1 Message Date
05364c0f68 Avoid cryptic message when survey's first argument is empty
Catch empty argument instead of letting nstr_comp_val() choke on it.
2008-07-21 08:13:40 -04:00
4646dfbf80 Fix origin and zdone for invalid country argument
Invalid country argument was interpreted as (natid)-1, which is
normally 255.  Harmless as long as this is less than MAXNOC (99).
Wrong anyway.
2008-07-21 08:13:40 -04:00
da59e02706 Validate explore's third argument earlier
The old code checked a bunch of other things first, which made it hard
to see that the value of onearg() was checked properly.
2008-07-21 08:13:40 -04:00
03937d6c58 Fix cede not prompt twice for its first argument 2008-07-21 08:13:40 -04:00
be41e70fa8 Fail commands properly when they get aborted
The old code didn't return RET_SYN when aborting at the following
prompts:

* designate second argument

* morale second argument

* route second argument

* set third argument

* tend fourth argument

* zdone last argument
2008-07-21 08:13:40 -04:00
a7cf69af50 Clean up how desi() handles bad designation arguments
Fail the command when the designation isn't allowed for mortals, or
when the player can't afford it.

Treat '=' and '@' like the other designations not allowed for mortals,
not like invalid designations.  Change failure for invalid designation
from RET_FAIL to RET_SYN.
2008-07-21 08:13:40 -04:00
d000bf9296 Fix bdes and designate to always write updated bmap to disk
bdes() failed to do that when the player aborted at the prompt for the
new designation.

desi() failed to do it when it failed the command because the new
designation was bad.
2008-07-21 08:13:31 -04:00
90a4864c17 Fix bdes not to gripe about empty desig input 2008-07-21 08:13:20 -04:00
e031a8a052 Fix bomb to fail on empty <pin|strat> argument
Before, the planes flew empty, and oopsed (since commit feaa2dd9,
v4.3.12) or complained (before) over the target instead of bombing it.
2008-07-21 07:52:35 -04:00
7bbd3fcd89 Fix distribute aborting at prompt for second argument
Before failing the command, the old code attempted to change the
current sector's distribution center to the last one used, which might
have been uninitialized coordinates.  If lucky, the coordinates were
invalid, and the attempt oopsed and did nothing.
2008-07-21 07:50:13 -04:00
2fa522588a Simplify pin_bomb() aborting at "Bomb what" prompt 2008-07-21 07:25:16 -04:00
9eda5f87b8 Fix command abortion after getting player input
The old code didn't honor command abortion at the following prompts:

* arm third argument

* deliver fourth argument (also simplify)

* fire third argument

* fly and recon prompt for carrier to land on: pln_onewaymission()
  treated abort like empty input, which made planes attempt landing in
  the sector.

* lmine second argument

* order d fourth argument

* power c nat(s) argument

* range second argument

* sail second argument

* shutdown both arguments (first one was broken in commit 84cfd670,
  v4.3.10, second one never worked).

* tend third argument
2008-07-21 07:19:18 -04:00
f2294d67a4 Change pln_mine() parameters to match pln_dropoff()
This moves getting the target sector from caller into pln_mine().
Makes sense, because that's where it's put.
2008-07-12 14:53:46 -04:00
27edba1f1b Change pln_dropoff() parameters to match pln_newlanding()
This moves getting the target sector or ship from caller into
pln_dropoff().  Makes sense, because that's where it's put.
2008-07-12 14:53:28 -04:00
42d9475d89 Fix seqno mismatch in fly()
fly() reads the carrier, then passes it to pln_dropoff(), which writes
it back.  fly() also calls pln_oneway_to_carrier_ok(), which updates
the carrier when its plane summary information is incorrect.

The old code called it between reading the carrier and passing it to
pln_dropoff().  This made pln_dropoff() wipe out the plane summary
update, and triggered a seqno mismatch oops.  Broken by introduction
of pln_oneway_to_carrier_ok() in commit 1127762c, v4.2.17.

Fix by reading the carrier right before passing it to pln_dropoff().
2008-07-12 14:51:18 -04:00
23d52a4147 Fix bomb not to let you p-bomb dead ships and land units
ASW planes bombing ships were not affected, because asw_shipsatxy()
excludes dead ships correctly.
2008-07-12 10:43:03 -04:00
bb5dfd803b Clean up and improve retreat condition handling
Change retreat condition prompt to point to help.  Before, it listed
conditions rather cryptically, without mentioning how to get help.

Don't provide help when encountering a bad retreat condition
character.

Fail the command when encountering a bad retreat condition character.
Before, they were dropped.

Don't fail the command when the player asks for help at the condition
code prompt.

Retreat condition help failed to explain 'c'.
2008-07-12 10:41:44 -04:00
700089dd42 Clean up unified unit loop in retreat()
Factor common code out of the type conditional.  Widens the "as flt?"
column to match the "as army?" column.
2008-07-11 07:19:29 -04:00
6b311f39da Unify retreat and lretreat code
New retreat(), call from retr() and lretr().  No functional changes.
Needs cleanup.
2008-07-11 07:19:29 -04:00
44e2ef468f Make retr() and lretr() simpler and more robust
The old code recognized group retreat only when the first argument was
on the command line.  Didn't make a difference, because it was only
used when there were at least two arguments on the command line.

The old code relied on rflags being represented as two's complement.

When given an empty retreat path, the old code deleted the retreat
path and set the retreat flags normally.  The new code deletes both.
Neither is nice; it should perhaps keep the retreat path and only set
the flags.
2008-07-11 07:18:59 -04: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
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
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
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
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
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
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
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
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
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
13d0fc7077 Avoid compiler warning 2008-05-05 21:54:02 +02:00
fe5b26658d Fix fire not to disclose retreat and wipe out target shell use
multifire() clobbered any changes to the target ship or sector made by
defend().  This let the target fire back for free.

multifire() retreated the target ship before reporting its location to
the player.  This disclosed its new location.

Fix by damaging and retreating the target after calling defend().
2008-05-05 06:53:33 +02:00
aae77430bf Change fire to always fire guns when the target is beyond range
multifire() drops depth charges if the target is a submarine, else it
fires guns.  It fails if the target is out of range.  But players
could still find out whether the target is a sub then, because depth
charge shell use differs from gun fire shell use.  This loophole
existed before 4.0.6, and was reopened by commit a3ad623b (v4.3.12).

Change multifire() to always use guns if the target is out of range.

While there, treat failure from shp_dchrg() and shp_fire() the same,
so that the player can't distinguish the two cases.  Failure there
should not happen.
2008-05-05 06:52:15 +02:00
66165f34cb Fix fire command to detect when the firing object changes
multifire() failed to take into account that the firing firing sector,
ship or land unit can change while it is getting the target argument.
It thus clobbered any updates made to the firing object while it was
sleeping for the target argument.  Abusable.  Broken when Chainsaw
introduced MULTIFIRE.
2008-05-04 16:44:26 +02:00
8209b88a54 Fix launch not to report the same ship sunk twice
This happened when a marine missile with a conventional warhead sunk
its target.
2008-04-29 21:10:33 +02:00