unsigned char *resource;
double output;
int actual;
- int unit_work;
+ int unit_work, work_used;
i_type item;
- int worker_limit;
+ double worker_limit;
int material_limit, res_limit;
int material_consume;
int val;
if (unit_work == 0)
unit_work = 1;
- worker_limit = roundavg(work * p_e / unit_work);
+ worker_limit = work * p_e / unit_work;
res_limit = prod_resource_limit(product, resource);
material_consume = res_limit;
if (material_consume > worker_limit)
- material_consume = worker_limit;
+ material_consume = (int)worker_limit;
if (material_consume > material_limit)
material_consume = material_limit;
if (material_consume == 0)
}
}
- /* The MIN() here is to take care of integer rounding errors */
- if (p_e > 0.0) {
- return MIN(work, (int)(unit_work * material_consume / p_e));
- }
- return 0;
+ if (CANT_HAPPEN(p_e <= 0.0))
+ return 0;
+ work_used = roundavg(unit_work * material_consume / p_e);
+ if (CANT_HAPPEN(work_used > work))
+ return work;
+ return work_used;
}
/*