Changeset - r25106:1ff7bebe2803
[Not reviewed]
master
0 3 0
Tyler Trahan - 4 years ago 2021-04-02 08:13:27
tyler@tylertrahan.com
Feature: Press ctrl to build diagonal rivers in Scenario Editor (#8880)
3 files changed with 20 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/dock_gui.cpp
Show inline comments
 
@@ -170,7 +170,7 @@ struct BuildDocksToolbarWindow : Window 
 

	
 
			case WID_DT_RIVER: // Build river button (in scenario editor)
 
				if (_game_mode != GM_EDITOR) return;
 
				HandlePlacePushButton(this, WID_DT_RIVER, SPR_CURSOR_RIVER, HT_RECT);
 
				HandlePlacePushButton(this, WID_DT_RIVER, SPR_CURSOR_RIVER, HT_RECT | HT_DIAGONAL);
 
				break;
 

	
 
			case WID_DT_BUILD_AQUEDUCT: // Build aqueduct button
 
@@ -247,7 +247,7 @@ struct BuildDocksToolbarWindow : Window 
 
					DoCommandP(end_tile, start_tile, (_game_mode == GM_EDITOR && _ctrl_pressed) ? WATER_CLASS_SEA : WATER_CLASS_CANAL, CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_BUILD_CANALS), CcPlaySound_CONSTRUCTION_WATER);
 
					break;
 
				case DDSP_CREATE_RIVER:
 
					DoCommandP(end_tile, start_tile, WATER_CLASS_RIVER, CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_PLACE_RIVERS), CcPlaySound_CONSTRUCTION_WATER);
 
					DoCommandP(end_tile, start_tile, WATER_CLASS_RIVER | (_ctrl_pressed ? 1 << 2 : 0), CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_PLACE_RIVERS), CcPlaySound_CONSTRUCTION_WATER);
 
					break;
 

	
 
				default: break;
src/lang/english.txt
Show inline comments
 
@@ -2531,7 +2531,7 @@ STR_WATERWAYS_TOOLBAR_BUILD_DOCK_TOOLTIP
 
STR_WATERWAYS_TOOLBAR_BUOY_TOOLTIP                              :{BLACK}Place a buoy which can be used as a waypoint. Shift toggles building/showing cost estimate
 
STR_WATERWAYS_TOOLBAR_BUILD_AQUEDUCT_TOOLTIP                    :{BLACK}Build aqueduct. Shift toggles building/showing cost estimate
 
STR_WATERWAYS_TOOLBAR_CREATE_LAKE_TOOLTIP                       :{BLACK}Define water area.{}Make a canal, unless Ctrl is held down at sea level, when it will flood the surroundings instead
 
STR_WATERWAYS_TOOLBAR_CREATE_RIVER_TOOLTIP                      :{BLACK}Place rivers
 
STR_WATERWAYS_TOOLBAR_CREATE_RIVER_TOOLTIP                      :{BLACK}Place rivers. Ctrl selects the area diagonally
 

	
 
# Ship depot construction window
 
STR_DEPOT_BUILD_SHIP_CAPTION                                    :{WHITE}Ship Depot Orientation
src/water_cmd.cpp
Show inline comments
 
@@ -437,7 +437,9 @@ bool RiverModifyDesertZone(TileIndex til
 
 * @param tile end tile of stretch-dragging
 
 * @param flags type of operation
 
 * @param p1 start tile of stretch-dragging
 
 * @param p2 waterclass to build. sea and river can only be built in scenario editor
 
 * @param p2 various bitstuffed data
 
 *  bits  0-1: waterclass to build. sea and river can only be built in scenario editor
 
 *  bit     2: Whether to use the Orthogonal (0) or Diagonal (1) iterator.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
@@ -449,13 +451,23 @@ CommandCost CmdBuildCanal(TileIndex tile
 
	/* Outside of the editor you can only build canals, not oceans */
 
	if (wc != WATER_CLASS_CANAL && _game_mode != GM_EDITOR) return CMD_ERROR;
 

	
 
	TileArea ta(tile, p1);
 

	
 
	/* Outside the editor you can only drag canals, and not areas */
 
	if (_game_mode != GM_EDITOR && ta.w != 1 && ta.h != 1) return CMD_ERROR;
 
	if (_game_mode != GM_EDITOR) {
 
		TileArea ta(tile, p1);
 
		if (ta.w != 1 && ta.h != 1) return CMD_ERROR;
 
	}
 

	
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	TILE_AREA_LOOP(tile, ta) {
 

	
 
	std::unique_ptr<TileIterator> iter;
 
	if (HasBit(p2, 2)) {
 
		iter = std::make_unique<DiagonalTileIterator>(tile, p1);
 
	} else {
 
		iter = std::make_unique<OrthogonalTileIterator>(tile, p1);
 
	}
 

	
 
	for (; *iter != INVALID_TILE; ++(*iter)) {
 
		TileIndex tile = *iter;
 
		CommandCost ret;
 

	
 
		Slope slope = GetTileSlope(tile);
0 comments (0 inline, 0 general)