annotate death.c @ 1:ff5e05767bd3 ALPHA

Empty changelog
author darius
date Sat, 06 Dec 1997 05:41:28 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
1 /* $Id: death.c,v 1.1.1.1 1997/12/06 05:41:28 darius Exp $ */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
2
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
3 /*
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
4 * death.c
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
5 */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
6 #include "copyright.h"
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
7
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
8 #include <stdio.h>
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
9 #include <signal.h>
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
10 #include <setjmp.h>
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
11 #include <sys/types.h>
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
12 #ifdef hpux
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
13 #include <time.h>
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
14 #else /* hpux */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
15 #include <sys/time.h>
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
16 #endif /* hpux */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
17 #include <string.h>
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
18 #include "Wlib.h"
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
19 #include "defs.h"
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
20 #include "struct.h"
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
21 #include "data.h"
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
22 #include "proto.h"
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
23 #include "gameconf.h"
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
24
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
25 extern jmp_buf env;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
26
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
27 static char *teamstring[4] = { /* "", */ "and the Federation",
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
28 "and the Romulan Empire", /* "", */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
29 "and the Klingon Empire", /* "", "", "", */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
30 "and the Orions"};
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
31
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
32 void
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
33 redraw_death_messages()
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
34 {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
35 char buf[256];
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
36 int len;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
37
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
38 switch (me->p_whydead) {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
39 case KNOREASON:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
40 strcpy(buf, "You were not killed");
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
41 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
42 case KQUIT:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
43 strcpy(buf, "You have self-destructed.");
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
44 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
45 case KTORP:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
46 sprintf(buf, "You were killed by a photon torpedo from %s (%c%c).",
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
47 players[me->p_whodead].p_name,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
48 teaminfo[players[me->p_whodead].p_teami].letter,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
49 shipnos[me->p_whodead]);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
50 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
51 case KPLASMA:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
52 sprintf(buf, "You were killed by a plasma torpedo from %s (%c%c)",
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
53 players[me->p_whodead].p_name,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
54 teaminfo[players[me->p_whodead].p_teami].letter,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
55 shipnos[me->p_whodead]);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
56 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
57 case KPHASER:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
58 sprintf(buf, "You were killed by a phaser shot from %s (%c%c)",
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
59 players[me->p_whodead].p_name,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
60 teaminfo[players[me->p_whodead].p_teami].letter,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
61 shipnos[me->p_whodead]);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
62 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
63 case KPLANET:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
64 sprintf(buf, "You were killed by planetary fire from %s (%c)",
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
65 planets[me->p_whodead].pl_name,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
66 teaminfo[mask_to_idx(planets[me->p_whodead].pl_owner)].letter);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
67 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
68 case KSHIP:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
69 sprintf(buf, "You were killed by an exploding ship formerly owned by %s (%c%c)",
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
70 players[me->p_whodead].p_name,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
71 teaminfo[players[me->p_whodead].p_teami].letter,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
72 shipnos[me->p_whodead]);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
73 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
74 case KDAEMON:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
75 strcpy(buf, "You were killed by a dying daemon.");
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
76 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
77 case KWINNER:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
78 if (me->p_whodead >= 0)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
79 sprintf(buf, "Galaxy has been conquered by %s (%c%c) %s",
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
80 players[me->p_whodead].p_name,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
81 teaminfo[players[me->p_whodead].p_teami].letter,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
82 shipnos[players[me->p_whodead].p_no],
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
83 teamstring[players[me->p_whodead].p_teami]);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
84 else
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
85 sprintf(buf, "Galaxy has been conquered by %s",
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
86 teamstring[-1 - me->p_whodead]);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
87 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
88 case KGHOST:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
89 sprintf(buf, "You were ghostbusted.");
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
90 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
91 case KGENOCIDE:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
92 sprintf(buf, "Your team was genocided by %s (%c%c) %s.",
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
93 players[me->p_whodead].p_name,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
94 teaminfo[players[me->p_whodead].p_teami].letter,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
95 shipnos[me->p_whodead],
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
96 teamstring[players[me->p_whodead].p_teami]);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
97 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
98 case KPROVIDENCE:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
99 sprintf(buf, "You were removed from existence by divine mercy.");
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
100 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
101 case KTOURNEND:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
102 strcpy(buf, "The tournament has ended.");
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
103 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
104 case KOVER:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
105 strcpy(buf, "The game has gone into overtime!");
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
106 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
107 case KTOURNSTART:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
108 strcpy(buf, "The tournament has begun.");
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
109 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
110 case KBADBIN:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
111 sprintf(buf, "Your netrek executable didn't verify correctly.");
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
112 W_WriteText(mapw, 50, 70, textColor, buf, strlen(buf), W_RegularFont);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
113 sprintf(buf, "(could be an old copy or illegal cyborg)");
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
114 W_WriteText(mapw, 50, 110, W_Yellow, buf, strlen(buf), W_RegularFont);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
115 *buf = 0;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
116 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
117 case KMISSILE:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
118 sprintf(buf, "You were killed by a missile from %s (%c%c).",
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
119 players[me->p_whodead].p_name,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
120 teaminfo[players[me->p_whodead].p_teami].letter,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
121 shipnos[me->p_whodead]);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
122 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
123
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
124 case KASTEROID:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
125 strcpy(buf, "You were smashed to bits by an asteroid.");
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
126 W_WriteText(mapw, 50, 70, textColor, buf, strlen(buf), W_RegularFont );
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
127 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
128
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
129 default:
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
130 sprintf(buf, "You were killed by something unknown to this game (%d).",
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
131 me->p_whydead);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
132 break;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
133 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
134 len = strlen(buf);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
135 W_WriteText(mapw, 250 - len * W_Textwidth / 2, 11 * W_Textheight, W_Yellow, buf,
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
136 len, W_RegularFont);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
137 /* First we check for promotions: */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
138 if (promoted) {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
139 if (!paradise) {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
140 sprintf(buf, "Congratulations! You have been promoted to %s",
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
141 ranks[mystats->st_rank].name);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
142 W_WriteText(mapw, 150, 23 * W_Textheight, W_Yellow, buf, strlen(buf), W_BoldFont);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
143 } else {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
144 sprintf(buf, "Congratulations! You have been promoted to %s",
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
145 ranks2[mystats->st_rank].name);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
146 W_WriteText(mapw, 150, 23 * W_Textheight, W_Yellow, buf, strlen(buf), W_BoldFont);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
147 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
148 promoted = 0;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
149 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
150 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
151
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
152 void
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
153 death()
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
154 {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
155 W_Event event;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
156
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
157 #ifdef AUTOKEY
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
158 if (autoKey)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
159 autoKeyAllOff();
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
160 #endif /* AUTOKEY */
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
161
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
162
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
163 W_ClearWindow(mapw);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
164 W_ClearWindow(iconWin);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
165 if (oldalert != PFGREEN) {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
166 if (extraBorder)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
167 W_ChangeBorder(w, gColor);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
168 W_ChangeBorder(baseWin, gColor);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
169 oldalert = PFGREEN;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
170 if(autoUnZoom>0)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
171 blk_zoom = 0;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
172 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
173 if (W_IsMapped(statwin)) {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
174 W_UnmapWindow(statwin);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
175 showStats = 1;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
176 } else {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
177 showStats = 0;
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
178 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
179 if (infomapped)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
180 destroyInfo();
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
181 W_UnmapWindow(planetw);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
182 W_UnmapWindow(planetw2);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
183 W_UnmapWindow(rankw);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
184 W_UnmapWindow(war);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
185 if (optionWin)
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
186 optiondone();
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
187
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
188 redraw_death_messages();
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
189
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
190 while (W_EventsPending()) {
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
191 W_NextEvent(&event);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
192 }
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
193 longjmp(env, 0);
ff5e05767bd3 Empty changelog
darius
parents:
diff changeset
194 }