From 991b59183d709984a55187a6c8b3738722fbe2cb Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 3 Jun 2016 20:24:04 +0200 Subject: [PATCH] update: Eliminate produce_sect()'s getnatp() Make callers pass struct natstr * instead of a country number. All callers have it already. Signed-off-by: Markus Armbruster --- include/prototypes.h | 2 +- src/lib/commands/budg.c | 4 ++-- src/lib/update/main.c | 4 ++-- src/lib/update/sect.c | 7 ++----- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/include/prototypes.h b/include/prototypes.h index 600e321f..007d477b 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -718,7 +718,7 @@ extern void guerrilla(struct sctstr *); extern void do_fallout(struct sctstr *, int); extern void spread_fallout(struct sctstr *, int); extern void decay_fallout(struct sctstr *, int); -extern void produce_sect(int, int, struct bp *, int[][2]); +extern void produce_sect(struct natstr *, int, struct bp *, int[][2]); /* ship.c */ extern int prod_ship(int, int, struct bp *, int); diff --git a/src/lib/commands/budg.c b/src/lib/commands/budg.c index 8984b0e2..83efbf71 100644 --- a/src/lib/commands/budg.c +++ b/src/lib/commands/budg.c @@ -30,7 +30,7 @@ * Thomas Ruschak, 1992 * Ville Virrankoski, 1995 * Steve McClure, 1997-2000 - * Markus Armbruster, 2004-2013 + * Markus Armbruster, 2004-2016 */ #include @@ -229,7 +229,7 @@ calc_all(int p_sect[][2], *lmaint = lnd_money[player->cnum]; /* Produce */ - produce_sect(player->cnum, etu, bp, p_sect); + produce_sect(np, etu, bp, p_sect); /* Build ships */ sea_money[player->cnum] = 0; diff --git a/src/lib/update/main.c b/src/lib/update/main.c index ffc90411..b2a0c0be 100644 --- a/src/lib/update/main.c +++ b/src/lib/update/main.c @@ -30,7 +30,7 @@ * Dave Pare, 1994 * Steve McClure, 1996 * Doug Hay, 1998 - * Markus Armbruster, 2006-2013 + * Markus Armbruster, 2006-2016 */ #include @@ -119,7 +119,7 @@ update_main(void) prod_land(etu, i, bp, 0); /* produce all sects */ - produce_sect(i, etu, bp, p_sect); + produce_sect(np, etu, bp, p_sect); /* build units */ prod_ship(etu, i, bp, 1); diff --git a/src/lib/update/sect.c b/src/lib/update/sect.c index 8c193b13..7d174358 100644 --- a/src/lib/update/sect.c +++ b/src/lib/update/sect.c @@ -242,10 +242,9 @@ decay_fallout(struct sctstr *sp, int etus) * Produce for a specific nation */ void -produce_sect(int natnum, int etu, struct bp *bp, int p_sect[][2]) +produce_sect(struct natstr *np, int etu, struct bp *bp, int p_sect[][2]) { struct sctstr *sp; - struct natstr *np; short buf[I_MAX + 1]; short *vec; int work, cost, ecost, pcost; @@ -254,7 +253,7 @@ produce_sect(int natnum, int etu, struct bp *bp, int p_sect[][2]) for (n = 0; NULL != (sp = getsectid(n)); n++) { if (sp->sct_type == SCT_WATER) continue; - if (sp->sct_own != natnum) + if (sp->sct_own != np->nat_cnum) continue; if (sp->sct_updated != 0) continue; @@ -267,8 +266,6 @@ produce_sect(int natnum, int etu, struct bp *bp, int p_sect[][2]) if (running_test_suite) seed_prng(sp->sct_uid); - np = getnatp(natnum); - if (player->simulation) { /* work on a copy, which will be discarded */ memcpy(buf, sp->sct_item, sizeof(buf));