Rearrange produce() and prod() a bit to make them more similar
This commit is contained in:
parent
ba2600e7db
commit
739852dd3f
2 changed files with 30 additions and 39 deletions
|
@ -72,17 +72,17 @@ prod(void)
|
||||||
double real; /* floating pt version of act */
|
double real; /* floating pt version of act */
|
||||||
int work;
|
int work;
|
||||||
int totpop;
|
int totpop;
|
||||||
int act; /* actual production */
|
int material_consume; /* actual production */
|
||||||
double cost;
|
double cost;
|
||||||
int i;
|
int i;
|
||||||
int max; /* production w/infinite materials */
|
int max_consume; /* production w/infinite materials */
|
||||||
int nsect;
|
int nsect;
|
||||||
double take;
|
double take;
|
||||||
double mtake;
|
double mtake;
|
||||||
int there;
|
int there;
|
||||||
int unit_work; /* sum of component amounts */
|
int unit_work; /* sum of component amounts */
|
||||||
int used; /* production w/infinite workforce */
|
int mat_limit, res_limit;
|
||||||
int res_limit;
|
int worker_limit;
|
||||||
i_type it;
|
i_type it;
|
||||||
i_type vtype;
|
i_type vtype;
|
||||||
unsigned char *resource;
|
unsigned char *resource;
|
||||||
|
@ -174,10 +174,6 @@ prod(void)
|
||||||
if (eff < 60)
|
if (eff < 60)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
p_e = eff / 100.0;
|
|
||||||
if (p_e > 1.0)
|
|
||||||
p_e = 1.0;
|
|
||||||
|
|
||||||
if (type == SCT_ENLIST) {
|
if (type == SCT_ENLIST) {
|
||||||
int maxmil;
|
int maxmil;
|
||||||
int enlisted;
|
int enlisted;
|
||||||
|
@ -195,7 +191,7 @@ prod(void)
|
||||||
}
|
}
|
||||||
if (enlisted < 0)
|
if (enlisted < 0)
|
||||||
enlisted = 0;
|
enlisted = 0;
|
||||||
prprod(sect.sct_x, sect.sct_y, type, p_e, 1.0, work,
|
prprod(sect.sct_x, sect.sct_y, type, eff / 100.0, 1.0, work,
|
||||||
ichr[I_MILIT].i_mnem, enlisted, maxmil, enlisted * 3,
|
ichr[I_MILIT].i_mnem, enlisted, maxmil, enlisted * 3,
|
||||||
"c\0\0", &enlisted, &enlisted, nsect++);
|
"c\0\0", &enlisted, &enlisted, nsect++);
|
||||||
continue;
|
continue;
|
||||||
|
@ -209,32 +205,29 @@ prod(void)
|
||||||
resource = (unsigned char *)§ + pp->p_nrndx;
|
resource = (unsigned char *)§ + pp->p_nrndx;
|
||||||
else
|
else
|
||||||
resource = NULL;
|
resource = NULL;
|
||||||
used = prod_materials_cost(pp, sect.sct_item, &unit_work);
|
|
||||||
/*
|
mat_limit = prod_materials_cost(pp, sect.sct_item, &unit_work);
|
||||||
* sect p_e (inc improvements)
|
|
||||||
*/
|
/* sector p.e. */
|
||||||
|
p_e = eff / 100.0;
|
||||||
if (resource) {
|
if (resource) {
|
||||||
unit_work++;
|
unit_work++;
|
||||||
p_e *= *resource / 100.0;
|
p_e *= *resource / 100.0;
|
||||||
}
|
}
|
||||||
if (unit_work == 0)
|
if (unit_work == 0)
|
||||||
unit_work = 1;
|
unit_work = 1;
|
||||||
/*
|
|
||||||
* production effic.
|
|
||||||
*/
|
|
||||||
prodeff = prod_eff(type, natp->nat_level[pp->p_nlndx]);
|
|
||||||
/*
|
|
||||||
* is production limited by resources or
|
|
||||||
* workforce?
|
|
||||||
*/
|
|
||||||
max = (int)(work * p_e / (double)unit_work + 0.5);
|
|
||||||
res_limit = prod_resource_limit(pp, resource);
|
|
||||||
if (max > res_limit)
|
|
||||||
max = res_limit;
|
|
||||||
act = MIN(used, max);
|
|
||||||
|
|
||||||
real = (double)act * prodeff;
|
worker_limit = (int)(work * p_e / (double)unit_work + 0.5);
|
||||||
maxr = (double)max * prodeff;
|
res_limit = prod_resource_limit(pp, resource);
|
||||||
|
|
||||||
|
max_consume = res_limit;
|
||||||
|
if (max_consume > worker_limit)
|
||||||
|
max_consume = worker_limit;
|
||||||
|
material_consume = MIN(max_consume, mat_limit);
|
||||||
|
|
||||||
|
prodeff = prod_eff(type, natp->nat_level[pp->p_nlndx]);
|
||||||
|
real = (double)material_consume * prodeff;
|
||||||
|
maxr = (double)max_consume * prodeff;
|
||||||
|
|
||||||
if (vtype != I_NONE) {
|
if (vtype != I_NONE) {
|
||||||
real = MIN(999.0, real);
|
real = MIN(999.0, real);
|
||||||
|
|
|
@ -75,29 +75,27 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work,
|
||||||
material_limit = prod_materials_cost(product, vec, &unit_work);
|
material_limit = prod_materials_cost(product, vec, &unit_work);
|
||||||
if (material_limit <= 0)
|
if (material_limit <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
/*
|
|
||||||
* calculate production efficiency.
|
/* sector p.e. */
|
||||||
*/
|
|
||||||
p_e = neweff / 100.0;
|
p_e = neweff / 100.0;
|
||||||
if (resource) {
|
if (resource) {
|
||||||
unit_work++;
|
unit_work++;
|
||||||
p_e *= *resource / 100.0;
|
p_e *= *resource / 100.0;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* determine number that can be made with
|
|
||||||
* the available workforce
|
|
||||||
*/
|
|
||||||
if (unit_work == 0)
|
if (unit_work == 0)
|
||||||
unit_work = 1;
|
unit_work = 1;
|
||||||
material_consume = material_limit;
|
|
||||||
worker_limit = roundavg(work * p_e / unit_work);
|
worker_limit = roundavg(work * p_e / unit_work);
|
||||||
|
res_limit = prod_resource_limit(product, resource);
|
||||||
|
|
||||||
|
material_consume = res_limit;
|
||||||
if (material_consume > worker_limit)
|
if (material_consume > worker_limit)
|
||||||
material_consume = worker_limit;
|
material_consume = worker_limit;
|
||||||
res_limit = prod_resource_limit(product, resource);
|
if (material_consume > material_limit)
|
||||||
if (material_consume > res_limit)
|
material_consume = material_limit;
|
||||||
material_consume = res_limit;
|
|
||||||
if (material_consume == 0)
|
if (material_consume == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
prodeff = prod_eff(desig, np->nat_level[product->p_nlndx]);
|
prodeff = prod_eff(desig, np->nat_level[product->p_nlndx]);
|
||||||
if (prodeff <= 0.0 && !player->simulation) {
|
if (prodeff <= 0.0 && !player->simulation) {
|
||||||
wu(0, sp->sct_own,
|
wu(0, sp->sct_own,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue