]> git.pond.sub.org Git - empserver/commitdiff
Simplify would_abandon()
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 24 Mar 2008 09:06:52 +0000 (10:06 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 26 Mar 2008 21:10:28 +0000 (22:10 +0100)
src/lib/commands/move.c

index 3d829688ce3fbadb0c6159b603c843db45e2eac7..8022791fd017abec5f63631b8781d245cfbe08e8 100644 (file)
@@ -367,30 +367,22 @@ want_to_abandon(struct sctstr *sp, i_type vtype, int amnt, struct lndstr *lp)
 int
 would_abandon(struct sctstr *sp, i_type vtype, int amnt, struct lndstr *lp)
 {
-    int mil, civs, loyalcivs;
+    int mil, loyalcivs;
 
-    if ((vtype != I_CIVIL) && (vtype != I_MILIT))
+    if (vtype != I_CIVIL && vtype != I_MILIT)
        return 0;
 
     mil = sp->sct_item[I_MILIT];
-    civs = sp->sct_item[I_CIVIL];
+    loyalcivs = sp->sct_item[I_CIVIL];
 
     if (vtype == I_MILIT)
        mil -= amnt;
-
     if (vtype == I_CIVIL)
-       civs -= amnt;
-
-    if (sp->sct_own == sp->sct_oldown)
-       loyalcivs = civs;
-    else
+       loyalcivs -= amnt;
+    if (sp->sct_own != sp->sct_oldown)
        loyalcivs = 0;
 
-    /* If they have a military unit there, they still own it */
-    if (sp->sct_own != 0
-       && ((loyalcivs == 0) && (mil == 0)
-           && (has_units(sp->sct_x, sp->sct_y, sp->sct_own, lp) == 0)))
-       return 1;
-
-    return 0;
+    return sp->sct_own != 0
+       && loyalcivs == 0 && mil == 0
+       && !has_units(sp->sct_x, sp->sct_y, sp->sct_own, lp);
 }