| 138 | } |
| 139 | |
| 140 | Result FootpathAdditionPlaceAction::Execute(GameState_t& gameState, Park::ParkData& park) const |
| 141 | { |
| 142 | auto res = Result(); |
| 143 | res.position = _loc; |
| 144 | res.expenditure = ExpenditureType::landscaping; |
| 145 | |
| 146 | auto tileElement = MapGetFootpathElement(_loc); |
| 147 | auto pathElement = tileElement->asPath(); |
| 148 | |
| 149 | if (pathElement == nullptr) |
| 150 | { |
| 151 | LOG_ERROR("No path element at x = %d, y = %d, z = %d", _loc.x, _loc.y, _loc.z); |
| 152 | return Result(Status::invalidParameters, STR_CANT_POSITION_THIS_HERE, STR_ERR_PATH_ELEMENT_NOT_FOUND); |
| 153 | } |
| 154 | |
| 155 | // No change |
| 156 | if (!GetFlags().has(CommandFlag::ghost) && pathElement->GetAdditionEntryIndex() == _entryIndex |
| 157 | && !(pathElement->IsBroken()) && !pathElement->AdditionIsGhost()) |
| 158 | { |
| 159 | return res; |
| 160 | } |
| 161 | |
| 162 | auto* pathAdditionEntry = ObjectEntryManager::GetObjectEntry<PathAdditionEntry>(_entryIndex); |
| 163 | if (pathAdditionEntry == nullptr) |
| 164 | { |
| 165 | LOG_ERROR("Unknown footpath addition entry for entryIndex %d", _entryIndex); |
| 166 | return Result(Status::invalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE); |
| 167 | } |
| 168 | |
| 169 | res.cost = pathAdditionEntry->price; |
| 170 | |
| 171 | if (GetFlags().has(CommandFlag::ghost)) |
| 172 | { |
| 173 | pathElement->SetAdditionIsGhost(true); |
| 174 | } |
| 175 | else |
| 176 | { |
| 177 | FootpathInterruptPeeps(_loc); |
| 178 | pathElement->SetAdditionIsGhost(false); |
| 179 | } |
| 180 | |
| 181 | pathElement->SetAdditionEntryIndex(_entryIndex); |
| 182 | pathElement->SetIsBroken(false); |
| 183 | if (pathAdditionEntry->flags & PATH_ADDITION_FLAG_IS_BIN) |
| 184 | { |
| 185 | pathElement->SetAdditionStatus(255); |
| 186 | } |
| 187 | MapInvalidateTileFull(_loc); |
| 188 | return res; |
| 189 | } |
| 190 | } // namespace OpenRCT2::GameActions |
nothing calls this directly
no test coverage detected