]> git.pond.sub.org Git - empserver/commitdiff
subs: Clean up direction code range checks
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 4 Jan 2015 16:52:36 +0000 (17:52 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 28 Feb 2015 15:21:35 +0000 (16:21 +0100)
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 <armbru@pond.sub.org>
src/lib/subs/lndsub.c
src/lib/subs/shpsub.c

index 2f67863058f0208f3ec3bfcf6dbe87c65edfa577..db520020eecdedbf3f3f7f487148f5a9e089be60 100644 (file)
@@ -1021,7 +1021,8 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor)
     if (CANT_HAPPEN(QEMPTY(list)))
        return 1;
 
     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;
     }
        lnd_mar_put(list, actor);
        return 1;
     }
index 2182a4a25fcbb5526392467a966e9030573c9e8a..58262fdc942f8f8c8cdcf0506d5ecbb222f696a0 100644 (file)
@@ -796,7 +796,8 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor)
     if (CANT_HAPPEN(QEMPTY(list)))
        return 1;
 
     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;
     }
        shp_nav_put(list, actor);
        return 1;
     }