1
0
Fork 0

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

release/0.5
tron 2006-08-31 07:49:34 +00:00
parent 22d2ca7cc6
commit 45e34d555c
1 changed files with 159 additions and 136 deletions

View File

@ -1471,10 +1471,10 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
if (!(_display_opt & DO_SHOW_TOWN_NAMES)) return false;
if (vp->zoom < 1) {
switch (vp->zoom) {
case 0:
x = x - vp->left + vp->virtual_left;
y = y - vp->top + vp->virtual_top;
FOR_ALL_TOWNS(t) {
if (y >= t->sign.top &&
y < t->sign.top + 12 &&
@ -1484,7 +1484,9 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
return true;
}
}
} else if (vp->zoom == 1) {
break;
case 1:
x = (x - vp->left + 1) * 2 + vp->virtual_left;
y = (y - vp->top + 1) * 2 + vp->virtual_top;
FOR_ALL_TOWNS(t) {
@ -1496,7 +1498,9 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
return true;
}
}
} else {
break;
default:
x = (x - vp->left + 3) * 4 + vp->virtual_left;
y = (y - vp->top + 3) * 4 + vp->virtual_top;
FOR_ALL_TOWNS(t) {
@ -1508,21 +1512,23 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
return true;
}
}
break;
}
return false;
}
static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
{
const Station *st;
if (!(_display_opt & DO_SHOW_STATION_NAMES)) return false;
if (vp->zoom < 1) {
switch (vp->zoom) {
case 0:
x = x - vp->left + vp->virtual_left;
y = y - vp->top + vp->virtual_top;
FOR_ALL_STATIONS(st) {
if (y >= st->sign.top &&
y < st->sign.top + 12 &&
@ -1532,7 +1538,9 @@ static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
return true;
}
}
} else if (vp->zoom == 1) {
break;
case 1:
x = (x - vp->left + 1) * 2 + vp->virtual_left;
y = (y - vp->top + 1) * 2 + vp->virtual_top;
FOR_ALL_STATIONS(st) {
@ -1544,7 +1552,9 @@ static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
return true;
}
}
} else {
break;
default:
x = (x - vp->left + 3) * 4 + vp->virtual_left;
y = (y - vp->top + 3) * 4 + vp->virtual_top;
FOR_ALL_STATIONS(st) {
@ -1556,21 +1566,23 @@ static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
return true;
}
}
break;
}
return false;
}
static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
{
const Sign *si;
if (!(_display_opt & DO_SHOW_SIGNS)) return false;
if (vp->zoom < 1) {
switch (vp->zoom) {
case 0:
x = x - vp->left + vp->virtual_left;
y = y - vp->top + vp->virtual_top;
FOR_ALL_SIGNS(si) {
if (y >= si->sign.top &&
y < si->sign.top + 12 &&
@ -1580,7 +1592,9 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
return true;
}
}
} else if (vp->zoom == 1) {
break;
case 1:
x = (x - vp->left + 1) * 2 + vp->virtual_left;
y = (y - vp->top + 1) * 2 + vp->virtual_top;
FOR_ALL_SIGNS(si) {
@ -1592,7 +1606,9 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
return true;
}
}
} else {
break;
default:
x = (x - vp->left + 3) * 4 + vp->virtual_left;
y = (y - vp->top + 3) * 4 + vp->virtual_top;
FOR_ALL_SIGNS(si) {
@ -1604,21 +1620,23 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
return true;
}
}
break;
}
return false;
}
static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
{
const Waypoint *wp;
if (!(_display_opt & DO_WAYPOINTS)) return false;
if (vp->zoom < 1) {
switch (vp->zoom) {
case 0:
x = x - vp->left + vp->virtual_left;
y = y - vp->top + vp->virtual_top;
FOR_ALL_WAYPOINTS(wp) {
if (y >= wp->sign.top &&
y < wp->sign.top + 12 &&
@ -1628,7 +1646,9 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
return true;
}
}
} else if (vp->zoom == 1) {
break;
case 1:
x = (x - vp->left + 1) * 2 + vp->virtual_left;
y = (y - vp->top + 1) * 2 + vp->virtual_top;
FOR_ALL_WAYPOINTS(wp) {
@ -1640,7 +1660,9 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
return true;
}
}
} else {
break;
default:
x = (x - vp->left + 3) * 4 + vp->virtual_left;
y = (y - vp->top + 3) * 4 + vp->virtual_top;
FOR_ALL_WAYPOINTS(wp) {
@ -1652,6 +1674,7 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
return true;
}
}
break;
}
return false;