]> git.pond.sub.org Git - empserver/commitdiff
Path finding for trains never worked; it ignored the need for rail:
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 4 Jun 2006 17:27:17 +0000 (17:27 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 4 Jun 2006 17:27:17 +0000 (17:27 +0000)
(sector_mcost, bp_neighbors): Fix for MOB_RAIL and sct_rail == 0.
Closes #781528.

src/lib/common/move.c
src/lib/common/path.c

index 34df9b95a14325a6f3d077de40904acd6e2026a6..141accb5132ac481f34cb1cabda328e53795a7fa 100644 (file)
@@ -53,6 +53,8 @@ sector_mcost(struct sctstr *sp, int do_bonus)
     if (do_bonus == MOB_ROAD) {
        d = d / (1.0 + sp->sct_road / 122.0);
     } else if (do_bonus == MOB_RAIL) {
+       if (sp->sct_rail <= 0)
+           return -1.0;
        d = d / (1.0 + sp->sct_rail / 100.0);
     } else {
        if (d < 2.0)
index aa5a2512182111c404fd0793888676f29d054db7..ab4604ad33cad535f3423ce55ba5c0f007d9e252 100644 (file)
@@ -182,6 +182,7 @@ static int
 bp_neighbors(struct as_coord c, struct as_coord *cp, void *pp)
 {
     struct sctstr *sectp = (void *)empfile[EF_SECTOR].cache;
+    struct bestp *bp = pp;
     coord x, y;
     coord nx, ny;
     int n = 0, q;
@@ -220,6 +221,8 @@ bp_neighbors(struct as_coord c, struct as_coord *cp, void *pp)
           move through it.  We calculate it later. */
        if (dchr[sp->sct_type].d_mcst == 0)
            continue;
+       if (bp->bp_mobtype == MOB_RAIL && sp->sct_rail == 0)
+           continue;
        if (sp->sct_own != from->sct_own)
            continue;
        cp[n].x = sx;