1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
|
#include <setjmp.h>
#include "config.h"
#include "copyright.h"
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include <time.h>
#include INC_SYS_TIME
#include "Wlib.h"
#include "defs.h"
#include "struct.h"
#include "data.h"
#include "packets.h"
#include "inform.h"
#include "option.h"
#include "short.h"
extern jmp_buf env;
W_Font deathFont;
#ifdef nodef
static struct itimerval udt;
#endif
static char *teamstring[9] =
{"", "and the Feds",
"and the Roms", "",
"and the Klis", "", "", "",
"and the Oris"};
void death(void)
{
W_Event event;
W_Window oldw;
oldw = w;
#ifdef AUTOKEY
if (autoKey)
autoKeyAllOff();
#endif /* AUTOKEY */
#ifdef nodef
/* Reset the signal */
SIGNAL(SIGALRM, SIG_IGN);
udt.it_interval.tv_sec = 0;
udt.it_interval.tv_usec = 0;
udt.it_value.tv_sec = 0;
udt.it_value.tv_usec = 0;
setitimer(ITIMER_REAL, &udt, 0);
SIGNAL(SIGALRM, SIG_DFL);
#endif
W_ClearWindow(w);
W_ClearWindow(iconWin);
sound_flags = PFSHIELD;
if (oldalert != PFGREEN)
{
if (extraBorder)
W_ChangeBorder(oldw, gColor);
W_ChangeBorder(baseWin, gColor);
oldalert = PFGREEN;
}
if (W_IsMapped(statwin))
{
W_UnmapWindow(statwin);
showStats = 1;
}
else
{
showStats = 0;
}
if (infomapped)
destroyInfo();
W_UnmapWindow(planetw);
W_UnmapWindow(rankw);
W_UnmapWindow(war);
if (optionWin)
optiondone();
#ifdef SOUND
if (soundWin)
sounddone();
#endif
if (promoted)
{
/* Use deathmessage as a buffer because it will be updated in a moment
* * anyway */
if (mystats->st_rank < nranks) {
sprintf(deathmessage, "Congratulations, you were promoted to %s",
ranks[mystats->st_rank].name);
} else {
sprintf(deathmessage, "Congratulations, you were promoted");
}
if (warncount > 0)
W_ClearArea(warnw, 5, 5, W_Textwidth * warncount, W_Textheight);
W_WriteText(warnw, 5, 5, W_Green, deathmessage, strlen(deathmessage),
W_BoldFont);
warncount = strlen(deathmessage);
promoted = 0;
} else {
static int first = 10;
if (first) {
first--;
sprintf(deathmessage, "Okay, you died, but that is NORMAL! Press Enter for new ship!");
if (warncount > 0)
W_ClearArea(warnw, 5, 5, W_Textwidth * warncount, W_Textheight);
W_WriteText(warnw, 5, 5, W_Green, deathmessage, strlen(deathmessage),
W_BoldFont);
warncount = strlen(deathmessage);
}
}
deathFont = W_RegularFont;
switch (me->p_whydead)
{
case KQUIT:
strcpy(deathmessage, " You QUIT!!");
break;
case KTORP:
sprintf(deathmessage,
"You were thumped by a photon torpedo from %s (%c%c).",
players[me->p_whodead].p_name,
teamlet[players[me->p_whodead].p_team],
shipnos[me->p_whodead]);
break;
case KPLASMA:
sprintf(deathmessage,
"You were SMACKed by a plasma torpedo from %s (%c%c) ",
players[me->p_whodead].p_name,
teamlet[players[me->p_whodead].p_team],
shipnos[me->p_whodead]);
break;
case KPHASER:
sprintf(deathmessage,
"You were phasered to death by %s (%c%c)",
players[me->p_whodead].p_name,
teamlet[players[me->p_whodead].p_team],
shipnos[me->p_whodead]);
break;
case KPLANET:
sprintf(deathmessage, "You were killed by planetary fire from %s (%c)",
planets[me->p_whodead].pl_name,
teamlet[planets[me->p_whodead].pl_owner]);
break;
case KSHIP:
sprintf(deathmessage, "You were killed by the explosion of %s (%c%c)",
players[me->p_whodead].p_name,
teamlet[players[me->p_whodead].p_team],
shipnos[me->p_whodead]);
break;
case KDAEMON:
strcpy(deathmessage, "You were killed by a dying daemon.");
break;
case KWINNER:
sprintf(deathmessage, "Galaxy has been conquered by %s (%c%c) %s",
players[me->p_whodead].p_name,
teamlet[players[me->p_whodead].p_team],
shipnos[players[me->p_whodead].p_no],
teamstring[players[me->p_whodead].p_team]);
deathFont = W_BoldFont;
W_GalacticBgd(GENO_PIX);
break;
case KGHOST:
strcpy(deathmessage, "You were killed by a confused daemon.");
break;
case KGENOCIDE:
sprintf(deathmessage, "You were GENOCIDED by %s (%c%c) %s. You suck!",
players[me->p_whodead].p_name,
teamlet[players[me->p_whodead].p_team],
shipnos[me->p_whodead],
teamstring[players[me->p_whodead].p_team]);
deathFont = W_BoldFont;
break;
case KPROVIDENCE:
strcpy(deathmessage, "You were nuked by GOD.");
break;
case KOVER:
strcpy(deathmessage, "The game is over!");
break;
case TOURNSTART:
strcpy(deathmessage, "The tournament game has begun!");
#if defined(SOUND) && defined(sgi)
Play_Sound(BUZZER_SOUND);
#endif
break;
case TOURNEND:
strcpy(deathmessage, "The tournament game has ended.");
break;
case KBADBIN:
strcpy(deathmessage, "Your netrek executable didn't verify correctly.");
break;
default:
strcpy(deathmessage,
"You were killed by something unknown to this game?");
break;
}
W_ClearWindow(messagew);
W_WriteText(messagew, 5, 5, W_Yellow, deathmessage, strlen(deathmessage),
deathFont);
w = oldw;
/* This is a good time to expire all the torps and phasors that we have *
* missed the TFREE and PFREE packes for. */
resetWeaponInfo();
#ifndef THREADED
while (W_EventsPending())
W_NextEvent(&event);
longjmp(env, 0);
#else
/* Threaded: when using threads, this thread has been spawned to handle *
* network I/O and so we cannot longjmp here, into another thread! Instead
* * we call W_TerminateWait which makes the main thead's W_WaitForEvent()
* * return 0 and exitthread */
W_TerminateWait();
ENDTHREAD
#endif /* Threaded */
}
void updatedeath(void)
{
if (deathFont != W_BoldFont) /* Initialise deathFont */
deathFont = W_RegularFont;
W_WriteText(messagew, 5, 5, W_Yellow, deathmessage, strlen(deathmessage),
deathFont);
}
|