812 if ((grid_pos.x % 4) == 0) rcmd |= ROAD_Y; |
812 if ((grid_pos.x % 4) == 0) rcmd |= ROAD_Y; |
813 if ((grid_pos.y % 4) == 0) rcmd |= ROAD_X; |
813 if ((grid_pos.y % 4) == 0) rcmd |= ROAD_X; |
814 break; |
814 break; |
815 } |
815 } |
816 |
816 |
817 /* Skip slope optimisations */ |
817 /* Stop if the tile is not a part of the grid lines */ |
818 if (rcmd == ROAD_NONE) return rcmd; |
818 if (rcmd == ROAD_NONE) return rcmd; |
819 |
819 |
820 RoadBits rb_template; |
820 /* Optimise only X-junctions */ |
821 switch (GetTileSlope(tile, NULL)) { |
821 if (COUNTBITS(rcmd) != 2) { |
822 default: rb_template = ROAD_ALL; break; |
822 RoadBits rb_template; |
823 case SLOPE_W: rb_template = ROAD_NW | ROAD_SW; break; |
823 |
824 case SLOPE_SW: rb_template = ROAD_Y | ROAD_SW; break; |
824 switch (GetTileSlope(tile, NULL)) { |
825 case SLOPE_S: rb_template = ROAD_SE | ROAD_SW; break; |
825 default: rb_template = ROAD_ALL; break; |
826 case SLOPE_SE: rb_template = ROAD_X | ROAD_SE; break; |
826 case SLOPE_W: rb_template = ROAD_NW | ROAD_SW; break; |
827 case SLOPE_E: rb_template = ROAD_NE | ROAD_SE; break; |
827 case SLOPE_SW: rb_template = ROAD_Y | ROAD_SW; break; |
828 case SLOPE_NE: rb_template = ROAD_Y | ROAD_NE; break; |
828 case SLOPE_S: rb_template = ROAD_SW | ROAD_SE; break; |
829 case SLOPE_N: rb_template = ROAD_NW | ROAD_NE; break; |
829 case SLOPE_SE: rb_template = ROAD_X | ROAD_SE; break; |
830 case SLOPE_NW: rb_template = ROAD_X | ROAD_NW; break; |
830 case SLOPE_E: rb_template = ROAD_SE | ROAD_NE; break; |
831 case SLOPE_STEEP_W: |
831 case SLOPE_NE: rb_template = ROAD_Y | ROAD_NE; break; |
832 case SLOPE_STEEP_S: |
832 case SLOPE_N: rb_template = ROAD_NE | ROAD_NW; break; |
833 case SLOPE_STEEP_E: |
833 case SLOPE_NW: rb_template = ROAD_X | ROAD_NW; break; |
834 case SLOPE_STEEP_N: |
834 case SLOPE_STEEP_W: |
835 rb_template = (dir == DIAGDIR_NE || dir == DIAGDIR_SW) ? ROAD_X : ROAD_Y; |
835 case SLOPE_STEEP_S: |
836 break; |
836 case SLOPE_STEEP_E: |
837 } |
837 case SLOPE_STEEP_N: |
838 |
838 rb_template = ROAD_NONE; |
839 /* Check for the right growth dir */ |
839 break; |
840 if (DiagDirToRoadBits(ReverseDiagDir(dir)) & (rcmd & rb_template)) return rb_template & rcmd; |
840 } |
841 |
841 |
842 return (dir == DIAGDIR_NE || dir == DIAGDIR_SW) ? ROAD_X : ROAD_Y; |
842 /* Stop if the template is compatible to the growth dir */ |
|
843 if (DiagDirToRoadBits(ReverseDiagDir(dir)) & rb_template) return rb_template; |
|
844 /* If not generate a straight road in the direction of the growth */ |
|
845 return DiagDirToRoadBits(dir) | DiagDirToRoadBits(ReverseDiagDir(dir)); |
|
846 } |
|
847 |
|
848 return rcmd; |
843 } |
849 } |
844 |
850 |
845 /** |
851 /** |
846 * Check there are enough neighbor house tiles next to the current tile |
852 * Check there are enough neighbor house tiles next to the current tile |
847 * |
853 * |