assault: Simplify sneak_ashore()

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-07-23 17:36:09 +02:00
parent 97dd515378
commit d54b3f6da5

View file

@ -195,6 +195,7 @@ sneak_ashore(struct emp_qelem *olist, struct combat *def)
{ {
struct emp_qelem *qp, *next; struct emp_qelem *qp, *next;
struct ulist *llp; struct ulist *llp;
struct lndstr *lp;
int rel; int rel;
pr("Trying to sneak on shore...\n"); pr("Trying to sneak on shore...\n");
@ -202,32 +203,33 @@ sneak_ashore(struct emp_qelem *olist, struct combat *def)
for (qp = olist->q_forw; qp != olist; qp = next) { for (qp = olist->q_forw; qp != olist; qp = next) {
next = qp->q_forw; next = qp->q_forw;
llp = (struct ulist *)qp; llp = (struct ulist *)qp;
lp = &llp->unit.land;
rel = relations_with(def->own, player->cnum); rel = relations_with(def->own, player->cnum);
if (chance(0.10) || rel == ALLIED || !def->own) { if (chance(0.10) || rel == ALLIED || !def->own) {
pr("%s made it on shore safely.\n", prland(&llp->unit.land)); pr("%s made it on shore safely.\n", prland(lp));
llp->unit.land.lnd_x = def->x; lp->lnd_x = def->x;
llp->unit.land.lnd_y = def->y; lp->lnd_y = def->y;
llp->unit.land.lnd_ship = -1; lp->lnd_ship = -1;
putland(llp->unit.land.lnd_uid, &llp->unit.land); putland(lp->lnd_uid, lp);
} else { } else {
pr("%s was spotted", prland(&llp->unit.land)); pr("%s was spotted", prland(lp));
if (rel <= HOSTILE) { if (rel <= HOSTILE) {
wu(0, def->own, "%s spy shot and killed in %s.\n", wu(0, def->own, "%s spy shot and killed in %s.\n",
cname(player->cnum), xyas(def->x, def->y, cname(player->cnum), xyas(def->x, def->y,
def->own)); def->own));
pr(" and was killed in the attempt.\n"); pr(" and was killed in the attempt.\n");
llp->unit.land.lnd_effic = 0; lp->lnd_effic = 0;
putland(llp->unit.land.lnd_uid, &llp->unit.land); putland(lp->lnd_uid, lp);
lnd_put_one(llp); lnd_put_one(llp);
} else { } else {
wu(0, def->own, "%s spy spotted in %s.\n", wu(0, def->own, "%s spy spotted in %s.\n",
cname(player->cnum), xyas(def->x, def->y, cname(player->cnum), xyas(def->x, def->y,
def->own)); def->own));
pr(" but made it ok.\n"); pr(" but made it ok.\n");
llp->unit.land.lnd_x = def->x; lp->lnd_x = def->x;
llp->unit.land.lnd_y = def->y; lp->lnd_y = def->y;
llp->unit.land.lnd_ship = -1; lp->lnd_ship = -1;
putland(llp->unit.land.lnd_uid, &llp->unit.land); putland(lp->lnd_uid, lp);
} }
} }
} }