Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/gui/citylist_stats_t.cc b/gui/citylist_stats_t.cc
- index 35438b9..2419b6a 100644
- --- a/gui/citylist_stats_t.cc
- +++ b/gui/citylist_stats_t.cc
- @@ -134,7 +134,7 @@ void citylist_stats_t::zeichnen(koord offset)
- sint32 growth = stadt->get_wachstum();
- buf.clear();
- - buf.printf( "%s: ", stadt->get_name() );
- + buf.printf( "%s%s: ", stadt->get_name(), stadt->get_transport_status()?"":" (!)" );
- buf.append( bev, 0 );
- buf.append( " (" );
- buf.append( growth/10.0, 1 );
- diff --git a/simcity.cc b/simcity.cc
- index ce2b183..1eb7783 100644
- --- a/simcity.cc
- +++ b/simcity.cc
- @@ -1056,6 +1056,9 @@ stadt_t::stadt_t(spieler_t* sp, koord pos, sint32 citizens) :
- check_bau_rathaus(true);
- wachstum = 0;
- + shrink = 0;
- + transport_level = 0;
- + ratio_transported = 0;
- allow_citygrowth = true;
- change_size( citizens );
- @@ -1098,6 +1101,10 @@ stadt_t::stadt_t(karte_t* wl, loadsave_t* file) :
- has_low_density = false;
- wachstum = 0;
- + shrink = 0;
- + transport_level = 0;
- + ratio_transported = 0;
- +
- stadtinfo_options = 3;
- rdwr(file);
- @@ -1437,6 +1444,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 +1468,51 @@ void stadt_t::step(long delta_t)
- city_history_year[0][HIST_BUILDING] = buildings.get_count();
- }
- +/* performs depopulation */
- +void stadt_t::step_depopulation()
- +{
- + sint64 const(& h1)[MAX_CITY_HISTORY] = city_history_month[1];
- + sint64 const(& h0)[MAX_CITY_HISTORY] = city_history_month[0];
- + ratio_transported = (h0[HIST_PAS_TRANSPORTED] + h1[HIST_PAS_TRANSPORTED]) * 10 / ((h0[HIST_PAS_GENERATED] + h1[HIST_PAS_GENERATED]) + 1 ); // transported passengers in 10% steps
- + 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;
- + }
- + // population rewards rising transport level
- + shrink -= (ratio_transported > transport_level && shrink > 0)?1:0;
- +
- + // highest level of transported passengers
- + transport_level = (transport_level >= ratio_transported)?transport_level:ratio_transported;
- +
- + // city shrinks when expected passenger transport level is higher than reached transport level
- + if ( (transport_level - 1) > ratio_transported ) { // population accepts an underachievement margin
- + shrink += transport_level - ratio_transported - 1;
- + }
- + const int shrink_step = (shrink>>4);
- + DBG_DEBUG("stadt_t::step_depopulation()", "%s: shrink %i; shrink_step %i; transport_level %i; ratio_transported %i; is_shrink_too_high %s", get_name(), shrink, shrink_step, transport_level, ratio_transported, is_shrink_too_high?"true":"false");
- + shrink &= 0x0F;
- + // every shrink_step lowers expected transport level
- + if ( shrink_step > 0 ) {
- + transport_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..a729c48 100644
- --- a/simcity.h
- +++ b/simcity.h
- @@ -155,6 +155,11 @@ private:
- */
- sint32 wachstum;
- + // used for city depopulation
- + sint32 shrink;
- + sint32 transport_level;
- + sint32 ratio_transported;
- +
- /**
- * City history
- * @author prissi
- @@ -260,6 +265,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
- @@ -400,6 +408,9 @@ public:
- */
- void set_name( const char *name );
- + // returns status of transport level (used for depopulation)
- + bool get_transport_status() const { return ((transport_level - 1) < ratio_transported); }
- +
- /**
- * gibt einen zufällingen gleichverteilten Punkt innerhalb der
- * Stadtgrenzen zurück
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement