]> git.pond.sub.org Git - empserver/commitdiff
assault: Simplify sneak_ashore()
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 23 Jul 2016 15:36:09 +0000 (17:36 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 18:09:18 +0000 (20:09 +0200)
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/commands/assa.c

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