diff options
author | Dave Chapman <dave@dchapman.com> | 2006-03-28 15:44:01 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2006-03-28 15:44:01 +0000 |
commit | 47f4a458d636a889e955e68f896708f1276febc0 (patch) | |
tree | 99f770c02ef606f0abbdcd332ac39e69830d8007 /apps/plugins/doom/wi_stuff.c | |
parent | fff7d6157d56f233cad5c2003475e47a5ff809a7 (diff) | |
download | rockbox-47f4a458d636a889e955e68f896708f1276febc0.tar.gz rockbox-47f4a458d636a889e955e68f896708f1276febc0.zip |
Patch #2969 - Doom! Currently only working on the H300.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9312 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/doom/wi_stuff.c')
-rw-r--r-- | apps/plugins/doom/wi_stuff.c | 1989 |
1 files changed, 1989 insertions, 0 deletions
diff --git a/apps/plugins/doom/wi_stuff.c b/apps/plugins/doom/wi_stuff.c new file mode 100644 index 0000000000..3d14d088d5 --- /dev/null +++ b/apps/plugins/doom/wi_stuff.c | |||
@@ -0,0 +1,1989 @@ | |||
1 | /* Emacs style mode select -*- C++ -*- | ||
2 | *----------------------------------------------------------------------------- | ||
3 | * | ||
4 | * | ||
5 | * PrBoom a Doom port merged with LxDoom and LSDLDoom | ||
6 | * based on BOOM, a modified and improved DOOM engine | ||
7 | * Copyright (C) 1999 by | ||
8 | * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman | ||
9 | * Copyright (C) 1999-2000 by | ||
10 | * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
25 | * 02111-1307, USA. | ||
26 | * | ||
27 | * DESCRIPTION: | ||
28 | * Intermission screens. | ||
29 | * | ||
30 | *----------------------------------------------------------------------------- | ||
31 | */ | ||
32 | |||
33 | #include "doomstat.h" | ||
34 | #include "m_random.h" | ||
35 | #include "w_wad.h" | ||
36 | #include "g_game.h" | ||
37 | #include "r_main.h" | ||
38 | #include "v_video.h" | ||
39 | #include "wi_stuff.h" | ||
40 | #include "s_sound.h" | ||
41 | #include "sounds.h" | ||
42 | #include "m_swap.h" | ||
43 | #include "r_draw.h" | ||
44 | |||
45 | // | ||
46 | // Data needed to add patches to full screen intermission pics. | ||
47 | // Patches are statistics messages, and animations. | ||
48 | // Loads of by-pixel layout and placement, offsets etc. | ||
49 | // | ||
50 | |||
51 | // | ||
52 | // Different vetween registered DOOM (1994) and | ||
53 | // Ultimate DOOM - Final edition (retail, 1995?). | ||
54 | // This is supposedly ignored for commercial | ||
55 | // release (aka DOOM II), which had 34 maps | ||
56 | // in one episode. So there. | ||
57 | #define NUMEPISODES 4 | ||
58 | #define NUMMAPS 9 | ||
59 | |||
60 | |||
61 | // Not used | ||
62 | // in tics | ||
63 | //U #define PAUSELEN (TICRATE*2) | ||
64 | //U #define SCORESTEP 100 | ||
65 | //U #define ANIMPERIOD 32 | ||
66 | // pixel distance from "(YOU)" to "PLAYER N" | ||
67 | //U #define STARDIST 10 | ||
68 | //U #define WK 1 | ||
69 | |||
70 | |||
71 | // GLOBAL LOCATIONS | ||
72 | #define WI_TITLEY 2 | ||
73 | #define WI_SPACINGY 33 | ||
74 | |||
75 | // SINGLE-PLAYER STUFF | ||
76 | #define SP_STATSX 50 | ||
77 | #define SP_STATSY 50 | ||
78 | |||
79 | #define SP_TIMEX 8 | ||
80 | // proff/nicolas 09/20/98 -- changed for hi-res | ||
81 | #define SP_TIMEY 160 | ||
82 | //#define SP_TIMEY (SCREENHEIGHT-32) | ||
83 | |||
84 | |||
85 | // NET GAME STUFF | ||
86 | #define NG_STATSY 50 | ||
87 | #define NG_STATSX (32 + V_NamePatchWidth(star)/2 + 32*!dofrags) | ||
88 | |||
89 | #define NG_SPACINGX 64 | ||
90 | |||
91 | |||
92 | // Used to display the frags matrix at endgame | ||
93 | // DEATHMATCH STUFF | ||
94 | #define DM_MATRIXX 42 | ||
95 | #define DM_MATRIXY 68 | ||
96 | |||
97 | #define DM_SPACINGX 40 | ||
98 | |||
99 | #define DM_TOTALSX 269 | ||
100 | |||
101 | #define DM_KILLERSX 10 | ||
102 | #define DM_KILLERSY 100 | ||
103 | #define DM_VICTIMSX 5 | ||
104 | #define DM_VICTIMSY 50 | ||
105 | |||
106 | |||
107 | // These animation variables, structures, etc. are used for the | ||
108 | // DOOM/Ultimate DOOM intermission screen animations. This is | ||
109 | // totally different from any sprite or texture/flat animations | ||
110 | typedef enum | ||
111 | { | ||
112 | ANIM_ALWAYS, // determined by patch entry | ||
113 | ANIM_RANDOM, // occasional | ||
114 | ANIM_LEVEL // continuous | ||
115 | } animenum_t; | ||
116 | |||
117 | typedef struct | ||
118 | { | ||
119 | int x; // x/y coordinate pair structure | ||
120 | int y; | ||
121 | } point_t; | ||
122 | |||
123 | |||
124 | // | ||
125 | // Animation. | ||
126 | // There is another anim_t used in p_spec. | ||
127 | // | ||
128 | typedef struct | ||
129 | { | ||
130 | animenum_t type; | ||
131 | |||
132 | // period in tics between animations | ||
133 | int period; | ||
134 | |||
135 | // number of animation frames | ||
136 | int nanims; | ||
137 | |||
138 | // location of animation | ||
139 | point_t loc; | ||
140 | |||
141 | // ALWAYS: n/a, | ||
142 | // RANDOM: period deviation (<256), | ||
143 | // LEVEL: level | ||
144 | int data1; | ||
145 | |||
146 | // ALWAYS: n/a, | ||
147 | // RANDOM: random base period, | ||
148 | // LEVEL: n/a | ||
149 | int data2; | ||
150 | |||
151 | /* actual graphics for frames of animations | ||
152 | * cphipps - const | ||
153 | */ | ||
154 | const patch_t* p[3]; | ||
155 | |||
156 | // following must be initialized to zero before use! | ||
157 | |||
158 | // next value of bcnt (used in conjunction with period) | ||
159 | int nexttic; | ||
160 | |||
161 | // last drawn animation frame | ||
162 | int lastdrawn; | ||
163 | |||
164 | // next frame number to animate | ||
165 | int ctr; | ||
166 | |||
167 | // used by RANDOM and LEVEL when animating | ||
168 | int state; | ||
169 | } anim_t; | ||
170 | |||
171 | |||
172 | static point_t lnodes[NUMEPISODES][NUMMAPS] = | ||
173 | { | ||
174 | // Episode 0 World Map | ||
175 | { | ||
176 | { 185, 164 }, // location of level 0 (CJ) | ||
177 | { 148, 143 }, // location of level 1 (CJ) | ||
178 | { 69, 122 }, // location of level 2 (CJ) | ||
179 | { 209, 102 }, // location of level 3 (CJ) | ||
180 | { 116, 89 }, // location of level 4 (CJ) | ||
181 | { 166, 55 }, // location of level 5 (CJ) | ||
182 | { 71, 56 }, // location of level 6 (CJ) | ||
183 | { 135, 29 }, // location of level 7 (CJ) | ||
184 | { 71, 24 } // location of level 8 (CJ) | ||
185 | }, | ||
186 | |||
187 | // Episode 1 World Map should go here | ||
188 | { | ||
189 | { 254, 25 }, // location of level 0 (CJ) | ||
190 | { 97, 50 }, // location of level 1 (CJ) | ||
191 | { 188, 64 }, // location of level 2 (CJ) | ||
192 | { 128, 78 }, // location of level 3 (CJ) | ||
193 | { 214, 92 }, // location of level 4 (CJ) | ||
194 | { 133, 130 }, // location of level 5 (CJ) | ||
195 | { 208, 136 }, // location of level 6 (CJ) | ||
196 | { 148, 140 }, // location of level 7 (CJ) | ||
197 | { 235, 158 } // location of level 8 (CJ) | ||
198 | }, | ||
199 | |||
200 | // Episode 2 World Map should go here | ||
201 | { | ||
202 | { 156, 168 }, // location of level 0 (CJ) | ||
203 | { 48, 154 }, // location of level 1 (CJ) | ||
204 | { 174, 95 }, // location of level 2 (CJ) | ||
205 | { 265, 75 }, // location of level 3 (CJ) | ||
206 | { 130, 48 }, // location of level 4 (CJ) | ||
207 | { 279, 23 }, // location of level 5 (CJ) | ||
208 | { 198, 48 }, // location of level 6 (CJ) | ||
209 | { 140, 25 }, // location of level 7 (CJ) | ||
210 | { 281, 136 } // location of level 8 (CJ) | ||
211 | } | ||
212 | |||
213 | }; | ||
214 | |||
215 | |||
216 | // | ||
217 | // Animation locations for episode 0 (1). | ||
218 | // Using patches saves a lot of space, | ||
219 | // as they replace 320x200 full screen frames. | ||
220 | // | ||
221 | static anim_t epsd0animinfo[] = | ||
222 | { | ||
223 | { ANIM_ALWAYS, TICRATE/3, 3, { 224, 104 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
224 | { ANIM_ALWAYS, TICRATE/3, 3, { 184, 160 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
225 | { ANIM_ALWAYS, TICRATE/3, 3, { 112, 136 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
226 | { ANIM_ALWAYS, TICRATE/3, 3, { 72, 112 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
227 | { ANIM_ALWAYS, TICRATE/3, 3, { 88, 96 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
228 | { ANIM_ALWAYS, TICRATE/3, 3, { 64, 48 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
229 | { ANIM_ALWAYS, TICRATE/3, 3, { 192, 40 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
230 | { ANIM_ALWAYS, TICRATE/3, 3, { 136, 16 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
231 | { ANIM_ALWAYS, TICRATE/3, 3, { 80, 16 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
232 | { ANIM_ALWAYS, TICRATE/3, 3, { 64, 24 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 } | ||
233 | }; | ||
234 | |||
235 | static anim_t epsd1animinfo[] = | ||
236 | { | ||
237 | { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 1, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
238 | { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 2, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
239 | { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 3, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
240 | { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 4, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
241 | { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 5, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
242 | { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 6, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
243 | { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 7, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
244 | { ANIM_LEVEL, TICRATE/3, 3, { 192, 144 }, 8, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
245 | { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 8, 0, { 0, 0, 0 }, 0, 0, 0, 0 } | ||
246 | }; | ||
247 | |||
248 | static anim_t epsd2animinfo[] = | ||
249 | { | ||
250 | { ANIM_ALWAYS, TICRATE/3, 3, { 104, 168 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
251 | { ANIM_ALWAYS, TICRATE/3, 3, { 40, 136 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
252 | { ANIM_ALWAYS, TICRATE/3, 3, { 160, 96 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
253 | { ANIM_ALWAYS, TICRATE/3, 3, { 104, 80 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
254 | { ANIM_ALWAYS, TICRATE/3, 3, { 120, 32 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 }, | ||
255 | { ANIM_ALWAYS, TICRATE/4, 3, { 40, 0 }, 0, 0, { 0, 0, 0 }, 0, 0, 0, 0 } | ||
256 | }; | ||
257 | |||
258 | static int NUMANIMS[NUMEPISODES] = | ||
259 | { | ||
260 | sizeof(epsd0animinfo)/sizeof(anim_t), | ||
261 | sizeof(epsd1animinfo)/sizeof(anim_t), | ||
262 | sizeof(epsd2animinfo)/sizeof(anim_t) | ||
263 | }; | ||
264 | |||
265 | static anim_t *anims[NUMEPISODES] = | ||
266 | { | ||
267 | epsd0animinfo, | ||
268 | epsd1animinfo, | ||
269 | epsd2animinfo | ||
270 | }; | ||
271 | |||
272 | |||
273 | // | ||
274 | // GENERAL DATA | ||
275 | // | ||
276 | |||
277 | // | ||
278 | // Locally used stuff. | ||
279 | // | ||
280 | #define FB 0 | ||
281 | |||
282 | |||
283 | // States for single-player | ||
284 | #define SP_KILLS 0 | ||
285 | #define SP_ITEMS 2 | ||
286 | #define SP_SECRET 4 | ||
287 | #define SP_FRAGS 6 | ||
288 | #define SP_TIME 8 | ||
289 | #define SP_PAR ST_TIME | ||
290 | |||
291 | #define SP_PAUSE 1 | ||
292 | |||
293 | // in seconds | ||
294 | #define SHOWNEXTLOCDELAY 4 | ||
295 | //#define SHOWLASTLOCDELAY SHOWNEXTLOCDELAY | ||
296 | |||
297 | |||
298 | // used to accelerate or skip a stage | ||
299 | int acceleratestage; // killough 3/28/98: made global | ||
300 | |||
301 | // wbs->pnum | ||
302 | static int me; | ||
303 | |||
304 | // specifies current state | ||
305 | static stateenum_t state; | ||
306 | |||
307 | // contains information passed into intermission | ||
308 | static wbstartstruct_t* wbs; | ||
309 | |||
310 | static wbplayerstruct_t* plrs; // wbs->plyr[] | ||
311 | |||
312 | // used for general timing | ||
313 | static int cnt; | ||
314 | |||
315 | // used for timing of background animation | ||
316 | static int bcnt; | ||
317 | |||
318 | // signals to refresh everything for one frame | ||
319 | static int firstrefresh; | ||
320 | |||
321 | static int cnt_time; | ||
322 | static int cnt_total_time; | ||
323 | static int cnt_par; | ||
324 | static int cnt_pause; | ||
325 | |||
326 | |||
327 | // | ||
328 | // GRAPHICS | ||
329 | // | ||
330 | |||
331 | // You Are Here graphic | ||
332 | static const char* yah[2] = { "WIURH0", "WIURH1" }; | ||
333 | |||
334 | // splat | ||
335 | static const char* splat = "WISPLAT"; | ||
336 | |||
337 | // %, : graphics | ||
338 | static const char percent[] = {"WIPCNT"}; | ||
339 | static const char colon[] = {"WICOLON"}; | ||
340 | |||
341 | // 0-9 graphic | ||
342 | static const patch_t * num[10]; | ||
343 | |||
344 | // minus sign | ||
345 | static const char wiminus[] = {"WIMINUS"}; | ||
346 | |||
347 | // "Finished!" graphics | ||
348 | static const char finished[] = {"WIF"}; | ||
349 | |||
350 | // "Entering" graphic | ||
351 | static const char entering[] = {"WIENTER"}; | ||
352 | |||
353 | // "secret" | ||
354 | static const char sp_secret[] = {"WISCRT2"}; | ||
355 | |||
356 | // "Kills", "Scrt", "Items", "Frags" | ||
357 | static const char kills[] = {"WIOSTK"}; | ||
358 | static const char secret[] = {"WIOSTS"}; | ||
359 | static const char items[] = {"WIOSTI"}; | ||
360 | static const char frags[] = {"WIFRGS"}; | ||
361 | |||
362 | // Time sucks. | ||
363 | static const char time1[] = {"WITIME"}; | ||
364 | static const char par[] = {"WIPAR"}; | ||
365 | static const char sucks[] = {"WISUCKS"}; | ||
366 | |||
367 | // "killers", "victims" | ||
368 | static const char killers[] = {"WIKILRS"}; | ||
369 | static const char victims[] = {"WIVCTMS"}; | ||
370 | |||
371 | // "Total", your face, your dead face | ||
372 | static const char total[] = {"WIMSTT"}; | ||
373 | static const char star[] = {"STFST01"}; | ||
374 | static const char bstar[] = {"STFDEAD0"}; | ||
375 | |||
376 | // "red P[1..MAXPLAYERS]" | ||
377 | static const char facebackp[] = {"STPB0"}; | ||
378 | |||
379 | |||
380 | // | ||
381 | // CODE | ||
382 | // | ||
383 | |||
384 | static void WI_endDeathmatchStats(void); | ||
385 | static void WI_endNetgameStats(void); | ||
386 | void WI_unloadData(void); | ||
387 | #define WI_endStats WI_endNetgameStats | ||
388 | |||
389 | /* ==================================================================== | ||
390 | * WI_levelNameLump | ||
391 | * Purpore: Returns the name of the graphic lump containing the name of | ||
392 | * the given level. | ||
393 | * Args: Episode and level, and buffer (must by 9 chars) to write to | ||
394 | * Returns: void | ||
395 | */ | ||
396 | void WI_levelNameLump(int epis, int map, char* buf, int bsize) | ||
397 | { | ||
398 | if (gamemode == commercial) { | ||
399 | snprintf(buf, bsize,"CWILV%s%d",(map/10>0?"":"0"), map); //ANOTHER ROCKHACK "CWILV%2.2d" | ||
400 | //snprintf(buf,bsize, "CWILV%2.2d", map); | ||
401 | } else { | ||
402 | snprintf(buf,bsize, "WILV%d%d", epis, map); | ||
403 | } | ||
404 | } | ||
405 | |||
406 | // ==================================================================== | ||
407 | // WI_slamBackground | ||
408 | // Purpose: Put the full-screen background up prior to patches | ||
409 | // Args: none | ||
410 | // Returns: void | ||
411 | // | ||
412 | static void WI_slamBackground(void) | ||
413 | { | ||
414 | char name[9]; // limited to 8 characters | ||
415 | |||
416 | if (gamemode == commercial || (gamemode == retail && wbs->epsd == 3)) | ||
417 | strcpy(name, "INTERPIC"); | ||
418 | else | ||
419 | snprintf(name, sizeof(name), "WIMAP%d", wbs->epsd); | ||
420 | |||
421 | // background | ||
422 | V_DrawNamePatch(0, 0, FB, name, CR_DEFAULT, VPT_STRETCH); | ||
423 | } | ||
424 | |||
425 | // ==================================================================== | ||
426 | // WI_Responder | ||
427 | // Purpose: Draw animations on intermission background screen | ||
428 | // Args: ev -- event pointer, not actually used here. | ||
429 | // Returns: False -- dummy routine | ||
430 | // | ||
431 | // The ticker is used to detect keys | ||
432 | // because of timing issues in netgames. | ||
433 | boolean WI_Responder(event_t* ev) | ||
434 | { | ||
435 | (void)ev; | ||
436 | return false; | ||
437 | } | ||
438 | |||
439 | // ==================================================================== | ||
440 | // WI_drawLF | ||
441 | // Purpose: Draw the "Finished" level name before showing stats | ||
442 | // Args: none | ||
443 | // Returns: void | ||
444 | // | ||
445 | void WI_drawLF(void) | ||
446 | { | ||
447 | int y = WI_TITLEY; | ||
448 | char lname[9]; | ||
449 | |||
450 | // draw <LevelName> | ||
451 | /* cph - get the graphic lump name and use it */ | ||
452 | WI_levelNameLump(wbs->epsd, wbs->last, lname, sizeof(lname)); | ||
453 | // CPhipps - patch drawing updated | ||
454 | V_DrawNamePatch((320 - V_NamePatchWidth(lname))/2, y, | ||
455 | FB, lname, CR_DEFAULT, VPT_STRETCH); | ||
456 | |||
457 | // draw "Finished!" | ||
458 | y += (5*V_NamePatchHeight(lname))/4; | ||
459 | |||
460 | // CPhipps - patch drawing updated | ||
461 | V_DrawNamePatch((320 - V_NamePatchWidth(finished))/2, y, | ||
462 | FB, finished, CR_DEFAULT, VPT_STRETCH); | ||
463 | } | ||
464 | |||
465 | // ==================================================================== | ||
466 | // WI_drawEL | ||
467 | // Purpose: Draw introductory "Entering" and level name | ||
468 | // Args: none | ||
469 | // Returns: void | ||
470 | // | ||
471 | void WI_drawEL(void) | ||
472 | { | ||
473 | int y = WI_TITLEY; | ||
474 | char lname[9]; | ||
475 | |||
476 | /* cph - get the graphic lump name */ | ||
477 | WI_levelNameLump(wbs->epsd, wbs->next, lname, sizeof(lname)); | ||
478 | |||
479 | // draw "Entering" | ||
480 | // CPhipps - patch drawing updated | ||
481 | V_DrawNamePatch((320 - V_NamePatchWidth(entering))/2, | ||
482 | y, FB, entering, CR_DEFAULT, VPT_STRETCH); | ||
483 | |||
484 | // draw level | ||
485 | y += (5*V_NamePatchHeight(lname))/4; | ||
486 | |||
487 | // CPhipps - patch drawing updated | ||
488 | V_DrawNamePatch((320 - V_NamePatchWidth(lname))/2, y, FB, | ||
489 | lname, CR_DEFAULT, VPT_STRETCH); | ||
490 | } | ||
491 | |||
492 | |||
493 | /* ==================================================================== | ||
494 | * WI_drawOnLnode | ||
495 | * Purpose: Draw patches at a location based on episode/map | ||
496 | * Args: n -- index to map# within episode | ||
497 | * c[] -- array of names of patches to be drawn | ||
498 | * Returns: void | ||
499 | */ | ||
500 | void | ||
501 | WI_drawOnLnode // draw stuff at a location by episode/map# | ||
502 | ( int n, | ||
503 | const char* const c[] ) | ||
504 | { | ||
505 | int i; | ||
506 | boolean fits = false; | ||
507 | |||
508 | i = 0; | ||
509 | do | ||
510 | { | ||
511 | int left; | ||
512 | int top; | ||
513 | int right; | ||
514 | int bottom; | ||
515 | int lump = W_GetNumForName(c[i]); | ||
516 | const patch_t* p = W_CacheLumpNum(lump); | ||
517 | |||
518 | left = lnodes[wbs->epsd][n].x - SHORT(p->leftoffset); | ||
519 | top = lnodes[wbs->epsd][n].y - SHORT(p->topoffset); | ||
520 | right = left + SHORT(p->width); | ||
521 | bottom = top + SHORT(p->height); | ||
522 | W_UnlockLumpNum(lump); | ||
523 | |||
524 | if (left >= 0 | ||
525 | && right < 320 | ||
526 | && top >= 0 | ||
527 | && bottom < 200) | ||
528 | { | ||
529 | fits = true; | ||
530 | } | ||
531 | else | ||
532 | { | ||
533 | i++; | ||
534 | } | ||
535 | } while (!fits && i!=2); | ||
536 | |||
537 | if (fits && i<2) | ||
538 | { | ||
539 | // CPhipps - patch drawing updated | ||
540 | V_DrawNamePatch(lnodes[wbs->epsd][n].x, lnodes[wbs->epsd][n].y, | ||
541 | FB, c[i], CR_DEFAULT, VPT_STRETCH); | ||
542 | } | ||
543 | else | ||
544 | { | ||
545 | // DEBUG | ||
546 | //jff 8/3/98 use logical output routine | ||
547 | printf("Could not place patch on level %d", n+1); | ||
548 | } | ||
549 | } | ||
550 | |||
551 | |||
552 | // ==================================================================== | ||
553 | // WI_initAnimatedBack | ||
554 | // Purpose: Initialize pointers and styles for background animation | ||
555 | // Args: none | ||
556 | // Returns: void | ||
557 | // | ||
558 | void WI_initAnimatedBack(void) | ||
559 | { | ||
560 | int i; | ||
561 | anim_t* a; | ||
562 | |||
563 | if (gamemode == commercial) // no animation for DOOM2 | ||
564 | return; | ||
565 | |||
566 | if (wbs->epsd > 2) | ||
567 | return; | ||
568 | |||
569 | for (i=0;i<NUMANIMS[wbs->epsd];i++) | ||
570 | { | ||
571 | a = &anims[wbs->epsd][i]; | ||
572 | |||
573 | // init variables | ||
574 | a->ctr = -1; | ||
575 | |||
576 | // specify the next time to draw it | ||
577 | if (a->type == ANIM_ALWAYS) | ||
578 | a->nexttic = bcnt + 1 + (M_Random()%a->period); | ||
579 | else | ||
580 | if (a->type == ANIM_RANDOM) | ||
581 | a->nexttic = bcnt + 1 + a->data2+(M_Random()%a->data1); | ||
582 | else | ||
583 | if (a->type == ANIM_LEVEL) | ||
584 | a->nexttic = bcnt + 1; | ||
585 | } | ||
586 | } | ||
587 | |||
588 | |||
589 | // ==================================================================== | ||
590 | // WI_updateAnimatedBack | ||
591 | // Purpose: Figure out what animation we do on this iteration | ||
592 | // Args: none | ||
593 | // Returns: void | ||
594 | // | ||
595 | void WI_updateAnimatedBack(void) | ||
596 | { | ||
597 | int i; | ||
598 | anim_t* a; | ||
599 | |||
600 | if (gamemode == commercial) | ||
601 | return; | ||
602 | |||
603 | if (wbs->epsd > 2) | ||
604 | return; | ||
605 | |||
606 | for (i=0;i<NUMANIMS[wbs->epsd];i++) | ||
607 | { | ||
608 | a = &anims[wbs->epsd][i]; | ||
609 | |||
610 | if (bcnt == a->nexttic) | ||
611 | { | ||
612 | switch (a->type) | ||
613 | { | ||
614 | case ANIM_ALWAYS: | ||
615 | if (++a->ctr >= a->nanims) a->ctr = 0; | ||
616 | a->nexttic = bcnt + a->period; | ||
617 | break; | ||
618 | |||
619 | case ANIM_RANDOM: | ||
620 | a->ctr++; | ||
621 | if (a->ctr == a->nanims) | ||
622 | { | ||
623 | a->ctr = -1; | ||
624 | a->nexttic = bcnt+a->data2+(M_Random()%a->data1); | ||
625 | } | ||
626 | else | ||
627 | a->nexttic = bcnt + a->period; | ||
628 | break; | ||
629 | |||
630 | case ANIM_LEVEL: | ||
631 | // gawd-awful hack for level anims | ||
632 | if (!(state == StatCount && i == 7) | ||
633 | && wbs->next == a->data1) | ||
634 | { | ||
635 | a->ctr++; | ||
636 | if (a->ctr == a->nanims) a->ctr--; | ||
637 | a->nexttic = bcnt + a->period; | ||
638 | } | ||
639 | break; | ||
640 | } | ||
641 | } | ||
642 | } | ||
643 | } | ||
644 | |||
645 | |||
646 | // ==================================================================== | ||
647 | // WI_drawAnimatedBack | ||
648 | // Purpose: Actually do the animation (whew!) | ||
649 | // Args: none | ||
650 | // Returns: void | ||
651 | // | ||
652 | void WI_drawAnimatedBack(void) | ||
653 | { | ||
654 | int i; | ||
655 | anim_t* a; | ||
656 | |||
657 | if (gamemode==commercial) //jff 4/25/98 Someone forgot commercial an enum | ||
658 | return; | ||
659 | |||
660 | if (wbs->epsd > 2) | ||
661 | return; | ||
662 | |||
663 | for (i=0 ; i<NUMANIMS[wbs->epsd] ; i++) | ||
664 | { | ||
665 | a = &anims[wbs->epsd][i]; | ||
666 | |||
667 | if (a->ctr >= 0) | ||
668 | // CPhipps - patch drawing updated | ||
669 | V_DrawMemPatch(a->loc.x, a->loc.y, FB, a->p[a->ctr], CR_DEFAULT, VPT_STRETCH); | ||
670 | } | ||
671 | } | ||
672 | |||
673 | |||
674 | // ==================================================================== | ||
675 | // WI_drawNum | ||
676 | // Purpose: Draws a number. If digits > 0, then use that many digits | ||
677 | // minimum, otherwise only use as many as necessary | ||
678 | // Args: x, y -- location | ||
679 | // n -- the number to be drawn | ||
680 | // digits -- number of digits minimum or zero | ||
681 | // Returns: new x position after drawing (note we are going to the left) | ||
682 | // CPhipps - static | ||
683 | static int WI_drawNum (int x, int y, int n, int digits) | ||
684 | { | ||
685 | int fontwidth = SHORT(num[0]->width); | ||
686 | int neg; | ||
687 | int temp; | ||
688 | |||
689 | if (digits < 0) | ||
690 | { | ||
691 | if (!n) | ||
692 | { | ||
693 | // make variable-length zeros 1 digit long | ||
694 | digits = 1; | ||
695 | } | ||
696 | else | ||
697 | { | ||
698 | // figure out # of digits in # | ||
699 | digits = 0; | ||
700 | temp = n; | ||
701 | |||
702 | while (temp) | ||
703 | { | ||
704 | temp /= 10; | ||
705 | digits++; | ||
706 | } | ||
707 | } | ||
708 | } | ||
709 | |||
710 | neg = n < 0; | ||
711 | if (neg) | ||
712 | n = -n; | ||
713 | |||
714 | // if non-number, do not draw it | ||
715 | if (n == 1994) | ||
716 | return 0; | ||
717 | |||
718 | // draw the new number | ||
719 | while (digits--) | ||
720 | { | ||
721 | x -= fontwidth; | ||
722 | // CPhipps - patch drawing updated | ||
723 | V_DrawMemPatch(x, y, FB, num[ n % 10 ], CR_DEFAULT, VPT_STRETCH); | ||
724 | n /= 10; | ||
725 | } | ||
726 | |||
727 | // draw a minus sign if necessary | ||
728 | if (neg) | ||
729 | // CPhipps - patch drawing updated | ||
730 | V_DrawNamePatch(x-=8, y, FB, wiminus, CR_DEFAULT, VPT_STRETCH); | ||
731 | |||
732 | return x; | ||
733 | } | ||
734 | |||
735 | |||
736 | // ==================================================================== | ||
737 | // WI_drawPercent | ||
738 | // Purpose: Draws a percentage, really just a call to WI_drawNum | ||
739 | // after putting a percent sign out there | ||
740 | // Args: x, y -- location | ||
741 | // p -- the percentage value to be drawn, no negatives | ||
742 | // Returns: void | ||
743 | // CPhipps - static | ||
744 | static void WI_drawPercent(int x, int y, int p) | ||
745 | { | ||
746 | if (p < 0) | ||
747 | return; | ||
748 | |||
749 | // CPhipps - patch drawing updated | ||
750 | V_DrawNamePatch(x, y, FB, percent, CR_DEFAULT, VPT_STRETCH); | ||
751 | WI_drawNum(x, y, p, -1); | ||
752 | } | ||
753 | |||
754 | |||
755 | // ==================================================================== | ||
756 | // WI_drawTime | ||
757 | // Purpose: Draws the level completion time or par time, or "Sucks" | ||
758 | // if 1 hour or more | ||
759 | // Args: x, y -- location | ||
760 | // t -- the time value to be drawn | ||
761 | // Returns: void | ||
762 | // | ||
763 | // CPhipps - static | ||
764 | // - largely rewritten to display hours and use slightly better algorithm | ||
765 | |||
766 | static void WI_drawTime(int x, int y, int t) | ||
767 | { | ||
768 | int n; | ||
769 | |||
770 | if (t<0) | ||
771 | return; | ||
772 | |||
773 | if (t < 100*60*60) | ||
774 | for(;;) { | ||
775 | n = t % 60; | ||
776 | t /= 60; | ||
777 | x = WI_drawNum(x, y, n, (t || n>9) ? 2 : 1) - V_NamePatchWidth(colon); | ||
778 | |||
779 | // draw | ||
780 | if (t) | ||
781 | // CPhipps - patch drawing updated | ||
782 | V_DrawNamePatch(x, y, FB, colon, CR_DEFAULT, VPT_STRETCH); | ||
783 | else break; | ||
784 | } | ||
785 | else // "sucks" (maybe should be "addicted", even I've never had a 100 hour game ;) | ||
786 | V_DrawNamePatch(x - V_NamePatchWidth(sucks), | ||
787 | y, FB, sucks, CR_DEFAULT, VPT_STRETCH); | ||
788 | } | ||
789 | |||
790 | |||
791 | // ==================================================================== | ||
792 | // WI_End | ||
793 | // Purpose: Unloads data structures (inverse of WI_Start) | ||
794 | // Args: none | ||
795 | // Returns: void | ||
796 | // | ||
797 | void WI_End(void) | ||
798 | { | ||
799 | WI_unloadData(); | ||
800 | |||
801 | if (deathmatch) | ||
802 | WI_endDeathmatchStats(); | ||
803 | else if (netgame) | ||
804 | WI_endNetgameStats(); | ||
805 | else | ||
806 | WI_endStats(); | ||
807 | } | ||
808 | |||
809 | |||
810 | // ==================================================================== | ||
811 | // WI_initNoState | ||
812 | // Purpose: Clear state, ready for end of level activity | ||
813 | // Args: none | ||
814 | // Returns: void | ||
815 | // | ||
816 | void WI_initNoState(void) | ||
817 | { | ||
818 | state = NoState; | ||
819 | acceleratestage = 0; | ||
820 | cnt = 10; | ||
821 | } | ||
822 | |||
823 | |||
824 | // ==================================================================== | ||
825 | // WI_drawTimeStats | ||
826 | // Purpose: Put the times on the screen | ||
827 | // Args: time, total time, par time, in seconds | ||
828 | // Returns: void | ||
829 | // | ||
830 | // cph - pulled from WI_drawStats below | ||
831 | |||
832 | static void WI_drawTimeStats(int cnt_time, int cnt_total_time, int cnt_par) | ||
833 | { | ||
834 | V_DrawNamePatch(SP_TIMEX, SP_TIMEY, FB, time1, CR_DEFAULT, VPT_STRETCH); | ||
835 | WI_drawTime(320/2 - SP_TIMEX, SP_TIMEY, cnt_time); | ||
836 | |||
837 | V_DrawNamePatch(SP_TIMEX, (SP_TIMEY+200)/2, FB, total, CR_DEFAULT, VPT_STRETCH); | ||
838 | WI_drawTime(320/2 - SP_TIMEX, (SP_TIMEY+200)/2, cnt_total_time); | ||
839 | |||
840 | // Ty 04/11/98: redid logic: should skip only if with pwad but | ||
841 | // without deh patch | ||
842 | // killough 2/22/98: skip drawing par times on pwads | ||
843 | // Ty 03/17/98: unless pars changed with deh patch | ||
844 | |||
845 | if (!(modifiedgame)) //&& !deh_pars)) | ||
846 | { | ||
847 | if (wbs->epsd < 3) | ||
848 | { | ||
849 | V_DrawNamePatch(320/2 + SP_TIMEX, SP_TIMEY, FB, par, CR_DEFAULT, VPT_STRETCH); | ||
850 | WI_drawTime(320 - SP_TIMEX, SP_TIMEY, cnt_par); | ||
851 | } | ||
852 | } | ||
853 | } | ||
854 | |||
855 | // ==================================================================== | ||
856 | // WI_updateNoState | ||
857 | // Purpose: Cycle until end of level activity is done | ||
858 | // Args: none | ||
859 | // Returns: void | ||
860 | // | ||
861 | void WI_updateNoState(void) | ||
862 | { | ||
863 | |||
864 | WI_updateAnimatedBack(); | ||
865 | |||
866 | if (!--cnt) | ||
867 | G_WorldDone(); | ||
868 | } | ||
869 | |||
870 | static boolean snl_pointeron = false; | ||
871 | |||
872 | |||
873 | |||
874 | // ==================================================================== | ||
875 | // WI_initShowNextLoc | ||
876 | // Purpose: Prepare to show the next level's location | ||
877 | // Args: none | ||
878 | // Returns: void | ||
879 | // | ||
880 | void WI_initShowNextLoc(void) | ||
881 | { | ||
882 | if ((gamemode != commercial) && (gamemap == 8)) { | ||
883 | G_WorldDone(); | ||
884 | return; | ||
885 | } | ||
886 | |||
887 | state = ShowNextLoc; | ||
888 | acceleratestage = 0; | ||
889 | cnt = SHOWNEXTLOCDELAY * TICRATE; | ||
890 | |||
891 | WI_initAnimatedBack(); | ||
892 | } | ||
893 | |||
894 | // ==================================================================== | ||
895 | // WI_updateShowNextLoc | ||
896 | // Purpose: Prepare to show the next level's location | ||
897 | // Args: none | ||
898 | // Returns: void | ||
899 | // | ||
900 | void WI_updateShowNextLoc(void) | ||
901 | { | ||
902 | WI_updateAnimatedBack(); | ||
903 | |||
904 | if (!--cnt || acceleratestage) | ||
905 | WI_initNoState(); | ||
906 | else | ||
907 | snl_pointeron = (cnt & 31) < 20; | ||
908 | } | ||
909 | |||
910 | |||
911 | // ==================================================================== | ||
912 | // WI_drawShowNextLoc | ||
913 | // Purpose: Show the next level's location on animated backgrounds | ||
914 | // Args: none | ||
915 | // Returns: void | ||
916 | // | ||
917 | void WI_drawShowNextLoc(void) | ||
918 | { | ||
919 | int i; | ||
920 | int last; | ||
921 | |||
922 | WI_slamBackground(); | ||
923 | |||
924 | // draw animated background | ||
925 | WI_drawAnimatedBack(); | ||
926 | |||
927 | if ( gamemode != commercial) | ||
928 | { | ||
929 | if (wbs->epsd > 2) | ||
930 | { | ||
931 | WI_drawEL(); // "Entering..." if not E1 or E2 | ||
932 | return; | ||
933 | } | ||
934 | |||
935 | last = (wbs->last == 8) ? wbs->next - 1 : wbs->last; | ||
936 | |||
937 | // draw a splat on taken cities. | ||
938 | for (i=0 ; i<=last ; i++) | ||
939 | WI_drawOnLnode(i, &splat); | ||
940 | |||
941 | // splat the secret level? | ||
942 | if (wbs->didsecret) | ||
943 | WI_drawOnLnode(8, &splat); | ||
944 | |||
945 | // draw flashing ptr | ||
946 | if (snl_pointeron) | ||
947 | WI_drawOnLnode(wbs->next, yah); | ||
948 | } | ||
949 | |||
950 | // draws which level you are entering.. | ||
951 | if ( (gamemode != commercial) | ||
952 | || wbs->next != 30) // check for MAP30 end game | ||
953 | WI_drawEL(); | ||
954 | } | ||
955 | |||
956 | // ==================================================================== | ||
957 | // WI_drawNoState | ||
958 | // Purpose: Draw the pointer and next location | ||
959 | // Args: none | ||
960 | // Returns: void | ||
961 | // | ||
962 | void WI_drawNoState(void) | ||
963 | { | ||
964 | snl_pointeron = true; | ||
965 | WI_drawShowNextLoc(); | ||
966 | } | ||
967 | |||
968 | |||
969 | // ==================================================================== | ||
970 | // WI_fragSum | ||
971 | // Purpose: Calculate frags for this player based on the current totals | ||
972 | // of all the other players. Subtract self-frags. | ||
973 | // Args: playernum -- the player to be calculated | ||
974 | // Returns: the total frags for this player | ||
975 | // | ||
976 | int WI_fragSum(int playernum) | ||
977 | { | ||
978 | int i; | ||
979 | int frags = 0; | ||
980 | |||
981 | for (i=0 ; i<MAXPLAYERS ; i++) | ||
982 | { | ||
983 | if (playeringame[i] // is this player playing? | ||
984 | && i!=playernum) // and it's not the player we're calculating | ||
985 | { | ||
986 | frags += plrs[playernum].frags[i]; | ||
987 | } | ||
988 | } | ||
989 | |||
990 | |||
991 | // JDC hack - negative frags. | ||
992 | frags -= plrs[playernum].frags[playernum]; | ||
993 | |||
994 | return frags; | ||
995 | } | ||
996 | |||
997 | |||
998 | static int dm_state; | ||
999 | // CPhipps - short, dynamically allocated | ||
1000 | static short int **dm_frags; // frags matrix | ||
1001 | static short int *dm_totals; // totals by player | ||
1002 | |||
1003 | // ==================================================================== | ||
1004 | // WI_initDeathmatchStats | ||
1005 | // Purpose: Set up to display DM stats at end of level. Calculate | ||
1006 | // frags for all players. | ||
1007 | // Args: none | ||
1008 | // Returns: void | ||
1009 | // | ||
1010 | void WI_initDeathmatchStats(void) | ||
1011 | { | ||
1012 | int i; // looping variables | ||
1013 | |||
1014 | // CPhipps - allocate data structures needed | ||
1015 | dm_frags = calloc(MAXPLAYERS, sizeof(*dm_frags)); | ||
1016 | dm_totals = calloc(MAXPLAYERS, sizeof(*dm_totals)); | ||
1017 | |||
1018 | state = StatCount; // We're doing stats | ||
1019 | acceleratestage = 0; | ||
1020 | dm_state = 1; // count how many times we've done a complete stat | ||
1021 | |||
1022 | cnt_pause = TICRATE; | ||
1023 | |||
1024 | for (i=0 ; i<MAXPLAYERS ; i++) | ||
1025 | { | ||
1026 | if (playeringame[i]) | ||
1027 | { | ||
1028 | // CPhipps - allocate frags line | ||
1029 | dm_frags[i] = calloc(MAXPLAYERS, sizeof(**dm_frags)); // set all counts to zero | ||
1030 | |||
1031 | dm_totals[i] = 0; | ||
1032 | } | ||
1033 | } | ||
1034 | WI_initAnimatedBack(); | ||
1035 | } | ||
1036 | |||
1037 | |||
1038 | // ==================================================================== | ||
1039 | // CPhipps - WI_endDeathmatchStats | ||
1040 | // Purpose: Deallocate dynamically allocated DM stats data | ||
1041 | // Args: none | ||
1042 | // Returns: void | ||
1043 | // | ||
1044 | |||
1045 | void WI_endDeathmatchStats(void) | ||
1046 | { | ||
1047 | int i; | ||
1048 | for (i=0; i<MAXPLAYERS; i++) | ||
1049 | free(dm_frags[i]); | ||
1050 | |||
1051 | free(dm_frags); free(dm_totals); | ||
1052 | } | ||
1053 | |||
1054 | // ==================================================================== | ||
1055 | // WI_updateDeathmatchStats | ||
1056 | // Purpose: Advance Deathmatch stats screen animation. Calculate | ||
1057 | // frags for all players. Lots of noise and drama around | ||
1058 | // the presentation. | ||
1059 | // Args: none | ||
1060 | // Returns: void | ||
1061 | // | ||
1062 | void WI_updateDeathmatchStats(void) | ||
1063 | { | ||
1064 | int i; | ||
1065 | int j; | ||
1066 | |||
1067 | boolean stillticking; | ||
1068 | |||
1069 | WI_updateAnimatedBack(); | ||
1070 | |||
1071 | if (acceleratestage && dm_state != 4) // still ticking | ||
1072 | { | ||
1073 | acceleratestage = 0; | ||
1074 | |||
1075 | for (i=0 ; i<MAXPLAYERS ; i++) | ||
1076 | { | ||
1077 | if (playeringame[i]) | ||
1078 | { | ||
1079 | for (j=0 ; j<MAXPLAYERS ; j++) | ||
1080 | if (playeringame[j]) | ||
1081 | dm_frags[i][j] = plrs[i].frags[j]; | ||
1082 | |||
1083 | dm_totals[i] = WI_fragSum(i); | ||
1084 | } | ||
1085 | } | ||
1086 | |||
1087 | |||
1088 | S_StartSound(0, sfx_barexp); // bang | ||
1089 | dm_state = 4; // we're done with all 4 (or all we have to do) | ||
1090 | } | ||
1091 | |||
1092 | |||
1093 | if (dm_state == 2) | ||
1094 | { | ||
1095 | if (!(bcnt&3)) | ||
1096 | S_StartSound(0, sfx_pistol); // noise while counting | ||
1097 | |||
1098 | stillticking = false; | ||
1099 | |||
1100 | for (i=0 ; i<MAXPLAYERS ; i++) | ||
1101 | { | ||
1102 | if (playeringame[i]) | ||
1103 | { | ||
1104 | for (j=0 ; j<MAXPLAYERS ; j++) | ||
1105 | { | ||
1106 | if (playeringame[j] | ||
1107 | && dm_frags[i][j] != plrs[i].frags[j]) | ||
1108 | { | ||
1109 | if (plrs[i].frags[j] < 0) | ||
1110 | dm_frags[i][j]--; | ||
1111 | else | ||
1112 | dm_frags[i][j]++; | ||
1113 | |||
1114 | if (dm_frags[i][j] > 999) // Ty 03/17/98 3-digit frag count | ||
1115 | dm_frags[i][j] = 999; | ||
1116 | |||
1117 | if (dm_frags[i][j] < -999) | ||
1118 | dm_frags[i][j] = -999; | ||
1119 | |||
1120 | stillticking = true; | ||
1121 | } | ||
1122 | } | ||
1123 | dm_totals[i] = WI_fragSum(i); | ||
1124 | |||
1125 | if (dm_totals[i] > 999) | ||
1126 | dm_totals[i] = 999; | ||
1127 | |||
1128 | if (dm_totals[i] < -999) | ||
1129 | dm_totals[i] = -999; // Ty 03/17/98 end 3-digit frag count | ||
1130 | } | ||
1131 | } | ||
1132 | |||
1133 | if (!stillticking) | ||
1134 | { | ||
1135 | S_StartSound(0, sfx_barexp); | ||
1136 | dm_state++; | ||
1137 | } | ||
1138 | } | ||
1139 | else if (dm_state == 4) | ||
1140 | { | ||
1141 | if (acceleratestage) | ||
1142 | { | ||
1143 | S_StartSound(0, sfx_slop); | ||
1144 | |||
1145 | if ( gamemode == commercial) | ||
1146 | WI_initNoState(); | ||
1147 | else | ||
1148 | WI_initShowNextLoc(); | ||
1149 | } | ||
1150 | } | ||
1151 | else if (dm_state & 1) | ||
1152 | { | ||
1153 | if (!--cnt_pause) | ||
1154 | { | ||
1155 | dm_state++; | ||
1156 | cnt_pause = TICRATE; | ||
1157 | } | ||
1158 | } | ||
1159 | } | ||
1160 | |||
1161 | |||
1162 | // ==================================================================== | ||
1163 | // WI_drawDeathmatchStats | ||
1164 | // Purpose: Draw the stats on the screen in a matrix | ||
1165 | // Args: none | ||
1166 | // Returns: void | ||
1167 | // | ||
1168 | // proff/nicolas 09/20/98 -- changed for hi-res | ||
1169 | // CPhipps - patch drawing updated | ||
1170 | void WI_drawDeathmatchStats(void) | ||
1171 | { | ||
1172 | int i; | ||
1173 | int j; | ||
1174 | int x; | ||
1175 | int y; | ||
1176 | int w; | ||
1177 | |||
1178 | int lh; // line height | ||
1179 | int halfface = V_NamePatchWidth(facebackp)/2; | ||
1180 | |||
1181 | lh = WI_SPACINGY; | ||
1182 | |||
1183 | WI_slamBackground(); | ||
1184 | |||
1185 | // draw animated background | ||
1186 | WI_drawAnimatedBack(); | ||
1187 | WI_drawLF(); | ||
1188 | |||
1189 | // draw stat titles (top line) | ||
1190 | V_DrawNamePatch(DM_TOTALSX-V_NamePatchWidth(total)/2, | ||
1191 | DM_MATRIXY-WI_SPACINGY+10, FB, total, CR_DEFAULT, VPT_STRETCH); | ||
1192 | |||
1193 | V_DrawNamePatch(DM_KILLERSX, DM_KILLERSY, FB, killers, CR_DEFAULT, VPT_STRETCH); | ||
1194 | V_DrawNamePatch(DM_VICTIMSX, DM_VICTIMSY, FB, victims, CR_DEFAULT, VPT_STRETCH); | ||
1195 | |||
1196 | // draw P? | ||
1197 | x = DM_MATRIXX + DM_SPACINGX; | ||
1198 | y = DM_MATRIXY; | ||
1199 | |||
1200 | for (i=0 ; i<MAXPLAYERS ; i++) | ||
1201 | { | ||
1202 | if (playeringame[i]) { | ||
1203 | //int trans = playernumtotrans[i]; | ||
1204 | V_DrawNamePatch(x-halfface, DM_MATRIXY - WI_SPACINGY, | ||
1205 | FB, facebackp, i ? CR_LIMIT+i : CR_DEFAULT, | ||
1206 | VPT_STRETCH | (i ? VPT_TRANS : 0)); | ||
1207 | V_DrawNamePatch(DM_MATRIXX-halfface, y, | ||
1208 | FB, facebackp, i ? CR_LIMIT+i : CR_DEFAULT, | ||
1209 | VPT_STRETCH | (i ? VPT_TRANS : 0)); | ||
1210 | |||
1211 | if (i == me) | ||
1212 | { | ||
1213 | V_DrawNamePatch(x-halfface, DM_MATRIXY - WI_SPACINGY, | ||
1214 | FB, bstar, CR_DEFAULT, VPT_STRETCH); | ||
1215 | V_DrawNamePatch(DM_MATRIXX-halfface, y, | ||
1216 | FB, star, CR_DEFAULT, VPT_STRETCH); | ||
1217 | } | ||
1218 | } | ||
1219 | x += DM_SPACINGX; | ||
1220 | y += WI_SPACINGY; | ||
1221 | } | ||
1222 | |||
1223 | // draw stats | ||
1224 | y = DM_MATRIXY+10; | ||
1225 | w = SHORT(num[0]->width); | ||
1226 | |||
1227 | for (i=0 ; i<MAXPLAYERS ; i++) | ||
1228 | { | ||
1229 | x = DM_MATRIXX + DM_SPACINGX; | ||
1230 | |||
1231 | if (playeringame[i]) | ||
1232 | { | ||
1233 | for (j=0 ; j<MAXPLAYERS ; j++) | ||
1234 | { | ||
1235 | if (playeringame[j]) | ||
1236 | WI_drawNum(x+w, y, dm_frags[i][j], 2); | ||
1237 | |||
1238 | x += DM_SPACINGX; | ||
1239 | } | ||
1240 | WI_drawNum(DM_TOTALSX+w, y, dm_totals[i], 2); | ||
1241 | } | ||
1242 | y += WI_SPACINGY; | ||
1243 | } | ||
1244 | } | ||
1245 | |||
1246 | |||
1247 | // | ||
1248 | // Note: The term "Netgame" means a coop game | ||
1249 | // | ||
1250 | static short *cnt_kills; | ||
1251 | static short *cnt_items; | ||
1252 | static short *cnt_secret; | ||
1253 | static short *cnt_frags; | ||
1254 | static int dofrags; | ||
1255 | static int ng_state; | ||
1256 | |||
1257 | // ==================================================================== | ||
1258 | // CPhipps - WI_endNetgameStats | ||
1259 | // Purpose: Clean up coop game stats | ||
1260 | // Args: none | ||
1261 | // Returns: void | ||
1262 | // | ||
1263 | static void WI_endNetgameStats(void) | ||
1264 | { | ||
1265 | free(cnt_frags); | ||
1266 | free(cnt_secret); | ||
1267 | free(cnt_items); | ||
1268 | free(cnt_kills); | ||
1269 | } | ||
1270 | |||
1271 | // ==================================================================== | ||
1272 | // WI_initNetgameStats | ||
1273 | // Purpose: Prepare for coop game stats | ||
1274 | // Args: none | ||
1275 | // Returns: void | ||
1276 | // | ||
1277 | void WI_initNetgameStats(void) | ||
1278 | { | ||
1279 | int i; | ||
1280 | |||
1281 | state = StatCount; | ||
1282 | acceleratestage = 0; | ||
1283 | ng_state = 1; | ||
1284 | |||
1285 | cnt_pause = TICRATE; | ||
1286 | |||
1287 | // CPhipps - allocate these dynamically, blank with calloc | ||
1288 | cnt_kills = calloc(MAXPLAYERS, sizeof(*cnt_kills)); | ||
1289 | cnt_items = calloc(MAXPLAYERS, sizeof(*cnt_items)); | ||
1290 | cnt_secret= calloc(MAXPLAYERS, sizeof(*cnt_secret)); | ||
1291 | cnt_frags = calloc(MAXPLAYERS, sizeof(*cnt_frags)); | ||
1292 | |||
1293 | for (i=0 ; i<MAXPLAYERS ; i++) | ||
1294 | if (playeringame[i]) | ||
1295 | dofrags += WI_fragSum(i); | ||
1296 | |||
1297 | dofrags = !!dofrags; // set to true or false - did we have frags? | ||
1298 | |||
1299 | WI_initAnimatedBack(); | ||
1300 | } | ||
1301 | |||
1302 | |||
1303 | // ==================================================================== | ||
1304 | // WI_updateNetgameStats | ||
1305 | // Purpose: Calculate coop stats as we display them with noise and fury | ||
1306 | // Args: none | ||
1307 | // Returns: void | ||
1308 | // Comment: This stuff sure is complicated for what it does | ||
1309 | // | ||
1310 | void WI_updateNetgameStats(void) | ||
1311 | { | ||
1312 | int i; | ||
1313 | int fsum; | ||
1314 | |||
1315 | boolean stillticking; | ||
1316 | |||
1317 | WI_updateAnimatedBack(); | ||
1318 | |||
1319 | if (acceleratestage && ng_state != 10) | ||
1320 | { | ||
1321 | acceleratestage = 0; | ||
1322 | |||
1323 | for (i=0 ; i<MAXPLAYERS ; i++) | ||
1324 | { | ||
1325 | if (!playeringame[i]) | ||
1326 | continue; | ||
1327 | |||
1328 | cnt_kills[i] = (plrs[i].skills * 100) / wbs->maxkills; | ||
1329 | cnt_items[i] = (plrs[i].sitems * 100) / wbs->maxitems; | ||
1330 | |||
1331 | // killough 2/22/98: Make secrets = 100% if maxsecret = 0: | ||
1332 | cnt_secret[i] = wbs->maxsecret ? | ||
1333 | (plrs[i].ssecret * 100) / wbs->maxsecret : 100; | ||
1334 | if (dofrags) | ||
1335 | cnt_frags[i] = WI_fragSum(i); // we had frags | ||
1336 | } | ||
1337 | S_StartSound(0, sfx_barexp); // bang | ||
1338 | ng_state = 10; | ||
1339 | } | ||
1340 | |||
1341 | if (ng_state == 2) | ||
1342 | { | ||
1343 | if (!(bcnt&3)) | ||
1344 | S_StartSound(0, sfx_pistol); // pop | ||
1345 | |||
1346 | stillticking = false; | ||
1347 | |||
1348 | for (i=0 ; i<MAXPLAYERS ; i++) | ||
1349 | { | ||
1350 | if (!playeringame[i]) | ||
1351 | continue; | ||
1352 | |||
1353 | cnt_kills[i] += 2; | ||
1354 | |||
1355 | if (cnt_kills[i] >= (plrs[i].skills * 100) / wbs->maxkills) | ||
1356 | cnt_kills[i] = (plrs[i].skills * 100) / wbs->maxkills; | ||
1357 | else | ||
1358 | stillticking = true; // still got stuff to tally | ||
1359 | } | ||
1360 | |||
1361 | if (!stillticking) | ||
1362 | { | ||
1363 | S_StartSound(0, sfx_barexp); | ||
1364 | ng_state++; | ||
1365 | } | ||
1366 | } | ||
1367 | else if (ng_state == 4) | ||
1368 | { | ||
1369 | if (!(bcnt&3)) | ||
1370 | S_StartSound(0, sfx_pistol); | ||
1371 | |||
1372 | stillticking = false; | ||
1373 | |||
1374 | for (i=0 ; i<MAXPLAYERS ; i++) | ||
1375 | { | ||
1376 | if (!playeringame[i]) | ||
1377 | continue; | ||
1378 | |||
1379 | cnt_items[i] += 2; | ||
1380 | if (cnt_items[i] >= (plrs[i].sitems * 100) / wbs->maxitems) | ||
1381 | cnt_items[i] = (plrs[i].sitems * 100) / wbs->maxitems; | ||
1382 | else | ||
1383 | stillticking = true; | ||
1384 | } | ||
1385 | |||
1386 | if (!stillticking) | ||
1387 | { | ||
1388 | S_StartSound(0, sfx_barexp); | ||
1389 | ng_state++; | ||
1390 | } | ||
1391 | } | ||
1392 | else if (ng_state == 6) | ||
1393 | { | ||
1394 | if (!(bcnt&3)) | ||
1395 | S_StartSound(0, sfx_pistol); | ||
1396 | |||
1397 | stillticking = false; | ||
1398 | |||
1399 | for (i=0 ; i<MAXPLAYERS ; i++) | ||
1400 | { | ||
1401 | if (!playeringame[i]) | ||
1402 | continue; | ||
1403 | |||
1404 | cnt_secret[i] += 2; | ||
1405 | |||
1406 | // killough 2/22/98: Make secrets = 100% if maxsecret = 0: | ||
1407 | |||
1408 | if (cnt_secret[i] >= (wbs->maxsecret ? (plrs[i].ssecret * 100) / wbs->maxsecret : compatibility_level < lxdoom_1_compatibility ? 0 : 100)) | ||
1409 | cnt_secret[i] = wbs->maxsecret ? (plrs[i].ssecret * 100) / wbs->maxsecret : 100; | ||
1410 | else | ||
1411 | stillticking = true; | ||
1412 | } | ||
1413 | |||
1414 | if (!stillticking) | ||
1415 | { | ||
1416 | S_StartSound(0, sfx_barexp); | ||
1417 | ng_state += 1 + 2*!dofrags; | ||
1418 | } | ||
1419 | } | ||
1420 | else if (ng_state == 8) | ||
1421 | { | ||
1422 | if (!(bcnt&3)) | ||
1423 | S_StartSound(0, sfx_pistol); | ||
1424 | |||
1425 | stillticking = false; | ||
1426 | |||
1427 | for (i=0 ; i<MAXPLAYERS ; i++) | ||
1428 | { | ||
1429 | if (!playeringame[i]) | ||
1430 | continue; | ||
1431 | |||
1432 | cnt_frags[i] += 1; | ||
1433 | |||
1434 | if (cnt_frags[i] >= (fsum = WI_fragSum(i))) | ||
1435 | cnt_frags[i] = fsum; | ||
1436 | else | ||
1437 | stillticking = true; | ||
1438 | } | ||
1439 | |||
1440 | if (!stillticking) | ||
1441 | { | ||
1442 | S_StartSound(0, sfx_pldeth); | ||
1443 | ng_state++; | ||
1444 | } | ||
1445 | } | ||
1446 | else if (ng_state == 10) | ||
1447 | { | ||
1448 | if (acceleratestage) | ||
1449 | { | ||
1450 | S_StartSound(0, sfx_sgcock); | ||
1451 | if ( gamemode == commercial ) | ||
1452 | WI_initNoState(); | ||
1453 | else | ||
1454 | WI_initShowNextLoc(); | ||
1455 | } | ||
1456 | } | ||
1457 | else if (ng_state & 1) | ||
1458 | { | ||
1459 | if (!--cnt_pause) | ||
1460 | { | ||
1461 | ng_state++; | ||
1462 | cnt_pause = TICRATE; | ||
1463 | } | ||
1464 | } | ||
1465 | } | ||
1466 | |||
1467 | |||
1468 | // ==================================================================== | ||
1469 | // WI_drawNetgameStats | ||
1470 | // Purpose: Put the coop stats on the screen | ||
1471 | // Args: none | ||
1472 | // Returns: void | ||
1473 | // | ||
1474 | // proff/nicolas 09/20/98 -- changed for hi-res | ||
1475 | // CPhipps - patch drawing updated | ||
1476 | void WI_drawNetgameStats(void) | ||
1477 | { | ||
1478 | int i; | ||
1479 | int x; | ||
1480 | int y; | ||
1481 | int pwidth = V_NamePatchWidth(percent); | ||
1482 | int fwidth = V_NamePatchWidth(facebackp); | ||
1483 | |||
1484 | WI_slamBackground(); | ||
1485 | |||
1486 | // draw animated background | ||
1487 | WI_drawAnimatedBack(); | ||
1488 | |||
1489 | WI_drawLF(); | ||
1490 | |||
1491 | // draw stat titles (top line) | ||
1492 | V_DrawNamePatch(NG_STATSX+NG_SPACINGX-V_NamePatchWidth(kills), | ||
1493 | NG_STATSY, FB, kills, CR_DEFAULT, VPT_STRETCH); | ||
1494 | |||
1495 | V_DrawNamePatch(NG_STATSX+2*NG_SPACINGX-V_NamePatchWidth(items), | ||
1496 | NG_STATSY, FB, items, CR_DEFAULT, VPT_STRETCH); | ||
1497 | |||
1498 | V_DrawNamePatch(NG_STATSX+3*NG_SPACINGX-V_NamePatchWidth(secret), | ||
1499 | NG_STATSY, FB, secret, CR_DEFAULT, VPT_STRETCH); | ||
1500 | |||
1501 | if (dofrags) | ||
1502 | V_DrawNamePatch(NG_STATSX+4*NG_SPACINGX-V_NamePatchWidth(frags), | ||
1503 | NG_STATSY, FB, frags, CR_DEFAULT, VPT_STRETCH); | ||
1504 | |||
1505 | // draw stats | ||
1506 | y = NG_STATSY + V_NamePatchHeight(kills); | ||
1507 | |||
1508 | for (i=0 ; i<MAXPLAYERS ; i++) | ||
1509 | { | ||
1510 | //int trans = playernumtotrans[i]; | ||
1511 | if (!playeringame[i]) | ||
1512 | continue; | ||
1513 | |||
1514 | x = NG_STATSX; | ||
1515 | V_DrawNamePatch(x-fwidth, y, FB, facebackp, | ||
1516 | i ? CR_LIMIT+i : CR_DEFAULT, | ||
1517 | VPT_STRETCH | (i ? VPT_TRANS : 0)); | ||
1518 | |||
1519 | if (i == me) | ||
1520 | V_DrawNamePatch(x-fwidth, y, FB, star, CR_DEFAULT, VPT_STRETCH); | ||
1521 | |||
1522 | x += NG_SPACINGX; | ||
1523 | WI_drawPercent(x-pwidth, y+10, cnt_kills[i]); x += NG_SPACINGX; | ||
1524 | WI_drawPercent(x-pwidth, y+10, cnt_items[i]); x += NG_SPACINGX; | ||
1525 | WI_drawPercent(x-pwidth, y+10, cnt_secret[i]); x += NG_SPACINGX; | ||
1526 | |||
1527 | if (dofrags) | ||
1528 | WI_drawNum(x, y+10, cnt_frags[i], -1); | ||
1529 | |||
1530 | y += WI_SPACINGY; | ||
1531 | } | ||
1532 | |||
1533 | if (y <= SP_TIMEY) | ||
1534 | // cph - show times in coop on the entering screen | ||
1535 | WI_drawTimeStats(plrs[me].stime / TICRATE, wbs->totaltimes / TICRATE, wbs->partime / TICRATE); | ||
1536 | } | ||
1537 | |||
1538 | static int sp_state; | ||
1539 | |||
1540 | // ==================================================================== | ||
1541 | // WI_initStats | ||
1542 | // Purpose: Get ready for single player stats | ||
1543 | // Args: none | ||
1544 | // Returns: void | ||
1545 | // Comment: Seems like we could do all these stats in a more generic | ||
1546 | // set of routines that weren't duplicated for dm, coop, sp | ||
1547 | // | ||
1548 | void WI_initStats(void) | ||
1549 | { | ||
1550 | state = StatCount; | ||
1551 | acceleratestage = 0; | ||
1552 | sp_state = 1; | ||
1553 | |||
1554 | // CPhipps - allocate (awful code, I know, but saves changing it all) and initialise | ||
1555 | *(cnt_kills = malloc(sizeof(*cnt_kills))) = | ||
1556 | *(cnt_items = malloc(sizeof(*cnt_items))) = | ||
1557 | *(cnt_secret= malloc(sizeof(*cnt_secret))) = -1; | ||
1558 | cnt_time = cnt_par = cnt_total_time = -1; | ||
1559 | cnt_pause = TICRATE; | ||
1560 | |||
1561 | WI_initAnimatedBack(); | ||
1562 | } | ||
1563 | |||
1564 | // ==================================================================== | ||
1565 | // WI_updateStats | ||
1566 | // Purpose: Calculate solo stats | ||
1567 | // Args: none | ||
1568 | // Returns: void | ||
1569 | // | ||
1570 | void WI_updateStats(void) | ||
1571 | { | ||
1572 | WI_updateAnimatedBack(); | ||
1573 | |||
1574 | if (acceleratestage && sp_state != 10) | ||
1575 | { | ||
1576 | acceleratestage = 0; | ||
1577 | cnt_kills[0] = (plrs[me].skills * 100) / wbs->maxkills; | ||
1578 | cnt_items[0] = (plrs[me].sitems * 100) / wbs->maxitems; | ||
1579 | |||
1580 | // killough 2/22/98: Make secrets = 100% if maxsecret = 0: | ||
1581 | cnt_secret[0] = (wbs->maxsecret ? | ||
1582 | (plrs[me].ssecret * 100) / wbs->maxsecret : 100); | ||
1583 | |||
1584 | cnt_total_time = wbs->totaltimes / TICRATE; | ||
1585 | cnt_time = plrs[me].stime / TICRATE; | ||
1586 | cnt_par = wbs->partime / TICRATE; | ||
1587 | S_StartSound(0, sfx_barexp); | ||
1588 | sp_state = 10; | ||
1589 | } | ||
1590 | |||
1591 | if (sp_state == 2) | ||
1592 | { | ||
1593 | cnt_kills[0] += 2; | ||
1594 | |||
1595 | if (!(bcnt&3)) | ||
1596 | S_StartSound(0, sfx_pistol); | ||
1597 | |||
1598 | if (cnt_kills[0] >= (plrs[me].skills * 100) / wbs->maxkills) | ||
1599 | { | ||
1600 | cnt_kills[0] = (plrs[me].skills * 100) / wbs->maxkills; | ||
1601 | S_StartSound(0, sfx_barexp); | ||
1602 | sp_state++; | ||
1603 | } | ||
1604 | } | ||
1605 | else if (sp_state == 4) | ||
1606 | { | ||
1607 | cnt_items[0] += 2; | ||
1608 | |||
1609 | if (!(bcnt&3)) | ||
1610 | S_StartSound(0, sfx_pistol); | ||
1611 | |||
1612 | if (cnt_items[0] >= (plrs[me].sitems * 100) / wbs->maxitems) | ||
1613 | { | ||
1614 | cnt_items[0] = (plrs[me].sitems * 100) / wbs->maxitems; | ||
1615 | S_StartSound(0, sfx_barexp); | ||
1616 | sp_state++; | ||
1617 | } | ||
1618 | } | ||
1619 | else if (sp_state == 6) | ||
1620 | { | ||
1621 | cnt_secret[0] += 2; | ||
1622 | |||
1623 | if (!(bcnt&3)) | ||
1624 | S_StartSound(0, sfx_pistol); | ||
1625 | |||
1626 | // killough 2/22/98: Make secrets = 100% if maxsecret = 0: | ||
1627 | if ((!wbs->maxsecret && compatibility_level < lxdoom_1_compatibility) || | ||
1628 | cnt_secret[0] >= (wbs->maxsecret ? | ||
1629 | (plrs[me].ssecret * 100) / wbs->maxsecret : 100)) | ||
1630 | { | ||
1631 | cnt_secret[0] = (wbs->maxsecret ? | ||
1632 | (plrs[me].ssecret * 100) / wbs->maxsecret : 100); | ||
1633 | S_StartSound(0, sfx_barexp); | ||
1634 | sp_state++; | ||
1635 | } | ||
1636 | } | ||
1637 | else if (sp_state == 8) | ||
1638 | { | ||
1639 | if (!(bcnt&3)) | ||
1640 | S_StartSound(0, sfx_pistol); | ||
1641 | |||
1642 | cnt_time += 3; | ||
1643 | |||
1644 | if (cnt_time >= plrs[me].stime / TICRATE) | ||
1645 | cnt_time = plrs[me].stime / TICRATE; | ||
1646 | |||
1647 | cnt_total_time += 3; | ||
1648 | |||
1649 | if (cnt_total_time >= wbs->totaltimes / TICRATE) | ||
1650 | cnt_total_time = wbs->totaltimes / TICRATE; | ||
1651 | |||
1652 | cnt_par += 3; | ||
1653 | |||
1654 | if (cnt_par >= wbs->partime / TICRATE) | ||
1655 | { | ||
1656 | cnt_par = wbs->partime / TICRATE; | ||
1657 | |||
1658 | if ((cnt_time >= plrs[me].stime / TICRATE) && (compatibility_level < lxdoom_1_compatibility || cnt_total_time >= wbs->totaltimes / TICRATE)) | ||
1659 | { | ||
1660 | S_StartSound(0, sfx_barexp); | ||
1661 | sp_state++; | ||
1662 | } | ||
1663 | } | ||
1664 | } | ||
1665 | else if (sp_state == 10) | ||
1666 | { | ||
1667 | if (acceleratestage) | ||
1668 | { | ||
1669 | S_StartSound(0, sfx_sgcock); | ||
1670 | |||
1671 | if (gamemode == commercial) | ||
1672 | WI_initNoState(); | ||
1673 | else | ||
1674 | WI_initShowNextLoc(); | ||
1675 | } | ||
1676 | } | ||
1677 | else if (sp_state & 1) | ||
1678 | { | ||
1679 | if (!--cnt_pause) | ||
1680 | { | ||
1681 | sp_state++; | ||
1682 | cnt_pause = TICRATE; | ||
1683 | } | ||
1684 | } | ||
1685 | } | ||
1686 | |||
1687 | |||
1688 | // ==================================================================== | ||
1689 | // WI_drawStats | ||
1690 | // Purpose: Put the solo stats on the screen | ||
1691 | // Args: none | ||
1692 | // Returns: void | ||
1693 | // | ||
1694 | // proff/nicolas 09/20/98 -- changed for hi-res | ||
1695 | // CPhipps - patch drawing updated | ||
1696 | void WI_drawStats(void) | ||
1697 | { | ||
1698 | // line height | ||
1699 | int lh; | ||
1700 | |||
1701 | lh = (3*SHORT(num[0]->height))/2; | ||
1702 | |||
1703 | WI_slamBackground(); | ||
1704 | |||
1705 | // draw animated background | ||
1706 | WI_drawAnimatedBack(); | ||
1707 | |||
1708 | WI_drawLF(); | ||
1709 | |||
1710 | V_DrawNamePatch(SP_STATSX, SP_STATSY, FB, kills, CR_DEFAULT, VPT_STRETCH); | ||
1711 | WI_drawPercent(320 - SP_STATSX, SP_STATSY, cnt_kills[0]); | ||
1712 | |||
1713 | V_DrawNamePatch(SP_STATSX, SP_STATSY+lh, FB, items, CR_DEFAULT, VPT_STRETCH); | ||
1714 | WI_drawPercent(320 - SP_STATSX, SP_STATSY+lh, cnt_items[0]); | ||
1715 | |||
1716 | V_DrawNamePatch(SP_STATSX, SP_STATSY+2*lh, FB, sp_secret, CR_DEFAULT, VPT_STRETCH); | ||
1717 | WI_drawPercent(320 - SP_STATSX, SP_STATSY+2*lh, cnt_secret[0]); | ||
1718 | |||
1719 | WI_drawTimeStats(cnt_time, cnt_total_time, cnt_par); | ||
1720 | } | ||
1721 | |||
1722 | // ==================================================================== | ||
1723 | // WI_checkForAccelerate | ||
1724 | // Purpose: See if the player has hit either the attack or use key | ||
1725 | // or mouse button. If so we set acceleratestage to 1 and | ||
1726 | // all those display routines above jump right to the end. | ||
1727 | // Args: none | ||
1728 | // Returns: void | ||
1729 | // | ||
1730 | void WI_checkForAccelerate(void) | ||
1731 | { | ||
1732 | int i; | ||
1733 | player_t *player; | ||
1734 | |||
1735 | // check for button presses to skip delays | ||
1736 | for (i=0, player = players ; i<MAXPLAYERS ; i++, player++) | ||
1737 | { | ||
1738 | if (playeringame[i]) | ||
1739 | { | ||
1740 | if (player->cmd.buttons & BT_ATTACK) | ||
1741 | { | ||
1742 | if (!player->attackdown) | ||
1743 | acceleratestage = 1; | ||
1744 | player->attackdown = true; | ||
1745 | } | ||
1746 | else | ||
1747 | player->attackdown = false; | ||
1748 | |||
1749 | if (player->cmd.buttons & BT_USE) | ||
1750 | { | ||
1751 | if (!player->usedown) | ||
1752 | acceleratestage = 1; | ||
1753 | player->usedown = true; | ||
1754 | } | ||
1755 | else | ||
1756 | player->usedown = false; | ||
1757 | } | ||
1758 | } | ||
1759 | } | ||
1760 | |||
1761 | // ==================================================================== | ||
1762 | // WI_Ticker | ||
1763 | // Purpose: Do various updates every gametic, for stats, animation, | ||
1764 | // checking that intermission music is running, etc. | ||
1765 | // Args: none | ||
1766 | // Returns: void | ||
1767 | // | ||
1768 | void WI_Ticker(void) | ||
1769 | { | ||
1770 | // counter for general background animation | ||
1771 | bcnt++; | ||
1772 | |||
1773 | if (bcnt == 1) | ||
1774 | { | ||
1775 | // intermission music | ||
1776 | if ( gamemode == commercial ) | ||
1777 | S_ChangeMusic(mus_dm2int, true); | ||
1778 | else | ||
1779 | S_ChangeMusic(mus_inter, true); | ||
1780 | } | ||
1781 | |||
1782 | WI_checkForAccelerate(); | ||
1783 | |||
1784 | switch (state) | ||
1785 | { | ||
1786 | case StatCount: | ||
1787 | if (deathmatch) WI_updateDeathmatchStats(); | ||
1788 | else if (netgame) WI_updateNetgameStats(); | ||
1789 | else WI_updateStats(); | ||
1790 | break; | ||
1791 | |||
1792 | case ShowNextLoc: | ||
1793 | WI_updateShowNextLoc(); | ||
1794 | break; | ||
1795 | |||
1796 | case NoState: | ||
1797 | WI_updateNoState(); | ||
1798 | break; | ||
1799 | } | ||
1800 | } | ||
1801 | |||
1802 | /* ==================================================================== | ||
1803 | * WI_loadData | ||
1804 | * Purpose: Initialize intermission data such as background graphics, | ||
1805 | * patches, map names, etc. | ||
1806 | * Args: none | ||
1807 | * Returns: void | ||
1808 | * | ||
1809 | * CPhipps - modified for new wad lump handling. | ||
1810 | * - no longer preload most graphics, other funcs can use | ||
1811 | * them by name | ||
1812 | */ | ||
1813 | |||
1814 | void WI_loadData(void) | ||
1815 | { | ||
1816 | int i; | ||
1817 | int j; | ||
1818 | char name[9]; // limited to 8 characters | ||
1819 | anim_t* a; | ||
1820 | |||
1821 | if (gamemode != commercial) | ||
1822 | { | ||
1823 | if (wbs->epsd < 3) | ||
1824 | { | ||
1825 | for (j=0;j<NUMANIMS[wbs->epsd];j++) | ||
1826 | { | ||
1827 | a = &anims[wbs->epsd][j]; | ||
1828 | for (i=0;i<a->nanims;i++) | ||
1829 | { | ||
1830 | // MONDO HACK! | ||
1831 | if (wbs->epsd != 1 || j != 8) | ||
1832 | { | ||
1833 | // animations | ||
1834 | snprintf(name, sizeof(name),"WIA%d%s%d%s%d", wbs->epsd, (j/10>0?"":"0"), j,(i/10>0?"":"0"), i); //ANOTHER ROCKHACK | ||
1835 | //snprintf(name, sizeof(name),"WIA%d%.2d%.2d", wbs->epsd, j, i); | ||
1836 | a->p[i] = W_CacheLumpName(name); | ||
1837 | } | ||
1838 | else | ||
1839 | { | ||
1840 | // HACK ALERT! | ||
1841 | a->p[i] = anims[1][4].p[i]; | ||
1842 | } | ||
1843 | } | ||
1844 | } | ||
1845 | } | ||
1846 | } | ||
1847 | |||
1848 | for (i=0;i<10;i++) | ||
1849 | { | ||
1850 | // numbers 0-9 | ||
1851 | snprintf(name,sizeof(name),"WINUM%d", i); | ||
1852 | num[i] = W_CacheLumpName(name); | ||
1853 | } | ||
1854 | } | ||
1855 | |||
1856 | // ==================================================================== | ||
1857 | // WI_unloadData | ||
1858 | // Purpose: Free up the space allocated during WI_loadData | ||
1859 | // Args: none | ||
1860 | // Returns: void | ||
1861 | // | ||
1862 | // CPhipps - reverse of WI_loadData, goes through the same lumps, but unlocking | ||
1863 | void WI_unloadData(void) | ||
1864 | { | ||
1865 | int i,j; | ||
1866 | char name[9]; // limited to 8 characters | ||
1867 | |||
1868 | // cph - unlock gamemode dependent stuff here | ||
1869 | if (gamemode != commercial) { | ||
1870 | if (wbs->epsd < 3) { | ||
1871 | for (j=0;j<NUMANIMS[wbs->epsd];j++) { | ||
1872 | anim_t* a = &anims[wbs->epsd][j]; | ||
1873 | for (i=0; i<a->nanims; i++) { | ||
1874 | // MONDO HACK! | ||
1875 | if (wbs->epsd != 1 || j != 8) { | ||
1876 | // animations | ||
1877 | snprintf(name, sizeof(name),"WIA%d%s%d%s%d", wbs->epsd, (j/10>0?"":"0"), j,(i/10>0?"":"0"), i); //ANOTHER ROCKHACK | ||
1878 | //snprintf(name,sizeof(name), "WIA%d%.2d%.2d", wbs->epsd, j, i); | ||
1879 | W_UnlockLumpName(name); | ||
1880 | } | ||
1881 | } | ||
1882 | } | ||
1883 | } | ||
1884 | } | ||
1885 | |||
1886 | for (i=0;i<10;i++) { | ||
1887 | // numbers 0-9 | ||
1888 | snprintf(name, sizeof(name),"WINUM%d", i); | ||
1889 | W_UnlockLumpName(name); | ||
1890 | } | ||
1891 | } | ||
1892 | |||
1893 | |||
1894 | // ==================================================================== | ||
1895 | // WI_Drawer | ||
1896 | // Purpose: Call the appropriate stats drawing routine depending on | ||
1897 | // what kind of game is being played (DM, coop, solo) | ||
1898 | // Args: none | ||
1899 | // Returns: void | ||
1900 | // | ||
1901 | void WI_Drawer (void) | ||
1902 | { | ||
1903 | switch (state) | ||
1904 | { | ||
1905 | case StatCount: | ||
1906 | if (deathmatch) | ||
1907 | WI_drawDeathmatchStats(); | ||
1908 | else if (netgame) | ||
1909 | WI_drawNetgameStats(); | ||
1910 | else | ||
1911 | WI_drawStats(); | ||
1912 | break; | ||
1913 | |||
1914 | case ShowNextLoc: | ||
1915 | WI_drawShowNextLoc(); | ||
1916 | break; | ||
1917 | |||
1918 | case NoState: | ||
1919 | WI_drawNoState(); | ||
1920 | break; | ||
1921 | } | ||
1922 | } | ||
1923 | |||
1924 | // ==================================================================== | ||
1925 | // WI_initVariables | ||
1926 | // Purpose: Initialize the intermission information structure | ||
1927 | // Note: wbstartstruct_t is defined in d_player.h | ||
1928 | // Args: wbstartstruct -- pointer to the structure with the data | ||
1929 | // Returns: void | ||
1930 | // | ||
1931 | void WI_initVariables(wbstartstruct_t* wbstartstruct) | ||
1932 | { | ||
1933 | |||
1934 | wbs = wbstartstruct; | ||
1935 | |||
1936 | #ifdef RANGECHECKING | ||
1937 | if (gamemode != commercial) | ||
1938 | { | ||
1939 | if ( gamemode == retail ) | ||
1940 | RNGCHECK(wbs->epsd, 0, 3); | ||
1941 | else | ||
1942 | RNGCHECK(wbs->epsd, 0, 2); | ||
1943 | } | ||
1944 | else | ||
1945 | { | ||
1946 | RNGCHECK(wbs->last, 0, 8); | ||
1947 | RNGCHECK(wbs->next, 0, 8); | ||
1948 | } | ||
1949 | RNGCHECK(wbs->pnum, 0, MAXPLAYERS); | ||
1950 | RNGCHECK(wbs->pnum, 0, MAXPLAYERS); | ||
1951 | #endif | ||
1952 | |||
1953 | acceleratestage = 0; | ||
1954 | cnt = bcnt = 0; | ||
1955 | firstrefresh = 1; | ||
1956 | me = wbs->pnum; | ||
1957 | plrs = wbs->plyr; | ||
1958 | |||
1959 | if (!wbs->maxkills) | ||
1960 | wbs->maxkills = 1; // probably only useful in MAP30 | ||
1961 | |||
1962 | if (!wbs->maxitems) | ||
1963 | wbs->maxitems = 1; | ||
1964 | |||
1965 | if ( gamemode != retail ) | ||
1966 | if (wbs->epsd > 2) | ||
1967 | wbs->epsd -= 3; | ||
1968 | } | ||
1969 | |||
1970 | // ==================================================================== | ||
1971 | // WI_Start | ||
1972 | // Purpose: Call the various init routines | ||
1973 | // Note: wbstartstruct_t is defined in d_player.h | ||
1974 | // Args: wbstartstruct -- pointer to the structure with the | ||
1975 | // intermission data | ||
1976 | // Returns: void | ||
1977 | // | ||
1978 | void WI_Start(wbstartstruct_t* wbstartstruct) | ||
1979 | { | ||
1980 | WI_initVariables(wbstartstruct); | ||
1981 | WI_loadData(); | ||
1982 | |||
1983 | if (deathmatch) | ||
1984 | WI_initDeathmatchStats(); | ||
1985 | else if (netgame) | ||
1986 | WI_initNetgameStats(); | ||
1987 | else | ||
1988 | WI_initStats(); | ||
1989 | } | ||