mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r4435) - Fix: an assertion triggered when trying to remove a bridge with the remove-tool (r4348 surfaced this). In CmdRemoveRoad tiletype was not checked for ownership. Intorudce IsLevelCrossingTile() which checks if a tile is a crossing without knowing the type. Suggested by peter1138 and Tron.
This commit is contained in:
parent
f69fcf400e
commit
d63fad7a7b
@ -47,11 +47,8 @@ static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool* edge_roa
|
|||||||
// Only do the special processing for actual players.
|
// Only do the special processing for actual players.
|
||||||
if (_current_player >= MAX_PLAYERS) return true;
|
if (_current_player >= MAX_PLAYERS) return true;
|
||||||
|
|
||||||
if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile)) {
|
owner = IsLevelCrossingTile(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile);
|
||||||
owner = GetCrossingRoadOwner(tile);
|
|
||||||
} else {
|
|
||||||
owner = GetTileOwner(tile);
|
|
||||||
}
|
|
||||||
// Only do the special processing if the road is owned
|
// Only do the special processing if the road is owned
|
||||||
// by a town
|
// by a town
|
||||||
if (owner != OWNER_TOWN) {
|
if (owner != OWNER_TOWN) {
|
||||||
@ -112,7 +109,7 @@ int32 CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
|
|
||||||
if (!IsTileType(tile, MP_STREET) && !IsTileType(tile, MP_TUNNELBRIDGE)) return CMD_ERROR;
|
if (!IsTileType(tile, MP_STREET) && !IsTileType(tile, MP_TUNNELBRIDGE)) return CMD_ERROR;
|
||||||
|
|
||||||
owner = IsLevelCrossing(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile);
|
owner = IsLevelCrossingTile(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile);
|
||||||
|
|
||||||
if (owner == OWNER_TOWN && _game_mode != GM_EDITOR) {
|
if (owner == OWNER_TOWN && _game_mode != GM_EDITOR) {
|
||||||
if (IsTileType(tile, MP_TUNNELBRIDGE)) { // index of town is not saved for bridge (no space)
|
if (IsTileType(tile, MP_TUNNELBRIDGE)) { // index of town is not saved for bridge (no space)
|
||||||
|
@ -26,6 +26,10 @@ static inline bool IsLevelCrossing(TileIndex t)
|
|||||||
return GetRoadType(t) == ROAD_CROSSING;
|
return GetRoadType(t) == ROAD_CROSSING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool IsLevelCrossingTile(TileIndex t)
|
||||||
|
{
|
||||||
|
return IsTileType(t, MP_STREET) && IsLevelCrossing(t);
|
||||||
|
}
|
||||||
|
|
||||||
static inline RoadBits GetRoadBits(TileIndex t)
|
static inline RoadBits GetRoadBits(TileIndex t)
|
||||||
{
|
{
|
||||||
|
@ -568,7 +568,7 @@ static void RoadVehCheckTrainCrash(Vehicle *v)
|
|||||||
|
|
||||||
tile = v->tile;
|
tile = v->tile;
|
||||||
|
|
||||||
if (!IsTileType(tile, MP_STREET) || !IsLevelCrossing(tile)) return;
|
if (!IsLevelCrossingTile(tile)) return;
|
||||||
|
|
||||||
if (VehicleFromPos(tile, v, EnumCheckRoadVehCrashTrain) != NULL)
|
if (VehicleFromPos(tile, v, EnumCheckRoadVehCrashTrain) != NULL)
|
||||||
RoadVehCrash(v);
|
RoadVehCrash(v);
|
||||||
|
@ -92,7 +92,7 @@ void TrainPowerChanged(Vehicle* v)
|
|||||||
if (IsBridgeTile(u->tile) && IsBridgeMiddle(u->tile) && DiagDirToAxis(DirToDiagDir(u->direction)) == GetBridgeAxis(u->tile)) {
|
if (IsBridgeTile(u->tile) && IsBridgeMiddle(u->tile) && DiagDirToAxis(DirToDiagDir(u->direction)) == GetBridgeAxis(u->tile)) {
|
||||||
if (!HasPowerOnRail(u->u.rail.railtype, GetRailTypeOnBridge(u->tile))) engine_has_power = false;
|
if (!HasPowerOnRail(u->u.rail.railtype, GetRailTypeOnBridge(u->tile))) engine_has_power = false;
|
||||||
if (!HasPowerOnRail(v->u.rail.railtype, GetRailTypeOnBridge(u->tile))) wagon_has_power = false;
|
if (!HasPowerOnRail(v->u.rail.railtype, GetRailTypeOnBridge(u->tile))) wagon_has_power = false;
|
||||||
} else if (IsTileType(u->tile, MP_STREET) && IsLevelCrossing(u->tile)) {
|
} else if (IsLevelCrossingTile(u->tile)) {
|
||||||
if (!HasPowerOnRail(u->u.rail.railtype, GetRailTypeCrossing(u->tile))) engine_has_power = false;
|
if (!HasPowerOnRail(u->u.rail.railtype, GetRailTypeCrossing(u->tile))) engine_has_power = false;
|
||||||
if (!HasPowerOnRail(v->u.rail.railtype, GetRailTypeCrossing(u->tile))) wagon_has_power = false;
|
if (!HasPowerOnRail(v->u.rail.railtype, GetRailTypeCrossing(u->tile))) wagon_has_power = false;
|
||||||
} else {
|
} else {
|
||||||
@ -1529,8 +1529,7 @@ static void *TestTrainOnCrossing(Vehicle *v, void *data)
|
|||||||
|
|
||||||
static void DisableTrainCrossing(TileIndex tile)
|
static void DisableTrainCrossing(TileIndex tile)
|
||||||
{
|
{
|
||||||
if (IsTileType(tile, MP_STREET) &&
|
if (IsLevelCrossingTile(tile) &&
|
||||||
IsLevelCrossing(tile) &&
|
|
||||||
VehicleFromPos(tile, &tile, TestTrainOnCrossing) == NULL && // empty?
|
VehicleFromPos(tile, &tile, TestTrainOnCrossing) == NULL && // empty?
|
||||||
IsCrossingBarred(tile)) {
|
IsCrossingBarred(tile)) {
|
||||||
UnbarCrossing(tile);
|
UnbarCrossing(tile);
|
||||||
@ -3235,7 +3234,7 @@ static bool TrainCheckIfLineEnds(Vehicle *v)
|
|||||||
}
|
}
|
||||||
if ((ts &= (ts >> 16)) == 0) {
|
if ((ts &= (ts >> 16)) == 0) {
|
||||||
// make a rail/road crossing red
|
// make a rail/road crossing red
|
||||||
if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile)) {
|
if (IsLevelCrossingTile(tile)) {
|
||||||
if (!IsCrossingBarred(tile)) {
|
if (!IsCrossingBarred(tile)) {
|
||||||
BarCrossing(tile);
|
BarCrossing(tile);
|
||||||
SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v);
|
SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v);
|
||||||
|
Loading…
Reference in New Issue
Block a user