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 <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-06-03 20:24:04 +02:00
parent 60450f1637
commit 991b59183d
4 changed files with 7 additions and 10 deletions

View file

@ -718,7 +718,7 @@ extern void guerrilla(struct sctstr *);
extern void do_fallout(struct sctstr *, int); extern void do_fallout(struct sctstr *, int);
extern void spread_fallout(struct sctstr *, int); extern void spread_fallout(struct sctstr *, int);
extern void decay_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 */ /* ship.c */
extern int prod_ship(int, int, struct bp *, int); extern int prod_ship(int, int, struct bp *, int);

View file

@ -30,7 +30,7 @@
* Thomas Ruschak, 1992 * Thomas Ruschak, 1992
* Ville Virrankoski, 1995 * Ville Virrankoski, 1995
* Steve McClure, 1997-2000 * Steve McClure, 1997-2000
* Markus Armbruster, 2004-2013 * Markus Armbruster, 2004-2016
*/ */
#include <config.h> #include <config.h>
@ -229,7 +229,7 @@ calc_all(int p_sect[][2],
*lmaint = lnd_money[player->cnum]; *lmaint = lnd_money[player->cnum];
/* Produce */ /* Produce */
produce_sect(player->cnum, etu, bp, p_sect); produce_sect(np, etu, bp, p_sect);
/* Build ships */ /* Build ships */
sea_money[player->cnum] = 0; sea_money[player->cnum] = 0;

View file

@ -30,7 +30,7 @@
* Dave Pare, 1994 * Dave Pare, 1994
* Steve McClure, 1996 * Steve McClure, 1996
* Doug Hay, 1998 * Doug Hay, 1998
* Markus Armbruster, 2006-2013 * Markus Armbruster, 2006-2016
*/ */
#include <config.h> #include <config.h>
@ -119,7 +119,7 @@ update_main(void)
prod_land(etu, i, bp, 0); prod_land(etu, i, bp, 0);
/* produce all sects */ /* produce all sects */
produce_sect(i, etu, bp, p_sect); produce_sect(np, etu, bp, p_sect);
/* build units */ /* build units */
prod_ship(etu, i, bp, 1); prod_ship(etu, i, bp, 1);

View file

@ -242,10 +242,9 @@ decay_fallout(struct sctstr *sp, int etus)
* Produce for a specific nation * Produce for a specific nation
*/ */
void 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 sctstr *sp;
struct natstr *np;
short buf[I_MAX + 1]; short buf[I_MAX + 1];
short *vec; short *vec;
int work, cost, ecost, pcost; 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++) { for (n = 0; NULL != (sp = getsectid(n)); n++) {
if (sp->sct_type == SCT_WATER) if (sp->sct_type == SCT_WATER)
continue; continue;
if (sp->sct_own != natnum) if (sp->sct_own != np->nat_cnum)
continue; continue;
if (sp->sct_updated != 0) if (sp->sct_updated != 0)
continue; continue;
@ -267,8 +266,6 @@ produce_sect(int natnum, int etu, struct bp *bp, int p_sect[][2])
if (running_test_suite) if (running_test_suite)
seed_prng(sp->sct_uid); seed_prng(sp->sct_uid);
np = getnatp(natnum);
if (player->simulation) { if (player->simulation) {
/* work on a copy, which will be discarded */ /* work on a copy, which will be discarded */
memcpy(buf, sp->sct_item, sizeof(buf)); memcpy(buf, sp->sct_item, sizeof(buf));