From 7da69c92e00fbf67d6a4a28a70348bdb00f5df25 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 12 Feb 2009 07:39:46 +0100 Subject: [PATCH] Don't use automatic supply to avoid starvation at the update Food supply during update adds complexity to the update. How much good it does to players is highly doubtful; certainly nobody can rely on it. It isn't covered by the starvation command. Starving ships or land units can steal enough food from their sector to make it starve, too. Finally, the supply code is notoriously hard to use correctly. We don't know of issues with the update's use, but we haven't convinced ourselves that there aren't any either. --- info/Food.t | 9 +-------- info/Land-units.t | 5 +---- info/Update-sequence.t | 12 ++++-------- info/starvation.t | 2 +- info/supply.t | 11 ++--------- src/lib/update/human.c | 7 ------- src/lib/update/land.c | 25 ------------------------- src/lib/update/sect.c | 7 ------- src/lib/update/ship.c | 16 ---------------- 9 files changed, 9 insertions(+), 85 deletions(-) diff --git a/info/Food.t b/info/Food.t index afc1cebec..61ffcc98c 100644 --- a/info/Food.t +++ b/info/Food.t @@ -125,16 +125,9 @@ in one time unit is: 0 .in .s1 -Note that if a ship doesn't have enough food, it will try to draw it from -supply sources (see info supply). If it still hasn't enough food, it will +Note that if a ship doesn't have enough food, it will attempt to grab unneeded food from any land units it is carrying. .s1 -Land units eat food as well, an amount based on the total number of military -in the unit (this is the efficiency times the number of mil needed to build -the unit). If a land unit doesn't have enough food, it will try to draw it -from supply sources (see info supply). If it still doesn't have enough, and -it is on a ship, it will attempt to get food from the ship. -.s1 The presence of food also affects the birthrate in Empire; if there is no food in a sector no babies will be born. A baby consumes 0.3 units of food in growing to adulthood. diff --git a/info/Land-units.t b/info/Land-units.t index 0c37c502a..00252351a 100644 --- a/info/Land-units.t +++ b/info/Land-units.t @@ -230,10 +230,7 @@ used in assaulting sectors. (See info \*Qassault\*U) .s1 .L Supply .s1 -Units need supplies in order to attack. Each update, and each time they -attack, units will attempt to draw supplies. See info \*Qsupply\*U. -Really, I'm serious. If you don't read info \*Qsupply\*U, you'll die a horrible -death. I'm not kidding. +Units need supplies in order to attack. See info \*Qsupply\*U. .s1 .L Fortification .s1 diff --git a/info/Update-sequence.t b/info/Update-sequence.t index f0e1de397..cb431c09f 100644 --- a/info/Update-sequence.t +++ b/info/Update-sequence.t @@ -27,14 +27,10 @@ This document gives a rough order of events during the update. a) if the sector is a cap, it costs $1 per etu since the last update b) people in non-sanctuary sectors eat - 1) If not enough is available, the sector - uses the supply routines to draw more. - 2) If still not enough is available, - the excess people will starve off. - a) No more than 50% of the people - in a sect can die; - the uw's die first, then - the civs, then the mil. + 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 to 0, otherwise the work rate rises by 8+(1-15), max of 100 diff --git a/info/starvation.t b/info/starvation.t index 9766571b5..f5ef18f9c 100644 --- a/info/starvation.t +++ b/info/starvation.t @@ -11,7 +11,7 @@ sectors, land units, and ships that will starve at the update. .s1 With this syntax, the starvation command displays all sectors in that currently do not have enough food. It does not take into account -emergency food growing & supplying (see info supply) +emergency food growing. It also does not worry about feeding babies... it merely check for starvation. If you want population increase, you'll need to chuck in some extra food... diff --git a/info/supply.t b/info/supply.t index 35ff4fea8..ef4c52fa7 100644 --- a/info/supply.t +++ b/info/supply.t @@ -26,15 +26,11 @@ A unit that fights may use a basic load of supplies to attack with. (depending on the intensity of combat. The more intense the combat, the more chance the unit will use a basic load of supplies) .s1 -During the update, each unit will attempt to draw food supplies just before -starvation is calculated. -.s1 When a unit needs to draw supplies, such as when you use the supply command, or the unit wishes to attack, or is attacked, etc, it must attempt to get them from supply sources. Other things may use the same routines, such as -loyal sectors, which will draw food from supply sources when in danger of -starvation, and ships/forts/sectors, which will draw shells when they need -them to fire defensively. +ships/forts/sectors, which will draw shells when they need them to +fire defensively. .s1 .L "Supply Sources" .s1 @@ -89,7 +85,4 @@ OTHER USES OF SUPPLY In general, when any land unit/ship/fort needs shells, it will attempt to draw them before use, if it does not already have them. .s1 -Also, units/ships/sectors will use supply sources to get enough food during -the update so that they do not starve. -.s1 .SA "lload, LandUnits" diff --git a/src/lib/update/human.c b/src/lib/update/human.c index f4236e34f..18a1e68e1 100644 --- a/src/lib/update/human.c +++ b/src/lib/update/human.c @@ -84,13 +84,6 @@ do_feed(struct sctstr *sp, struct natstr *np, short *vec, /* Conjure up 1f to make life easier for the player */ manna = vec[I_FOOD] = 1; } - if (vec[I_FOOD] < needed && sp->sct_own == sp->sct_oldown) { - /* steal food from warehouses, headquarters, - supply ships in port, or supply units */ - vec[I_FOOD] = supply_commod(sp->sct_own, - sp->sct_x, sp->sct_y, - I_FOOD, needed); - } } starved = feed_people(vec, etu); if (starved > 0) { diff --git a/src/lib/update/land.c b/src/lib/update/land.c index c9626379c..32d03a3a5 100644 --- a/src/lib/update/land.c +++ b/src/lib/update/land.c @@ -59,9 +59,7 @@ prod_land(int etus, int natnum, struct bp *bp, int build) struct natstr *np; int n, k = 0; int start_money; - int lastx = 9999, lasty = 9999; - bp_enable_cachepath(); for (n = 0; NULL != (lp = getlandp(n)); n++) { if (lp->lnd_own == 0) continue; @@ -77,16 +75,6 @@ prod_land(int etus, int natnum, struct bp *bp, int build) sp = getsectp(lp->lnd_x, lp->lnd_y); if (sp->sct_type == SCT_SANCT) continue; - if (lastx == 9999 || lasty == 9999) { - lastx = lp->lnd_x; - lasty = lp->lnd_y; - } - if (lastx != lp->lnd_x || lasty != lp->lnd_y) { - /* Reset the cache */ - bp_disable_cachepath(); - bp_clear_cachepath(); - bp_enable_cachepath(); - } np = getnatp(lp->lnd_own); start_money = np->nat_money; upd_land(lp, etus, np, bp, build); @@ -96,8 +84,6 @@ prod_land(int etus, int natnum, struct bp *bp, int build) if (player->simulation) np->nat_money = start_money; } - bp_disable_cachepath(); - bp_clear_cachepath(); return k; } @@ -285,16 +271,5 @@ landrepair(struct lndstr *land, struct natstr *np, struct bp *bp, int etus) static int feed_land(struct lndstr *lp, int etus) { - int needed; - - if (opt_NOFOOD) - return 0; - - needed = (int)ceil(food_needed(lp->lnd_item, etus)); - - /* scrounge */ - if (needed > lp->lnd_item[I_FOOD]) - resupply_commod(lp, I_FOOD); - return feed_people(lp->lnd_item, etus); } diff --git a/src/lib/update/sect.c b/src/lib/update/sect.c index 6bf812519..6b310a1b3 100644 --- a/src/lib/update/sect.c +++ b/src/lib/update/sect.c @@ -308,16 +308,9 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2]) sp->sct_updated = 1; work = 0; - /* do_feed trys to supply. So, we need to enable cacheing - here */ - bp_enable_cachepath(); - sctwork = do_feed(sp, np, vec, &work, etu); bp_put_items(bp, sp, vec); - bp_disable_cachepath(); - bp_clear_cachepath(); - if (sp->sct_off || np->nat_money < 0) continue; diff --git a/src/lib/update/ship.c b/src/lib/update/ship.c index 891a8c7ed..edc41b894 100644 --- a/src/lib/update/ship.c +++ b/src/lib/update/ship.c @@ -59,9 +59,7 @@ prod_ship(int etus, int natnum, struct bp *bp, int build) struct natstr *np; int n, k = 0; int start_money; - int lastx = 9999, lasty = 9999; - bp_enable_cachepath(); for (n = 0; NULL != (sp = getshipp(n)); n++) { if (sp->shp_own == 0) continue; @@ -75,16 +73,6 @@ prod_ship(int etus, int natnum, struct bp *bp, int build) } np = getnatp(sp->shp_own); - if (lastx == 9999 || lasty == 9999) { - lastx = sp->shp_x; - lasty = sp->shp_y; - } - if (lastx != sp->shp_x || lasty != sp->shp_y) { - /* Reset the cache */ - bp_disable_cachepath(); - bp_clear_cachepath(); - bp_enable_cachepath(); - } start_money = np->nat_money; upd_ship(sp, etus, np, bp, build); if (build && !player->simulation) /* make sure to only autonav once */ @@ -382,10 +370,6 @@ feed_ship(struct shpstr *sp, int etus) needed = (int)ceil(food_needed(sp->shp_item, etus)); /* scrounge */ - if (needed > sp->shp_item[I_FOOD]) - sp->shp_item[I_FOOD] += supply_commod(sp->shp_own, - sp->shp_x, sp->shp_y, I_FOOD, - needed - sp->shp_item[I_FOOD]); if (needed > sp->shp_item[I_FOOD]) { /* take from embarked land units, but don't starve them */ snxtitem_cargo(&ni, EF_LAND, EF_SHIP, sp->shp_uid); -- 2.43.0