Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/dataobj/einstellungen.cc b/dataobj/einstellungen.cc
- index 3393bfc..97f64d9 100644
- --- a/dataobj/einstellungen.cc
- +++ b/dataobj/einstellungen.cc
- @@ -103,6 +103,8 @@ settings_t::settings_t() :
- mail_multiplier = 20;
- goods_multiplier = 20;
- electricity_multiplier = 0;
- + depopulation = 0;
- + increased_depop = 101;
- // Also there are size dependen factors (0 causes crash !)
- growthfactor_small = 400;
- @@ -954,6 +956,9 @@ void settings_t::parse_simuconf(tabfile_t& simuconf, sint16& disp_width, sint16&
- goods_multiplier = contents.get_int("goods_multiplier", goods_multiplier );
- electricity_multiplier = contents.get_int("electricity_multiplier", electricity_multiplier );
- + depopulation = contents.get_int("depopulation", depopulation);
- + increased_depop = contents.get_int("increased_depop", increased_depop);
- +
- growthfactor_small = contents.get_int("growthfactor_villages", growthfactor_small );
- growthfactor_medium = contents.get_int("growthfactor_cities", growthfactor_medium );
- growthfactor_large = contents.get_int("growthfactor_capitals", growthfactor_large );
- diff --git a/dataobj/einstellungen.h b/dataobj/einstellungen.h
- index c2c3ad2..bd76e2d 100644
- --- a/dataobj/einstellungen.h
- +++ b/dataobj/einstellungen.h
- @@ -74,6 +74,9 @@ private:
- sint32 growthfactor_medium;
- sint32 growthfactor_large;
- + sint32 depopulation;
- + sint32 increased_depop;
- +
- uint32 minimum_city_distance;
- uint32 industry_increase;
- @@ -464,6 +467,8 @@ public:
- sint32 get_growthfactor_small() const { return growthfactor_small; }
- sint32 get_growthfactor_medium() const { return growthfactor_medium; }
- sint32 get_growthfactor_large() const { return growthfactor_large; }
- + sint32 get_depopulation() const { return depopulation; }
- + sint32 get_increased_depop() const {return increased_depop; }
- // percentage of passengers for different kinds of trips
- sint16 get_factory_worker_percentage() const { return factory_worker_percentage; }
- diff --git a/simcity.cc b/simcity.cc
- index ce2b183..21b5513 100644
- --- a/simcity.cc
- +++ b/simcity.cc
- @@ -1056,6 +1056,8 @@ stadt_t::stadt_t(spieler_t* sp, koord pos, sint32 citizens) :
- check_bau_rathaus(true);
- wachstum = 0;
- + shrink = 0;
- + shrink_is_increased = false;
- allow_citygrowth = true;
- change_size( citizens );
- @@ -1098,6 +1100,9 @@ stadt_t::stadt_t(karte_t* wl, loadsave_t* file) :
- has_low_density = false;
- wachstum = 0;
- + shrink = 0;
- + shrink_is_increased = false;
- +
- stadtinfo_options = 3;
- rdwr(file);
- @@ -1437,6 +1442,7 @@ void stadt_t::step(long delta_t)
- }
- while(stadt_t::step_bau_interval < next_bau_step) {
- + step_depopulation();
- calc_growth();
- step_bau();
- next_bau_step -= stadt_t::step_bau_interval;
- @@ -1460,7 +1466,49 @@ void stadt_t::step(long delta_t)
- city_history_year[0][HIST_BUILDING] = buildings.get_count();
- }
- +/* performs depopulation */
- +void stadt_t::step_depopulation()
- +{
- + settings_t const& s = welt->get_settings();
- + sint64 const(& h)[MAX_CITY_HISTORY] = city_history_month[1];
- + sint32 const population = get_einwohner();
- + sint32 const not_transported = (h[HIST_PAS_GENERATED] - h[HIST_PAS_TRANSPORTED]);
- + sint32 const depopulation = s.get_depopulation();
- + sint32 const ratio_transported = h[HIST_PAS_TRANSPORTED] / ((h[HIST_PAS_GENERATED] * s.get_increased_depop() / 100) + 1);
- + int const jobless = (bev - arb);
- + // maybe this town should stay static
- + if( !allow_citygrowth ) {
- + shrink = 0;
- + return;
- + }
- +
- + // after get_increased_depop() per cent of the generated passengers are transported the city depopulation will be faster
- + if ( !shrink_is_increased && (ratio_transported >= 1)) {
- + shrink_is_increased = true;
- + }
- +
- + sint32 depop_factor = depopulation;
- + if ( shrink_is_increased ) depop_factor += depopulation;
- + // shrink is based on tatio of jobless and not transported passengers to city population
- + shrink += (jobless + not_transported) * depop_factor / (population+1);
- + const int shrink_step = (shrink>>4);
- + DBG_DEBUG("stadt_t::step_depopulation()", "%s: depop_factor %i, depopulation %i; not_transported %i; jobless %i; shrink %i; shrink_step %i; shrink_is_increased %s; ratio_transported %i; increased_depop %i; population %i", get_name(), depop_factor, depopulation, not_transported, jobless, shrink, shrink_step, (shrink_is_increased)?"true":"false", ratio_transported, s.get_increased_depop(), population);
- + shrink &= 0x0F;
- + // max. depopulation is normally lower value of jobless and calculated shrink
- + if ( (shrink_step <= jobless || shrink_is_increased) && bev > shrink_step ) bev -= shrink_step;
- + else if ( bev > jobless ) bev -= jobless;
- + // correct homeless, jobless < 0)
- + if (bev < won) won = bev;
- + if (bev < arb) arb = bev;
- + // small chance to bulldoze a public owned building
- + gebaeude_t* const gb = pick_any(buildings);
- + gebaeude_t::typ const typ = gb->get_haustyp();
- + if ( shrink_is_increased && spieler_t::check_owner(gb->get_besitzer(),NULL) && shrink_step > 0 && (typ == gebaeude_t::wohnung || typ == gebaeude_t::gewerbe) ) {
- + remove_gebaeude_from_stadt(gb);
- + DBG_DEBUG("stadt_t::step_depopulation()", "%s: bulldozed building %s at %i %i %i", get_name(), gb->get_tile()->get_besch()->get_name(), gb->get_pos().x, gb->get_pos().y, gb->get_pos().z);
- + }
- +}
- /* updates the city history
- * @author prissi
- diff --git a/simcity.h b/simcity.h
- index 98a9742..c1e84c1 100644
- --- a/simcity.h
- +++ b/simcity.h
- @@ -155,6 +155,10 @@ private:
- */
- sint32 wachstum;
- + // used for city depopulation
- + sint32 shrink;
- + bool shrink_is_increased;
- +
- /**
- * City history
- * @author prissi
- @@ -260,6 +264,9 @@ private:
- // calculates the growth rate for next step_bau using all the different indicators
- void calc_growth();
- + /* performs depopulation */
- + void step_depopulation();
- +
- /**
- * plant das bauen von Gebaeuden
- * @author Hj. Malthaner
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement