aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kohaut2016-10-04 18:59:25 +0200
committerPeter Kohaut2016-10-04 18:59:25 +0200
commit5d1e1131dc48f65de2f7c00bef3989df8d0d809f (patch)
tree3e4c1a46b1c2dc846a9eeb13dc37f89ade93dc49
parent2b835eb14dd5974b89e860066140ee35243f1c9a (diff)
downloadscummvm-rg350-5d1e1131dc48f65de2f7c00bef3989df8d0d809f.tar.gz
scummvm-rg350-5d1e1131dc48f65de2f7c00bef3989df8d0d809f.tar.bz2
scummvm-rg350-5d1e1131dc48f65de2f7c00bef3989df8d0d809f.zip
BLADERUNNER: code formatting
-rw-r--r--engines/bladerunner/actor.cpp12
-rw-r--r--engines/bladerunner/actor_walk.cpp19
-rw-r--r--engines/bladerunner/obstacles.h43
-rw-r--r--engines/bladerunner/vector.h27
4 files changed, 39 insertions, 62 deletions
diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp
index d1493b9300..f6ce1c0414 100644
--- a/engines/bladerunner/actor.cpp
+++ b/engines/bladerunner/actor.cpp
@@ -985,10 +985,8 @@ bool Actor::walkFindU1(const Vector3 &startPosition, const Vector3 &targetPositi
int facing2 = facing;
int facing3 = 0;
while (true) {
- float cos = cos_1024(facing);
- float sin = sin_1024(facing);
- float rotatedX = size * sin + targetPosition.x;
- float rotatedZ = size * cos + targetPosition.z;
+ float rotatedX = size * sin_1024(facing) + targetPosition.x;
+ float rotatedZ = size * cos_1024(facing) + targetPosition.z;
if (!_walkInfo->isXYZEmpty(rotatedX, targetPosition.y, rotatedZ, _id)) {
if (_vm->_scene->_set->findWalkbox(rotatedX, rotatedZ) >= 0) {
@@ -1005,10 +1003,8 @@ bool Actor::walkFindU1(const Vector3 &startPosition, const Vector3 &targetPositi
facing3 += 20;
}
- cos = cos_1024(facing2);
- sin = sin_1024(facing2);
- rotatedX = size * sin + targetPosition.x;
- rotatedZ = size * cos + targetPosition.z;
+ rotatedX = size * sin_1024(facing2) + targetPosition.x;
+ rotatedZ = size * cos_1024(facing2) + targetPosition.z;
if (!_walkInfo->isXYZEmpty(rotatedX, targetPosition.y, rotatedZ, _id)) {
if (_vm->_scene->_set->findWalkbox(rotatedX, rotatedZ) >= 0) {
diff --git a/engines/bladerunner/actor_walk.cpp b/engines/bladerunner/actor_walk.cpp
index 717422f60d..556f7b9afa 100644
--- a/engines/bladerunner/actor_walk.cpp
+++ b/engines/bladerunner/actor_walk.cpp
@@ -177,7 +177,6 @@ bool ActorWalk::isXYZEmpty(float x, float y, float z, int actorId) {
}
int ActorWalk::findU1(int actorId, const Vector3 &to, int dist, Vector3 *out) {
- float cos, sin;
bool inWalkbox;
int facingFound = -1;
@@ -190,10 +189,8 @@ int ActorWalk::findU1(int actorId, const Vector3 &to, int dist, Vector3 *out) {
out->z = 0.0f;
for (int facing = 0; facing < 1024; facing += 128) {
- sin = sin_1024(facing);
- cos = cos_1024(facing);
- x = to.x + sin * dist;
- z = to.z + cos * dist;
+ x = to.x + sin_1024(facing) * dist;
+ z = to.z + cos_1024(facing) * dist;
float dist2 = distance(x, z, _vm->_actors[actorId]->getX(), _vm->_actors[actorId]->getZ());
if (distFound == -1.0f || distFound > dist2) {
@@ -206,19 +203,15 @@ int ActorWalk::findU1(int actorId, const Vector3 &to, int dist, Vector3 *out) {
int v24 = facingFound;
int v25 = -1024;
while (v25 < 0) {
- sin = sin_1024(v24);
- cos = cos_1024(v24);
- x = to.x + sin * dist;
- z = to.z + cos * dist;
+ x = to.x + sin_1024(v24) * dist;
+ z = to.z + cos_1024(v24) * dist;
if (!_vm->_sceneObjects->existsOnXZ(actorId, x, z, true, true) && _vm->_scene->_set->findWalkbox(x, z) >= 0) {
break;
}
- sin = sin_1024(v23);
- cos = cos_1024(v23);
- x = to.x + sin * dist;
- z = to.z + cos * dist;
+ x = to.x + sin_1024(v23) * dist;
+ z = to.z + cos_1024(v23) * dist;
if (!_vm->_sceneObjects->existsOnXZ(actorId, x, z, true, true) && _vm->_scene->_set->findWalkbox(x, z) >= 0) {
break;
diff --git a/engines/bladerunner/obstacles.h b/engines/bladerunner/obstacles.h
index 2caa3cd580..9cf3ffa8f5 100644
--- a/engines/bladerunner/obstacles.h
+++ b/engines/bladerunner/obstacles.h
@@ -1,28 +1,29 @@
/* ScummVM - Graphic Adventure Engine
-*
-* ScummVM is the legal property of its developers, whose names
-* are too numerous to list here. Please refer to the COPYRIGHT
-* file distributed with this source distribution.
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*
-*/
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
#ifndef BLADERUNNER_OBSTACLES_H
#define BLADERUNNER_OBSTACLES_H
-#include "vector.h"
+
+#include "bladerunner/vector.h"
namespace BladeRunner {
diff --git a/engines/bladerunner/vector.h b/engines/bladerunner/vector.h
index 84e4df63bb..d04070f7c5 100644
--- a/engines/bladerunner/vector.h
+++ b/engines/bladerunner/vector.h
@@ -108,26 +108,20 @@ inline Vector4 operator/(Vector4 a, Vector4 b) {
return Vector4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
}
-inline
-int angle_1024(float x1, float z1, float x2, float z2)
-{
+inline int angle_1024(float x1, float z1, float x2, float z2) {
float angle_rad = atan2(x2 - x1, z1 - z2);
int a = int(512.0 * angle_rad / M_PI);
return (a + 1024) % 1024;
}
-inline
-int angle_1024(const Vector3 &v1, const Vector3 &v2)
-{
+inline int angle_1024(const Vector3 &v1, const Vector3 &v2) {
return angle_1024(v1.x, v1.z, v2.x, v2.z);
}
-inline
-float distance(float x1, float z1, float x2, float z2)
-{
+inline float distance(float x1, float z1, float x2, float z2) {
float dx = x1 - x2;
float dz = z1 - z2;
- float d = sqrt(dx*dx + dz*dz);
+ float d = sqrt(dx * dx + dz * dz);
float int_part = (int)d;
float frac_part = d - int_part;
@@ -138,24 +132,17 @@ float distance(float x1, float z1, float x2, float z2)
return int_part + frac_part;
}
-inline
-float distance(const Vector3 &v1, const Vector3 &v2)
-{
+inline float distance(const Vector3 &v1, const Vector3 &v2) {
return distance(v1.x, v1.z, v2.x, v2.z);
}
-inline
-float cos_1024(int angle1024) {
+inline float cos_1024(int angle1024) {
return cos(angle1024 * (M_PI / 512.0f));
}
-inline
-float sin_1024(int angle1024) {
+inline float sin_1024(int angle1024) {
return sin(angle1024 * (M_PI / 512.0f));
}
-
-
-
} // End of namespace BladeRunner
#endif