]> git.pond.sub.org Git - empserver/commitdiff
Capital obliteration failed to charge money and report news
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 15 Nov 2008 21:43:13 +0000 (16:43 -0500)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 15 Nov 2008 22:40:48 +0000 (17:40 -0500)
Commit 221e88f1 (v4.3.15) made caploss() expect the new owner in
sct_own, so it can distinguish between sack and obliteration.  Commit
0d139ee1 (v4.3.17) broke that in sct_prewrite(): it moved zapping the
sector owner after caploss(), and passed 0 instead of the old owner to
caploss().  Because of that, obliterating a capital didn't make the
news and didn't cost the victim money.  Fix that.

src/lib/subs/sect.c

index cae10971ffdb769d388220063031378be7386f39..1effb10407f46842271e2087e5caa70e30895dd9 100644 (file)
@@ -65,7 +65,7 @@ sct_prewrite(int id, void *old, void *new)
     struct sctstr *oldsp = old;
     struct sctstr *sp = new;
     int mil, civs;
-    natid own;
+    natid own, prev_own;
 
     bridge_damaged(sp);
     item_prewrite(sp->sct_item);
@@ -73,6 +73,7 @@ sct_prewrite(int id, void *old, void *new)
     mil = sp->sct_item[I_MILIT];
     civs = sp->sct_item[I_CIVIL];
     own = sp->sct_own;
+    prev_own = oldsp->sct_own;
 
     if (own && !civs) {
        sp->sct_work = 100;
@@ -82,18 +83,15 @@ sct_prewrite(int id, void *old, void *new)
     if (own && !civs && !mil && !has_units(sp->sct_x, sp->sct_y, own, NULL)
        && !(sp->sct_flags & MOVE_IN_PROGRESS)) {
        /* more cruft! */
-       own = 0;
+       own = sp->sct_own = 0;
        sp->sct_mobil = 0;
        if (sp->sct_type == SCT_CAPIT || sp->sct_type == SCT_MOUNT)
-           caploss(sp, own, "");
+           caploss(sp, prev_own, "");
     }
 
-    /* We've avoided assigning to sp->sct_own, in case oldsp == sp */
-    if (oldsp->sct_own != own)
-       lost_and_found(EF_SECTOR, oldsp->sct_own, own,
+    if (prev_own != own)
+       lost_and_found(EF_SECTOR, prev_own, own,
                       0, sp->sct_x, sp->sct_y);
-
-    sp->sct_own = own;
 }
 
 void