Merge remote-tracking branch 'upstream/master' into 13.0
This commit is contained in:
@@ -20,9 +20,9 @@
|
||||
#include "sortlist_type.h"
|
||||
#include "widgets/dropdown_func.h"
|
||||
#include "core/geometry_func.hpp"
|
||||
#include "cmd_helper.h"
|
||||
#include "tunnelbridge_map.h"
|
||||
#include "road_gui.h"
|
||||
#include "tunnelbridge_cmd.h"
|
||||
#include "tilehighlight_func.h"
|
||||
|
||||
#include "widgets/bridge_widget.h"
|
||||
@@ -53,27 +53,22 @@ typedef GUIList<BuildBridgeData> GUIBridgeList; ///< List of bridges, used in #B
|
||||
* Callback executed after a build Bridge CMD has been called
|
||||
*
|
||||
* @param result Whether the build succeeded
|
||||
* @param end_tile End tile of the bridge.
|
||||
* @param p1 packed start tile coords (~ dx)
|
||||
* @param p2 various bitstuffed elements
|
||||
* - p2 = (bit 0- 7) - bridge type (hi bh)
|
||||
* - p2 = (bit 8-13) - rail type or road types.
|
||||
* - p2 = (bit 15-16) - transport type.
|
||||
* @param cmd unused
|
||||
* @param end_tile End tile of the bridge.
|
||||
* @param tile_start start tile
|
||||
* @param transport_type transport type.
|
||||
*/
|
||||
void CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32 p1, uint32 p2, uint32 cmd)
|
||||
void CcBuildBridge(Commands cmd, const CommandCost &result, TileIndex end_tile, TileIndex tile_start, TransportType transport_type, BridgeType, byte)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
if (_settings_client.sound.confirm) SndPlayTileFx(SND_27_CONSTRUCTION_BRIDGE, end_tile);
|
||||
|
||||
TransportType transport_type = Extract<TransportType, 15, 2>(p2);
|
||||
|
||||
if (transport_type == TRANSPORT_ROAD) {
|
||||
DiagDirection end_direction = ReverseDiagDir(GetTunnelBridgeDirection(end_tile));
|
||||
ConnectRoadToStructure(end_tile, end_direction);
|
||||
|
||||
DiagDirection start_direction = ReverseDiagDir(GetTunnelBridgeDirection(p1));
|
||||
ConnectRoadToStructure(p1, start_direction);
|
||||
DiagDirection start_direction = ReverseDiagDir(GetTunnelBridgeDirection(tile_start));
|
||||
ConnectRoadToStructure(tile_start, start_direction);
|
||||
}
|
||||
|
||||
StoreRailPlacementEndpoints(p1, end_tile, (TileX(p1) == TileX(end_tile)) ? TRACK_Y : TRACK_X, false);
|
||||
@@ -92,7 +87,8 @@ private:
|
||||
/* Internal variables */
|
||||
TileIndex start_tile;
|
||||
TileIndex end_tile;
|
||||
uint32 type;
|
||||
TransportType transport_type;
|
||||
byte road_rail_type;
|
||||
GUIBridgeList *bridges;
|
||||
int bridgetext_offset; ///< Horizontal offset of the text describing the bridge properties in #WID_BBS_BRIDGE_LIST relative to the left edge.
|
||||
Scrollbar *vscroll;
|
||||
@@ -117,13 +113,13 @@ private:
|
||||
|
||||
void BuildBridge(uint8 i)
|
||||
{
|
||||
switch ((TransportType)(this->type >> 15)) {
|
||||
switch (this->transport_type) {
|
||||
case TRANSPORT_RAIL: _last_railbridge_type = this->bridges->at(i).index; break;
|
||||
case TRANSPORT_ROAD: _last_roadbridge_type = this->bridges->at(i).index; break;
|
||||
default: break;
|
||||
}
|
||||
DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->at(i).index,
|
||||
CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge);
|
||||
Command<CMD_BUILD_BRIDGE>::Post(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE, CcBuildBridge,
|
||||
this->end_tile, this->start_tile, this->transport_type, this->bridges->at(i).index, this->road_rail_type);
|
||||
}
|
||||
|
||||
/** Sort the builable bridges */
|
||||
@@ -140,19 +136,20 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
BuildBridgeWindow(WindowDesc *desc, TileIndex start, TileIndex end, uint32 br_type, GUIBridgeList *bl) : Window(desc),
|
||||
BuildBridgeWindow(WindowDesc *desc, TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type, GUIBridgeList *bl) : Window(desc),
|
||||
start_tile(start),
|
||||
end_tile(end),
|
||||
type(br_type),
|
||||
transport_type(transport_type),
|
||||
road_rail_type(road_rail_type),
|
||||
bridges(bl)
|
||||
{
|
||||
this->CreateNestedTree();
|
||||
this->vscroll = this->GetScrollbar(WID_BBS_SCROLLBAR);
|
||||
/* Change the data, or the caption of the gui. Set it to road or rail, accordingly. */
|
||||
this->GetWidget<NWidgetCore>(WID_BBS_CAPTION)->widget_data = (GB(this->type, 15, 2) == TRANSPORT_ROAD) ? STR_SELECT_ROAD_BRIDGE_CAPTION : STR_SELECT_RAIL_BRIDGE_CAPTION;
|
||||
this->FinishInitNested(GB(br_type, 15, 2)); // Initializes 'this->bridgetext_offset'.
|
||||
this->GetWidget<NWidgetCore>(WID_BBS_CAPTION)->widget_data = (transport_type == TRANSPORT_ROAD) ? STR_SELECT_ROAD_BRIDGE_CAPTION : STR_SELECT_RAIL_BRIDGE_CAPTION;
|
||||
this->FinishInitNested(transport_type); // Initializes 'this->bridgetext_offset'.
|
||||
|
||||
this->parent = FindWindowById(WC_BUILD_TOOLBAR, GB(this->type, 15, 2));
|
||||
this->parent = FindWindowById(WC_BUILD_TOOLBAR, transport_type);
|
||||
this->bridges->SetListing(this->last_sorting);
|
||||
this->bridges->SetSortFuncs(this->sorter_funcs);
|
||||
this->bridges->NeedResort();
|
||||
@@ -367,12 +364,6 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
|
||||
{
|
||||
CloseWindowByClass(WC_BUILD_BRIDGE);
|
||||
|
||||
/* Data type for the bridge.
|
||||
* Bit 16,15 = transport type,
|
||||
* 14..8 = road/rail types,
|
||||
* 7..0 = type of bridge */
|
||||
uint32 type = (transport_type << 15) | (road_rail_type << 8);
|
||||
|
||||
/* The bridge length without ramps. */
|
||||
const uint bridge_len = GetTunnelBridgeLength(start, end);
|
||||
|
||||
@@ -388,14 +379,14 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
|
||||
default: break; // water ways and air routes don't have bridge types
|
||||
}
|
||||
if (citymania::_fn_mod && CheckBridgeAvailability(last_bridge_type, bridge_len).Succeeded()) {
|
||||
DoCommandP(end, start, type | last_bridge_type, CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge);
|
||||
Command<CMD_BUILD_BRIDGE>::Post(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE, CcBuildBridge, end, start, transport_type, last_bridge_type, road_rail_type);
|
||||
return;
|
||||
}
|
||||
|
||||
/* only query bridge building possibility once, result is the same for all bridges!
|
||||
* returns CMD_ERROR on failure, and price on success */
|
||||
StringID errmsg = INVALID_STRING_ID;
|
||||
CommandCost ret = DoCommand(end, start, type, CommandFlagsToDCFlags(GetCommandFlags(CMD_BUILD_BRIDGE)) | DC_QUERY_COST, CMD_BUILD_BRIDGE);
|
||||
CommandCost ret = Command<CMD_BUILD_BRIDGE>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_BRIDGE>()) | DC_QUERY_COST, end, start, transport_type, 0, road_rail_type);
|
||||
|
||||
GUIBridgeList *bl = nullptr;
|
||||
if (ret.Failed()) {
|
||||
@@ -455,7 +446,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
|
||||
}
|
||||
|
||||
if (bl != nullptr && bl->size() != 0) {
|
||||
new BuildBridgeWindow(&_build_bridge_desc, start, end, type, bl);
|
||||
new BuildBridgeWindow(&_build_bridge_desc, start, end, transport_type, road_rail_type, bl);
|
||||
} else {
|
||||
delete bl;
|
||||
ShowErrorMessage(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE, errmsg, WL_INFO, TileX(end) * TILE_SIZE, TileY(end) * TILE_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user