]> git.pond.sub.org Git - empserver/blobdiff - src/lib/as/as.h
New path finder
[empserver] / src / lib / as / as.h
index 258090df91e230ca16102148fe25af81be3a39ce..c6817816ef8693bfbd62787545c6b69e8ac70b81 100644 (file)
@@ -30,8 +30,8 @@
 #ifndef AS_H
 #define AS_H
 
-#include <stdio.h>             /* for FILE */
-#include "misc.h"              /* for s_char */
+#include <stdio.h>
+#include "types.h"
 
 /*
  * Coordinate.
@@ -61,7 +61,7 @@ struct as_node {
     int flags;
     struct as_node *back;
 };
-#define        AS_TRIED        1       /* we've tried this node before */
+#define AS_TRIED       1       /* we've tried this node before */
 
 /*
  * Linked list of nodes, used internally by A* algorithm.
@@ -90,12 +90,17 @@ struct as_data {
     int maxneighbors;          /* max # of neighbors a cell can have */
     int hashsize;              /* size of internal hash table */
 
-    int (*hash) (struct as_coord);     /* hash function (coord -> int) */
-    int (*neighbor) (struct as_coord, struct as_coord *, s_char *);    /* function to find neighbors */
-    double (*lbcost) (struct as_coord, struct as_coord, s_char *);     /* function to give lower bound cost */
-    double (*realcost) (struct as_coord, struct as_coord, s_char *);   /* function to give real cost */
-    double (*seccost) (struct as_coord, struct as_coord, s_char *);    /* function to secondary cost */
-    char *userdata;            /* user's data, passed to callbacks */
+    /* hash function (coord -> int) */
+    int (*hash)(struct as_coord);
+    /* function to find neighbors */
+    int (*neighbor)(struct as_coord, struct as_coord *, void *);
+    /* function to give lower bound cost */
+    double (*lbcost)(struct as_coord, struct as_coord, void *);
+    /* function to give real cost */
+    double (*realcost)(struct as_coord, struct as_coord, void *);
+    /* function to secondary cost */
+    double (*seccost)(struct as_coord, struct as_coord, void *);
+    void *userdata;            /* user's data, passed to callbacks */
     struct as_coord from;      /* from coordinate */
     struct as_coord to;                /* to coordinate */
     struct as_path *path;      /* solution */
@@ -109,7 +114,7 @@ struct as_data {
     struct as_node **neighbor_nodes;
 };
 
-/* 
+/*
  * Added these for caching of paths as we stumble across them
  */
 
@@ -128,42 +133,42 @@ struct as_frompath {
 /*
  * Some cheezy allocation macros.
  */
-#define        AS_NEW_ARRAY(p, type, n, err) \
+#define AS_NEW_ARRAY(p, type, n, err) \
        (p) = (type *)calloc((n), sizeof(*(p))); \
        if ((p) == NULL) \
                return err; \
 
-#define        AS_NEW(p, type, err) \
+#define AS_NEW(p, type, err) \
        AS_NEW_ARRAY((p), type, 1, err);
 
-#define        AS_NEW_MALLOC(p, type, err) \
-        (p) = (type *)malloc(sizeof(type)); \
+#define AS_NEW_MALLOC(p, type, err) \
+       (p) = (type *)malloc(sizeof(type)); \
        if ((p) == NULL) \
               return err; \
 
 /* Functions that the user can call.  */
 
 extern struct as_data *as_init(int maxneighbors, int hashsize,
-                              int (*hashfunc) (struct as_coord),
-                              int (*neighborfunc) (struct as_coord,
-                                                   struct as_coord *,
-                                                   s_char *),
-                              double (*lbcostfunc) (struct as_coord,
-                                                    struct as_coord,
-                                                    s_char *),
-                              double (*realcostfunc) (struct as_coord,
-                                                      struct as_coord,
-                                                      s_char *),
-                              double (*seccostfunc) (struct as_coord,
+                              int (*hashfunc)(struct as_coord),
+                              int (*neighborfunc)(struct as_coord,
+                                                  struct as_coord *,
+                                                  void *),
+                              double (*lbcostfunc)(struct as_coord,
+                                                   struct as_coord,
+                                                   void *),
+                              double (*realcostfunc)(struct as_coord,
                                                      struct as_coord,
-                                                     s_char *),
-                              s_char *userdata);
+                                                     void *),
+                              double (*seccostfunc)(struct as_coord,
+                                                    struct as_coord,
+                                                    void *),
+                              void *userdata);
 extern int as_search(struct as_data *adp);
 extern void as_delete(struct as_data *adp);
 extern void as_reset(struct as_data *adp);
 extern void as_stats(struct as_data *adp, FILE * fp);
-extern struct as_path *as_find_cachepath(coord fx,
-                                        coord fy, coord tx, coord ty);
+extern struct as_path *as_find_cachepath(coord fx, coord fy,
+                                        coord tx, coord ty);
 
 /* Functions that are "private" to algorithm */