update: Move work percentage update into do_feed()

Since changing *sp is safe now, we can move the update of sp->sct_work
into do_feed(), use the return value for work, and drop parameter
workp.

The sp->sct_avail update looks similar, but there's a subtle
difference: it's skipped when the sector is stopped or its owner is
broke.  The caller already checks that, so leave the update there.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-06-04 07:30:40 +02:00
parent 4daf98a160
commit d30de533d7
3 changed files with 8 additions and 11 deletions

View file

@ -52,7 +52,7 @@ static int babies(int, int, double, int, int);
* feed the individual sector
*/
int
do_feed(struct sctstr *sp, struct natstr *np, int *workp, int etu)
do_feed(struct sctstr *sp, struct natstr *np, int etu)
{
int work_avail;
int starved, sctwork;
@ -116,13 +116,12 @@ do_feed(struct sctstr *sp, struct natstr *np, int *workp, int etu)
sp->sct_item[I_FOOD] = 0;
} else
sctwork = 100;
/* Here is where we truncate extra people, always */
trunc_people(sp, np);
*workp = work_avail;
if (!player->simulation)
sp->sct_work = sctwork;
return sctwork;
sp->sct_work = sctwork;
return work_avail;
}
int