diff --git a/include/land.h b/include/land.h index 4dbc2d03..336ea2dc 100644 --- a/include/land.h +++ b/include/land.h @@ -180,7 +180,6 @@ extern double attack_val(int, struct lndstr *); extern double defense_val(struct lndstr *); extern int lnd_reaction_range(struct lndstr *); extern void lnd_print(natid, struct ulist *, char *); -extern void lnd_delete(struct ulist *); extern int lnd_take_casualty(int, struct ulist *, int); extern void lnd_submil(struct lndstr *, int); extern void lnd_takemob(struct emp_qelem *, double); @@ -189,6 +188,7 @@ extern void intelligence_report(int, struct lndstr *, int, char *); extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid); extern void lnd_mar_put(struct emp_qelem *, natid); extern void lnd_put(struct emp_qelem *); +extern void lnd_put_one(struct ulist *); 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/src/lib/commands/assa.c b/src/lib/commands/assa.c index 7c4aa152..2b3164cb 100644 --- a/src/lib/commands/assa.c +++ b/src/lib/commands/assa.c @@ -176,7 +176,7 @@ assa(void) pr(" and was killed in the attempt.\n"); llp->unit.land.lnd_effic = 0; putland(llp->unit.land.lnd_uid, &llp->unit.land); - lnd_delete(llp); + lnd_put_one(llp); } else { wu(0, def->own, "%s spy spotted in %s.\n", cname(player->cnum), xyas(def->x, def->y, diff --git a/src/lib/subs/attsub.c b/src/lib/subs/attsub.c index af3df3a6..9640f10e 100644 --- a/src/lib/subs/attsub.c +++ b/src/lib/subs/attsub.c @@ -1246,7 +1246,7 @@ get_ototal(int combat_mode, struct combat *off, struct emp_qelem *olist, if (w < 0) { lnd_print(player->cnum, llp, "can't attack from this sector now"); - lnd_delete(llp); + lnd_put_one(llp); continue; } ototal += attack_val(combat_mode, &llp->unit.land) * @@ -1312,7 +1312,7 @@ get_oland(int combat_mode, struct ulist *llp) sprintf(buf, "was destroyed and is no longer a part of the %s", att_mode[combat_mode]); lnd_print(player->cnum, llp, buf); - lnd_delete(llp); + lnd_put_one(llp); return 0; } if (lp->lnd_x != llp->x || lp->lnd_y != llp->y) { @@ -1320,7 +1320,7 @@ get_oland(int combat_mode, struct ulist *llp) "left to fight another battle and is no longer a part of the %s", att_mode[combat_mode]); lnd_print(player->cnum, llp, buf); - lnd_delete(llp); + lnd_put_one(llp); return 0; } if (lp->lnd_effic < llp->eff) { @@ -1344,13 +1344,13 @@ get_dland(struct combat *def, struct ulist *llp) if (lp->lnd_effic < LAND_MINEFF) { sprintf(buf, "was destroyed and is no longer a part of the defense"); lnd_print(llp->unit.land.lnd_own, llp, buf); - lnd_delete(llp); + lnd_put_one(llp); return 0; } if (lp->lnd_x != def->x || lp->lnd_y != def->y) { lnd_print(llp->unit.land.lnd_own, llp, "left to go fight another battle and is no longer a part of the defense"); - lnd_delete(llp); + lnd_put_one(llp); return 0; } @@ -1371,7 +1371,7 @@ kill_land(struct emp_qelem *list) llp->unit.land.lnd_effic = 0; lnd_print(player->cnum, llp, "cannot return to the ship, and dies!"); - lnd_delete(llp); + lnd_put_one(llp); } } } @@ -2110,7 +2110,7 @@ send_reacting_units_home(struct emp_qelem *list) llp->unit.land.lnd_x = llp->x; llp->unit.land.lnd_y = llp->y; lnd_print(llp->unit.land.lnd_own, llp, buf); - lnd_delete(llp); + lnd_put_one(llp); } } } @@ -2190,7 +2190,7 @@ take_def(int combat_mode, struct emp_qelem *list, struct combat *off, sprintf(buf, "moves in to occupy %s", xyas(def->x, def->y, player->cnum)); lnd_print(player->cnum, llp, buf); - lnd_delete(llp); + lnd_put_one(llp); } } } @@ -2212,7 +2212,7 @@ take_def(int combat_mode, struct emp_qelem *list, struct combat *off, putland(land.lnd_uid, &land); } if (delete_me) - lnd_delete(delete_me); + lnd_put_one(delete_me); att_get_combat(def, 0); return 1; } @@ -2272,7 +2272,7 @@ ask_move_in(struct combat *off, struct emp_qelem *olist, xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y, player->cnum)); lnd_print(player->cnum, llp, buf); - lnd_delete(llp); + lnd_put_one(llp); } if (QEMPTY(olist)) return; @@ -2286,7 +2286,7 @@ ask_move_in(struct combat *off, struct emp_qelem *olist, xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y, player->cnum)); lnd_print(player->cnum, llp, buf); - lnd_delete(llp); + lnd_put_one(llp); } return; } diff --git a/src/lib/subs/lndsub.c b/src/lib/subs/lndsub.c index 9183d0aa..3b25ff0c 100644 --- a/src/lib/subs/lndsub.c +++ b/src/lib/subs/lndsub.c @@ -145,14 +145,6 @@ lnd_print(natid actor, struct ulist *llp, char *s) wu(0, actor, "%s %s\n", prland(&llp->unit.land), s); } -void -lnd_delete(struct ulist *llp) -{ - putland(llp->unit.land.lnd_uid, &llp->unit.land); - emp_remque(&llp->queue); - free(llp); -} - int lnd_take_casualty(int combat_mode, struct ulist *llp, int cas) /* attacking or assaulting or paratrooping? */ @@ -190,7 +182,7 @@ lnd_take_casualty(int combat_mode, struct ulist *llp, int cas) xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y, llp->unit.land.lnd_own)); lnd_print(llp->unit.land.lnd_own, llp, buf); - lnd_delete(llp); + lnd_put_one(llp); /* Since we killed the unit, we killed all the mil on it */ return taken; } else { @@ -264,7 +256,7 @@ lnd_take_casualty(int combat_mode, struct ulist *llp, int cas) llp->unit.land.lnd_effic, xyas(bx, by, llp->unit.land.lnd_own)); lnd_print(llp->unit.land.lnd_own, llp, buf); - lnd_delete(llp); + lnd_put_one(llp); } } else { /* attacking from a sector */ sprintf(buf, "leaves the battlefield at %d%% efficiency", @@ -275,7 +267,7 @@ lnd_take_casualty(int combat_mode, struct ulist *llp, int cas) llp->unit.land.lnd_mobil -= (int)llp->mobil; llp->mobil = 0.0; lnd_print(llp->unit.land.lnd_own, llp, buf); - lnd_delete(llp); + lnd_put_one(llp); } } if (nowhere_to_go) { @@ -286,7 +278,7 @@ lnd_take_casualty(int combat_mode, struct ulist *llp, int cas) if (llp->unit.land.lnd_effic < LAND_MINEFF) { lnd_print(llp->unit.land.lnd_own, llp, "has nowhere to retreat, and dies!"); - lnd_delete(llp); + lnd_put_one(llp); } else lnd_print(llp->unit.land.lnd_own, llp, "has nowhere to retreat and takes extra losses!"); @@ -568,6 +560,14 @@ lnd_put(struct emp_qelem *list) } } +void +lnd_put_one(struct ulist *llp) +{ + putland(llp->unit.land.lnd_uid, &llp->unit.land); + emp_remque(&llp->queue); + free(llp); +} + /* * Sweep landmines with engineers in LAND_LIST for ACTOR. * If EXPLICIT is non-zero, this is for an explicit sweep command from @@ -695,7 +695,7 @@ lnd_stays(natid actor, char *str, struct ulist *llp) if (llp->mobil < -127) llp->mobil = -127; llp->unit.land.lnd_mobil = llp->mobil; - lnd_delete(llp); + lnd_put_one(llp); } static int @@ -1059,7 +1059,7 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor, prland(&llp->unit.land)); llp->unit.land.lnd_effic = 0; putland(llp->unit.land.lnd_uid, &llp->unit.land); - lnd_delete(llp); + lnd_put_one(llp); } } }