diff options
Diffstat (limited to 'src/script/api/script_tunnel.cpp')
-rw-r--r-- | src/script/api/script_tunnel.cpp | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/script/api/script_tunnel.cpp b/src/script/api/script_tunnel.cpp index ea9cbc518..8529f908d 100644 --- a/src/script/api/script_tunnel.cpp +++ b/src/script/api/script_tunnel.cpp @@ -88,22 +88,13 @@ static void _DoCommandReturnBuildTunnel1(class ScriptInstance *instance) EnforcePrecondition(false, vehicle_type != ScriptVehicle::VT_ROAD || ScriptRoad::IsRoadTypeAvailable(ScriptRoad::GetCurrentRoadType())); EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY || vehicle_type == ScriptVehicle::VT_ROAD); - uint type = 0; - if (vehicle_type == ScriptVehicle::VT_ROAD) { - type |= (TRANSPORT_ROAD << 8); - type |= ScriptRoad::GetCurrentRoadType(); - } else { - type |= (TRANSPORT_RAIL << 8); - type |= ScriptRail::GetCurrentRailType(); - } - - /* For rail we do nothing special */ if (vehicle_type == ScriptVehicle::VT_RAIL) { - return ScriptObject::Command<CMD_BUILD_TUNNEL>::Do(start, type, 0, {}); + /* For rail we do nothing special */ + return ScriptObject::Command<CMD_BUILD_TUNNEL>::Do(start, TRANSPORT_RAIL, ScriptRail::GetCurrentRailType()); + } else { + ScriptObject::SetCallbackVariable(0, start); + return ScriptObject::Command<CMD_BUILD_TUNNEL>::Do(&::_DoCommandReturnBuildTunnel1, start, TRANSPORT_ROAD, ScriptRoad::GetCurrentRoadType()); } - - ScriptObject::SetCallbackVariable(0, start); - return ScriptObject::Command<CMD_BUILD_TUNNEL>::Do(&::_DoCommandReturnBuildTunnel1, start, type, 0, {}); } /* static */ bool ScriptTunnel::_BuildTunnelRoad1() @@ -115,7 +106,7 @@ static void _DoCommandReturnBuildTunnel1(class ScriptInstance *instance) DiagDirection dir_1 = ::DiagdirBetweenTiles(end, start); DiagDirection dir_2 = ::ReverseDiagDir(dir_1); - return ScriptObject::Command<CMD_BUILD_ROAD>::Do(&::_DoCommandReturnBuildTunnel2, start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (ScriptObject::GetRoadType() << 4), 0, {}); + return ScriptObject::Command<CMD_BUILD_ROAD>::Do(&::_DoCommandReturnBuildTunnel2, start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2), ScriptRoad::GetRoadType(), DRD_NONE, 0); } /* static */ bool ScriptTunnel::_BuildTunnelRoad2() @@ -127,7 +118,7 @@ static void _DoCommandReturnBuildTunnel1(class ScriptInstance *instance) DiagDirection dir_1 = ::DiagdirBetweenTiles(end, start); DiagDirection dir_2 = ::ReverseDiagDir(dir_1); - return ScriptObject::Command<CMD_BUILD_ROAD>::Do(end + ::TileOffsByDiagDir(dir_2), ::DiagDirToRoadBits(dir_1) | (ScriptObject::GetRoadType() << 4), 0, {}); + return ScriptObject::Command<CMD_BUILD_ROAD>::Do(end + ::TileOffsByDiagDir(dir_2), ::DiagDirToRoadBits(dir_1), ScriptRoad::GetRoadType(), DRD_NONE, 0); } /* static */ bool ScriptTunnel::RemoveTunnel(TileIndex tile) |