From 495f18a890a24684a2cdaa4e9ceed01f072b2aba Mon Sep 17 00:00:00 2001 From: frosch Date: Thu, 30 Jul 2015 18:48:25 +0000 Subject: [PATCH] (svn r27349) [1.5] -Backport from trunk: - Fix: Prevent breaking of tram-reversal points by adding more road pieces [FS#6283] (r27308) - Fix: Error message window with manager face failed with GUI zoom [FS#6259] (r27307) - Fix: Account for road-bridges and drive-through-stops in CanFollowRoad [FS#6320] (r27306, r27305) --- src/error_gui.cpp | 31 ++++++++++++++++++++----------- src/road_cmd.cpp | 9 +++++++++ src/station_cmd.cpp | 6 +++++- src/town_cmd.cpp | 7 ++++++- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/error_gui.cpp b/src/error_gui.cpp index 98988de5a0..c8c603afb3 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -182,21 +182,30 @@ public: virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) { - if (widget != WID_EM_MESSAGE) return; + switch (widget) { + case WID_EM_MESSAGE: { + CopyInDParam(0, this->decode_params, lengthof(this->decode_params)); + if (this->textref_stack_size > 0) StartTextRefStackUsage(this->textref_stack_grffile, this->textref_stack_size, this->textref_stack); - CopyInDParam(0, this->decode_params, lengthof(this->decode_params)); - if (this->textref_stack_size > 0) StartTextRefStackUsage(this->textref_stack_grffile, this->textref_stack_size, this->textref_stack); + int text_width = max(0, (int)size->width - WD_FRAMETEXT_LEFT - WD_FRAMETEXT_RIGHT); + this->height_summary = GetStringHeight(this->summary_msg, text_width); + this->height_detailed = (this->detailed_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->detailed_msg, text_width); - int text_width = max(0, (int)size->width - WD_FRAMETEXT_LEFT - WD_FRAMETEXT_RIGHT); - this->height_summary = GetStringHeight(this->summary_msg, text_width); - this->height_detailed = (this->detailed_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->detailed_msg, text_width); + if (this->textref_stack_size > 0) StopTextRefStackUsage(); - if (this->textref_stack_size > 0) StopTextRefStackUsage(); + uint panel_height = WD_FRAMERECT_TOP + this->height_summary + WD_FRAMERECT_BOTTOM; + if (this->detailed_msg != INVALID_STRING_ID) panel_height += this->height_detailed + WD_PAR_VSEP_WIDE; - uint panel_height = WD_FRAMERECT_TOP + this->height_summary + WD_FRAMERECT_BOTTOM; - if (this->detailed_msg != INVALID_STRING_ID) panel_height += this->height_detailed + WD_PAR_VSEP_WIDE; - - size->height = max(size->height, panel_height); + size->height = max(size->height, panel_height); + break; + } + case WID_EM_FACE: { + Dimension face_size = GetSpriteSize(SPR_GRADIENT); + size->width = max(size->width, face_size.width); + size->height = max(size->height, face_size.height); + break; + } + } } virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index dcf9b23d06..449a8016bb 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -563,6 +563,15 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } return_cmd_error(STR_ERROR_ALREADY_BUILT); } + /* Disallow breaking end-of-line of someone else + * so trams can still reverse on this tile. */ + if (rt == ROADTYPE_TRAM && HasExactlyOneBit(existing)) { + Owner owner = GetRoadOwner(tile, rt); + if (Company::IsValidID(owner)) { + CommandCost ret = CheckOwnership(owner); + if (ret.Failed()) return ret; + } + } break; } diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 2c87d8f062..6a644b08eb 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -963,7 +963,11 @@ static CommandCost CheckFlatLandRoadStop(TileArea tile_area, DoCommandFlag flags /* There is a tram, check if we can build road+tram stop over it. */ if (HasBit(cur_rts, ROADTYPE_TRAM)) { Owner tram_owner = GetRoadOwner(cur_tile, ROADTYPE_TRAM); - if (!_settings_game.construction.road_stop_on_competitor_road && tram_owner != OWNER_NONE) { + if (Company::IsValidID(tram_owner) && + (!_settings_game.construction.road_stop_on_competitor_road || + /* Disallow breaking end-of-line of someone else + * so trams can still reverse on this tile. */ + HasExactlyOneBit(GetRoadBits(cur_tile, ROADTYPE_TRAM)))) { CommandCost ret = CheckOwnership(tram_owner); if (ret.Failed()) return ret; } diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 4ac63d5de1..ea44603b0c 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -1317,8 +1317,13 @@ static bool CanFollowRoad(TileIndex tile, DiagDirection dir) case MP_ROAD: return target_rb != ROAD_NONE; - case MP_HOUSE: case MP_STATION: + return IsDriveThroughStopTile(target_tile); + + case MP_TUNNELBRIDGE: + return GetTunnelBridgeTransportType(target_tile) == TRANSPORT_ROAD; + + case MP_HOUSE: case MP_INDUSTRY: case MP_OBJECT: return false;