]> git.pond.sub.org Git - empserver/commitdiff
(switch_leader): Generalize the code, no functional changes.
authorRon Koenderink <rkoenderink@yahoo.ca>
Tue, 10 Oct 2006 20:23:19 +0000 (20:23 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Tue, 10 Oct 2006 20:23:19 +0000 (20:23 +0000)
(navi): Change switch_flagship() to call switch_leader() instead.
(switch_flagship): Remove, not needed, replaced with switch_leader().

include/prototypes.h
src/lib/commands/marc.c
src/lib/commands/navi.c

index 0060d462fbea45b3ad5177f33f2837946707fa32..6d651e896e2d2c6f5d41db472c029156aa84af95 100644 (file)
@@ -62,6 +62,7 @@ extern int display_mark(i_type, int);
 extern int want_to_abandon(struct sctstr *, i_type, int, struct lndstr *);
 extern int would_abandon(struct sctstr *, i_type, int, struct lndstr *);
 extern int nav_map(int, int, int);
+extern void switch_leader(struct emp_qelem *list, int uid);
 extern int count_pop(int);
 extern int scuttle_tradeship(struct shpstr *, int);
 extern void scuttle_ship(struct shpstr *);
index 74f61729d5e7d88263bb6734cf8a7795437e344a..4d346ec40244167a44f7255c55e0e4fc94d56c82 100644 (file)
@@ -43,7 +43,6 @@
 #include "unit.h"
 
 static int set_leader(struct emp_qelem *list, struct lndstr **leaderp);
-static void switch_leader(struct emp_qelem *list, int land_uid);
 
 int
 march(void)
@@ -201,11 +200,11 @@ set_leader(struct emp_qelem *list, struct lndstr **leaderp)
     return 1;
 }
 
-static void
-switch_leader(struct emp_qelem *list, int land_uid)
+void
+switch_leader(struct emp_qelem *list, int uid)
 {
     struct emp_qelem *qp, *save;
-    struct ulist *llp;
+    struct ulist *ulp;
 
     if (QEMPTY(list))
        return;
@@ -215,8 +214,8 @@ switch_leader(struct emp_qelem *list, int land_uid)
         emp_remque(qp);
         emp_insque(qp, list);
         qp = list->q_back;
-        llp = (struct ulist *)qp;
-        if (llp->unit.land.lnd_uid == land_uid || land_uid == -1)
+        ulp = (struct ulist *)qp;
+        if (ulp->unit.gen.uid == uid || uid == -1)
             break;
     } while (list->q_back != save);
 }
index ba576b9c19b94b38a61c9128f9d1f46ea06125e9..b15f1d537b04df7a1600147eb26b67efea4ae637 100644 (file)
@@ -42,7 +42,6 @@
 #include "unit.h"
 
 static int set_flagship(struct emp_qelem *list, struct shpstr **flagshipp);
-static void switch_flagship(struct emp_qelem *list, int ship_uid);
 
 int
 navi(void)
@@ -168,9 +167,9 @@ navi(void)
            break;
        case 'f':
            if (ac <= 1) 
-               switch_flagship(&ship_list, -1);
+               switch_leader(&ship_list, -1);
            else
-               switch_flagship(&ship_list, atoi(player->argp[1]));
+               switch_leader(&ship_list, atoi(player->argp[1]));
            set_flagship(&ship_list, &shp);
            break;
        case 'i':
@@ -301,24 +300,3 @@ set_flagship(struct emp_qelem *list, struct shpstr **flagshipp)
     pr("%s\n", prship(&mlp->unit.ship));
     return 1;
 }
-
-static void
-switch_flagship(struct emp_qelem *list, int ship_uid)
-{
-    struct emp_qelem *qp, *save;
-    struct ulist *mlp;
-
-    if (QEMPTY(list))
-       return;
-
-    save = qp = list->q_back;
-    do {
-        emp_remque(qp);
-        emp_insque(qp, list);
-        qp = list->q_back;
-        mlp = (struct ulist *)qp;
-        if (mlp->unit.ship.shp_uid == ship_uid || ship_uid == -1)
-            break;
-    } while (list->q_back != save);
-}
-