Commit graph

1234 commits

Author SHA1 Message Date
97d6c5262f Streamline flak damage report to plane owner
Don't tell him that it's his plane, he knows that.

Put a " -- " between "takes N%" and "aborted" / "shot down" for
ordinary flak as well, not just for flak vs. pinpoint bombing.
2010-07-18 08:36:19 +02:00
aa5bb9790c Factor common plane damage code into ac_damage_plane()
Out of ac_planedamage() and pinflak_planedamage().
2010-07-18 08:36:19 +02:00
1a4fc50d57 Make flak vs. pinpoint bombing consistent with ordinary flak
Reduce abort chance from 100-eff to 80-eff.  Ordinary flak's abort
chance was reduced from 100-eff (if eff<80) to 80-eff in commit
0252d4a7, v4.3.6.

Report plane efficiency when it aborts, not 100 - efficiency.

Charge mobility proportional to damage, down to -32.
2010-07-18 08:34:45 +02:00
8eca636c7d Factor look_at_sect() out of do_look() and ac_encounter() 2010-07-18 08:31:53 +02:00
2cfb124b6c Restrict ac_encounter() mission_flags to current player
The only user is reco(), so the restriction is fine.  Several
functions called on behalf of mission_flags assumed it already:
plane_sweep(), sathead(), satdisp_sect(), satdisp_units().  Simplify
the rest accordingly: plane_sona() and ac_encounter() itself.
2010-07-18 08:31:53 +02:00
e25413a688 Fix lookout to report sector owner properly to deities
It reported all sectors as owned by the deity.
2010-07-18 08:31:53 +02:00
f3fc477c82 All-nuclear bombing run reported "bombing raid did 0 damage"
Broken in commit 162435e6, v4.3.26.
2010-06-27 09:21:56 +02:00
5920515cd7 Drop prxy()'s parameter country
Argument is always player->cnum.  Hardly surprising, because that's
to whom it prints.
2010-06-21 21:03:21 +02:00
79dccdf5a8 Fix sabotage command to use correct coordinate system
It reported the spy's location in the spy's coordinate system
instead of the player's.  Fortunately, they're the same in normal
usage.  They can differ only when a deity uses a foreign spy.
2010-06-21 21:03:21 +02:00
a4cd4aa7f7 Fix sail command to use correct coordinate system
It reported the ship's location in the ship's coordinate system
instead of the player's.  Fortunately, they're the same in normal
usage.  They can differ only when a deity uses a foreign ship.
2010-06-21 21:03:21 +02:00
bc72ff768f Fix lmine to use correct coordinate system
It reported the engineer's location in the engineer's coordinate
system instead of the player's.  Fortunately, they're the same in
normal usage.  They can differ only when a deity uses a foreign
engineer.

The buggy code is also reachable from and march sub-command 'd', but
can't bite there, because even deities can't march foreign land units.
2010-06-21 21:03:21 +02:00
bedf3ae415 Fix nation command to use correct coordinate system
It reported capital location in the nation's coordinate system instead
of the player's.  Fortunately, they're the same in normal usage.  They
can differ only when a deity requests a nation report for another
country.
2010-06-21 21:03:21 +02:00
25d29c8f8f Convert tab after #define to space 2010-06-20 18:38:54 +02:00
243a15052f Convert spaces to tabs 2010-06-20 18:36:44 +02:00
7465574195 Break long lines more tastefully 2010-06-20 18:36:44 +02:00
373651359e Coding style fixes, mostly indentation and whitespace 2010-06-20 18:36:38 +02:00
531bac70a4 Remove superfluous casts to natid 2010-05-24 18:23:32 +02:00
f6cab16b65 Don't capitalize words in the middle of sentences
Affects output of commands add, anti, build, edit, order, reset, set,
setresource, setsector, show, version.
2010-05-24 18:23:32 +02:00
72b31dae13 Fix retreat, lretreat condition 'c'
Broken in commit bb5dfd80, v4.3.16.
2010-04-04 09:24:33 +02:00
5e08b7fa55 coastwatch and skywatch could see too far
Both coas() and skyw() want to iterate over a circular area with
radius vrange.  They did that by iterating over a rectangle that
encloses the circle, skipping coordinates out of range.  To "save
time", they used a rather odd predicate for "out of range", namely
"vrange * vrange < (j * j + 3 * k * k) / 4)".

