* Perform the "bribe" town action. * @param t The town to bribe. * @param flags Type of operation. * @return An empty cost. */
| 3614 | * @return An empty cost. |
| 3615 | */ |
| 3616 | static CommandCost TownActionBribe(Town *t, DoCommandFlags flags) |
| 3617 | { |
| 3618 | if (flags.Test(DoCommandFlag::Execute)) { |
| 3619 | if (Chance16(1, 14)) { |
| 3620 | /* set as unwanted for 6 months */ |
| 3621 | t->unwanted[_current_company] = 6; |
| 3622 | |
| 3623 | /* set all close by station ratings to 0 */ |
| 3624 | for (Station *st : Station::Iterate()) { |
| 3625 | if (st->town == t && st->owner == _current_company) { |
| 3626 | for (GoodsEntry &ge : st->goods) ge.rating = 0; |
| 3627 | } |
| 3628 | } |
| 3629 | |
| 3630 | /* only show error message to the executing player. All errors are handled command.c |
| 3631 | * but this is special, because it can only 'fail' on a DoCommandFlag::Execute */ |
| 3632 | if (IsLocalCompany()) ShowErrorMessage(GetEncodedString(STR_ERROR_BRIBE_FAILED), {}, WL_INFO); |
| 3633 | |
| 3634 | /* decrease by a lot! |
| 3635 | * ChangeTownRating is only for stuff in demolishing. Bribe failure should |
| 3636 | * be independent of any cheat settings |
| 3637 | */ |
| 3638 | if (t->ratings[_current_company] > RATING_BRIBE_DOWN_TO) { |
| 3639 | t->ratings[_current_company] = RATING_BRIBE_DOWN_TO; |
| 3640 | SetWindowDirty(WC_TOWN_AUTHORITY, t->index); |
| 3641 | } |
| 3642 | } else { |
| 3643 | ChangeTownRating(t, RATING_BRIBE_UP_STEP, RATING_BRIBE_MAXIMUM, DoCommandFlag::Execute); |
| 3644 | if (t->exclusivity != _current_company && t->exclusivity != CompanyID::Invalid()) { |
| 3645 | t->exclusivity = CompanyID::Invalid(); |
| 3646 | t->exclusive_counter = 0; |
| 3647 | } |
| 3648 | } |
| 3649 | } |
| 3650 | return CommandCost(); |
| 3651 | } |
| 3652 | |
| 3653 | typedef CommandCost TownActionProc(Town *t, DoCommandFlags flags); |
| 3654 | static TownActionProc * const _town_action_proc[] = { |
nothing calls this directly
no test coverage detected