00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <config.h>
00037
00038 #include "budg.h"
00039 #include "item.h"
00040 #include "land.h"
00041 #include "path.h"
00042 #include "player.h"
00043 #include "ship.h"
00044 #include "update.h"
00045
00046 void
00047 prepare_sects(int etu, struct bp *bp)
00048 {
00049 struct sctstr *sp;
00050 struct natstr *np;
00051 int n, civ_tax, uw_tax, mil_pay;
00052
00053 memset(levels, 0, sizeof(levels));
00054
00055
00056 if (opt_FALLOUT) {
00057 if (!player->simulation) {
00058
00059 for (n = 0; NULL != (sp = getsectid(n)); n++)
00060 sp->sct_updated = sp->sct_fallout != 0;
00061
00062 for (n = 0; NULL != (sp = getsectid(n)); n++)
00063 if (sp->sct_updated)
00064 do_fallout(sp, etu);
00065
00066 for (n = 0; NULL != (sp = getsectid(n)); n++)
00067 if (sp->sct_updated)
00068 spread_fallout(sp, etu);
00069
00070 for (n = 0; NULL != (sp = getsectid(n)); n++)
00071 if (sp->sct_fallout)
00072 decay_fallout(sp, etu);
00073 }
00074 }
00075 for (n = 0; NULL != (sp = getsectid(n)); n++) {
00076 sp->sct_updated = 0;
00077
00078 if (sp->sct_type == SCT_WATER)
00079 continue;
00080 bp_set_from_sect(bp, sp);
00081 np = getnatp(sp->sct_own);
00082
00083 #ifdef DEBUG
00084 if (np->nat_stat == STAT_SANCT)
00085 logerror("Prepare.c: country in sanctuary skipped production");
00086 #endif
00087
00088 if (np->nat_stat != STAT_SANCT) {
00089 guerrilla(sp);
00090 do_plague(sp, np, etu);
00091 tax(sp, np, etu, &pops[sp->sct_own], &civ_tax, &uw_tax,
00092 &mil_pay);
00093 np->nat_money += civ_tax + uw_tax + mil_pay;
00094 if (sp->sct_type == SCT_BANK)
00095 np->nat_money += bank_income(sp, etu);
00096 }
00097 }
00098 for (n = 0; NULL != (np = getnatp(n)); n++) {
00099 np->nat_money += upd_slmilcosts(np->nat_cnum, etu);
00100 }
00101 }
00102
00103 void
00104 tax(struct sctstr *sp, struct natstr *np, int etu, long *pop, int *civ_tax,
00105 int *uw_tax, int *mil_pay)
00106 {
00107 *civ_tax = 0;
00108 *uw_tax = 0;
00109 *mil_pay = 0;
00110
00111 if (!player->simulation)
00112 populace(np, sp, etu);
00113 *civ_tax = (int)(0.5 + sp->sct_item[I_CIVIL] * sp->sct_effic *
00114 etu * money_civ / 100);
00115
00116
00117
00118 if (sp->sct_own != sp->sct_oldown)
00119 *civ_tax = *civ_tax / 4;
00120 *uw_tax = (int)(0.5 + sp->sct_item[I_UW] * sp->sct_effic *
00121 etu * money_uw / 100);
00122 *mil_pay = sp->sct_item[I_MILIT] * etu * money_mil;
00123
00124
00125
00126
00127 if (sp->sct_oldown == sp->sct_own)
00128 *pop += sp->sct_item[I_CIVIL];
00129 }
00130
00131 int
00132 upd_slmilcosts(natid n, int etu)
00133 {
00134 struct shpstr *sp;
00135 struct lndstr *lp;
00136 int mil = 0;
00137 int totalmil = 0;
00138 int mil_pay = 0;
00139 int i;
00140
00141 for (i = 0; NULL != (sp = getshipp(i)); i++) {
00142 if (!sp->shp_own || sp->shp_own != n)
00143 continue;
00144 if ((mil = sp->shp_item[I_MILIT]) > 0)
00145 totalmil += mil;
00146 }
00147 for (i = 0; NULL != (lp = getlandp(i)); i++) {
00148 if (!lp->lnd_own || lp->lnd_own != n)
00149 continue;
00150 if ((mil = lp->lnd_item[I_MILIT]) > 0)
00151 totalmil += mil;
00152 }
00153 mil_pay = totalmil * etu * money_mil;
00154 return mil_pay;
00155 }
00156
00157 int
00158 bank_income(struct sctstr *sp, int etu)
00159 {
00160 return (int)(sp->sct_item[I_BAR] * etu * bankint * sp->sct_effic / 100);
00161 }