MCPcopy Create free account
hub / github.com/NetHack/NetHack / cmp_coord_distu

Function cmp_coord_distu

src/getpos.c:311–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309RESTORE_WARNING_FORMAT_NONLITERAL
310
311staticfn int QSORTCALLBACK
312cmp_coord_distu(const void *a, const void *b)
313{
314 const coord *c1 = a;
315 const coord *c2 = b;
316 int dx, dy, dist_1, dist_2;
317
318 dx = u.ux - c1->x;
319 dy = u.uy - c1->y;
320 dist_1 = max(abs(dx), abs(dy));
321 dx = u.ux - c2->x;
322 dy = u.uy - c2->y;
323 dist_2 = max(abs(dx), abs(dy));
324
325 if (dist_1 == dist_2)
326 return (c1->y != c2->y) ? (c1->y - c2->y) : (c1->x - c2->x);
327
328 return dist_1 - dist_2;
329}
330
331#define IS_UNEXPLORED_LOC(x,y) \
332 (isok((x), (y)) \

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected