summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Placeable.cpp71
1 files changed, 31 insertions, 40 deletions
diff --git a/src/Placeable.cpp b/src/Placeable.cpp
index 43708d3e..b4b2a37b 100644
--- a/src/Placeable.cpp
+++ b/src/Placeable.cpp
@@ -20,56 +20,47 @@ CPlaceable::SetHeading(float angle)
bool
CPlaceable::IsWithinArea(float x1, float y1, float x2, float y2)
{
- float x, xmin, xmax;
- float y, ymin, ymax;
- xmin = x1;
- xmax = x2;
- ymin = y1;
- ymax = y2;
- if(x2 > x1){
- xmin = x2;
- xmax = x1;
+ float tmp;
+
+ if(x1 > x2){
+ tmp = x1;
+ x1 = x2;
+ x2 = tmp;
}
- if(y2 > y1){
- ymin = y2;
- ymax = y1;
+ if(y1 > y2){
+ tmp = y1;
+ y1 = y2;
+ y2 = tmp;
}
- x = GetPosition().x;
- y = GetPosition().y;
- return xmin <= x && x <= xmax &&
- ymin <= y && y <= ymax;
+
+ return x1 <= GetPosition().x && GetPosition().x <= x2 &&
+ y1 <= GetPosition().y && GetPosition().y <= y2;
}
bool
CPlaceable::IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2)
{
- float x, xmin, xmax;
- float y, ymin, ymax;
- float z, zmin, zmax;
- xmin = x1;
- xmax = x2;
- ymin = y1;
- ymax = y2;
- zmin = z1;
- zmax = z2;
- if(x2 > x1){
- xmin = x2;
- xmax = x1;
+ float tmp;
+
+ if(x1 > x2){
+ tmp = x1;
+ x1 = x2;
+ x2 = tmp;
}
- if(y2 > y1){
- ymin = y2;
- ymax = y1;
+ if(y1 > y2){
+ tmp = y1;
+ y1 = y2;
+ y2 = tmp;
}
- if(z2 > z1){
- zmin = z2;
- zmax = z1;
+ if(z1 > z2){
+ tmp = z1;
+ z1 = z2;
+ z2 = tmp;
}
- x = GetPosition().x;
- y = GetPosition().y;
- z = GetPosition().z;
- return xmin <= x && x <= xmax &&
- ymin <= y && y <= ymax &&
- zmin <= z && z <= zmax;
+
+ return x1 <= GetPosition().x && GetPosition().x <= x2 &&
+ y1 <= GetPosition().y && GetPosition().y <= y2 &&
+ z1 <= GetPosition().z && GetPosition().z <= z2;
}
STARTPATCHES