(dirindex): Narrow member type to signed char to save cache.
(pathcost): Catch bad direction characters (should not happen).
This commit is contained in:
parent
6bfdc38df1
commit
a88f12017e
3 changed files with 13 additions and 6 deletions
|
@ -307,8 +307,9 @@ bp_clear_cachepath(void)
|
|||
double
|
||||
pathcost(struct sctstr *start, s_char *path, int mob_type)
|
||||
{
|
||||
register int o;
|
||||
register int cx, cy;
|
||||
unsigned i;
|
||||
int o;
|
||||
int cx, cy;
|
||||
double cost = 0.0;
|
||||
struct sctstr *sp;
|
||||
int sx, sy, offset;
|
||||
|
@ -321,7 +322,12 @@ pathcost(struct sctstr *start, s_char *path, int mob_type)
|
|||
path++;
|
||||
continue;
|
||||
}
|
||||
o = dirindex[(int)((*path) - 'a')];
|
||||
i = *path - 'a';
|
||||
if (CANT_HAPPEN(i >= sizeof(dirindex) / sizeof(*dirindex)))
|
||||
break;
|
||||
o = dirindex[i];
|
||||
if (CANT_HAPPEN(o) < 0)
|
||||
break;
|
||||
cx += diroff[o][0];
|
||||
cy += diroff[o][1];
|
||||
sx = XNORM(cx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue