cleanup toSimpleDir: should be easier to understand this way, and hopefully fixes the valgrind warnings
svn-id: r6755
This commit is contained in:
parent
ade9c80333
commit
992b4f479f
1 changed files with 11 additions and 9 deletions
|
@ -1447,16 +1447,18 @@ int oldDirToNewDir(int dir) {
|
||||||
// Convert an angle to a simple direction.
|
// Convert an angle to a simple direction.
|
||||||
//
|
//
|
||||||
int toSimpleDir(int dirType, int dir) {
|
int toSimpleDir(int dirType, int dir) {
|
||||||
const int16 many_direction_tab[16] = {
|
if (dirType) {
|
||||||
71, 109, 251, 289, -1, -1, -1, -1,
|
const int16 directions[] = { 22, 72, 107, 157, 202, 252, 287, 337 };
|
||||||
22, 72, 107, 157, 202, 252, 287, 337
|
for (int i = 0; i < 7; i++)
|
||||||
};
|
if (dir >= directions[i] && dir <= directions[i+1])
|
||||||
int num = dirType ? 8 : 4;
|
return i;
|
||||||
const int16 *dirtab = &many_direction_tab[dirType * 8];
|
} else {
|
||||||
for (int i = 1; i < num-1; i++, dirtab++) {
|
const int16 directions[] = { 71, 109, 251, 289 };
|
||||||
if (dir >= dirtab[0] && dir <= dirtab[1])
|
for (int i = 0; i < 3; i++)
|
||||||
return i;
|
if (dir >= directions[i] && dir <= directions[i+1])
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue