]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/sona.c
Update copyright notice.
[empserver] / src / lib / commands / sona.c
index e4648b474c22d08942f768bb0b14b6ad12d86b9e..8fb692d972fe9d2b575afc698285662f7a457222 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
 
 #include <config.h>
 
-#include "misc.h"
-#include "player.h"
-#include "xy.h"
-#include "sect.h"
-#include "nsc.h"
-#include "retreat.h"
-#include "ship.h"
-#include "nat.h"
-#include "path.h"
-#include "file.h"
-#include "queue.h"
-#include "plane.h"
-#include <fcntl.h>
-#include <ctype.h>
 #include "commands.h"
+#include "map.h"
 #include "optlist.h"
+#include "path.h"
+#include "plane.h"
+#include "retreat.h"
+#include "ship.h"
 
 static int blankrow(char *);
 
@@ -191,12 +182,12 @@ sona(void)
                       prship(&targ),
                       xyas(targ.shp_x, targ.shp_y, player->cnum));
                else
-                   pr("Sonar detects %s %s @ %s\n", cname(targ.shp_own),
-                      prship(&targ),
+                   pr("Sonar detects %s %s @ %s\n",
+                      cname(targ.shp_own), prship(&targ),
                       xyas(targ.shp_x, targ.shp_y, player->cnum));
            } else
-               pr("Sonar detects %s %s @ %s\n", cname(targ.shp_own),
-                  prship(&targ),
+               pr("Sonar detects %s %s @ %s\n",
+                  cname(targ.shp_own), prship(&targ),
                   xyas(targ.shp_x, targ.shp_y, player->cnum));
 
            if (targ.shp_visib > vis[y][x]) {
@@ -248,10 +239,7 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
        pcp = ip->pcp;
        if (!(pcp->pl_flags & P_A))     /* if it isn't an ASW plane */
            continue;
-       range = (int)techfact(pp->pln_tech, (100 - pp->pln_acc) / 10);
-/*
-               for (i=0; targ = getshipp(i); i++) {
-*/
+       range = (int)techfact(pp->pln_tech, (100.0 - pp->pln_acc) / 10.0);
        for (i = 0; getship(i, &s); i++) {
            targ = &s;
            if (targ->shp_own == pp->pln_own || targ->shp_own == 0)
@@ -261,11 +249,11 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
            tmcp = &mchr[(int)targ->shp_type];
            if (!(tmcp->m_flags & M_SUB))
                continue;
-           if (roll(100) >
-               pln_identchance(pp, shp_hardtarget(targ), EF_SHIP))
+           if (roll(100) > pln_identchance(pp, shp_hardtarget(targ),
+                                           EF_SHIP))
                continue;
            pingrange = MAX(targ->shp_visib, 10) * range / 10;
-           vrange = ((float)pingrange) * ((float)pp->pln_effic / 200.0);
+           vrange = pingrange * (pp->pln_effic / 200.0);
            dist = mapdist(targ->shp_x, targ->shp_y, x, y);
            pingrange = (MAX(pingrange, 2) * targ->shp_effic);
            pingrange = roundavg(pingrange / 100.0);
@@ -289,8 +277,8 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
            if (getrel(getnatp(targ->shp_own), pp->pln_own) < FRIENDLY &&
                roll(100) > pln_identchance(pp, shp_hardtarget(targ),
                                            EF_SHIP))
-               if (roll(100) >
-                   pln_identchance(pp, shp_hardtarget(targ), EF_SHIP))
+               if (roll(100) > pln_identchance(pp, shp_hardtarget(targ),
+                                               EF_SHIP))
                    mpr(pp->pln_own, "sub #%d %s\n", targ->shp_uid,
                        xyas(targ->shp_x, targ->shp_y, pp->pln_own));
                else
@@ -298,8 +286,8 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
                        prship(targ),
                        xyas(targ->shp_x, targ->shp_y, pp->pln_own));
            else
-               mpr(pp->pln_own, "%s %s @ %s\n", cname(targ->shp_own),
-                   prship(targ),
+               mpr(pp->pln_own, "%s %s @ %s\n",
+                   cname(targ->shp_own), prship(targ),
                    xyas(targ->shp_x, targ->shp_y, pp->pln_own));
        }
     }