(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
|
@ -163,7 +163,7 @@ buy(void)
|
||||||
ip = whichitem(comm.com_type);
|
ip = whichitem(comm.com_type);
|
||||||
n = sect.sct_item[ip->i_vtype];
|
n = sect.sct_item[ip->i_vtype];
|
||||||
qty = comm.com_amount;
|
qty = comm.com_amount;
|
||||||
if (qty + n > 9990) {
|
if (qty + n > ITEM_MAX) {
|
||||||
pr("That sector cannot hold %d more %s. It currently holds %d.\n",
|
pr("That sector cannot hold %d more %s. It currently holds %d.\n",
|
||||||
qty, ip->i_name, n);
|
qty, ip->i_name, n);
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
|
|
|
@ -258,9 +258,10 @@ move(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
amt_dst = sect.sct_item[vtype];
|
amt_dst = sect.sct_item[vtype];
|
||||||
if (32767 - amt_dst < amount) {
|
if (amount > ITEM_MAX - amt_dst) {
|
||||||
pr("Only enough room for %d in %s. The goods will be returned.\n",
|
pr("Only enough room for %d in %s. The goods will be returned.\n",
|
||||||
32767 - amt_dst, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
ITEM_MAX - amt_dst, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||||
|
/* FIXME Not nice. Move what we can and return the rest. */
|
||||||
getsect(x, y, §);
|
getsect(x, y, §);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +282,7 @@ move(void)
|
||||||
if (tsct.sct_own != player->cnum)
|
if (tsct.sct_own != player->cnum)
|
||||||
continue;
|
continue;
|
||||||
amt_dst = tsct.sct_item[vtype];
|
amt_dst = tsct.sct_item[vtype];
|
||||||
if (32767 - amt_dst < amount)
|
if (amount > ITEM_MAX - amt_dst)
|
||||||
continue;
|
continue;
|
||||||
n = -1;
|
n = -1;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -286,11 +286,9 @@ prod(void)
|
||||||
if (real < 0.0)
|
if (real < 0.0)
|
||||||
real = 0.0;
|
real = 0.0;
|
||||||
/* production backlog? */
|
/* production backlog? */
|
||||||
if ((there = sect.sct_item[vtype]) >= 9999) {
|
there = min(ITEM_MAX, sect.sct_item[vtype]);
|
||||||
there = 9999;
|
act = min(act, ITEM_MAX - there);
|
||||||
}
|
max = min(max, ITEM_MAX - there);
|
||||||
act = min(act, (9999 - there));
|
|
||||||
max = min(max, (9999 - there));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prodeff != 0) {
|
if (prodeff != 0) {
|
||||||
|
|
|
@ -178,8 +178,8 @@ dodistribute(struct sctstr *sp, int imex, s_char *path, double dist_i_cost,
|
||||||
amt = amt_sect;
|
amt = amt_sect;
|
||||||
if (sp->sct_mobil < excost * amt)
|
if (sp->sct_mobil < excost * amt)
|
||||||
amt = sp->sct_mobil / excost;
|
amt = sp->sct_mobil / excost;
|
||||||
if (amt + amt_dist > 9999)
|
if (amt > ITEM_MAX - amt_dist)
|
||||||
amt = 9999 - amt_dist;
|
amt = ITEM_MAX - amt_dist;
|
||||||
if (amt == 0)
|
if (amt == 0)
|
||||||
continue;
|
continue;
|
||||||
/* XXX replace with vector assign and putvec() */
|
/* XXX replace with vector assign and putvec() */
|
||||||
|
|
|
@ -138,20 +138,19 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work,
|
||||||
actual = 999;
|
actual = 999;
|
||||||
material_consume = (int)(actual / (product->p_effic * 0.01));
|
material_consume = (int)(actual / (product->p_effic * 0.01));
|
||||||
}
|
}
|
||||||
vec[item] += actual;
|
if (vec[item] + actual > ITEM_MAX) {
|
||||||
if (vec[item] > 9999) {
|
|
||||||
material_consume =
|
material_consume =
|
||||||
roundavg((9999.0 - vec[item] + actual) *
|
roundavg((ITEM_MAX - vec[item]) * material_consume / actual);
|
||||||
material_consume / actual);
|
|
||||||
if (material_consume < 0)
|
if (material_consume < 0)
|
||||||
material_consume = 0;
|
material_consume = 0;
|
||||||
vec[item] = 9999;
|
vec[item] = ITEM_MAX;
|
||||||
if (( /* vtype != V_FOOD && */ sp->sct_own) &&
|
if (( /* vtype != V_FOOD && */ sp->sct_own) &&
|
||||||
(!player->simulation))
|
(!player->simulation))
|
||||||
wu(0, sp->sct_own,
|
wu(0, sp->sct_own,
|
||||||
"%s production backlog in %s\n",
|
"%s production backlog in %s\n",
|
||||||
product->p_name, ownxy(sp));
|
product->p_name, ownxy(sp));
|
||||||
}
|
} else
|
||||||
|
vec[item] += actual;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Reset produced amount by commodity production ratio
|
* Reset produced amount by commodity production ratio
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue