Commit graph

3972 commits

Author SHA1 Message Date
10736cd157 Don't write garbage to unused trade destination in trade file
struct trdstr members trd_x, trd_y are used only for teleporting
trades.  For others, trad() wrote garbage coordinates to the trade
file.  They weren't used except by xdump.  Fortunately, even there
they're visible only to deities.

Write invalid coordinates instead.  Do that in set() as well, so that
coordinates are valid only when we have a teleport destination.

Spotted by the Clang Static Analyzer.
2010-07-25 17:48:53 +02:00
8c78b1188b Clean up dead store in skyw()
Dead since commit 38befcb4.  Spotted by the Clang Static Analyzer.
2010-07-25 17:48:53 +02:00
765bf06ab2 Make disabled recursive supply in s_commod() compile again
Untested.  Broken in commit 98f24d5c, v4.3.20.
2010-07-25 17:48:53 +02:00
a8a68287bb Remove unused variables in disabled lnd_fort_interdiction() 2010-07-25 17:48:53 +02:00
5eb337e232 Clean up unobvious coordinate system use in doland()
Use the obviously correct newown instead of sect->sct_own.  They're
actually equal here.
2010-07-25 17:48:53 +02:00
f0da4769dc Clean up unobvious coordinate system use in detonate()
Use the obviously correct player->cnum instead of own.  They're
actually equal here.
2010-07-25 17:48:53 +02:00
efd3940322 Clean up unobvious coordinate system use in pln_airbase_ok()
Use the obviously correct player->cnum instead of pp->pln_own.
They're actually equal here.
2010-07-25 17:48:53 +02:00
1fa06bd45f Clean up suspicious coordinate system use in unit_put()
It showed unit coordinates in unit's coordinate system instead of the
actor's.  Fortunately, they're the same, since it is reachable only
for non-zero actor, only shp_nav_one_sector(), lnd_mar_one_sector()
and sail_nav_fleet() pass that, and even deities can't navigate
foreign ships or march foreign land units.
2010-07-25 17:48:53 +02:00
eea0dfd133 Factor rad_char() out of radmap() and rad_map_set()
Code was duplicated in commit 0d477e5d.
2010-07-25 17:47:30 +02:00
e41762ca49 Compute radar range in one place, rad_range()
Before, a part was duplicated in radmap() and rad_map_set(), and
another part in their callers.
2010-07-25 17:45:14 +02:00
e49cb13480 Don't limit radar command's range to fit into world map
Limited since Chainsaw 2 so that the radar map fits into a world map
without clipping, i.e. its diameter neither exceeds WORLD_X / 2 nor
WORLD_Y.  Maybe range exceeding that triggered bugs then.  It doesn't
now, and it makes no sense.

The limit never applied to automatic bmap update from ship radar.
2010-07-25 17:40:52 +02:00
a65ee5e9b2 Simplify radmap() and radmap2()
radmap() is now radmap2()'s only caller.  Inline radmap2() and
simplify.  This cleans up a suspicious-looking use of xyas(): it
relied on the fact that owner == player->cnum if pr_flag.
2010-07-25 17:40:36 +02:00
0d477e5df1 Simplify automatic bmap update from ship radar
Inline radmap2() into radmapupd() and simplify.  Drop unused parameter
seesub.  Rename to rad_map_set().
2010-07-25 17:34:44 +02:00
27f22f36bb Remove radmapnopr(), use radmapupd() instead 2010-07-24 11:28:45 +02:00
db04ba4355 Clean up output destinations in navigation code
shp_nav() and shp_nav_one_sector() printed both to their actor
argument and to ship owner.  shp_nav_one_sector()'s use of xyas()
looked particularly suspicious: it passed actor, then printed the
result to the ship owner.  Fortunately, actor and ship owner are the
same, since even deities can't navigate foreign ships.  Normalize to
actor for consistency.

