(buy, move, prod, dodistribute, produce): Obey ITEM_MAX. Previous
change to move() was incomplete.
This commit is contained in:
parent
913774e53e
commit
9b7a65b865
5 changed files with 16 additions and 18 deletions
|
@ -178,8 +178,8 @@ dodistribute(struct sctstr *sp, int imex, s_char *path, double dist_i_cost,
|
|||
amt = amt_sect;
|
||||
if (sp->sct_mobil < excost * amt)
|
||||
amt = sp->sct_mobil / excost;
|
||||
if (amt + amt_dist > 9999)
|
||||
amt = 9999 - amt_dist;
|
||||
if (amt > ITEM_MAX - amt_dist)
|
||||
amt = ITEM_MAX - amt_dist;
|
||||
if (amt == 0)
|
||||
continue;
|
||||
/* XXX replace with vector assign and putvec() */
|
||||
|
|
|
@ -138,20 +138,19 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work,
|
|||
actual = 999;
|
||||
material_consume = (int)(actual / (product->p_effic * 0.01));
|
||||
}
|
||||
vec[item] += actual;
|
||||
if (vec[item] > 9999) {
|
||||
if (vec[item] + actual > ITEM_MAX) {
|
||||
material_consume =
|
||||
roundavg((9999.0 - vec[item] + actual) *
|
||||
material_consume / actual);
|
||||
roundavg((ITEM_MAX - vec[item]) * material_consume / actual);
|
||||
if (material_consume < 0)
|
||||
material_consume = 0;
|
||||
vec[item] = 9999;
|
||||
vec[item] = ITEM_MAX;
|
||||
if (( /* vtype != V_FOOD && */ sp->sct_own) &&
|
||||
(!player->simulation))
|
||||
wu(0, sp->sct_own,
|
||||
"%s production backlog in %s\n",
|
||||
product->p_name, ownxy(sp));
|
||||
}
|
||||
} else
|
||||
vec[item] += actual;
|
||||
}
|
||||
/*
|
||||
* Reset produced amount by commodity production ratio
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue