src/road_cmd.cpp
changeset 6498 aff910a05c6e
parent 6486 4f8af35b11eb
child 6574 e1d1a12faaf7
child 9895 7bd07f43b0e3
equal deleted inserted replaced
6497:b7170a1ffb33 6498:aff910a05c6e
   160 			}
   160 			}
   161 
   161 
   162 			if (flags & DC_EXEC) {
   162 			if (flags & DC_EXEC) {
   163 				ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
   163 				ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
   164 
   164 
   165 				MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailTypeCrossing(tile));
   165 				MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailType(tile));
   166 				MarkTileDirtyByTile(tile);
   166 				MarkTileDirtyByTile(tile);
   167 				YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile)));
   167 				YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile)));
   168 			}
   168 			}
   169 			return _price.remove_road * 2;
   169 			return _price.remove_road * 2;
   170 		}
   170 		}
   372 	if (!IsLevelCrossing(tile)) return CMD_ERROR;
   372 	if (!IsLevelCrossing(tile)) return CMD_ERROR;
   373 
   373 
   374 	// not owned by me?
   374 	// not owned by me?
   375 	if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR;
   375 	if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR;
   376 
   376 
   377 	if (GetRailTypeCrossing(tile) == totype) return CMD_ERROR;
   377 	if (GetRailType(tile) == totype) return CMD_ERROR;
   378 
   378 
   379 	// 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
   379 	// 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
   380 	if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailTypeCrossing(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
   380 	if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
   381 
   381 
   382 	if (exec) {
   382 	if (exec) {
   383 		SetRailTypeCrossing(tile, totype);
   383 		SetRailType(tile, totype);
   384 		MarkTileDirtyByTile(tile);
   384 		MarkTileDirtyByTile(tile);
   385 		YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetCrossingRailBits(tile)));
   385 		YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetCrossingRailBits(tile)));
   386 	}
   386 	}
   387 
   387 
   388 	return _price.build_rail >> 1;
   388 	return _price.build_rail >> 1;
   715 			SpriteID image;
   715 			SpriteID image;
   716 			SpriteID pal = PAL_NONE;
   716 			SpriteID pal = PAL_NONE;
   717 
   717 
   718 			if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
   718 			if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
   719 
   719 
   720 			image = GetRailTypeInfo(GetRailTypeCrossing(ti->tile))->base_sprites.crossing;
   720 			image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.crossing;
   721 
   721 
   722 			if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++;
   722 			if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++;
   723 			if (IsCrossingBarred(ti->tile)) image += 2;
   723 			if (IsCrossingBarred(ti->tile)) image += 2;
   724 
   724 
   725 			if (IsOnSnow(ti->tile)) {
   725 			if (IsOnSnow(ti->tile)) {
   731 					default:              image += 4; break; // Paved
   731 					default:              image += 4; break; // Paved
   732 				}
   732 				}
   733 			}
   733 			}
   734 
   734 
   735 			DrawGroundSprite(image, pal);
   735 			DrawGroundSprite(image, pal);
   736 			if (GetRailTypeCrossing(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
   736 			if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
   737 			break;
   737 			break;
   738 		}
   738 		}
   739 
   739 
   740 		default:
   740 		default:
   741 		case ROAD_TILE_DEPOT: {
   741 		case ROAD_TILE_DEPOT: {