dix: use single return value in GetDirection
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
This commit is contained in:
parent
afaa178125
commit
5f8edbe47e
|
@ -516,22 +516,21 @@ DoGetDirection(int dx, int dy){
|
||||||
static int
|
static int
|
||||||
GetDirection(int dx, int dy){
|
GetDirection(int dx, int dy){
|
||||||
static int cache[DIRECTION_CACHE_SIZE][DIRECTION_CACHE_SIZE];
|
static int cache[DIRECTION_CACHE_SIZE][DIRECTION_CACHE_SIZE];
|
||||||
int i;
|
int dir;
|
||||||
if (abs(dx) <= DIRECTION_CACHE_RANGE &&
|
if (abs(dx) <= DIRECTION_CACHE_RANGE &&
|
||||||
abs(dy) <= DIRECTION_CACHE_RANGE) {
|
abs(dy) <= DIRECTION_CACHE_RANGE) {
|
||||||
/* cacheable */
|
/* cacheable */
|
||||||
i = cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy];
|
dir = cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy];
|
||||||
if(i != 0){
|
if(dir == 0) {
|
||||||
return i;
|
dir = DoGetDirection(dx, dy);
|
||||||
}else{
|
cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy] = dir;
|
||||||
i = DoGetDirection(dx, dy);
|
|
||||||
cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy] = i;
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
/* non-cacheable */
|
/* non-cacheable */
|
||||||
return DoGetDirection(dx, dy);
|
dir = DoGetDirection(dx, dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef DIRECTION_CACHE_RANGE
|
#undef DIRECTION_CACHE_RANGE
|
||||||
|
|
Loading…
Reference in New Issue