From 153527a3ebc7c93de60cc6a6094f620ea09e44df Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 12 Feb 2005 16:17:57 +0000 Subject: [PATCH] From Ray Hyatt: (dchrstr): New member d_maxpop. (dchr): Initialize it. (max_pop): Use it. Use dchr[SCT_MINE].d_maxpop when called with null argument. RES_POP now affects mountains and plains as well. --- include/sect.h | 1 + src/lib/common/res_pop.c | 18 ++++------ src/lib/global/sect.c | 76 ++++++++++++++++++++-------------------- 3 files changed, 46 insertions(+), 49 deletions(-) diff --git a/include/sect.h b/include/sect.h index 7cd4fa1e..143cdf08 100644 --- a/include/sect.h +++ b/include/sect.h @@ -100,6 +100,7 @@ struct dchrstr { int d_build; /* cost multiplier for eff */ int d_lcms; /* lcm's needed per point of eff */ int d_hcms; /* hcm's needed per point of eff */ + int d_maxpop; /* maximum population */ char *d_name; /* full name of sector type */ }; diff --git a/src/lib/common/res_pop.c b/src/lib/common/res_pop.c index ba1db6ac..5b3428f6 100644 --- a/src/lib/common/res_pop.c +++ b/src/lib/common/res_pop.c @@ -43,26 +43,22 @@ int max_pop(float research, struct sctstr *sp) { - int maxpop = 999; + int maxpop = dchr[sp ? sp->sct_type : SCT_MINE].d_maxpop; if (opt_RES_POP) { - maxpop = 400 + 600 * ((50.0 + 4.0 * research) - / (200.0 + 3.0 * research)); + /* research limits maximum population */ + maxpop = maxpop * 0.4 + + maxpop * 0.6 * (50.0 + 4.0*research) / (200.0 + 3.0*research); if (maxpop > 999) maxpop = 999; } if (opt_BIG_CITY) { + /* city efficiency limits maximum population */ if (sp && dchr[sp->sct_type].d_pkg == UPKG) maxpop = (int)(maxpop * ((9.0 * sp->sct_effic) / 100 + 1)); + if (CANT_HAPPEN(maxpop > 9999)) + maxpop = 9999; } - - if (sp) { - if (sp->sct_type == SCT_MOUNT) - maxpop /= 10; - else if (sp->sct_type == SCT_PLAINS) - maxpop /= 20; - } - return maxpop; } diff --git a/src/lib/global/sect.c b/src/lib/global/sect.c index 2f41631c..ce0068dd 100644 --- a/src/lib/global/sect.c +++ b/src/lib/global/sect.c @@ -42,48 +42,48 @@ #include "product.h" struct dchrstr bigcity_dchr = { - 'c', 0, 2, NAV_02, UPKG, 1.0, 2.0, 30, 0, 10, 1, 2, "city" + 'c', 0, 2, NAV_02, UPKG, 1.0, 2.0, 30, 0, 10, 1, 2, 9999, "city" }; struct dchrstr dchr[SCT_MAXDEF + 2] = { /* - mnem prd mcst flg pkg ostr dstr value $ bld lcm hcm name */ - {'.', 0, 0, NAVOK, NPKG, 0.0, 0.0, 0, -1, 0, 0, 0, "sea"}, - {'^', P_MDUST, 25, 0, NPKG, 1.0, 4.0, 5, -1, 1, 0, 0, "mountain"}, - {'s', 0, 0, 0, NPKG, 0.0, 99.0, 127, -1, 0, 0, 0, "sanctuary"}, - {'\\', 0, 0, 0, NPKG, 0.0, 99.0, 0, -1, 0, 0, 0, "wasteland"}, - {'-', 0, 3, 0, NPKG, 1.0, 2.0, 1, 0, 0, 0, 0, "wilderness"}, - {'c', 0, 2, 0, NPKG, 1.0, 2.0, 30, 0, 1, 0, 0, "capital"}, - {'u', P_URAN, 2, 0, NPKG, 1.0, 2.0, 15, 0, 1, 0, 0, "uranium mine"}, - {'p', P_HLEV, 2, 0, NPKG, 1.0, 1.5, 5, 0, 1, 0, 0, "park"}, - {'d', P_GUN, 2, 0, NPKG, 1.0, 1.5, 7, 0, 1, 0, 0, "defense plant"}, - {'i', P_SHELL, 2, 0, NPKG, 1.0, 1.5, 6, 0, 1, 0, 0, "shell industry"}, - {'m', P_IRON, 2, 0, NPKG, 1.0, 2.0, 5, 0, 1, 0, 0, "mine"}, - {'g', P_DUST, 2, 0, NPKG, 1.0, 2.0, 8, 0, 1, 0, 0, "gold mine"}, - {'h', 0, 2, NAV_02, WPKG, 1.0, 1.5, 12, 0, 1, 0, 0, "harbor"}, - {'w', 0, 2, 0, WPKG, 1.0, 1.5, 7, 0, 1, 0, 0, "warehouse"}, - {'*', 0, 2, 0, NPKG, 1.0, 1.25, 12, 0, 1, 0, 0, "airfield"}, - {'a', P_FOOD, 2, 0, NPKG, 1.0, 1.5, 2, 0, 1, 0, 0, "agribusiness"}, - {'o', P_OIL, 2, 0, NPKG, 1.0, 1.5, 5, 0, 1, 0, 0, "oil field"}, - {'j', P_LCM, 2, 0, NPKG, 1.0, 1.5, 3, 0, 1, 0, 0, "light manufacturing"}, - {'k', P_HCM, 2, 0, NPKG, 1.0, 1.5, 4, 0, 1, 0, 0, "heavy manufacturing"}, - {'f', 0, 2, 0, NPKG, 2.0, 4.0, 10, 0, 5, 0, 1, "fortress"}, - {'t', P_TLEV, 2, 0, NPKG, 1.0, 1.5, 10, 0, 1, 0, 0, "technical center"}, - {'r', P_RLEV, 2, 0, NPKG, 1.0, 1.5, 9, 0, 1, 0, 0, "research lab"}, - {'n', 0, 2, 0, NPKG, 1.0, 2.0, 10, 0, 1, 0, 0, "nuclear plant"}, - {'l', P_ELEV, 2, 0, NPKG, 1.0, 1.5, 4, 0, 1, 0, 0, "library/school"}, - {'+', 0, 1, 0, NPKG, 1.0, 1.0, 3, 0, 1, 0, 0, "highway"}, - {')', 0, 2, 0, NPKG, 1.0, 1.5, 4, 0, 1, 0, 0, "radar installation"}, - {'!', 0, 2, 0, NPKG, 1.0, 1.5, 12, 0, 1, 0, 0, "headquarters"}, - {'#', 0, 1, 0, NPKG, 1.0, 1.5, 4, 0, 1, 0, 0, "bridge head"}, - {'=', 0, 1, NAV_60, NPKG, 1.0, 1.0, 5, -1, 1, 0, 0, "bridge span"}, - {'b', P_BAR, 2, 0, BPKG, 1.0, 2.25, 10, 0, 1, 0, 0, "bank"}, - {'%', P_PETROL, 2, 0, NPKG, 1.0, 1.5, 2, 0, 1, 0, 0, "refinery"}, - {'e', 0, 2, 0, NPKG, 1.0, 2.0, 7, 0, 1, 0, 0, "enlistment center"}, - {'~', 0, 2, 0, NPKG, 1.0, 1.5, 1, -1, 1, 0, 0, "plains"}, - {'@', 0, 1, 0, NPKG, 1.0, 1.5, 4, -1, 1, 0, 0, "bridge tower"}, - {0, 0, 0, 0, IPKG, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, IPKG, 0, 0, 0, 0, 0, 0, 0, 0} + mnem prd mcst flg pkg ostr dstr value $ bld lcm hcm maxpop name */ + {'.', 0, 0, NAVOK, NPKG, 0.0, 0.0, 0, -1, 0, 0, 0, 0, "sea"}, + {'^', P_MDUST, 25, 0, NPKG, 1.0, 4.0, 5, -1, 1, 0, 0, 99, "mountain"}, + {'s', 0, 0, 0, NPKG, 0.0, 99.0, 127, -1, 0, 0, 0, 9999, "sanctuary"}, + {'\\', 0, 0, 0, NPKG, 0.0, 99.0, 0, -1, 0, 0, 0, 0, "wasteland"}, + {'-', 0, 3, 0, NPKG, 1.0, 2.0, 1, 0, 0, 0, 0, 999, "wilderness"}, + {'c', 0, 2, 0, NPKG, 1.0, 2.0, 30, 0, 1, 0, 0, 999, "capital"}, + {'u', P_URAN, 2, 0, NPKG, 1.0, 2.0, 15, 0, 1, 0, 0, 999, "uranium mine"}, + {'p', P_HLEV, 2, 0, NPKG, 1.0, 1.5, 5, 0, 1, 0, 0, 999, "park"}, + {'d', P_GUN, 2, 0, NPKG, 1.0, 1.5, 7, 0, 1, 0, 0, 999, "defense plant"}, + {'i', P_SHELL, 2, 0, NPKG, 1.0, 1.5, 6, 0, 1, 0, 0, 999, "shell industry"}, + {'m', P_IRON, 2, 0, NPKG, 1.0, 2.0, 5, 0, 1, 0, 0, 999, "mine"}, + {'g', P_DUST, 2, 0, NPKG, 1.0, 2.0, 8, 0, 1, 0, 0, 999, "gold mine"}, + {'h', 0, 2, NAV_02, WPKG, 1.0, 1.5, 12, 0, 1, 0, 0, 999, "harbor"}, + {'w', 0, 2, 0, WPKG, 1.0, 1.5, 7, 0, 1, 0, 0, 999, "warehouse"}, + {'*', 0, 2, 0, NPKG, 1.0, 1.25, 12, 0, 1, 0, 0, 999, "airfield"}, + {'a', P_FOOD, 2, 0, NPKG, 1.0, 1.5, 2, 0, 1, 0, 0, 999, "agribusiness"}, + {'o', P_OIL, 2, 0, NPKG, 1.0, 1.5, 5, 0, 1, 0, 0, 999, "oil field"}, + {'j', P_LCM, 2, 0, NPKG, 1.0, 1.5, 3, 0, 1, 0, 0, 999, "light manufacturing"}, + {'k', P_HCM, 2, 0, NPKG, 1.0, 1.5, 4, 0, 1, 0, 0, 999, "heavy manufacturing"}, + {'f', 0, 2, 0, NPKG, 2.0, 4.0, 10, 0, 5, 0, 1, 999, "fortress"}, + {'t', P_TLEV, 2, 0, NPKG, 1.0, 1.5, 10, 0, 1, 0, 0, 999, "technical center"}, + {'r', P_RLEV, 2, 0, NPKG, 1.0, 1.5, 9, 0, 1, 0, 0, 999, "research lab"}, + {'n', 0, 2, 0, NPKG, 1.0, 2.0, 10, 0, 1, 0, 0, 999, "nuclear plant"}, + {'l', P_ELEV, 2, 0, NPKG, 1.0, 1.5, 4, 0, 1, 0, 0, 999, "library/school"}, + {'+', 0, 1, 0, NPKG, 1.0, 1.0, 3, 0, 1, 0, 0, 999, "highway"}, + {')', 0, 2, 0, NPKG, 1.0, 1.5, 4, 0, 1, 0, 0, 999, "radar installation"}, + {'!', 0, 2, 0, NPKG, 1.0, 1.5, 12, 0, 1, 0, 0, 999, "headquarters"}, + {'#', 0, 1, 0, NPKG, 1.0, 1.5, 4, 0, 1, 0, 0, 999, "bridge head"}, + {'=', 0, 1, NAV_60, NPKG, 1.0, 1.0, 5, -1, 1, 0, 0, 999, "bridge span"}, + {'b', P_BAR, 2, 0, BPKG, 1.0, 2.25, 10, 0, 1, 0, 0, 999, "bank"}, + {'%', P_PETROL, 2, 0, NPKG, 1.0, 1.5, 2, 0, 1, 0, 0, 999, "refinery"}, + {'e', 0, 2, 0, NPKG, 1.0, 2.0, 7, 0, 1, 0, 0, 999, "enlistment center"}, + {'~', 0, 2, 0, NPKG, 1.0, 1.5, 1, -1, 1, 0, 0, 50, "plains"}, + {'@', 0, 1, 0, NPKG, 1.0, 1.5, 4, -1, 1, 0, 0, 999, "bridge tower"}, + {0, 0, 0, 0, IPKG, 0, 0, 0, 0, 0, 0, 0, 0, NULL}, + {0, 0, 0, 0, IPKG, 0, 0, 0, 0, 0, 0, 0, 0, NULL} }; struct sctintrins intrchr[] = {