|
@@ -482,21 +482,31 @@ CommandCost CmdBuildBridge(TileIndex end
|
|
|
/** Build Tunnel.
|
|
|
* @param start_tile start tile of tunnel
|
|
|
* @param flags type of operation
|
|
|
* @param p1 railtype or roadtypes. bit 9 set means road tunnel
|
|
|
* @param p1 bit 0-3 railtype or roadtypes
|
|
|
* bit 8-9 transport type
|
|
|
* @param p2 unused
|
|
|
* @param text unused
|
|
|
* @return the cost of this operation or an error
|
|
|
*/
|
|
|
CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
{
|
|
|
TransportType transport_type = (TransportType)GB(p1, 9, 1);
|
|
|
TransportType transport_type = (TransportType)GB(p1, 8, 2);
|
|
|
|
|
|
RailType railtype = INVALID_RAILTYPE;
|
|
|
RoadTypes rts = ROADTYPES_NONE;
|
|
|
_build_tunnel_endtile = 0;
|
|
|
if (transport_type == TRANSPORT_RAIL) {
|
|
|
if (!ValParamRailtype((RailType)p1)) return CMD_ERROR;
|
|
|
} else {
|
|
|
const RoadTypes rts = (RoadTypes)GB(p1, 0, 2);
|
|
|
if (!HasExactlyOneBit(rts) || !HasRoadTypesAvail(_current_company, rts)) return CMD_ERROR;
|
|
|
switch (transport_type) {
|
|
|
case TRANSPORT_RAIL:
|
|
|
railtype = (RailType)GB(p1, 0, 4);
|
|
|
if (!ValParamRailtype(railtype)) return CMD_ERROR;
|
|
|
break;
|
|
|
|
|
|
case TRANSPORT_ROAD:
|
|
|
rts = (RoadTypes)GB(p1, 0, 2);
|
|
|
if (!HasExactlyOneBit(rts) || !HasRoadTypesAvail(_current_company, rts)) return CMD_ERROR;
|
|
|
break;
|
|
|
|
|
|
default: return CMD_ERROR;
|
|
|
}
|
|
|
|
|
|
uint start_z;
|
|
@@ -584,13 +594,13 @@ CommandCost CmdBuildTunnel(TileIndex sta
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
if (transport_type == TRANSPORT_RAIL) {
|
|
|
MakeRailTunnel(start_tile, _current_company, direction, (RailType)GB(p1, 0, 4));
|
|
|
MakeRailTunnel(end_tile, _current_company, ReverseDiagDir(direction), (RailType)GB(p1, 0, 4));
|
|
|
MakeRailTunnel(start_tile, _current_company, direction, railtype);
|
|
|
MakeRailTunnel(end_tile, _current_company, ReverseDiagDir(direction), railtype);
|
|
|
AddSideToSignalBuffer(start_tile, INVALID_DIAGDIR, _current_company);
|
|
|
YapfNotifyTrackLayoutChange(start_tile, DiagDirToDiagTrack(direction));
|
|
|
} else {
|
|
|
MakeRoadTunnel(start_tile, _current_company, direction, (RoadTypes)GB(p1, 0, 2));
|
|
|
MakeRoadTunnel(end_tile, _current_company, ReverseDiagDir(direction), (RoadTypes)GB(p1, 0, 2));
|
|
|
MakeRoadTunnel(start_tile, _current_company, direction, rts);
|
|
|
MakeRoadTunnel(end_tile, _current_company, ReverseDiagDir(direction), rts);
|
|
|
}
|
|
|
}
|
|
|
|