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..b2be4bf 100644
- --- a/dataobj/einstellungen.cc
- +++ b/dataobj/einstellungen.cc
- @@ -103,6 +103,9 @@ settings_t::settings_t() :
- mail_multiplier = 20;
- goods_multiplier = 20;
- electricity_multiplier = 0;
- + depopulation_low = 101;
- + depopulation_med = 101;
- + depopulation_hig = 101;
- // Also there are size dependen factors (0 causes crash !)
- growthfactor_small = 400;
- @@ -954,6 +957,10 @@ 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_low = contents.get_int("depopulation_low", depopulation_low);
- + depopulation_med = contents.get_int("depopulation_med", depopulation_med);
- + depopulation_hig = contents.get_int("depopulation_hig", depopulation_hig);
- +
- 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..602f9d5 100644
- --- a/dataobj/einstellungen.h
- +++ b/dataobj/einstellungen.h
- @@ -74,6 +74,10 @@ private:
- sint32 growthfactor_medium;
- sint32 growthfactor_large;
- + sint32 depopulation_low;
- + sint32 depopulation_med;
- + sint32 depopulation_hig;
- +
- uint32 minimum_city_distance;
- uint32 industry_increase;
- @@ -464,6 +468,9 @@ 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_depopopulation_low() const { return depopulation_low; }
- + sint32 get_depopopulation_med() const { return depopulation_med; }
- + sint32 get_depopopulation_hig() const { return depopulation_hig; }
- // 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..47758d4 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_level = 0;
- 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_level = 0;
- +
- 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,51 @@ 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(& h1)[MAX_CITY_HISTORY] = city_history_month[1];
- + sint64 const(& h0)[MAX_CITY_HISTORY] = city_history_month[0];
- + sint32 const ratio_transported_low = ((h0[HIST_PAS_TRANSPORTED] + h1[HIST_PAS_TRANSPORTED]) / (((h0[HIST_PAS_GENERATED] + h1[HIST_PAS_GENERATED]) * s.get_depopopulation_low() / 100) + 1))?1:0;
- + sint32 const ratio_transported_med = ((h0[HIST_PAS_TRANSPORTED] + h1[HIST_PAS_TRANSPORTED]) / (((h0[HIST_PAS_GENERATED] + h1[HIST_PAS_GENERATED]) * s.get_depopopulation_med() / 100) + 1))?1:0;
- + sint32 const ratio_transported_hig = ((h0[HIST_PAS_TRANSPORTED] + h1[HIST_PAS_TRANSPORTED]) / (((h0[HIST_PAS_GENERATED] + h1[HIST_PAS_GENERATED]) * s.get_depopopulation_hig() / 100) + 1))?1:0;
- + bool const is_shrink_too_high = (get_wachstum() * -10 >= get_einwohner())?true:false;
- +
- + // maybe this town should stay static, also skip depopulation when previous month had no passengers
- + if( !allow_citygrowth || h1[HIST_PAS_GENERATED] == 0 ) {
- + shrink = 0;
- + return;
- + }
- + // highest level of transported passengers
- + if ( shrink_level < (ratio_transported_low+ratio_transported_med+ratio_transported_hig) ) {
- + shrink_level = ratio_transported_low+ratio_transported_med+ratio_transported_hig;
- + }
- +
- + // shrink is based on tatio of jobless and not transported passengers to city population
- + shrink += shrink_level - (ratio_transported_low+ratio_transported_med+ratio_transported_hig);
- + const int shrink_step = (shrink>>4);
- + DBG_DEBUG("stadt_t::step_depopulation()", "%s: shrink %i; shrink_step %i; shrink_level %i; ratio_transported_low %i; ratio_transported_med %i; ratio_transported_hig %i; depopulation_low %i; depopulation_med %i; depopulation_hig %i; is_shrink_too_high %s", get_name(), shrink, shrink_step, shrink_level, ratio_transported_low, ratio_transported_med, ratio_transported_hig, s.get_depopopulation_low(), s.get_depopopulation_med(), s.get_depopopulation_hig(), is_shrink_too_high?"true":"false");
- + shrink &= 0x0F;
- + // every shrink_step lowers shrink_level
- + if ( shrink_step > 0 ) {
- + shrink_level -= 1;
- + // small chance to bulldoze a public owned building
- + gebaeude_t* const gb = pick_any(buildings);
- + gebaeude_t::typ const typ = gb->get_haustyp();
- + if ( spieler_t::check_owner(gb->get_besitzer(),NULL) && (typ == gebaeude_t::wohnung || typ == gebaeude_t::gewerbe) && !is_shrink_too_high ) {
- + sint32 population_before = get_einwohner();
- + koord gb_koord = gb->get_pos().get_2d();
- + 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);
- + remove_gebaeude_from_stadt(gb);
- + hausbauer_t::remove(welt,welt->get_spieler(1),gb);
- + cbuffer_t buf;
- + buf.printf(translator::translate("The citizens of %s\nare displeased with\nthe public transport.\n%i inhabitants\nemigrated to Mars."), get_name(), population_before - get_einwohner());
- + welt->get_message()->add_message(buf, gb_koord, message_t::city, CITY_KI, IMG_LEER);
- + }
- + }
- +}
- /* updates the city history
- * @author prissi
- diff --git a/simcity.h b/simcity.h
- index 98a9742..8d3e01e 100644
- --- a/simcity.h
- +++ b/simcity.h
- @@ -155,6 +155,10 @@ private:
- */
- sint32 wachstum;
- + // used for city depopulation
- + sint32 shrink;
- + sint32 shrink_level;
- +
- /**
- * 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