Simplify would_abandon()

This commit is contained in:
Markus Armbruster 2008-03-24 10:06:52 +01:00
parent a55f5d016f
commit f89a1a711b

View file

@ -367,30 +367,22 @@ want_to_abandon(struct sctstr *sp, i_type vtype, int amnt, struct lndstr *lp)
int int
would_abandon(struct sctstr *sp, i_type vtype, int amnt, struct lndstr *lp) 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; return 0;
mil = sp->sct_item[I_MILIT]; mil = sp->sct_item[I_MILIT];
civs = sp->sct_item[I_CIVIL]; loyalcivs = sp->sct_item[I_CIVIL];
if (vtype == I_MILIT) if (vtype == I_MILIT)
mil -= amnt; mil -= amnt;
if (vtype == I_CIVIL) if (vtype == I_CIVIL)
civs -= amnt; loyalcivs -= amnt;
if (sp->sct_own != sp->sct_oldown)
if (sp->sct_own == sp->sct_oldown)
loyalcivs = civs;
else
loyalcivs = 0; loyalcivs = 0;
/* If they have a military unit there, they still own it */ return sp->sct_own != 0
if (sp->sct_own != 0 && loyalcivs == 0 && mil == 0
&& ((loyalcivs == 0) && (mil == 0) && !has_units(sp->sct_x, sp->sct_y, sp->sct_own, lp);
&& (has_units(sp->sct_x, sp->sct_y, sp->sct_own, lp) == 0)))
return 1;
return 0;
} }