From 1fd8c45c5562bd216c5707a24b191b4cd94db749 Mon Sep 17 00:00:00 2001 From: Celestar Date: Thu, 27 Jan 2005 09:43:24 +0000 Subject: [PATCH] (svn r1693) -Fix: [ 1108618 ] A wrong error message was displayed when trying to expand railroad stations beyond maximum spread --- lang/english.txt | 1 + station_cmd.c | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lang/english.txt b/lang/english.txt index e40c947cc0..28d2143271 100644 --- a/lang/english.txt +++ b/lang/english.txt @@ -1689,6 +1689,7 @@ STR_3069_BUOY :Buoy STR_306A_BUOY_IN_THE_WAY :{WHITE}...buoy in the way STR_306B_HELIPORT :{BLACK}Heliport STR_306C_STATION_TOO_SPREAD_OUT :{WHITE}...station too spread out +STR_306D_NONUNIFORM_STATIONS_DISALLOWED :{WHITE}...nonuniform stations disabled ##id 0x3800 STR_3800_SHIP_DEPOT_ORIENTATION :{WHITE}Ship Depot Orientation diff --git a/station_cmd.c b/station_cmd.c index dd6fa12040..3ddb5340b8 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -76,6 +76,7 @@ static Station *GetStationAround(uint tile, int w, int h, int closest_station) if (IsTileType(tile_cur, MP_STATION)) { int t; t = _map2[tile_cur]; + DEBUG(misc, 0) ("%x, %d", tile_cur, t); { Station *st = GetStation(t); // you cannot take control of an oilrig!! @@ -686,7 +687,10 @@ static bool CanExpandRailroadStation(Station *st, uint *fin, int direction) tile = TILE_XY(x,y); } else { // check so the direction is the same - if ((_map5[st->train_tile] & 1) != direction) return false; + if ((_map5[st->train_tile] & 1) != direction) { + _error_message = STR_306D_NONUNIFORM_STATIONS_DISALLOWED; + return false; + } // check if the new station adjoins the old station in either direction if (curw == w && st->train_tile == tile + TILE_XY(0, h)) { @@ -703,11 +707,16 @@ static bool CanExpandRailroadStation(Station *st, uint *fin, int direction) // to the right tile -= TILE_XY(curw, 0); curw += w; - } else + } else { + _error_message = STR_306D_NONUNIFORM_STATIONS_DISALLOWED; return false; + } } // make sure the final size is not too big. - if (curw > _patches.station_spread || curh > _patches.station_spread) return false; + if (curw > _patches.station_spread || curh > _patches.station_spread) { + _error_message = STR_306C_STATION_TOO_SPREAD_OUT; + return false; + } // now tile contains the new value for st->train_tile // curw, curh contain the new value for width and height @@ -834,10 +843,13 @@ int32 CmdBuildRailroadStation(int x_org, int y_org, uint32 flags, uint32 p1, uin if (st->train_tile != 0) { // check if we want to expanding an already existing station? - if ((!_patches.ainew_active && _is_ai_player) || !_patches.join_stations || !CanExpandRailroadStation(st, finalvalues, direction)) + if ((!_patches.ainew_active && _is_ai_player) || !_patches.join_stations) return_cmd_error(STR_3005_TOO_CLOSE_TO_ANOTHER_RAILROAD); + if (!CanExpandRailroadStation(st, finalvalues, direction)) + return CMD_ERROR; } + //XXX can't we pack this in the "else" part of the if above? if (!CheckStationSpreadOut(st, tile_org, w_org, h_org)) return CMD_ERROR;