| 55 | } |
| 56 | |
| 57 | Result BannerSetColourAction::QueryExecute(bool isExecuting) const |
| 58 | { |
| 59 | auto res = Result(); |
| 60 | res.expenditure = ExpenditureType::landscaping; |
| 61 | res.position.x = _loc.x + 16; |
| 62 | res.position.y = _loc.y + 16; |
| 63 | res.position.z = _loc.z; |
| 64 | res.errorTitle = STR_CANT_REPAINT_THIS; |
| 65 | |
| 66 | if (!LocationValid(_loc)) |
| 67 | { |
| 68 | LOG_ERROR("Invalid x / y coordinates: x = %d, y = %d", _loc.x, _loc.y); |
| 69 | return Result(Status::invalidParameters, STR_CANT_REPAINT_THIS, STR_OFF_EDGE_OF_MAP); |
| 70 | } |
| 71 | |
| 72 | if (!Drawing::colourIsValid(_primaryColour)) |
| 73 | { |
| 74 | LOG_ERROR("Invalid primary colour %u", _primaryColour); |
| 75 | return Result(Status::invalidParameters, STR_CANT_REPAINT_THIS, STR_ERR_INVALID_COLOUR); |
| 76 | } |
| 77 | |
| 78 | if (!MapCanBuildAt({ _loc.x, _loc.y, _loc.z - 16 })) |
| 79 | { |
| 80 | return Result(Status::notOwned, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); |
| 81 | } |
| 82 | |
| 83 | auto bannerElement = MapGetBannerElementAt(_loc, _loc.direction); |
| 84 | |
| 85 | if (bannerElement == nullptr) |
| 86 | { |
| 87 | LOG_ERROR("No banner at x = %d, y = %d, z = %d, direction = %u", _loc.x, _loc.y, _loc.z, _loc.direction); |
| 88 | return Result(Status::unknown, STR_CANT_REPAINT_THIS, STR_ERR_BANNER_ELEMENT_NOT_FOUND); |
| 89 | } |
| 90 | |
| 91 | auto index = bannerElement->GetIndex(); |
| 92 | auto banner = GetBanner(index); |
| 93 | if (banner == nullptr) |
| 94 | { |
| 95 | LOG_ERROR("Invalid banner index %u", index); |
| 96 | return Result(Status::invalidParameters, STR_CANT_REPAINT_THIS, kStringIdNone); |
| 97 | } |
| 98 | |
| 99 | if (isExecuting) |
| 100 | { |
| 101 | auto intent = Intent(INTENT_ACTION_UPDATE_BANNER); |
| 102 | intent.PutExtra(INTENT_EXTRA_BANNER_INDEX, index); |
| 103 | ContextBroadcastIntent(&intent); |
| 104 | |
| 105 | banner->colour = _primaryColour; |
| 106 | MapInvalidateTileZoom1({ _loc, _loc.z, _loc.z + 32 }); |
| 107 | } |
| 108 | |
| 109 | return res; |
| 110 | } |
| 111 | } // namespace OpenRCT2::GameActions |
nothing calls this directly
no test coverage detected