* Marks subsidy as awarded, creates news and AI event * @param company awarded company */
| 67 | * @param company awarded company |
| 68 | */ |
| 69 | void Subsidy::AwardTo(CompanyID company) |
| 70 | { |
| 71 | assert(!this->IsAwarded()); |
| 72 | |
| 73 | this->awarded = company; |
| 74 | this->remaining = _settings_game.difficulty.subsidy_duration * CalendarTime::MONTHS_IN_YEAR; |
| 75 | |
| 76 | std::string company_name = GetString(STR_COMPANY_NAME, company); |
| 77 | |
| 78 | /* Add a news item */ |
| 79 | const CargoSpec *cs = CargoSpec::Get(this->cargo_type); |
| 80 | EncodedString headline = GetEncodedString(STR_NEWS_SERVICE_SUBSIDY_AWARDED_HALF + _settings_game.difficulty.subsidy_multiplier, std::move(company_name), cs->name, this->src.GetFormat(), this->src.id, this->dst.GetFormat(), this->dst.id, _settings_game.difficulty.subsidy_duration); |
| 81 | AddNewsItem(std::move(headline), NewsType::Subsidies, NewsStyle::Normal, {}, this->src.GetNewsReference(), this->dst.GetNewsReference()); |
| 82 | AI::BroadcastNewEvent(new ScriptEventSubsidyAwarded(this->index)); |
| 83 | Game::NewEvent(new ScriptEventSubsidyAwarded(this->index)); |
| 84 | |
| 85 | InvalidateWindowData(WC_SUBSIDIES_LIST, 0); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Sets a flag indicating that given town/industry is part of subsidised route. |
no test coverage detected