Changeset - r3560:ad5e3e34a211
[Not reviewed]
master
0 4 0
Darkvater - 19 years ago 2006-04-15 20:07:42
darkvater@openttd.org
(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.
4 files changed with 11 insertions and 11 deletions:
0 comments (0 inline, 0 general)
road_cmd.c
Show inline comments
 
@@ -47,11 +47,8 @@ static bool CheckAllowRemoveRoad(TileInd
 
	// Only do the special processing for actual players.
 
	if (_current_player >= MAX_PLAYERS) return true;
 

	
 
	if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile)) {
 
		owner = GetCrossingRoadOwner(tile);
 
	} else {
 
		owner = GetTileOwner(tile);
 
	}
 
	owner = IsLevelCrossingTile(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile);
 

	
 
	// Only do the special processing if the road is owned
 
	// by a town
 
	if (owner != OWNER_TOWN) {
 
@@ -112,7 +109,7 @@ int32 CmdRemoveRoad(TileIndex tile, uint
 

	
 
	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 (IsTileType(tile, MP_TUNNELBRIDGE)) { // index of town is not saved for bridge (no space)
road_map.h
Show inline comments
 
@@ -26,6 +26,10 @@ static inline bool IsLevelCrossing(TileI
 
	return GetRoadType(t) == ROAD_CROSSING;
 
}
 

	
 
static inline bool IsLevelCrossingTile(TileIndex t)
 
{
 
	return IsTileType(t, MP_STREET) && IsLevelCrossing(t);
 
}
 

	
 
static inline RoadBits GetRoadBits(TileIndex t)
 
{
roadveh_cmd.c
Show inline comments
 
@@ -568,7 +568,7 @@ static void RoadVehCheckTrainCrash(Vehic
 

	
 
	tile = v->tile;
 

	
 
	if (!IsTileType(tile, MP_STREET) || !IsLevelCrossing(tile)) return;
 
	if (!IsLevelCrossingTile(tile)) return;
 

	
 
	if (VehicleFromPos(tile, v, EnumCheckRoadVehCrashTrain) != NULL)
 
		RoadVehCrash(v);
train_cmd.c
Show inline comments
 
@@ -92,7 +92,7 @@ void TrainPowerChanged(Vehicle* v)
 
		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(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(v->u.rail.railtype, GetRailTypeCrossing(u->tile)))	wagon_has_power = false;
 
		} else {
 
@@ -1529,8 +1529,7 @@ static void *TestTrainOnCrossing(Vehicle
 

	
 
static void DisableTrainCrossing(TileIndex tile)
 
{
 
	if (IsTileType(tile, MP_STREET) &&
 
			IsLevelCrossing(tile) &&
 
	if (IsLevelCrossingTile(tile) &&
 
			VehicleFromPos(tile, &tile, TestTrainOnCrossing) == NULL && // empty?
 
			IsCrossingBarred(tile)) {
 
		UnbarCrossing(tile);
 
@@ -3235,7 +3234,7 @@ static bool TrainCheckIfLineEnds(Vehicle
 
		}
 
		if ((ts &= (ts >> 16)) == 0) {
 
			// make a rail/road crossing red
 
			if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile)) {
 
			if (IsLevelCrossingTile(tile)) {
 
				if (!IsCrossingBarred(tile)) {
 
					BarCrossing(tile);
 
					SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v);
0 comments (0 inline, 0 general)