| 216 | } |
| 217 | |
| 218 | void MakeWaterKeepingClass(TileIndex tile, Owner o) |
| 219 | { |
| 220 | WaterClass wc = GetWaterClass(tile); |
| 221 | |
| 222 | /* Autoslope might turn an originally canal or river tile into land */ |
| 223 | auto [slope, z] = GetTileSlopeZ(tile); |
| 224 | |
| 225 | if (slope != SLOPE_FLAT) { |
| 226 | if (wc == WaterClass::Canal) { |
| 227 | /* If we clear the canal, we have to remove it from the infrastructure count as well. */ |
| 228 | Company *c = Company::GetIfValid(o); |
| 229 | if (c != nullptr) { |
| 230 | c->infrastructure.water--; |
| 231 | DirtyCompanyInfrastructureWindows(c->index); |
| 232 | } |
| 233 | /* Sloped canals are locks and no natural water remains whatever the slope direction */ |
| 234 | wc = WaterClass::Invalid; |
| 235 | } |
| 236 | |
| 237 | /* Only river water should be restored on appropriate slopes. Other water would be invalid on slopes */ |
| 238 | if (wc != WaterClass::River || GetInclinedSlopeDirection(slope) == INVALID_DIAGDIR) { |
| 239 | wc = WaterClass::Invalid; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | if (wc == WaterClass::Sea && z > 0) { |
| 244 | /* Update company infrastructure count. */ |
| 245 | Company *c = Company::GetIfValid(o); |
| 246 | if (c != nullptr) { |
| 247 | c->infrastructure.water++; |
| 248 | DirtyCompanyInfrastructureWindows(c->index); |
| 249 | } |
| 250 | |
| 251 | wc = WaterClass::Canal; |
| 252 | } |
| 253 | |
| 254 | /* Zero map array and terminate animation */ |
| 255 | DoClearSquare(tile); |
| 256 | |
| 257 | /* Maybe change to water */ |
| 258 | switch (wc) { |
| 259 | case WaterClass::Sea: MakeSea(tile); break; |
| 260 | case WaterClass::Canal: MakeCanal(tile, o, Random()); break; |
| 261 | case WaterClass::River: MakeRiver(tile, Random()); break; |
| 262 | default: break; |
| 263 | } |
| 264 | |
| 265 | if (wc != WaterClass::Invalid) CheckForDockingTile(tile); |
| 266 | MarkTileDirtyByTile(tile); |
| 267 | } |
| 268 | |
| 269 | static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlags flags) |
| 270 | { |
no test coverage detected