]> git.pond.sub.org Git - empserver/commitdiff
(lnd_mar_one_sector): When units in different sectors march, only
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 22 Mar 2005 20:49:54 +0000 (20:49 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 22 Mar 2005 20:49:54 +0000 (20:49 +0000)
units in the sector with the highest-numbered unit were interdicted.
A marching non-spy made all marching spies visible to interdiction
regardless of location.  Interdict sector by sector, similar to
shp_nav_one_sector().  Interdict spies only if they are together with
non-spies in the same sector.

src/lib/subs/lndsub.c

index 33542e6a2b3cb4a6cfbce759b7c78111807fad66..ca38715bb6ddce1d94f53d0e519b5883746c9a7a 100644 (file)
@@ -1075,12 +1075,13 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
     struct emp_qelem *qp2;
     struct emp_qelem *next;
     struct llist *llp;
+    struct emp_qelem cur, done;
     coord dx;
     coord dy;
     coord newx;
     coord newy;
     int stopping = 0;
-    int visible = 0;
+    int visible;
     int stop;
     s_char dp[80];
     int rel;
@@ -1115,9 +1116,6 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
                continue;
            }
        }
-
-       if (!(lchr[(int)llp->land.lnd_type].l_flags & L_SPY))
-           visible = 1;
        if (sect.sct_rail == 0 &&
            lchr[(int)llp->land.lnd_type].l_flags & L_TRAIN) {
            if (together) {
@@ -1199,8 +1197,41 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
     stopping |= lnd_check_mines(list);
     if (QEMPTY(list))
        return stopping;
-    if (visible)
-       stopping |= lnd_interdict(list, newx, newy, actor);
+
+    /* interdict land units sector by sector */
+    emp_initque(&cur);
+    emp_initque(&done);
+    while (!QEMPTY(list)) {
+       llp = (struct llist *)list->q_back;
+       newx = llp->land.lnd_x;
+       newy = llp->land.lnd_y;
+       /* move units in NEWX,NEWY to cur */
+       visible = 0;
+       for (qp = list->q_back; qp != list; qp = next) {
+           next = qp->q_back;
+           llp = (struct llist *)qp;
+           if (llp->land.lnd_x == newx && llp->land.lnd_y == newy) {
+               emp_remque(qp);
+               emp_insque(qp, &cur);
+               if (!(lchr[(int)llp->land.lnd_type].l_flags & L_SPY))
+                   visible = 1;
+           }
+       }
+       /* interdict them */
+       if (visible)
+           stopping |= lnd_interdict(&cur, newx, newy, actor);
+       /* move survivors to done */
+       for (qp = cur.q_back; qp != &cur; qp = next) {
+           next = qp->q_back;
+           llp = (struct llist *)qp;
+           emp_remque(qp);
+           emp_insque(qp, &done);
+       }
+    }
+    /* assign surviving land units back to list */
+    emp_insque(list, &done);
+    emp_remque(&done);
+
     return stopping;
 }