(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:
parent
d5d8028ad1
commit
e5804f8dd8
3 changed files with 10 additions and 7 deletions
|
@ -87,7 +87,7 @@ prod(void)
|
||||||
int wforce;
|
int wforce;
|
||||||
i_type it;
|
i_type it;
|
||||||
i_type vtype;
|
i_type vtype;
|
||||||
s_char *resource;
|
u_char *resource;
|
||||||
s_char maxc[MAXPRCON][10];
|
s_char maxc[MAXPRCON][10];
|
||||||
s_char use[MAXPRCON][10];
|
s_char use[MAXPRCON][10];
|
||||||
int lcms, hcms;
|
int lcms, hcms;
|
||||||
|
@ -204,7 +204,7 @@ prod(void)
|
||||||
goto is_enlist;
|
goto is_enlist;
|
||||||
if (pp->p_nrndx != 0) {
|
if (pp->p_nrndx != 0) {
|
||||||
unit_work++;
|
unit_work++;
|
||||||
resource = ((s_char *)§) + pp->p_nrndx;
|
resource = (u_char *)§ + pp->p_nrndx;
|
||||||
p_e = (*resource * p_e) / 100.0;
|
p_e = (*resource * p_e) / 100.0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -57,7 +57,7 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work,
|
||||||
struct pchrstr *product;
|
struct pchrstr *product;
|
||||||
double p_e;
|
double p_e;
|
||||||
double prodeff;
|
double prodeff;
|
||||||
s_char *resource;
|
u_char *resource;
|
||||||
double output;
|
double output;
|
||||||
int actual;
|
int actual;
|
||||||
int unit_work;
|
int unit_work;
|
||||||
|
@ -82,7 +82,7 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work,
|
||||||
p_e = neweff / 100.0;
|
p_e = neweff / 100.0;
|
||||||
if (product->p_nrndx != 0) {
|
if (product->p_nrndx != 0) {
|
||||||
unit_work++;
|
unit_work++;
|
||||||
resource = ((s_char *)sp) + product->p_nrndx;
|
resource = (u_char *)sp + product->p_nrndx;
|
||||||
p_e = (*resource * p_e) / 100.0;
|
p_e = (*resource * p_e) / 100.0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -121,6 +121,7 @@ upd_ship(struct shpstr *sp, int etus,
|
||||||
int max_food;
|
int max_food;
|
||||||
struct pchrstr *product;
|
struct pchrstr *product;
|
||||||
s_char *resource;
|
s_char *resource;
|
||||||
|
int dep;
|
||||||
int n;
|
int n;
|
||||||
int mult;
|
int mult;
|
||||||
int needed;
|
int needed;
|
||||||
|
@ -180,9 +181,11 @@ upd_ship(struct shpstr *sp, int etus,
|
||||||
oil_gained = max_oil - sp->shp_item[I_OIL];
|
oil_gained = max_oil - sp->shp_item[I_OIL];
|
||||||
sp->shp_item[I_OIL] += oil_gained;
|
sp->shp_item[I_OIL] += oil_gained;
|
||||||
if (product->p_nrdep != 0 && oil_gained > 0) {
|
if (product->p_nrdep != 0 && oil_gained > 0) {
|
||||||
resource = ((s_char *)sectp) + product->p_nrndx;
|
resource = (u_char *)sectp + product->p_nrndx;
|
||||||
*resource -= roundavg(oil_gained *
|
dep = roundavg(oil_gained * product->p_nrdep / 100.0);
|
||||||
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) {
|
if ((mp->m_flags & M_FOOD) && sectp->sct_type == SCT_WATER) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue