X-Git-Url: http://git.pond.sub.org/?p=empserver;a=blobdiff_plain;f=src%2Flib%2Fupdate%2Fmain.c;h=1082aaa6cd41442780eb92d50115b2dc625156ac;hp=7f90e93d2544be4d2e79e090adee8c176da22c48;hb=9b7adfbe;hpb=5f263a7753dc728809ff85c993af975f6c76e61e diff --git a/src/lib/update/main.c b/src/lib/update/main.c index 7f90e93d2..1082aaa6c 100644 --- a/src/lib/update/main.c +++ b/src/lib/update/main.c @@ -51,202 +51,198 @@ #include #endif -long money[MAXNOC]; -long pops[MAXNOC]; -long sea_money[MAXNOC]; -long lnd_money[MAXNOC]; -long air_money[MAXNOC]; -long tpops[MAXNOC]; +long money[MAXNOC]; +long pops[MAXNOC]; +long sea_money[MAXNOC]; +long lnd_money[MAXNOC]; +long air_money[MAXNOC]; +long tpops[MAXNOC]; -extern int mil_dbl_pay; -int update_pending = 0; +extern int mil_dbl_pay; +int update_pending = 0; /*ARGSUSED*/ void update_main(void *argv) { - extern int etu_per_update; - extern double money_res; - int etu = etu_per_update; - int n; - int x; - int *bp; - int cn,cn2,rel; - struct natstr *cnp; - struct natstr *np; + extern int etu_per_update; + extern double money_res; + int etu = etu_per_update; + int n; + int x; + int *bp; + int cn, cn2, rel; + struct natstr *cnp; + struct natstr *np; - /* First, make sure all mobility is updated correctly. */ - if (opt_MOB_ACCESS) { - mob_ship(etu); - mob_sect(etu); - mob_plane(etu); - mob_land(etu); - } - update_pending = 1; - player->proc = empth_self(); - player->cnum = 0; - player->god = 1; - /* - * set up all the variables which get used in the - * sector production routine (for producing education, - * happiness, and printing out the state of the nation) - */ - logerror("production update (%d etus)", etu); - bzero((s_char *)pops, sizeof(pops)); - bzero((s_char *)air_money, sizeof(air_money)); - bzero((s_char *)sea_money, sizeof(sea_money)); - bzero((s_char *)lnd_money, sizeof(lnd_money)); - bp = (int *) calloc(WORLD_X * WORLD_Y * 7, sizeof(int)); - for (n=0; nnat_money; - tpops[n] = count_pop(n); - } + /* First, make sure all mobility is updated correctly. */ + if (opt_MOB_ACCESS) { + mob_ship(etu); + mob_sect(etu); + mob_plane(etu); + mob_land(etu); + } + update_pending = 1; + player->proc = empth_self(); + player->cnum = 0; + player->god = 1; + /* + * set up all the variables which get used in the + * sector production routine (for producing education, + * happiness, and printing out the state of the nation) + */ + logerror("production update (%d etus)", etu); + bzero((s_char *)pops, sizeof(pops)); + bzero((s_char *)air_money, sizeof(air_money)); + bzero((s_char *)sea_money, sizeof(sea_money)); + bzero((s_char *)lnd_money, sizeof(lnd_money)); + bp = (int *)calloc(WORLD_X * WORLD_Y * 7, sizeof(int)); + for (n = 0; n < MAXNOC; n++) { + money[n] = 0; + if ((np = getnatp(n)) == (struct natstr *)0) + continue; + money[n] = np->nat_money; + tpops[n] = count_pop(n); + } - logerror("preparing sectors..."); - prepare_sects(etu, bp); - logerror("done preparing sectors."); - logerror("producing for countries..."); - for (x=0; xnat_stat & STAT_SANCT ) { + bzero((s_char *)p_sect, sizeof(p_sect)); + mil_dbl_pay = 0; + if ((np = getnatp(x)) == (struct natstr *)0) + continue; + if (np->nat_stat & STAT_SANCT) { #ifdef DEBUG - logerror("Country %i is in sanctuary and did not update",x); + logerror("Country %i is in sanctuary and did not update", x); #endif - continue; - } - np->nat_money += (int) (np->nat_reserve * money_res * etu); + continue; + } + np->nat_money += (int)(np->nat_reserve * money_res * etu); - for(y=1; ynat_priorities[z] == y) { - do_prod(z, etu, x, bp, p_sect, - &sb, &sm, &pb, &pm, &lb, &lm); - } - } + for (y = 1; y < SCT_MAXDEF + 8; y++) { + for (z = 0; z < SCT_MAXDEF + 8; z++) { + if (np->nat_priorities[z] == y) { + do_prod(z, etu, x, bp, p_sect, + &sb, &sm, &pb, &pm, &lb, &lm); } - /* 0 is maintain, 1 is build */ - if (!sm) prod_ship(etu, x, bp, 0); - if (!sb) prod_ship(etu, x, bp, 1); - if (!pm) prod_plane(etu, x, bp, 0); - if (!pb) prod_plane(etu, x, bp, 1); - if (!lm) prod_land(etu, x, bp, 0); - if (!lb) prod_land(etu, x, bp, 1); - - /* produce all sects that haven't produced yet */ - produce_sect(x, etu, bp, p_sect, -1); - np->nat_money -= p_sect[SCT_CAPIT][1]; + } } - logerror("done producing for countries."); + /* 0 is maintain, 1 is build */ + if (!sm) + prod_ship(etu, x, bp, 0); + if (!sb) + prod_ship(etu, x, bp, 1); + if (!pm) + prod_plane(etu, x, bp, 0); + if (!pb) + prod_plane(etu, x, bp, 1); + if (!lm) + prod_land(etu, x, bp, 0); + if (!lb) + prod_land(etu, x, bp, 1); - finish_sects(etu); - prod_nat(etu); - age_levels(etu); - free(bp); - /*flushwu();*/ - if (opt_SLOW_WAR) { - /* Update war declarations */ - /* MOBILIZATION->SITZKRIEG->AT_WAR */ - for (cn=1; cn < MAXNOC; cn++) { - if ((cnp = getnatp(cn)) == 0) - break; - for (cn2=1; cn2 < MAXNOC; cn2++) { - if (cn2 == cn) - continue; - rel=getrel(cnp,cn2); - if (rel == MOBILIZATION){ - rel = SITZKRIEG; - setrel(cn,cn2,rel); - } - else if (rel == SITZKRIEG){ - rel = AT_WAR; - setrel(cn,cn2,rel); - } + /* produce all sects that haven't produced yet */ + produce_sect(x, etu, bp, p_sect, -1); + np->nat_money -= p_sect[SCT_CAPIT][1]; + } + logerror("done producing for countries."); + + finish_sects(etu); + prod_nat(etu); + age_levels(etu); + free(bp); + /*flushwu(); */ + if (opt_SLOW_WAR) { + /* Update war declarations */ + /* MOBILIZATION->SITZKRIEG->AT_WAR */ + for (cn = 1; cn < MAXNOC; cn++) { + if ((cnp = getnatp(cn)) == 0) + break; + for (cn2 = 1; cn2 < MAXNOC; cn2++) { + if (cn2 == cn) + continue; + rel = getrel(cnp, cn2); + if (rel == MOBILIZATION) { + rel = SITZKRIEG; + setrel(cn, cn2, rel); + } else if (rel == SITZKRIEG) { + rel = AT_WAR; + setrel(cn, cn2, rel); } - } + } } - /* Age contact */ - if (opt_LOSE_CONTACT) { - for (cn=1; cnnat_money -= (int) (money_mil * etu * mil_dbl_pay); - prod_land(etu,n,bp,0); - *land_maint=1; - } - else - if (sector_type == PRI_LBUILD){ - prod_land(etu,n,bp,1); - *land_build=1; - } - else { - produce_sect(n,etu,bp,p_sect,sector_type); - } + if (sector_type == PRI_SMAINT) { + prod_ship(etu, n, bp, 0); + *ship_maint = 1; + } else if (sector_type == PRI_SBUILD) { + prod_ship(etu, n, bp, 1); + *ship_build = 1; + } else if (sector_type == PRI_PMAINT) { + prod_plane(etu, n, bp, 0); + *plane_maint = 1; + } else if (sector_type == PRI_PBUILD) { + prod_plane(etu, n, bp, 1); + *plane_build = 1; + } else if (sector_type == PRI_LMAINT) { + if (*land_build) + np->nat_money -= (int)(money_mil * etu * mil_dbl_pay); + prod_land(etu, n, bp, 0); + *land_maint = 1; + } else if (sector_type == PRI_LBUILD) { + prod_land(etu, n, bp, 1); + *land_build = 1; + } else { + produce_sect(n, etu, bp, p_sect, sector_type); + } } -