fixed bug in CPlaceable

This commit is contained in:
aap 2019-06-24 20:01:15 +02:00
parent db2e2575c8
commit 0b384356f9

View File

@ -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