]> git.pond.sub.org Git - empserver/commitdiff
subs: Split unit_put() into shp_put() and lnd_put() again
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 25 Jan 2014 14:41:58 +0000 (15:41 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 17 Jan 2015 14:25:16 +0000 (15:25 +0100)
Commit d94d269 combined them into unit_put(), but that has turned out
not to be useful.  Split them again.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
include/land.h
include/ship.h
include/unit.h
src/lib/subs/attsub.c
src/lib/subs/lndsub.c
src/lib/subs/shpsub.c
src/lib/subs/unitsub.c
src/lib/update/sail.c

index 764bb1f843e0fb5aff43233921fdb7d270e1362f..261f2f05d7536f5e3f2069f0e7e10ba26c886d83 100644 (file)
@@ -187,6 +187,7 @@ extern void lnd_takemob(struct emp_qelem *, double);
 extern int lnd_spyval(struct lndstr *);
 extern void intelligence_report(int, struct lndstr *, int, char *);
 extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid);
+extern void lnd_put(struct emp_qelem *, natid);
 extern int lnd_hardtarget(struct lndstr *);
 extern int lnd_mar_one_sector(struct emp_qelem *, int, natid, int);
 extern int lnd_support(natid, natid, coord, coord, int);
index 4b952b6bf5b7b6fe15e67989e6823515e48cdac5..81c2f0868a3d470d53aac328b440798b18eece1d 100644 (file)
@@ -185,6 +185,7 @@ extern double shp_torp_hitchance(struct shpstr *, int);
 extern void shp_sel(struct nstr_item *, struct emp_qelem *);
 extern struct ulist *shp_insque(struct shpstr *, struct emp_qelem *);
 extern void shp_nav(struct emp_qelem *, double *, double *, int *, natid);
+extern void shp_put(struct emp_qelem *, natid);
 extern int shp_sweep(struct emp_qelem *, int, int, natid);
 extern enum d_navigation shp_check_nav(struct shpstr *, struct sctstr *);
 extern int sect_has_dock(struct sctstr *);
index 28ab3f9b30da649ba64ffa6b13199dd4bc308479..65f16c6d0e38e5160555bf09919a85dd8250e5bf 100644 (file)
@@ -58,7 +58,6 @@ extern void unit_onresize(int);
 
 extern char *unit_nameof(struct empobj *);
 extern void unit_list(struct emp_qelem *);
-extern void unit_put(struct emp_qelem *list, natid actor);
 extern char *unit_path(int, struct empobj *, char *, size_t);
 extern void unit_view(struct emp_qelem *);
 extern void unit_teleport(struct empobj *, coord, coord);
