summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCelestar <celestar@openttd.org>2005-01-27 09:43:24 +0000
committerCelestar <celestar@openttd.org>2005-01-27 09:43:24 +0000
commit1fd8c45c5562bd216c5707a24b191b4cd94db749 (patch)
tree120f3c2099743f04d202796b8afe3e4f117656ea
parent0470fe9f89836be247e0ec3f5fcfdfa3bb51cca8 (diff)
downloadopenttd-1fd8c45c5562bd216c5707a24b191b4cd94db749.tar.xz
(svn r1693) -Fix: [ 1108618 ] A wrong error message was displayed when trying to
expand railroad stations beyond maximum spread
-rw-r--r--lang/english.txt1
-rw-r--r--station_cmd.c20
2 files changed, 17 insertions, 4 deletions
diff --git a/lang/english.txt b/lang/english.txt
index e40c947cc..28d214327 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 dd6fa1204..3ddb5340b 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;