diff --git a/include/land.h b/include/land.h index 764bb1f8..261f2f05 100644 --- a/include/land.h +++ b/include/land.h @@ -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); diff --git a/include/ship.h b/include/ship.h index 4b952b6b..81c2f086 100644 --- a/include/ship.h +++ b/include/ship.h @@ -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 *); diff --git a/include/unit.h b/include/unit.h index 28ab3f9b..65f16c6d 100644 --- a/include/unit.h +++ b/include/unit.h @@ -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); diff --git a/src/lib/subs/attsub.c b/src/lib/subs/attsub.c index 34f664cc..d4405e2c 100644 --- a/src/lib/subs/attsub.c +++ b/src/lib/subs/attsub.c @@ -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); } /* diff --git a/src/lib/subs/lndsub.c b/src/lib/subs/lndsub.c index 2aad16d6..66cae1ad 100644 --- a/src/lib/subs/lndsub.c +++ b/src/lib/subs/lndsub.c @@ -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]; diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index 577c5734..ffa06b20 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -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]; diff --git a/src/lib/subs/unitsub.c b/src/lib/subs/unitsub.c index a3e537bd..7fecad51 100644 --- a/src/lib/subs/unitsub.c +++ b/src/lib/subs/unitsub.c @@ -28,7 +28,7 @@ * * Known contributors to this file: * Ron Koenderink, 2007 - * Markus Armbruster, 2009-2013 + * Markus Armbruster, 2009-2014 */ #include @@ -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) { diff --git a/src/lib/update/sail.c b/src/lib/update/sail.c index 644086cf..1d6a1984 100644 --- a/src/lib/update/sail.c +++ b/src/lib/update/sail.c @@ -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;