diff --git a/src/lib/commands/move.c b/src/lib/commands/move.c index e185b773..70602082 100644 --- a/src/lib/commands/move.c +++ b/src/lib/commands/move.c @@ -367,22 +367,19 @@ 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, loyalcivs; + int mil, civs; if (vtype != I_CIVIL && vtype != I_MILIT) return 0; mil = sp->sct_item[I_MILIT]; - loyalcivs = sp->sct_item[I_CIVIL]; + civs = sp->sct_item[I_CIVIL]; if (vtype == I_MILIT) mil -= amnt; if (vtype == I_CIVIL) - loyalcivs -= amnt; - if (sp->sct_own != sp->sct_oldown) - loyalcivs = 0; + civs -= amnt; - return sp->sct_own != 0 - && loyalcivs <= 0 && mil <= 0 + return sp->sct_own != 0 && civs <= 0 && mil <= 0 && !has_units(sp->sct_x, sp->sct_y, sp->sct_own, lp); } diff --git a/src/lib/subs/sect.c b/src/lib/subs/sect.c index f94dd0d4..1aef5baa 100644 --- a/src/lib/subs/sect.c +++ b/src/lib/subs/sect.c @@ -86,7 +86,7 @@ item_prewrite(short *item) static int checksect(struct sctstr *sp) { - int mil, civs, loyalcivs; + int mil, civs; natid own; item_prewrite(sp->sct_item); @@ -97,30 +97,22 @@ checksect(struct sctstr *sp) mil = sp->sct_item[I_MILIT]; civs = sp->sct_item[I_CIVIL]; - if (sp->sct_own == sp->sct_oldown) - loyalcivs = civs; - else - loyalcivs = 0; if (sp->sct_own != 0 && !civs) { sp->sct_work = 100; sp->sct_oldown = sp->sct_own; } - /* If they have a military unit there, they still own it */ - if (sp->sct_own && !loyalcivs && !(sp->sct_flags & MOVE_IN_PROGRESS)) { - if (!mil && !has_units(sp->sct_x, sp->sct_y, sp->sct_own, 0)) { - /* more cruft! */ - own = sp->sct_own; - if (sp->sct_oldown == sp->sct_own) { - makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y); - sp->sct_own = 0; - sp->sct_oldown = 0; - } else - takeover(sp, sp->sct_oldown); - sp->sct_mobil = 0; - if (sp->sct_type == SCT_CAPIT || sp->sct_type == SCT_MOUNT) - caploss(sp, own, ""); - } + + if (sp->sct_own && !civs && !mil + && !has_units(sp->sct_x, sp->sct_y, sp->sct_own, NULL) + && !(sp->sct_flags & MOVE_IN_PROGRESS)) { + /* more cruft! */ + own = sp->sct_own; + makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y); + sp->sct_own = 0; + sp->sct_mobil = 0; + if (sp->sct_type == SCT_CAPIT || sp->sct_type == SCT_MOUNT) + caploss(sp, own, ""); } return 1; }