Main Page | Data Structures | Directories | File List | Data Fields | Globals

stats.c

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------- *
00002  * ldsvguts.c
00003  * This file is part of lincity.
00004  * Lincity is copyright (c) I J Peters 1995-1997, (c) Greg Sharp 1997-2002.
00005  * Portions copyright (c) Corey Keasling, 2000-2002.
00006  * ---------------------------------------------------------------------- */
00007 #include "lcconfig.h"
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 
00011 #include "lin-city.h"
00012 #include "lctypes.h"
00013 #include "engglobs.h"
00014 #include "pbar.h"
00015 #include "stats.h"
00016 
00017 /* ---------------------------------------------------------------------- *
00018  * Public Global Variables
00019  * ---------------------------------------------------------------------- */
00020 
00021 /* Daily accumulators */
00022 int food_in_markets;
00023 int jobs_in_markets;
00024 int coal_in_markets;
00025 int goods_in_markets;
00026 int ore_in_markets; 
00027 int steel_in_markets; 
00028 int waste_in_markets; 
00029 
00030 /* Monthly accumulators */
00031 int tfood_in_markets;
00032 int tjobs_in_markets;
00033 int tcoal_in_markets;
00034 int tgoods_in_markets;
00035 int tore_in_markets;
00036 int tsteel_in_markets;
00037 int twaste_in_markets;
00038 int tpopulation;
00039 int tstarving_population;
00040 int tunemployed_population;
00041 
00042 /* yearly */
00043 int income_tax; 
00044 int coal_tax; 
00045 int goods_tax; 
00046 int export_tax; 
00047 int import_cost;
00048 int unemployment_cost; 
00049 int transport_cost; 
00050 int windmill_cost; 
00051 int university_cost; 
00052 int recycle_cost; 
00053 int deaths_cost; 
00054 int health_cost; 
00055 int rocket_pad_cost; 
00056 int school_cost; 
00057 int fire_cost; 
00058 int cricket_cost; 
00059 int other_cost;
00060 
00061 /* Last Year's totals */
00062 int ly_income_tax;
00063 int ly_coal_tax;
00064 int ly_goods_tax;
00065 int ly_export_tax;
00066 int ly_import_cost;
00067 int ly_other_cost;
00068 int ly_unemployment_cost;
00069 int ly_transport_cost;
00070 int ly_university_cost;
00071 int ly_recycle_cost;
00072 int ly_school_cost;
00073 int ly_deaths_cost;
00074 int ly_health_cost;
00075 int ly_rocket_pad_cost;
00076 int ly_interest;
00077 int ly_windmill_cost;
00078 int ly_cricket_cost;
00079 int ly_fire_cost;
00080 
00081 /* Averaging variables */
00082 int data_last_month;
00083 
00084 
00085 /* ---------------------------------------------------------------------- *
00086  * Private Function Prototypes
00087  * ---------------------------------------------------------------------- */
00088 void inventory_market(int x, int y);
00089 
00090 
00091 void
00092 init_daily(void)
00093 {
00094     population = 0;
00095     starving_population = 0;
00096     unemployed_population = 0;
00097     food_in_markets = 0;
00098     jobs_in_markets = 0;
00099     coal_in_markets = 0;
00100     goods_in_markets = 0;
00101     ore_in_markets = 0;
00102     steel_in_markets = 0;
00103 }
00104 
00105 void
00106 init_monthly(void)
00107 {
00108     data_last_month = 0;
00109     
00110     tpopulation = 0;
00111     tstarving_population = 0;
00112     tfood_in_markets = 0;
00113     tjobs_in_markets = 0;
00114     tcoal_in_markets = 0;
00115     tgoods_in_markets = 0;
00116     tore_in_markets = 0;
00117     tsteel_in_markets = 0;
00118     tunemployed_population = 0;
00119     unnat_deaths = 0;
00120 }
00121 
00122 void
00123 init_yearly(void)
00124 {
00125     income_tax = 0;
00126     coal_tax = 0;
00127     unemployment_cost = 0;
00128     transport_cost = 0;
00129     goods_tax = 0;
00130     export_tax = 0;
00131     import_cost = 0;
00132     windmill_cost = 0;
00133     university_cost = 0;
00134     recycle_cost = 0;
00135     deaths_cost = 0;
00136     health_cost = 0;
00137     rocket_pad_cost = 0;
00138     school_cost = 0;
00139     fire_cost = 0;
00140     cricket_cost = 0;
00141 }
00142 
00143 void
00144 init_lastyear(void)
00145 {
00146     ly_income_tax = 0;
00147     ly_coal_tax = 0;
00148     ly_goods_tax = 0;
00149     ly_export_tax = 0;
00150     ly_import_cost = 0;
00151     ly_other_cost = 0;
00152     ly_unemployment_cost = 0;
00153     ly_transport_cost = 0;
00154     ly_university_cost = 0;
00155     ly_recycle_cost = 0;
00156     ly_school_cost = 0;
00157     ly_deaths_cost = 0;
00158     ly_health_cost = 0;
00159     ly_rocket_pad_cost = 0;
00160     ly_interest = 0;
00161     ly_windmill_cost = 0;
00162     ly_cricket_cost = 0;
00163     ly_fire_cost = 0;
00164 }
00165 
00166 void
00167 inventory(int x, int y)
00168 {
00169 
00170     switch(get_group_of_type(MP_TYPE(x,y))) {
00171 
00172     case GROUP_MARKET: 
00173         inventory_market(x, y); 
00174         break;
00175     
00176     default: {
00177         printf("Default in inventory(%d,%d): got %d\n"), 
00178             x, y, get_group_of_type(MP_TYPE(x,y));
00179         break;
00180     }
00181 
00182     }
00183 }
00184 
00185 void
00186 init_inventory(void)
00187 {
00188     init_daily();
00189     init_monthly();
00190     init_yearly();
00191     init_lastyear();
00192 }
00193 
00194 void
00195 inventory_market(int x, int y) 
00196 {
00197     food_in_markets += MP_INFO(x,y).int_1;
00198     jobs_in_markets += MP_INFO(x,y).int_2;
00199     coal_in_markets += MP_INFO(x,y).int_3;
00200     goods_in_markets += MP_INFO(x,y).int_4;
00201     ore_in_markets += MP_INFO(x,y).int_5;
00202     steel_in_markets += MP_INFO(x,y).int_6;
00203     waste_in_markets += MP_INFO(x,y).int_7;
00204 }
00205 
00206 
00207 /* XXX: WCK:  Why oh why must we divide by arbitrary values, below? */
00208 /* If this is fixed, make sure to fix it in pbar also! */
00209 
00210 void
00211 add_daily_to_monthly(void)
00212 {
00213     data_last_month++;
00214     
00215     tpopulation += population;
00216     tstarving_population += starving_population;
00217     tfood_in_markets += food_in_markets / 1000;
00218     tjobs_in_markets += jobs_in_markets / 1000;
00219     tcoal_in_markets += coal_in_markets / 250;
00220     tgoods_in_markets += goods_in_markets / 500;
00221     tore_in_markets += ore_in_markets / 500;
00222     tsteel_in_markets += steel_in_markets / 25;
00223     twaste_in_markets += waste_in_markets;
00224     tunemployed_population += unemployed_population;
00225 }

Generated on Sun Dec 26 11:23:26 2004 for lincity by  doxygen 1.3.9.1