1 // SONIC ROBO BLAST 2
2 //-----------------------------------------------------------------------------
3 // Copyright (C) 1993-1996 by id Software, Inc.
4 // Copyright (C) 1998-2000 by DooM Legacy Team.
5 // Copyright (C) 1999-2020 by Sonic Team Junior.
6 //
7 // This program is free software distributed under the
8 // terms of the GNU General Public License, version 2.
9 // See the 'LICENSE' file for more details.
10 //-----------------------------------------------------------------------------
11 /// \file  doomstat.h
12 /// \brief All the global variables that store the internal state.
13 ///
14 ///        Theoretically speaking, the internal state of the engine
15 ///        should be found by looking at the variables collected
16 ///        here, and every relevant module will have to include
17 ///        this header file. In practice... things are a bit messy.
18 
19 #ifndef __DOOMSTAT__
20 #define __DOOMSTAT__
21 
22 // We need globally shared data structures, for defining the global state variables.
23 #include "doomdata.h"
24 
25 // We need the player data structure as well.
26 #include "d_player.h"
27 
28 // =============================
29 // Selected map etc.
30 // =============================
31 
32 // Selected by user.
33 extern INT16 gamemap;
34 extern char mapmusname[7];
35 extern UINT16 mapmusflags;
36 extern UINT32 mapmusposition;
37 #define MUSIC_TRACKMASK   0x0FFF // ----************
38 #define MUSIC_RELOADRESET 0x8000 // *---------------
39 #define MUSIC_FORCERESET  0x4000 // -*--------------
40 // Use other bits if necessary.
41 
42 extern UINT32 maptol;
43 extern UINT8 globalweather;
44 extern INT32 curWeather;
45 extern INT32 cursaveslot;
46 //extern INT16 lastmapsaved;
47 extern INT16 lastmaploaded;
48 extern UINT8 gamecomplete;
49 
50 // Extra abilities/settings for skins (combinable stuff)
51 typedef enum
52 {
53 	MA_RUNNING     = 1,    // In action
54 	MA_INIT        = 1<<1, // Initialisation
55 	MA_NOCUTSCENES = 1<<2, // No cutscenes
56 	MA_INGAME      = 1<<3  // Timer ignores loads
57 } marathonmode_t;
58 
59 extern marathonmode_t marathonmode;
60 extern tic_t marathontime;
61 
62 #define maxgameovers 13
63 extern UINT8 numgameovers;
64 extern SINT8 startinglivesbalance[maxgameovers+1];
65 
66 #define PRECIP_NONE  0
67 #define PRECIP_STORM 1
68 #define PRECIP_SNOW  2
69 #define PRECIP_RAIN  3
70 #define PRECIP_BLANK 4
71 #define PRECIP_STORM_NORAIN 5
72 #define PRECIP_STORM_NOSTRIKES 6
73 
74 // Set if homebrew PWAD stuff has been added.
75 extern boolean modifiedgame;
76 extern UINT16 mainwads;
77 extern boolean savemoddata; // This mod saves time/emblem data.
78 extern boolean disableSpeedAdjust; // Don't alter the duration of player states if true
79 extern boolean imcontinuing; // Temporary flag while continuing
80 extern boolean metalrecording;
81 
82 #define ATTACKING_NONE   0
83 #define ATTACKING_RECORD 1
84 #define ATTACKING_NIGHTS 2
85 extern UINT8 modeattacking;
86 
87 // menu demo things
88 extern UINT8  numDemos;
89 extern UINT32 demoDelayTime;
90 extern UINT32 demoIdleTime;
91 
92 // Netgame? only true in a netgame
93 extern boolean netgame;
94 extern boolean addedtogame; // true after the server has added you
95 // Only true if >1 player. netgame => multiplayer but not (multiplayer=>netgame)
96 extern boolean multiplayer;
97 
98 extern INT16 gametype;
99 extern UINT32 gametyperules;
100 extern INT16 gametypecount;
101 
102 extern boolean splitscreen;
103 extern boolean circuitmap; // Does this level have 'circuit mode'?
104 extern boolean fromlevelselect;
105 
106 // ========================================
107 // Internal parameters for sound rendering.
108 // ========================================
109 
110 extern boolean midi_disabled;
111 extern boolean sound_disabled;
112 extern boolean digital_disabled;
113 
114 // =========================
115 // Status flags for refresh.
116 // =========================
117 //
118 
119 extern boolean menuactive; // Menu overlaid?
120 extern UINT8 paused; // Game paused?
121 extern UINT8 window_notinfocus; // are we in focus? (backend independant -- handles auto pausing and display of "focus lost" message)
122 
123 extern boolean nodrawers;
124 extern boolean noblit;
125 extern boolean lastdraw;
126 extern postimg_t postimgtype;
127 extern INT32 postimgparam;
128 extern postimg_t postimgtype2;
129 extern INT32 postimgparam2;
130 
131 extern INT32 viewwindowx, viewwindowy;
132 extern INT32 viewwidth, scaledviewwidth;
133 
134 extern boolean gamedataloaded;
135 
136 // Player taking events, and displaying.
137 extern INT32 consoleplayer;
138 extern INT32 displayplayer;
139 extern INT32 secondarydisplayplayer; // for splitscreen
140 
141 // Maps of special importance
142 extern INT16 spstage_start, spmarathon_start;
143 extern INT16 sstage_start, sstage_end, smpstage_start, smpstage_end;
144 
145 extern INT16 titlemap;
146 extern boolean hidetitlepics;
147 extern INT16 bootmap; //bootmap for loading a map on startup
148 
149 extern INT16 tutorialmap; // map to load for tutorial
150 extern boolean tutorialmode; // are we in a tutorial right now?
151 extern INT32 tutorialgcs; // which control scheme is loaded?
152 extern INT32 tutorialusemouse; // store cv_usemouse user value
153 extern INT32 tutorialfreelook; // store cv_alwaysfreelook user value
154 extern INT32 tutorialmousemove; // store cv_mousemove user value
155 extern INT32 tutorialanalog; // store cv_analog[0] user value
156 
157 extern boolean looptitle;
158 
159 // CTF colors.
160 extern UINT16 skincolor_redteam, skincolor_blueteam, skincolor_redring, skincolor_bluering;
161 
162 extern tic_t countdowntimer;
163 extern boolean countdowntimeup;
164 extern boolean exitfadestarted;
165 
166 typedef struct
167 {
168 	UINT8 numpics;
169 	char picname[8][8];
170 	UINT8 pichires[8];
171 	char *text;
172 	UINT16 xcoord[8];
173 	UINT16 ycoord[8];
174 	UINT16 picduration[8];
175 	UINT8 musicloop;
176 	UINT16 textxpos;
177 	UINT16 textypos;
178 
179 	char   musswitch[7];
180 	UINT16 musswitchflags;
181 	UINT32 musswitchposition;
182 
183 	UINT8 fadecolor; // Color number for fade, 0 means don't do the first fade
184 	UINT8 fadeinid;  // ID of the first fade, to a color -- ignored if fadecolor is 0
185 	UINT8 fadeoutid; // ID of the second fade, to the new screen
186 } scene_t; // TODO: It would probably behoove us to implement subsong/track selection here, too, but I'm lazy -SH
187 
188 typedef struct
189 {
190 	scene_t scene[128]; // 128 scenes per cutscene.
191 	INT32 numscenes; // Number of scenes in this cutscene
192 } cutscene_t;
193 
194 extern cutscene_t *cutscenes[128];
195 
196 // Reserve prompt space for tutorials
197 #define TUTORIAL_PROMPT 201 // one-based
198 #define TUTORIAL_AREAS 6
199 #define TUTORIAL_AREA_PROMPTS 5
200 #define MAX_PROMPTS (TUTORIAL_PROMPT+TUTORIAL_AREAS*TUTORIAL_AREA_PROMPTS*3) // 3 control modes
201 #define MAX_PAGES 128
202 
203 #define PROMPT_PIC_PERSIST 0
204 #define PROMPT_PIC_LOOP 1
205 #define PROMPT_PIC_DESTROY 2
206 #define MAX_PROMPT_PICS 8
207 typedef struct
208 {
209 	UINT8 numpics;
210 	UINT8 picmode; // sequence mode after displaying last pic, 0 = persist, 1 = loop, 2 = destroy
211 	UINT8 pictoloop; // if picmode == loop, which pic to loop to?
212 	UINT8 pictostart; // initial pic number to show
213 	char picname[MAX_PROMPT_PICS][8];
214 	UINT8 pichires[MAX_PROMPT_PICS];
215 	UINT16 xcoord[MAX_PROMPT_PICS]; // gfx
216 	UINT16 ycoord[MAX_PROMPT_PICS]; // gfx
217 	UINT16 picduration[MAX_PROMPT_PICS];
218 
219 	char   musswitch[7];
220 	UINT16 musswitchflags;
221 	UINT8 musicloop;
222 
223 	char tag[33]; // page tag
224 	char name[34]; // narrator name, extra char for color
225 	char iconname[8]; // narrator icon lump
226 	boolean rightside; // narrator side, false = left, true = right
227 	boolean iconflip; // narrator flip icon horizontally
228 	UINT8 hidehud; // hide hud, 0 = show all, 1 = hide depending on prompt position (top/bottom), 2 = hide all
229 	UINT8 lines; // # of lines to show. If name is specified, name takes one of the lines. If 0, defaults to 4.
230 	INT32 backcolor; // see CON_SetupBackColormap: 0-11, INT32_MAX for user-defined (CONS_BACKCOLOR)
231 	UINT8 align; // text alignment, 0 = left, 1 = right, 2 = center
232 	UINT8 verticalalign; // vertical text alignment, 0 = top, 1 = bottom, 2 = middle
233 	UINT8 textspeed; // text speed, delay in tics between characters.
234 	sfxenum_t textsfx; // sfx_ id for printing text
235 	UINT8 nextprompt; // next prompt to jump to, one-based. 0 = current prompt
236 	UINT8 nextpage; // next page to jump to, one-based. 0 = next page within prompt->numpages
237 	char nexttag[33]; // next tag to jump to. If set, this overrides nextprompt and nextpage.
238 	INT32 timetonext; // time in tics to jump to next page automatically. 0 = don't jump automatically
239 	char *text;
240 } textpage_t;
241 
242 typedef struct
243 {
244 	textpage_t page[MAX_PAGES];
245 	INT32 numpages; // Number of pages in this prompt
246 } textprompt_t;
247 
248 extern textprompt_t *textprompts[MAX_PROMPTS];
249 
250 // For the Custom Exit linedef.
251 extern INT16 nextmapoverride;
252 extern UINT8 skipstats;
253 
254 extern UINT32 ssspheres; //  Total # of spheres in a level
255 
256 // Fun extra stuff
257 extern INT16 lastmap; // Last level you were at (returning from special stages).
258 extern mobj_t *redflag, *blueflag; // Pointers to physical flags
259 extern mapthing_t *rflagpoint, *bflagpoint; // Pointers to the flag spawn locations
260 #define GF_REDFLAG 1
261 #define GF_BLUEFLAG 2
262 
263 // A single point in space.
264 typedef struct
265 {
266 	fixed_t x, y, z;
267 } mappoint_t;
268 
269 extern struct quake
270 {
271 	// camera offsets and duration
272 	fixed_t x,y,z;
273 	UINT16 time;
274 
275 	// location, radius, and intensity...
276 	mappoint_t *epicenter;
277 	fixed_t radius, intensity;
278 } quake;
279 
280 // NiGHTS grades
281 typedef struct
282 {
283 	UINT32 grade[6]; // D, C, B, A, S, X (F: failed to reach any of these)
284 } nightsgrades_t;
285 
286 // Custom Lua values
287 // (This is not ifdeffed so the map header structure can stay identical, just in case.)
288 typedef struct
289 {
290 	char option[32]; // 31 usable characters
291 	char value[256]; // 255 usable characters. If this seriously isn't enough then wtf.
292 } customoption_t;
293 
294 /** Map header information.
295   */
296 typedef struct
297 {
298 	// The original eight, plus one.
299 	char lvlttl[22];       ///< Level name without "Zone". (21 character limit instead of 32, 21 characters can display on screen max anyway)
300 	char subttl[33];       ///< Subtitle for level
301 	UINT8 actnum;          ///< Act number or 0 for none.
302 	UINT32 typeoflevel;    ///< Combination of typeoflevel flags.
303 	INT16 nextlevel;       ///< Map number of next level, or 1100-1102 to end.
304 	INT16 marathonnext;    ///< See nextlevel, but for Marathon mode. Necessary to support hub worlds ala SUGOI.
305 	char keywords[33];     ///< Keywords separated by space to search for. 32 characters.
306 	char musname[7];       ///< Music track to play. "" for no music.
307 	UINT16 mustrack;       ///< Subsong to play. Only really relevant for music modules and specific formats supported by GME. 0 to ignore.
308 	UINT32 muspos;    ///< Music position to jump to.
309 	char forcecharacter[17];  ///< (SKINNAMESIZE+1) Skin to switch to or "" to disable.
310 	UINT8 weather;         ///< 0 = sunny day, 1 = storm, 2 = snow, 3 = rain, 4 = blank, 5 = thunder w/o rain, 6 = rain w/o lightning, 7 = heat wave.
311 	INT16 skynum;          ///< Sky number to use.
312 	INT16 skybox_scalex;   ///< Skybox X axis scale. (0 = no movement, 1 = 1:1 movement, 16 = 16:1 slow movement, -4 = 1:4 fast movement, etc.)
313 	INT16 skybox_scaley;   ///< Skybox Y axis scale.
314 	INT16 skybox_scalez;   ///< Skybox Z axis scale.
315 
316 	// Extra information.
317 	char interscreen[8];  ///< 320x200 patch to display at intermission.
318 	char runsoc[33];      ///< SOC to execute at start of level (32 character limit instead of 63)
319 	char scriptname[33];  ///< Script to use when the map is switched to. (32 character limit instead of 191)
320 	UINT8 precutscenenum; ///< Cutscene number to play BEFORE a level starts.
321 	UINT8 cutscenenum;    ///< Cutscene number to use, 0 for none.
322 	INT16 countdown;      ///< Countdown until level end?
323 	UINT16 palette;       ///< PAL lump to use on this map
324 	UINT8 numlaps;        ///< Number of laps in circuit mode, unless overridden.
325 	SINT8 unlockrequired; ///< Is an unlockable required to play this level? -1 if no.
326 	UINT8 levelselect;    ///< Is this map available in the level select? If so, which map list is it available in?
327 	SINT8 bonustype;      ///< What type of bonus does this level have? (-1 for null.)
328 	SINT8 maxbonuslives;  ///< How many bonus lives to award at Intermission? (-1 for unlimited.)
329 
330 	UINT16 levelflags;     ///< LF_flags:  merged booleans into one UINT16 for space, see below
331 	UINT8 menuflags;      ///< LF2_flags: options that affect record attack / nights mode menus
332 
333 	char selectheading[22]; ///< Level select heading. Allows for controllable grouping.
334 	UINT16 startrings;      ///< Number of rings players start with.
335 	INT32 sstimer;          ///< Timer for special stages.
336 	UINT32 ssspheres;       ///< Sphere requirement in special stages.
337 	fixed_t gravity;        ///< Map-wide gravity.
338 
339 	// Title card.
340 	char ltzzpatch[8];      ///< Zig zag patch.
341 	char ltzztext[8];       ///< Zig zag text.
342 	char ltactdiamond[8];   ///< Act diamond.
343 
344 	// Freed animals stuff.
345 	UINT8 numFlickies;     ///< Internal. For freed flicky support.
346 	mobjtype_t *flickies;  ///< List of freeable flickies in this level. Allocated dynamically for space reasons. Be careful.
347 
348 	// NiGHTS stuff.
349 	UINT8 numGradedMares;   ///< Internal. For grade support.
350 	nightsgrades_t *grades; ///< NiGHTS grades. Allocated dynamically for space reasons. Be careful.
351 
352 	// Music stuff.
353 	UINT32 musinterfadeout;  ///< Fade out level music on intermission screen in milliseconds
354 	char musintername[7];    ///< Intermission screen music.
355 
356 	char muspostbossname[7];    ///< Post-bossdeath music.
357 	UINT16 muspostbosstrack;    ///< Post-bossdeath track.
358 	UINT32 muspostbosspos;      ///< Post-bossdeath position
359 	UINT32 muspostbossfadein;   ///< Post-bossdeath fade-in milliseconds.
360 
361 	SINT8 musforcereset; ///< Force resetmusic (-1 for default; 0 for force off; 1 for force on)
362 
363 	// Lua stuff.
364 	// (This is not ifdeffed so the map header structure can stay identical, just in case.)
365 	UINT8 numCustomOptions;     ///< Internal. For Lua custom value support.
366 	customoption_t *customopts; ///< Custom options. Allocated dynamically for space reasons. Be careful.
367 } mapheader_t;
368 
369 // level flags
370 #define LF_SCRIPTISFILE       (1<<0) ///< True if the script is a file, not a lump.
371 #define LF_SPEEDMUSIC         (1<<1) ///< Speed up act music for super sneakers
372 #define LF_NOSSMUSIC          (1<<2) ///< Disable Super Sonic music
373 #define LF_NORELOAD           (1<<3) ///< Don't reload level on death
374 #define LF_NOZONE             (1<<4) ///< Don't include "ZONE" on level title
375 #define LF_SAVEGAME           (1<<5) ///< Save the game upon loading this level
376 #define LF_MIXNIGHTSCOUNTDOWN (1<<6) ///< Play sfx_timeup instead of music change for NiGHTS countdown
377 #define LF_WARNINGTITLE       (1<<7) ///< WARNING! WARNING! WARNING! WARNING!
378 
379 #define LF_NOTITLECARDFIRST        (1<<8)
380 #define LF_NOTITLECARDRESPAWN      (1<<9)
381 #define LF_NOTITLECARDRECORDATTACK (1<<10)
382 #define LF_NOTITLECARD  (LF_NOTITLECARDFIRST|LF_NOTITLECARDRESPAWN|LF_NOTITLECARDRECORDATTACK) ///< Don't start the title card at all
383 
384 #define LF2_HIDEINMENU     1 ///< Hide in the multiplayer menu
385 #define LF2_HIDEINSTATS    2 ///< Hide in the statistics screen
386 #define LF2_RECORDATTACK   4 ///< Show this map in Time Attack
387 #define LF2_NIGHTSATTACK   8 ///< Show this map in NiGHTS mode menu
388 #define LF2_NOVISITNEEDED 16 ///< Available in time attack/nights mode without visiting the level
389 #define LF2_WIDEICON      32 ///< If you're in a circumstance where it fits, use a wide map icon
390 
391 extern mapheader_t* mapheaderinfo[NUMMAPS];
392 
393 // Gametypes
394 #define NUMGAMETYPEFREESLOTS 128
395 enum GameType
396 {
397 	GT_COOP = 0, // also used in single player
398 	GT_COMPETITION, // Classic "Race"
399 	GT_RACE,
400 
401 	GT_MATCH,
402 	GT_TEAMMATCH,
403 
404 	GT_TAG,
405 	GT_HIDEANDSEEK,
406 
407 	GT_CTF, // capture the flag
408 
409 	GT_FIRSTFREESLOT,
410 	GT_LASTFREESLOT = GT_FIRSTFREESLOT + NUMGAMETYPEFREESLOTS - 1,
411 	NUMGAMETYPES
412 };
413 // If you alter this list, update deh_tables.c, MISC_ChangeGameTypeMenu in m_menu.c, and Gametype_Names in g_game.c
414 
415 // Gametype rules
416 enum GameTypeRules
417 {
418 	GTR_CAMPAIGN         = 1,     // Linear Co-op map progression, don't allow random maps
419 	GTR_RINGSLINGER      = 1<<1,  // Outside of Co-op, Competition, and Race (overriden by cv_ringslinger)
420 	GTR_SPECTATORS       = 1<<2,  // Outside of Co-op, Competition, and Race
421 	GTR_LIVES            = 1<<3,  // Co-op and Competition
422 	GTR_TEAMS            = 1<<4,  // Team Match, CTF
423 	GTR_FIRSTPERSON      = 1<<5,  // First person camera
424 	GTR_POWERSTONES      = 1<<6,  // Power stones (Match and CTF)
425 	GTR_TEAMFLAGS        = 1<<7,  // Gametype has team flags (CTF)
426 	GTR_FRIENDLY         = 1<<8,  // Co-op
427 	GTR_SPECIALSTAGES    = 1<<9,  // Allow special stages
428 	GTR_EMERALDTOKENS    = 1<<10, // Spawn emerald tokens
429 	GTR_EMERALDHUNT      = 1<<11, // Emerald Hunt
430 	GTR_RACE             = 1<<12, // Race and Competition
431 	GTR_TAG              = 1<<13, // Tag and Hide and Seek
432 	GTR_POINTLIMIT       = 1<<14, // Ringslinger point limit
433 	GTR_TIMELIMIT        = 1<<15, // Ringslinger time limit
434 	GTR_OVERTIME         = 1<<16, // Allow overtime
435 	GTR_HURTMESSAGES     = 1<<17, // Hit and death messages
436 	GTR_FRIENDLYFIRE     = 1<<18, // Always allow friendly fire
437 	GTR_STARTCOUNTDOWN   = 1<<19, // Hide time countdown (Tag and Hide and Seek)
438 	GTR_HIDEFROZEN       = 1<<20, // Frozen after hide time (Hide and Seek, but not Tag)
439 	GTR_BLINDFOLDED      = 1<<21, // Blindfolded view (Tag and Hide and Seek)
440 	GTR_RESPAWNDELAY     = 1<<22, // Respawn delay
441 	GTR_PITYSHIELD       = 1<<23, // Award pity shield
442 	GTR_DEATHPENALTY     = 1<<24, // Death score penalty
443 	GTR_NOSPECTATORSPAWN = 1<<25, // Use with GTR_SPECTATORS, spawn in the map instead of with the spectators
444 	GTR_DEATHMATCHSTARTS = 1<<26, // Use deathmatch starts
445 	GTR_SPAWNINVUL       = 1<<27, // Babysitting deterrent
446 	GTR_SPAWNENEMIES     = 1<<28, // Spawn enemies
447 	GTR_ALLOWEXIT        = 1<<29, // Allow exit sectors
448 	GTR_NOTITLECARD      = 1<<30, // Don't show the title card
449 	GTR_CUTSCENES        = 1<<31, // Play cutscenes, ending, credits, and evaluation
450 };
451 
452 // String names for gametypes
453 extern const char *Gametype_Names[NUMGAMETYPES];
454 extern const char *Gametype_ConstantNames[NUMGAMETYPES];
455 
456 // Point and time limits for every gametype
457 extern INT32 pointlimits[NUMGAMETYPES];
458 extern INT32 timelimits[NUMGAMETYPES];
459 
460 // TypeOfLevel things
461 enum TypeOfLevel
462 {
463 	TOL_SP          = 0x01, ///< Single Player
464 	TOL_COOP        = 0x02, ///< Cooperative
465 	TOL_COMPETITION = 0x04, ///< Competition
466 	TOL_RACE        = 0x08, ///< Race
467 // Single Player default = 15
468 
469 	TOL_MATCH       = 0x10, ///< Match
470 	TOL_TAG         = 0x20, ///< Tag
471 // Match/Tag default = 48
472 
473 	TOL_CTF         = 0x40, ///< Capture the Flag
474 // CTF default = 64
475 
476 	// 0x80 was here
477 
478 	TOL_2D     = 0x0100, ///< 2D
479 	TOL_MARIO  = 0x0200, ///< Mario
480 	TOL_NIGHTS = 0x0400, ///< NiGHTS
481 	TOL_ERZ3   = 0x0800, ///< ERZ3
482 	TOL_XMAS   = 0x1000, ///< Christmas NiGHTS
483 };
484 
485 #define MAXTOL             (1<<31)
486 #define NUMBASETOLNAMES    (19)
487 #define NUMTOLNAMES        (NUMBASETOLNAMES + NUMGAMETYPEFREESLOTS)
488 
489 typedef struct
490 {
491 	const char *name;
492 	UINT32 flag;
493 } tolinfo_t;
494 extern tolinfo_t TYPEOFLEVEL[NUMTOLNAMES];
495 extern UINT32 lastcustomtol;
496 
497 extern tic_t totalplaytime;
498 
499 extern UINT8 stagefailed;
500 
501 // Emeralds stored as bits to throw savegame hackers off.
502 extern UINT16 emeralds;
503 #define EMERALD1 1
504 #define EMERALD2 2
505 #define EMERALD3 4
506 #define EMERALD4 8
507 #define EMERALD5 16
508 #define EMERALD6 32
509 #define EMERALD7 64
510 #define ALL7EMERALDS(v) ((v & (EMERALD1|EMERALD2|EMERALD3|EMERALD4|EMERALD5|EMERALD6|EMERALD7)) == (EMERALD1|EMERALD2|EMERALD3|EMERALD4|EMERALD5|EMERALD6|EMERALD7))
511 
512 #define NUM_LUABANKS 16 // please only make this number go up between versions, never down. you'll break saves otherwise. also, must fit in UINT8
513 extern INT32 luabanks[NUM_LUABANKS];
514 
515 extern INT32 nummaprings; //keep track of spawned rings/coins
516 
517 /** Time attack information, currently a very small structure.
518   */
519 typedef struct
520 {
521 	tic_t time;   ///< Time in which the level was finished.
522 	UINT32 score; ///< Score when the level was finished.
523 	UINT16 rings; ///< Rings when the level was finished.
524 } recorddata_t;
525 
526 /** Setup for one NiGHTS map.
527   * These are dynamically allocated because I am insane
528   */
529 #define GRADE_F 0
530 #define GRADE_E 1
531 #define GRADE_D 2
532 #define GRADE_C 3
533 #define GRADE_B 4
534 #define GRADE_A 5
535 #define GRADE_S 6
536 
537 typedef struct
538 {
539 	// 8 mares, 1 overall (0)
540 	UINT8	nummares;
541 	UINT32	score[9];
542 	UINT8	grade[9];
543 	tic_t	time[9];
544 } nightsdata_t;
545 
546 extern nightsdata_t *nightsrecords[NUMMAPS];
547 extern recorddata_t *mainrecords[NUMMAPS];
548 
549 // mapvisited is now a set of flags that says what we've done in the map.
550 #define MV_VISITED      1
551 #define MV_BEATEN       2
552 #define MV_ALLEMERALDS  4
553 #define MV_ULTIMATE     8
554 #define MV_PERFECT     16
555 #define MV_PERFECTRA   32
556 #define MV_MAX         63 // used in gamedata check, update whenever MV's are added
557 #define MV_MP         128
558 extern UINT8 mapvisited[NUMMAPS];
559 
560 // Temporary holding place for nights data for the current map
561 extern nightsdata_t ntemprecords;
562 
563 extern UINT32 token; ///< Number of tokens collected in a level
564 extern UINT32 tokenlist; ///< List of tokens collected
565 extern boolean gottoken; ///< Did you get a token? Used for end of act
566 extern INT32 tokenbits; ///< Used for setting token bits
567 extern INT32 sstimer; ///< Time allotted in the special stage
568 extern UINT32 bluescore; ///< Blue Team Scores
569 extern UINT32 redscore;  ///< Red Team Scores
570 
571 // Eliminates unnecessary searching.
572 extern boolean CheckForBustableBlocks;
573 extern boolean CheckForBouncySector;
574 extern boolean CheckForQuicksand;
575 extern boolean CheckForMarioBlocks;
576 extern boolean CheckForFloatBob;
577 extern boolean CheckForReverseGravity;
578 
579 // Powerup durations
580 extern UINT16 invulntics;
581 extern UINT16 sneakertics;
582 extern UINT16 flashingtics;
583 extern UINT16 tailsflytics;
584 extern UINT16 underwatertics;
585 extern UINT16 spacetimetics;
586 extern UINT16 extralifetics;
587 extern UINT16 nightslinktics;
588 
589 extern UINT8 introtoplay;
590 extern UINT8 creditscutscene;
591 extern UINT8 useBlackRock;
592 
593 extern UINT8 use1upSound;
594 extern UINT8 maxXtraLife; // Max extra lives from rings
595 extern UINT8 useContinues;
596 #define continuesInSession (!multiplayer && (ultimatemode || (useContinues && !marathonmode) || (!modeattacking && !(cursaveslot > 0))))
597 
598 extern mobj_t *hunt1, *hunt2, *hunt3; // Emerald hunt locations
599 
600 // For racing
601 extern UINT32 countdown;
602 extern UINT32 countdown2;
603 
604 extern fixed_t gravity;
605 
606 //for CTF balancing
607 extern INT16 autobalance;
608 extern INT16 teamscramble;
609 extern INT16 scrambleplayers[MAXPLAYERS]; //for CTF team scramble
610 extern INT16 scrambleteams[MAXPLAYERS]; //for CTF team scramble
611 extern INT16 scrambletotal; //for CTF team scramble
612 extern INT16 scramblecount; //for CTF team scramble
613 
614 extern INT32 cheats;
615 
616 extern tic_t hidetime;
617 
618 extern UINT32 timesBeaten; // # of times the game has been beaten.
619 extern UINT32 timesBeatenWithEmeralds;
620 extern UINT32 timesBeatenUltimate;
621 
622 // ===========================
623 // Internal parameters, fixed.
624 // ===========================
625 // These are set by the engine, and not changed
626 //  according to user inputs. Partly load from
627 //  WAD, partly set at startup time.
628 
629 extern tic_t gametic;
630 #define localgametic leveltime
631 
632 // Player spawn spots.
633 extern mapthing_t *playerstarts[MAXPLAYERS]; // Cooperative
634 extern mapthing_t *bluectfstarts[MAXPLAYERS]; // CTF
635 extern mapthing_t *redctfstarts[MAXPLAYERS]; // CTF
636 
637 #define WAYPOINTSEQUENCESIZE 256
638 #define NUMWAYPOINTSEQUENCES 256
639 extern mobj_t *waypoints[NUMWAYPOINTSEQUENCES][WAYPOINTSEQUENCESIZE];
640 extern UINT16 numwaypoints[NUMWAYPOINTSEQUENCES];
641 
642 void P_AddWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint);
643 mobj_t *P_GetFirstWaypoint(UINT8 sequence);
644 mobj_t *P_GetLastWaypoint(UINT8 sequence);
645 mobj_t *P_GetPreviousWaypoint(mobj_t *current, boolean wrap);
646 mobj_t *P_GetNextWaypoint(mobj_t *current, boolean wrap);
647 mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo);
648 boolean P_IsDegeneratedWaypointSequence(UINT8 sequence);
649 
650 // =====================================
651 // Internal parameters, used for engine.
652 // =====================================
653 
654 #if defined (macintosh)
655 #define DEBFILE(msg) I_OutputMsg(msg)
656 #else
657 #define DEBUGFILE
658 #ifdef DEBUGFILE
659 #define DEBFILE(msg) { if (debugfile) { fputs(msg, debugfile); fflush(debugfile); } }
660 #else
661 #define DEBFILE(msg) {}
662 #endif
663 #endif
664 
665 #ifdef DEBUGFILE
666 extern FILE *debugfile;
667 extern INT32 debugload;
668 #endif
669 
670 // if true, load all graphics at level load
671 extern boolean precache;
672 
673 // wipegamestate can be set to -1
674 //  to force a wipe on the next draw
675 extern gamestate_t wipegamestate;
676 extern INT16 wipetypepre;
677 extern INT16 wipetypepost;
678 
679 // debug flag to cancel adaptiveness
680 extern boolean singletics;
681 
682 // =============
683 // Netgame stuff
684 // =============
685 
686 #include "d_clisrv.h"
687 
688 extern consvar_t cv_timetic; // display high resolution timer
689 extern consvar_t cv_powerupdisplay; // display powerups
690 extern consvar_t cv_showinputjoy; // display joystick in time attack
691 extern consvar_t cv_forceskin; // force clients to use the server's skin
692 extern consvar_t cv_downloading; // allow clients to downloading WADs.
693 extern ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS];
694 extern INT32 serverplayer;
695 extern INT32 adminplayers[MAXPLAYERS];
696 
697 /// \note put these in d_clisrv outright?
698 
699 #endif //__DOOMSTAT__
700