build scrap: Redo 4.2.3's fix for manufacturing military

scrap has always returned the scrapped planes' full crew, regardless
of efficiency.  build, however, charged only 10%.  If you built ten
planes with one crew each, you used up one military.  Or none, if you
abused random rounding.  If you scrapped them again, you got ten back.
Pretty pricey way to manufacture military, but wrong all the same.

4.2.3 plugged this hole by making build never round military to zero.
Ugly special case, and not documented.  Also doesn't prevent abuse of
random rounding for planes requiring more than 10 crew, but such
planes don't exist in the stock game.

Redo this fix:

1. Make scrap return crew proportional to efficiency, randomly
rounded.  Note that scrap returns only two thirds of the other
materials, rounded down.  Recycling materials isn't perfect, but
recycling aircrew is.

2. Drop the special case from build: treat military just like other
materials.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2014-01-12 18:40:45 +01:00
parent e2d176fd8a
commit eeb62ab280
6 changed files with 27 additions and 36 deletions

View file

@ -379,14 +379,9 @@ build_plane(struct sctstr *sp, int type, int tlev)
short mat[I_MAX+1];
int work;
struct plnstr plane;
double eff = PLANE_MINEFF / 100.0;
int mil;
mil = roundavg(pp->pl_crew * eff);
/* Always use at least 1 mil to build a plane */
if (mil == 0 && pp->pl_crew > 0)
mil = 1;
memset(mat, 0, sizeof(mat));
mat[I_MILIT] = pp->pl_crew;
mat[I_LCM] = pp->pl_lcm;
mat[I_HCM] = pp->pl_hcm;
work = PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm);
@ -399,12 +394,6 @@ build_plane(struct sctstr *sp, int type, int tlev)
return 0;
if (!build_can_afford(pp->pl_cost, PLANE_MINEFF, pp->pl_name))
return 0;
if (sp->sct_item[I_MILIT] < mil) {
pr("Not enough military for crew in %s\n",
xyas(sp->sct_x, sp->sct_y, player->cnum));
return 0;
}
sp->sct_item[I_MILIT] -= mil;
build_charge(sp, mat, work, pp->pl_cost, PLANE_MINEFF);
ef_blank(EF_PLANE, pick_unused_unit_uid(EF_PLANE), &plane);