From f89a1a711bb8e2c00a2da778c7d16f8dae881915 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 24 Mar 2008 10:06:52 +0100 Subject: [PATCH] Simplify would_abandon() --- src/lib/commands/move.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/lib/commands/move.c b/src/lib/commands/move.c index 3d829688c..8022791fd 100644 --- a/src/lib/commands/move.c +++ b/src/lib/commands/move.c @@ -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); } -- 2.43.0