While there, rename shp_mess() to shp_stays().
2010-07-24 11:28:40 +02:00
3aca5a701a Clean up output destinations in march code
lnd_mar(), lnd_sweep() and lnd_mar_one_sector() printed to the current
player, their actor argument, and to land unit owner.
lnd_mar_one_sector()'s use of xyas() looked particularly suspicious:
it passed actor, then printed the result to the current player or land
unit owner.  Fortunately, all three are the same: all callers pass
current player for actor, and land unit owner is the same, since even
deities can't march foreign land units.  Normalize to actor for
consistency.

While there, rename lnd_mess() to lnd_stays().
2010-07-24 11:28:33 +02:00
a207032625 Clean up confusing use of def->own in move_in_land()
It passed def->own to lnd_sweep(), which looks like a bug.  But it's
actually player->cnum there, because take_def() already set def->own
to player->owner: take_def() first changes the owner of the attacked
sector by calling takeover(), then updates def->own from that in
att_get_combat().
2010-07-24 11:28:33 +02:00
2960ac40db Clean up output destinations in attack code
take_def() and ask_move_in() printed both to the current player and to
land unit owner.  Their use of prcom() and xyas() looked particularly
suspicious: they used the current player, then printed the result to
the land unit owner.  Fortunately, current player and land unit owner
are the same, since even even deities can't attack with foreign land
units.  Normalize to current player for consistency.

Switch get_ototal(), get_oland(), kill_land() and move_in_land() to
current player as well.
2010-07-24 11:28:33 +02:00
18ce536041 Use lnd_delete() in lnd_mess() 2010-07-24 11:28:32 +02:00
2c4826e420 lnd_delete() can no longer print a message
Callers changed to print it themselves.

But print the first "boards" message before plane takeover instead of
after, in take_def().
2010-07-24 11:28:32 +02:00
2ae4799beb Rename put_land() to put_oland() for clarity 2010-07-24 11:28:32 +02:00
1f080ef570 Split get_land() into get_oland() and get_dland() & simplify 2010-07-24 11:28:24 +02:00
8e4d898f01 put_land()'s function comment has drifted away, fix 2010-07-24 11:23:17 +02:00
0d8ee6ee6c Fix oops recovery in lnd_set_tech()
Broken in commit 0219bf08.
2010-07-18 09:28:50 +02:00
8c12432327 PR() and PRdate() are no longer used, remove them 2010-07-18 09:28:50 +02:00
dcd192f324 Use mpr() instead of PR() where possible
The difference between the two is that PR() buffers partial lines, and
mpr() suppresses output to country#0.  Doesn't matter when printing
complete lines to a country other than #0, e.g. the owner of a unit.
2010-07-18 09:28:49 +02:00
73260a8a6d Factor ac_dog_report() out of ac_dog() 2010-07-18 09:26:57 +02:00
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
7defa55394 Suppress "no damage" after "takes 0" when reporting flak 2010-07-18 08:34:45 +02:00
5bb4846267 Clean up ac_planedamage() a bit
Reshuffle code for clarity, and delete a bogus comment.
2010-07-18 08:34:45 +02:00
22834d6793 Rename ac_planedamage() argument show to flak
Parameter name "show" is misleading since the previous commit:
non-zero no longer shows anything, only suppresses output.
2010-07-18 08:34:45 +02:00
16b16e34b3 Move printing from ac_planedamage() into callers
It prints only if show is non-zero, so only ac_fireflak() is affected.
2010-07-18 08:34:45 +02:00
4007fc0f99 Streamline ac_planedamage()'s last argument
ac_planedamage() writes up to 14 characters.  Trim excessive buffers
in callers.  Guard against overrun in callee.
2010-07-18 08:34:45 +02:00
38ae0252b8 Simplify ac_planedamage() to write straight to mesg[] 2010-07-18 08:34:45 +02:00
d96202fc90 Remove dead code from ac_planedamage()
Since Empire 3 made option NEWPAF mandatory, checkabort is always
non-zero, and show implies checkabort != 1 and other == 0.  Drop
unreachable code, and remove unused parameters checkabort and other.
2010-07-18 08:34:45 +02:00
5161953996 Clean up call of writemap() in ac_encounter()
Pass the more obviously correct plane_owner instead of player->cnum.
They're the same, actually.

