]> git.pond.sub.org Git - empserver/commitdiff
Remove hard-coded differences between highways and bridge heads
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 12 Feb 2008 06:10:33 +0000 (07:10 +0100)
committerMarkus Armbruster <armbru@pike.pond.sub.org>
Wed, 7 May 2008 08:33:41 +0000 (10:33 +0200)
Let highways build and support bridges.  Allow bridge heads anywhere,
not just on the coast.

include/sect.h
src/lib/commands/buil.c
src/lib/commands/desi.c
src/lib/subs/bridgefall.c

index da0e9cb1c9bcca5049de3250be27eb64781657fc..60fb72b7ad05debb9ee66b411b40c2a3b2910e06 100644 (file)
@@ -170,6 +170,9 @@ extern struct dchrstr dchr[SCT_TYPE_MAX + 2];
 extern struct dchrstr bigcity_dchr;
 #define IS_BIG_CITY(type) (dchr[(type)].d_pkg == UPKG)
 
+#define IS_BRIDGE_HEAD(type) \
+    ((type) == SCT_BHEAD || (type) == SCT_HIWAY || (type) == SCT_BTOWER)
+
 /* Minimal efficiency of sectors that can be knocked down (bridges) */
 #define SCT_MINEFF 20
 
index c9ea788a34b6d56cba75c29cf6550fdaa3f26adf..bb3d2d6e826b7dafeddae1ccdb91572a27bfc87e 100644 (file)
@@ -528,12 +528,10 @@ build_bridge(struct sctstr *sp, short *vec)
     char buf[1024];
 
     if (opt_EASY_BRIDGES == 0) {       /* must have a bridge head or tower */
-       if (sp->sct_type != SCT_BTOWER) {
-           if (sp->sct_type != SCT_BHEAD)
-               return 0;
-           if (sp->sct_newtype != SCT_BHEAD)
-               return 0;
-       }
+       if (!IS_BRIDGE_HEAD(sp->sct_type))
+           return 0;
+       if (sp->sct_newtype != sp->sct_type)
+           return 0;
     }
 
     if (sp->sct_effic < 60 && !player->god) {
index cee4e2d83ede209cbb811c165dcef1f7d3231ab6..ce14be6152d149df70a531799fcab56f777754fb 100644 (file)
@@ -97,7 +97,7 @@ desi(void)
            continue;
        if (sect.sct_type == SCT_SANCT)
            breaksanct++;
-       if ((des == SCT_HARBR || des == SCT_BHEAD) && !sect.sct_coastal) {
+       if (des == SCT_HARBR && !sect.sct_coastal) {
            pr("%s does not border on water.\n",
               xyas(nstr.x, nstr.y, player->cnum));
            if (player->god)
@@ -129,11 +129,8 @@ desi(void)
        if (sect.sct_x == cap_x && sect.sct_y == cap_y
            && des != SCT_CAPIT && des != SCT_SANCT && des != SCT_MOUNT)
            pr("You have redesignated your capital!\n");
-       if (opt_EASY_BRIDGES == 0) {    /* may cause a bridge fall */
-           if (n != SCT_BHEAD)
-               continue;
+       if (!opt_EASY_BRIDGES && IS_BRIDGE_HEAD(n))
            bridgefall(&sect);
-       }
     }
     if (changed)
        writemap(player->cnum);
index f407f32f06c8607a716eb8c46eb96a728a78d866..624b0a957303b6d36212f6bc6e7a9322bbf05207 100644 (file)
@@ -70,7 +70,7 @@ bridge_damaged(struct sctstr *sp)
     des = sp->sct_type;
     if (des == SCT_BSPAN || des == SCT_BTOWER)
        knockdown(sp);
-    if ((des == SCT_BHEAD || des == SCT_BTOWER) && !opt_EASY_BRIDGES)
+    if (IS_BRIDGE_HEAD(des) && !opt_EASY_BRIDGES)
        bridgefall(sp);
 }
 
@@ -98,17 +98,16 @@ bridgefall(struct sctstr *sp)
            if (nnx == sp->sct_x && nny == sp->sct_y)
                continue;
            getsect(nnx, nny, &bh_sect);
-           if (bh_sect.sct_type == SCT_BHEAD &&
-               bh_sect.sct_newtype == SCT_BHEAD)
-               break;
-           if (bh_sect.sct_type == SCT_BTOWER)
-               break;
            /* With EASY_BRIDGES, it just has to be next to any
               land */
            if (opt_EASY_BRIDGES) {
                if (bh_sect.sct_type != SCT_WATER &&
                    bh_sect.sct_type != SCT_BSPAN)
                    break;
+           } else {
+               if (IS_BRIDGE_HEAD(bh_sect.sct_type)
+                   && bh_sect.sct_newtype == bh_sect.sct_type)
+                   break;
            }
        }
        if (j > 6) {