summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-02-14 20:58:19 +0000
committerrubidium <rubidium@openttd.org>2007-02-14 20:58:19 +0000
commitdcc7dd936ef9eae6375be94e750db5861e830d4c (patch)
tree9e975c0a864b9bd93a80002f53634479162a1ab5
parent3053109c635f2874564b9fb5186328ed6fcc496f (diff)
downloadopenttd-dcc7dd936ef9eae6375be94e750db5861e830d4c.tar.xz
(svn r8741) -Fix (r8735): make the saveguards of CmdBuildRoadStop more robust and add roadstops.grf to the list of required grfs.
-rw-r--r--src/road_gui.cpp2
-rw-r--r--src/station_cmd.cpp15
-rw-r--r--src/table/files.h1
3 files changed, 8 insertions, 10 deletions
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 535fcbb93..0f8f00074 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -109,8 +109,6 @@ static void PlaceRoadStop(TileIndex tile, uint32 p2, uint32 cmd)
!(GetRoadBits(tile) & ((DiagDirection)p1 == DIAGDIR_NE ? ROAD_Y : ROAD_X)))) {
cmd ^= CMD_AUTO;
- SETBIT(p2, 2); // We're building over an existing road
- if (IsTileOwner(tile, OWNER_TOWN)) SETBIT(p2, 3); // It's a town owned road
}
}
DoCommandP(tile, p1, p2, CcRoadDepot, cmd);
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 293caa95f..2cc1718de 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1250,8 +1250,6 @@ static RoadStop **FindRoadStopSpot(bool truck_station, Station* st)
* @param p1 entrance direction (DiagDirection)
* @param p2 bit 0: 0 for Bus stops, 1 for truck stops
* bit 1: 0 for normal, 1 for drive-through
- * bit 2: 0 for normal, 1 for build over road
- * bit 3: 0 for player owned road, 1 for town owned road
*/
int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -1261,27 +1259,28 @@ int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
int32 ret;
bool type = HASBIT(p2, 0);
bool is_drive_through = HASBIT(p2, 1);
+ bool build_over_road = is_drive_through && IsTileType(tile, MP_STREET) && GetRoadTileType(tile) == ROAD_TILE_NORMAL;
Owner cur_owner = _current_player;
/* Saveguard the parameters */
if (!IsValidDiagDirection((DiagDirection)p1)) return CMD_ERROR;
/* If it is a drive-through stop check for valid axis */
if (is_drive_through && !IsValidAxis((Axis)p1)) return CMD_ERROR;
- /* If overbuilding a road check tile is a valid road tile */
- if (HASBIT(p2, 2) && !(IsTileType(tile, MP_STREET) && GetRoadTileType(tile) == ROAD_TILE_NORMAL)) return CMD_ERROR;
- /* If overbuilding a town road,check tile is town owned and patch setting is enabled */
- if (HASBIT(p2, 3) && !(_patches.road_stop_on_town_road && IsTileOwner(tile, OWNER_TOWN))) return CMD_ERROR;
+ /* Road bits in the wrong direction */
+ if (build_over_road && (GetRoadBits(tile) & ((Axis)p1 == AXIS_X ? ROAD_Y : ROAD_X)) != 0) return CMD_ERROR;
+ /* Not allowed to build over this road */
+ if (build_over_road && !IsTileOwner(tile, _current_player) && !(IsTileOwner(tile, OWNER_TOWN) && _patches.road_stop_on_town_road)) return CMD_ERROR;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile))
return CMD_ERROR;
- if (is_drive_through & HASBIT(p2, 3)) _current_player = OWNER_TOWN;
+ if (build_over_road && IsTileOwner(tile, OWNER_TOWN)) _current_player = OWNER_TOWN;
ret = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL);
_current_player = cur_owner;
if (CmdFailed(ret)) return ret;
- cost = HASBIT(p2, 2) ? 0 : ret; // Don't add cost of clearing road when overbuilding
+ cost = build_over_road ? 0 : ret; // Don't add cost of clearing road when overbuilding
st = GetStationAround(tile, 1, 1, INVALID_STATION);
if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
diff --git a/src/table/files.h b/src/table/files.h
index 4dfdfebb6..d843d8a9e 100644
--- a/src/table/files.h
+++ b/src/table/files.h
@@ -61,4 +61,5 @@ static MD5File files_openttd[] = {
{ "elrailsw.grf", { 0x4f, 0xf9, 0xac, 0x79, 0x50, 0x28, 0x9b, 0xe2, 0x15, 0x30, 0xa8, 0x1e, 0xd5, 0xfd, 0xe1, 0xda } },
{ "openttd.grf", { 0x59, 0x22, 0x19, 0xe0, 0x6e, 0xe7, 0xb6, 0xa3, 0x55, 0x53, 0xcc, 0x9e, 0xbc, 0xaf, 0xcc, 0x83 } },
{ "trkfoundw.grf", { 0x12, 0x33, 0x3f, 0xa3, 0xd1, 0x86, 0x8b, 0x04, 0x53, 0x18, 0x9c, 0xee, 0xf9, 0x2d, 0xf5, 0x95 } },
+ { "roadstops.grf", { 0x8c, 0xd9, 0x45, 0x21, 0x28, 0x82, 0x96, 0x45, 0x33, 0x22, 0x7a, 0xb9, 0x0d, 0xf3, 0x67, 0x4a } },
};