From: Ron Koenderink Date: Mon, 14 Nov 2005 13:52:12 +0000 (+0000) Subject: (fuel, load, prod, max_population, shp_nav_one_sector, X-Git-Tag: PZ5~442 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=a2798857cf87591531ce14f3481301ad8c86b7d6 (fuel, load, prod, max_population, shp_nav_one_sector, nav_loadship, upd_buildeff): Identify BIG_CITY (IS_BIG_CITY) by using packing type of UPKG instead of opt_BIG_CITY and sector type of SCT_CAPITAL. --- diff --git a/include/sect.h b/include/sect.h index ae869f3d2..f0b576ea7 100644 --- a/include/sect.h +++ b/include/sect.h @@ -165,6 +165,7 @@ extern int sctoff(coord x, coord y); extern struct dchrstr dchr[SCT_MAXDEF + 1]; extern struct dchrstr bigcity_dchr; +#define IS_BIG_CITY(sect) (dchr[sect].d_pkg == UPKG) /* Minimal efficiency of sectors that can be knocked down (bridges) */ #define SCT_MINEFF 20 diff --git a/src/lib/commands/fuel.c b/src/lib/commands/fuel.c index f97456d8f..ffd1c9f40 100644 --- a/src/lib/commands/fuel.c +++ b/src/lib/commands/fuel.c @@ -121,9 +121,8 @@ fuel(void) if ((sect.sct_type != SCT_HARBR) && (sect.sct_type != SCT_WATER) - && (sect.sct_type != SCT_BSPAN) && (!opt_BIG_CITY - || sect.sct_type != - SCT_CAPIT)) { + && (sect.sct_type != SCT_BSPAN) + && (!IS_BIG_CITY(sect.sct_type))) { pr("Sector %s is not a harbor, bridge span, or sea.\n", xyas(item.ship.shp_x, item.ship.shp_y, item.ship.shp_own)); @@ -134,7 +133,7 @@ fuel(void) harbor = 0; if (sect.sct_type == SCT_HARBR - || (opt_BIG_CITY && sect.sct_type == SCT_CAPIT)) { + || IS_BIG_CITY(sect.sct_type)) { harbor = 1; oil_amt = sect.sct_item[I_OIL]; pet_amt = sect.sct_item[I_PETROL]; diff --git a/src/lib/commands/load.c b/src/lib/commands/load.c index fee70f9ad..6df341912 100644 --- a/src/lib/commands/load.c +++ b/src/lib/commands/load.c @@ -138,7 +138,7 @@ load(void) continue; if (!player->owner && sect.sct_type != SCT_HARBR && - (!opt_BIG_CITY || sect.sct_type != SCT_CAPIT)) + !IS_BIG_CITY(sect.sct_type)) continue; if (!sect.sct_own) continue; @@ -149,11 +149,13 @@ load(void) continue; } if (sect.sct_type != SCT_HARBR && - (!opt_BIG_CITY || sect.sct_type != SCT_CAPIT)) { + !IS_BIG_CITY(sect.sct_type)) { if (noisy) - pr("Sector %s is not a harbor%s.\n", + pr("Sector %s is not a harbor%s%s.\n", xyas(ship.shp_x, ship.shp_y, player->cnum), - opt_BIG_CITY ? " or a city" : ""); + IS_BIG_CITY(sect.sct_type) ? " or a " : "", + IS_BIG_CITY(sect.sct_type) ? + dchr[sect.sct_type].d_name : ""); continue; } if (sect.sct_own != player->cnum && load_unload == UNLOAD diff --git a/src/lib/commands/prod.c b/src/lib/commands/prod.c index fd6cbb4f4..6101b17cc 100644 --- a/src/lib/commands/prod.c +++ b/src/lib/commands/prod.c @@ -136,18 +136,16 @@ prod(void) type = sect.sct_newtype; eff = 0; } - if (opt_BIG_CITY) { - if (!eff && dchr[otype].d_pkg == UPKG && - dchr[type].d_pkg != UPKG) { - natp = getnatp(sect.sct_own); - maxpop = max_population(natp->nat_level[NAT_RLEV], - type, eff); - work = new_work(§, - total_work(sect.sct_work, etu_per_update, - civs, sect.sct_item[I_MILIT], - uws, maxpop)); - bwork = min(work / 2, bwork); - } + if (!eff && IS_BIG_CITY(otype) && + !IS_BIG_CITY(type)) { + natp = getnatp(sect.sct_own); + maxpop = max_population(natp->nat_level[NAT_RLEV], + type, eff); + work = new_work(§, + total_work(sect.sct_work, etu_per_update, + civs, sect.sct_item[I_MILIT], + uws, maxpop)); + bwork = min(work / 2, bwork); } twork = 100 - eff; if (twork > bwork) { diff --git a/src/lib/common/res_pop.c b/src/lib/common/res_pop.c index 036040c12..eba5b8b00 100644 --- a/src/lib/common/res_pop.c +++ b/src/lib/common/res_pop.c @@ -46,11 +46,9 @@ max_population(float research, int desig, int eff) int maxpop = dchr[desig].d_maxpop; int rmax; - if (opt_BIG_CITY) { - /* city efficiency limits maximum population */ - if (dchr[desig].d_pkg == UPKG) - maxpop *= 1 + 9.0 * eff / 100; - } + /* city efficiency limits maximum population */ + if (IS_BIG_CITY(desig)) + maxpop *= 1 + 9.0 * eff / 100; if (opt_RES_POP) { /* research limits maximum population */ diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index 843780c97..ccb72fd56 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -834,7 +834,7 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor, continue; } } - if (opt_BIG_CITY && sect.sct_type == SCT_CAPIT) { + if (IS_BIG_CITY(sect.sct_type)) { if (mlp->mcp->m_lcm + 2 * mlp->mcp->m_hcm >= 60) { sprintf(dp, "is too large to fit into the canal system at %s", diff --git a/src/lib/update/nav_ship.c b/src/lib/update/nav_ship.c index 5b0c7017d..6353b0086 100644 --- a/src/lib/update/nav_ship.c +++ b/src/lib/update/nav_ship.c @@ -192,7 +192,7 @@ nav_loadship(struct shpstr *sp, natid cnum) continue; } if (sectp->sct_type != SCT_HARBR && - (!opt_BIG_CITY || sectp->sct_type != SCT_CAPIT)) { + !IS_BIG_CITY(sectp->sct_type)) { /* we can only load in harbors */ didsomething[i] = 1; continue; diff --git a/src/lib/update/sect.c b/src/lib/update/sect.c index ad123c093..e8e534150 100644 --- a/src/lib/update/sect.c +++ b/src/lib/update/sect.c @@ -84,20 +84,18 @@ upd_buildeff(struct natstr *np, struct sctstr *sp, int *workp, } neweff = n; *cost += work_cost; - if (opt_BIG_CITY) { - if (!n && dchr[old_type].d_pkg == UPKG && - dchr[*desig].d_pkg != UPKG) { - int maxpop = max_population(np->nat_level[NAT_RLEV], *desig, n); - if (vec[I_CIVIL] > maxpop) - vec[I_CIVIL] = maxpop; - if (vec[I_UW] > maxpop) - vec[I_UW] = maxpop; - *workp = (vec[I_CIVIL] * sctwork) / 100.0 - + (vec[I_MILIT] * 2 / 5.0) + vec[I_UW]; - *workp = roundavg((etu * (*workp)) / 100.0); - - buildeff_work = min((int)(*workp / 2), buildeff_work); - } + if (!n && IS_BIG_CITY(old_type) && + !IS_BIG_CITY(*desig)) { + int maxpop = max_population(np->nat_level[NAT_RLEV], *desig, n); + if (vec[I_CIVIL] > maxpop) + vec[I_CIVIL] = maxpop; + if (vec[I_UW] > maxpop) + vec[I_UW] = maxpop; + *workp = (vec[I_CIVIL] * sctwork) / 100.0 + + (vec[I_MILIT] * 2 / 5.0) + vec[I_UW]; + *workp = roundavg((etu * (*workp)) / 100.0); + + buildeff_work = min((int)(*workp / 2), buildeff_work); } } if (np->nat_priorities[*desig]) {