Commit graph

3993 commits

Author SHA1 Message Date
b42748001a Clarify info turn: turn off doesn't disable updates 2011-04-17 17:52:31 +02:00
eec6de50c8 Belatedly update designate's c_form
Commit 8227d8c8 (v4.3.12) removed its optional argument without
updating c_form.
2011-04-17 17:52:31 +02:00
c45a3bb923 Make option RAILWAYS disable rail infrastructure
Rail infrastructure isn't used with RAILWAYS.  Disable, to make the
improve command reject it.
2011-04-17 17:52:31 +02:00
81d80109ed Clean up mark()'s test for its optional argument
Commit 60bbb6b0 (v4.2.15) accidentally changed the test from "absent
or empty" to "absent".  Leave it that way, just clean it up.
2011-04-17 17:52:31 +02:00
40b11c098c Fix buy not to wipe out concurrent updates
buy() reads the lot, prompts for input, then writes back the lot,
triggering a generation oops.  Any updates made by other threads while
buy() waits for input are wiped out, triggering a seqno mismatch oops.

Since commodities are taken from the seller when he puts them on the
market, and given to the buyer when the trade executes, the wiped out
lot's seller loses his goods without compensation, the other seller
gets to keep his goods, and the buyer receives their duplicates.

This can be abused by two conspiring countries to duplicate
commodities.  The seller puts them on the market (say 100 gold bars).
The buyer starts a buy command, and waits at its last prompt for the
lot to be replaced.  The seller takes them off the market (possible,
since there's no bid, yet), and sells something else (say one food)
quickly enough to get the same lot number assigned.  The buyer then
completes the buy command.  The seller loses one food, the buyer gains
100 gold bars.

Replaces a partial fix from v4.0.1, which only caught lots gone away,
not lots replaced by new ones.
2011-04-17 17:48:18 +02:00
0563101703 Use SECS_PER_DAY instead of literal 86400 2011-04-17 17:48:18 +02:00
2f05b844c1 Don't let planes on trading block intercept or interdict
Fighters, SAMs, ABMs and anti-sats could intercept, and tactical
missiles could interdict ships or land units.

Missed when the other missions were fixed in v4.2.7.
2011-04-17 17:45:50 +02:00
04a332a89d Fix setsector and setres not to wipe out concurrent updates
setsector() reads the sector, prompts for input, then writes back the
sector, triggering a generation oops.  Any updates made by other
threads while setsector() waits for input are wiped out, triggering a
seqno mismatch oops.

Same for setres().
2011-04-17 10:47:57 +02:00
f4db90c849 Reduce massive code duplication in setsector(), setres()
There's the same sector loop in every switch case.  Loop around the
switch instead.
2011-04-17 10:47:23 +02:00
9afc6a8e5c Make info pray point to version (for e-mail) and flash 2011-04-16 15:53:01 +02:00
577c74b739 Commit 44db5453 added a FIXME comment accidentally, drop it 2011-04-16 14:50:51 +02:00
0d16b832d7 Commit f04d1ae0 made journal escape '\t' again, fix 2011-04-16 13:25:47 +02:00
05fc6523d5 Clean up write-only variable in path_find_to() 2011-04-14 21:20:09 +02:00
baae04ba29 Update change log for 4.3.27 2011-04-14 20:54:16 +02:00
8de0869a21 Clean up getcommand(): use sizeof() instead of literal 1024 2011-04-14 20:47:20 +02:00
e8b98f308e Fix client to log long input lines untruncated
They can still get split by output arriving between two reads from
input, but that's unavoidable, because the client is designed to read
and write big chunks, not lines.
2011-04-14 20:42:47 +02:00
819e28421e Fix client crash for long input lines
recv_input() misued lbuf_putc() and passed truncated lines without a
final newline to save_input(), failing the assertion in save_input().
2011-04-14 20:28:31 +02:00
4c0b4c0416 Mark long info pages with `!' in subject pages 2011-04-14 20:21:23 +02:00
7c8eef0525 Update info version example to current output 2011-04-14 20:21:23 +02:00
a93c8f628f Remove edit keys deprecated in 4.3.15, 4.3.17 and 4.3.20
These are: ship and land 'B', land 'P', and plane 'n'.
2011-04-14 20:21:23 +02:00
98cd2a3a70 Update known contributors comments 2011-04-14 20:21:23 +02:00
b58c37e296 Fix give not to wipe out concurrect updates
give() reads the sector, prompts for input, updates the sector and
writes it back, triggering a generation oops.  Any updates made by
other threads during the yield are wiped out, triggering a seqno
mismatch oops.
2011-04-14 20:21:23 +02:00
e3cf1e3280 Make generation numbers catch more potential yields on input
getstarg(), snxtitem() and snxtsct() can yield the processor, because
they call getstring().  But only for null or empty arguments.  For
other arguments, we should call ef_make_stale(), to catch errors.
Problem: if a caller never passes null or empty arguments, it may rely
on these functions not yielding.  We'd get false positives.  In
general, we can't know whether that's the case.  But we do know in the
common special case of player arguments.  Call ef_make_stale() for
those.
2011-04-14 20:21:23 +02:00
47b68a1c1f Document sequence numbers and generation numbers better 2011-04-14 20:21:23 +02:00
12a0279a80 Simplify map(): use getstarg() instead of getstring() 2011-04-14 20:21:23 +02:00
96d1039c24 Simplify execute(): use getstarg() instead of getstring() 2011-04-14 20:21:23 +02:00
437f16a4d4 Clean up display_region_map()
Without ARG1, display_region_map() formats a rectangular area around
CURX,CURY, so it can use do_map().  Ugly, and duplicates some
unit_map() functionality.

Factor snxtsct_around() out of unit_map().  Inline do_map() into
display_region_map(), so we can use snxtsct_around().

Don't mess with player->condarg.  Leftover from when we abused map()
here.
2011-04-14 20:21:23 +02:00
619b3def31 Factor parse_map_arg() out of do_map() 2011-04-14 20:21:23 +02:00
78fd95f67c Switch do_unit_move() over to display_region_map()
Just to make it more obviously consistent with map() callbacks used
with move_ground().
2011-04-14 20:21:23 +02:00
28d4847416 Clean up move_ground()'s parsing of DIR_MAP
Split with parse() and pass first two arguments instead of the raw
tail to the map() callback.  Advantages:

* Consistent with do_unit_move().

* Does the right thing when the tail is just spaces.  Before, the
  spaces got passed to the map() callback, which complained about
  syntax.  Now, they are ignored.  This is what the commit I just
  reverted tried to fix.

* Works better when the tail splits into more than two arguments.
  Except for explore_map(), which ignores the argument(s), the map()
  callbacks use display_region_map(), which split the tail at the
  first space, and complained about any spaces in the second part.
  Now, display_region_map() takes two argument strings instead of a
  single, unsplit argument string, and extra arguments get silently
  ignored, as usual.
2011-04-14 20:21:23 +02:00
40cfb41b4e Revert "(move_ground): Passed junk to map callback when 'm' sub-command"
It ignores all embedded space, not just trailing space after 'm'.

This reverts commit f65b255d18.
2011-04-14 20:21:23 +02:00
d59e19f5c2 Collapse duplicated code in draw_map()
One loop for maps and one for bmaps suffice.  Before, we had two
similar ones for each.
2011-04-14 20:21:22 +02:00
10f6ffde62 Fix map drawing commands to report bad unit arguments
Before, they failed without explanation when they interpreted the
argument as unit number, but the player didn't own that unit.
2011-04-14 20:21:22 +02:00
d3004510c8 Change unit_map() not to use RET_OK and RET_FAIL as return values
Returning 0 and -1 is simpler.
2011-04-14 20:21:22 +02:00
a00f9e200e Clean up bmap commands' flags argument
parse_map_flags() silently truncates map flags after the first 't' or
'r'.  This makes it accept arguments "true" and "revert".  However, it
also breaks the perfectly sensible argument "ts", which should show
ships just like "st", but doesn't.

info bmap & friends document arguments "true" and "revert", and also
suggest flags 't' and 'r'.  What a mess.

Make argument "revert" a special case.  Deprecate flag 'r', and clean
up truncation there.

Don't truncate after flag 't'.  If any bad flags follow, ignore
everything after 't', but deprecate that usage.
2011-04-14 20:21:22 +02:00
457f797972 Factor parse_map_flags() out of do_map() 2011-04-14 20:21:22 +02:00
5da60a5abb Fold draw_map() parameter bmap into map_flags
No functional change.
2011-04-14 20:21:22 +02:00
a4c5d05fe1 Tweak info on movement commands' map drawing sub-commands 2011-04-14 20:21:22 +02:00
35127accb5 Fail map drawing command when player doesn't confirm bmap revert
Doesn't affect mapping at movement prompts (navigate, march, move,
test and transport), because the failure is ignored there.
2011-04-14 20:21:22 +02:00
33ac27777a Don't show a map on bmap revert
Before, it showed a map, but only when the player confirmed the
revert.
2011-04-14 20:21:22 +02:00
6b498f3908 Clean up map info pages a bit
Drop .SY for map commands other than the one documented by the info
page.

Use the page's command to discuss arguments "revert" and "true", not
"bmap".

Clarify flags argument.
2011-04-14 20:21:22 +02:00
5230ea8de4 Drop useless checks for player->aborted in draw_map()
player->aborted gets set when we get an interrupt or EOF cookie from
the player, when update or shutdown abort commands, and when we abort
an attack (not relevant here).

The checks are useless: player interrupt and EOF are checked
elsewhere, and update/shutdown can run only when we yield the
processor, which we never do (output doesn't yield because C_MOD is
set).
2011-04-14 20:21:22 +02:00
2f86e79e80 Drop potentially misleading build and radar error messages
buil() complains about the argument when snxtsct() fails.  Misleading
when the argument is fine, but snxtsct() fails due to bad conditional
argument.

Same for radar() with snxtitem().
2011-04-14 20:21:22 +02:00
4dfb84086a Remove disabled command cede
It misuses snxtsct() and snxtitem() to find out whether the first
argument looks like sectors or like ships, which doesn't work with a
bad conditional argument.

Not worth fixing now; it's been disabled since 4.0.1, and broken at
least since commit 2fc1e74a (v4.3.0) broke its sector/ship
disambiguation via third argument.
2011-04-14 20:21:22 +02:00
16daa4007c Fix do_map()'s misuse of snxtsct() for testing argument syntax
It assumes snxtsct() fails only when the argument can't be parsed.  It
can also fail when the condition argument has errors.  `map # ?xxx'
first complains about xxx, then maps around ship#0.  Broken since
Chainsaw 2 introduced smap, pmap and lmap.

Use sarg_type() to recognize sectors vs. unit argument.  `map # ?xxx'
now fails as it should.

Subtle side effect: do_map() no longer prompts for argument "",
because snxtsct() is now guarded by sarg_type().  Impact on callers:

* display_region_map() is not affected, because it never passes "".

* map() passes on "" arguments.  Change it to prompt in that case.
  Consistent with how other commands behave.  No functional change.

* do_unit_move() passes on "" arguments.  Keep it that way.  This
  changes navigate and march sub-commands 'M' and 'B' not to prompt
  for "" arguments, which is consistent with sub-command 'm' of move,
  test and transport.
2011-04-14 20:21:22 +02:00
baee0744ff Make map drawing commands fail on bad flags
Also affects mapping at movement prompts of navigate, march, move,
test, transport.
2011-04-14 20:21:22 +02:00
d78df0b48b Move function declarations for maps.c from prototypes.h to map.h 2011-04-14 20:21:22 +02:00
8dc69a9a84 Move map flags from map.h to maps.c, and reorder
Not useful elsewhere.  Since I'm touching them anyway, put them in the
usual ship, plane, land, nuke order.
2011-04-14 20:21:21 +02:00
0f0b5605e9 Remove misleading comment on MAP_PLANE & friends
ef_unit_list doesn't exist.  Order doesn't matter, priority is defined
by draw_map()'s ef_unit_map[].

This reverts commit 9e75e5e009.
2011-04-14 20:21:21 +02:00
78b3af20fe Drop "xdump ver" deprecated in 4.3.12 2011-04-14 20:21:21 +02:00