(food_needed): New.
(feed_ship, feed_land): Use it. (do_feed): Use it. Estimate of food needed was one too large for integer food needs. Used to round fractional food need to nearest instead of up for supply_commod(), which could cause starvation. (s_commod, get_minimum): Use it. Estimate of food needed was one too large for integer food needs. s_commod() used to reserve one more than get_minimum() would have returned; it's now the same. (famine_victims): New. (feed_people): Use it. This rounds victim fractions down instead of up. It also dosn't flush needs <=1 to zero. Doesn't change starvation, as do_feed() always produces at least one emergency food. Does change food consumption. (starve_some): New. (feed_people): Use it. (feed_ship): Use feed_people(). This rounds victim fractions down instead of up. (feed_land): Use feed_people(). Rounding of victim fractions unchanged. Feeds all people not just mil; closes #913997. (starv_people): New. (starv_sects, starv_ships, starv_units): Use it. Fixes starve land to talk about people instead of mil. (starv_sects): Use famine_victims() rather than feed_people(). Take emergency food into account, because feed_people() doesn't. Don't aim for one extra food, for consistency with starv_ships() and starv_units(). (feed_people): Remove useless parameter. Simplify. (starv_ships, starv_ships): Use famine_victims() rather than feed_ship() and feed_land(). (feed_ship, feed_land): Remove useless parameters. Internal linkage. Simplify. (feed_land): Call resupply_commod() only if there's a food shortage. Don't scrounge lnd_ship for food, resupply_commod() already does.
This commit is contained in:
parent
0ac31b3ece
commit
109dad1bee
6 changed files with 119 additions and 203 deletions
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#include <math.h>
|
||||
#include "misc.h"
|
||||
#include "nat.h"
|
||||
#include "ship.h"
|
||||
|
@ -202,11 +203,9 @@ s_commod(int own, int x, int y, i_type type, int total_wanted,
|
|||
continue;
|
||||
if (!BestLandPath(buf, &dest, §, &move_cost, MOB_ROAD))
|
||||
continue;
|
||||
if (!opt_NOFOOD && type == I_FOOD) {
|
||||
minimum = 2 + ((etu_per_update * eatrate)
|
||||
* (sect.sct_item[I_CIVIL] + sect.sct_item[I_MILIT]
|
||||
+ sect.sct_item[I_UW]));
|
||||
}
|
||||
if (!opt_NOFOOD && type == I_FOOD)
|
||||
minimum = 1 + (int)ceil(food_needed(sect.sct_item,
|
||||
etu_per_update));
|
||||
if (sect.sct_item[type] <= minimum) {
|
||||
/* Don't bother... */
|
||||
continue;
|
||||
|
@ -278,9 +277,8 @@ s_commod(int own, int x, int y, i_type type, int total_wanted,
|
|||
if (!BestLandPath(buf, &dest, §, &move_cost, MOB_ROAD))
|
||||
continue;
|
||||
if (!opt_NOFOOD && type == I_FOOD)
|
||||
minimum = 2 + ((etu_per_update * eatrate)
|
||||
* (ship.shp_item[I_CIVIL] + ship.shp_item[I_MILIT]
|
||||
+ ship.shp_item[I_UW]));
|
||||
minimum = 1 + (int)ceil(food_needed(ship.shp_item,
|
||||
etu_per_update));
|
||||
if (ship.shp_item[type] <= minimum) {
|
||||
/* Don't bother... */
|
||||
continue;
|
||||
|
@ -438,7 +436,7 @@ get_minimum(struct lndstr *lp, i_type type)
|
|||
case I_FOOD:
|
||||
if (opt_NOFOOD)
|
||||
return 0; /* no food reqd, get out */
|
||||
want = (double)etu_per_update * eatrate * lp->lnd_item[I_MILIT] + 1;
|
||||
want = (int)ceil(food_needed(lp->lnd_item, etu_per_update));
|
||||
break;
|
||||
case I_SHELL:
|
||||
want = lp->lnd_ammo;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue