]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/bridgefall.c
Get rid of src/lib/gen/copy.c
[empserver] / src / lib / common / bridgefall.c
index 93534fa7eb72b33a25cf6ee72e4522d8b7f099dd..c11529d1e4424064e393876ae57c27c60146b2b4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2000, 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
@@ -19,9 +19,9 @@
  *
  *  ---
  *
- *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- *  related information and legal notices. It is expected that any future
- *  projects/authors will amend these files as needed.
+ *  See files README, COPYING and CREDITS in the root of the source
+ *  tree for related information and legal notices.  It is expected
+ *  that future projects/authors will amend these files as needed.
  *
  *  ---
  *
  *     Steve McClure, 1998
  */
 
-#include "misc.h"
-#include "var.h"
-#include "sect.h"
-#include "path.h"
+#include <config.h>
+
 #include "file.h"
-#include "xy.h"
-#include "plane.h"
 #include "land.h"
-#include "nsc.h"
-#include "common.h"
-#include "subs.h"
 #include "lost.h"
+#include "misc.h"
+#include "nat.h"
+#include "nsc.h"
+#include "nuke.h"
 #include "optlist.h"
+#include "path.h"
+#include "plague.h"
+#include "plane.h"
+#include "prototypes.h"
+#include "sect.h"
+#include "xy.h"
 
 void
 bridgefall(struct sctstr *sp, struct emp_qelem *list)
 {
-    register int i;
-    register int j;
+    int i;
+    int j;
     struct sctstr sect;
     struct sctstr bh_sect;
     int nx;
@@ -96,18 +99,14 @@ knockdown(struct sctstr *sp, struct emp_qelem *list)
 {
     struct lndstr land;
     struct plnstr plane;
+    struct nukstr nuke;
     struct nstr_item ni;
-    int mines;
     struct natstr *np;
 
-    if (sp->sct_type == SCT_BTOWER)
-       mpr(sp->sct_own,
-           "Crumble... SCREEEECH!  Splash! Bridge tower falls at %s!\n",
-           xyas(sp->sct_x, sp->sct_y, sp->sct_own));
-    else
-       mpr(sp->sct_own,
-           "Crumble... SCREEEECH!  Splash! Bridge falls at %s!\n",
-           xyas(sp->sct_x, sp->sct_y, sp->sct_own));
+    mpr(sp->sct_own,
+       "Crumble... SCREEEECH!  Splash! Bridge%s falls at %s!\n",
+       sp->sct_type == SCT_BTOWER ? " tower" : "",
+       xyas(sp->sct_x, sp->sct_y, sp->sct_own));
     sp->sct_type = SCT_WATER;
     sp->sct_newtype = SCT_WATER;
     makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
@@ -118,11 +117,9 @@ knockdown(struct sctstr *sp, struct emp_qelem *list)
 
     /* Sink all the units */
     snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
-    while (nxtitem(&ni, (s_char *)&land)) {
+    while (nxtitem(&ni, &land)) {
        if (land.lnd_own == 0)
            continue;
-       if (land.lnd_x != sp->sct_x || land.lnd_y != sp->sct_y)
-           continue;
        if (land.lnd_ship >= 0)
            continue;
        np = getnatp(land.lnd_own);
@@ -130,19 +127,14 @@ knockdown(struct sctstr *sp, struct emp_qelem *list)
            mpr(land.lnd_own, "\07");
        mpr(land.lnd_own, "     AARGH! %s tumbles to its doom!\n",
            prland(&land));
-       makelost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
-                land.lnd_y);
-       land.lnd_own = 0;
        land.lnd_effic = 0;
        putland(land.lnd_uid, &land);
     }
     /* Sink all the planes */
     snxtitem_xy(&ni, EF_PLANE, sp->sct_x, sp->sct_y);
-    while (nxtitem(&ni, (s_char *)&plane)) {
+    while (nxtitem(&ni, &plane)) {
        if (plane.pln_own == 0)
            continue;
-       if (plane.pln_x != sp->sct_x || plane.pln_y != sp->sct_y)
-           continue;
        if (plane.pln_flags & PLN_LAUNCHED)
            continue;
        if (plane.pln_ship >= 0)
@@ -155,18 +147,29 @@ knockdown(struct sctstr *sp, struct emp_qelem *list)
            mpr(plane.pln_own, "\07");
        mpr(plane.pln_own, "     AARGH! %s tumbles to its doom!\n",
            prplane(&plane));
-       makelost(EF_PLANE, plane.pln_own, plane.pln_uid, plane.pln_x,
-                plane.pln_y);
-       plane.pln_own = 0;
        plane.pln_effic = 0;
        putplane(plane.pln_uid, &plane);
     }
-    /*
-     * save only the mines; zero the rest of the
-     * commodities.
-     */
-    mines = getvar(V_MINE, (caddr_t)sp, EF_SECTOR);
-    sp->sct_nv = 0;
-    if (mines > 0)
-       (void)putvar(V_MINE, mines, (caddr_t)sp, EF_SECTOR);
+    /* Sink all the nukes */
+    snxtitem_xy(&ni, EF_NUKE, sp->sct_x, sp->sct_y);
+    while (nxtitem(&ni, &nuke)) {
+       if (nuke.nuk_own == 0)
+           continue;
+       if (nuke.nuk_plane >= 0)
+           continue;
+       np = getnatp(nuke.nuk_own);
+       if (np->nat_flags & NF_BEEP)
+           mpr(nuke.nuk_own, "\07");
+       mpr(nuke.nuk_own, "     %s sinks to the bottom of the sea!\n",
+           prnuke(&nuke));
+       nuke.nuk_effic = 0;
+       putnuke(nuke.nuk_uid, &nuke);
+    }
+    memset(sp->sct_item, 0, sizeof(sp->sct_item));
+    memset(sp->sct_del, 0, sizeof(sp->sct_del));
+    memset(sp->sct_dist, 0, sizeof(sp->sct_dist));
+    sp->sct_pstage = PLG_HEALTHY;
+    sp->sct_ptime = 0;
+    sp->sct_che = 0;
+    sp->sct_che_target = 0;
 }