mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-08 23:19:40 +00:00
(svn r6256) if () cascades -> switch ()
This commit is contained in:
parent
22d2ca7cc6
commit
45e34d555c
55
viewport.c
55
viewport.c
@ -1471,10 +1471,10 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
|
|||||||
|
|
||||||
if (!(_display_opt & DO_SHOW_TOWN_NAMES)) return false;
|
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;
|
x = x - vp->left + vp->virtual_left;
|
||||||
y = y - vp->top + vp->virtual_top;
|
y = y - vp->top + vp->virtual_top;
|
||||||
|
|
||||||
FOR_ALL_TOWNS(t) {
|
FOR_ALL_TOWNS(t) {
|
||||||
if (y >= t->sign.top &&
|
if (y >= t->sign.top &&
|
||||||
y < t->sign.top + 12 &&
|
y < t->sign.top + 12 &&
|
||||||
@ -1484,7 +1484,9 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (vp->zoom == 1) {
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
||||||
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
||||||
FOR_ALL_TOWNS(t) {
|
FOR_ALL_TOWNS(t) {
|
||||||
@ -1496,7 +1498,9 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
||||||
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
||||||
FOR_ALL_TOWNS(t) {
|
FOR_ALL_TOWNS(t) {
|
||||||
@ -1508,21 +1512,23 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
|
static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
|
||||||
{
|
{
|
||||||
const Station *st;
|
const Station *st;
|
||||||
|
|
||||||
if (!(_display_opt & DO_SHOW_STATION_NAMES)) return false;
|
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;
|
x = x - vp->left + vp->virtual_left;
|
||||||
y = y - vp->top + vp->virtual_top;
|
y = y - vp->top + vp->virtual_top;
|
||||||
|
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
if (y >= st->sign.top &&
|
if (y >= st->sign.top &&
|
||||||
y < st->sign.top + 12 &&
|
y < st->sign.top + 12 &&
|
||||||
@ -1532,7 +1538,9 @@ static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (vp->zoom == 1) {
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
||||||
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
@ -1544,7 +1552,9 @@ static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
||||||
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
@ -1556,21 +1566,23 @@ static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
|
static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
|
||||||
{
|
{
|
||||||
const Sign *si;
|
const Sign *si;
|
||||||
|
|
||||||
if (!(_display_opt & DO_SHOW_SIGNS)) return false;
|
if (!(_display_opt & DO_SHOW_SIGNS)) return false;
|
||||||
|
|
||||||
if (vp->zoom < 1) {
|
switch (vp->zoom) {
|
||||||
|
case 0:
|
||||||
x = x - vp->left + vp->virtual_left;
|
x = x - vp->left + vp->virtual_left;
|
||||||
y = y - vp->top + vp->virtual_top;
|
y = y - vp->top + vp->virtual_top;
|
||||||
|
|
||||||
FOR_ALL_SIGNS(si) {
|
FOR_ALL_SIGNS(si) {
|
||||||
if (y >= si->sign.top &&
|
if (y >= si->sign.top &&
|
||||||
y < si->sign.top + 12 &&
|
y < si->sign.top + 12 &&
|
||||||
@ -1580,7 +1592,9 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (vp->zoom == 1) {
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
||||||
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
||||||
FOR_ALL_SIGNS(si) {
|
FOR_ALL_SIGNS(si) {
|
||||||
@ -1592,7 +1606,9 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
||||||
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
||||||
FOR_ALL_SIGNS(si) {
|
FOR_ALL_SIGNS(si) {
|
||||||
@ -1604,21 +1620,23 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
|
static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
|
||||||
{
|
{
|
||||||
const Waypoint *wp;
|
const Waypoint *wp;
|
||||||
|
|
||||||
if (!(_display_opt & DO_WAYPOINTS)) return false;
|
if (!(_display_opt & DO_WAYPOINTS)) return false;
|
||||||
|
|
||||||
if (vp->zoom < 1) {
|
switch (vp->zoom) {
|
||||||
|
case 0:
|
||||||
x = x - vp->left + vp->virtual_left;
|
x = x - vp->left + vp->virtual_left;
|
||||||
y = y - vp->top + vp->virtual_top;
|
y = y - vp->top + vp->virtual_top;
|
||||||
|
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
FOR_ALL_WAYPOINTS(wp) {
|
||||||
if (y >= wp->sign.top &&
|
if (y >= wp->sign.top &&
|
||||||
y < wp->sign.top + 12 &&
|
y < wp->sign.top + 12 &&
|
||||||
@ -1628,7 +1646,9 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (vp->zoom == 1) {
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
||||||
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
FOR_ALL_WAYPOINTS(wp) {
|
||||||
@ -1640,7 +1660,9 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
||||||
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
FOR_ALL_WAYPOINTS(wp) {
|
||||||
@ -1652,6 +1674,7 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user