]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/mfir.c
Update copyright notice
[empserver] / src / lib / commands / mfir.c
index 70cd0f4abe35cf64013e11811d89a432db40d8d5..f42ce38fc4eacb4bde7acf2c844c8ebfad719cf1 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-2008, 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 "treaty.h"
-#include "nat.h"
-#include "ship.h"
-#include "land.h"
-#include "sect.h"
-#include "retreat.h"
-#include "news.h"
-#include "nsc.h"
-#include "file.h"
-#include "queue.h"
-#include <ctype.h>
-#include "optlist.h"
-#include "damage.h"
 #include "commands.h"
+#include "damage.h"
+#include "empobj.h"
+#include "optlist.h"
+#include "retreat.h"
 
 enum targ_type {
     targ_land, targ_ship, targ_sub, targ_unit, targ_bogus
@@ -64,12 +52,6 @@ struct flist {
     int victim;                        /* who I was shooting at */
 };
 
-union item_u {
-    struct shpstr ship;
-    struct sctstr sect;
-    struct lndstr land;
-};
-
 static void add_to_fired_queue(struct emp_qelem *, struct emp_qelem *);
 static int defend(struct emp_qelem *al,
                  struct emp_qelem *dl,
@@ -120,7 +102,7 @@ multifire(void)
     char *p;
     int nfiring = 0;
     int ndefending = 0;
-    union item_u item;
+    union empobj_storage item;
     struct emp_qelem fired, defended;
     double odds;
     char buf[1024];
@@ -342,8 +324,8 @@ multifire(void)
                continue;
            }
            if (fship.shp_effic < 60) {
-               pr("Ship #%d is crippled (%d%%)\n", fshipno,
-                  fship.shp_effic);
+               pr("Ship #%d is crippled (%d%%)\n",
+                  fshipno, fship.shp_effic);
                continue;
            }
            range = effrange(fship.shp_frnge, fship.shp_tech);
@@ -364,7 +346,7 @@ multifire(void)
            shots = gun;
            guneff = seagun(fship.shp_effic, shots);
            dam = (int)guneff;
-           shell -= ldround(((double)shots) / 2.0, 1);
+           shell -= ldround(shots / 2.0, 1);
            fship.shp_item[I_SHELL] = shell;
            if (opt_NOMOBCOST == 0)
                fship.shp_mobil = MAX(fship.shp_mobil - 15, -100);
@@ -414,8 +396,8 @@ multifire(void)
            dam = (int)landunitgun(fland.lnd_effic, fland.lnd_dam, gun,
                                   fland.lnd_ammo, shell);
            if (target == targ_ship) {
-               if (chance(((double)fland.lnd_acc) / 100.0))
-                   dam = ldround(((double)dam / 2.0), 1);
+               if (chance(fland.lnd_acc / 100.0))
+                   dam = ldround(dam / 2.0, 1);
            }
            use_supply(&fland);
            resupply_commod(&fland, I_SHELL);   /* Get more shells */
@@ -554,7 +536,7 @@ multifire(void)
            prb *= prb;
            if (chance(prb)) {
                pr("Wind deflects shell%s.\n", splur(shots));
-/*                     dam = (int)((double)dam / 2.0);*/
+/*                     dam = (int)(dam / 2.0);*/
                dam *= (90 - (random() % 11)) / 100.0;
                if (dam < 0)
                    dam = 0;
@@ -713,7 +695,7 @@ do_defdam(struct emp_qelem *list, double odds)
            pr("\nDefenders fire back!\n");
            first = 0;
        }
-       dam = (odds * (double)fp->defdam);
+       dam = odds * fp->defdam;
 
        if (fp->type == targ_ship) {
            vict = fp->victim;
@@ -958,8 +940,6 @@ use_ammo(struct emp_qelem *list)
     struct sctstr sect;
     int shell;
     short *item;
-    double mobcost;
-    struct mchrstr *mcp;
 
     /* use 1 shell from everyone */
     for (qp = list->q_forw; qp != list; qp = next) {
@@ -975,13 +955,8 @@ use_ammo(struct emp_qelem *list)
                    shell = 0;
                item[I_SHELL] = shell;
                putship(ship.shp_uid, &ship);
-               mcp = &mchr[(int)ship.shp_type];
-               mobcost = ship.shp_effic * 0.01 * ship.shp_speed;
-               mobcost = (480.0 / (mobcost +
-                                   techfact(ship.shp_tech, mobcost)));
                /* mob cost = 1/2 a sect's mob */
-               mobcost /= 2.0;
-               ship.shp_mobil -= mobcost;
+               ship.shp_mobil -= shp_mobcost(&ship) / 2.0;
            }
        } else if (fp->type == targ_land) {
            getsect(fp->x, fp->y, &sect);