summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-04-14 20:28:37 +0000
committerfrosch <frosch@openttd.org>2010-04-14 20:28:37 +0000
commit0f656010c81ac31be8fd59280b427138dce411ff (patch)
tree15ba6245a31a82ddd678fb98bf2247be3ac4beb9
parent1177092da650ff539c1d4933737e0bf42a417771 (diff)
downloadopenttd-0f656010c81ac31be8fd59280b427138dce411ff.tar.xz
(svn r19637) -Codechange: Pass complete TransportType to CmdBuildTunnel.
-rw-r--r--src/ai/api/ai_tunnel.cpp4
-rw-r--r--src/rail_gui.cpp4
-rw-r--r--src/road_gui.cpp4
-rw-r--r--src/tunnelbridge_cmd.cpp32
4 files changed, 27 insertions, 17 deletions
diff --git a/src/ai/api/ai_tunnel.cpp b/src/ai/api/ai_tunnel.cpp
index 911b4a6fd..65689a513 100644
--- a/src/ai/api/ai_tunnel.cpp
+++ b/src/ai/api/ai_tunnel.cpp
@@ -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();
}
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 1d9302872..81c95e5a1 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -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);
}
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 029da1e2e..9fb423e35 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -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);
}
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 522879f17..aaa8b7e7f 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -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);
}
}