Commit graph

3972 commits

Author SHA1 Message Date
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
1ffea04a6d info xdump still has long gone pseudo-table ver, remove
Missed in commit da8a1dae, v4.3.12
2011-04-14 20:21:21 +02:00
af5e25aa16 Move xdmeta() back to commands/xdump.c, internal linkage
Partially revert commit 4c746b5e.
2011-04-14 20:21:21 +02:00
6db74cd282 Simplify satmap() with snxtitem_use_condarg(), snxtsct_use_condarg() 2011-04-14 20:21:21 +02:00
7de511fb66 Factor snxtsct_use_condarg() out of snxtsct() 2011-04-14 20:21:21 +02:00
84072cff5d Factor snxtitem_use_condarg() out of snxtitem() 2011-04-14 20:21:21 +02:00
74a69cf74c Fix satellite to fail on bad conditional
snxtsct() and snxtitem() fail when the condition argument is bad.
satmap() didn't check for failure.  Due to the way snxtsct() and
snxtitem() work, bad condition arguments were reported and otherwise
ignored.
2011-04-14 20:21:21 +02:00
d0a6dffa02 Collect nstr_item, nstr_sect function declarations in nsc.h
Moved from prototypes.h.
2011-04-14 20:21:21 +02:00
40b6032a5d Move xysize_range(), xydist_range() to xy.c and xy.h
Moved from snxtsct.c and prototypes.h next to the other struct range
functions.
2011-04-14 20:21:21 +02:00
e7d7cfdc10 Fix journal.c boilerplate comment 2011-04-14 20:21:21 +02:00
4785662587 New journal event "output"
Redundant information, but incredibly useful when you want to figure
out what happened without a (still nonexistent) journal replay tool.
The redundancy could help making a journal replay tool more robust.

To enable, set econfig key keep_journal to at least 2.  Output events
are *not* flushed to disk immediately.
2011-04-14 20:21:21 +02:00
f04d1ae032 Fix journal not to truncate long lines
Could happen only for input events.
2011-04-14 20:21:21 +02:00
27212dc46b Escape '\\' in journal, but not '\t' 2011-04-14 20:15:19 +02:00
a7be765ed4 Journal login phase input, too 2011-04-14 19:58:49 +02:00
72d051310c New journal event "command"
Redundant information.  Allows making sense of input without context.
The redundancy could help making a journal replay tool more robust.
2011-04-14 19:46:05 +02:00
9be4f57ad5 Clean up superfluous include of queue.h in land.h, ship.h 2011-04-14 19:46:05 +02:00
157ae8ec21 Clean up superfluous include of nsc.h in prototypes.h 2011-04-14 19:46:05 +02:00
a2386edc01 Clean up superfluous include of news.h in empobj.h
Missed in commit 0ba61f17, v4.3.24.
2011-04-14 19:46:05 +02:00
44db545344 Disable BRIDGETOWERS by default
A deity can easily break BRIDGETOWERS by reducing etu_per_update
without compensating customization of buil_tower_bh,
rollover_avail_max or bridge span maxpop.

Document the issue in output of pconfig (which is installed as
$prefix/etc/empire/econfig).

To increase the chance deities actually read the documentation,
disable BRIDGETOWERS.
2011-04-12 21:51:32 +02:00
11ab95411e Reduce bridge tower materials from 400 to 300 hcms.
Bridge spans have been unable to produce enough avail for a tower with
default game configuration since we reduced their maximum population
in commit 6bbd7ffd, v4.3.6.  This commit reduces required avail from
160 to 120, fixing the stock game: 100 civilians and 100 uws can make
that much in a 60 ETU update.
2011-04-12 21:51:32 +02:00
a12a315cd9 Fix stop orders to expire even when the country is broke
Broken in commit 8da88626, v4.3.8.
2011-04-12 21:51:32 +02:00
d6cf175b0b Fix march and navigate not to interpret coordinates as path
Destination arguments can be a path or sector coordinates.
do_unit_move() passes the argument buffer to unit_path() to convert
coordinates to a path.  If unit_path() fails, do_unit_move() still
interprets the argument as path.

This is correct when unit_path() fails because the argument is not
coordinates.  But it can also fail when it is coordinates, namely when
the destination isn't reachable, when the path to it is too long, or
when the ships or land units aren't together.  Then do_unit_move()
interprets coordinates as path, and rejects them with "Legal
directions are:".

Except when a land unit's destination read from a march prompt isn't
reachable, because then unit_path() empties the argument buffer that
do_unit_move() uses.

Change unit_path() to succeed when the argument is not coordinates.
Make do_unit_move() discard the argument when unit_path() fails,
i.e. when it is bad coordinates.  unit_path() emptying the argument no
longer has an effect, drop it.
2011-04-12 21:51:32 +02:00