Prevent AIs from creating or adding to rail custom bridge heads

This commit is contained in:
Jonathan G Rennison
2018-12-19 18:51:15 +00:00
parent 7da1f8b592
commit ccf13467db
2 changed files with 3 additions and 2 deletions

View File

@@ -982,6 +982,7 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint3
Track track = Extract<Track, 6, 3>(p2); Track track = Extract<Track, 6, 3>(p2);
bool remove = HasBit(p2, 9); bool remove = HasBit(p2, 9);
bool fail_if_obstacle = HasBit(p2, 10); bool fail_if_obstacle = HasBit(p2, 10);
bool no_custom_bridge_heads = HasBit(p2, 11);
_rail_track_endtile = INVALID_TILE; _rail_track_endtile = INVALID_TILE;
@@ -997,7 +998,7 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint3
CommandCost last_error = CMD_ERROR; CommandCost last_error = CMD_ERROR;
for (;;) { for (;;) {
TileIndex last_endtile = _rail_track_endtile; TileIndex last_endtile = _rail_track_endtile;
CommandCost ret = DoCommand(tile, remove ? 0 : railtype, TrackdirToTrack(trackdir), flags, remove ? CMD_REMOVE_SINGLE_RAIL : CMD_BUILD_SINGLE_RAIL); CommandCost ret = DoCommand(tile, remove ? 0 : railtype, TrackdirToTrack(trackdir) | (no_custom_bridge_heads ? 1 << 4 : 0), flags, remove ? CMD_REMOVE_SINGLE_RAIL : CMD_BUILD_SINGLE_RAIL);
if (ret.Failed()) { if (ret.Failed()) {
last_error = ret; last_error = ret;

View File

@@ -355,7 +355,7 @@ static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to)
(::TileX(from) == ::TileX(tile) && ::TileX(tile) == ::TileX(to)) || (::TileX(from) == ::TileX(tile) && ::TileX(tile) == ::TileX(to)) ||
(::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(to))); (::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(to)));
uint32 p2 = SimulateDrag(from, tile, &to) | 1 << 10 | ScriptRail::GetCurrentRailType();; uint32 p2 = SimulateDrag(from, tile, &to) | 1 << 10 | 1 << 11 | ScriptRail::GetCurrentRailType();;
return ScriptObject::DoCommand(tile, to, p2, CMD_BUILD_RAILROAD_TRACK); return ScriptObject::DoCommand(tile, to, p2, CMD_BUILD_RAILROAD_TRACK);
} }