diff --git a/src/citymania/cm_event.hpp b/src/citymania/cm_event.hpp index 54d66b9c4b..d3d28f9dc3 100644 --- a/src/citymania/cm_event.hpp +++ b/src/citymania/cm_event.hpp @@ -22,6 +22,10 @@ namespace event { struct NewMonth {}; +struct TownBiilt { + Town *town; +}; + struct TownGrowthSucceeded { Town *town; TileIndex tile; diff --git a/src/citymania/cm_game.cpp b/src/citymania/cm_game.cpp index c4e035daef..a442ae2172 100644 --- a/src/citymania/cm_game.cpp +++ b/src/citymania/cm_game.cpp @@ -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::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::Slot::GAME, [this] (const event::TownGrowthSucceeded &event) { if (event.town->cache.num_houses <= event.prev_houses) { diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index bd25d734a2..2a9de9de78 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -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}); } /**