* Check that the new track bits may be built. * @param tile %Tile to build on. * @param to_build New track bits. * @return Succeeded or failed command. */
| 236 | * @return Succeeded or failed command. |
| 237 | */ |
| 238 | static CommandCost CheckTrackCombination(TileIndex tile, TrackBits to_build) |
| 239 | { |
| 240 | if (!IsPlainRail(tile)) return CommandCost(STR_ERROR_IMPOSSIBLE_TRACK_COMBINATION); |
| 241 | |
| 242 | /* So, we have a tile with tracks on it (and possibly signals). Let's see |
| 243 | * what tracks first */ |
| 244 | TrackBits current = GetTrackBits(tile); // The current track layout. |
| 245 | TrackBits future = current | to_build; // The track layout we want to build. |
| 246 | |
| 247 | /* Are we really building something new? */ |
| 248 | if (current == future) { |
| 249 | /* Nothing new is being built */ |
| 250 | return CommandCost(STR_ERROR_ALREADY_BUILT); |
| 251 | } |
| 252 | |
| 253 | /* Normally, we may overlap and any combination is valid */ |
| 254 | return CommandCost(); |
| 255 | } |
| 256 | |
| 257 | |
| 258 | /** Valid TrackBits on a specific (non-steep)-slope without foundation */ |
no test coverage detected