]> git.pond.sub.org Git - empserver/commitdiff
New concept sector terrain
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 13 Feb 2008 19:54:08 +0000 (20:54 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 28 Oct 2008 23:35:51 +0000 (19:35 -0400)
A sector type's terrain (struct dchrstr member d_terrain) is the
sector type of its underlying terrain.  Sector types occuring in
d_terrain are terrain types, and must have their own type in
d_terrain.  Players can change sector types only to those with the
same terrain.

The builtin configuration defines terrain types sea, mountain,
wasteland, wilderness and plains.  It gives bridge span and tower
terrain sea, and everything else terrain wilderness.  Hence, the stock
game remains unchanged.

Deities can use terrain to create sector types that can be developed
only in limited ways.

include/sect.h
src/lib/commands/add.c
src/lib/commands/desi.c
src/lib/common/nsc.c
src/lib/global/sect.config

index d0f14bfe3bb5aa56193036db456fe59aa1f20ce5..2c682961689f500b3bc218356b9274431800c074 100644 (file)
@@ -103,6 +103,7 @@ enum d_navigation {
 struct dchrstr {
     unsigned char d_uid;
     char d_mnem;               /* map symbol */
 struct dchrstr {
     unsigned char d_uid;
     char d_mnem;               /* map symbol */
+    unsigned char d_terrain;   /* terrain sector type */
     int d_prd;                 /* product type */
     int d_peffic;              /* process efficiency, in percent */
     float d_mob0, d_mob1;      /* movement cost at 0 and 100% eff */
     int d_prd;                 /* product type */
     int d_peffic;              /* process efficiency, in percent */
     float d_mob0, d_mob1;      /* movement cost at 0 and 100% eff */
index 1ecd94e20d7b7e1047139b9abb7ded4457424612..a0add70016cc6f15ee8a0dae49c21c3b42991435 100644 (file)
@@ -154,13 +154,8 @@ add(void)
                sect.sct_defense = 0;
                sect.sct_own = 0;
                sect.sct_oldown = 0;
                sect.sct_defense = 0;
                sect.sct_own = 0;
                sect.sct_oldown = 0;
-               if (sect.sct_type == SCT_BSPAN ||
-                   sect.sct_type == SCT_BTOWER)
-                   sect.sct_newtype = sect.sct_type = SCT_WATER;
-               else if (sect.sct_type != SCT_MOUNT &&
-                   sect.sct_type != SCT_PLAINS)
-                   sect.sct_newtype = sect.sct_type = SCT_RURAL;
-               /* No dist path */
+               sect.sct_newtype = sect.sct_type
+                   = dchr[sect.sct_type].d_terrain;
                sect.sct_dist_x = sect.sct_x;
                sect.sct_dist_y = sect.sct_y;
                memset(sect.sct_item, 0, sizeof(sect.sct_item));
                sect.sct_dist_x = sect.sct_x;
                sect.sct_dist_y = sect.sct_y;
                memset(sect.sct_item, 0, sizeof(sect.sct_item));
index 3d095469d677f4d3e78f166b873e75f83c9978a7..c320a7a1bd58d9c01ed0fdf594fc4a529156bd31 100644 (file)
@@ -96,6 +96,11 @@ desi(void)
                rc = RET_FAIL;
                break;
            }
                rc = RET_FAIL;
                break;
            }
+           if (dchr[des].d_terrain != dchr[sect.sct_type].d_terrain) {
+               pr("You can't change a %s into a %s\n",
+                  dchr[sect.sct_type].d_name, dchr[des].d_name);
+               continue;
+           }
        }
        if (sect.sct_type == des && sect.sct_newtype == des)
            continue;
        }
        if (sect.sct_type == des && sect.sct_newtype == des)
            continue;
