]> git.pond.sub.org Git - empserver/commitdiff
Fix attack when attacking sector gets taken by ally
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 20 Jan 2011 06:49:44 +0000 (07:49 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 13 Feb 2011 15:03:34 +0000 (16:03 +0100)
When an attacking sector got lost while the player was at a prompt,
and the new owner was allied to the player, the server got confused:

1. If the sector attacked with mil, the server let the ghost mil
attack, but not occupy.

2. If the sector was allied, the server reported the sector loss and
land units dropping out of the attack, but claimed the lost sector was
yours.

Fix 1. by dropping sectors from attack when they change owner away
from the player, regardless of relations.  Side effect: also drops any
surviving land units there.  Before, they dropped out only if the new
owner wasn't allied to the player.  That change's okay.

Fix 2. the obvious way: change the messages.

Broken in 4.0.0.

src/lib/subs/attsub.c

index e2651352d467317be78578cd058db97a7e1e6494..4c2f7ed226e5ae8d7546c70b79ac80c1585442eb 100644 (file)
@@ -285,16 +285,15 @@ att_get_combat(struct combat *com, int isdef)
                   mil);
            com->troops = mil;
        } else {                /* attacker */
-           if (owner != player->cnum
-               && getrel(getnatp(owner), player->cnum) != ALLIED) {
+           if (owner != com->own && owner != player->cnum) {
                /* must be EF_SECTOR */
-               if (com->mil)
+               if (com->troops)
                    pr("WARNING: Your %d mil in %s were destroyed because %s just took the sector!\n",
                       com->mil, xyas(com->x, com->y, player->cnum),
                       cname(owner));
                else
-                   pr("You no longer own %s\n",
-                      xyas(com->x, com->y, player->cnum));
+                   pr("%s just took %s!\n",
+                      cname(owner), xyas(com->x, com->y, player->cnum));
                return att_combat_init(com, EF_BAD);
            }
            if (com->troops && com->troops + 1 > mil) {
@@ -1272,7 +1271,7 @@ get_ototal(int combat_mode, struct combat *off, struct emp_qelem *olist,
            }
            if (w < 0) {
                lnd_print(player->cnum, llp,
-                         "is in a sector not owned by you");
+                         "can't attack from this sector now");
                lnd_delete(llp);
                continue;
            }