From: Ron Koenderink Date: Tue, 10 Oct 2006 20:23:19 +0000 (+0000) Subject: (switch_leader): Generalize the code, no functional changes. X-Git-Tag: v4.3.8~3 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=fd49704a7401f5a946755843d6549bb9950a2e48 (switch_leader): Generalize the code, no functional changes. (navi): Change switch_flagship() to call switch_leader() instead. (switch_flagship): Remove, not needed, replaced with switch_leader(). --- diff --git a/include/prototypes.h b/include/prototypes.h index 0060d462f..6d651e896 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -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 *); diff --git a/src/lib/commands/marc.c b/src/lib/commands/marc.c index 74f61729d..4d346ec40 100644 --- a/src/lib/commands/marc.c +++ b/src/lib/commands/marc.c @@ -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); } diff --git a/src/lib/commands/navi.c b/src/lib/commands/navi.c index ba576b9c1..b15f1d537 100644 --- a/src/lib/commands/navi.c +++ b/src/lib/commands/navi.c @@ -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); -} -