]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/pathfind.c
Update copyright notice
[empserver] / src / lib / common / pathfind.c
index bde7d31bda8fcbeae69b6c3679925dbf970e80e4..33127b79397a2b81337bb14a4317bd9f09625395 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2016, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -27,7 +27,7 @@
  *  pathfind.c: Find cheapest paths
  *
  *  Known contributors to this file:
- *     Markus Armbruster, 2014
+ *     Markus Armbruster, 2014-2020
  */
 
 #include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "file.h"
 #include "nat.h"
 #include "optlist.h"
 #include "path.h"
 #include "sect.h"
 
 #ifdef PATH_FIND_DEBUG
-#define DPRINTF(fmt, ...) ((void)printf(fmt , ## __VA_ARGS__))
+#define DPRINTF(...) ((void)fprintf(stdout, ## __VA_ARGS__))
 #else
-#define DPRINTF(fmt, ...) ((void)0)
+#define DPRINTF(...) ((void)0)
 #endif
 
 static char *bufrotate(char *buf, size_t bufsz, size_t i);
@@ -58,7 +57,7 @@ static char *bufrotate(char *buf, size_t bufsz, size_t i);
  */
 
 /*
- * Array of sector data, indexed by sector uid
+ * Array of sector data, indexed by sector UID
  *
  * We need to store a few values per sector visited by the path
  * search.  An array is the stupidest data structure that could
@@ -99,8 +98,8 @@ static struct pf_map *pf_map;
  */
 
 struct pf_heap {
-    int uid;                   /* sector uid and */
-    coord x, y;                        /* coordinates, uid == XYOFFSET(x, y) */
+    int uid;                   /* sector UID and ... */
+    coord x, y;                        /* coordinates, @uid == XYOFFSET(@x, @y) */
     double cost;               /* cost from source */
 };
 
@@ -132,7 +131,7 @@ static double pf_sumcost;
 #endif /* !PATH_FIND_STATS */
 
 #ifndef NDEBUG                 /* silence "not used" warning */
-/* Is sector with uid @uid open? */
+/* Is sector with UID @uid open? */
 static int
 pf_is_open(int uid)
 {
@@ -140,7 +139,7 @@ pf_is_open(int uid)
 }
 #endif
 
-/* Is sector with uid @uid closed? */
+/* Is sector with UID @uid closed? */
 static int
 pf_is_closed(int uid)
 {
@@ -151,7 +150,7 @@ pf_is_closed(int uid)
     return pf_map[uid].visit > pf_visit;
 }
 
-/* Is sector with uid @uid unvisited? */
+/* Is sector with UID @uid unvisited? */
 static int
 pf_is_unvisited(int uid)
 {
@@ -235,7 +234,7 @@ pf_sift_up(int n)
 
 /*
  * Open the unvisited sector @x,@y.
- * @uid is sector uid, it equals XYOFFSET(@x,@y).
+ * @uid is sector UID, it equals XYOFFSET(@x,@y).
  * Cheapest path from source comes from direction @dir and has cost @cost.
  */
 static void
@@ -284,7 +283,7 @@ pf_close(void)
 /* silence "not used" warning */
 #ifdef PATH_FIND_DEBUG
 /*
- * Return cost from source to sector with uid @uid.
+ * Return cost from source to sector with UID @uid.
  * It must be visited, i.e. open or closed.
  */
 static double
@@ -328,7 +327,7 @@ y_in_dir(coord y, int dir)
 /*
  * Set the current source and cost function.
  * @sx,@sy is the source.
- * The cost to enter the sector with uid ID is @cost(@actor, ID).
+ * The cost to enter the sector with UID ID is @cost(@actor, ID).
  * Negative value means the sector can't be entered.
  */
 static void
@@ -388,11 +387,11 @@ path_find_to(coord dx, coord dy)
            ny = y_in_dir(y, DIR_FIRST + i);
            nuid = XYOFFSET(nx, ny);
            /*
-            * Cost to enter NX,NY doesn't depend on direction of
-            * entry.  This X,Y is at least as expensive as any
-            * previous one.  Therefore, cost to go to NX,NY via X,Y
-            * is at least as high as any previously found route.
-            * Skip neighbors that have a route already.
+            * Cost to enter @nx,@ny doesn't depend on direction of
+            * entry.  This @x,@y is at least as expensive as any
+            * previous one.  Therefore, cost to go to @nx,@ny via
+            * @x,@y is at least as high as any previously found
+            * route.  Skip neighbors that have a route already.
             */
            if (!pf_is_unvisited(nuid))
                continue;
@@ -566,7 +565,7 @@ static double
 cost_land(natid actor, int uid, int mobtype)
 {
     /*
-     * Non-negative cost must not depend on ACTOR, see unit_path().
+     * Non-negative cost must not depend on @actor, see unit_path().
      */
     struct sctstr *sp = (void *)empfile[EF_SECTOR].cache;