Commit graph

1154 commits

Author SHA1 Message Date
de7657dd99 Permit flash to yourself
Flashing yourself failed with a bogus "not logged on" message for
deities, and a mildly bogus "not a deity or friendly with us" message
for mortals.

Fix by simply permitting it.  Not terribly useful, except perhaps for
empire-hub users, but why not.
2011-02-13 16:39:20 +01:00
0d4566847f Drop redundant chat(), sendmessage() parameter us
It can't be anything but the current player.
2011-02-13 16:39:20 +01:00
5eeac45b8d Clean up confusing control flow in sendmessage()
The second patch hunk fixes a latent bug.  Before, rejected deity
flashes led to a bogus "not logged on" message, now they lead to a
"not accepting" message.  But deity flashes can't be rejected, so this
doesn't matter.
2011-02-13 16:32:37 +01:00
e21f5035cb Optimize sendmessage() use of getnatp()
Don't call it when its value must be TO anyway.

While there, oops when it fails instead of recovering silently.
2011-02-13 16:06:23 +01:00
fc633a4f1f Fix racy detection of ally rejecting flashes
sendmessage() checked NF_FLASH on two places: when deciding whether to
send the message, and later when telling the player why it didn't send
a flash.  This can race with the toggle command as follows: if a flash
could not be sent because the recipient's NF_FLASH was off, and the
recipient toggled it on before the flag was checked again, the flash
command claimed the sender wasn't logged on.
2011-02-13 16:06:23 +01:00
53a4fc6e26 Change flash not to print "Flash sent" for deities
It's annoying.  It never did that for mortals.
2011-02-13 16:06:23 +01:00
c095ad285b Factor feels_like_helping() out of quiet_bigdef(), sd(), dd() 2011-02-13 16:06:22 +01:00
16c68eb403 Fix trade ships to pay off in own harbor
Broken in commit 3318e4e4, v4.3.17.
2011-02-13 16:03:34 +01:00
439f111f98 Remove option SLOW_WAR
SLOW_WAR has issues:

* The check whether the attacker old-owns the attacked sector is
  broken, because att_abort() uses sect.sct_oldown uninitialized.

  Spotted by the Clang Static Analyzer.

* Its implementation in setrel() is somewhat scary.  It's actually
  okay, because that part of setrel() only runs within decl().  Other
  callers don't reach it: update_main() because player->god != 0
  there, and the rest because they never pass a rel < HOSTILE.

* Documentation is a bit vague.

SLOW_WAR hasn't been used in a public game in years.  Fixing it is not
worth it, so remove it instead.
2011-02-13 15:59:49 +01:00
217fe6dd16 Fix sail command to support full path length
Off-by-one in cmd_sail_ship() chopped off the last character of
full-length sail paths.
2011-01-09 15:27:26 +01:00
ceee05eb7e Neater plane sonar contact output
plane_sona() prints an empty line to make sonar contacts stand out.
Move it so the contact is visually "attached" to the right sector,
like this:

    flying over sea at 15,-3
    Sonar contact in 15,-3
    sub #3 13,-3

    flying over sea at 13,-3

Before:

    flying over sea at 15,-3

    Sonar contact in 15,-3
    sb   submarine (#3) 13,-3
    flying over sea at 13,-3
2010-07-25 17:48:54 +02:00
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
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
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
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
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
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
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