Fix town HR counter
This commit is contained in:
@@ -92,6 +92,7 @@ This is usable for any OpenTTD servers
|
||||
- Shaded trees.
|
||||
- Add APM counter to the status bar.
|
||||
- Added cmtreemap console command to plant trees according to a heightmap image (scenario editor only).
|
||||
- Fix town HR couter.
|
||||
|
||||
*** 1.10.2 (5 Jun 2020) ***
|
||||
- Add new minimap mode showing industries, height and farms at the same time.
|
||||
|
||||
@@ -57,6 +57,12 @@ struct HouseCleared {
|
||||
bool was_completed; ///< whether house was completed before destruction
|
||||
};
|
||||
|
||||
struct HouseDestroyed { // by dynamite, called after HouseCleared
|
||||
CompanyID company_id;
|
||||
Town *town;
|
||||
TileIndex tile;
|
||||
};
|
||||
|
||||
struct HouseCompleted {
|
||||
Town *town;
|
||||
TileIndex tile;
|
||||
|
||||
@@ -62,6 +62,14 @@ Game::Game() {
|
||||
event.town->cm.real_population -= event.house_spec->population;
|
||||
});
|
||||
|
||||
this->events.listen<event::HouseDestroyed>(event::Slot::GAME, [this] (const event::HouseDestroyed &event) {
|
||||
const Company *company = Company::GetIfValid(event.company_id);
|
||||
if (company && company->cm.is_server) {
|
||||
this->set_town_growth_tile(event.tile, TownGrowthTileState::HR);
|
||||
event.town->cm.hr_total++;
|
||||
}
|
||||
});
|
||||
|
||||
this->events.listen<event::HouseCompleted>(event::Slot::GAME, [this] (const event::HouseCompleted &event) {
|
||||
event.town->cm.houses_constructing--;
|
||||
});
|
||||
|
||||
@@ -65,8 +65,6 @@ uint CBDECAY[NUM_CARGO] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
uint days_in_month[] = {31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};//CB
|
||||
void CB_UpdateTownStorage(Town *t); //CB
|
||||
|
||||
const Money NOVAPOLIS_COMPANY_MONEY_THRESHOLD = INT64_MAX >> 4;
|
||||
|
||||
TownID _new_town_id;
|
||||
CargoTypes _town_cargoes_accepted; ///< Bitmap of all cargoes accepted by houses.
|
||||
|
||||
@@ -702,12 +700,8 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags)
|
||||
|
||||
ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM, flags);
|
||||
if (flags & DC_EXEC) {
|
||||
// if (_current_company == COMPANY_FIRST &&
|
||||
// Company::Get(_current_company)->money > NOVAPOLIS_COMPANY_MONEY_THRESHOLD) {
|
||||
// if (t->cb.growth_state == TownGrowthState::GROWING) t->cm.hr_total++;
|
||||
// UpdateTownGrowthTile(tile, t->cb.growth_state == TownGrowthState::GROWING ? TGTS_CB_HOUSE_REMOVED: TGTS_CB_HOUSE_REMOVED_NOGROW);
|
||||
// }
|
||||
ClearTownHouse(t, tile);
|
||||
citymania::Emit(citymania::event::HouseDestroyed{_current_company, t, tile});
|
||||
}
|
||||
|
||||
return cost;
|
||||
|
||||
Reference in New Issue
Block a user