index 8dfacecffac58fd36b086da39b8cbe152b357861..15e7d8099273ce666b1724f4d63e89c50983bcb5 100644 (file)
@@ -185,6 +185,7 @@ struct castr dchr_ca[] = {
     {"uid", fldoff(d_uid), NSC_UCHAR, 0, NULL, EF_SECTOR_CHR, 0},
     {"name", fldoff(d_name), NSC_STRING, 0, NULL, EF_BAD, 0},
     {"mnem", fldoff(d_mnem), NSC_STRINGY, 1, NULL, EF_BAD, NSC_CONST},
     {"uid", fldoff(d_uid), NSC_UCHAR, 0, NULL, EF_SECTOR_CHR, 0},
     {"name", fldoff(d_name), NSC_STRING, 0, NULL, EF_BAD, 0},
     {"mnem", fldoff(d_mnem), NSC_STRINGY, 1, NULL, EF_BAD, NSC_CONST},
+    {"terrain", fldoff(d_terrain), NSC_UCHAR, 0, NULL, EF_SECTOR_CHR, 0},
     {"prd", fldoff(d_prd), NSC_INT, 0, NULL, EF_PRODUCT, 0},
     {"peffic", fldoff(d_peffic), NSC_INT, 0, NULL, EF_BAD, 0},
     {"mob0", fldoff(d_mob0), NSC_FLOAT, 0, NULL, EF_BAD, 0},
     {"prd", fldoff(d_prd), NSC_INT, 0, NULL, EF_PRODUCT, 0},
     {"peffic", fldoff(d_peffic), NSC_INT, 0, NULL, EF_BAD, 0},
     {"mob0", fldoff(d_mob0), NSC_FLOAT, 0, NULL, EF_BAD, 0},
index 2e4032fd1b15c62edaf80408b7b6237041560e8a..4608ce6e1dbdc8331cf7608aefce5e151ea88227 100644 (file)
@@ -28,7 +28,7 @@
 #   sect.config: Sector characteristics
 #
 #   Known contributors to this file:
 #   sect.config: Sector characteristics
 #
 #   Known contributors to this file:
-#      Markus Armbruster, 2006
+#      Markus Armbruster, 2006-2008
 #
 #   Derived from sect.c; known contributors:
 #      Dave Pare, 1986
 #
 #   Derived from sect.c; known contributors:
 #      Dave Pare, 1986
 #      Steve McClure, 1998
 #
 
 #      Steve McClure, 1998
 #
 
+# Sector terrain (column terra) is the uid of the underlying terrain
+# sector type.  Sector types that occur in that column are terrain
+# types, and must have themselves as terrain.
+
 # Available products (column prd) are in product.config.  Navigation
 # types (column nav) are in sector_navigation[].  Packing types
 # (column pkg) are in packing[].
 
 # Players can only designate sectors with a non-negative value in
 # Available products (column prd) are in product.config.  Navigation
 # types (column nav) are in sector_navigation[].  Packing types
 # (column pkg) are in packing[].
 
 # Players can only designate sectors with a non-negative value in
-# column cost.  All such sectors should have the same population limit
-# (column maxp), or else players can abuse redesignation to
-# mass-murder people.
+# column cost, and only to something with the same terrain.  All
+# sectors with the same terrain and non-negative cost should have the
+# same population limit (column maxp), or else players can abuse
+# redesignation to mass-murder people.
 
 # A sector with urban packing (urba in column pkg) is a big city.
 # Column maxp applies at 0% efficiency.  The limit at 100% is ten
 
 # A sector with urban packing (urba in column pkg) is a big city.
 # Column maxp applies at 0% efficiency.  The limit at 100% is ten
 # econfig key custom_tables.
 
 config sect-chr
 # econfig key custom_tables.
 
 config sect-chr
-uid mnem  prd peff mob0 mob1  nav  pkg ostr dstr val cost bui lcm hcm maxp name
-  0  "."   -1    0   -1   -1  sea norm  0.0  0.0   0   -1   0   0   0    0 "sea"
-  1  "^" dust   75  2.4  1.2 land norm  1.0  4.0   5   -1   1   0   0  100 "mountain"
-  2  "s"   -1    0   -1   -1 land norm  0.0 99.0 127   -1   0   0   0 1000 "sanctuary"
-  3 "\134" -1    0   -1   -1 land norm  0.0 99.0   0   -1   0   0   0    0 "wasteland"
-  4  "-"   -1    0  0.4  0.4 land norm  1.0  2.0   1    0   0   0   0 1000 "wilderness"
+uid mnem terra prd peff mob0 mob1  nav  pkg ostr dstr val cost bui lcm hcm maxp name
+  0  "."    0   -1    0   -1   -1  sea norm  0.0  0.0   0   -1   0   0   0    0 "sea"
+  1  "^"    1 dust   75  2.4  1.2 land norm  1.0  4.0   5   -1   1   0   0  100 "mountain"
+  2  "s"    4   -1    0   -1   -1 land norm  0.0 99.0 127   -1   0   0   0 1000 "sanctuary"
+  3 "\134"  3   -1    0   -1   -1 land norm  0.0 99.0   0   -1   0   0   0    0 "wasteland"
+  4  "-"    4   -1    0  0.4  0.4 land norm  1.0  2.0   1    0   0   0   0 1000 "wilderness"
 # Uncomment one of the following two.  The second one is for big cities.
 # Uncomment one of the following two.  The second one is for big cities.
-  5  "c"   -1    0  0.4  0.2 land norm  1.0  2.0  30    0   1   0   0 1000 "capital"
-# 5  "c"   -1    0  0.4  0.2 cana urba  1.0  2.0  30    0  10   1   2 1000 "city"
-  6  "u"  rad  100  0.4  0.2 land norm  1.0  2.0  15    0   1   0   0 1000 "uranium mine"
-  7  "p"  hap  100  0.4  0.2 land norm  1.0  1.5   5    0   1   0   0 1000 "park"
-  8  "d"  gun  100  0.4  0.2 land norm  1.0  1.5   7    0   1   0   0 1000 "defense plant"
-  9  "i"   sh  100  0.4  0.2 land norm  1.0  1.5   6    0   1   0   0 1000 "shell industry"
- 10  "m" iron  100  0.4  0.2 land norm  1.0  2.0   5    0   1   0   0 1000 "mine"
- 11  "g" dust  100  0.4  0.2 land norm  1.0  2.0   8    0   1   0   0 1000 "gold mine"
- 12  "h"   -1    0  0.4  0.2 harb ware  1.0  1.5  12    0   1   0   0 1000 "harbor"
- 13  "w"   -1    0  0.4  0.2 land ware  1.0  1.5   7    0   1   0   0 1000 "warehouse"
- 14  "*"   -1    0  0.4  0.2 land norm  1.0  1.25 12    0   1   0   0 1000 "airfield"
- 15  "a" food  900  0.4  0.2 land norm  1.0  1.5   2    0   1   0   0 1000 "agribusiness"
- 16  "o"  oil  100  0.4  0.2 land norm  1.0  1.5   5    0   1   0   0 1000 "oil field"
- 17  "j"  lcm  100  0.4  0.2 land norm  1.0  1.5   3    0   1   0   0 1000 "light manufacturing"
- 18  "k"  hcm  100  0.4  0.2 land norm  1.0  1.5   4    0   1   0   0 1000 "heavy manufacturing"
- 19  "f"   -1    0  0.4  0.2 land norm  2.0  4.0  10    0   5   0   1 1000 "fortress"
- 20  "t" tech  100  0.4  0.2 land norm  1.0  1.5  10    0   1   0   0 1000 "technical center"
- 21  "r"  med  100  0.4  0.2 land norm  1.0  1.5   9    0   1   0   0 1000 "research lab"
- 22  "n"   -1    0  0.4  0.2 land norm  1.0  2.0  10    0   1   0   0 1000 "nuclear plant"
- 23  "l"  edu  100  0.4  0.2 land norm  1.0  1.5   4    0   1   0   0 1000 "library/school"
- 24  "+"   -1    0  0.4  0.0 land norm  1.0  1.0   3    0   1   0   0 1000 "highway"
- 25  ")"   -1    0  0.4  0.2 land norm  1.0  1.5   4    0   1   0   0 1000 "radar installation"
- 26  "!"   -1    0  0.4  0.2 land norm  1.0  1.5  12    0   1   0   0 1000 "headquarters"
- 27  "#"   -1    0  0.4  0.0 land norm  1.0  1.0   3    0   1   0   0 1000 "bridge head"
- 28  "="   -1    0  0.4  0.0 brid norm  1.0  1.0   5   -1   1   0   0  100 "bridge span"
- 29  "b" bars  100  0.4  0.2 land bank  1.0  2.25 10    0   1   0   0 1000 "bank"
- 30  "%"  pet 1000  0.4  0.2 land norm  1.0  1.5   2    0   1   0   0 1000 "refinery"
- 31  "e"   -1    0  0.4  0.2 land norm  1.0  2.0   7    0   1   0   0 1000 "enlistment center"
- 32  "~"   -1    0  0.4  0.2 land norm  1.0  1.5   1   -1   1   0   0  100 "plains"
- 33  "@"   -1    0  0.4  0.0 land norm  1.0  1.5   4   -1   1   0   0  100 "bridge tower"
+  5  "c"    4   -1    0  0.4  0.2 land norm  1.0  2.0  30    0   1   0   0 1000 "capital"
+# 5  "c"    4   -1    0  0.4  0.2 cana urba  1.0  2.0  30    0  10   1   2 1000 "city"
+  6  "u"    4  rad  100  0.4  0.2 land norm  1.0  2.0  15    0   1   0   0 1000 "uranium mine"
+  7  "p"    4  hap  100  0.4  0.2 land norm  1.0  1.5   5    0   1   0   0 1000 "park"
+  8  "d"    4  gun  100  0.4  0.2 land norm  1.0  1.5   7    0   1   0   0 1000 "defense plant"
+  9  "i"    4   sh  100  0.4  0.2 land norm  1.0  1.5   6    0   1   0   0 1000 "shell industry"
+ 10  "m"    4 iron  100  0.4  0.2 land norm  1.0  2.0   5    0   1   0   0 1000 "mine"
+ 11  "g"    4 dust  100  0.4  0.2 land norm  1.0  2.0   8    0   1   0   0 1000 "gold mine"
+ 12  "h"    4   -1    0  0.4  0.2 harb ware  1.0  1.5  12    0   1   0   0 1000 "harbor"
+ 13  "w"    4   -1    0  0.4  0.2 land ware  1.0  1.5   7    0   1   0   0 1000 "warehouse"
+ 14  "*"    4   -1    0  0.4  0.2 land norm  1.0  1.25 12    0   1   0   0 1000 "airfield"
+ 15  "a"    4 food  900  0.4  0.2 land norm  1.0  1.5   2    0   1   0   0 1000 "agribusiness"
+ 16  "o"    4  oil  100  0.4  0.2 land norm  1.0  1.5   5    0   1   0   0 1000 "oil field"
+ 17  "j"    4  lcm  100  0.4  0.2 land norm  1.0  1.5   3    0   1   0   0 1000 "light manufacturing"
+ 18  "k"    4  hcm  100  0.4  0.2 land norm  1.0  1.5   4    0   1   0   0 1000 "heavy manufacturing"
+ 19  "f"    4   -1    0  0.4  0.2 land norm  2.0  4.0  10    0   5   0   1 1000 "fortress"
+ 20  "t"    4 tech  100  0.4  0.2 land norm  1.0  1.5  10    0   1   0   0 1000 "technical center"
+ 21  "r"    4  med  100  0.4  0.2 land norm  1.0  1.5   9    0   1   0   0 1000 "research lab"
+ 22  "n"    4   -1    0  0.4  0.2 land norm  1.0  2.0  10    0   1   0   0 1000 "nuclear plant"
+ 23  "l"    4  edu  100  0.4  0.2 land norm  1.0  1.5   4    0   1   0   0 1000 "library/school"
+ 24  "+"    4   -1    0  0.4  0.0 land norm  1.0  1.0   3    0   1   0   0 1000 "highway"
+ 25  ")"    4   -1    0  0.4  0.2 land norm  1.0  1.5   4    0   1   0   0 1000 "radar installation"
+ 26  "!"    4   -1    0  0.4  0.2 land norm  1.0  1.5  12    0   1   0   0 1000 "headquarters"
+ 27  "#"    4   -1    0  0.4  0.0 land norm  1.0  1.0   3    0   1   0   0 1000 "bridge head"
+ 28  "="    0   -1    0  0.4  0.0 brid norm  1.0  1.0   5   -1   1   0   0  100 "bridge span"
+ 29  "b"    4 bars  100  0.4  0.2 land bank  1.0  2.25 10    0   1   0   0 1000 "bank"
+ 30  "%"    4  pet 1000  0.4  0.2 land norm  1.0  1.5   2    0   1   0   0 1000 "refinery"
+ 31  "e"    4   -1    0  0.4  0.2 land norm  1.0  2.0   7    0   1   0   0 1000 "enlistment center"
+ 32  "~"   32   -1    0  0.4  0.2 land norm  1.0  1.5   1   -1   1   0   0  100 "plains"
+ 33  "@"    0   -1    0  0.4  0.0 land norm  1.0  1.5   4   -1   1   0   0  100 "bridge tower"
 /config
 /config