]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/mfir.c
Remove option TREATIES
[empserver] / src / lib / commands / mfir.c
index b6c7da2f2814f57a81a6036bff83216b9853d8ac..87b308aa875564f4845a608667afb6b43c4d1dee 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -28,7 +28,7 @@
  *
  *  Known contributors to this file:
  *     Steve McClure, 2000
- *     Markus Armbruster, 2004-2011
+ *     Markus Armbruster, 2004-2014
  */
 
 #include <config.h>
@@ -80,6 +80,7 @@ multifire(void)
     struct shpstr fship;
     struct lndstr fland;
     struct sctstr fsect;
+    char *sep = "";
     struct shpstr vship;
     struct sctstr vsect;
     enum targ_type target;
@@ -145,10 +146,16 @@ multifire(void)
                   fland.lnd_uid, LAND_MINFIREEFF);
                continue;
            }
+           if (fland.lnd_item[I_GUN] == 0) {
+               pr("%s -- not enough guns\n", prland(&fland));
+               continue;
+           }
+
            if (fland.lnd_item[I_SHELL] == 0) {
                pr("%s -- not enough shells\n", prland(&fland));
                continue;
            }
+           pr("%s%s ready to fire\n", sep, prland(&fland));
            fx = fland.lnd_x;
            fy = fland.lnd_y;
        } else if (type == EF_SHIP) {
@@ -160,7 +167,8 @@ multifire(void)
                pr("Not enough mil on ship #%d\n", item.ship.shp_uid);
                continue;
            }
-           if (mchr[item.ship.shp_type].m_glim == 0) {
+           if (mchr[item.ship.shp_type].m_glim == 0
+               && !(mchr[fship.shp_type].m_flags & M_DCH)) {
                pr("Ships %d cannot fire guns!\n", item.ship.shp_uid);
                continue;
            }
@@ -176,6 +184,7 @@ multifire(void)
                pr("Ship #%d is crippled!\n", item.ship.shp_uid);
                continue;
            }
+           pr("%s%s ready to fire\n", sep, prship(&fship));
            fx = fship.shp_x;
            fy = fship.shp_y;
        } else {
@@ -204,11 +213,12 @@ multifire(void)
                   xyas(item.sect.sct_x, item.sect.sct_y, player->cnum));
                continue;
            }
-           pr("\nSector %s firing\n",
+           pr("%sSector %s ready to fire\n", sep,
               xyas(item.sect.sct_x, item.sect.sct_y, player->cnum));
            fx = fsect.sct_x;
            fy = fsect.sct_y;
        }
+       sep = "\n";
 
        ptr = getstarg(player->argp[3], "Firing at? ", buf);
        if (!ptr)
@@ -253,25 +263,12 @@ multifire(void)
        if (type == EF_SHIP) {
            if (!check_ship_ok(&fship))
                return RET_FAIL;
-           if (fship.shp_own != player->cnum) {
-               pr("Not your ship!\n");
-               continue;
-           }
            if (target == targ_sub || target == targ_ship) {
                if (fship.shp_uid == vship.shp_uid) {
                    pr("You can't fire upon yourself!\n");
                    continue;
                }
            }
-           if (fship.shp_item[I_MILIT] < 1) {
-               pr("Not enough military for firing crew.\n");
-               continue;
-           }
-           if (fship.shp_effic < 60) {
-               pr("Ship #%d is crippled (%d%%)\n",
-                  fship.shp_uid, fship.shp_effic);
-               continue;
-           }
            range = shp_fire_range(&fship);
            range2 = roundrange(range);
            pr("range is %d.00 (%.2f)\n", range2, range);
@@ -290,7 +287,7 @@ multifire(void)
                dam = shp_fire(&fship);
            }
            putship(fship.shp_uid, &fship);
