- Test m_pkthdr.fw_flags against DUMMYNET_MBUF_TAGGED before trying to locate
[dragonfly/netmp.git] / games / trek / abandon.c
blobfc44dbe5f196583bae816d8eaf2b147660b9bc44
1 /*
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
33 * @(#)abandon.c 8.1 (Berkeley) 5/31/93
34 * $FreeBSD: src/games/trek/abandon.c,v 1.4 1999/11/30 03:49:43 billf Exp $
35 * $DragonFly: src/games/trek/abandon.c,v 1.3 2006/09/07 21:19:44 pavalos Exp $
38 # include "trek.h"
41 ** Abandon Ship
43 ** The ship is abandoned. If your current ship is the Faire
44 ** Queene, or if your shuttlecraft is dead, you're out of
45 ** luck. You need the shuttlecraft in order for the captain
46 ** (that's you!!) to escape.
48 ** Your crew can beam to an inhabited starsystem in the
49 ** quadrant, if there is one and if the transporter is working.
50 ** If there is no inhabited starsystem, or if the transporter
51 ** is out, they are left to die in outer space.
53 ** These currently just count as regular deaths, but they
54 ** should count very heavily against you.
56 ** If there are no starbases left, you are captured by the
57 ** Klingons, who torture you mercilessly. However, if there
58 ** is at least one starbase, you are returned to the
59 ** Federation in a prisoner of war exchange. Of course, this
60 ** can't happen unless you have taken some prisoners.
62 ** Uses trace flag 40
65 void
66 abandon(__unused int unused)
68 struct quad *q;
69 int i;
70 int j;
71 struct event *e;
73 if (Ship.ship == QUEENE) {
74 printf("You may not abandon ye Faire Queene\n");
75 return;
77 if (Ship.cond != DOCKED)
79 if (damaged(SHUTTLE)) {
80 out(SHUTTLE);
81 return;
83 printf("Officers escape in shuttlecraft\n");
84 /* decide on fate of crew */
85 q = &Quad[Ship.quadx][Ship.quady];
86 if (q->qsystemname == 0 || damaged(XPORTER))
88 printf("Entire crew of %d left to die in outer space\n",
89 Ship.crew);
90 Game.deaths += Ship.crew;
92 else
94 printf("Crew beams down to planet %s\n", systemname(q));
97 /* see if you can be exchanged */
98 if (Now.bases == 0 || Game.captives < 20 * Game.skill)
99 lose(L_CAPTURED);
100 /* re-outfit new ship */
101 printf("You are hereby put in charge of an antiquated but still\n");
102 printf(" functional ship, the Fairie Queene.\n");
103 Ship.ship = QUEENE;
104 Ship.shipname = "Fairie Queene";
105 Param.energy = Ship.energy = 3000;
106 Param.torped = Ship.torped = 6;
107 Param.shield = Ship.shield = 1250;
108 Ship.shldup = 0;
109 Ship.cloaked = 0;
110 Ship.warp = 5.0;
111 Ship.warp2 = 25.0;
112 Ship.warp3 = 125.0;
113 Ship.cond = GREEN;
114 /* clear out damages on old ship */
115 for (i = 0; i < MAXEVENTS; i++)
117 e = &Event[i];
118 if (e->evcode != E_FIXDV)
119 continue;
120 unschedule(e);
122 /* get rid of some devices and redistribute probabilities */
123 i = Param.damprob[SHUTTLE] + Param.damprob[CLOAK];
124 Param.damprob[SHUTTLE] = Param.damprob[CLOAK] = 0;
125 while (i > 0)
126 for (j = 0; j < NDEV; j++)
128 if (Param.damprob[j] != 0)
130 Param.damprob[j] += 1;
131 i--;
132 if (i <= 0)
133 break;
136 /* pick a starbase to restart at */
137 i = ranf(Now.bases);
138 Ship.quadx = Now.base[i].x;
139 Ship.quady = Now.base[i].y;
140 /* setup that quadrant */
141 while (1)
143 initquad(1);
144 Sect[Ship.sectx][Ship.secty] = EMPTY;
145 for (i = 0; i < 5; i++)
147 Ship.sectx = Etc.starbase.x + ranf(3) - 1;
148 if (Ship.sectx < 0 || Ship.sectx >= NSECTS)
149 continue;
150 Ship.secty = Etc.starbase.y + ranf(3) - 1;
151 if (Ship.secty < 0 || Ship.secty >= NSECTS)
152 continue;
153 if (Sect[Ship.sectx][Ship.secty] == EMPTY)
155 Sect[Ship.sectx][Ship.secty] = QUEENE;
156 dock(0);
157 compkldist(0);
158 return;