1 /* ---------------------------------------------------------------------- *
2  * ldsvguts.c
3  * This file is part of lincity.
4  * Lincity is copyright (c) I J Peters 1995-1997, (c) Greg Sharp 1997-2002.
5  * Portions copyright (c) Corey Keasling, 2000-2002.
6  * ---------------------------------------------------------------------- */
7 #include "lcconfig.h"
8 #include <stdio.h>
9 #include <stdlib.h>
10 
11 #include "lin-city.h"
12 #include "lctypes.h"
13 #include "engglobs.h"
14 #include "pbar.h"
15 #include "stats.h"
16 
17 /* ---------------------------------------------------------------------- *
18  * Public Global Variables
19  * ---------------------------------------------------------------------- */
20 
21 /* Daily accumulators */
22 int food_in_markets;
23 int jobs_in_markets;
24 int coal_in_markets;
25 int goods_in_markets;
26 int ore_in_markets;
27 int steel_in_markets;
28 int waste_in_markets;
29 
30 /* Monthly accumulators */
31 int tfood_in_markets;
32 int tjobs_in_markets;
33 int tcoal_in_markets;
34 int tgoods_in_markets;
35 int tore_in_markets;
36 int tsteel_in_markets;
37 int twaste_in_markets;
38 int tpopulation;
39 int tstarving_population;
40 int tunemployed_population;
41 
42 /* yearly */
43 int income_tax;
44 int coal_tax;
45 int goods_tax;
46 int export_tax;
47 int import_cost;
48 int unemployment_cost;
49 int transport_cost;
50 int windmill_cost;
51 int university_cost;
52 int recycle_cost;
53 int deaths_cost;
54 int health_cost;
55 int rocket_pad_cost;
56 int school_cost;
57 int fire_cost;
58 int cricket_cost;
59 int other_cost;
60 
61 /* Last Year's totals */
62 int ly_income_tax;
63 int ly_coal_tax;
64 int ly_goods_tax;
65 int ly_export_tax;
66 int ly_import_cost;
67 int ly_other_cost;
68 int ly_unemployment_cost;
69 int ly_transport_cost;
70 int ly_university_cost;
71 int ly_recycle_cost;
72 int ly_school_cost;
73 int ly_deaths_cost;
74 int ly_health_cost;
75 int ly_rocket_pad_cost;
76 int ly_interest;
77 int ly_windmill_cost;
78 int ly_cricket_cost;
79 int ly_fire_cost;
80 
81 /* Averaging variables */
82 int data_last_month;
83 
84 
85 /* ---------------------------------------------------------------------- *
86  * Private Function Prototypes
87  * ---------------------------------------------------------------------- */
88 void inventory_market(int x, int y);
89 
90 
91 void
init_daily(void)92 init_daily(void)
93 {
94     population = 0;
95     starving_population = 0;
96     unemployed_population = 0;
97     food_in_markets = 0;
98     jobs_in_markets = 0;
99     coal_in_markets = 0;
100     goods_in_markets = 0;
101     ore_in_markets = 0;
102     steel_in_markets = 0;
103 }
104 
105 void
init_monthly(void)106 init_monthly(void)
107 {
108     data_last_month = 0;
109 
110     tpopulation = 0;
111     tstarving_population = 0;
112     tfood_in_markets = 0;
113     tjobs_in_markets = 0;
114     tcoal_in_markets = 0;
115     tgoods_in_markets = 0;
116     tore_in_markets = 0;
117     tsteel_in_markets = 0;
118     tunemployed_population = 0;
119     unnat_deaths = 0;
120 }
121 
122 void
init_yearly(void)123 init_yearly(void)
124 {
125     income_tax = 0;
126     coal_tax = 0;
127     unemployment_cost = 0;
128     transport_cost = 0;
129     goods_tax = 0;
130     export_tax = 0;
131     import_cost = 0;
132     windmill_cost = 0;
133     university_cost = 0;
134     recycle_cost = 0;
135     deaths_cost = 0;
136     health_cost = 0;
137     rocket_pad_cost = 0;
138     school_cost = 0;
139     fire_cost = 0;
140     cricket_cost = 0;
141 }
142 
143 void
init_lastyear(void)144 init_lastyear(void)
145 {
146     ly_income_tax = 0;
147     ly_coal_tax = 0;
148     ly_goods_tax = 0;
149     ly_export_tax = 0;
150     ly_import_cost = 0;
151     ly_other_cost = 0;
152     ly_unemployment_cost = 0;
153     ly_transport_cost = 0;
154     ly_university_cost = 0;
155     ly_recycle_cost = 0;
156     ly_school_cost = 0;
157     ly_deaths_cost = 0;
158     ly_health_cost = 0;
159     ly_rocket_pad_cost = 0;
160     ly_interest = 0;
161     ly_windmill_cost = 0;
162     ly_cricket_cost = 0;
163     ly_fire_cost = 0;
164 }
165 
166 void
inventory(int x,int y)167 inventory(int x, int y)
168 {
169 
170     switch(get_group_of_type(MP_TYPE(x,y))) {
171 
172     case GROUP_MARKET:
173 	inventory_market(x, y);
174 	break;
175 
176     default: {
177 	printf("Default in inventory(%d,%d): got %d\n",
178 	    x, y, get_group_of_type(MP_TYPE(x,y)));
179 	break;
180     }
181 
182     }
183 }
184 
185 void
init_inventory(void)186 init_inventory(void)
187 {
188     init_daily();
189     init_monthly();
190     init_yearly();
191     init_lastyear();
192 }
193 
194 void
inventory_market(int x,int y)195 inventory_market(int x, int y)
196 {
197     food_in_markets += MP_INFO(x,y).int_1;
198     jobs_in_markets += MP_INFO(x,y).int_2;
199     coal_in_markets += MP_INFO(x,y).int_3;
200     goods_in_markets += MP_INFO(x,y).int_4;
201     ore_in_markets += MP_INFO(x,y).int_5;
202     steel_in_markets += MP_INFO(x,y).int_6;
203     waste_in_markets += MP_INFO(x,y).int_7;
204 }
205 
206 
207 /* XXX: WCK:  Why oh why must we divide by arbitrary values, below? */
208 /* If this is fixed, make sure to fix it in pbar also! */
209 
210 void
add_daily_to_monthly(void)211 add_daily_to_monthly(void)
212 {
213     data_last_month++;
214 
215     tpopulation += population;
216     tstarving_population += starving_population;
217     tfood_in_markets += food_in_markets / 1000;
218     tjobs_in_markets += jobs_in_markets / 1000;
219     tcoal_in_markets += coal_in_markets / 250;
220     tgoods_in_markets += goods_in_markets / 500;
221     tore_in_markets += ore_in_markets / 500;
222     tsteel_in_markets += steel_in_markets / 25;
223     twaste_in_markets += waste_in_markets;
224     tunemployed_population += unemployed_population;
225 }
226