-           if (dam <= 0) {
+           if (CANT_HAPPEN(dam < 0)) {
                pr("Klick!     ...\n");
                continue;
            }
@@ -301,11 +298,6 @@ multifire(void)
        } else if (type == EF_LAND) {
            if (!check_land_ok(&fland))
                return RET_FAIL;
-           if (fland.lnd_own != player->cnum) {
-               pr("Not your unit!\n");
-               continue;
-           }
-
            if (target == targ_land) {
                if (fland.lnd_x == vsect.sct_x
                    && fland.lnd_y == vsect.sct_y) {
@@ -314,15 +306,6 @@ multifire(void)
                }
            }
 
-           if (lchr[fland.lnd_type].l_dam == 0) {
-               pr("Unit %d cannot fire!\n", fland.lnd_uid);
-               continue;
-           }
-           if (fland.lnd_item[I_GUN] == 0) {
-               pr("%s -- not enough guns\n", prland(&fland));
-               continue;
-           }
-
            range = lnd_fire_range(&fland);
            range2 = roundrange(range);
            pr("range is %d.00 (%.2f)\n", range2, range);
@@ -333,7 +316,7 @@ multifire(void)
 
            dam = lnd_fire(&fland);
            putland(fland.lnd_uid, &fland);
-           if (dam < 0) {
+           if (CANT_HAPPEN(dam < 0)) {
                pr("Klick!     ...\n");
                continue;
            }
@@ -344,12 +327,6 @@ multifire(void)
        } else {
            if (!check_sect_ok(&fsect))
                return RET_FAIL;
-           if (fsect.sct_own != player->cnum ||
-               fsect.sct_type != SCT_FORTR) {
-               pr("No fortress at %s\n",
-                  xyas(fsect.sct_x, fsect.sct_y, player->cnum));
-               continue;
-           }
            if (target == targ_land) {
                if (fsect.sct_x == vsect.sct_x
                    && fsect.sct_y == vsect.sct_y) {
@@ -357,17 +334,9 @@ multifire(void)
                    continue;
                }
            }
-           if (fsect.sct_item[I_GUN] == 0) {
-               pr("Insufficient arms.\n");
-               continue;
-           }
-           if (fsect.sct_item[I_MILIT] < 5) {
-               pr("Not enough military for firing crew.\n");
-               continue;
-           }
            dam = fort_fire(&fsect);
            putsect(&fsect);
-           if (dam < 0) {
+           if (CANT_HAPPEN(dam < 0)) {
                pr("Klick!     ...\n");
                continue;
            }
@@ -398,22 +367,6 @@ multifire(void)
            }
            continue;
        }
-       switch (target) {
-       case targ_ship:
-           if (!trechk(player->cnum, vict, SEAFIR))
-               continue;
-           break;
-       case targ_sub:
-           if (!trechk(player->cnum, vict, SUBFIR))
-               continue;
-           break;
-       case targ_land:
-           if (!trechk(player->cnum, vict, LANFIR))
-               continue;
-           break;
-       default:
-           break;
-       }
 
        nfiring++;
        switch (target) {
@@ -441,7 +394,7 @@ multifire(void)
            nreport(player->cnum, N_SHP_SHELL, vict, 1);
            /* fall through */
        default:
-           if (vict) {
+           if (vict && vict != player->cnum) {
                wu(0, vict,
                   "Country #%d shelled %s in %s for %d damage.\n",
                   player->cnum, prship(&vship),
@@ -477,13 +430,13 @@ multifire(void)
                && (vship.shp_rflags & RET_DCHRGED)
                && !(vship.shp_rflags & RET_INJURED))
                retreat_ship(&vship, 'd');
+           else if (totaldefdam == 0
+                    && (vship.shp_rflags & RET_HELPLESS)
+                    && !(vship.shp_rflags & RET_INJURED))
+               retreat_ship(&vship, 'h');
            putship(vship.shp_uid, &vship);
            break;
        }
-       if (totaldefdam == 0 && target == targ_ship
-           && (vship.shp_rflags & RET_HELPLESS)
-           && !(vship.shp_rflags & RET_INJURED))
-           retreat_ship(&vship, 'h');
        switch (attgp->ef_type) {
        case EF_SECTOR:
            putsect(&fsect);