autorotate rail depots

--HG--
branch : stations-autorotate
This commit is contained in:
Pavel Stupnikov
2014-04-17 17:13:13 +04:00
parent 7433e55314
commit 05faae1952
7 changed files with 68 additions and 60 deletions

View File

@@ -3,8 +3,7 @@
[
{
"follow_symlinks": true,
"path": ".",
"file_exclude_patterns": ["*.cod"]
"path": "."
}
]
}

View File

@@ -2413,8 +2413,6 @@ STR_STATION_BUILD_PASSENGER_TRAM_ORIENTATION :{WHITE}Passenge
STR_STATION_BUILD_PASSENGER_TRAM_ORIENTATION_TOOLTIP :{BLACK}Select passenger tram station orientation
STR_STATION_BUILD_CARGO_TRAM_ORIENTATION :{WHITE}Freight Tram Station Orientation
STR_STATION_BUILD_CARGO_TRAM_ORIENTATION_TOOLTIP :{BLACK}Select freight tram station orientation
STR_STATION_BUILD_ORIENTATION_AUTO :{BLACK}Auto
STR_STATION_BUILD_ORIENTATION_AUTO_TOOLTIP :{BLACK}Automatically select suitable station orientation
# Waterways toolbar (last two for SE only)
STR_WATERWAYS_TOOLBAR_CAPTION :{WHITE}Waterways Construction
@@ -2968,7 +2966,6 @@ STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER :{ORANGE}{STRING
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED_GENERAL :{ORANGE}{STRING}{GREEN} delivered
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED :{ORANGE}{CARGO_TINY} / {CARGO_LONG}{RED} (still required)
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED :{ORANGE}{CARGO_TINY} / {CARGO_LONG}{GREEN} (delivered)
STR_TOWN_VIEW_POP_HOUSES_RATIO :{BLACK}P/h ratio: {ORANGE}{NUM} {NUM}
STR_TOWN_VIEW_TOWN_GROWS_EVERY :{BLACK}Town grows every {ORANGE}{COMMA}{BLACK} day{P "" s}
STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED :{BLACK}Town grows every {ORANGE}{COMMA}{BLACK} day{P "" s} (funded)
STR_TOWN_VIEW_TOWN_GROW_STOPPED :{BLACK}Town is {RED}not{BLACK} growing

View File

@@ -424,31 +424,59 @@ static DiagDirection TileFractCoordsToDiagDir() {
return diag ? DIAGDIR_NW : DIAGDIR_SW;
}
// FIXME duplicate from road_gui.cpp
static DiagDirection RoadBitsToDiagDir(RoadBits bits) {
if (bits < ROAD_SE) {
return bits == ROAD_NW ? DIAGDIR_NW : DIAGDIR_SW;
}
return bits == ROAD_SE ? DIAGDIR_SE : DIAGDIR_NE;
}
RoadBits FindRailsToConnect(TileIndex tile) {
RoadBits directed = ROAD_NONE;
RoadBits passing = ROAD_NONE;
DiagDirection ddir;
for (ddir = DIAGDIR_BEGIN; ddir < DIAGDIR_END; ddir++) {
TileIndex cur_tile = TileAddByDiagDir(tile, ddir);
if (!IsTileType(cur_tile, MP_RAILWAY)) continue;
if (!IsPlainRail(cur_tile)) continue;
passing |= DiagDirToRoadBits(ddir);
if (GetTrackBits(cur_tile) & DiagdirReachesTracks(ddir)) {
directed |= DiagDirToRoadBits(ddir);
}
}
// Prioritize track bits that head in this direction
if (directed != ROAD_NONE) {
return directed;
}
return passing;
}
/*
* Selects orientation for rail object (depot)
*/
static DiagDirection AutodetectRailObjectDirection(TileIndex tile) {
return TileFractCoordsToDiagDir();
// RoadBits bits = FindRoadsToConnect(tile);
// if (HasExactlyOneBit(bits))
// return RoadBitsToDiagDir(bits);
// if (bits == ROAD_NONE)
// bits = ROAD_ALL;
// RoadBits frac_bits = DiagDirToRoadBits(TileFractCoordsToDiagDir());
// if (HasExactlyOneBit(frac_bits & bits))
// return RoadBitsToDiagDir(frac_bits & bits);
// frac_bits |= MirrorRoadBits(frac_bits);
// if (HasExactlyOneBit(frac_bits & bits))
// return RoadBitsToDiagDir(frac_bits & bits);
// for (DiagDirection ddir = DIAGDIR_BEGIN; ddir < DIAGDIR_END; ddir++) {
// if (DiagDirToRoadBits(ddir) & bits)
// return ddir;
// }
RoadBits bits = FindRailsToConnect(tile);
// FIXME after this point repeats road autodetection
if (HasExactlyOneBit(bits))
return RoadBitsToDiagDir(bits);
if (bits == ROAD_NONE)
bits = ROAD_ALL;
RoadBits frac_bits = DiagDirToRoadBits(TileFractCoordsToDiagDir());
if (HasExactlyOneBit(frac_bits & bits))
return RoadBitsToDiagDir(frac_bits & bits);
frac_bits |= MirrorRoadBits(frac_bits);
if (HasExactlyOneBit(frac_bits & bits))
return RoadBitsToDiagDir(frac_bits & bits);
for (DiagDirection ddir = DIAGDIR_BEGIN; ddir < DIAGDIR_END; ddir++) {
if (DiagDirToRoadBits(ddir) & bits)
return ddir;
}
NOT_REACHED();
}
/** Rail toolbar management class. */
struct BuildRailToolbarWindow : Window {
RailType railtype; ///< Rail type to build.

View File

@@ -304,14 +304,6 @@ static DiagDirection AutodetectDriveThroughRoadStopDirection(TileArea area) {
if (area.w < area.h) return DIAGDIR_SE;
return AutodetectRoadObjectDirection(area.tile);
// Check tile fractional coords
// if (((_tile_fract_coords.x < _tile_fract_coords.y &&
// (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
// (_tile_fract_coords.x > _tile_fract_coords.y &&
// (_tile_fract_coords.x + _tile_fract_coords.y) > 16) )) {
// return DIAGDIR_NE;
// }
// return DIAGDIR_SE;
}
@@ -1280,6 +1272,6 @@ static void ShowRVStationPicker(Window *parent, RoadStopType rs)
void InitializeRoadGui()
{
_road_depot_orientation = DIAGDIR_NW;
_road_station_picker_orientation = DIAGDIR_NW;
_road_depot_orientation = (DiagDirection)(DIAGDIR_NW + 1);
_road_station_picker_orientation = (DiagDirection)(DIAGDIR_END + 3);
}

View File

@@ -400,10 +400,6 @@ public:
SetDParam(5, this->town->cb_houses_removed_last_month);
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_GROWTH_TILES);
SetDParam(0, 10 * this->town->cache.population / this->town->cache.num_houses);
SetDParam(1, 10 * this->town->cache.potential_pop / this->town->cache.num_houses);
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_POP_HOUSES_RATIO);
bool first = true;
for (int i = TE_BEGIN; i < TE_END; i++) {
if (this->town->goal[i] == 0) continue;

View File

@@ -100,11 +100,10 @@ enum BuildSignalWidgets {
/** Widgets of the #BuildRailDepotWindow class. */
enum BuildRailDepotWidgets {
/* Name starts with BRA instead of BR, because of collision with BuildRoadDepotWidgets */
WID_BRAD_DEPOT_NE, ///< Build a depot with the entrance in the north east.
WID_BRAD_DEPOT_SE, ///< Build a depot with the entrance in the south east.
WID_BRAD_DEPOT_SW, ///< Build a depot with the entrance in the south west.
WID_BRAD_DEPOT_NW, ///< Build a depot with the entrance in the north west.
WID_BRAD_DEPOT_AUTO, ///< Build a depot, autoselect entrance.
WID_BRAD_DEPOT_NE, ///< Build a depot with the entrance in the north east.
WID_BRAD_DEPOT_SE, ///< Build a depot with the entrance in the south east.
WID_BRAD_DEPOT_SW, ///< Build a depot with the entrance in the south west.
WID_BRAD_DEPOT_NW, ///< Build a depot with the entrance in the north west.
};
/** Widgets of the #BuildRailWaypointWindow class. */

View File

@@ -32,30 +32,27 @@ enum RoadToolbarWidgets {
/** Widgets of the #BuildRoadDepotWindow class. */
enum BuildRoadDepotWidgets {
/* Name starts with BRO instead of BR, because of collision with BuildRailDepotWidgets */
WID_BROD_CAPTION, ///< Caption of the window.
WID_BROD_DEPOT_NE, ///< Depot with NE entry.
WID_BROD_DEPOT_SE, ///< Depot with SE entry.
WID_BROD_DEPOT_SW, ///< Depot with SW entry.
WID_BROD_DEPOT_NW, ///< Depot with NW entry.
WID_BROD_DEPOT_AUTO, ///< Depot with automatically selected entry.
WID_BROD_CAPTION, ///< Caption of the window.
WID_BROD_DEPOT_NE, ///< Depot with NE entry.
WID_BROD_DEPOT_SE, ///< Depot with SE entry.
WID_BROD_DEPOT_SW, ///< Depot with SW entry.
WID_BROD_DEPOT_NW, ///< Depot with NW entry.
};
/** Widgets of the #BuildRoadStationWindow class. */
enum BuildRoadStationWidgets {
/* Name starts with BRO instead of BR, because of collision with BuildRailStationWidgets */
WID_BROS_CAPTION, ///< Caption of the window.
WID_BROS_BACKGROUND, ///< Background of the window.
WID_BROS_STATION_NE, ///< Terminal station with NE entry.
WID_BROS_STATION_SE, ///< Terminal station with SE entry.
WID_BROS_STATION_SW, ///< Terminal station with SW entry.
WID_BROS_STATION_NW, ///< Terminal station with NW entry.
WID_BROS_STATION_X, ///< Drive-through station in x-direction.
WID_BROS_STATION_Y, ///< Drive-through station in y-direction.
WID_BROS_STATION_AUTO, ///< Terminal station, autodetect direction.
WID_BROS_STATION_XY_AUTO, ///< Drive-through station, autodetect direction.
WID_BROS_LT_OFF, ///< Turn off area highlight.
WID_BROS_LT_ON, ///< Turn on area highlight.
WID_BROS_INFO, ///< Station acceptance info.
WID_BROS_CAPTION, ///< Caption of the window.
WID_BROS_BACKGROUND, ///< Background of the window.
WID_BROS_STATION_NE, ///< Terminal station with NE entry.
WID_BROS_STATION_SE, ///< Terminal station with SE entry.
WID_BROS_STATION_SW, ///< Terminal station with SW entry.
WID_BROS_STATION_NW, ///< Terminal station with NW entry.
WID_BROS_STATION_X, ///< Drive-through station in x-direction.
WID_BROS_STATION_Y, ///< Drive-through station in y-direction.
WID_BROS_LT_OFF, ///< Turn off area highlight.
WID_BROS_LT_ON, ///< Turn on area highlight.
WID_BROS_INFO, ///< Station acceptance info.
};
#endif /* WIDGETS_ROAD_WIDGET_H */