2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future projects/authors will amend these files as needed.
28 * bridgefall.c: Knock a bridge down
30 * Known contributors to this file:
51 bridgefall(struct sctstr *sp, struct emp_qelem *list)
56 struct sctstr bh_sect;
62 for (i = 1; i <= 6; i++) {
63 nx = sp->sct_x + diroff[i][0];
64 ny = sp->sct_y + diroff[i][1];
65 getsect(nx, ny, §);
66 if (sect.sct_type != SCT_BSPAN)
68 for (j = 1; j <= 6; j++) {
69 nnx = nx + diroff[j][0];
70 nny = ny + diroff[j][1];
71 if (nnx == sp->sct_x && nny == sp->sct_y)
73 getsect(nnx, nny, &bh_sect);
74 if (bh_sect.sct_type == SCT_BHEAD &&
75 bh_sect.sct_newtype == SCT_BHEAD)
77 if (bh_sect.sct_type == SCT_BTOWER)
79 /* With EASY_BRIDGES, it just has to be next to any
81 if (opt_EASY_BRIDGES) {
82 if (bh_sect.sct_type != SCT_WATER &&
83 bh_sect.sct_type != SCT_BSPAN)
88 knockdown(§, list);
94 /* Knock down a bridge span. Note that this does NOT write the
95 * sector out to the database, it's up to the caller to do that. */
97 knockdown(struct sctstr *sp, struct emp_qelem *list)
106 "Crumble... SCREEEECH! Splash! Bridge%s falls at %s!\n",
107 sp->sct_type == SCT_BTOWER ? " tower" : "",
108 xyas(sp->sct_x, sp->sct_y, sp->sct_own));
109 sp->sct_type = SCT_WATER;
110 sp->sct_newtype = SCT_WATER;
111 makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
117 /* Sink all the units */
118 snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
119 while (nxtitem(&ni, &land)) {
120 if (land.lnd_own == 0)
122 if (land.lnd_ship >= 0)
124 np = getnatp(land.lnd_own);
125 if (np->nat_flags & NF_BEEP)
126 mpr(land.lnd_own, "\07");
127 mpr(land.lnd_own, " AARGH! %s tumbles to its doom!\n",
129 makelost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
133 putland(land.lnd_uid, &land);
135 /* Sink all the planes */
136 snxtitem_xy(&ni, EF_PLANE, sp->sct_x, sp->sct_y);
137 while (nxtitem(&ni, &plane)) {
138 if (plane.pln_own == 0)
140 if (plane.pln_flags & PLN_LAUNCHED)
142 if (plane.pln_ship >= 0)
144 /* Is this plane flying in this list? */
145 if (ac_isflying(&plane, list))
147 np = getnatp(plane.pln_own);
148 if (np->nat_flags & NF_BEEP)
149 mpr(plane.pln_own, "\07");
150 mpr(plane.pln_own, " AARGH! %s tumbles to its doom!\n",
152 makelost(EF_PLANE, plane.pln_own, plane.pln_uid, plane.pln_x,
156 putplane(plane.pln_uid, &plane);
158 /* Sink all the nukes */
159 snxtitem_xy(&ni, EF_NUKE, sp->sct_x, sp->sct_y);
160 while (nxtitem(&ni, &nuke)) {
161 if (nuke.nuk_own == 0)
163 if (nuke.nuk_plane >= 0)
165 np = getnatp(nuke.nuk_own);
166 if (np->nat_flags & NF_BEEP)
167 mpr(nuke.nuk_own, "\07");
168 mpr(nuke.nuk_own, " %s sinks to the bottom of the sea!\n",
170 makelost(EF_NUKE, nuke.nuk_own, nuke.nuk_uid, nuke.nuk_x,
174 putnuke(nuke.nuk_uid, &nuke);
176 memset(sp->sct_item, 0, sizeof(sp->sct_item));
177 memset(sp->sct_del, 0, sizeof(sp->sct_del));
178 memset(sp->sct_dist, 0, sizeof(sp->sct_dist));
179 sp->sct_pstage = PLG_HEALTHY;
182 sp->sct_che_target = 0;