1
0
Fork 0

(svn r1693) -Fix: [ 1108618 ] A wrong error message was displayed when trying to

expand railroad stations beyond maximum spread
release/0.4.5
Celestar 2005-01-27 09:43:24 +00:00
parent 0470fe9f89
commit 1fd8c45c55
2 changed files with 17 additions and 4 deletions

View File

@ -1689,6 +1689,7 @@ STR_3069_BUOY :Buoy
STR_306A_BUOY_IN_THE_WAY :{WHITE}...buoy in the way STR_306A_BUOY_IN_THE_WAY :{WHITE}...buoy in the way
STR_306B_HELIPORT :{BLACK}Heliport STR_306B_HELIPORT :{BLACK}Heliport
STR_306C_STATION_TOO_SPREAD_OUT :{WHITE}...station too spread out STR_306C_STATION_TOO_SPREAD_OUT :{WHITE}...station too spread out
STR_306D_NONUNIFORM_STATIONS_DISALLOWED :{WHITE}...nonuniform stations disabled
##id 0x3800 ##id 0x3800
STR_3800_SHIP_DEPOT_ORIENTATION :{WHITE}Ship Depot Orientation STR_3800_SHIP_DEPOT_ORIENTATION :{WHITE}Ship Depot Orientation

View File

@ -76,6 +76,7 @@ static Station *GetStationAround(uint tile, int w, int h, int closest_station)
if (IsTileType(tile_cur, MP_STATION)) { if (IsTileType(tile_cur, MP_STATION)) {
int t; int t;
t = _map2[tile_cur]; t = _map2[tile_cur];
DEBUG(misc, 0) ("%x, %d", tile_cur, t);
{ {
Station *st = GetStation(t); Station *st = GetStation(t);
// you cannot take control of an oilrig!! // 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); tile = TILE_XY(x,y);
} else { } else {
// check so the direction is the same // 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 // check if the new station adjoins the old station in either direction
if (curw == w && st->train_tile == tile + TILE_XY(0, h)) { 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 // to the right
tile -= TILE_XY(curw, 0); tile -= TILE_XY(curw, 0);
curw += w; curw += w;
} else } else {
_error_message = STR_306D_NONUNIFORM_STATIONS_DISALLOWED;
return false; return false;
}
} }
// make sure the final size is not too big. // 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 // now tile contains the new value for st->train_tile
// curw, curh contain the new value for width and height // 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) { if (st->train_tile != 0) {
// check if we want to expanding an already existing station? // 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); 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)) if (!CheckStationSpreadOut(st, tile_org, w_org, h_org))
return CMD_ERROR; return CMD_ERROR;