(prod, produce, upd_ship): struct pchrstr p_nrndx refers to u_char,

not s_char.  Fix types.

(upd_ship): Catch resource underflow (should not happen).
This commit is contained in:
Markus Armbruster 2005-02-19 17:28:30 +00:00
parent d5d8028ad1
commit e5804f8dd8
3 changed files with 10 additions and 7 deletions

View file

@ -121,6 +121,7 @@ upd_ship(struct shpstr *sp, int etus,
int max_food;
struct pchrstr *product;
s_char *resource;
int dep;
int n;
int mult;
int needed;
@ -180,9 +181,11 @@ upd_ship(struct shpstr *sp, int etus,
oil_gained = max_oil - sp->shp_item[I_OIL];
sp->shp_item[I_OIL] += oil_gained;
if (product->p_nrdep != 0 && oil_gained > 0) {
resource = ((s_char *)sectp) + product->p_nrndx;
*resource -= roundavg(oil_gained *
product->p_nrdep / 100.0);
resource = (u_char *)sectp + product->p_nrndx;
dep = roundavg(oil_gained * product->p_nrdep / 100.0);
if (CANT_HAPPEN(dep > *resource))
dep = *resource;
*resource -= dep;
}
}
if ((mp->m_flags & M_FOOD) && sectp->sct_type == SCT_WATER) {