]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/damage.c
Update copyright notice
[empserver] / src / lib / subs / damage.c
index 9c2fcc2801711b7e1603ef6f1ea3e6ea65a4e39f..cff7daabf7aa9e1379f64ee363ac1420eb4058db 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-2020, 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:
  *     Dave Pare, 1989
  *     Steve McClure, 1997
+ *     Markus Armbruster, 2004-2012
  */
 
 #include <config.h>
 
+#include "chance.h"
 #include "damage.h"
 #include "land.h"
 #include "misc.h"
@@ -41,7 +43,6 @@
 #include "optlist.h"
 #include "plane.h"
 #include "prototypes.h"
-#include "sect.h"
 #include "ship.h"
 
 void
@@ -162,16 +163,9 @@ nukedamage(struct nchrstr *ncp, int range, int airburst)
 int
 damage(int amt, int pct)
 {
-    int tmp;
-    int lost;
-
     if (amt <= 0)
        return 0;
-    tmp = amt * pct;
-    lost = tmp / 100;
-    if (random() % 100 < tmp % 100)
-       lost++;
-    return amt - lost;
+    return amt - roundavg(amt * (pct / 100.0));
 }
 
 /* asymptotic damage to commodities, efficiency, and sectors */