The predicate is wrong.  coastwatch and skywatch could see one sector
too far in certain directions for practical radar ranges, and up to
two sectors for not so practical tech 1900+ radar stations.

For instance, with j = 13 and k = 3, vrange = 7, the predicate
evaluates to false (49 < 48), i.e. in range.  However, the true
distance is 8, i.e. out of range.  Likewise, j = 22, k = 8, vrange =
13: 169 < 169, true distance 15.

Fix by iterating over the circle directly, without comparing
distances.
2010-04-04 07:31:06 +02:00
38befcb446 Make skywatch report satellite uid
The uid is required for launching a-sats since commit 1ee02875,
v4.3.23.

Change output to resemble coastwatch's.
2010-04-02 20:35:57 +02:00
162435e690 Clean up checks for zero value of pln_damage()
Before commit a269cdd7, pln_damage() returned zero when the damage was
nuclear, and callers used that to bypass conventional damage code.
Zero value can't happen anymore.
2010-04-02 19:08:27 +02:00
6c639f1481 Fix sabo not to kill the spy every time
The hack to protect the spy from sabotage damage killed it outright.
Broken in 861a6662, v4.3.17.
2010-03-29 17:39:07 +02:00
28cc236e12 Fix navigate and march not to lay mines free of charge
do_unit_move() reads the ships into a list.  It re-reads them when it
prompts for sub-commands.  shp_nav_one_sector() writes them back when
it moves ships.

Mine-laying (sub-command 'd') updates the minelayer, invalidating the
copy in the list.  Any movement sub-command before the next prompt for
sub-commands wiped out this update, triggering a seno mismatch oops.

Happens only if 'd' is used without arguments, because remaining
sub-commands are discarded when there are arguments.

Broken when mine-laying was added in commits 2438fe7c, v4.3.7.

Same for march, commit 274c8e42, v4.3.7.

Fix by stopping after 'd' regardless of arguments.
2010-03-20 14:57:05 +01:00
45106ab91f Fix navigate and march not to prompt for number of mines to lay
When sub-command 'd' was used without arguments, do_unit_move() failed
to supply the second argument to mine(), which duly prompted for it.
This contracticted info, and could trigger a generation oops.

do_unit_move() reads the ships into a list.  It re-reads them when it
prompts for sub-commands.  shp_nav_one_sector() writes them back when
it moves ships.

The mine prompt made the list stale.  Movement sub-commands before the
next prompt for sub-commands wrote back stale ships, triggering a
generation oops.  Example: "nav 15 dg".

Broken when mine-laying was added in commits 2438fe7c, v4.3.7.

Same for march, commit 274c8e42, v4.3.7.
2010-03-20 14:24:25 +01:00
bb5abd95e0 Fix news for torpedo attack's return torpedo
When a torpedo attack triggered a return torpedo, the news reported it
to be fired by the attacker instead of the defender.
2010-03-16 21:27:41 +01:00
2b14f876be Fix generation numbers for order command
orde() uses a "clever" trick to get away with just one
check_ship_ok(): it makes a copy of the ship in the beginning, and
checks it at the end.  Generation numbers (commit 2fa5f652) break this
trick.  It could be fixed by manually marking the ship fresh.
Instead, check the ship the stupid, straightforward way, without a
copy.
2010-01-26 22:20:16 +01:00
b54bc83e26 Normalize order's reaction to bad input
Consistently fail the command on bad or missing argument.  Before, it
merely skipped to the next ship in some cases.
2010-01-26 22:02:34 +01:00
7ac10453a2 Get third argument of "order l" the ordinary way
Now prompts when the argument is empty.  Before, that was interpreted
as zero.  Not likely to affect players.
2010-01-26 21:48:54 +01:00
ae6ad76516 Clean up dead code in orde()
Does not change optimized code (gcc -O) apart from __LINE__.
2010-01-26 21:38:31 +01:00
b8f5eaff0b Clean up dead stores
Does not change optimized code (gcc -O).

Spotted by the Clang Static Analyzer.
2010-01-19 08:40:42 +01:00
3650587dab Fix navigate/march crash on funny path arguments
For an argument consisting of a valid path plus whitespace,
do_unit_move() eventually passed the whitespace suffix to parse(),
then dereferenced player->argp[0].  But that was null.

