diff options
author | tron <tron@openttd.org> | 2006-11-05 12:22:46 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-11-05 12:22:46 +0000 |
commit | a763e7e52ede53d617dac0a84421629d96eec0e5 (patch) | |
tree | 6a7d06a941e79c26c136d9f80c9eeb94c3744313 | |
parent | f9fa8437ebb57bb0f824aacf759b0f4faaef13ad (diff) | |
download | openttd-a763e7e52ede53d617dac0a84421629d96eec0e5.tar.xz |
(svn r7068) if () cascades -> switch ()
-rw-r--r-- | viewport.c | 275 |
1 files changed, 146 insertions, 129 deletions
diff --git a/viewport.c b/viewport.c index 9ae39daf7..79ae0b269 100644 --- a/viewport.c +++ b/viewport.c @@ -768,48 +768,51 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi) right = left + dpi->width; bottom = top + dpi->height; - if (dpi->zoom < 1) { - FOR_ALL_TOWNS(t) { - if (bottom > t->sign.top && - top < t->sign.top + 12 && - right > t->sign.left && - left < t->sign.left + t->sign.width_1) { - - AddStringToDraw(t->sign.left + 1, t->sign.top + 1, - _patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL, - t->index, t->population); + switch (dpi->zoom) { + case 0: + FOR_ALL_TOWNS(t) { + if (bottom > t->sign.top && + top < t->sign.top + 12 && + right > t->sign.left && + left < t->sign.left + t->sign.width_1) { + AddStringToDraw(t->sign.left + 1, t->sign.top + 1, + _patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL, + t->index, t->population); + } } - } - } else if (dpi->zoom == 1) { - right += 2; - bottom += 2; - - FOR_ALL_TOWNS(t) { - if (bottom > t->sign.top && - top < t->sign.top + 24 && - right > t->sign.left && - left < t->sign.left + t->sign.width_1*2) { - - AddStringToDraw(t->sign.left + 1, t->sign.top + 1, - _patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL, - t->index, t->population); + break; + + case 1: + right += 2; + bottom += 2; + + FOR_ALL_TOWNS(t) { + if (bottom > t->sign.top && + top < t->sign.top + 24 && + right > t->sign.left && + left < t->sign.left + t->sign.width_1*2) { + AddStringToDraw(t->sign.left + 1, t->sign.top + 1, + _patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL, + t->index, t->population); + } } - } - } else { - right += 4; - bottom += 5; - - assert(dpi->zoom == 2); - FOR_ALL_TOWNS(t) { - if (bottom > t->sign.top && - top < t->sign.top + 24 && - right > t->sign.left && - 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 + 1, t->sign.top - 3, STR_TOWN_LABEL_TINY_WHITE, t->index, 0); + break; + + default: NOT_REACHED(); + case 2: + right += 4; + bottom += 5; + + FOR_ALL_TOWNS(t) { + if (bottom > t->sign.top && + top < t->sign.top + 24 && + right > t->sign.left && + 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 + 1, t->sign.top - 3, STR_TOWN_LABEL_TINY_WHITE, t->index, 0); + } } - } + break; } } @@ -839,42 +842,44 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi) right = left + dpi->width; bottom = top + dpi->height; - if (dpi->zoom < 1) { - FOR_ALL_STATIONS(st) { - if (bottom > st->sign.top && - top < st->sign.top + 12 && - right > st->sign.left && - left < st->sign.left + st->sign.width_1) { - AddStation(st, STR_305C_0, st->sign.width_1); - } - } - } else if (dpi->zoom == 1) { - right += 2; - bottom += 2; - - FOR_ALL_STATIONS(st) { - if (bottom > st->sign.top && - top < st->sign.top + 24 && - right > st->sign.left && - left < st->sign.left + st->sign.width_1*2) { - AddStation(st, STR_305C_0, st->sign.width_1); + switch (dpi->zoom) { + case 0: + FOR_ALL_STATIONS(st) { + if (bottom > st->sign.top && + top < st->sign.top + 12 && + right > st->sign.left && + left < st->sign.left + st->sign.width_1) { + AddStation(st, STR_305C_0, st->sign.width_1); + } } - } - - } else { - assert(dpi->zoom == 2); + break; - right += 4; - bottom += 5; + case 1: + right += 2; + bottom += 2; + FOR_ALL_STATIONS(st) { + if (bottom > st->sign.top && + top < st->sign.top + 24 && + right > st->sign.left && + left < st->sign.left + st->sign.width_1*2) { + AddStation(st, STR_305C_0, st->sign.width_1); + } + } + break; - FOR_ALL_STATIONS(st) { - if (bottom > st->sign.top && - top < st->sign.top + 24 && - right > st->sign.left && - left < st->sign.left + st->sign.width_2*4) { - AddStation(st, STR_STATION_SIGN_TINY, st->sign.width_2 | 0x8000); + default: NOT_REACHED(); + case 2: + right += 4; + bottom += 5; + FOR_ALL_STATIONS(st) { + if (bottom > st->sign.top && + top < st->sign.top + 24 && + right > st->sign.left && + left < st->sign.left + st->sign.width_2*4) { + AddStation(st, STR_STATION_SIGN_TINY, st->sign.width_2 | 0x8000); + } } - } + break; } } @@ -904,38 +909,44 @@ static void ViewportAddSigns(DrawPixelInfo *dpi) right = left + dpi->width; bottom = top + dpi->height; - if (dpi->zoom < 1) { - FOR_ALL_SIGNS(si) { - if (bottom > si->sign.top && - top < si->sign.top + 12 && - right > si->sign.left && - left < si->sign.left + si->sign.width_1) { - AddSign(si, STR_2806, si->sign.width_1); + switch (dpi->zoom) { + case 0: + FOR_ALL_SIGNS(si) { + if (bottom > si->sign.top && + top < si->sign.top + 12 && + right > si->sign.left && + left < si->sign.left + si->sign.width_1) { + AddSign(si, STR_2806, si->sign.width_1); + } } - } - } else if (dpi->zoom == 1) { - right += 2; - bottom += 2; - FOR_ALL_SIGNS(si) { - if (bottom > si->sign.top && - top < si->sign.top + 24 && - right > si->sign.left && - left < si->sign.left + si->sign.width_1 * 2) { - AddSign(si, STR_2806, si->sign.width_1); + break; + + case 1: + right += 2; + bottom += 2; + FOR_ALL_SIGNS(si) { + if (bottom > si->sign.top && + top < si->sign.top + 24 && + right > si->sign.left && + left < si->sign.left + si->sign.width_1 * 2) { + AddSign(si, STR_2806, si->sign.width_1); + } } - } - } else { - right += 4; - bottom += 5; - - FOR_ALL_SIGNS(si) { - if (bottom > si->sign.top && - top < si->sign.top + 24 && - right > si->sign.left && - left < si->sign.left + si->sign.width_2 * 4) { - AddSign(si, STR_2002, si->sign.width_2 | 0x8000); + break; + + default: NOT_REACHED(); + case 2: + right += 4; + bottom += 5; + FOR_ALL_SIGNS(si) { + if (bottom > si->sign.top && + top < si->sign.top + 24 && + right > si->sign.left && + left < si->sign.left + si->sign.width_2 * 4) { + AddSign(si, STR_2002, si->sign.width_2 | 0x8000); + } } - } + break; } } @@ -965,38 +976,44 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi) right = left + dpi->width; bottom = top + dpi->height; - if (dpi->zoom < 1) { - FOR_ALL_WAYPOINTS(wp) { - if (bottom > wp->sign.top && - top < wp->sign.top + 12 && - right > wp->sign.left && - left < wp->sign.left + wp->sign.width_1) { - AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1); + switch (dpi->zoom) { + case 0: + FOR_ALL_WAYPOINTS(wp) { + if (bottom > wp->sign.top && + top < wp->sign.top + 12 && + right > wp->sign.left && + left < wp->sign.left + wp->sign.width_1) { + AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1); + } } - } - } else if (dpi->zoom == 1) { - right += 2; - bottom += 2; - FOR_ALL_WAYPOINTS(wp) { - if (bottom > wp->sign.top && - top < wp->sign.top + 24 && - right > wp->sign.left && - left < wp->sign.left + wp->sign.width_1*2) { - AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1); + break; + + case 1: + right += 2; + bottom += 2; + FOR_ALL_WAYPOINTS(wp) { + if (bottom > wp->sign.top && + top < wp->sign.top + 24 && + right > wp->sign.left && + left < wp->sign.left + wp->sign.width_1*2) { + AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1); + } } - } - } else { - right += 4; - bottom += 5; - - FOR_ALL_WAYPOINTS(wp) { - if (bottom > wp->sign.top && - top < wp->sign.top + 24 && - right > wp->sign.left && - left < wp->sign.left + wp->sign.width_2*4) { - AddWaypoint(wp, STR_WAYPOINT_VIEWPORT_TINY, wp->sign.width_2 | 0x8000); + break; + + default: NOT_REACHED(); + case 2: + right += 4; + bottom += 5; + FOR_ALL_WAYPOINTS(wp) { + if (bottom > wp->sign.top && + top < wp->sign.top + 24 && + right > wp->sign.left && + left < wp->sign.left + wp->sign.width_2*4) { + AddWaypoint(wp, STR_WAYPOINT_VIEWPORT_TINY, wp->sign.width_2 | 0x8000); + } } - } + break; } } |