Fixed walk_choices's type (#3353)

Fixes #3310

Replaced some still hardcoded values with their define constants.
Added a function to check if a walk will be diagonal and fixed invalid calculation for it.

Thanks to @DavidPS92
This commit is contained in:
Lemongrass3110
2018-07-30 00:24:31 +02:00
committed by GitHub
parent 4f97c749c4
commit a05ed6e814
5 changed files with 31 additions and 27 deletions

View File

@@ -56,7 +56,7 @@ static BHEAP_STRUCT_VAR(node_heap, g_open_set); // use static heap for all path
/// @}
// Translates dx,dy into walking direction
static const char walk_choices [3][3] =
static enum directions walk_choices [3][3] =
{
{DIR_NORTHWEST,DIR_NORTH,DIR_NORTHEAST},
{DIR_WEST,DIR_CENTER,DIR_EAST},
@@ -510,3 +510,7 @@ int distance_client(int dx, int dy)
return ((int)temp_dist);
}
bool direction_diagonal( enum directions direction ){
return direction == DIR_NORTHWEST || direction == DIR_SOUTHWEST || direction == DIR_SOUTHEAST || direction == DIR_NORTHEAST;
}