Broken in commit 0c12d837, v4.3.7.  Trivial for players to trigger.
2010-01-19 08:40:42 +01:00
8195d5fb88 Clean up useless getnatp() in conv(), nav_map(), tele()
Spotted by the Clang Static Analyzer.
2010-01-19 08:40:42 +01:00
73e25ff21e Update copyright notice 2010-01-19 08:40:17 +01:00
05b56fa942 Clean up poorly chosen loop control variable names
Calling a counting loop's control variable q or z is tasteless
bordering on actively misleading.
2010-01-19 08:38:16 +01:00
aa659c7754 Narrow struct sctstr member sct_mobil to char
To bring it in line with unit mobility.
2010-01-19 08:37:05 +01:00
ca2dba33f0 Make struct sctstr member sct_effic signed
To bring it in line with unit efficiency.
2010-01-19 08:37:05 +01:00
da48ba6d13 Fix sloppy sanity check for mobility going negative in transport
Assignment to sct_mobil was vulnerable to integer underflow.  Should
not happen, as move_ground() never returns a cost exceeding available
mobility.
2010-01-19 08:37:05 +01:00
ba2044be18 Store uids as int to support more sectors and units
Before, they were stored as short.  Wider uids use more space, but the
next commit will recover it by narrowing other members.

The use of short has always limited the number of ships, planes, land
units and nukes to SHRT_MAX (commonly 32768).  Only the most extreme
games ever came close.

Commit 49780e2c (v4.3.12) added struct sctstr member sct_uid to make
struct empobj member uid work for sectors.  This made the limit apply
to sectors as well.  We've had games with more than 32768 sectors.
2010-01-19 08:26:42 +01:00
4e895465df Remove unused members of struct lndstr, lonstr, nukstr, trtstr
struct lndstr member lnd_flags is a leftover from Empire3's C_SYNC,
which was ripped out in 4.0.0.

struct lonstr member l_sel, struct nuk_str members nuk_ship, nuk_land,
and struct trtstr member trt_bond have been there basically forever
without any use.
2010-01-19 08:21:37 +01:00
c0ed527311 Consistently use int for file type parameters and locals 2009-12-29 17:23:22 +01:00
b23c52951f Fix launch not to wipe out target sector updates
Launching ABMs updates their base, in mission_pln_equip().  The update
got wiped out when launch_missile() wrote back the target sector,
triggering a seqno mismatch oops.  Harmless with the stock game's
ABMs, because they use neither shells nor petrol.

Fix by re-reading the target sector.
2009-12-26 14:02:50 +01:00
7dc130b7ac Fix launch not to wipe out target ship updates
Ships can expend shells to defend against missiles, in
shp_missile_defense().  Any shell use by the target ship got wiped out
when launch_missile() wrote back the target ship, triggering a seqno
mismatch oops.

Fix by re-reading the target ship.
2009-12-26 11:28:25 +01:00
c528fcbe3e Update known contributors comments 2009-12-13 17:34:28 +01:00
fd894d9864 Fix and enable collateral damage for missing missiles
Collateral damage was disabled, because after msl_hit() reported a
miss, the missile may or may not have reached the target.

Fix by splitting msl_launch() off msl_hit().

Drop the disabled collateral damage code for sector targets, because
sectors can't be missed.  Enable it for ships and land units.

Since msl_launch() returns whether the missile is sub-launched, drop
launch_missile() parameter sublaunch, and simplify its caller.
2009-12-13 08:05:26 +01:00
e7fec28009 News reported victim as actor for sub-launched anti-sat and ABM
If the intercepted missile was sub-launched as well, this disclosed
its owner.

The stock game's anti-sats and ABMs can't be sub-launched.
2009-12-13 08:05:25 +01:00
0060e48ea4 Refactor missile interception code
Keep only the common part in msl_intercept(), and give it internal
linkage.  Wrap new msl_abm_intercept() and msl_asat_intercept() around
it.  They are simpler to use.
2009-12-13 08:04:07 +01:00
de2fae0ee6 Fix defense value of intercepted missiles and satellites
Use the plane's defense value, not the plane type's base value.
2009-12-13 08:04:07 +01:00
0f0d785601 Don't attempt to hide owner of sub-launched satellite
The attempt was pointless, because the recipient of the message could
see the owner on skywatch, and the news reported it as well.
2009-12-13 08:03:51 +01:00
f7f3178ce2 Move msl_equip() to callers, internal linkage 2009-12-13 08:03:49 +01:00