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.
This commit is contained in:
Markus Armbruster 2009-02-12 07:39:46 +01:00
parent c0b300d875
commit 7da69c92e0
9 changed files with 9 additions and 85 deletions

View file

@ -125,16 +125,9 @@ in one time unit is:
0 0
.in .in
.s1 .s1
Note that if a ship doesn't have enough food, it will try to draw it from Note that if a ship doesn't have enough food, it will
supply sources (see info supply). If it still hasn't enough food, it will
attempt to grab unneeded food from any land units it is carrying. attempt to grab unneeded food from any land units it is carrying.
.s1 .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; The presence of food also affects the birthrate in Empire;
if there is no food in a sector no babies will be born. 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. A baby consumes 0.3 units of food in growing to adulthood.

View file

@ -230,10 +230,7 @@ used in assaulting sectors. (See info \*Qassault\*U)
.s1 .s1
.L Supply .L Supply
.s1 .s1
Units need supplies in order to attack. Each update, and each time they Units need supplies in order to attack. See info \*Qsupply\*U.
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.
.s1 .s1
.L Fortification .L Fortification
.s1 .s1

View file

@ -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 a) if the sector is a cap, it costs $1 per etu since
the last update the last update
b) people in non-sanctuary sectors eat b) people in non-sanctuary sectors eat
1) If not enough is available, the sector If not enough is available, the excess people will
uses the supply routines to draw more. starve off. No more than 50% of the people
2) If still not enough is available, in a sector can die; the uw's die first, then
the excess people will starve off. the civs, then the mil.
a) No more than 50% of the people
in a sect can die;
the uw's die first, then
the civs, then the mil.
c) if there was starvation, the work percentage is set c) if there was starvation, the work percentage is set
to 0, otherwise the work rate rises by to 0, otherwise the work rate rises by
8+(1-15), max of 100 8+(1-15), max of 100

View file

@ -11,7 +11,7 @@ sectors, land units, and ships that will starve at the update.
.s1 .s1
With this syntax, the starvation command displays all sectors in With this syntax, the starvation command displays all sectors in
<SECTS> that currently do not have enough food. It does not take into account <SECTS> 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 It also does not worry about feeding babies... it merely
check for starvation. If you want population increase, check for starvation. If you want population increase,
you'll need to chuck in some extra food... you'll need to chuck in some extra food...

View file

@ -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 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) combat, the more chance the unit will use a basic load of supplies)
.s1 .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, 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 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 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 ships/forts/sectors, which will draw shells when they need them to
starvation, and ships/forts/sectors, which will draw shells when they need fire defensively.
them to fire defensively.
.s1 .s1
.L "Supply Sources" .L "Supply Sources"
.s1 .s1
@ -89,7 +85,4 @@ OTHER USES OF SUPPLY
In general, when any land unit/ship/fort needs shells, it will attempt to 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. draw them before use, if it does not already have them.
.s1 .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" .SA "lload, LandUnits"

View file

@ -84,13 +84,6 @@ do_feed(struct sctstr *sp, struct natstr *np, short *vec,
/* Conjure up 1f to make life easier for the player */ /* Conjure up 1f to make life easier for the player */
manna = vec[I_FOOD] = 1; 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); starved = feed_people(vec, etu);
if (starved > 0) { if (starved > 0) {

View file

@ -59,9 +59,7 @@ prod_land(int etus, int natnum, struct bp *bp, int build)
struct natstr *np; struct natstr *np;
int n, k = 0; int n, k = 0;
int start_money; int start_money;
int lastx = 9999, lasty = 9999;
bp_enable_cachepath();
for (n = 0; NULL != (lp = getlandp(n)); n++) { for (n = 0; NULL != (lp = getlandp(n)); n++) {
if (lp->lnd_own == 0) if (lp->lnd_own == 0)
continue; continue;
@ -77,16 +75,6 @@ prod_land(int etus, int natnum, struct bp *bp, int build)
sp = getsectp(lp->lnd_x, lp->lnd_y); sp = getsectp(lp->lnd_x, lp->lnd_y);
if (sp->sct_type == SCT_SANCT) if (sp->sct_type == SCT_SANCT)
continue; 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); np = getnatp(lp->lnd_own);
start_money = np->nat_money; start_money = np->nat_money;
upd_land(lp, etus, np, bp, build); 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) if (player->simulation)
np->nat_money = start_money; np->nat_money = start_money;
} }
bp_disable_cachepath();
bp_clear_cachepath();
return k; return k;
} }
@ -285,16 +271,5 @@ landrepair(struct lndstr *land, struct natstr *np, struct bp *bp, int etus)
static int static int
feed_land(struct lndstr *lp, int etus) 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); return feed_people(lp->lnd_item, etus);
} }

View file

@ -308,16 +308,9 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2])
sp->sct_updated = 1; sp->sct_updated = 1;
work = 0; 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); sctwork = do_feed(sp, np, vec, &work, etu);
bp_put_items(bp, sp, vec); bp_put_items(bp, sp, vec);
bp_disable_cachepath();
bp_clear_cachepath();
if (sp->sct_off || np->nat_money < 0) if (sp->sct_off || np->nat_money < 0)
continue; continue;

View file

@ -59,9 +59,7 @@ prod_ship(int etus, int natnum, struct bp *bp, int build)
struct natstr *np; struct natstr *np;
int n, k = 0; int n, k = 0;
int start_money; int start_money;
int lastx = 9999, lasty = 9999;
bp_enable_cachepath();
for (n = 0; NULL != (sp = getshipp(n)); n++) { for (n = 0; NULL != (sp = getshipp(n)); n++) {
if (sp->shp_own == 0) if (sp->shp_own == 0)
continue; continue;
@ -75,16 +73,6 @@ prod_ship(int etus, int natnum, struct bp *bp, int build)
} }
np = getnatp(sp->shp_own); 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; start_money = np->nat_money;
upd_ship(sp, etus, np, bp, build); upd_ship(sp, etus, np, bp, build);
if (build && !player->simulation) /* make sure to only autonav once */ 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)); needed = (int)ceil(food_needed(sp->shp_item, etus));
/* scrounge */ /* 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]) { if (needed > sp->shp_item[I_FOOD]) {
/* take from embarked land units, but don't starve them */ /* take from embarked land units, but don't starve them */
snxtitem_cargo(&ni, EF_LAND, EF_SHIP, sp->shp_uid); snxtitem_cargo(&ni, EF_LAND, EF_SHIP, sp->shp_uid);