Reset layout error counters after town construction

This commit is contained in:
dP
2020-08-11 12:16:02 +03:00
parent 9e8951295c
commit c374464178
3 changed files with 10 additions and 0 deletions

View File

@@ -22,6 +22,10 @@ namespace event {
struct NewMonth {};
struct TownBiilt {
Town *town;
};
struct TownGrowthSucceeded {
Town *town;
TileIndex tile;

View File

@@ -27,6 +27,11 @@ Game::Game() {
this->towns_growth_tiles_last_month = this->towns_growth_tiles;
this->towns_growth_tiles.clear();
});
this->events.listen<event::TownBuilt>(event::Slot::GAME, [this] (const event::TownBuilt &event) {
t->cm.hs_total = t->cm.hs_last_month = t->cm.hs_total_prev = 0;
t->cm.cs_total = t->cm.cs_last_month = t->cm.cs_total_prev = 0;
t->cm.hr_total = t->cm.hr_last_month = t->cm.hr_total_prev = 0;
});
this->events.listen<event::TownGrowthSucceeded>(event::Slot::GAME, [this] (const event::TownGrowthSucceeded &event) {
if (event.town->cache.num_houses <= event.prev_houses) {

View File

@@ -1763,6 +1763,7 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, TownSize
UpdateTownGrowthRate(t);
UpdateTownMaxPass(t);
UpdateAirportsNoise();
citymania::Emit(citymania::event::TownBuilt{t});
}
/**