mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r19637) -Codechange: Pass complete TransportType to CmdBuildTunnel.
This commit is contained in:
parent
1177092da6
commit
0f656010c8
|
@ -77,10 +77,10 @@ static void _DoCommandReturnBuildTunnel1(class AIInstance *instance)
|
|||
|
||||
uint type = 0;
|
||||
if (vehicle_type == AIVehicle::VT_ROAD) {
|
||||
type |= (TRANSPORT_ROAD << 9);
|
||||
type |= (TRANSPORT_ROAD << 8);
|
||||
type |= ::RoadTypeToRoadTypes((::RoadType)AIObject::GetRoadType());
|
||||
} else {
|
||||
type |= (TRANSPORT_RAIL << 9);
|
||||
type |= (TRANSPORT_RAIL << 8);
|
||||
type |= AIRail::GetCurrentRailType();
|
||||
}
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@ void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uin
|
|||
|
||||
static void PlaceRail_Tunnel(TileIndex tile)
|
||||
{
|
||||
DoCommandP(tile, _cur_railtype, 0, CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRailTunnel);
|
||||
DoCommandP(tile, _cur_railtype | (TRANSPORT_RAIL << 8), 0, CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRailTunnel);
|
||||
}
|
||||
|
||||
static void PlaceRail_ConvertRail(TileIndex tile)
|
||||
|
@ -821,7 +821,7 @@ struct BuildRailToolbarWindow : Window {
|
|||
|
||||
virtual void OnPlacePresize(Point pt, TileIndex tile)
|
||||
{
|
||||
DoCommand(tile, _cur_railtype, 0, DC_AUTO, CMD_BUILD_TUNNEL);
|
||||
DoCommand(tile, _cur_railtype | (TRANSPORT_RAIL << 8), 0, DC_AUTO, CMD_BUILD_TUNNEL);
|
||||
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
|
||||
}
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ static const RoadTypeInfo _road_type_infos[] = {
|
|||
|
||||
static void PlaceRoad_Tunnel(TileIndex tile)
|
||||
{
|
||||
DoCommandP(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRoadTunnel);
|
||||
DoCommandP(tile, RoadTypeToRoadTypes(_cur_roadtype) | (TRANSPORT_ROAD << 8), 0, CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRoadTunnel);
|
||||
}
|
||||
|
||||
static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
|
||||
|
@ -688,7 +688,7 @@ struct BuildRoadToolbarWindow : Window {
|
|||
|
||||
virtual void OnPlacePresize(Point pt, TileIndex tile)
|
||||
{
|
||||
DoCommand(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, DC_AUTO, CMD_BUILD_TUNNEL);
|
||||
DoCommand(tile, RoadTypeToRoadTypes(_cur_roadtype) | (TRANSPORT_ROAD << 8), 0, DC_AUTO, CMD_BUILD_TUNNEL);
|
||||
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
|
||||
}
|
||||
|
||||
|
|
|
@ -482,21 +482,31 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
|||
/** 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 start_tile, DoCommandFlag flags, uint32 p1,
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue