mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r8077) -Cleanup: Restructure some switch() statements' default case when they're unreachable
This commit is contained in:
parent
4ae861880b
commit
bccef9f948
@ -287,18 +287,15 @@ static void GrayscaleToMapHeights(uint img_width, uint img_height, byte *map)
|
|||||||
|
|
||||||
/* Get map size and calculate scale and padding values */
|
/* Get map size and calculate scale and padding values */
|
||||||
switch (_patches.heightmap_rotation) {
|
switch (_patches.heightmap_rotation) {
|
||||||
case HM_COUNTER_CLOCKWISE:
|
default: NOT_REACHED();
|
||||||
width = MapSizeX();
|
case HM_COUNTER_CLOCKWISE:
|
||||||
height = MapSizeY();
|
width = MapSizeX();
|
||||||
break;
|
height = MapSizeY();
|
||||||
case HM_CLOCKWISE:
|
break;
|
||||||
width = MapSizeY();
|
case HM_CLOCKWISE:
|
||||||
height = MapSizeX();
|
width = MapSizeY();
|
||||||
break;
|
height = MapSizeX();
|
||||||
default:
|
break;
|
||||||
NOT_REACHED();
|
|
||||||
/* Avoids compiler warnings */
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((img_width * num_div) / img_height > ((width * num_div) / height)) {
|
if ((img_width * num_div) / img_height > ((width * num_div) / height)) {
|
||||||
@ -315,9 +312,9 @@ static void GrayscaleToMapHeights(uint img_width, uint img_height, byte *map)
|
|||||||
for (row = 0; row < height - 1; row++) {
|
for (row = 0; row < height - 1; row++) {
|
||||||
for (col = 0; col < width - 1; col++) {
|
for (col = 0; col < width - 1; col++) {
|
||||||
switch (_patches.heightmap_rotation) {
|
switch (_patches.heightmap_rotation) {
|
||||||
case HM_COUNTER_CLOCKWISE: tile = TileXY(col, row); break;
|
default: NOT_REACHED();
|
||||||
case HM_CLOCKWISE: tile = TileXY(row, col); break;
|
case HM_COUNTER_CLOCKWISE: tile = TileXY(col, row); break;
|
||||||
default: NOT_REACHED(); return;
|
case HM_CLOCKWISE: tile = TileXY(row, col); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if current tile is within the 1-pixel map edge or padding regions */
|
/* Check if current tile is within the 1-pixel map edge or padding regions */
|
||||||
@ -330,16 +327,13 @@ static void GrayscaleToMapHeights(uint img_width, uint img_height, byte *map)
|
|||||||
* We rotate the map 45 degrees (counter)clockwise */
|
* We rotate the map 45 degrees (counter)clockwise */
|
||||||
img_row = (((row - row_pad) * num_div) / img_scale);
|
img_row = (((row - row_pad) * num_div) / img_scale);
|
||||||
switch (_patches.heightmap_rotation) {
|
switch (_patches.heightmap_rotation) {
|
||||||
case HM_COUNTER_CLOCKWISE:
|
default: NOT_REACHED();
|
||||||
img_col = (((width - 1 - col - col_pad) * num_div) / img_scale);
|
case HM_COUNTER_CLOCKWISE:
|
||||||
break;
|
img_col = (((width - 1 - col - col_pad) * num_div) / img_scale);
|
||||||
case HM_CLOCKWISE:
|
break;
|
||||||
img_col = (((col - col_pad) * num_div) / img_scale);
|
case HM_CLOCKWISE:
|
||||||
break;
|
img_col = (((col - col_pad) * num_div) / img_scale);
|
||||||
default:
|
break;
|
||||||
NOT_REACHED();
|
|
||||||
/* Avoids compiler warnings */
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(img_row < img_height);
|
assert(img_row < img_height);
|
||||||
@ -408,17 +402,13 @@ static void FixSlopes(void)
|
|||||||
static bool ReadHeightMap(char *filename, uint *x, uint *y, byte **map)
|
static bool ReadHeightMap(char *filename, uint *x, uint *y, byte **map)
|
||||||
{
|
{
|
||||||
switch (_file_to_saveload.mode) {
|
switch (_file_to_saveload.mode) {
|
||||||
|
default: NOT_REACHED();
|
||||||
#ifdef WITH_PNG
|
#ifdef WITH_PNG
|
||||||
case SL_PNG:
|
case SL_PNG:
|
||||||
return ReadHeightmapPNG(filename, x, y, map);
|
return ReadHeightmapPNG(filename, x, y, map);
|
||||||
#endif /* WITH_PNG */
|
#endif /* WITH_PNG */
|
||||||
case SL_BMP:
|
case SL_BMP:
|
||||||
return ReadHeightmapBMP(filename, x, y, map);
|
return ReadHeightmapBMP(filename, x, y, map);
|
||||||
|
|
||||||
default:
|
|
||||||
NOT_REACHED();
|
|
||||||
/* Avoids compiler warnings */
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user