index 34f664cc8cc7804f7665379bcb5619dfe0f72bb8..d4405e2c7715519b39bd6cce057e9cb6542026af 100644 (file)
@@ -1959,7 +1959,7 @@ att_fight(int combat_mode, struct combat *off, struct emp_qelem *olist,
     send_reacting_units_home(dlist);
 
     /* putland the defending land */
-    unit_put(dlist, 0);
+    lnd_put(dlist, 0);
 
     /* putland the attacking land */
     put_oland(olist);
@@ -2340,7 +2340,7 @@ move_in_land(int combat_mode, struct combat *off, struct emp_qelem *olist,
     }
     if (QEMPTY(olist))
        return;
-    unit_put(olist, 0);
+    lnd_put(olist, 0);
 }
 
 /*
index 2aad16d6334d06f9d5e9f890e74c5ea1c5f15b94..66cae1ad3620c261b4475fc763f3c9d31f274eea 100644 (file)
@@ -531,6 +531,30 @@ lnd_mar(struct emp_qelem *list, double *minmobp, double *maxmobp,
     }
 }
 
+void
+lnd_put(struct emp_qelem *list, natid actor)
+{
+    struct emp_qelem *qp, *next;
+    struct ulist *llp;
+    struct lndstr *lp;
+
+    for (qp = list->q_back; qp != list; qp = next) {
+       next = qp->q_back;
+       llp = (struct ulist *)qp;
+       lp = &llp->unit.land;
+       if (actor) {
+           mpr(actor, "%s stopped at %s\n",
+               prland(lp), xyas(lp->lnd_x, lp->lnd_y, actor));
+           if (llp->mobil < -127)
+               llp->mobil = -127;
+           lp->lnd_mobil = llp->mobil;
+       }
+       putland(lp->lnd_uid, lp);
+       emp_remque(qp);
+       free(qp);
+    }
+}
+
 /*
  * Sweep landmines with engineers in LAND_LIST for ACTOR.
  * If EXPLICIT is non-zero, this is for an explicit sweep command from
@@ -927,7 +951,7 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
     int oldown;
 
     if (dir <= DIR_STOP || dir >= DIR_VIEW) {
-       unit_put(list, actor);
+       lnd_put(list, actor);
        return 1;
     }
     dx = diroff[dir][0];
index 577c5734a9b046bab3b8440e4c3983886c37171e..ffa06b20f03c22f959d8596ed4640a331c5bf872 100644 (file)
@@ -180,6 +180,26 @@ shp_nav(struct emp_qelem *list, double *minmobp, double *maxmobp,
     }
 }
 
+void
+shp_put(struct emp_qelem *list, natid actor)
+{
+    struct emp_qelem *qp, *next;
+    struct ulist *mlp;
+    struct shpstr *sp;
+
+    for (qp = list->q_back; qp != list; qp = next) {
+       next = qp->q_back;
+       mlp = (struct ulist *)qp;
+       sp = &mlp->unit.ship;
+       mpr(actor, "%s stopped at %s\n",
+           prship(sp), xyas(sp->shp_x, sp->shp_y, actor));
+       sp->shp_mobil = (int)mlp->mobil;
+       putship(sp->shp_uid, sp);
+       emp_remque(qp);
+       free(qp);
+    }
+}
+
 int
 shp_sweep(struct emp_qelem *ship_list, int verbose, int takemob, natid actor)
 {
@@ -759,7 +779,7 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor,
     int navigate;
 
     if (dir <= DIR_STOP || dir >= DIR_VIEW) {
-       unit_put(list, actor);
+       shp_put(list, actor);
        return 1;
     }
     dx = diroff[dir][0];
index a3e537bde4c0323f7608b520da6baeda31a9435b..7fecad51a16beef8127a3169e918a04e4750c6b1 100644 (file)
@@ -28,7 +28,7 @@
  *
  *  Known contributors to this file:
  *     Ron Koenderink, 2007
- *     Markus Armbruster, 2009-2013
+ *     Markus Armbruster, 2009-2014
  */
 
 #include <config.h>
@@ -116,40 +116,6 @@ unit_list(struct emp_qelem *unit_list)
     }
 }
 
-void
-unit_put(struct emp_qelem *list, natid actor)
-{
-    struct emp_qelem *qp;
-    struct emp_qelem *newqp;
-    struct ulist *ulp;
-    struct empobj *unit;
-
-    qp = list->q_back;
-    while (qp != list) {
-       ulp = (struct ulist *)qp;
-       unit = &ulp->unit.gen;
-       if (CANT_HAPPEN(unit->ef_type != EF_LAND
-                       && unit->ef_type != EF_SHIP))
-           continue;
-       if (actor) {
-           mpr(actor, "%s stopped at %s\n", unit_nameof(unit),
-               xyas(unit->x, unit->y, actor));
-           if (unit->ef_type == EF_LAND) {
-               if (ulp->mobil < -127)
-                   ulp->mobil = -127;
-               unit->mobil = ulp->mobil;
-           }
-       }
-       if (unit->ef_type == EF_SHIP)
-           unit->mobil = (int)ulp->mobil;
-       put_empobj(unit->ef_type, unit->uid, unit);
-       newqp = qp->q_back;
-       emp_remque(qp);
-       free(qp);
-       qp = newqp;
-    }
-}
-
 char *
 unit_path(int together, struct empobj *unit, char *buf, size_t bufsz)
 {
index 644086cfb51f029b7fc3b1e696058183f7edf48e..1d6a19846e11d5dcbe136205e0722e7c393240cf 100644 (file)
@@ -270,7 +270,7 @@ sail_nav_fleet(struct fltheadstr *fltp)
            fltp->maxmoves = 1;
        --fltp->maxmoves;
     }
-    unit_put(&ship_list, own);
+    shp_put(&ship_list, own);
     getship(sp->shp_uid, &ship);
     fltp->x = ship.shp_x;
     fltp->y = ship.shp_y;