void save_city_2(char *cname) { LOGD("[Lincity]save_city_2() %s\n",cname); int x, y, p; int dumbint = 0; gzFile ofile = gzopen(cname, "wb"); if (ofile == NULL) { printf(_("Save file <%s> - "), cname); do_error(_("Can't open save file!")); } /* Now we have upgraded game */ ldsv_version = WATERWELL_V2; gzprintf(ofile, "%d\n", ldsv_version); for (x = 0; x < WORLD_SIDE_LEN; x++) for (y = 0; y < WORLD_SIDE_LEN; y++) { /* TY po fl cr or i1 i2 i3 i4 i5 i6 i7 PL al ec ws gp wa wp ww wn g1 g2 g3 g4 DA TK AN d4 d5 d6 d7 d8 d9 */ gzprintf(ofile, "%u %d %d %u %u %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n" , MP_TYPE(x, y) , MP_INFO(x, y).population , MP_INFO(x, y).flags , MP_INFO(x, y).coal_reserve , MP_INFO(x, y).ore_reserve , MP_INFO(x, y).int_1 , MP_INFO(x, y).int_2 , MP_INFO(x, y).int_3 , MP_INFO(x, y).int_4 , MP_INFO(x, y).int_5 , MP_INFO(x, y).int_6 , MP_INFO(x, y).int_7 , MP_POL(x, y) , ground[x][y].altitude , ground[x][y].ecotable , ground[x][y].wastes , ground[x][y].pollution , ground[x][y].water_alt , ground[x][y].water_pol , ground[x][y].water_wast , ground[x][y].water_next , ground[x][y].int1 , ground[x][y].int2 , ground[x][y].int3 , ground[x][y].int4 , MP_DATE(x,y) // d1 = date of built , MP_TECH(x,y) // d2 = tech at build time , MP_ANIM(x,y) // d3 = animation_time (see reset_animation_time mess :) , dumbint // d4 could be image index for smooth animation, cf windmill anim_tile , dumbint // d5 percentage of activity to choose family of pic , dumbint // d6 , dumbint // d7 , dumbint // d8 , dumbint // d9 ); } gzprintf(ofile, "%d\n", main_screen_originx); gzprintf(ofile, "%d\n", main_screen_originy); gzprintf(ofile, "%d\n", total_time); for (x = 0; x < MAX_NUMOF_SUBSTATIONS; x++) { gzprintf(ofile, "%d\n", substationx[x]); gzprintf(ofile, "%d\n", substationy[x]); } gzprintf(ofile, "%d\n", numof_substations); for (x = 0; x < MAX_NUMOF_MARKETS; x++) { gzprintf(ofile, "%d\n", marketx[x]); gzprintf(ofile, "%d\n", markety[x]); } gzprintf(ofile, "%d\n", numof_markets); gzprintf(ofile, "%d\n", people_pool); gzprintf(ofile, "%o\n", total_money); gzprintf(ofile, "%d\n", income_tax_rate); gzprintf(ofile, "%d\n", coal_tax_rate); gzprintf(ofile, "%d\n", dole_rate); gzprintf(ofile, "%d\n", transport_cost_rate); gzprintf(ofile, "%d\n", goods_tax_rate); gzprintf(ofile, "%d\n", export_tax); gzprintf(ofile, "%d\n", export_tax_rate); gzprintf(ofile, "%d\n", import_cost); gzprintf(ofile, "%d\n", import_cost_rate); gzprintf(ofile, "%d\n", tech_level); gzprintf(ofile, "%d\n", tpopulation); gzprintf(ofile, "%d\n", tstarving_population); gzprintf(ofile, "%d\n", tunemployed_population); gzprintf(ofile, "%d\n", 0); /* waste_goods is obsolete */ gzprintf(ofile, "%d\n", power_made); gzprintf(ofile, "%d\n", power_used); gzprintf(ofile, "%d\n", coal_made); gzprintf(ofile, "%d\n", coal_used); gzprintf(ofile, "%d\n", goods_made); gzprintf(ofile, "%d\n", goods_used); gzprintf(ofile, "%d\n", ore_made); gzprintf(ofile, "%d\n", ore_used); gzprintf(ofile, "%d\n", 0); /* Removed diff_old_population, version 1.12 */ /* Changed, version 1.12 */ gzprintf(ofile, "%d\n", monthgraph_size); for (x = 0; x < monthgraph_size; x++) { gzprintf(ofile, "%d\n", monthgraph_pop[x]); gzprintf(ofile, "%d\n", monthgraph_starve[x]); gzprintf(ofile, "%d\n", monthgraph_nojobs[x]); gzprintf(ofile, "%d\n", monthgraph_ppool[x]); } gzprintf(ofile, "%d\n", rockets_launched); gzprintf(ofile, "%d\n", rockets_launched_success); gzprintf(ofile, "%d\n", coal_survey_done); for (x = 0; x < PBAR_DATA_SIZE; x++) for (p = 0; p < NUM_PBARS; p++) gzprintf(ofile, "%d\n", pbars[p].data[x]); for (p = 0; p < NUM_PBARS; p++) { gzprintf(ofile, "%d\n", pbars[p].oldtot); gzprintf(ofile, "%d\n", pbars[p].diff); } gzprintf(ofile, "%d\n", cheat_flag); gzprintf(ofile, "%d\n", total_pollution_deaths); gzprintf(ofile, "%f\n", pollution_deaths_history); gzprintf(ofile, "%d\n", total_starve_deaths); gzprintf(ofile, "%f\n", starve_deaths_history); gzprintf(ofile, "%d\n", total_unemployed_years); gzprintf(ofile, "%f\n", unemployed_history); gzprintf(ofile, "%d\n", max_pop_ever); gzprintf(ofile, "%d\n", total_evacuated); gzprintf(ofile, "%d\n", total_births); for (x = 0; x < NUMOF_MODULES; x++) gzprintf(ofile, "%d\n", module_help_flag[x]); if (strlen(given_scene) > 1) gzprintf(ofile, "%s\n", given_scene); else gzprintf(ofile, "dummy\n"); /* 1 */ gzprintf(ofile, "%d\n", highest_tech_level); /* 2 */ gzprintf(ofile, "sust %d %d %d %d %d %d %d %d %d %d\n", sust_dig_ore_coal_count, sust_port_count, sust_old_money_count, sust_old_population_count, sust_old_tech_count, sust_fire_count, sust_old_money, sust_old_population, sust_old_tech, sustain_flag); /* 3 */ gzprintf(ofile, "arid %d %d\n", global_aridity, global_mountainity); /* 4 */ gzprintf(ofile, "dummy\n"); /* 5 */ gzprintf(ofile, "dummy\n"); /* 6 */ gzprintf(ofile, "dummy\n"); /* 7 */ gzprintf(ofile, "dummy\n"); /* 8 */ gzprintf(ofile, "dummy\n"); /* 9 */ gzprintf(ofile, "dummy\n"); /* 10 */ gzclose(ofile); }
void load_city_2(char *cname) { int i, x, y, p; int dumbint = 0; int num_pbars, pbar_data_size; int pbar_tmp; int dummy; gzFile gzfile; char s[512]; clear_game(); gzfile = gzopen(cname, "rb"); if (gzfile == NULL) { printf(_("Can't open <%s> (gzipped)"), cname); do_error("Can't open it!"); } sscanf(gzgets(gzfile, s, 256), "%d", &ldsv_version); if (ldsv_version < WATERWELL_V2) { gzclose(gzfile); load_city_old( cname ); /* Fix desert frontier for old saved games and scenarios */ desert_frontier(0, 0, WORLD_SIDE_LEN, WORLD_SIDE_LEN); return; } fprintf(stderr, " ldsv_version = %i \n", ldsv_version); use_waterwell = true; init_pbars(); num_pbars = NUM_PBARS; pbar_data_size = PBAR_DATA_SIZE; init_inventory(); print_time_for_year(); // Easier debugging from saved game: #Line = 100 x + y + 1 (first line = ldsv_version) for (x = 0; x < WORLD_SIDE_LEN; x++) { for (y = 0; y < WORLD_SIDE_LEN; y++) { gzgets(gzfile, s, 512); // TY po fl cr or i1 i2 i3 i4 i5 i6 i7 PL al ec ws gp wa wp ww wn g1 g2 g3 g4 DA TK AN d4 d5 d6 d7 d8 d9 sscanf(s, "%hi %d %i %hu %hu %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d" , &MP_TYPE(x, y) , &MP_INFO(x, y).population , &MP_INFO(x, y).flags , &MP_INFO(x, y).coal_reserve , &MP_INFO(x, y).ore_reserve , &MP_INFO(x, y).int_1 , &MP_INFO(x, y).int_2 , &MP_INFO(x, y).int_3 , &MP_INFO(x, y).int_4 , &MP_INFO(x, y).int_5 , &MP_INFO(x, y).int_6 , &MP_INFO(x, y).int_7 , &MP_POL(x, y) , &ground[x][y].altitude , &ground[x][y].ecotable , &ground[x][y].wastes , &ground[x][y].pollution , &ground[x][y].water_alt , &ground[x][y].water_pol , &ground[x][y].water_wast , &ground[x][y].water_next , &ground[x][y].int1 , &ground[x][y].int2 , &ground[x][y].int3 , &ground[x][y].int4 , &MP_DATE(x,y) // d1 = date of built , &MP_TECH(x,y) // d2 = tech at build time , &MP_ANIM(x,y) // d3 = animation_time (see reset_animation_time mess :) , &dumbint // d4 could be image index for smooth animation, cf windmill anim_tile , &dumbint // d5 percentage of activity to choose family of pic , &dumbint // d6 , &dumbint // d7 , &dumbint // d8 , &dumbint // d9 ); if (get_group_of_type(MP_TYPE(x, y)) == GROUP_MARKET) inventory(x, y); } } set_map_groups(); sscanf(gzgets(gzfile, s, 256), "%d", &main_screen_originx); sscanf(gzgets(gzfile, s, 256), "%d", &main_screen_originy); sscanf(gzgets(gzfile, s, 256), "%d", &total_time); for (x = 0; x < MAX_NUMOF_SUBSTATIONS; x++) { sscanf(gzgets(gzfile, s, 256), "%d", &substationx[x]); sscanf(gzgets(gzfile, s, 256), "%d", &substationy[x]); } sscanf(gzgets(gzfile, s, 256), "%d", &numof_substations); for (x = 0; x < MAX_NUMOF_MARKETS; x++) { sscanf(gzgets(gzfile, s, 256), "%d", &marketx[x]); sscanf(gzgets(gzfile, s, 256), "%d", &markety[x]); } sscanf(gzgets(gzfile, s, 256), "%d", &numof_markets); sscanf(gzgets(gzfile, s, 256), "%d", &people_pool); sscanf(gzgets(gzfile, s, 256), "%o", &total_money); sscanf(gzgets(gzfile, s, 256), "%d", &income_tax_rate); sscanf(gzgets(gzfile, s, 256), "%d", &coal_tax_rate); sscanf(gzgets(gzfile, s, 256), "%d", &dole_rate); sscanf(gzgets(gzfile, s, 256), "%d", &transport_cost_rate); sscanf(gzgets(gzfile, s, 256), "%d", &goods_tax_rate); sscanf(gzgets(gzfile, s, 256), "%d", &export_tax); sscanf(gzgets(gzfile, s, 256), "%d", &export_tax_rate); sscanf(gzgets(gzfile, s, 256), "%d", &import_cost); sscanf(gzgets(gzfile, s, 256), "%d", &import_cost_rate); sscanf(gzgets(gzfile, s, 256), "%d", &tech_level); sscanf(gzgets(gzfile, s, 256), "%d", &tpopulation); sscanf(gzgets(gzfile, s, 256), "%d", &tstarving_population); sscanf(gzgets(gzfile, s, 256), "%d", &tunemployed_population); sscanf(gzgets(gzfile, s, 256), "%d", &x); /* waste_goods obsolete */ sscanf(gzgets(gzfile, s, 256), "%d", &power_made); sscanf(gzgets(gzfile, s, 256), "%d", &power_used); sscanf(gzgets(gzfile, s, 256), "%d", &coal_made); sscanf(gzgets(gzfile, s, 256), "%d", &coal_used); sscanf(gzgets(gzfile, s, 256), "%d", &goods_made); sscanf(gzgets(gzfile, s, 256), "%d", &goods_used); sscanf(gzgets(gzfile, s, 256), "%d", &ore_made); sscanf(gzgets(gzfile, s, 256), "%d", &ore_used); sscanf(gzgets(gzfile, s, 256), "%d", &dummy); /* &diff_old_population */ /* Update variables calculated from those above */ housed_population = tpopulation / ((total_time % NUMOF_DAYS_IN_MONTH) + 1); /* Get size of monthgraph array */ sscanf(gzgets(gzfile, s, 256), "%d", &i); for (x = 0; x < i; x++) { /* If more entries in file than will fit on screen, then we need to skip past them. */ if (x >= monthgraph_size) { sscanf(gzgets(gzfile, s, 256), "%d", &dummy); /* &monthgraph_pop[x] */ sscanf(gzgets(gzfile, s, 256), "%d", &dummy); /* &monthgraph_starve[x] */ sscanf(gzgets(gzfile, s, 256), "%d", &dummy); /* &monthgraph_nojobs[x] */ sscanf(gzgets(gzfile, s, 256), "%d", &dummy); /* &monthgraph_ppool[x] */ } else { sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_pop[x]); sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_starve[x]); sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_nojobs[x]); sscanf(gzgets(gzfile, s, 256), "%d", &monthgraph_ppool[x]); } } /* If screen bigger than number of entries in file, pad with zeroes */ while (x < monthgraph_size) { monthgraph_pop[x] = 0; monthgraph_starve[x] = 0; monthgraph_nojobs[x] = 0; monthgraph_ppool[x] = 0; x++; } sscanf(gzgets(gzfile, s, 256), "%d", &rockets_launched); sscanf(gzgets(gzfile, s, 256), "%d", &rockets_launched_success); sscanf(gzgets(gzfile, s, 256), "%d", &coal_survey_done); for (x = 0; x < pbar_data_size; x++) { for (p = 0; p < num_pbars; p++) { sscanf(gzgets(gzfile, s, 256), "%d", &(pbar_tmp)); update_pbar(p, pbar_tmp, 1); } } for (p = 0; p < num_pbars; p++) pbars[p].data_size = pbar_data_size; for (p = 0; p < num_pbars; p++) { sscanf(gzgets(gzfile, s, 256), "%d", &(pbars[p].oldtot)); sscanf(gzgets(gzfile, s, 256), "%d", &(pbars[p].diff)); } sscanf(gzgets(gzfile, s, 256), "%d", &cheat_flag); sscanf(gzgets(gzfile, s, 256), "%d", &total_pollution_deaths); sscanf(gzgets(gzfile, s, 256), "%f", &pollution_deaths_history); sscanf(gzgets(gzfile, s, 256), "%d", &total_starve_deaths); sscanf(gzgets(gzfile, s, 256), "%f", &starve_deaths_history); sscanf(gzgets(gzfile, s, 256), "%d", &total_unemployed_years); sscanf(gzgets(gzfile, s, 256), "%f", &unemployed_history); sscanf(gzgets(gzfile, s, 256), "%d", &max_pop_ever); sscanf(gzgets(gzfile, s, 256), "%d", &total_evacuated); sscanf(gzgets(gzfile, s, 256), "%d", &total_births); for (x = 0; x < NUMOF_MODULES; x++) sscanf(gzgets(gzfile, s, 256), "%d", &(module_help_flag[x])); sscanf(gzgets(gzfile, s, 256), "%128s", given_scene); if (strncmp(given_scene, "dummy", 5) == 0 || strlen(given_scene) < 3) given_scene[0] = 0; sscanf(gzgets(gzfile, s, 256), "%128s", s); if (strncmp(given_scene, "dummy", 5) != 0) sscanf(s, "%d", &highest_tech_level); else highest_tech_level = 0; gzgets(gzfile, s, 200); if (sscanf (s, "sust %d %d %d %d %d %d %d %d %d %d", &sust_dig_ore_coal_count, &sust_port_count, &sust_old_money_count, &sust_old_population_count, &sust_old_tech_count, &sust_fire_count, &sust_old_money, &sust_old_population, &sust_old_tech, &sustain_flag) == 10) { sust_dig_ore_coal_tip_flag = sust_port_flag = 1; } else sustain_flag = sust_dig_ore_coal_count = sust_port_count = sust_old_money_count = sust_old_population_count = sust_old_tech_count = sust_fire_count = sust_old_money = sust_old_population = sust_old_tech = 0; gzgets(gzfile, s, 80); sscanf(s, "arid %d %d", &global_aridity, &global_mountainity); gzclose(gzfile); /* FIXME: AL1 this is initialisation stuff, should go elsewhere */ // Engine stuff if (tech_level > MODERN_WINDMILL_TECH) modern_windmill_flag = 1; numof_shanties = count_groups(GROUP_SHANTY); numof_communes = count_groups(GROUP_COMMUNE); /* set up the university intake. */ x = count_groups(GROUP_UNIVERSITY); if (x > 0) { university_intake_rate = (count_groups(GROUP_SCHOOL) * 20) / x; if (university_intake_rate > 100) university_intake_rate = 100; } else university_intake_rate = 50; print_total_money(); //reset_animation_times //get alt_min, alt_max alt_min = 2000000000; alt_max = -alt_min; for ( y = 0; y < WORLD_SIDE_LEN; y++){ for ( x = 0; x < WORLD_SIDE_LEN; x++) { MP_ANIM(x,y) = 0; if (MP_GROUP(x, y) == GROUP_FIRE){ MP_INFO(x, y).int_3 = 0; } if (alt_min > ALT(x,y)){ alt_min = ALT(x,y); } if (alt_max < ALT(x,y)){ alt_max = ALT(x,y); } } } alt_step = (alt_max - alt_min) /10; map_power_grid(true); /* WCK: Is this safe to do here? * AL1: No, in NG_1.1 * In case of error message with ok_dial_box * the dialog cannot appear because the screen * is not set up => crash. * FIXME: move all initialisation elsewhere, in * engine.cpp or simulate.cpp. */ // UI stuff if (main_screen_originx > WORLD_SIDE_LEN - getMainWindowWidth() / 16 - 1) main_screen_originx = WORLD_SIDE_LEN - getMainWindowWidth() / 16 - 1; if (main_screen_originy > WORLD_SIDE_LEN - getMainWindowHeight() / 16 - 1) main_screen_originy = WORLD_SIDE_LEN - getMainWindowHeight() / 16 - 1; unhighlight_module_button(selected_module); selected_module = sbut[7]; /* 7 is track. Watch out though! */ highlight_module_button(selected_module); set_selected_module(CST_TRACK_LR); connect_transport(1, 1, WORLD_SIDE_LEN - 2, WORLD_SIDE_LEN - 2); /* Fix desert frontier for old saved games and scenarios */ desert_frontier(0, 0, WORLD_SIDE_LEN, WORLD_SIDE_LEN); }
void save_city_raw (char *cname) { int x, y, z, q, n, p; gzFile ofile = gzopen(cname, "wb"); if (ofile == NULL) { printf (_("Save file <%s> - "), cname); do_error (_("Can't open save file!")); } /* save without waterwell are in NG 1.1 format, eg scenario good_time is ver 98 when loaded */ if (ldsv_version < VERSION_INT) ldsv_version = VERSION_INT; gzprintf (ofile, "%d\n", ldsv_version); q = sizeof (Map_Point_Info); prog_box (_("Saving scene"), 0); check_endian (); for (x = 0; x < WORLD_SIDE_LEN; x++) { for (y = 0; y < WORLD_SIDE_LEN; y++) { for (z = 0; z < sizeof(int); z++) { n = *(((unsigned char *) &MP_INFO(x,y).population) + z); gzprintf (ofile, "%d\n", n); } for (z = 0; z < sizeof(int); z++) { n = *(((unsigned char *) &MP_INFO(x,y).flags) + z); gzprintf (ofile, "%d\n", n); } for (z = 0; z < sizeof(unsigned short); z++) { n = *(((unsigned char *) &MP_INFO(x,y).coal_reserve) + z); gzprintf (ofile, "%d\n", n); } for (z = 0; z < sizeof(unsigned short); z++) { n = *(((unsigned char *) &MP_INFO(x,y).ore_reserve) + z); gzprintf (ofile, "%d\n", n); } for (z = 0; z < sizeof(int); z++) { n = *(((unsigned char *) &MP_INFO(x,y).int_1) + z); gzprintf (ofile, "%d\n", n); } for (z = 0; z < sizeof(int); z++) { n = *(((unsigned char *) &MP_INFO(x,y).int_2) + z); gzprintf (ofile, "%d\n", n); } for (z = 0; z < sizeof(int); z++) { n = *(((unsigned char *) &MP_INFO(x,y).int_3) + z); gzprintf (ofile, "%d\n", n); } for (z = 0; z < sizeof(int); z++) { n = *(((unsigned char *) &MP_INFO(x,y).int_4) + z); gzprintf (ofile, "%d\n", n); } for (z = 0; z < sizeof(int); z++) { n = *(((unsigned char *) &MP_INFO(x,y).int_5) + z); gzprintf (ofile, "%d\n", n); } for (z = 0; z < sizeof(int); z++) { n = *(((unsigned char *) &MP_INFO(x,y).int_6) + z); gzprintf (ofile, "%d\n", n); } for (z = 0; z < sizeof(int); z++) { n = *(((unsigned char *) &MP_INFO(x,y).int_7) + z); gzprintf (ofile, "%d\n", n); } gzprintf (ofile, "%d\n", (int) MP_POL(x,y)); gzprintf (ofile, "%d\n", (int) MP_TYPE(x,y)); } prog_box ("", (90 * x) / WORLD_SIDE_LEN); } check_endian (); /* we have to put the byte order back. */ gzprintf (ofile, "%d\n", main_screen_originx); gzprintf (ofile, "%d\n", main_screen_originy); gzprintf (ofile, "%d\n", total_time); for (x = 0; x < MAX_NUMOF_SUBSTATIONS; x++) { gzprintf (ofile, "%d\n", substationx[x]); gzprintf (ofile, "%d\n", substationy[x]); } prog_box ("", 92); gzprintf (ofile, "%d\n", numof_substations); for (x = 0; x < MAX_NUMOF_MARKETS; x++) { gzprintf (ofile, "%d\n", marketx[x]); gzprintf (ofile, "%d\n", markety[x]); } prog_box ("", 94); gzprintf (ofile, "%d\n", numof_markets); gzprintf (ofile, "%d\n", people_pool); gzprintf (ofile, "%d\n", total_money); gzprintf (ofile, "%d\n", income_tax_rate); gzprintf (ofile, "%d\n", coal_tax_rate); gzprintf (ofile, "%d\n", dole_rate); gzprintf (ofile, "%d\n", transport_cost_rate); gzprintf (ofile, "%d\n", goods_tax_rate); gzprintf (ofile, "%d\n", export_tax); gzprintf (ofile, "%d\n", export_tax_rate); gzprintf (ofile, "%d\n", import_cost); gzprintf (ofile, "%d\n", import_cost_rate); gzprintf (ofile, "%d\n", tech_level); gzprintf (ofile, "%d\n", tpopulation); gzprintf (ofile, "%d\n", tstarving_population); gzprintf (ofile, "%d\n", tunemployed_population); gzprintf (ofile, "%d\n", 0); /* waste_goods is obsolete */ gzprintf (ofile, "%d\n", power_made); gzprintf (ofile, "%d\n", power_used); gzprintf (ofile, "%d\n", coal_made); gzprintf (ofile, "%d\n", coal_used); gzprintf (ofile, "%d\n", goods_made); gzprintf (ofile, "%d\n", goods_used); gzprintf (ofile, "%d\n", ore_made); gzprintf (ofile, "%d\n", ore_used); gzprintf (ofile, "%d\n", 0); /* Removed diff_old_population, version 1.12 */ prog_box ("", 96); /* Changed, version 1.12 */ gzprintf (ofile, "%d\n", monthgraph_size); for (x = 0; x < monthgraph_size; x++) { gzprintf (ofile, "%d\n", monthgraph_pop[x]); gzprintf (ofile, "%d\n", monthgraph_starve[x]); gzprintf (ofile, "%d\n", monthgraph_nojobs[x]); gzprintf (ofile, "%d\n", monthgraph_ppool[x]); } prog_box ("", 98); gzprintf (ofile, "%d\n", rockets_launched); gzprintf (ofile, "%d\n", rockets_launched_success); gzprintf (ofile, "%d\n", coal_survey_done); for (x = 0; x < PBAR_DATA_SIZE; x++) for (p = 0; p < NUM_PBARS; p++) gzprintf(ofile, "%d\n", pbars[p].data[x]); prog_box ("", 99); for (p = 0; p < NUM_PBARS; p++) { gzprintf(ofile, "%d\n", pbars[p].oldtot); gzprintf(ofile, "%d\n", pbars[p].diff); } gzprintf (ofile, "%d\n", cheat_flag); gzprintf (ofile, "%d\n", total_pollution_deaths); gzprintf (ofile, "%f\n", pollution_deaths_history); gzprintf (ofile, "%d\n", total_starve_deaths); gzprintf (ofile, "%f\n", starve_deaths_history); gzprintf (ofile, "%d\n", total_unemployed_years); gzprintf (ofile, "%f\n", unemployed_history); gzprintf (ofile, "%d\n", max_pop_ever); gzprintf (ofile, "%d\n", total_evacuated); gzprintf (ofile, "%d\n", total_births); for (x = 0; x < NUMOF_MODULES; x++) gzprintf (ofile, "%d\n", module_help_flag[x]); gzprintf (ofile, "%d\n", 0); /* dummy values */ gzprintf (ofile, "%d\n", 0); /* backward compatibility */ if (strlen (given_scene) > 1) gzprintf (ofile, "%s\n", given_scene); else gzprintf (ofile, "dummy\n"); /* 1 */ gzprintf (ofile, "%d\n", highest_tech_level); /* 2 */ gzprintf (ofile, "sust %d %d %d %d %d %d %d %d %d %d\n" ,sust_dig_ore_coal_count, sust_port_count ,sust_old_money_count, sust_old_population_count ,sust_old_tech_count, sust_fire_count ,sust_old_money, sust_old_population, sust_old_tech ,sustain_flag); /* 3 */ if (use_waterwell == true) { } else { gzprintf (ofile, "dummy\n"); /* 4 */ } gzprintf (ofile, "dummy\n"); /* 5 */ gzprintf (ofile, "dummy\n"); /* 6 */ gzprintf (ofile, "dummy\n"); /* 7 */ gzprintf (ofile, "dummy\n"); /* 8 */ gzprintf (ofile, "dummy\n"); /* 9 */ gzprintf (ofile, "dummy\n"); /* 10 */ gzclose (ofile); prog_box ("", 100); }
void load_city (char *cname) { unsigned long q; int i, x, y, z, n, p; int num_pbars, pbar_data_size; int pbar_tmp; int dummy; gzFile gzfile; char s[256]; gzfile = gzopen( cname, "rb" ); if ( gzfile == NULL) { printf (_("Can't open <%s> (gzipped)"), cname); do_error ("Can't open it!"); } /* Add version to shared global variables for playing/saving games without waterwell */ sscanf( gzgets( gzfile, s, 256 ), "%d", &ldsv_version); if (ldsv_version < MIN_LOAD_VERSION) { ok_dial_box ("too-old.mes", BAD, 0L); gzclose( gzfile ); return; } fprintf(stderr," ldsv_version = %i \n", ldsv_version); if (ldsv_version < MIN_WATERWELL_VERSION) { /* ok_dial_box ("no-waterwell.mes", GOOD, 0L);*/ use_waterwell=false; } else { use_waterwell=true; /* needed until it is written in the saved file * in case of load after having played an old game */ } init_pbars(); num_pbars = NUM_PBARS; pbar_data_size = PBAR_DATA_SIZE; init_inventory(); print_time_for_year(); q = (unsigned long) sizeof (Map_Point_Info); prog_box (_("Loading scene"), 0); for (x = 0; x < WORLD_SIDE_LEN; x++) { for (y = 0; y < WORLD_SIDE_LEN; y++) { for (z = 0; z < sizeof(int); z++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &n); *(((unsigned char *) &MP_INFO(x,y).population) + z) = n; } for (z = 0; z < sizeof(int); z++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &n); *(((unsigned char *) &MP_INFO(x,y).flags) + z) = n; } for (z = 0; z < sizeof(unsigned short); z++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &n); *(((unsigned char *) &MP_INFO(x,y).coal_reserve) + z) = n; } for (z = 0; z < sizeof(unsigned short); z++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &n); *(((unsigned char *) &MP_INFO(x,y).ore_reserve) + z) = n; } for (z = 0; z < sizeof(int); z++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &n); *(((unsigned char *) &MP_INFO(x,y).int_1) + z) = n; } for (z = 0; z < sizeof(int); z++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &n); *(((unsigned char *) &MP_INFO(x,y).int_2) + z) = n; } for (z = 0; z < sizeof(int); z++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &n); *(((unsigned char *) &MP_INFO(x,y).int_3) + z) = n; } for (z = 0; z < sizeof(int); z++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &n); *(((unsigned char *) &MP_INFO(x,y).int_4) + z) = n; } for (z = 0; z < sizeof(int); z++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &n); *(((unsigned char *) &MP_INFO(x,y).int_5) + z) = n; } for (z = 0; z < sizeof(int); z++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &n); *(((unsigned char *) &MP_INFO(x,y).int_6) + z) = n; } for (z = 0; z < sizeof(int); z++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &n); *(((unsigned char *) &MP_INFO(x,y).int_7) + z) = n; } sscanf( gzgets( gzfile, s, 256 ), "%d", &n); MP_POL(x,y) = (unsigned short) n; sscanf( gzgets( gzfile, s, 256 ), "%d", &n); MP_TYPE(x,y) = (short) n; if (get_group_of_type(MP_TYPE(x,y)) == GROUP_MARKET) inventory(x,y); } if (((93 * x) / WORLD_SIDE_LEN) % 3 == 0) prog_box ("", (93 * x) / WORLD_SIDE_LEN); } check_endian (); set_map_groups (); sscanf( gzgets( gzfile, s, 256 ), "%d", &main_screen_originx); sscanf( gzgets( gzfile, s, 256 ), "%d", &main_screen_originy); if (main_screen_originx > WORLD_SIDE_LEN - getMainWindowWidth() / 16 - 1) main_screen_originx = WORLD_SIDE_LEN - getMainWindowWidth() / 16 - 1; if (main_screen_originy > WORLD_SIDE_LEN - getMainWindowHeight() / 16 - 1) main_screen_originy = WORLD_SIDE_LEN - getMainWindowHeight() / 16 - 1; sscanf( gzgets( gzfile, s, 256 ), "%d", &total_time); if (ldsv_version <= MM_MS_C_VER) i = OLD_MAX_NUMOF_SUBSTATIONS; else i = MAX_NUMOF_SUBSTATIONS; for (x = 0; x < i; x++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &substationx[x]); sscanf( gzgets( gzfile, s, 256 ), "%d", &substationy[x]); } prog_box ("", 92); sscanf( gzgets( gzfile, s, 256 ), "%d", &numof_substations); if (ldsv_version <= MM_MS_C_VER) i = OLD_MAX_NUMOF_MARKETS; else i = MAX_NUMOF_MARKETS; for (x = 0; x < i; x++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &marketx[x]); sscanf( gzgets( gzfile, s, 256 ), "%d", &markety[x]); } prog_box ("", 94); sscanf( gzgets( gzfile, s, 256 ), "%d", &numof_markets); sscanf( gzgets( gzfile, s, 256 ), "%d", &people_pool); sscanf( gzgets( gzfile, s, 256 ), "%d", &total_money); sscanf( gzgets( gzfile, s, 256 ), "%d", &income_tax_rate); sscanf( gzgets( gzfile, s, 256 ), "%d", &coal_tax_rate); sscanf( gzgets( gzfile, s, 256 ), "%d", &dole_rate); sscanf( gzgets( gzfile, s, 256 ), "%d", &transport_cost_rate); sscanf( gzgets( gzfile, s, 256 ), "%d", &goods_tax_rate); sscanf( gzgets( gzfile, s, 256 ), "%d", &export_tax); sscanf( gzgets( gzfile, s, 256 ), "%d", &export_tax_rate); sscanf( gzgets( gzfile, s, 256 ), "%d", &import_cost); sscanf( gzgets( gzfile, s, 256 ), "%d", &import_cost_rate); sscanf( gzgets( gzfile, s, 256 ), "%d", &tech_level); if (tech_level > MODERN_WINDMILL_TECH) modern_windmill_flag = 1; sscanf( gzgets( gzfile, s, 256 ), "%d", &tpopulation); sscanf( gzgets( gzfile, s, 256 ), "%d", &tstarving_population); sscanf( gzgets( gzfile, s, 256 ), "%d", &tunemployed_population); sscanf( gzgets( gzfile, s, 256 ), "%d", &x); /* waste_goods obsolete */ sscanf( gzgets( gzfile, s, 256 ), "%d", &power_made); sscanf( gzgets( gzfile, s, 256 ), "%d", &power_used); sscanf( gzgets( gzfile, s, 256 ), "%d", &coal_made); sscanf( gzgets( gzfile, s, 256 ), "%d", &coal_used); sscanf( gzgets( gzfile, s, 256 ), "%d", &goods_made); sscanf( gzgets( gzfile, s, 256 ), "%d", &goods_used); sscanf( gzgets( gzfile, s, 256 ), "%d", &ore_made); sscanf( gzgets( gzfile, s, 256 ), "%d", &ore_used); sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &diff_old_population */ /* Update variables calculated from those above */ housed_population = tpopulation / NUMOF_DAYS_IN_MONTH; prog_box ("", 96); /* Get size of monthgraph array */ if (ldsv_version <= MG_C_VER) { i = 120; } else { sscanf( gzgets( gzfile, s, 256 ), "%d", &i); } for (x = 0; x < i; x++) { /* If more entries in file than will fit on screen, then we need to skip past them. */ if (x >= monthgraph_size) { sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &monthgraph_pop[x] */ sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &monthgraph_starve[x] */ sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &monthgraph_nojobs[x] */ sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &monthgraph_ppool[x] */ } else { sscanf( gzgets( gzfile, s, 256 ), "%d", &monthgraph_pop[x]); sscanf( gzgets( gzfile, s, 256 ), "%d", &monthgraph_starve[x]); sscanf( gzgets( gzfile, s, 256 ), "%d", &monthgraph_nojobs[x]); sscanf( gzgets( gzfile, s, 256 ), "%d", &monthgraph_ppool[x]); } /* If our save file is old, skip past obsolete diffgraph entries */ if (ldsv_version <= MG_C_VER) { sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &diffgraph_power[x] */ sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &diffgraph_coal[x] */ sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &diffgraph_goods[x] */ sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &diffgraph_ore[x] */ sscanf( gzgets( gzfile, s, 256 ), "%d", &dummy); /* &diffgraph_population[x] */ } } /* If screen bigger than number of entries in file, pad with zeroes */ while (x < monthgraph_size) { monthgraph_pop[x] = 0; monthgraph_starve[x] = 0; monthgraph_nojobs[x] = 0; monthgraph_ppool[x] = 0; x++; } prog_box ("", 98); sscanf( gzgets( gzfile, s, 256 ), "%d", &rockets_launched); sscanf( gzgets( gzfile, s, 256 ), "%d", &rockets_launched_success); sscanf( gzgets( gzfile, s, 256 ), "%d", &coal_survey_done); for (x = 0; x < pbar_data_size; x++) { for (p = 0; p < num_pbars; p++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &(pbar_tmp)); update_pbar(p,pbar_tmp,1); /* sscanf( gzgets( gzfile, s, 256 ), "%d", &(pbars[p].data[x])); */ } } for (p = 0; p < num_pbars; p++) pbars[p].data_size = pbar_data_size; prog_box ("", 99); for (p = 0; p < num_pbars; p++) { sscanf( gzgets( gzfile, s, 256 ), "%d", &(pbars[p].oldtot)); sscanf( gzgets( gzfile, s, 256 ), "%d", &(pbars[p].diff)); } sscanf( gzgets( gzfile, s, 256 ), "%d", &cheat_flag); sscanf( gzgets( gzfile, s, 256 ), "%d", &total_pollution_deaths); sscanf( gzgets( gzfile, s, 256 ), "%f", &pollution_deaths_history); sscanf( gzgets( gzfile, s, 256 ), "%d", &total_starve_deaths); sscanf( gzgets( gzfile, s, 256 ), "%f", &starve_deaths_history); sscanf( gzgets( gzfile, s, 256 ), "%d", &total_unemployed_years); sscanf( gzgets( gzfile, s, 256 ), "%f", &unemployed_history); sscanf( gzgets( gzfile, s, 256 ), "%d", &max_pop_ever); sscanf( gzgets( gzfile, s, 256 ), "%d", &total_evacuated); sscanf( gzgets( gzfile, s, 256 ), "%d", &total_births); for (x = 0; x < NUMOF_MODULES; x++) sscanf( gzgets( gzfile, s, 256 ), "%d", &(module_help_flag[x])); sscanf( gzgets( gzfile, s, 256 ), "%d", &x); /* just dummy reads */ sscanf( gzgets( gzfile, s, 256 ), "%d", &x); /* for backwards compatibility. */ /* 10 dummy strings, for missed out things, have been put in save. */ /* Input from this point uses them. */ /* XXX: WCK: Huh? Missed out things? */ sscanf( gzgets( gzfile, s, 256 ), "%128s", given_scene); if (strncmp (given_scene, "dummy", 5) == 0 || strlen (given_scene) < 3) given_scene[0] = 0; sscanf( gzgets( gzfile, s, 256 ), "%128s", s); if (strncmp (given_scene, "dummy", 5) != 0) sscanf (s, "%d", &highest_tech_level); else highest_tech_level = 0; gzgets( gzfile, s, 80 ); /* this is the CR */ if (sscanf (s, "sust %d %d %d %d %d %d %d %d %d %d" ,&sust_dig_ore_coal_count, &sust_port_count ,&sust_old_money_count, &sust_old_population_count ,&sust_old_tech_count, &sust_fire_count ,&sust_old_money, &sust_old_population, &sust_old_tech ,&sustain_flag) == 10) { sust_dig_ore_coal_tip_flag = sust_port_flag = 1; /* GCS FIX: Check after loading file if screen is drawn OK */ /* draw_sustainable_window (); */ } else sustain_flag = sust_dig_ore_coal_count = sust_port_count = sust_old_money_count = sust_old_population_count = sust_old_tech_count = sust_fire_count = sust_old_money = sust_old_population = sust_old_tech = 0; if (use_waterwell == true) { } gzclose( gzfile ); numof_shanties = count_groups (GROUP_SHANTY); numof_communes = count_groups (GROUP_COMMUNE); prog_box ("", 100); /* set up the university intake. */ x = count_groups (GROUP_UNIVERSITY); if (x > 0) { university_intake_rate = (count_groups (GROUP_SCHOOL) * 20) / x; if (university_intake_rate > 100) university_intake_rate = 100; } else university_intake_rate = 50; /*Al1 : What is this ? This does nothing, the value are saved in MP_INFO.int_ * for (x = 0; x < WORLD_SIDE_LEN; x++) * for (y = 0; y < WORLD_SIDE_LEN; y++) * update_tech_dep (x, y); */ unhighlight_module_button (selected_module); selected_module = sbut[7]; /* 7 is track. Watch out though! */ highlight_module_button (selected_module); set_selected_module (CST_TRACK_LR); print_total_money (); reset_animation_times (); /* update tech dep for compatibility with old games */ for (x = 0; x < WORLD_SIDE_LEN; x++) for (y = 0; y < WORLD_SIDE_LEN; y++) { switch (MP_GROUP(x,y)) { case (GROUP_WINDMILL): MP_INFO(x,y).int_1 = (int)(WINDMILL_POWER + (((double) MP_INFO(x,y).int_2 * WINDMILL_POWER) / MAX_TECH_LEVEL)); break; case (GROUP_COAL_POWER): MP_INFO(x,y).int_1 = (int)(POWERS_COAL_OUTPUT + (((double) MP_INFO(x,y).int_4 * POWERS_COAL_OUTPUT) / MAX_TECH_LEVEL)); break; case (GROUP_SOLAR_POWER): MP_INFO(x,y).int_1 = (int)(POWERS_SOLAR_OUTPUT + (((double) MP_INFO(x,y).int_2 * POWERS_SOLAR_OUTPUT) / MAX_TECH_LEVEL)); break; } } map_power_grid(true); /* WCK: Is this safe to do here? * AL1: No, in NG_1.1 * In case of error message with ok_dial_box * the dialog cannot appear because the screen * is not set up => crash. * FIXME: move all initialisation elsewhere, in * engine.cpp or simulate.cpp. */ }
void do_blacksmith (int x, int y) { /* // int_1 contains the goods at the blacksmith // int_2 contains the goods made - for the animation // int_3 contains the coal store // int_4 is the animation trigger time // int_5 is the % made so far this month // int_6 is the % capacity last month */ if (MP_INFO(x,y).int_3 < MAX_COAL_AT_BLACKSMITH) if (get_coal (x, y, BLACKSMITH_GET_COAL) != 0) MP_INFO(x,y).int_3 += BLACKSMITH_GET_COAL; if (MP_INFO(x,y).int_1 < MAX_GOODS_AT_BLACKSMITH && MP_INFO(x,y).int_3 >= BLACKSMITH_COAL_USED) { if (get_steel (x, y, BLACKSMITH_STEEL_USED) != 0) { MP_INFO(x,y).int_1 += GOODS_MADE_BY_BLACKSMITH; MP_INFO(x,y).int_3 -= BLACKSMITH_COAL_USED; } } if (get_jobs (x, y, BLACKSMITH_JOBS) != 0) { if (MP_INFO(x,y).int_1 > GOODS_MADE_BY_BLACKSMITH) { if (put_goods (x, y, GOODS_MADE_BY_BLACKSMITH - 1) != 0) { MP_INFO(x,y).int_1 -= (GOODS_MADE_BY_BLACKSMITH - 1); MP_INFO(x,y).int_2 += (GOODS_MADE_BY_BLACKSMITH - 1); MP_INFO(x,y).int_5++; } else put_jobs (x, y, BLACKSMITH_JOBS); } else put_jobs (x, y, BLACKSMITH_JOBS); } else MP_TYPE(x,y) = CST_BLACKSMITH_0; if (MP_INFO(x,y).int_2 > BLACKSMITH_BATCH && real_time >= MP_INFO(x,y).int_4) { MP_INFO(x,y).int_4 = real_time + BLACKSMITH_ANIM_SPEED; switch (MP_TYPE(x,y)) { case (CST_BLACKSMITH_0): MP_TYPE(x,y) = CST_BLACKSMITH_1; break; case (CST_BLACKSMITH_1): MP_TYPE(x,y) = CST_BLACKSMITH_2; break; case (CST_BLACKSMITH_2): MP_TYPE(x,y) = CST_BLACKSMITH_3; break; case (CST_BLACKSMITH_3): MP_TYPE(x,y) = CST_BLACKSMITH_4; break; case (CST_BLACKSMITH_4): MP_TYPE(x,y) = CST_BLACKSMITH_5; break; case (CST_BLACKSMITH_5): MP_TYPE(x,y) = CST_BLACKSMITH_6; break; case (CST_BLACKSMITH_6): MP_TYPE(x,y) = CST_BLACKSMITH_1; MP_INFO(x,y).int_2 = 0; MP_POL(x,y)++; break; } } if (total_time % 100 == 0) { MP_INFO(x,y).int_6 = MP_INFO(x,y).int_5; MP_INFO(x,y).int_5 = 0; } }
void load_city (char *cname) { unsigned long q; int i, x, y, z, n, p, ver; int num_pbars, pbar_data_size; int pbar_tmp; int dummy; FILE *ofile; char s[256]; if ((ofile = fopen_read_gzipped (cname)) == NULL) { printf (_("Can't open <%s> (gzipped)"), cname); do_error ("Can't open it!"); } fscanf (ofile, "%d", &ver); if (ver < MIN_LOAD_VERSION) { ok_dial_box ("too-old.mes", BAD, 0L); fclose_read_gzipped (ofile); return; } init_pbars(); num_pbars = NUM_PBARS; pbar_data_size = PBAR_DATA_SIZE; init_inventory(); print_time_for_year(); q = (unsigned long) sizeof (Map_Point_Info); prog_box (_("Loading scene"), 0); for (x = 0; x < WORLD_SIDE_LEN; x++) { for (y = 0; y < WORLD_SIDE_LEN; y++) { for (z = 0; z < sizeof(int); z++) { fscanf (ofile, "%d", &n); *(((unsigned char *) &MP_INFO(x,y).population) + z) = n; } for (z = 0; z < sizeof(int); z++) { fscanf (ofile, "%d", &n); *(((unsigned char *) &MP_INFO(x,y).flags) + z) = n; } for (z = 0; z < sizeof(unsigned short); z++) { fscanf (ofile, "%d", &n); *(((unsigned char *) &MP_INFO(x,y).coal_reserve) + z) = n; } for (z = 0; z < sizeof(unsigned short); z++) { fscanf (ofile, "%d", &n); *(((unsigned char *) &MP_INFO(x,y).ore_reserve) + z) = n; } for (z = 0; z < sizeof(int); z++) { fscanf (ofile, "%d", &n); *(((unsigned char *) &MP_INFO(x,y).int_1) + z) = n; } for (z = 0; z < sizeof(int); z++) { fscanf (ofile, "%d", &n); *(((unsigned char *) &MP_INFO(x,y).int_2) + z) = n; } for (z = 0; z < sizeof(int); z++) { fscanf (ofile, "%d", &n); *(((unsigned char *) &MP_INFO(x,y).int_3) + z) = n; } for (z = 0; z < sizeof(int); z++) { fscanf (ofile, "%d", &n); *(((unsigned char *) &MP_INFO(x,y).int_4) + z) = n; } for (z = 0; z < sizeof(int); z++) { fscanf (ofile, "%d", &n); *(((unsigned char *) &MP_INFO(x,y).int_5) + z) = n; } for (z = 0; z < sizeof(int); z++) { fscanf (ofile, "%d", &n); *(((unsigned char *) &MP_INFO(x,y).int_6) + z) = n; } for (z = 0; z < sizeof(int); z++) { fscanf (ofile, "%d", &n); *(((unsigned char *) &MP_INFO(x,y).int_7) + z) = n; } fscanf (ofile, "%d", &n); MP_POL(x,y) = (unsigned short) n; fscanf (ofile, "%d", &n); MP_TYPE(x,y) = (short) n; if (get_group_of_type(MP_TYPE(x,y)) == GROUP_MARKET) inventory(x,y); } if (((93 * x) / WORLD_SIDE_LEN) % 3 == 0) prog_box ("", (93 * x) / WORLD_SIDE_LEN); } check_endian (); set_map_groups (); fscanf (ofile, "%d", &main_screen_originx); fscanf (ofile, "%d", &main_screen_originy); if (main_screen_originx > WORLD_SIDE_LEN - scr.main_win.w / 16 - 1) main_screen_originx = WORLD_SIDE_LEN - scr.main_win.w / 16 - 1; if (main_screen_originy > WORLD_SIDE_LEN - scr.main_win.h / 16 - 1) main_screen_originy = WORLD_SIDE_LEN - scr.main_win.h / 16 - 1; fscanf (ofile, "%d", &total_time); if (ver <= MM_MS_C_VER) i = OLD_MAX_NUMOF_SUBSTATIONS; else i = MAX_NUMOF_SUBSTATIONS; for (x = 0; x < i; x++) { fscanf (ofile, "%d", &substationx[x]); fscanf (ofile, "%d", &substationy[x]); } prog_box ("", 92); fscanf (ofile, "%d", &numof_substations); if (ver <= MM_MS_C_VER) i = OLD_MAX_NUMOF_MARKETS; else i = MAX_NUMOF_MARKETS; for (x = 0; x < i; x++) { fscanf (ofile, "%d", &marketx[x]); fscanf (ofile, "%d", &markety[x]); } prog_box ("", 94); fscanf (ofile, "%d", &numof_markets); fscanf (ofile, "%d", &people_pool); fscanf (ofile, "%d", &total_money); fscanf (ofile, "%d", &income_tax_rate); fscanf (ofile, "%d", &coal_tax_rate); fscanf (ofile, "%d", &dole_rate); fscanf (ofile, "%d", &transport_cost_rate); fscanf (ofile, "%d", &goods_tax_rate); fscanf (ofile, "%d", &export_tax); fscanf (ofile, "%d", &export_tax_rate); fscanf (ofile, "%d", &import_cost); fscanf (ofile, "%d", &import_cost_rate); fscanf (ofile, "%d", &tech_level); if (tech_level > MODERN_WINDMILL_TECH) modern_windmill_flag = 1; fscanf (ofile, "%d", &tpopulation); fscanf (ofile, "%d", &tstarving_population); fscanf (ofile, "%d", &tunemployed_population); fscanf (ofile, "%d", &x); /* waste_goods obsolete */ fscanf (ofile, "%d", &power_made); fscanf (ofile, "%d", &power_used); fscanf (ofile, "%d", &coal_made); fscanf (ofile, "%d", &coal_used); fscanf (ofile, "%d", &goods_made); fscanf (ofile, "%d", &goods_used); fscanf (ofile, "%d", &ore_made); fscanf (ofile, "%d", &ore_used); fscanf (ofile, "%d", &dummy); /* &diff_old_population */ /* Update variables calculated from those above */ housed_population = tpopulation / NUMOF_DAYS_IN_MONTH; prog_box ("", 96); /* Get size of monthgraph array */ if (ver <= MG_C_VER) { i = 120; } else { fscanf (ofile, "%d", &i); } for (x = 0; x < i; x++) { /* If more entries in file than will fit on screen, then we need to skip past them. */ if (x >= monthgraph_size) { fscanf (ofile, "%d", &dummy); /* &monthgraph_pop[x] */ fscanf (ofile, "%d", &dummy); /* &monthgraph_starve[x] */ fscanf (ofile, "%d", &dummy); /* &monthgraph_nojobs[x] */ fscanf (ofile, "%d", &dummy); /* &monthgraph_ppool[x] */ } else { fscanf (ofile, "%d", &monthgraph_pop[x]); fscanf (ofile, "%d", &monthgraph_starve[x]); fscanf (ofile, "%d", &monthgraph_nojobs[x]); fscanf (ofile, "%d", &monthgraph_ppool[x]); } /* If our save file is old, skip past obsolete diffgraph entries */ if (ver <= MG_C_VER) { fscanf (ofile, "%d", &dummy); /* &diffgraph_power[x] */ fscanf (ofile, "%d", &dummy); /* &diffgraph_coal[x] */ fscanf (ofile, "%d", &dummy); /* &diffgraph_goods[x] */ fscanf (ofile, "%d", &dummy); /* &diffgraph_ore[x] */ fscanf (ofile, "%d", &dummy); /* &diffgraph_population[x] */ } } /* If screen bigger than number of entries in file, pad with zeroes */ while (x < monthgraph_size) { monthgraph_pop[x] = 0; monthgraph_starve[x] = 0; monthgraph_nojobs[x] = 0; monthgraph_ppool[x] = 0; x++; } prog_box ("", 98); fscanf (ofile, "%d", &rockets_launched); fscanf (ofile, "%d", &rockets_launched_success); fscanf (ofile, "%d", &coal_survey_done); for (x = 0; x < pbar_data_size; x++) { for (p = 0; p < num_pbars; p++) { fscanf (ofile, "%d", &(pbar_tmp)); update_pbar(p,pbar_tmp,1); /* fscanf (ofile, "%d", &(pbars[p].data[x])); */ } } for (p = 0; p < num_pbars; p++) pbars[p].data_size = pbar_data_size; prog_box ("", 99); for (p = 0; p < num_pbars; p++) { fscanf (ofile, "%d", &(pbars[p].oldtot)); fscanf (ofile, "%d", &(pbars[p].diff)); } fscanf (ofile, "%d", &cheat_flag); fscanf (ofile, "%d", &total_pollution_deaths); fscanf (ofile, "%f", &pollution_deaths_history); fscanf (ofile, "%d", &total_starve_deaths); fscanf (ofile, "%f", &starve_deaths_history); fscanf (ofile, "%d", &total_unemployed_years); fscanf (ofile, "%f", &unemployed_history); fscanf (ofile, "%d", &max_pop_ever); fscanf (ofile, "%d", &total_evacuated); fscanf (ofile, "%d", &total_births); for (x = 0; x < NUMOF_MODULES; x++) fscanf (ofile, "%d", &(module_help_flag[x])); fscanf (ofile, "%d", &x); /* just dummy reads */ fscanf (ofile, "%d", &x); /* for backwards compatibility. */ /* 10 dummy strings, for missed out things, have been put in save. */ /* Input from this point uses them. */ /* XXX: WCK: Huh? Missed out things? */ fscanf (ofile, "%128s", given_scene); if (strncmp (given_scene, "dummy", 5) == 0 || strlen (given_scene) < 3) given_scene[0] = 0; fscanf (ofile, "%128s", s); if (strncmp (given_scene, "dummy", 5) != 0) sscanf (s, "%d", &highest_tech_level); else highest_tech_level = 0; fgets (s, 80, ofile); /* this is the CR */ fgets (s, 80, ofile); if (sscanf (s, "sust %d %d %d %d %d %d %d %d %d %d" ,&sust_dig_ore_coal_count, &sust_port_count ,&sust_old_money_count, &sust_old_population_count ,&sust_old_tech_count, &sust_fire_count ,&sust_old_money, &sust_old_population, &sust_old_tech ,&sustain_flag) == 10) { sust_dig_ore_coal_tip_flag = sust_port_flag = 1; /* GCS FIX: Check after loading file if screen is drawn OK */ /* draw_sustainable_window (); */ } else sustain_flag = sust_dig_ore_coal_count = sust_port_count = sust_old_money_count = sust_old_population_count = sust_old_tech_count = sust_fire_count = sust_old_money = sust_old_population = sust_old_tech = 0; fclose_read_gzipped (ofile); numof_shanties = count_groups (GROUP_SHANTY); numof_communes = count_groups (GROUP_COMMUNE); prog_box ("", 100); /* set up the university intake. */ x = count_groups (GROUP_UNIVERSITY); if (x > 0) { university_intake_rate = (count_groups (GROUP_SCHOOL) * 20) / x; if (university_intake_rate > 100) university_intake_rate = 100; } else university_intake_rate = 50; for (x = 0; x < WORLD_SIDE_LEN; x++) { for (y = 0; y < WORLD_SIDE_LEN; y++) { update_tech_dep (x, y); } } unhighlight_module_button (selected_module); selected_module = sbut[7]; /* 7 is track. Watch out though! */ highlight_module_button (selected_module); set_selected_module (CST_TRACK_LR); print_total_money (); reset_animation_times (); map_power_grid (); /* WCK: Is this safe to do here? */ }
int deal_with_transport (int x, int y, int tx, int ty) { int i, r, extra_jobs = 3, flags; flags = MP_INFO(x,y).flags; /* tracks */ if (MP_GROUP(tx,ty) == GROUP_TRACK) { /* food */ if ((flags & FLAG_MB_FOOD) != 0) { r = (MAX_FOOD_IN_MARKET * 1000) / (MAX_FOOD_ON_TRACK + MAX_FOOD_IN_MARKET); i = MP_INFO(x,y).int_1 + MP_INFO(tx,ty).int_1; MP_INFO(x,y).int_1 = (i * r) / 1000; MP_INFO(tx,ty).int_1 = i - MP_INFO(x,y).int_1; } /* jobs */ if ((flags & FLAG_MB_JOBS) != 0) { r = (MAX_JOBS_IN_MARKET * 1000) / (MAX_JOBS_ON_TRACK + MAX_JOBS_IN_MARKET); i = MP_INFO(x,y).int_2 + MP_INFO(tx,ty).int_2; MP_INFO(x,y).int_2 = (i * r) / 1000; MP_INFO(tx,ty).int_2 = i - MP_INFO(x,y).int_2; } /* coal */ if ((flags & FLAG_MB_COAL) != 0) { r = (MAX_COAL_IN_MARKET * 1000) / (MAX_COAL_ON_TRACK + MAX_COAL_IN_MARKET); i = MP_INFO(x,y).int_3 + MP_INFO(tx,ty).int_3; MP_INFO(x,y).int_3 = (i * r) / 1000; MP_INFO(tx,ty).int_3 = i - MP_INFO(x,y).int_3; } /* goods */ if ((flags & FLAG_MB_GOODS) != 0) { r = (MAX_GOODS_IN_MARKET * 1000) / (MAX_GOODS_ON_TRACK + MAX_GOODS_IN_MARKET); i = MP_INFO(x,y).int_4 + MP_INFO(tx,ty).int_4; MP_INFO(x,y).int_4 = (i * r) / 1000; MP_INFO(tx,ty).int_4 = i - MP_INFO(x,y).int_4; } /* ore */ if ((flags & FLAG_MB_ORE) != 0) { r = (MAX_ORE_IN_MARKET * 1000) / (MAX_ORE_ON_TRACK + MAX_ORE_IN_MARKET); i = MP_INFO(x,y).int_5 + MP_INFO(tx,ty).int_5; MP_INFO(x,y).int_5 = (i * r) / 1000; MP_INFO(tx,ty).int_5 = i - MP_INFO(x,y).int_5; } /* steel */ if ((flags & FLAG_MB_STEEL) != 0) { r = (MAX_STEEL_IN_MARKET * 1000) / (MAX_STEEL_ON_TRACK + MAX_STEEL_IN_MARKET); i = MP_INFO(x,y).int_6 + MP_INFO(tx,ty).int_6; MP_INFO(x,y).int_6 = (i * r) / 1000; MP_INFO(tx,ty).int_6 = i - MP_INFO(x,y).int_6; } /* waste */ r = (MAX_WASTE_IN_MARKET * 1000) / (MAX_WASTE_ON_TRACK + MAX_WASTE_IN_MARKET); i = MP_INFO(x,y).int_7 + MP_INFO(tx,ty).int_7; MP_INFO(x,y).int_7 = (i * r) / 1000; MP_INFO(tx,ty).int_7 = i - MP_INFO(x,y).int_7; /* if it's full of waste, burn some to make pollution. */ if (MP_INFO(x,y).int_7 >= (99 * MAX_WASTE_IN_MARKET / 100)) { MP_POL(x,y) += 3000; MP_INFO(x,y).int_7 -= (7 * MAX_WASTE_IN_MARKET) / 10; #if defined (commentout) /* this should fire up the pollution mini screen within a second. */ mini_screen_flags = MINI_SCREEN_POL_FLAG; #endif } } /* do rail traffic */ else if (MP_GROUP(tx,ty) == GROUP_RAIL) { /* food */ if ((flags & FLAG_MB_FOOD) != 0) { r = (MAX_FOOD_IN_MARKET * 1000) / (MAX_FOOD_ON_RAIL + MAX_FOOD_IN_MARKET); i = MP_INFO(x,y).int_1 + MP_INFO(tx,ty).int_1; MP_INFO(x,y).int_1 = (i * r) / 1000; MP_INFO(tx,ty).int_1 = i - MP_INFO(x,y).int_1; } /* jobs */ if ((flags & FLAG_MB_JOBS) != 0) { r = (MAX_JOBS_IN_MARKET * 1000) / (MAX_JOBS_ON_RAIL + MAX_JOBS_IN_MARKET); i = MP_INFO(x,y).int_2 + MP_INFO(tx,ty).int_2; MP_INFO(x,y).int_2 = (i * r) / 1000; MP_INFO(tx,ty).int_2 = i - MP_INFO(x,y).int_2; } /* coal */ if ((flags & FLAG_MB_COAL) != 0) { r = (MAX_COAL_IN_MARKET * 1000) / (MAX_COAL_ON_RAIL + MAX_COAL_IN_MARKET); i = MP_INFO(x,y).int_3 + MP_INFO(tx,ty).int_3; MP_INFO(x,y).int_3 = (i * r) / 1000; MP_INFO(tx,ty).int_3 = i - MP_INFO(x,y).int_3; } /* goods */ if ((flags & FLAG_MB_GOODS) != 0) { r = (MAX_GOODS_IN_MARKET * 1000) / (MAX_GOODS_ON_RAIL + MAX_GOODS_IN_MARKET); i = MP_INFO(x,y).int_4 + MP_INFO(tx,ty).int_4; MP_INFO(x,y).int_4 = (i * r) / 1000; MP_INFO(tx,ty).int_4 = i - MP_INFO(x,y).int_4; } /* ore */ if ((flags & FLAG_MB_ORE) != 0) { r = (MAX_ORE_IN_MARKET * 1000) / (MAX_ORE_ON_RAIL + MAX_ORE_IN_MARKET); i = MP_INFO(x,y).int_5 + MP_INFO(tx,ty).int_5; MP_INFO(x,y).int_5 = (i * r) / 1000; MP_INFO(tx,ty).int_5 = i - MP_INFO(x,y).int_5; } /* steel */ if ((flags & FLAG_MB_STEEL) != 0) { r = (MAX_STEEL_IN_MARKET * 1000) / (MAX_STEEL_ON_RAIL + MAX_STEEL_IN_MARKET); i = MP_INFO(x,y).int_6 + MP_INFO(tx,ty).int_6; MP_INFO(x,y).int_6 = (i * r) / 1000; MP_INFO(tx,ty).int_6 = i - MP_INFO(x,y).int_6; } /* waste */ r = (MAX_WASTE_IN_MARKET * 1000) / (MAX_WASTE_ON_RAIL + MAX_WASTE_IN_MARKET); i = MP_INFO(x,y).int_7 + MP_INFO(tx,ty).int_7; MP_INFO(x,y).int_7 = (i * r) / 1000; MP_INFO(tx,ty).int_7 = i - MP_INFO(x,y).int_7; } /* do road traffic */ else if (MP_GROUP(tx,ty) == GROUP_ROAD) { /* food */ if ((flags & FLAG_MB_FOOD) != 0) { r = (MAX_FOOD_IN_MARKET * 1000) / (MAX_FOOD_ON_ROAD + MAX_FOOD_IN_MARKET); i = MP_INFO(x,y).int_1 + MP_INFO(tx,ty).int_1; MP_INFO(x,y).int_1 = (i * r) / 1000; MP_INFO(tx,ty).int_1 = i - MP_INFO(x,y).int_1; } /* jobs */ if ((flags & FLAG_MB_JOBS) != 0) { r = (MAX_JOBS_IN_MARKET * 1000) / (MAX_JOBS_ON_ROAD + MAX_JOBS_IN_MARKET); i = MP_INFO(x,y).int_2 + MP_INFO(tx,ty).int_2; MP_INFO(x,y).int_2 = (i * r) / 1000; MP_INFO(tx,ty).int_2 = i - MP_INFO(x,y).int_2; } /* coal */ if ((flags & FLAG_MB_COAL) != 0) { r = (MAX_COAL_IN_MARKET * 1000) / (MAX_COAL_ON_ROAD + MAX_COAL_IN_MARKET); i = MP_INFO(x,y).int_3 + MP_INFO(tx,ty).int_3; MP_INFO(x,y).int_3 = (i * r) / 1000; MP_INFO(tx,ty).int_3 = i - MP_INFO(x,y).int_3; } /* goods */ if ((flags & FLAG_MB_GOODS) != 0) { r = (MAX_GOODS_IN_MARKET * 1000) / (MAX_GOODS_ON_ROAD + MAX_GOODS_IN_MARKET); i = MP_INFO(x,y).int_4 + MP_INFO(tx,ty).int_4; MP_INFO(x,y).int_4 = (i * r) / 1000; MP_INFO(tx,ty).int_4 = i - MP_INFO(x,y).int_4; } /* ore */ if ((flags & FLAG_MB_ORE) != 0) { r = (MAX_ORE_IN_MARKET * 1000) / (MAX_ORE_ON_ROAD + MAX_ORE_IN_MARKET); i = MP_INFO(x,y).int_5 + MP_INFO(tx,ty).int_5; MP_INFO(x,y).int_5 = (i * r) / 1000; MP_INFO(tx,ty).int_5 = i - MP_INFO(x,y).int_5; } /* steel */ if ((flags & FLAG_MB_STEEL) != 0) { r = (MAX_STEEL_IN_MARKET * 1000) / (MAX_STEEL_ON_ROAD + MAX_STEEL_IN_MARKET); i = MP_INFO(x,y).int_6 + MP_INFO(tx,ty).int_6; MP_INFO(x,y).int_6 = (i * r) / 1000; MP_INFO(tx,ty).int_6 = i - MP_INFO(x,y).int_6; } /* waste */ r = (MAX_WASTE_IN_MARKET * 1000) / (MAX_WASTE_ON_ROAD + MAX_WASTE_IN_MARKET); i = MP_INFO(x,y).int_7 + MP_INFO(tx,ty).int_7; MP_INFO(x,y).int_7 = (i * r) / 1000; MP_INFO(tx,ty).int_7 = i - MP_INFO(x,y).int_7; } else extra_jobs = 0; return (extra_jobs); }
void do_residence (int x, int y) { /* // int_1 is a job swingometer to choose +/- JOB_SWING% of normal // int_2 is the date of the last starve // int 3 is the real time for the next icon update // int_4 is the birth rate modifier. // int_5 is the death rate modifier. */ int p; /* population */ int bad = 35, good = 30; /* (un)desirability of living here */ int r, po, swing; int hc = 0; /* have health cover ? */ int brm = 0, drm = 0; /* birth/death rate modifier */ int cc = 0; p = MP_INFO(x,y).population; if ((MP_INFO(x,y).flags & FLAG_HEALTH_COVER) != 0) { brm += RESIDENCE_BRM_HEALTH; good += 15; hc = 1; } if ((MP_INFO(x,y).flags & FLAG_FIRE_COVER) == 0) bad += 5; else good += 15; if ((MP_INFO(x,y).flags & FLAG_CRICKET_COVER) != 0) { good += 20; cc = CRICKET_JOB_SWING; } /* normal deaths + pollution deaths */ po = ((MP_POL(x,y) / 50) + 1); if ((RESIDENCE_BASE_DR - MP_INFO(x,y).int_5 - po) > 1) r = rand () % (RESIDENCE_BASE_DR - MP_INFO(x,y).int_5 - po); else r = 2; if (p > 0 && (r < po)) { if (r == 0 || hc == 0) p--; else if (hc != 0 && po > 10 && rand () % 4 == 0) { p--; unnat_deaths++; total_pollution_deaths++; pollution_deaths_history += 1.0; bad += 100; } if (r > 0 && hc == 0) { unnat_deaths++; total_pollution_deaths++; pollution_deaths_history += 1.0; bad += 100; } } /* normal births - must have food and jobs... and people */ if ((MP_INFO(x,y).flags & (FLAG_FED + FLAG_EMPLOYED)) == (FLAG_FED + FLAG_EMPLOYED) && (rand () % (RESIDENCE_BASE_BR + MP_INFO(x,y).int_4) == 1) && p > 0) { p++; total_births++; good += 50; } /* are people starving. */ if ((MP_INFO(x,y).flags & FLAG_FED) == 0 && p > 0) { if (rand () % DAYS_PER_STARVE == 1) { p--; unnat_deaths++; total_starve_deaths++; starve_deaths_history += 1.0; } starving_population += p; bad += 250; drm += 100; MP_INFO(x,y).int_2 = total_time; /* for the starve screen */ } /* kick one out if overpopulated */ if (MP_TYPE(x,y) == CST_RESIDENCE_LL) { brm += RESIDENCE1_BRM; drm += p * 8; if (p > 50) { p--; people_pool++; brm += 20; } } else if (MP_TYPE(x,y) == CST_RESIDENCE_ML) { brm += RESIDENCE2_BRM; drm += p * 3; if (p > 100) { p--; people_pool++; brm += 10; } } else if (MP_TYPE(x,y) == CST_RESIDENCE_HL) { brm += RESIDENCE3_BRM; drm += p; good += 40; if (p > 200) { p--; people_pool++; brm += 10; } } else if (MP_TYPE(x,y) == CST_RESIDENCE_LH) { brm += RESIDENCE4_BRM; drm += p * 5; if (p > 100) { p--; people_pool++; brm += 20; } } else if (MP_TYPE(x,y) == CST_RESIDENCE_MH) { brm += RESIDENCE5_BRM; drm += p / 2; if (p > 200) { p--; people_pool++; brm += 10; } } else if (MP_TYPE(x,y) == CST_RESIDENCE_HH) { good += 100; brm += RESIDENCE6_BRM; drm += p; if (p > 400) { p--; people_pool++; brm += 10; } } population += p; /* now get power */ if (get_power (x, y, POWER_RES_OVERHEAD + (POWER_USE_PER_PERSON * p), 0) != 0) { MP_INFO(x,y).flags |= FLAG_POWERED; MP_INFO(x,y).flags |= FLAG_HAD_POWER; good += 10; } else { MP_INFO(x,y).flags &= (0xffffffff - FLAG_POWERED); bad += 15; if ((MP_INFO(x,y).flags & FLAG_HAD_POWER) != 0) bad += 50; } /* now get fed */ if (get_food (x, y, p) != 0) { MP_INFO(x,y).flags |= FLAG_FED; good += 10; } else MP_INFO(x,y).flags &= (0xffffffff - FLAG_FED); /* now supply jobs and buy goods if employed */ if (MP_INFO(x,y).int_1 > 0) swing = JOB_SWING + (hc * HC_JOB_SWING) + cc; else swing = -(JOB_SWING + (hc * HC_JOB_SWING) + cc); if (put_jobs (x, y, ((p * (WORKING_POP_PERCENT + swing)) / 100)) != 0) { MP_INFO(x,y).flags |= FLAG_EMPLOYED; MP_INFO(x,y).int_1++; if (MP_INFO(x,y).int_1 > 10) MP_INFO(x,y).int_1 = 10; good += 20; if (get_goods (x, y, p / 4) != 0) { good += 10; if (get_power (x, y, p / 2, 0) != 0) /* goods use power */ { good += 5; brm += 10; /* buy more goods if got power for them */ if (get_goods (x, y, p / 4) != 0) good += 5; } else bad += 5; } } else if (MP_INFO(x,y).int_1 < 10) { MP_INFO(x,y).flags &= (0xffffffff - FLAG_EMPLOYED); MP_INFO(x,y).int_1 -= 11; if (MP_INFO(x,y).int_1 < -300) MP_INFO(x,y).int_1 = -300; unemployed_population += p; total_unemployed_days += p; if (total_unemployed_days >= NUMOF_DAYS_IN_YEAR) { total_unemployed_years++; /* think we're ok doing this, max of about 120 added each time. */ total_unemployed_days -= NUMOF_DAYS_IN_YEAR; unemployed_history += 1.0; } unemployment_cost += p; /* hmmm */ bad += 70; } else { MP_INFO(x,y).int_1 -= 20; bad += 50; } drm += p / 4; /* people_pool stuff */ bad += p / 2; bad += MP_POL(x,y) / 20; good += people_pool / 27; r = rand () % ((good + bad) * RESIDENCE_PPM); if (r < bad) { if (p > MIN_RES_POPULATION) { p--; people_pool++; } } else if (people_pool > 0 && r > ((good + bad) * (RESIDENCE_PPM - 1) + bad)) { p++; people_pool--; } MP_INFO(x,y).population = p; MP_INFO(x,y).int_4 = brm; MP_INFO(x,y).int_5 = drm; }
void do_mill (int x, int y) { /* // int_1 contains the goods at the mill // int_2 contains the food store // int_3 contains the coal store // int_4 contains the animation trigger time // int_5 is the % count so far this month // int_6 is the % capacity last month */ /* get food */ int block_anim = 0; if (MP_INFO(x,y).int_2 < MAX_FOOD_AT_MILL) if (get_food (x, y, MILL_GET_FOOD) != 0) MP_INFO(x,y).int_2 += MILL_GET_FOOD; /* get coal */ if (MP_INFO(x,y).int_3 < MAX_COAL_AT_MILL) { if (get_coal (x, y, MILL_GET_COAL) != 0) MP_INFO(x,y).int_3 += MILL_GET_COAL; else if (get_power (x, y, MILL_GET_COAL * MILL_POWER_PER_COAL, 0) != 0) MP_INFO(x,y).int_3 += MILL_GET_COAL; } if (MP_INFO(x,y).int_1 < MAX_GOODS_AT_MILL) { if (MP_INFO(x,y).int_2 > FOOD_USED_BY_MILL && MP_INFO(x,y).int_3 > COAL_USED_BY_MILL) { if (get_jobs (x, y, MILL_JOBS) != 0) { MP_INFO(x,y).int_2 -= FOOD_USED_BY_MILL; MP_INFO(x,y).int_3 -= COAL_USED_BY_MILL; MP_INFO(x,y).int_1 += GOODS_MADE_BY_MILL; MP_INFO(x,y).int_5++; } else { MP_TYPE(x,y) = CST_MILL_0; block_anim = 1; } } else block_anim = 1; } if (MP_INFO(x,y).int_1 > 0) if (put_goods (x, y, MP_INFO(x,y).int_1) != 0) MP_INFO(x,y).int_1 = 0; if (total_time % 100 == 0) { MP_INFO(x,y).int_6 = MP_INFO(x,y).int_5; MP_INFO(x,y).int_5 = 0; } if (real_time >= MP_INFO(x,y).int_4 && block_anim == 0) { MP_INFO(x,y).int_4 = real_time + MILL_ANIM_SPEED; switch (MP_TYPE(x,y)) { case (CST_MILL_0): MP_TYPE(x,y) = CST_MILL_1; break; case (CST_MILL_1): MP_TYPE(x,y) = CST_MILL_2; break; case (CST_MILL_2): MP_TYPE(x,y) = CST_MILL_3; break; case (CST_MILL_3): MP_TYPE(x,y) = CST_MILL_4; break; case (CST_MILL_4): MP_TYPE(x,y) = CST_MILL_5; break; case (CST_MILL_5): MP_TYPE(x,y) = CST_MILL_6; break; case (CST_MILL_6): MP_TYPE(x,y) = CST_MILL_1; MP_POL(x,y)++; break; } } }