From bbacc2860670f46e26f0a2826edb2b77fd79d5a3 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 4 Jan 2015 17:52:36 +0100 Subject: [PATCH] subs: Clean up direction code range checks Compare with DIR_LAST instead of DIR_VIEW, to avoid assuming DIR_VIEW is the first non-direction code. While there, oops on unexpected code. Signed-off-by: Markus Armbruster --- src/lib/subs/lndsub.c | 3 ++- src/lib/subs/shpsub.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/subs/lndsub.c b/src/lib/subs/lndsub.c index 2f6786305..db520020e 100644 --- a/src/lib/subs/lndsub.c +++ b/src/lib/subs/lndsub.c @@ -1021,7 +1021,8 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor) if (CANT_HAPPEN(QEMPTY(list))) return 1; - if (dir <= DIR_STOP || dir >= DIR_VIEW) { + if (dir <= DIR_STOP || dir > DIR_LAST) { + CANT_HAPPEN(dir != DIR_STOP); lnd_mar_put(list, actor); return 1; } diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index 2182a4a25..58262fdc9 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -796,7 +796,8 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor) if (CANT_HAPPEN(QEMPTY(list))) return 1; - if (dir <= DIR_STOP || dir >= DIR_VIEW) { + if (dir <= DIR_STOP || dir > DIR_LAST) { + CANT_HAPPEN(dir != DIR_STOP); shp_nav_put(list, actor); return 1; } -- 2.43.0