2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, 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 the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * bridgefall.c: Knock a bridge down
30 * Known contributors to this file:
49 bridgefall(struct sctstr *sp, struct emp_qelem *list)
54 struct sctstr bh_sect;
60 for (i = 1; i <= 6; i++) {
61 nx = sp->sct_x + diroff[i][0];
62 ny = sp->sct_y + diroff[i][1];
63 getsect(nx, ny, §);
64 if (sect.sct_type != SCT_BSPAN)
66 for (j = 1; j <= 6; j++) {
67 nnx = nx + diroff[j][0];
68 nny = ny + diroff[j][1];
69 if (nnx == sp->sct_x && nny == sp->sct_y)
71 getsect(nnx, nny, &bh_sect);
72 if (bh_sect.sct_type == SCT_BHEAD &&
73 bh_sect.sct_newtype == SCT_BHEAD)
75 if (bh_sect.sct_type == SCT_BTOWER)
77 /* With EASY_BRIDGES, it just has to be next to any
79 if (opt_EASY_BRIDGES) {
80 if (bh_sect.sct_type != SCT_WATER &&
81 bh_sect.sct_type != SCT_BSPAN)
86 knockdown(§, list);
92 /* Knock down a bridge span. Note that this does NOT write the
93 * sector out to the database, it's up to the caller to do that. */
95 knockdown(struct sctstr *sp, struct emp_qelem *list)
103 if (sp->sct_type == SCT_BTOWER)
105 "Crumble... SCREEEECH! Splash! Bridge tower falls at %s!\n",
106 xyas(sp->sct_x, sp->sct_y, sp->sct_own));
109 "Crumble... SCREEEECH! Splash! Bridge falls at %s!\n",
110 xyas(sp->sct_x, sp->sct_y, sp->sct_own));
111 sp->sct_type = SCT_WATER;
112 sp->sct_newtype = SCT_WATER;
113 makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
119 /* Sink all the units */
120 snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
121 while (nxtitem(&ni, (s_char *)&land)) {
122 if (land.lnd_own == 0)
124 if (land.lnd_x != sp->sct_x || land.lnd_y != sp->sct_y)
126 if (land.lnd_ship >= 0)
128 np = getnatp(land.lnd_own);
129 if (np->nat_flags & NF_BEEP)
130 mpr(land.lnd_own, "\07");
131 mpr(land.lnd_own, " AARGH! %s tumbles to its doom!\n",
133 makelost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
137 putland(land.lnd_uid, &land);
139 /* Sink all the planes */
140 snxtitem_xy(&ni, EF_PLANE, sp->sct_x, sp->sct_y);
141 while (nxtitem(&ni, (s_char *)&plane)) {
142 if (plane.pln_own == 0)
144 if (plane.pln_x != sp->sct_x || plane.pln_y != sp->sct_y)
146 if (plane.pln_flags & PLN_LAUNCHED)
148 if (plane.pln_ship >= 0)
150 /* Is this plane flying in this list? */
151 if (ac_isflying(&plane, list))
153 np = getnatp(plane.pln_own);
154 if (np->nat_flags & NF_BEEP)
155 mpr(plane.pln_own, "\07");
156 mpr(plane.pln_own, " AARGH! %s tumbles to its doom!\n",
158 makelost(EF_PLANE, plane.pln_own, plane.pln_uid, plane.pln_x,
162 putplane(plane.pln_uid, &plane);
165 * save only the mines; zero the rest of the
168 mines = getvar(V_MINE, (caddr_t)sp, EF_SECTOR);
171 (void)putvar(V_MINE, mines, (caddr_t)sp, EF_SECTOR);