When deities could still fly foreign planes (before commit 2023b47c),
they weren't.  ac_encounter() updated the plane owner's in-memory
bmap, but wrote the current player's bmap to disk.
2010-07-18 08:34:25 +02:00
c2cd58d561 Fix recon and satellite to write spy plane bmap updates to disk
satdisp_sect() updated the in-memory bmap, but failed to write the
updates to disk.  Its callers already update bmap from other sources,
so move this update there, and connect it to the existing write back.
2010-07-18 08:31:53 +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
7499d0bdee Fix bogus message when deity attempts to march foreign land unit
Much of the code assumes that only the land unit's owner can march it.
The assumption is correct, because lnd_mar() leaves foreign land units
behind with a bogus "was disbanded at" message (suppressed for country

It would be nice to let deities march foreign land units, but the
assumption is not trivial to remove.  For now, just avoid the bogus
message.

Historical note: it looks like deities used to be able to march
foreign land units just fine until Empire 2 factored common code out
of navigate, sail and autonav, and updated march to match navigate.
Likewise, it looks like they could board with foreign land units until
Empire 2 factored out common ground combat code.  Commands attack and
assault have always rejected foreign land units, even for deities.
2010-07-18 08:31:20 +02:00
8c502d40c6 Fix bogus message when deity attempts to navigate foreign ship
Much of the code assumes that only the ship's owner can navigate it.
The assumption is correct, because shp_nav() leaves foreign ships
behind with a bogus "was sunk at" message (suppressed for country #0).

It would be nice to let deities navigate foreign ships, but the
assumption is not trivial to remove.  For now, just avoid the bogus
message.

Historical note: it looks like deities used to be able to navigate
foreign ships just fine until Empire 2 factored common code out of
navigate, sail and autonav.
2010-07-11 07:59:43 +02:00
9e6b5a9133 Don't let deities fly foreign planes
Much code assumes that only the plane's owner can fly it.
pln_airbase_ok() oopses since commit 446f1991.  Before, flying planes
from carriers failed with a bogus "not valid for" message, and flying
from sectors had output misdirected to the plane's owner.

It would be nice to let deities fly foreign planes, but the assumption
is not trivial to remove, so just satisfy it for now.

Historical note: it looks like deities used to be able to fly foreign
planes just fine until Chainsaw 3 added missions.  The launch command
has always rejected foreign planes, even for deities.
2010-07-11 07:59:43 +02:00
2f4b5973ce Oops when mpr() is misused for printing partial lines
Such misuse creates a bulletin with a partial line.  The read command
normally merges it with the next one, but if the bulletins are more
than five seconds apart (clock jumped somehow), we get a bulletin
header in the middle of a line.
2010-07-11 07:59:43 +02:00
e002bf207f Clean up misuse of mpr() in pln_damage()
Don't use multiple calls of mpr() to print a single line, because that
creates a separate bulletin for each part.  The read command normally
merges the bulletins, but if the bulletins are more than five seconds
apart (clock jumped somehow), we get a bulletin header in the middle
of a line.

While there, wrap long "blam" lines.  Can only happen for bomb loads
above 16.  Stock game needs a tech 406 jhb for that.

The mpr() misuse was introduced in Empire 2.
2010-07-11 07:59:34 +02:00
47dd33698c Clean up misuse of mpr() in shp_missile_defense()
Don't use multiple calls of mpr() to print a single line, because that
creates a separate bulletin for each part.  The read command normally
merges the bulletins, but if the bulletins are more than five seconds
apart (clock jumped somehow), we get a bulletin header in the middle
of a line.

The mpr() misuse was introduced in Empire 2.
2010-06-27 18:28:07 +02:00
4033a3be7d Clean up misuse of mpr() in msl_launch()
Don't use multiple calls of mpr() to print a single line, because that
creates a separate bulletin for each part.  The read command normally
merges the bulletins, but if the bulletins are more than five seconds
apart (clock jumped somehow), we get a bulletin header in the middle
of a line.

The mpr() misuse was introduced in Empire 2.
2010-06-27 18:28:07 +02:00
4191b22758 Message for land unit hitting mines lacked a newline
Broken in Empire 2.
2010-06-27 18:28:07 +02:00