]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/bestpath.c
COPYING duplicates information from README. Remove. Move GPL from
[empserver] / src / lib / common / bestpath.c
index 0931a04e0eb944508cbc769aa91cbb8015e69d58..38aa4ead13e90744e7aa4503a0ff67ac2d52f822 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -19,9 +19,9 @@
  *
  *  ---
  *
- *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- *  related information and legal notices. It is expected that any future
- *  projects/authors will amend these files as needed.
+ *  See files README, COPYING and CREDITS in the root of the source
+ *  tree for related information and legal notices.  It is expected
+ *  that future projects/authors will amend these files as needed.
  *
  *  ---
  *
  * information.
  */
 
-#include "gamesdef.h"
+#include <config.h>
+
 #include "misc.h"
 #include "xy.h"
-#include "var.h"
 #include "sect.h"
 #include "file.h"
 #include "nat.h"
@@ -134,13 +134,12 @@ bestownedpath(s_char *bpath,
     unsigned int routelen;
 
     if (!mapbuf)
-       mapbuf = (unsigned int *)malloc((WORLD_X * WORLD_Y) *
+       mapbuf = malloc((WORLD_X * WORLD_Y) *
                                        sizeof(unsigned int));
     if (!mapbuf)
-       return ((s_char *)0);
+       return NULL;
     if (!mapindex) {
-       mapindex =
-           (unsigned int **)malloc(WORLD_X * sizeof(unsigned int *));
+       mapindex = malloc(WORLD_X * sizeof(unsigned int *));
        if (mapindex) {
            /* Setup the map pointers */
            for (i = 0; i < WORLD_X; i++)
@@ -148,7 +147,7 @@ bestownedpath(s_char *bpath,
        }
     }
     if (!mapindex)
-       return ((s_char *)0);
+       return NULL;
 
     bpath[0] = 0;
     if (0 != (restr2 = (*terrain == 'R')))
@@ -162,15 +161,15 @@ bestownedpath(s_char *bpath,
     if (x == ex && y == ey) {
        bpath[0] = 'h';
        bpath[1] = 0;
-       return ((s_char *)bpath);
+       return bpath;
     }
 
     if (!valid(x, y) || !valid(ex, ey))
-       return ((s_char *)0);
+       return NULL;
 
     if (restr2 && (!owned_and_navigable(bigmap, x, y, terrain, own) ||
                   !owned_and_navigable(bigmap, x, y, terrain, own)))
-       return ((s_char *)0);
+       return NULL;
 
     for (i = 0; i < WORLD_X; i++)
        for (j = 0; j < WORLD_Y; j++)
@@ -188,7 +187,7 @@ bestownedpath(s_char *bpath,
        if (++routelen == MAXROUTE) {
            bpath[0] = '?';
            bpath[1] = 0;
-           return ((s_char *)bpath);
+           return bpath;
        }
        markedsectors = 0;
        for (scanx = minx; scanx <= maxx; scanx++) {
@@ -221,7 +220,7 @@ bestownedpath(s_char *bpath,
                                    tx = XNORM(tx);
                                    ty = YNORM(ty);
                                }
-                               return ((s_char *)bpath);
+                               return bpath;
                            }
                        }
                    }
@@ -235,7 +234,7 @@ bestownedpath(s_char *bpath,
     } while (markedsectors);
 
     bpath[0] = 0;
-    return ((s_char *)0);      /* no route possible    */
+    return NULL;               /* no route possible    */
 }
 
 /* return TRUE if sector is passable */
@@ -252,7 +251,7 @@ owned_and_navigable(s_char *map, int x, int y, s_char *terrain, int own)
     /* No terrain to check?  Everything is navigable! (this
        probably means we are flying) */
     if (!(*terrain))
-       return (1);
+       return 1;
 
     /* Are we checking this map? */
     if (map) {
@@ -260,14 +259,14 @@ owned_and_navigable(s_char *map, int x, int y, s_char *terrain, int own)
           since otherwise we'll never venture anywhere */
        mapspot = map[sctoff(x, y)];
        if (mapspot == ' ' || mapspot == 0)
-           return (1);
+           return 1;
 
        /* Now, is it marked with a 'x' or 'X'? If so, avoid it! */
        if (mapspot == 'x' || mapspot == 'X')
-           return (0);
+           return 0;
     } else {
        /* We don't know what it is since we have no map, so return ok! */
-       return (1);
+       return 1;
     }
 
     /* Now, check this bmap entry to see if it is one of the
@@ -286,10 +285,10 @@ owned_and_navigable(s_char *map, int x, int y, s_char *terrain, int own)
     }
     if (negate && *t) {
        /* We found it, so we say it's bad since we are negating */
-       return (0);
+       return 0;
     } else if (!negate && !*t) {
        /* We didn't find it, so we say it's bad since we aren't negating */
-       return (0);
+       return 0;
     }
 
     /* According to our bmap, this sector is ok so far. */
@@ -304,16 +303,16 @@ owned_and_navigable(s_char *map, int x, int y, s_char *terrain, int own)
            /* We can't sail through deity sectors, but we can sail
               through any ocean */
            if (rel < FRIENDLY && sect->sct_type != SCT_WATER)
-               return (0);
+               return 0;
        }
     }
     /* Ok, now, check these two sector types */
     /* check for bad harbors. */
     if (c == 'h' && sect->sct_effic < 2)
-       return (0);
+       return 0;
     /* check for bad bridges  */
     if (c == '=' && sect->sct_effic < 60)
-       return (0);
+       return 0;
     /* Woo-hoo, it's ok! */
-    return (1);
+    return 1;
 }