wi_stuff.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851
  1. // Emacs style mode select -*- C++ -*-
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // $Log:$
  18. //
  19. // DESCRIPTION:
  20. // Intermission screens.
  21. //
  22. //-----------------------------------------------------------------------------
  23. static const char
  24. rcsid[] = "$Id: wi_stuff.c,v 1.7 1997/02/03 22:45:13 b1 Exp $";
  25. #include <stdio.h>
  26. #include "z_zone.h"
  27. #include "m_random.h"
  28. #include "m_swap.h"
  29. #include "i_system.h"
  30. #include "w_wad.h"
  31. #include "g_game.h"
  32. #include "r_local.h"
  33. #include "s_sound.h"
  34. #include "doomstat.h"
  35. // Data.
  36. #include "sounds.h"
  37. // Needs access to LFB.
  38. #include "v_video.h"
  39. #include "wi_stuff.h"
  40. //
  41. // Data needed to add patches to full screen intermission pics.
  42. // Patches are statistics messages, and animations.
  43. // Loads of by-pixel layout and placement, offsets etc.
  44. //
  45. //
  46. // Different vetween registered DOOM (1994) and
  47. // Ultimate DOOM - Final edition (retail, 1995?).
  48. // This is supposedly ignored for commercial
  49. // release (aka DOOM II), which had 34 maps
  50. // in one episode. So there.
  51. #define NUMEPISODES 4
  52. #define NUMMAPS 9
  53. // in tics
  54. //U #define PAUSELEN (TICRATE*2)
  55. //U #define SCORESTEP 100
  56. //U #define ANIMPERIOD 32
  57. // pixel distance from "(YOU)" to "PLAYER N"
  58. //U #define STARDIST 10
  59. //U #define WK 1
  60. // GLOBAL LOCATIONS
  61. #define WI_TITLEY 2
  62. #define WI_SPACINGY 33
  63. // SINGPLE-PLAYER STUFF
  64. #define SP_STATSX 50
  65. #define SP_STATSY 50
  66. #define SP_TIMEX 16
  67. #define SP_TIMEY (SCREENHEIGHT-32)
  68. // NET GAME STUFF
  69. #define NG_STATSY 50
  70. #define NG_STATSX (32 + SHORT(star->width)/2 + 32*!dofrags)
  71. #define NG_SPACINGX 64
  72. // DEATHMATCH STUFF
  73. #define DM_MATRIXX 42
  74. #define DM_MATRIXY 68
  75. #define DM_SPACINGX 40
  76. #define DM_TOTALSX 269
  77. #define DM_KILLERSX 10
  78. #define DM_KILLERSY 100
  79. #define DM_VICTIMSX 5
  80. #define DM_VICTIMSY 50
  81. typedef enum
  82. {
  83. ANIM_ALWAYS,
  84. ANIM_RANDOM,
  85. ANIM_LEVEL
  86. } animenum_t;
  87. typedef struct
  88. {
  89. int x;
  90. int y;
  91. } point_t;
  92. //
  93. // Animation.
  94. // There is another anim_t used in p_spec.
  95. //
  96. typedef struct
  97. {
  98. animenum_t type;
  99. // period in tics between animations
  100. int period;
  101. // number of animation frames
  102. int nanims;
  103. // location of animation
  104. point_t loc;
  105. // ALWAYS: n/a,
  106. // RANDOM: period deviation (<256),
  107. // LEVEL: level
  108. int data1;
  109. // ALWAYS: n/a,
  110. // RANDOM: random base period,
  111. // LEVEL: n/a
  112. int data2;
  113. // actual graphics for frames of animations
  114. patch_t* p[3];
  115. // following must be initialized to zero before use!
  116. // next value of bcnt (used in conjunction with period)
  117. int nexttic;
  118. // last drawn animation frame
  119. int lastdrawn;
  120. // next frame number to animate
  121. int ctr;
  122. // used by RANDOM and LEVEL when animating
  123. int state;
  124. } anim_t;
  125. static point_t lnodes[NUMEPISODES][NUMMAPS] =
  126. {
  127. // Episode 0 World Map
  128. {
  129. { 185, 164 }, // location of level 0 (CJ)
  130. { 148, 143 }, // location of level 1 (CJ)
  131. { 69, 122 }, // location of level 2 (CJ)
  132. { 209, 102 }, // location of level 3 (CJ)
  133. { 116, 89 }, // location of level 4 (CJ)
  134. { 166, 55 }, // location of level 5 (CJ)
  135. { 71, 56 }, // location of level 6 (CJ)
  136. { 135, 29 }, // location of level 7 (CJ)
  137. { 71, 24 } // location of level 8 (CJ)
  138. },
  139. // Episode 1 World Map should go here
  140. {
  141. { 254, 25 }, // location of level 0 (CJ)
  142. { 97, 50 }, // location of level 1 (CJ)
  143. { 188, 64 }, // location of level 2 (CJ)
  144. { 128, 78 }, // location of level 3 (CJ)
  145. { 214, 92 }, // location of level 4 (CJ)
  146. { 133, 130 }, // location of level 5 (CJ)
  147. { 208, 136 }, // location of level 6 (CJ)
  148. { 148, 140 }, // location of level 7 (CJ)
  149. { 235, 158 } // location of level 8 (CJ)
  150. },
  151. // Episode 2 World Map should go here
  152. {
  153. { 156, 168 }, // location of level 0 (CJ)
  154. { 48, 154 }, // location of level 1 (CJ)
  155. { 174, 95 }, // location of level 2 (CJ)
  156. { 265, 75 }, // location of level 3 (CJ)
  157. { 130, 48 }, // location of level 4 (CJ)
  158. { 279, 23 }, // location of level 5 (CJ)
  159. { 198, 48 }, // location of level 6 (CJ)
  160. { 140, 25 }, // location of level 7 (CJ)
  161. { 281, 136 } // location of level 8 (CJ)
  162. }
  163. };
  164. //
  165. // Animation locations for episode 0 (1).
  166. // Using patches saves a lot of space,
  167. // as they replace 320x200 full screen frames.
  168. //
  169. static anim_t epsd0animinfo[] =
  170. {
  171. { ANIM_ALWAYS, TICRATE/3, 3, { 224, 104 } },
  172. { ANIM_ALWAYS, TICRATE/3, 3, { 184, 160 } },
  173. { ANIM_ALWAYS, TICRATE/3, 3, { 112, 136 } },
  174. { ANIM_ALWAYS, TICRATE/3, 3, { 72, 112 } },
  175. { ANIM_ALWAYS, TICRATE/3, 3, { 88, 96 } },
  176. { ANIM_ALWAYS, TICRATE/3, 3, { 64, 48 } },
  177. { ANIM_ALWAYS, TICRATE/3, 3, { 192, 40 } },
  178. { ANIM_ALWAYS, TICRATE/3, 3, { 136, 16 } },
  179. { ANIM_ALWAYS, TICRATE/3, 3, { 80, 16 } },
  180. { ANIM_ALWAYS, TICRATE/3, 3, { 64, 24 } }
  181. };
  182. static anim_t epsd1animinfo[] =
  183. {
  184. { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 1 },
  185. { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 2 },
  186. { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 3 },
  187. { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 4 },
  188. { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 5 },
  189. { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 6 },
  190. { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 7 },
  191. { ANIM_LEVEL, TICRATE/3, 3, { 192, 144 }, 8 },
  192. { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 8 }
  193. };
  194. static anim_t epsd2animinfo[] =
  195. {
  196. { ANIM_ALWAYS, TICRATE/3, 3, { 104, 168 } },
  197. { ANIM_ALWAYS, TICRATE/3, 3, { 40, 136 } },
  198. { ANIM_ALWAYS, TICRATE/3, 3, { 160, 96 } },
  199. { ANIM_ALWAYS, TICRATE/3, 3, { 104, 80 } },
  200. { ANIM_ALWAYS, TICRATE/3, 3, { 120, 32 } },
  201. { ANIM_ALWAYS, TICRATE/4, 3, { 40, 0 } }
  202. };
  203. static int NUMANIMS[NUMEPISODES] =
  204. {
  205. sizeof(epsd0animinfo)/sizeof(anim_t),
  206. sizeof(epsd1animinfo)/sizeof(anim_t),
  207. sizeof(epsd2animinfo)/sizeof(anim_t)
  208. };
  209. static anim_t *anims[NUMEPISODES] =
  210. {
  211. epsd0animinfo,
  212. epsd1animinfo,
  213. epsd2animinfo
  214. };
  215. //
  216. // GENERAL DATA
  217. //
  218. //
  219. // Locally used stuff.
  220. //
  221. #define FB 0
  222. // States for single-player
  223. #define SP_KILLS 0
  224. #define SP_ITEMS 2
  225. #define SP_SECRET 4
  226. #define SP_FRAGS 6
  227. #define SP_TIME 8
  228. #define SP_PAR ST_TIME
  229. #define SP_PAUSE 1
  230. // in seconds
  231. #define SHOWNEXTLOCDELAY 4
  232. //#define SHOWLASTLOCDELAY SHOWNEXTLOCDELAY
  233. // used to accelerate or skip a stage
  234. static int acceleratestage;
  235. // wbs->pnum
  236. static int me;
  237. // specifies current state
  238. static stateenum_t state;
  239. // contains information passed into intermission
  240. static wbstartstruct_t* wbs;
  241. static wbplayerstruct_t* plrs; // wbs->plyr[]
  242. // used for general timing
  243. static int cnt;
  244. // used for timing of background animation
  245. static int bcnt;
  246. // signals to refresh everything for one frame
  247. static int firstrefresh;
  248. static int cnt_kills[MAXPLAYERS];
  249. static int cnt_items[MAXPLAYERS];
  250. static int cnt_secret[MAXPLAYERS];
  251. static int cnt_time;
  252. static int cnt_par;
  253. static int cnt_pause;
  254. // # of commercial levels
  255. static int NUMCMAPS;
  256. //
  257. // GRAPHICS
  258. //
  259. // background (map of levels).
  260. static patch_t* bg;
  261. // You Are Here graphic
  262. static patch_t* yah[2];
  263. // splat
  264. static patch_t* splat;
  265. // %, : graphics
  266. static patch_t* percent;
  267. static patch_t* colon;
  268. // 0-9 graphic
  269. static patch_t* num[10];
  270. // minus sign
  271. static patch_t* wiminus;
  272. // "Finished!" graphics
  273. static patch_t* finished;
  274. // "Entering" graphic
  275. static patch_t* entering;
  276. // "secret"
  277. static patch_t* sp_secret;
  278. // "Kills", "Scrt", "Items", "Frags"
  279. static patch_t* kills;
  280. static patch_t* secret;
  281. static patch_t* items;
  282. static patch_t* frags;
  283. // Time sucks.
  284. static patch_t* time;
  285. static patch_t* par;
  286. static patch_t* sucks;
  287. // "killers", "victims"
  288. static patch_t* killers;
  289. static patch_t* victims;
  290. // "Total", your face, your dead face
  291. static patch_t* total;
  292. static patch_t* star;
  293. static patch_t* bstar;
  294. // "red P[1..MAXPLAYERS]"
  295. static patch_t* p[MAXPLAYERS];
  296. // "gray P[1..MAXPLAYERS]"
  297. static patch_t* bp[MAXPLAYERS];
  298. // Name graphics of each level (centered)
  299. static patch_t** lnames;
  300. //
  301. // CODE
  302. //
  303. // slam background
  304. // UNUSED static unsigned char *background=0;
  305. void WI_slamBackground(void)
  306. {
  307. memcpy(screens[0], screens[1], SCREENWIDTH * SCREENHEIGHT);
  308. V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT);
  309. }
  310. // The ticker is used to detect keys
  311. // because of timing issues in netgames.
  312. boolean WI_Responder(event_t* ev)
  313. {
  314. return false;
  315. }
  316. // Draws "<Levelname> Finished!"
  317. void WI_drawLF(void)
  318. {
  319. int y = WI_TITLEY;
  320. // draw <LevelName>
  321. V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->last]->width))/2,
  322. y, FB, lnames[wbs->last]);
  323. // draw "Finished!"
  324. y += (5*SHORT(lnames[wbs->last]->height))/4;
  325. V_DrawPatch((SCREENWIDTH - SHORT(finished->width))/2,
  326. y, FB, finished);
  327. }
  328. // Draws "Entering <LevelName>"
  329. void WI_drawEL(void)
  330. {
  331. int y = WI_TITLEY;
  332. // draw "Entering"
  333. V_DrawPatch((SCREENWIDTH - SHORT(entering->width))/2,
  334. y, FB, entering);
  335. // draw level
  336. y += (5*SHORT(lnames[wbs->next]->height))/4;
  337. V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->next]->width))/2,
  338. y, FB, lnames[wbs->next]);
  339. }
  340. void
  341. WI_drawOnLnode
  342. ( int n,
  343. patch_t* c[] )
  344. {
  345. int i;
  346. int left;
  347. int top;
  348. int right;
  349. int bottom;
  350. boolean fits = false;
  351. i = 0;
  352. do
  353. {
  354. left = lnodes[wbs->epsd][n].x - SHORT(c[i]->leftoffset);
  355. top = lnodes[wbs->epsd][n].y - SHORT(c[i]->topoffset);
  356. right = left + SHORT(c[i]->width);
  357. bottom = top + SHORT(c[i]->height);
  358. if (left >= 0
  359. && right < SCREENWIDTH
  360. && top >= 0
  361. && bottom < SCREENHEIGHT)
  362. {
  363. fits = true;
  364. }
  365. else
  366. {
  367. i++;
  368. }
  369. } while (!fits && i!=2);
  370. if (fits && i<2)
  371. {
  372. V_DrawPatch(lnodes[wbs->epsd][n].x, lnodes[wbs->epsd][n].y,
  373. FB, c[i]);
  374. }
  375. else
  376. {
  377. // DEBUG
  378. printf("Could not place patch on level %d", n+1);
  379. }
  380. }
  381. void WI_initAnimatedBack(void)
  382. {
  383. int i;
  384. anim_t* a;
  385. if (gamemode == commercial)
  386. return;
  387. if (wbs->epsd > 2)
  388. return;
  389. for (i=0;i<NUMANIMS[wbs->epsd];i++)
  390. {
  391. a = &anims[wbs->epsd][i];
  392. // init variables
  393. a->ctr = -1;
  394. // specify the next time to draw it
  395. if (a->type == ANIM_ALWAYS)
  396. a->nexttic = bcnt + 1 + (M_Random()%a->period);
  397. else if (a->type == ANIM_RANDOM)
  398. a->nexttic = bcnt + 1 + a->data2+(M_Random()%a->data1);
  399. else if (a->type == ANIM_LEVEL)
  400. a->nexttic = bcnt + 1;
  401. }
  402. }
  403. void WI_updateAnimatedBack(void)
  404. {
  405. int i;
  406. anim_t* a;
  407. if (gamemode == commercial)
  408. return;
  409. if (wbs->epsd > 2)
  410. return;
  411. for (i=0;i<NUMANIMS[wbs->epsd];i++)
  412. {
  413. a = &anims[wbs->epsd][i];
  414. if (bcnt == a->nexttic)
  415. {
  416. switch (a->type)
  417. {
  418. case ANIM_ALWAYS:
  419. if (++a->ctr >= a->nanims) a->ctr = 0;
  420. a->nexttic = bcnt + a->period;
  421. break;
  422. case ANIM_RANDOM:
  423. a->ctr++;
  424. if (a->ctr == a->nanims)
  425. {
  426. a->ctr = -1;
  427. a->nexttic = bcnt+a->data2+(M_Random()%a->data1);
  428. }
  429. else a->nexttic = bcnt + a->period;
  430. break;
  431. case ANIM_LEVEL:
  432. // gawd-awful hack for level anims
  433. if (!(state == StatCount && i == 7)
  434. && wbs->next == a->data1)
  435. {
  436. a->ctr++;
  437. if (a->ctr == a->nanims) a->ctr--;
  438. a->nexttic = bcnt + a->period;
  439. }
  440. break;
  441. }
  442. }
  443. }
  444. }
  445. void WI_drawAnimatedBack(void)
  446. {
  447. int i;
  448. anim_t* a;
  449. if (commercial)
  450. return;
  451. if (wbs->epsd > 2)
  452. return;
  453. for (i=0 ; i<NUMANIMS[wbs->epsd] ; i++)
  454. {
  455. a = &anims[wbs->epsd][i];
  456. if (a->ctr >= 0)
  457. V_DrawPatch(a->loc.x, a->loc.y, FB, a->p[a->ctr]);
  458. }
  459. }
  460. //
  461. // Draws a number.
  462. // If digits > 0, then use that many digits minimum,
  463. // otherwise only use as many as necessary.
  464. // Returns new x position.
  465. //
  466. int
  467. WI_drawNum
  468. ( int x,
  469. int y,
  470. int n,
  471. int digits )
  472. {
  473. int fontwidth = SHORT(num[0]->width);
  474. int neg;
  475. int temp;
  476. if (digits < 0)
  477. {
  478. if (!n)
  479. {
  480. // make variable-length zeros 1 digit long
  481. digits = 1;
  482. }
  483. else
  484. {
  485. // figure out # of digits in #
  486. digits = 0;
  487. temp = n;
  488. while (temp)
  489. {
  490. temp /= 10;
  491. digits++;
  492. }
  493. }
  494. }
  495. neg = n < 0;
  496. if (neg)
  497. n = -n;
  498. // if non-number, do not draw it
  499. if (n == 1994)
  500. return 0;
  501. // draw the new number
  502. while (digits--)
  503. {
  504. x -= fontwidth;
  505. V_DrawPatch(x, y, FB, num[ n % 10 ]);
  506. n /= 10;
  507. }
  508. // draw a minus sign if necessary
  509. if (neg)
  510. V_DrawPatch(x-=8, y, FB, wiminus);
  511. return x;
  512. }
  513. void
  514. WI_drawPercent
  515. ( int x,
  516. int y,
  517. int p )
  518. {
  519. if (p < 0)
  520. return;
  521. V_DrawPatch(x, y, FB, percent);
  522. WI_drawNum(x, y, p, -1);
  523. }
  524. //
  525. // Display level completion time and par,
  526. // or "sucks" message if overflow.
  527. //
  528. void
  529. WI_drawTime
  530. ( int x,
  531. int y,
  532. int t )
  533. {
  534. int div;
  535. int n;
  536. if (t<0)
  537. return;
  538. if (t <= 61*59)
  539. {
  540. div = 1;
  541. do
  542. {
  543. n = (t / div) % 60;
  544. x = WI_drawNum(x, y, n, 2) - SHORT(colon->width);
  545. div *= 60;
  546. // draw
  547. if (div==60 || t / div)
  548. V_DrawPatch(x, y, FB, colon);
  549. } while (t / div);
  550. }
  551. else
  552. {
  553. // "sucks"
  554. V_DrawPatch(x - SHORT(sucks->width), y, FB, sucks);
  555. }
  556. }
  557. void WI_End(void)
  558. {
  559. void WI_unloadData(void);
  560. WI_unloadData();
  561. }
  562. void WI_initNoState(void)
  563. {
  564. state = NoState;
  565. acceleratestage = 0;
  566. cnt = 10;
  567. }
  568. void WI_updateNoState(void) {
  569. WI_updateAnimatedBack();
  570. if (!--cnt)
  571. {
  572. WI_End();
  573. G_WorldDone();
  574. }
  575. }
  576. static boolean snl_pointeron = false;
  577. void WI_initShowNextLoc(void)
  578. {
  579. state = ShowNextLoc;
  580. acceleratestage = 0;
  581. cnt = SHOWNEXTLOCDELAY * TICRATE;
  582. WI_initAnimatedBack();
  583. }
  584. void WI_updateShowNextLoc(void)
  585. {
  586. WI_updateAnimatedBack();
  587. if (!--cnt || acceleratestage)
  588. WI_initNoState();
  589. else
  590. snl_pointeron = (cnt & 31) < 20;
  591. }
  592. void WI_drawShowNextLoc(void)
  593. {
  594. int i;
  595. int last;
  596. WI_slamBackground();
  597. // draw animated background
  598. WI_drawAnimatedBack();
  599. if ( gamemode != commercial)
  600. {
  601. if (wbs->epsd > 2)
  602. {
  603. WI_drawEL();
  604. return;
  605. }
  606. last = (wbs->last == 8) ? wbs->next - 1 : wbs->last;
  607. // draw a splat on taken cities.
  608. for (i=0 ; i<=last ; i++)
  609. WI_drawOnLnode(i, &splat);
  610. // splat the secret level?
  611. if (wbs->didsecret)
  612. WI_drawOnLnode(8, &splat);
  613. // draw flashing ptr
  614. if (snl_pointeron)
  615. WI_drawOnLnode(wbs->next, yah);
  616. }
  617. // draws which level you are entering..
  618. if ( (gamemode != commercial)
  619. || wbs->next != 30)
  620. WI_drawEL();
  621. }
  622. void WI_drawNoState(void)
  623. {
  624. snl_pointeron = true;
  625. WI_drawShowNextLoc();
  626. }
  627. int WI_fragSum(int playernum)
  628. {
  629. int i;
  630. int frags = 0;
  631. for (i=0 ; i<MAXPLAYERS ; i++)
  632. {
  633. if (playeringame[i]
  634. && i!=playernum)
  635. {
  636. frags += plrs[playernum].frags[i];
  637. }
  638. }
  639. // JDC hack - negative frags.
  640. frags -= plrs[playernum].frags[playernum];
  641. // UNUSED if (frags < 0)
  642. // frags = 0;
  643. return frags;
  644. }
  645. static int dm_state;
  646. static int dm_frags[MAXPLAYERS][MAXPLAYERS];
  647. static int dm_totals[MAXPLAYERS];
  648. void WI_initDeathmatchStats(void)
  649. {
  650. int i;
  651. int j;
  652. state = StatCount;
  653. acceleratestage = 0;
  654. dm_state = 1;
  655. cnt_pause = TICRATE;
  656. for (i=0 ; i<MAXPLAYERS ; i++)
  657. {
  658. if (playeringame[i])
  659. {
  660. for (j=0 ; j<MAXPLAYERS ; j++)
  661. if (playeringame[j])
  662. dm_frags[i][j] = 0;
  663. dm_totals[i] = 0;
  664. }
  665. }
  666. WI_initAnimatedBack();
  667. }
  668. void WI_updateDeathmatchStats(void)
  669. {
  670. int i;
  671. int j;
  672. boolean stillticking;
  673. WI_updateAnimatedBack();
  674. if (acceleratestage && dm_state != 4)
  675. {
  676. acceleratestage = 0;
  677. for (i=0 ; i<MAXPLAYERS ; i++)
  678. {
  679. if (playeringame[i])
  680. {
  681. for (j=0 ; j<MAXPLAYERS ; j++)
  682. if (playeringame[j])
  683. dm_frags[i][j] = plrs[i].frags[j];
  684. dm_totals[i] = WI_fragSum(i);
  685. }
  686. }
  687. S_StartSound(0, sfx_barexp);
  688. dm_state = 4;
  689. }
  690. if (dm_state == 2)
  691. {
  692. if (!(bcnt&3))
  693. S_StartSound(0, sfx_pistol);
  694. stillticking = false;
  695. for (i=0 ; i<MAXPLAYERS ; i++)
  696. {
  697. if (playeringame[i])
  698. {
  699. for (j=0 ; j<MAXPLAYERS ; j++)
  700. {
  701. if (playeringame[j]
  702. && dm_frags[i][j] != plrs[i].frags[j])
  703. {
  704. if (plrs[i].frags[j] < 0)
  705. dm_frags[i][j]--;
  706. else
  707. dm_frags[i][j]++;
  708. if (dm_frags[i][j] > 99)
  709. dm_frags[i][j] = 99;
  710. if (dm_frags[i][j] < -99)
  711. dm_frags[i][j] = -99;
  712. stillticking = true;
  713. }
  714. }
  715. dm_totals[i] = WI_fragSum(i);
  716. if (dm_totals[i] > 99)
  717. dm_totals[i] = 99;
  718. if (dm_totals[i] < -99)
  719. dm_totals[i] = -99;
  720. }
  721. }
  722. if (!stillticking)
  723. {
  724. S_StartSound(0, sfx_barexp);
  725. dm_state++;
  726. }
  727. }
  728. else if (dm_state == 4)
  729. {
  730. if (acceleratestage)
  731. {
  732. S_StartSound(0, sfx_slop);
  733. if ( gamemode == commercial)
  734. WI_initNoState();
  735. else
  736. WI_initShowNextLoc();
  737. }
  738. }
  739. else if (dm_state & 1)
  740. {
  741. if (!--cnt_pause)
  742. {
  743. dm_state++;
  744. cnt_pause = TICRATE;
  745. }
  746. }
  747. }
  748. void WI_drawDeathmatchStats(void)
  749. {
  750. int i;
  751. int j;
  752. int x;
  753. int y;
  754. int w;
  755. int lh; // line height
  756. lh = WI_SPACINGY;
  757. WI_slamBackground();
  758. // draw animated background
  759. WI_drawAnimatedBack();
  760. WI_drawLF();
  761. // draw stat titles (top line)
  762. V_DrawPatch(DM_TOTALSX-SHORT(total->width)/2,
  763. DM_MATRIXY-WI_SPACINGY+10,
  764. FB,
  765. total);
  766. V_DrawPatch(DM_KILLERSX, DM_KILLERSY, FB, killers);
  767. V_DrawPatch(DM_VICTIMSX, DM_VICTIMSY, FB, victims);
  768. // draw P?
  769. x = DM_MATRIXX + DM_SPACINGX;
  770. y = DM_MATRIXY;
  771. for (i=0 ; i<MAXPLAYERS ; i++)
  772. {
  773. if (playeringame[i])
  774. {
  775. V_DrawPatch(x-SHORT(p[i]->width)/2,
  776. DM_MATRIXY - WI_SPACINGY,
  777. FB,
  778. p[i]);
  779. V_DrawPatch(DM_MATRIXX-SHORT(p[i]->width)/2,
  780. y,
  781. FB,
  782. p[i]);
  783. if (i == me)
  784. {
  785. V_DrawPatch(x-SHORT(p[i]->width)/2,
  786. DM_MATRIXY - WI_SPACINGY,
  787. FB,
  788. bstar);
  789. V_DrawPatch(DM_MATRIXX-SHORT(p[i]->width)/2,
  790. y,
  791. FB,
  792. star);
  793. }
  794. }
  795. else
  796. {
  797. // V_DrawPatch(x-SHORT(bp[i]->width)/2,
  798. // DM_MATRIXY - WI_SPACINGY, FB, bp[i]);
  799. // V_DrawPatch(DM_MATRIXX-SHORT(bp[i]->width)/2,
  800. // y, FB, bp[i]);
  801. }
  802. x += DM_SPACINGX;
  803. y += WI_SPACINGY;
  804. }
  805. // draw stats
  806. y = DM_MATRIXY+10;
  807. w = SHORT(num[0]->width);
  808. for (i=0 ; i<MAXPLAYERS ; i++)
  809. {
  810. x = DM_MATRIXX + DM_SPACINGX;
  811. if (playeringame[i])
  812. {
  813. for (j=0 ; j<MAXPLAYERS ; j++)
  814. {
  815. if (playeringame[j])
  816. WI_drawNum(x+w, y, dm_frags[i][j], 2);
  817. x += DM_SPACINGX;
  818. }
  819. WI_drawNum(DM_TOTALSX+w, y, dm_totals[i], 2);
  820. }
  821. y += WI_SPACINGY;
  822. }
  823. }
  824. static int cnt_frags[MAXPLAYERS];
  825. static int dofrags;
  826. static int ng_state;
  827. void WI_initNetgameStats(void)
  828. {
  829. int i;
  830. state = StatCount;
  831. acceleratestage = 0;
  832. ng_state = 1;
  833. cnt_pause = TICRATE;
  834. for (i=0 ; i<MAXPLAYERS ; i++)
  835. {
  836. if (!playeringame[i])
  837. continue;
  838. cnt_kills[i] = cnt_items[i] = cnt_secret[i] = cnt_frags[i] = 0;
  839. dofrags += WI_fragSum(i);
  840. }
  841. dofrags = !!dofrags;
  842. WI_initAnimatedBack();
  843. }
  844. void WI_updateNetgameStats(void)
  845. {
  846. int i;
  847. int fsum;
  848. boolean stillticking;
  849. WI_updateAnimatedBack();
  850. if (acceleratestage && ng_state != 10)
  851. {
  852. acceleratestage = 0;
  853. for (i=0 ; i<MAXPLAYERS ; i++)
  854. {
  855. if (!playeringame[i])
  856. continue;
  857. cnt_kills[i] = (plrs[i].skills * 100) / wbs->maxkills;
  858. cnt_items[i] = (plrs[i].sitems * 100) / wbs->maxitems;
  859. cnt_secret[i] = (plrs[i].ssecret * 100) / wbs->maxsecret;
  860. if (dofrags)
  861. cnt_frags[i] = WI_fragSum(i);
  862. }
  863. S_StartSound(0, sfx_barexp);
  864. ng_state = 10;
  865. }
  866. if (ng_state == 2)
  867. {
  868. if (!(bcnt&3))
  869. S_StartSound(0, sfx_pistol);
  870. stillticking = false;
  871. for (i=0 ; i<MAXPLAYERS ; i++)
  872. {
  873. if (!playeringame[i])
  874. continue;
  875. cnt_kills[i] += 2;
  876. if (cnt_kills[i] >= (plrs[i].skills * 100) / wbs->maxkills)
  877. cnt_kills[i] = (plrs[i].skills * 100) / wbs->maxkills;
  878. else
  879. stillticking = true;
  880. }
  881. if (!stillticking)
  882. {
  883. S_StartSound(0, sfx_barexp);
  884. ng_state++;
  885. }
  886. }
  887. else if (ng_state == 4)
  888. {
  889. if (!(bcnt&3))
  890. S_StartSound(0, sfx_pistol);
  891. stillticking = false;
  892. for (i=0 ; i<MAXPLAYERS ; i++)
  893. {
  894. if (!playeringame[i])
  895. continue;
  896. cnt_items[i] += 2;
  897. if (cnt_items[i] >= (plrs[i].sitems * 100) / wbs->maxitems)
  898. cnt_items[i] = (plrs[i].sitems * 100) / wbs->maxitems;
  899. else
  900. stillticking = true;
  901. }
  902. if (!stillticking)
  903. {
  904. S_StartSound(0, sfx_barexp);
  905. ng_state++;
  906. }
  907. }
  908. else if (ng_state == 6)
  909. {
  910. if (!(bcnt&3))
  911. S_StartSound(0, sfx_pistol);
  912. stillticking = false;
  913. for (i=0 ; i<MAXPLAYERS ; i++)
  914. {
  915. if (!playeringame[i])
  916. continue;
  917. cnt_secret[i] += 2;
  918. if (cnt_secret[i] >= (plrs[i].ssecret * 100) / wbs->maxsecret)
  919. cnt_secret[i] = (plrs[i].ssecret * 100) / wbs->maxsecret;
  920. else
  921. stillticking = true;
  922. }
  923. if (!stillticking)
  924. {
  925. S_StartSound(0, sfx_barexp);
  926. ng_state += 1 + 2*!dofrags;
  927. }
  928. }
  929. else if (ng_state == 8)
  930. {
  931. if (!(bcnt&3))
  932. S_StartSound(0, sfx_pistol);
  933. stillticking = false;
  934. for (i=0 ; i<MAXPLAYERS ; i++)
  935. {
  936. if (!playeringame[i])
  937. continue;
  938. cnt_frags[i] += 1;
  939. if (cnt_frags[i] >= (fsum = WI_fragSum(i)))
  940. cnt_frags[i] = fsum;
  941. else
  942. stillticking = true;
  943. }
  944. if (!stillticking)
  945. {
  946. S_StartSound(0, sfx_pldeth);
  947. ng_state++;
  948. }
  949. }
  950. else if (ng_state == 10)
  951. {
  952. if (acceleratestage)
  953. {
  954. S_StartSound(0, sfx_sgcock);
  955. if ( gamemode == commercial )
  956. WI_initNoState();
  957. else
  958. WI_initShowNextLoc();
  959. }
  960. }
  961. else if (ng_state & 1)
  962. {
  963. if (!--cnt_pause)
  964. {
  965. ng_state++;
  966. cnt_pause = TICRATE;
  967. }
  968. }
  969. }
  970. void WI_drawNetgameStats(void)
  971. {
  972. int i;
  973. int x;
  974. int y;
  975. int pwidth = SHORT(percent->width);
  976. WI_slamBackground();
  977. // draw animated background
  978. WI_drawAnimatedBack();
  979. WI_drawLF();
  980. // draw stat titles (top line)
  981. V_DrawPatch(NG_STATSX+NG_SPACINGX-SHORT(kills->width),
  982. NG_STATSY, FB, kills);
  983. V_DrawPatch(NG_STATSX+2*NG_SPACINGX-SHORT(items->width),
  984. NG_STATSY, FB, items);
  985. V_DrawPatch(NG_STATSX+3*NG_SPACINGX-SHORT(secret->width),
  986. NG_STATSY, FB, secret);
  987. if (dofrags)
  988. V_DrawPatch(NG_STATSX+4*NG_SPACINGX-SHORT(frags->width),
  989. NG_STATSY, FB, frags);
  990. // draw stats
  991. y = NG_STATSY + SHORT(kills->height);
  992. for (i=0 ; i<MAXPLAYERS ; i++)
  993. {
  994. if (!playeringame[i])
  995. continue;
  996. x = NG_STATSX;
  997. V_DrawPatch(x-SHORT(p[i]->width), y, FB, p[i]);
  998. if (i == me)
  999. V_DrawPatch(x-SHORT(p[i]->width), y, FB, star);
  1000. x += NG_SPACINGX;
  1001. WI_drawPercent(x-pwidth, y+10, cnt_kills[i]); x += NG_SPACINGX;
  1002. WI_drawPercent(x-pwidth, y+10, cnt_items[i]); x += NG_SPACINGX;
  1003. WI_drawPercent(x-pwidth, y+10, cnt_secret[i]); x += NG_SPACINGX;
  1004. if (dofrags)
  1005. WI_drawNum(x, y+10, cnt_frags[i], -1);
  1006. y += WI_SPACINGY;
  1007. }
  1008. }
  1009. static int sp_state;
  1010. void WI_initStats(void)
  1011. {
  1012. state = StatCount;
  1013. acceleratestage = 0;
  1014. sp_state = 1;
  1015. cnt_kills[0] = cnt_items[0] = cnt_secret[0] = -1;
  1016. cnt_time = cnt_par = -1;
  1017. cnt_pause = TICRATE;
  1018. WI_initAnimatedBack();
  1019. }
  1020. void WI_updateStats(void)
  1021. {
  1022. WI_updateAnimatedBack();
  1023. if (acceleratestage && sp_state != 10)
  1024. {
  1025. acceleratestage = 0;
  1026. cnt_kills[0] = (plrs[me].skills * 100) / wbs->maxkills;
  1027. cnt_items[0] = (plrs[me].sitems * 100) / wbs->maxitems;
  1028. cnt_secret[0] = (plrs[me].ssecret * 100) / wbs->maxsecret;
  1029. cnt_time = plrs[me].stime / TICRATE;
  1030. cnt_par = wbs->partime / TICRATE;
  1031. S_StartSound(0, sfx_barexp);
  1032. sp_state = 10;
  1033. }
  1034. if (sp_state == 2)
  1035. {
  1036. cnt_kills[0] += 2;
  1037. if (!(bcnt&3))
  1038. S_StartSound(0, sfx_pistol);
  1039. if (cnt_kills[0] >= (plrs[me].skills * 100) / wbs->maxkills)
  1040. {
  1041. cnt_kills[0] = (plrs[me].skills * 100) / wbs->maxkills;
  1042. S_StartSound(0, sfx_barexp);
  1043. sp_state++;
  1044. }
  1045. }
  1046. else if (sp_state == 4)
  1047. {
  1048. cnt_items[0] += 2;
  1049. if (!(bcnt&3))
  1050. S_StartSound(0, sfx_pistol);
  1051. if (cnt_items[0] >= (plrs[me].sitems * 100) / wbs->maxitems)
  1052. {
  1053. cnt_items[0] = (plrs[me].sitems * 100) / wbs->maxitems;
  1054. S_StartSound(0, sfx_barexp);
  1055. sp_state++;
  1056. }
  1057. }
  1058. else if (sp_state == 6)
  1059. {
  1060. cnt_secret[0] += 2;
  1061. if (!(bcnt&3))
  1062. S_StartSound(0, sfx_pistol);
  1063. if (cnt_secret[0] >= (plrs[me].ssecret * 100) / wbs->maxsecret)
  1064. {
  1065. cnt_secret[0] = (plrs[me].ssecret * 100) / wbs->maxsecret;
  1066. S_StartSound(0, sfx_barexp);
  1067. sp_state++;
  1068. }
  1069. }
  1070. else if (sp_state == 8)
  1071. {
  1072. if (!(bcnt&3))
  1073. S_StartSound(0, sfx_pistol);
  1074. cnt_time += 3;
  1075. if (cnt_time >= plrs[me].stime / TICRATE)
  1076. cnt_time = plrs[me].stime / TICRATE;
  1077. cnt_par += 3;
  1078. if (cnt_par >= wbs->partime / TICRATE)
  1079. {
  1080. cnt_par = wbs->partime / TICRATE;
  1081. if (cnt_time >= plrs[me].stime / TICRATE)
  1082. {
  1083. S_StartSound(0, sfx_barexp);
  1084. sp_state++;
  1085. }
  1086. }
  1087. }
  1088. else if (sp_state == 10)
  1089. {
  1090. if (acceleratestage)
  1091. {
  1092. S_StartSound(0, sfx_sgcock);
  1093. if (gamemode == commercial)
  1094. WI_initNoState();
  1095. else
  1096. WI_initShowNextLoc();
  1097. }
  1098. }
  1099. else if (sp_state & 1)
  1100. {
  1101. if (!--cnt_pause)
  1102. {
  1103. sp_state++;
  1104. cnt_pause = TICRATE;
  1105. }
  1106. }
  1107. }
  1108. void WI_drawStats(void)
  1109. {
  1110. // line height
  1111. int lh;
  1112. lh = (3*SHORT(num[0]->height))/2;
  1113. WI_slamBackground();
  1114. // draw animated background
  1115. WI_drawAnimatedBack();
  1116. WI_drawLF();
  1117. V_DrawPatch(SP_STATSX, SP_STATSY, FB, kills);
  1118. WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY, cnt_kills[0]);
  1119. V_DrawPatch(SP_STATSX, SP_STATSY+lh, FB, items);
  1120. WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY+lh, cnt_items[0]);
  1121. V_DrawPatch(SP_STATSX, SP_STATSY+2*lh, FB, sp_secret);
  1122. WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY+2*lh, cnt_secret[0]);
  1123. V_DrawPatch(SP_TIMEX, SP_TIMEY, FB, time);
  1124. WI_drawTime(SCREENWIDTH/2 - SP_TIMEX, SP_TIMEY, cnt_time);
  1125. if (wbs->epsd < 3)
  1126. {
  1127. V_DrawPatch(SCREENWIDTH/2 + SP_TIMEX, SP_TIMEY, FB, par);
  1128. WI_drawTime(SCREENWIDTH - SP_TIMEX, SP_TIMEY, cnt_par);
  1129. }
  1130. }
  1131. void WI_checkForAccelerate(void)
  1132. {
  1133. int i;
  1134. player_t *player;
  1135. // check for button presses to skip delays
  1136. for (i=0, player = players ; i<MAXPLAYERS ; i++, player++)
  1137. {
  1138. if (playeringame[i])
  1139. {
  1140. if (player->cmd.buttons & BT_ATTACK)
  1141. {
  1142. if (!player->attackdown)
  1143. acceleratestage = 1;
  1144. player->attackdown = true;
  1145. }
  1146. else
  1147. player->attackdown = false;
  1148. if (player->cmd.buttons & BT_USE)
  1149. {
  1150. if (!player->usedown)
  1151. acceleratestage = 1;
  1152. player->usedown = true;
  1153. }
  1154. else
  1155. player->usedown = false;
  1156. }
  1157. }
  1158. }
  1159. // Updates stuff each tick
  1160. void WI_Ticker(void)
  1161. {
  1162. // counter for general background animation
  1163. bcnt++;
  1164. if (bcnt == 1)
  1165. {
  1166. // intermission music
  1167. if ( gamemode == commercial )
  1168. S_ChangeMusic(mus_dm2int, true);
  1169. else
  1170. S_ChangeMusic(mus_inter, true);
  1171. }
  1172. WI_checkForAccelerate();
  1173. switch (state)
  1174. {
  1175. case StatCount:
  1176. if (deathmatch) WI_updateDeathmatchStats();
  1177. else if (netgame) WI_updateNetgameStats();
  1178. else WI_updateStats();
  1179. break;
  1180. case ShowNextLoc:
  1181. WI_updateShowNextLoc();
  1182. break;
  1183. case NoState:
  1184. WI_updateNoState();
  1185. break;
  1186. }
  1187. }
  1188. void WI_loadData(void)
  1189. {
  1190. int i;
  1191. int j;
  1192. char name[9];
  1193. anim_t* a;
  1194. if (gamemode == commercial)
  1195. strcpy(name, "INTERPIC");
  1196. else
  1197. sprintf(name, "WIMAP%d", wbs->epsd);
  1198. if ( gamemode == retail )
  1199. {
  1200. if (wbs->epsd == 3)
  1201. strcpy(name,"INTERPIC");
  1202. }
  1203. // background
  1204. bg = W_CacheLumpName(name, PU_CACHE);
  1205. V_DrawPatch(0, 0, 1, bg);
  1206. // UNUSED unsigned char *pic = screens[1];
  1207. // if (gamemode == commercial)
  1208. // {
  1209. // darken the background image
  1210. // while (pic != screens[1] + SCREENHEIGHT*SCREENWIDTH)
  1211. // {
  1212. // *pic = colormaps[256*25 + *pic];
  1213. // pic++;
  1214. // }
  1215. //}
  1216. if (gamemode == commercial)
  1217. {
  1218. NUMCMAPS = 32;
  1219. lnames = (patch_t **) Z_Malloc(sizeof(patch_t*) * NUMCMAPS,
  1220. PU_STATIC, 0);
  1221. for (i=0 ; i<NUMCMAPS ; i++)
  1222. {
  1223. sprintf(name, "CWILV%2.2d", i);
  1224. lnames[i] = W_CacheLumpName(name, PU_STATIC);
  1225. }
  1226. }
  1227. else
  1228. {
  1229. lnames = (patch_t **) Z_Malloc(sizeof(patch_t*) * NUMMAPS,
  1230. PU_STATIC, 0);
  1231. for (i=0 ; i<NUMMAPS ; i++)
  1232. {
  1233. sprintf(name, "WILV%d%d", wbs->epsd, i);
  1234. lnames[i] = W_CacheLumpName(name, PU_STATIC);
  1235. }
  1236. // you are here
  1237. yah[0] = W_CacheLumpName("WIURH0", PU_STATIC);
  1238. // you are here (alt.)
  1239. yah[1] = W_CacheLumpName("WIURH1", PU_STATIC);
  1240. // splat
  1241. splat = W_CacheLumpName("WISPLAT", PU_STATIC);
  1242. if (wbs->epsd < 3)
  1243. {
  1244. for (j=0;j<NUMANIMS[wbs->epsd];j++)
  1245. {
  1246. a = &anims[wbs->epsd][j];
  1247. for (i=0;i<a->nanims;i++)
  1248. {
  1249. // MONDO HACK!
  1250. if (wbs->epsd != 1 || j != 8)
  1251. {
  1252. // animations
  1253. sprintf(name, "WIA%d%.2d%.2d", wbs->epsd, j, i);
  1254. a->p[i] = W_CacheLumpName(name, PU_STATIC);
  1255. }
  1256. else
  1257. {
  1258. // HACK ALERT!
  1259. a->p[i] = anims[1][4].p[i];
  1260. }
  1261. }
  1262. }
  1263. }
  1264. }
  1265. // More hacks on minus sign.
  1266. wiminus = W_CacheLumpName("WIMINUS", PU_STATIC);
  1267. for (i=0;i<10;i++)
  1268. {
  1269. // numbers 0-9
  1270. sprintf(name, "WINUM%d", i);
  1271. num[i] = W_CacheLumpName(name, PU_STATIC);
  1272. }
  1273. // percent sign
  1274. percent = W_CacheLumpName("WIPCNT", PU_STATIC);
  1275. // "finished"
  1276. finished = W_CacheLumpName("WIF", PU_STATIC);
  1277. // "entering"
  1278. entering = W_CacheLumpName("WIENTER", PU_STATIC);
  1279. // "kills"
  1280. kills = W_CacheLumpName("WIOSTK", PU_STATIC);
  1281. // "scrt"
  1282. secret = W_CacheLumpName("WIOSTS", PU_STATIC);
  1283. // "secret"
  1284. sp_secret = W_CacheLumpName("WISCRT2", PU_STATIC);
  1285. // Yuck.
  1286. if (french)
  1287. {
  1288. // "items"
  1289. if (netgame && !deathmatch)
  1290. items = W_CacheLumpName("WIOBJ", PU_STATIC);
  1291. else
  1292. items = W_CacheLumpName("WIOSTI", PU_STATIC);
  1293. } else
  1294. items = W_CacheLumpName("WIOSTI", PU_STATIC);
  1295. // "frgs"
  1296. frags = W_CacheLumpName("WIFRGS", PU_STATIC);
  1297. // ":"
  1298. colon = W_CacheLumpName("WICOLON", PU_STATIC);
  1299. // "time"
  1300. time = W_CacheLumpName("WITIME", PU_STATIC);
  1301. // "sucks"
  1302. sucks = W_CacheLumpName("WISUCKS", PU_STATIC);
  1303. // "par"
  1304. par = W_CacheLumpName("WIPAR", PU_STATIC);
  1305. // "killers" (vertical)
  1306. killers = W_CacheLumpName("WIKILRS", PU_STATIC);
  1307. // "victims" (horiz)
  1308. victims = W_CacheLumpName("WIVCTMS", PU_STATIC);
  1309. // "total"
  1310. total = W_CacheLumpName("WIMSTT", PU_STATIC);
  1311. // your face
  1312. star = W_CacheLumpName("STFST01", PU_STATIC);
  1313. // dead face
  1314. bstar = W_CacheLumpName("STFDEAD0", PU_STATIC);
  1315. for (i=0 ; i<MAXPLAYERS ; i++)
  1316. {
  1317. // "1,2,3,4"
  1318. sprintf(name, "STPB%d", i);
  1319. p[i] = W_CacheLumpName(name, PU_STATIC);
  1320. // "1,2,3,4"
  1321. sprintf(name, "WIBP%d", i+1);
  1322. bp[i] = W_CacheLumpName(name, PU_STATIC);
  1323. }
  1324. }
  1325. void WI_unloadData(void)
  1326. {
  1327. int i;
  1328. int j;
  1329. Z_ChangeTag(wiminus, PU_CACHE);
  1330. for (i=0 ; i<10 ; i++)
  1331. Z_ChangeTag(num[i], PU_CACHE);
  1332. if (gamemode == commercial)
  1333. {
  1334. for (i=0 ; i<NUMCMAPS ; i++)
  1335. Z_ChangeTag(lnames[i], PU_CACHE);
  1336. }
  1337. else
  1338. {
  1339. Z_ChangeTag(yah[0], PU_CACHE);
  1340. Z_ChangeTag(yah[1], PU_CACHE);
  1341. Z_ChangeTag(splat, PU_CACHE);
  1342. for (i=0 ; i<NUMMAPS ; i++)
  1343. Z_ChangeTag(lnames[i], PU_CACHE);
  1344. if (wbs->epsd < 3)
  1345. {
  1346. for (j=0;j<NUMANIMS[wbs->epsd];j++)
  1347. {
  1348. if (wbs->epsd != 1 || j != 8)
  1349. for (i=0;i<anims[wbs->epsd][j].nanims;i++)
  1350. Z_ChangeTag(anims[wbs->epsd][j].p[i], PU_CACHE);
  1351. }
  1352. }
  1353. }
  1354. Z_Free(lnames);
  1355. Z_ChangeTag(percent, PU_CACHE);
  1356. Z_ChangeTag(colon, PU_CACHE);
  1357. Z_ChangeTag(finished, PU_CACHE);
  1358. Z_ChangeTag(entering, PU_CACHE);
  1359. Z_ChangeTag(kills, PU_CACHE);
  1360. Z_ChangeTag(secret, PU_CACHE);
  1361. Z_ChangeTag(sp_secret, PU_CACHE);
  1362. Z_ChangeTag(items, PU_CACHE);
  1363. Z_ChangeTag(frags, PU_CACHE);
  1364. Z_ChangeTag(time, PU_CACHE);
  1365. Z_ChangeTag(sucks, PU_CACHE);
  1366. Z_ChangeTag(par, PU_CACHE);
  1367. Z_ChangeTag(victims, PU_CACHE);
  1368. Z_ChangeTag(killers, PU_CACHE);
  1369. Z_ChangeTag(total, PU_CACHE);
  1370. // Z_ChangeTag(star, PU_CACHE);
  1371. // Z_ChangeTag(bstar, PU_CACHE);
  1372. for (i=0 ; i<MAXPLAYERS ; i++)
  1373. Z_ChangeTag(p[i], PU_CACHE);
  1374. for (i=0 ; i<MAXPLAYERS ; i++)
  1375. Z_ChangeTag(bp[i], PU_CACHE);
  1376. }
  1377. void WI_Drawer (void)
  1378. {
  1379. switch (state)
  1380. {
  1381. case StatCount:
  1382. if (deathmatch)
  1383. WI_drawDeathmatchStats();
  1384. else if (netgame)
  1385. WI_drawNetgameStats();
  1386. else
  1387. WI_drawStats();
  1388. break;
  1389. case ShowNextLoc:
  1390. WI_drawShowNextLoc();
  1391. break;
  1392. case NoState:
  1393. WI_drawNoState();
  1394. break;
  1395. }
  1396. }
  1397. void WI_initVariables(wbstartstruct_t* wbstartstruct)
  1398. {
  1399. wbs = wbstartstruct;
  1400. #ifdef RANGECHECKING
  1401. if (gamemode != commercial)
  1402. {
  1403. if ( gamemode == retail )
  1404. RNGCHECK(wbs->epsd, 0, 3);
  1405. else
  1406. RNGCHECK(wbs->epsd, 0, 2);
  1407. }
  1408. else
  1409. {
  1410. RNGCHECK(wbs->last, 0, 8);
  1411. RNGCHECK(wbs->next, 0, 8);
  1412. }
  1413. RNGCHECK(wbs->pnum, 0, MAXPLAYERS);
  1414. RNGCHECK(wbs->pnum, 0, MAXPLAYERS);
  1415. #endif
  1416. acceleratestage = 0;
  1417. cnt = bcnt = 0;
  1418. firstrefresh = 1;
  1419. me = wbs->pnum;
  1420. plrs = wbs->plyr;
  1421. if (!wbs->maxkills)
  1422. wbs->maxkills = 1;
  1423. if (!wbs->maxitems)
  1424. wbs->maxitems = 1;
  1425. if (!wbs->maxsecret)
  1426. wbs->maxsecret = 1;
  1427. if ( gamemode != retail )
  1428. if (wbs->epsd > 2)
  1429. wbs->epsd -= 3;
  1430. }
  1431. void WI_Start(wbstartstruct_t* wbstartstruct)
  1432. {
  1433. WI_initVariables(wbstartstruct);
  1434. WI_loadData();
  1435. if (deathmatch)
  1436. WI_initDeathmatchStats();
  1437. else if (netgame)
  1438. WI_initNetgameStats();
  1439. else
  1440. WI_initStats();
  1441. }