aboutsummaryrefslogtreecommitdiff
path: root/scumm/scummvm.cpp
diff options
context:
space:
mode:
authorMax Horn2003-03-07 21:56:38 +0000
committerMax Horn2003-03-07 21:56:38 +0000
commit992b4f479f9343da9acb05ea2dfbb8d5d55bfd45 (patch)
tree3691ef76e146dfd9a5f9fad73233868a109570f6 /scumm/scummvm.cpp
parentade9c8033362d673e6dd3456186547ab9d8eea01 (diff)
downloadscummvm-rg350-992b4f479f9343da9acb05ea2dfbb8d5d55bfd45.tar.gz
scummvm-rg350-992b4f479f9343da9acb05ea2dfbb8d5d55bfd45.tar.bz2
scummvm-rg350-992b4f479f9343da9acb05ea2dfbb8d5d55bfd45.zip
cleanup toSimpleDir: should be easier to understand this way, and hopefully fixes the valgrind warnings
svn-id: r6755
Diffstat (limited to 'scumm/scummvm.cpp')
-rw-r--r--scumm/scummvm.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index 21aeadbf05..58df2f05a2 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -1447,16 +1447,18 @@ int oldDirToNewDir(int dir) {
// Convert an angle to a simple direction.
//
int toSimpleDir(int dirType, int dir) {
- const int16 many_direction_tab[16] = {
- 71, 109, 251, 289, -1, -1, -1, -1,
- 22, 72, 107, 157, 202, 252, 287, 337
- };
- int num = dirType ? 8 : 4;
- const int16 *dirtab = &many_direction_tab[dirType * 8];
- for (int i = 1; i < num-1; i++, dirtab++) {
- if (dir >= dirtab[0] && dir <= dirtab[1])
- return i;
+ if (dirType) {
+ const int16 directions[] = { 22, 72, 107, 157, 202, 252, 287, 337 };
+ for (int i = 0; i < 7; i++)
+ if (dir >= directions[i] && dir <= directions[i+1])
+ return i;
+ } else {
+ const int16 directions[] = { 71, 109, 251, 289 };
+ for (int i = 0; i < 3; i++)
+ if (dir >= directions[i] && dir <= directions[i+1])
+ return i;
}
+
return 0;
}