]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/sona.c
Update copyright notice
[empserver] / src / lib / commands / sona.c
index b86701344124fd68341f53a2a25c421d6b8f89a4..a6ba97b472f3598959ef1ca1ad03ec0065867abb 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2016, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
  *  Known contributors to this file:
  *     Jim Griffith, 1989
  *     Ken Stevens, 1995
+ *     Markus Armbruster, 2004-2015
  */
 
 #include <config.h>
 
+#include "chance.h"
 #include "commands.h"
 #include "map.h"
 #include "optlist.h"
@@ -160,10 +162,8 @@ sona(void)
                       "Sonar ping from %s detected by %s!\n",
                       xyas(ship.shp_x, ship.shp_y,
                            targ.shp_own), prship(&targ));
-               if (targ.shp_rflags & RET_SONARED) {
-                   retreat_ship(&targ, 's');
-                   putship(targ.shp_uid, &targ);
-               }
+               if (targ.shp_rflags & RET_SONARED)
+                   retreat_ship(&targ, targ.shp_own, 's');
            }
            if (dist > vrange)
                continue;
@@ -249,8 +249,8 @@ 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 (!pct_chance(pln_identchance(pp, shp_hardtarget(targ),
+                                           EF_SHIP)))
                continue;
            vis = shp_visib(targ);
            pingrange = MAX(vis, 10) * range / 10;
@@ -275,10 +275,10 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
                found = 1;
            }
            if (relations_with(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))
+               !pct_chance(pln_identchance(pp, shp_hardtarget(targ),
+                                           EF_SHIP)))
+               if (!pct_chance(pln_identchance(pp, shp_hardtarget(targ),
+                                               EF_SHIP)))
                    pr("sub #%d %s\n", targ->shp_uid,
                       xyas(targ->shp_x, targ->shp_y, player->cnum));
                else