]> git.pond.sub.org Git - empserver/commit
Fix march and navigate not to interpret coordinates as path
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 27 Mar 2011 15:55:35 +0000 (17:55 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 12 Apr 2011 19:51:32 +0000 (21:51 +0200)
commitd6cf175b0b972bbfe6a138fc6dc9082da9501f69
tree41b03ee6f1931e4af7c74f93f77e52113587ce48
parent74b08563af23d4addf34852bd06bd27569b4934b
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.
src/lib/commands/navi.c
src/lib/subs/unitsub.c