(svn r7068) if () cascades -> switch ()

This commit is contained in:
tron 2006-11-05 12:22:46 +00:00
parent f9fa8437eb
commit a763e7e52e

View File

@ -768,19 +768,21 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
right = left + dpi->width; right = left + dpi->width;
bottom = top + dpi->height; bottom = top + dpi->height;
if (dpi->zoom < 1) { switch (dpi->zoom) {
case 0:
FOR_ALL_TOWNS(t) { FOR_ALL_TOWNS(t) {
if (bottom > t->sign.top && if (bottom > t->sign.top &&
top < t->sign.top + 12 && top < t->sign.top + 12 &&
right > t->sign.left && right > t->sign.left &&
left < t->sign.left + t->sign.width_1) { left < t->sign.left + t->sign.width_1) {
AddStringToDraw(t->sign.left + 1, t->sign.top + 1, AddStringToDraw(t->sign.left + 1, t->sign.top + 1,
_patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL, _patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
t->index, t->population); t->index, t->population);
} }
} }
} else if (dpi->zoom == 1) { break;
case 1:
right += 2; right += 2;
bottom += 2; bottom += 2;
@ -789,27 +791,28 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
top < t->sign.top + 24 && top < t->sign.top + 24 &&
right > t->sign.left && right > t->sign.left &&
left < t->sign.left + t->sign.width_1*2) { left < t->sign.left + t->sign.width_1*2) {
AddStringToDraw(t->sign.left + 1, t->sign.top + 1, AddStringToDraw(t->sign.left + 1, t->sign.top + 1,
_patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL, _patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
t->index, t->population); t->index, t->population);
} }
} }
} else { break;
default: NOT_REACHED();
case 2:
right += 4; right += 4;
bottom += 5; bottom += 5;
assert(dpi->zoom == 2);
FOR_ALL_TOWNS(t) { FOR_ALL_TOWNS(t) {
if (bottom > t->sign.top && if (bottom > t->sign.top &&
top < t->sign.top + 24 && top < t->sign.top + 24 &&
right > t->sign.left && right > t->sign.left &&
left < t->sign.left + t->sign.width_2*4) { left < t->sign.left + t->sign.width_2*4) {
AddStringToDraw(t->sign.left + 5, t->sign.top + 1, STR_TOWN_LABEL_TINY_BLACK, t->index, 0); AddStringToDraw(t->sign.left + 5, t->sign.top + 1, STR_TOWN_LABEL_TINY_BLACK, t->index, 0);
AddStringToDraw(t->sign.left + 1, t->sign.top - 3, STR_TOWN_LABEL_TINY_WHITE, t->index, 0); AddStringToDraw(t->sign.left + 1, t->sign.top - 3, STR_TOWN_LABEL_TINY_WHITE, t->index, 0);
} }
} }
break;
} }
} }
@ -839,7 +842,8 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
right = left + dpi->width; right = left + dpi->width;
bottom = top + dpi->height; bottom = top + dpi->height;
if (dpi->zoom < 1) { switch (dpi->zoom) {
case 0:
FOR_ALL_STATIONS(st) { FOR_ALL_STATIONS(st) {
if (bottom > st->sign.top && if (bottom > st->sign.top &&
top < st->sign.top + 12 && top < st->sign.top + 12 &&
@ -848,10 +852,11 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
AddStation(st, STR_305C_0, st->sign.width_1); AddStation(st, STR_305C_0, st->sign.width_1);
} }
} }
} else if (dpi->zoom == 1) { break;
case 1:
right += 2; right += 2;
bottom += 2; bottom += 2;
FOR_ALL_STATIONS(st) { FOR_ALL_STATIONS(st) {
if (bottom > st->sign.top && if (bottom > st->sign.top &&
top < st->sign.top + 24 && top < st->sign.top + 24 &&
@ -860,13 +865,12 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
AddStation(st, STR_305C_0, st->sign.width_1); AddStation(st, STR_305C_0, st->sign.width_1);
} }
} }
break;
} else { default: NOT_REACHED();
assert(dpi->zoom == 2); case 2:
right += 4; right += 4;
bottom += 5; bottom += 5;
FOR_ALL_STATIONS(st) { FOR_ALL_STATIONS(st) {
if (bottom > st->sign.top && if (bottom > st->sign.top &&
top < st->sign.top + 24 && top < st->sign.top + 24 &&
@ -875,6 +879,7 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
AddStation(st, STR_STATION_SIGN_TINY, st->sign.width_2 | 0x8000); AddStation(st, STR_STATION_SIGN_TINY, st->sign.width_2 | 0x8000);
} }
} }
break;
} }
} }
@ -904,7 +909,8 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
right = left + dpi->width; right = left + dpi->width;
bottom = top + dpi->height; bottom = top + dpi->height;
if (dpi->zoom < 1) { switch (dpi->zoom) {
case 0:
FOR_ALL_SIGNS(si) { FOR_ALL_SIGNS(si) {
if (bottom > si->sign.top && if (bottom > si->sign.top &&
top < si->sign.top + 12 && top < si->sign.top + 12 &&
@ -913,7 +919,9 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
AddSign(si, STR_2806, si->sign.width_1); AddSign(si, STR_2806, si->sign.width_1);
} }
} }
} else if (dpi->zoom == 1) { break;
case 1:
right += 2; right += 2;
bottom += 2; bottom += 2;
FOR_ALL_SIGNS(si) { FOR_ALL_SIGNS(si) {
@ -924,10 +932,12 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
AddSign(si, STR_2806, si->sign.width_1); AddSign(si, STR_2806, si->sign.width_1);
} }
} }
} else { break;
default: NOT_REACHED();
case 2:
right += 4; right += 4;
bottom += 5; bottom += 5;
FOR_ALL_SIGNS(si) { FOR_ALL_SIGNS(si) {
if (bottom > si->sign.top && if (bottom > si->sign.top &&
top < si->sign.top + 24 && top < si->sign.top + 24 &&
@ -936,6 +946,7 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
AddSign(si, STR_2002, si->sign.width_2 | 0x8000); AddSign(si, STR_2002, si->sign.width_2 | 0x8000);
} }
} }
break;
} }
} }
@ -965,7 +976,8 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi)
right = left + dpi->width; right = left + dpi->width;
bottom = top + dpi->height; bottom = top + dpi->height;
if (dpi->zoom < 1) { switch (dpi->zoom) {
case 0:
FOR_ALL_WAYPOINTS(wp) { FOR_ALL_WAYPOINTS(wp) {
if (bottom > wp->sign.top && if (bottom > wp->sign.top &&
top < wp->sign.top + 12 && top < wp->sign.top + 12 &&
@ -974,7 +986,9 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi)
AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1); AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1);
} }
} }
} else if (dpi->zoom == 1) { break;
case 1:
right += 2; right += 2;
bottom += 2; bottom += 2;
FOR_ALL_WAYPOINTS(wp) { FOR_ALL_WAYPOINTS(wp) {
@ -985,10 +999,12 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi)
AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1); AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1);
} }
} }
} else { break;
default: NOT_REACHED();
case 2:
right += 4; right += 4;
bottom += 5; bottom += 5;
FOR_ALL_WAYPOINTS(wp) { FOR_ALL_WAYPOINTS(wp) {
if (bottom > wp->sign.top && if (bottom > wp->sign.top &&
top < wp->sign.top + 24 && top < wp->sign.top + 24 &&
@ -997,6 +1013,7 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi)
AddWaypoint(wp, STR_WAYPOINT_VIEWPORT_TINY, wp->sign.width_2 | 0x8000); AddWaypoint(wp, STR_WAYPOINT_VIEWPORT_TINY, wp->sign.width_2 | 0x8000);
} }
} }
break;
} }
} }