From 44c36fa7d5ad382e11483e6d82d896efdf22016e Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 20 Feb 2009 18:58:01 +0100 Subject: [PATCH] Make sector maintenance cost configurable Replace the fixed $1 per ETU maintenance for capital/city sectors that are at least 60% efficient by a configurable maintenance cost, payable regardless of efficiency. The only change in the default configuration is that inefficient capitals now pay maintenance. Charging sector maintenance regardless of efficiency is consistent with unit maintenance. New struct dchrstr member d_maint and sector-chr selector maint. Make show_sect_build() show it. Change produce_sect() to record maintenance in new slot p_sect[SCT_MAINT] instead of abusing p_sect[SCT_CAPIT]. Replace the "Capital maintenance" line in budget by "Sector maintenance". --- include/budg.h | 3 +- include/sect.h | 1 + info/Sector-types.t | 13 ++++--- info/Update-sequence.t | 9 +++-- info/budget.t | 2 +- src/lib/commands/budg.c | 19 +++++----- src/lib/common/nsc.c | 1 + src/lib/global/sect.config | 72 +++++++++++++++++++------------------- src/lib/subs/show.c | 14 ++++---- src/lib/update/sect.c | 15 ++++---- 10 files changed, 77 insertions(+), 72 deletions(-) diff --git a/include/budg.h b/include/budg.h index f07cff133..50474c218 100644 --- a/include/budg.h +++ b/include/budg.h @@ -38,7 +38,8 @@ #include "item.h" #define SCT_EFFIC (SCT_TYPE_MAX + 1) -#define SCT_BUDG_MAX SCT_EFFIC +#define SCT_MAINT (SCT_TYPE_MAX + 2) +#define SCT_BUDG_MAX SCT_MAINT struct bp *bp_alloc(void); void bp_set_from_sect(struct bp *, struct sctstr *); diff --git a/include/sect.h b/include/sect.h index f5d6722e0..b03384af1 100644 --- a/include/sect.h +++ b/include/sect.h @@ -116,6 +116,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_maint; /* maintenance cost per ETU */ int d_maxpop; /* maximum population */ char *d_name; /* full name of sector type */ }; diff --git a/info/Sector-types.t b/info/Sector-types.t index 9e29b6edd..94c0de0b0 100644 --- a/info/Sector-types.t +++ b/info/Sector-types.t @@ -237,11 +237,12 @@ The \*Qshow\*U command can be used to show special things about sector types. To check out build costs, you do: .EX show sect build .NF - desig build 100% eff -sector type $ lcm hcm $ -- wilderness 0 0 0 0 -f fortress 0 0 100 500 -any other 0 0 0 100 + desig build 100% eff maint +sector type $ lcm hcm $ $ +- wilderness 0 0 0 0 0 +c capital 0 0 0 100 60 +f fortress 0 0 100 500 0 +any other 0 0 0 100 0 Infrastructure building - adding 1 point of efficiency costs: type lcms hcms mobility $$$$ @@ -259,6 +260,8 @@ The lcm required to build the sector. The hcm required to build the sector. .L "build $" What it costs to build the sector. +.L "maint $" +Cost of maintenance per update. .in .s1 The show command also shows infrastructure build costs. diff --git a/info/Update-sequence.t b/info/Update-sequence.t index cb431c09f..6b5c9a3f2 100644 --- a/info/Update-sequence.t +++ b/info/Update-sequence.t @@ -24,17 +24,16 @@ This document gives a rough order of events during the update. d) land unit maintenance pay maintenance, then feed and plague people on board e) produce for all sectors - a) if the sector is a cap, it costs $1 per etu since - the last update - b) people in non-sanctuary sectors eat + a) people in non-sanctuary sectors eat If not enough is available, the excess people will starve off. No more than 50% of the people in a sector can die; the uw's die first, then the civs, then the mil. - c) if there was starvation, the work percentage is set + b) if there was starvation, the work percentage is set to 0, otherwise the work rate rises by 8+(1-15), max of 100 - d) population grows and is truncated + c) population grows and is truncated + d) pay sector maintenance e) sectors that are stopped are skipped (see info stop) f) first increase eff g) then make things diff --git a/info/budget.t b/info/budget.t index acab8c3bb..872b11037 100644 --- a/info/budget.t +++ b/info/budget.t @@ -22,8 +22,8 @@ Ship maintenance 25 ships 6327 Plane building 9 planes 2508 Plane maintenance 219 planes 8874 Sector building 2398 +Sector maintenance 5 sectors 300 Military payroll 7648 mil, 338 res 38247 -City maintenance 5 cities 300 Total expenses....................................................147490 Income from taxes 320709 civs, 100235 uws +92513 Income from bars 7986 bars +95832 diff --git a/src/lib/commands/budg.c b/src/lib/commands/budg.c index 846d04d6f..2a40b033a 100644 --- a/src/lib/commands/budg.c +++ b/src/lib/commands/budg.c @@ -84,7 +84,7 @@ budg(void) expenses = 0; pr("Sector Type\t\t\tProduction\t\t\t Cost\n"); for (i = 0; i <= SCT_TYPE_MAX; i++) { - if (!p_sect[i][1] || i == SCT_CAPIT) + if (!p_sect[i][1]) continue; pr("%-17s\t\t", dchr[i].d_name); if (i == SCT_ENLIST) @@ -137,22 +137,19 @@ budg(void) p_sect[SCT_EFFIC][0], p_sect[SCT_EFFIC][1]); expenses += p_sect[SCT_EFFIC][1]; } + if (p_sect[SCT_MAINT][0]) { + sprintf(buf, "%ld sector%s", + p_sect[SCT_MAINT][0], splur(p_sect[SCT_MAINT][0])); + pr("Sector maintenance\t\t%-16s\t\t%8ld\n", + buf, p_sect[SCT_MAINT][1]); + expenses += p_sect[SCT_MAINT][1]; + } if (mil) { n = (mil - np->nat_reserve * money_res * etu) / (etu * money_mil); sprintf(in, "%d mil, %d res", n, (int)np->nat_reserve); pr("Military payroll\t\t%-32s%8d\n", in, -mil); expenses -= mil; } - if (p_sect[SCT_CAPIT][0]) { - pr("%c%s maintenance\t\t", - toupper(dchr[SCT_CAPIT].d_name[0]), - dchr[SCT_CAPIT].d_name + 1); - n = p_sect[SCT_CAPIT][0]; - sprintf(in, "%d %s", n, dchr[SCT_CAPIT].d_name); - plurize(in, sizeof(in), n); - pr("%-32s%8ld\n", in, p_sect[SCT_CAPIT][1]); - expenses += p_sect[SCT_CAPIT][1]; - } pr("Total expenses%s\n", dotsprintf(buf, "%58d", expenses)); if (taxes) { sprintf(in, "%d civ%s, %d uw%s", diff --git a/src/lib/common/nsc.c b/src/lib/common/nsc.c index 5753907ad..462007982 100644 --- a/src/lib/common/nsc.c +++ b/src/lib/common/nsc.c @@ -203,6 +203,7 @@ struct castr dchr_ca[] = { {"build", fldoff(d_build), NSC_INT, 0, NULL, EF_BAD, 0}, {"lcms", fldoff(d_lcms), NSC_INT, 0, NULL, EF_BAD, 0}, {"hcms", fldoff(d_hcms), NSC_INT, 0, NULL, EF_BAD, 0}, + {"maint", fldoff(d_maint), NSC_INT, 0, NULL, EF_BAD, 0}, {"maxpop", fldoff(d_maxpop), NSC_INT, 0, NULL, EF_BAD, 0}, {NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0} #undef CURSTR diff --git a/src/lib/global/sect.config b/src/lib/global/sect.config index bd3619d83..dd2aa00f0 100644 --- a/src/lib/global/sect.config +++ b/src/lib/global/sect.config @@ -61,41 +61,41 @@ # econfig key custom_tables. config sect-chr -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" +uid mnem terra prd peff mob0 mob1 nav pkg ostr dstr val cost bui lcm hcm maint maxp name + 0 "." 0 -1 0 -1 -1 sea norm 0.0 0.0 0 -1 0 0 0 0 0 "sea" + 1 "^" 1 dust 75 2.4 1.2 land norm 1.0 4.0 5 -1 1 0 0 0 100 "mountain" + 2 "s" 4 -1 0 -1 -1 land norm 0.0 99.0 127 -1 0 0 0 0 1000 "sanctuary" + 3 "\134" 3 -1 0 -1 -1 land norm 0.0 99.0 0 -1 0 0 0 0 0 "wasteland" + 4 "-" 4 -1 0 0.4 0.4 land norm 1.0 2.0 1 0 0 0 0 0 1000 "wilderness" # Uncomment one of the following two. The second one is for big cities. - 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" + 5 "c" 4 -1 0 0.4 0.2 land norm 1.0 2.0 30 0 1 0 0 1 1000 "capital" +# 5 "c" 4 -1 0 0.4 0.2 cana urba 1.0 2.0 30 0 10 1 2 1 1000 "city" + 6 "u" 4 rad 100 0.4 0.2 land norm 1.0 2.0 15 0 1 0 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 0 1000 "park" + 8 "d" 4 gun 100 0.4 0.2 land norm 1.0 1.5 7 0 1 0 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 0 1000 "shell industry" + 10 "m" 4 iron 100 0.4 0.2 land norm 1.0 2.0 5 0 1 0 0 0 1000 "mine" + 11 "g" 4 dust 100 0.4 0.2 land norm 1.0 2.0 8 0 1 0 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 0 1000 "harbor" + 13 "w" 4 -1 0 0.4 0.2 land ware 1.0 1.5 7 0 1 0 0 0 1000 "warehouse" + 14 "*" 4 -1 0 0.4 0.2 land norm 1.0 1.25 12 0 1 0 0 0 1000 "airfield" + 15 "a" 4 food 900 0.4 0.2 land norm 1.0 1.5 2 0 1 0 0 0 1000 "agribusiness" + 16 "o" 4 oil 100 0.4 0.2 land norm 1.0 1.5 5 0 1 0 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 0 1000 "light manufacturing" + 18 "k" 4 hcm 100 0.4 0.2 land norm 1.0 1.5 4 0 1 0 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 0 1000 "fortress" + 20 "t" 4 tech 100 0.4 0.2 land norm 1.0 1.5 10 0 1 0 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 0 1000 "research lab" + 22 "n" 4 -1 0 0.4 0.2 land norm 1.0 2.0 10 0 1 0 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 0 1000 "library/school" + 24 "+" 4 -1 0 0.4 0.0 land norm 1.0 1.0 3 0 1 0 0 0 1000 "highway" + 25 ")" 4 -1 0 0.4 0.2 land norm 1.0 1.5 4 0 1 0 0 0 1000 "radar installation" + 26 "!" 4 -1 0 0.4 0.2 land norm 1.0 1.5 12 0 1 0 0 0 1000 "headquarters" + 27 "#" 4 -1 0 0.4 0.0 land norm 1.0 1.0 3 0 1 0 0 0 1000 "bridge head" + 28 "=" 0 -1 0 0.4 0.0 brid norm 1.0 1.0 5 -1 1 0 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 0 1000 "bank" + 30 "%" 4 pet 1000 0.4 0.2 land norm 1.0 1.5 2 0 1 0 0 0 1000 "refinery" + 31 "e" 4 -1 0 0.4 0.2 land norm 1.0 2.0 7 0 1 0 0 0 1000 "enlistment center" + 32 "~" 32 -1 0 0.4 0.2 land norm 1.0 1.5 1 -1 1 0 0 0 100 "plains" + 33 "@" 0 -1 0 0.4 0.0 land norm 1.0 1.5 4 -1 1 0 0 0 100 "bridge tower" /config diff --git a/src/lib/subs/show.c b/src/lib/subs/show.c index fe65d8bf2..f2ae16855 100644 --- a/src/lib/subs/show.c +++ b/src/lib/subs/show.c @@ -460,27 +460,29 @@ show_sect_build(int foo) { int i, first; - pr(" desig build 100%% eff\n" - "sector type $ lcm hcm $\n"); + pr(" desig build 100%% eff maint\n" + "sector type $ lcm hcm $ $\n"); for (i = 0; dchr[i].d_name; i++) { if (dchr[i].d_mnem == 0) continue; if (dchr[i].d_mob0 < 0) continue; if (dchr[i].d_cost <= 0 && dchr[i].d_build == 1 - && dchr[i].d_lcms == 0 && dchr[i].d_hcms == 0) + && dchr[i].d_lcms == 0 && dchr[i].d_hcms == 0 + && dchr[i].d_maint == 0) continue; /* the usual, skip */ pr("%c %-21.21s", dchr[i].d_mnem, dchr[i].d_name); if (dchr[i].d_cost < 0) pr(" can't"); else pr(" %5d", dchr[i].d_cost); - pr(" %5d %5d %5d\n", + pr(" %5d%5d %5d %5d\n", 100 * dchr[i].d_lcms, 100 * dchr[i].d_hcms, - 100 * dchr[i].d_build); + 100 * dchr[i].d_build, + dchr[i].d_maint * etu_per_update); } - pr("any other 0 0 0 100\n"); + pr("any other 0 0 0 100 0\n"); first = 1; for (i = 0; intrchr[i].in_name; i++) { diff --git a/src/lib/update/sect.c b/src/lib/update/sect.c index 5f72fc85c..9f154e2bf 100644 --- a/src/lib/update/sect.c +++ b/src/lib/update/sect.c @@ -278,13 +278,6 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2]) np = getnatp(natnum); - if (sp->sct_type == SCT_CAPIT && sp->sct_effic >= 60) { - p_sect[SCT_CAPIT][0]++; - p_sect[SCT_CAPIT][1] += etu; - if (!player->simulation) - np->nat_money -= etu; - } - if (player->simulation) { /* work on a copy, which will be discarded */ memcpy(buf, sp->sct_item, sizeof(buf)); @@ -321,6 +314,14 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2]) desig = sp->sct_type; + if (dchr[desig].d_maint) { + cost = etu * dchr[desig].d_maint; + p_sect[SCT_MAINT][0]++; + p_sect[SCT_MAINT][1] += cost; + if (!player->simulation) + np->nat_money -= cost; + } + if ((sp->sct_effic < 100 || sp->sct_type != sp->sct_newtype) && np->nat_money >= 0) { neweff = upd_buildeff(np, sp, &work, vec, etu, &desig, sctwork, -- 2.43.0