/
g_levellocals.h
775 lines (662 loc) · 24.7 KB
/
g_levellocals.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
/*
** g_levellocals.h
** The static data for a level
**
**---------------------------------------------------------------------------
** Copyright 1998-2016 Randy Heit
** Copyright 2005-2017 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#pragma once
#include "doomdata.h"
#include "g_level.h"
#include "r_defs.h"
#include "r_sky.h"
#include "portal.h"
#include "p_blockmap.h"
#include "p_local.h"
#include "po_man.h"
#include "p_acs.h"
#include "p_tags.h"
#include "p_spec.h"
#include "actor.h"
#include "b_bot.h"
#include "p_effect.h"
#include "d_player.h"
#include "p_destructible.h"
#include "r_data/r_sections.h"
#include "r_data/r_canvastexture.h"
#include "r_data/r_interpolate.h"
//============================================================================
//
// This is used to mark processed portals for some collection functions.
//
//============================================================================
struct FPortalBits
{
TArray<uint32_t> data;
void setSize(int num)
{
data.Resize((num + 31) / 32);
clear();
}
void clear()
{
memset(&data[0], 0, data.Size() * sizeof(uint32_t));
}
void setBit(int group)
{
data[group >> 5] |= (1 << (group & 31));
}
int getBit(int group)
{
return data[group >> 5] & (1 << (group & 31));
}
};
class DACSThinker;
class DFraggleThinker;
class DSpotState;
class DSeqNode;
struct FStrifeDialogueNode;
class DAutomapBase;
struct wbstartstruct_t;
class DSectorMarker;
struct FTranslator;
struct EventManager;
typedef TMap<int, int> FDialogueIDMap; // maps dialogue IDs to dialogue array index (for ACS)
typedef TMap<FName, int> FDialogueMap; // maps actor class names to dialogue array index
typedef TMap<int, FUDMFKeys> FUDMFKeyMap;
struct FLevelLocals
{
void *level;
void *Level; // bug catchers.
FLevelLocals();
~FLevelLocals();
friend class MapLoader;
void Tick();
void Mark();
void AddScroller(int secnum);
void SetInterMusic(const char *nextmap);
void SetMusicVolume(float v);
void ClearLevelData();
void ClearPortals();
bool CheckIfExitIsGood(AActor *self, level_info_t *newmap);
void FormatMapName(FString &mapname, const char *mapnamecolor);
void ClearAllSubsectorLinks();
void TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid = -1);
int TranslateSectorSpecial(int special);
bool IsTIDUsed(int tid);
int FindUniqueTID(int start_tid, int limit);
int GetConversation(int conv_id);
int GetConversation(FName classname);
void SetConversation(int convid, PClassActor *Class, int dlgindex);
int FindNode (const FStrifeDialogueNode *node);
int GetInfighting();
void SetCompatLineOnSide(bool state);
void Init();
private:
line_t *FindPortalDestination(line_t *src, int tag);
void BuildPortalBlockmap();
void UpdatePortal(FLinePortal *port);
void CollectLinkedPortals();
void CreateLinkedPortals();
bool ChangePortalLine(line_t *line, int destid);
void AddDisplacementForPortal(FSectorPortal *portal);
void AddDisplacementForPortal(FLinePortal *portal);
bool ConnectPortalGroups();
public:
void SnapshotLevel();
void UnSnapshotLevel(bool hubLoad);
void FinalizePortals();
bool ChangePortal(line_t *ln, int thisid, int destid);
unsigned GetSkyboxPortal(AActor *actor);
unsigned GetPortal(int type, int plane, sector_t *orgsec, sector_t *destsec, const DVector2 &displacement);
unsigned GetStackPortal(AActor *point, int plane);
DVector2 GetPortalOffsetPosition(double x, double y, double dx, double dy);
bool CollectConnectedGroups(int startgroup, const DVector3 &position, double upperz, double checkradius, FPortalGroupArray &out);
void ActivateInStasisPlat(int tag);
bool CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag, double speed, double speed2, double height, int crush, int silent, int change, DCeiling::ECrushMode hexencrush);
void ActivateInStasisCeiling(int tag);
bool CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line, double speed, double height, int crush, int change, bool hexencrush, bool hereticlower);
void DoDeferedScripts();
void AdjustPusher(int tag, int magnitude, int angle, bool wind);
int Massacre(bool baddies = false, FName cls = NAME_None);
AActor *SpawnMapThing(FMapThing *mthing, int position);
AActor *SpawnMapThing(int index, FMapThing *mt, int position);
AActor *SpawnPlayer(FPlayerStart *mthing, int playernum, int flags = 0);
void StartLightning();
void ForceLightning(int mode);
void ClearDynamic3DFloorData();
void WorldDone(void);
void AirControlChanged();
AActor *SelectTeleDest(int tid, int tag, bool norandom);
bool AlignFlat(int linenum, int side, int fc);
void ReplaceTextures(const char *fromname, const char *toname, int flags);
bool EV_Thing_Spawn(int tid, AActor *source, int type, DAngle angle, bool fog, int newtid);
bool EV_Thing_Move(int tid, AActor *source, int mapspot, bool fog);
bool EV_Thing_Projectile(int tid, AActor *source, int type, const char *type_name, DAngle angle,
double speed, double vspeed, int dest, AActor *forcedest, int gravity, int newtid, bool leadTarget);
int EV_Thing_Damage(int tid, AActor *whofor0, int amount, FName type);
bool EV_DoPlat(int tag, line_t *line, DPlat::EPlatType type, double height, double speed, int delay, int lip, int change);
void EV_StopPlat(int tag, bool remove);
bool EV_DoPillar(DPillar::EPillar type, line_t *line, int tag, double speed, double height, double height2, int crush, bool hexencrush);
bool EV_DoDoor(DDoor::EVlDoor type, line_t *line, AActor *thing, int tag, double speed, int delay, int lock, int lightTag, bool boomgen = false, int topcountdown = 0);
bool EV_SlidingDoor(line_t *line, AActor *thing, int tag, int speed, int delay, DAnimatedDoor::EADType type);
bool EV_DoCeiling(DCeiling::ECeiling type, line_t *line, int tag, double speed, double speed2, double height, int crush, int silent, int change, DCeiling::ECrushMode hexencrush = DCeiling::ECrushMode::crushDoom);
bool EV_CeilingCrushStop(int tag, bool remove);
bool EV_StopCeiling(int tag, line_t *line);
bool EV_BuildStairs(int tag, DFloor::EStair type, line_t *line, double stairsize, double speed, int delay, int reset, int igntxt, int usespecials);
bool EV_DoFloor(DFloor::EFloor floortype, line_t *line, int tag, double speed, double height, int crush, int change, bool hexencrush, bool hereticlower = false);
bool EV_FloorCrushStop(int tag, line_t *line);
bool EV_StopFloor(int tag, line_t *line);
bool EV_DoDonut(int tag, line_t *line, double pillarspeed, double slimespeed);
bool EV_DoElevator(line_t *line, DElevator::EElevator type, double speed, double height, int tag);
bool EV_StartWaggle(int tag, line_t *line, int height, int speed, int offset, int timer, bool ceiling);
bool EV_DoChange(line_t *line, EChange changetype, int tag);
void EV_StartLightFlickering(int tag, int upper, int lower);
void EV_StartLightStrobing(int tag, int upper, int lower, int utics, int ltics);
void EV_StartLightStrobing(int tag, int utics, int ltics);
void EV_TurnTagLightsOff(int tag);
void EV_LightTurnOn(int tag, int bright);
void EV_LightTurnOnPartway(int tag, double frac);
void EV_LightChange(int tag, int value);
void EV_StartLightGlowing(int tag, int upper, int lower, int tics);
void EV_StartLightFading(int tag, int value, int tics);
void EV_StopLightEffect(int tag);
bool EV_Teleport(int tid, int tag, line_t *line, int side, AActor *thing, int flags);
bool EV_SilentLineTeleport(line_t *line, int side, AActor *thing, int id, INTBOOL reverse);
bool EV_TeleportOther(int other_tid, int dest_tid, bool fog);
bool EV_TeleportGroup(int group_tid, AActor *victim, int source_tid, int dest_tid, bool moveSource, bool fog);
bool EV_TeleportSector(int tag, int source_tid, int dest_tid, bool fog, int group_tid);
void RecalculateDrawnSubsectors();
FSerializer &SerializeSubsectors(FSerializer &arc, const char *key);
void SpawnExtraPlayers();
void Serialize(FSerializer &arc, bool hubload);
DThinker *FirstThinker (int statnum);
// g_Game
void PlayerReborn (int player);
bool CheckSpot (int playernum, FPlayerStart *mthing);
void DoReborn (int playernum, bool freshbot);
void QueueBody (AActor *body);
double PlayersRangeFromSpot (FPlayerStart *spot);
FPlayerStart *SelectFarthestDeathmatchSpot (size_t selections);
FPlayerStart *SelectRandomDeathmatchSpot (int playernum, unsigned int selections);
void DeathMatchSpawnPlayer (int playernum);
FPlayerStart *PickPlayerStart(int playernum, int flags = 0);
bool DoCompleted(FString nextlevel, wbstartstruct_t &wminfo);
void StartTravel();
int FinishTravel();
void ChangeLevel(const char *levelname, int position, int flags, int nextSkill = -1);
const char *GetSecretExitMap();
void ExitLevel(int position, bool keepFacing);
void SecretExitLevel(int position);
void DoLoadLevel(const FString &nextmapname, int position, bool autosave, bool newGame);
void DeleteAllAttachedLights();
void RecreateAllAttachedLights();
private:
// Work data for CollectConnectedGroups.
FPortalBits processMask;
TArray<FLinePortal*> foundPortals;
TArray<int> groupsToCheck;
public:
FSectorTagIterator GetSectorTagIterator(int tag)
{
return FSectorTagIterator(tagManager, tag);
}
FSectorTagIterator GetSectorTagIterator(int tag, line_t *line)
{
return FSectorTagIterator(tagManager, tag, line);
}
FLineIdIterator GetLineIdIterator(int tag)
{
return FLineIdIterator(tagManager, tag);
}
template<class T> TThinkerIterator<T> GetThinkerIterator(FName subtype = NAME_None, int statnum = MAX_STATNUM+1)
{
if (subtype == NAME_None) return TThinkerIterator<T>(this, statnum);
else return TThinkerIterator<T>(this, subtype, statnum);
}
template<class T> TThinkerIterator<T> GetThinkerIterator(FName subtype, int statnum, AActor *prev)
{
return TThinkerIterator<T>(this, subtype, statnum, prev);
}
FActorIterator GetActorIterator(int tid)
{
return FActorIterator(TIDHash, tid);
}
FActorIterator GetActorIterator(int tid, AActor *start)
{
return FActorIterator(TIDHash, tid, start);
}
NActorIterator GetActorIterator(FName type, int tid)
{
return NActorIterator(TIDHash, type, tid);
}
AActor *SingleActorFromTID(int tid, AActor *defactor)
{
return tid == 0 ? defactor : GetActorIterator(tid).Next();
}
bool SectorHasTags(sector_t *sector)
{
return tagManager.SectorHasTags(sector);
}
bool SectorHasTag(sector_t *sector, int tag)
{
return tagManager.SectorHasTag(sector, tag);
}
bool SectorHasTag(int sector, int tag)
{
return tagManager.SectorHasTag(sector, tag);
}
int GetFirstSectorTag(const sector_t *sect) const
{
return tagManager.GetFirstSectorTag(sect);
}
int GetFirstSectorTag(int i) const
{
return tagManager.GetFirstSectorTag(i);
}
int GetFirstLineId(const line_t *sect) const
{
return tagManager.GetFirstLineID(sect);
}
bool LineHasId(int line, int tag)
{
return tagManager.LineHasID(line, tag);
}
bool LineHasId(line_t *line, int tag)
{
return tagManager.LineHasID(line, tag);
}
int FindFirstSectorFromTag(int tag)
{
auto it = GetSectorTagIterator(tag);
return it.Next();
}
int FindFirstLineFromID(int tag)
{
auto it = GetLineIdIterator(tag);
return it.Next();
}
int isFrozen()
{
return frozenstate;
}
private: // The engine should never ever access subsectors of the game nodes. This is only needed for actually implementing PointInSector.
subsector_t *PointInSubsector(double x, double y);
public:
sector_t *PointInSectorBuggy(double x, double y);
subsector_t *PointInRenderSubsector (fixed_t x, fixed_t y);
sector_t *PointInSector(const DVector2 &pos)
{
return PointInSubsector(pos.X, pos.Y)->sector;
}
sector_t *PointInSector(double x, double y)
{
return PointInSubsector(x, y)->sector;
}
subsector_t *PointInRenderSubsector (const DVector2 &pos)
{
return PointInRenderSubsector(FloatToFixed(pos.X), FloatToFixed(pos.Y));
}
FPolyObj *GetPolyobj (int polyNum)
{
auto index = Polyobjects.FindEx([=](const auto &poly) { return poly.tag == polyNum; });
return index == Polyobjects.Size()? nullptr : &Polyobjects[index];
}
void ClearTIDHashes ()
{
memset(TIDHash, 0, sizeof(TIDHash));
}
bool CheckReject(sector_t *s1, sector_t *s2)
{
if (rejectmatrix.Size() > 0)
{
int pnum = int(s1->Index()) * sectors.Size() + int(s2->Index());
return !(rejectmatrix[pnum >> 3] & (1 << (pnum & 7)));
}
return true;
}
DThinker *CreateThinker(PClass *cls, int statnum = STAT_DEFAULT)
{
DThinker *thinker = static_cast<DThinker*>(cls->CreateNew());
assert(thinker->IsKindOf(RUNTIME_CLASS(DThinker)));
thinker->ObjectFlags |= OF_JustSpawned;
Thinkers.Link(thinker, statnum);
thinker->Level = this;
return thinker;
}
template<typename T, typename... Args>
T* CreateThinker(Args&&... args)
{
auto thinker = static_cast<T*>(CreateThinker(RUNTIME_CLASS(T), T::DEFAULT_STAT));
thinker->Construct(std::forward<Args>(args)...);
return thinker;
}
void SetMusic()
{
if (cdtrack == 0 || !S_ChangeCDMusic(cdtrack, cdid))
S_ChangeMusic(Music, musicorder);
}
TArray<vertex_t> vertexes;
TArray<sector_t> sectors;
TArray<line_t*> linebuffer; // contains the line lists for the sectors.
TArray<subsector_t*> subsectorbuffer; // contains the subsector lists for the sectors.
TArray<line_t> lines;
TArray<side_t> sides;
TArray<seg_t *> segbuffer; // contains the seg links for the sidedefs.
TArray<seg_t> segs;
TArray<subsector_t> subsectors;
TArray<node_t> nodes;
TArray<subsector_t> gamesubsectors;
TArray<node_t> gamenodes;
node_t *headgamenode;
TArray<uint8_t> rejectmatrix;
TArray<zone_t> Zones;
TArray<FPolyObj> Polyobjects;
TArray<FSectorPortal> sectorPortals;
TArray<FLinePortal> linePortals;
// Portal information.
FDisplacementTable Displacements;
FPortalBlockmap PortalBlockmap;
TArray<FLinePortal*> linkedPortals; // only the linked portals, this is used to speed up looking for them in P_CollectConnectedGroups.
TArray<FSectorPortalGroup *> portalGroups;
TArray<FLinePortalSpan> linePortalSpans;
FSectionContainer sections;
FCanvasTextureInfo canvasTextureInfo;
EventManager *localEventManager = nullptr;
// [ZZ] Destructible geometry information
TMap<int, FHealthGroup> healthGroups;
FBlockmap blockmap;
TArray<polyblock_t *> PolyBlockMap;
FUDMFKeyMap UDMFKeys[4];
// These are copies of the loaded map data that get used by the savegame code to skip unaltered fields
// Without such a mechanism the savegame format would become too slow and large because more than 80-90% are normally still unaltered.
TArray<sector_t> loadsectors;
TArray<line_t> loadlines;
TArray<side_t> loadsides;
// Maintain single and multi player starting spots.
TArray<FPlayerStart> deathmatchstarts;
FPlayerStart playerstarts[MAXPLAYERS];
TArray<FPlayerStart> AllPlayerStarts;
FBehaviorContainer Behaviors;
AActor *TIDHash[128];
TArray<FStrifeDialogueNode *> StrifeDialogues;
FDialogueIDMap DialogueRoots;
FDialogueMap ClassRoots;
FCajunMaster BotInfo;
int ii_compatflags = 0;
int ii_compatflags2 = 0;
int ib_compatflags = 0;
int i_compatflags = 0;
int i_compatflags2 = 0;
DSectorMarker *SectorMarker;
uint8_t md5[16]; // for savegame validation. If the MD5 does not match the savegame won't be loaded.
int time; // time in the hub
int maptime; // time in the map
int totaltime; // time in the game
int starttime;
int partime;
int sucktime;
uint32_t spawnindex;
level_info_t *info;
int cluster;
int clusterflags;
int levelnum;
int lumpnum;
FString LevelName;
FString MapName; // the lump name (E1M1, MAP01, etc)
FString NextMap; // go here when using the regular exit
FString NextSecretMap; // map to go to when used secret exit
FString F1Pic;
FTranslator *Translator;
EMapType maptype;
FTagManager tagManager;
FInterpolator interpolator;
uint64_t ShaderStartTime = 0; // tell the shader system when we started the level (forces a timer restart)
static const int BODYQUESIZE = 32;
TObjPtr<AActor*> bodyque[BODYQUESIZE];
TObjPtr<DAutomapBase*> automap = nullptr;
int bodyqueslot;
// For now this merely points to the global player array, but with this in place, access to this array can be moved over to the level.
// As things progress each level needs to be able to point to different players, even if they are just null if the second level is merely a skybox or camera target.
// But even if it got a real player, the level will not own it - the player merely links to the level.
// This should also be made a real object eventually.
player_t *Players[MAXPLAYERS];
// This is to allow refactoring without refactoring the data right away.
bool PlayerInGame(int pnum)
{
return playeringame[pnum];
}
// This needs to be done better, but for now it should be good enough.
bool PlayerInGame(player_t *player)
{
for (int i = 0; i < MAXPLAYERS; i++)
{
if (player == Players[i]) return PlayerInGame(i);
}
return false;
}
int PlayerNum(player_t *player)
{
for (int i = 0; i < MAXPLAYERS; i++)
{
if (player == Players[i]) return i;
}
return -1;
}
bool isPrimaryLevel() const
{
return true;
}
// Gets the console player without having the calling code be aware of the level's state.
player_t *GetConsolePlayer() const
{
return isPrimaryLevel()? Players[consoleplayer] : nullptr;
}
bool isConsolePlayer(AActor *mo) const
{
auto p = GetConsolePlayer();
if (!p) return false;
return p->mo == mo;
}
bool isCamera(AActor *mo) const
{
auto p = GetConsolePlayer();
if (!p) return false;
return p->camera == mo;
}
int NumMapSections;
uint32_t flags;
uint32_t flags2;
uint32_t flags3;
uint32_t fadeto; // The color the palette fades to (usually black)
uint32_t outsidefog; // The fog for sectors with sky ceilings
uint32_t hazardcolor; // what color strife hazard blends the screen color as
uint32_t hazardflash; // what color strife hazard flashes the screen color as
FString Music;
int musicorder;
int cdtrack;
unsigned int cdid;
FTextureID skytexture1;
FTextureID skytexture2;
float skyspeed1; // Scrolling speed of sky textures, in pixels per ms
float skyspeed2;
double sky1pos, sky2pos;
float hw_sky1pos, hw_sky2pos;
bool skystretch;
int total_secrets;
int found_secrets;
int total_items;
int found_items;
int total_monsters;
int killed_monsters;
double gravity;
double aircontrol;
double airfriction;
int airsupply;
int DefaultEnvironment; // Default sound environment.
DSeqNode *SequenceListHead;
// [RH] particle globals
uint32_t ActiveParticles;
uint32_t InactiveParticles;
TArray<particle_t> Particles;
TArray<uint16_t> ParticlesInSubsec;
FThinkerCollection Thinkers;
TArray<DVector2> Scrolls; // NULL if no DScrollers in this level
int8_t WallVertLight; // Light diffs for vert/horiz walls
int8_t WallHorizLight;
bool FromSnapshot; // The current map was restored from a snapshot
bool HasHeightSecs; // true if some Transfer_Heights effects are present in the map. If this is false, some checks in the renderer can be shortcut.
bool HasDynamicLights; // Another render optimization for maps with no lights at all.
int frozenstate;
double teamdamage;
// former OpenGL-exclusive properties that should also be usable by the true color software renderer.
int fogdensity;
int outsidefogdensity;
int skyfog;
FName deathsequence;
float pixelstretch;
float MusicVolume;
// Hardware render stuff that can either be set via CVAR or MAPINFO
ELightMode lightMode;
bool brightfog;
bool lightadditivesurfaces;
bool notexturefill;
int ImpactDecalCount;
FDynamicLight *lights;
// links to global game objects
TArray<TObjPtr<AActor *>> CorpseQueue;
TObjPtr<DFraggleThinker *> FraggleScriptThinker = nullptr;
TObjPtr<DACSThinker*> ACSThinker = nullptr;
TObjPtr<DSpotState *> SpotState = nullptr;
bool IsJumpingAllowed() const;
bool IsCrouchingAllowed() const;
bool IsFreelookAllowed() const;
node_t *HeadNode() const
{
return nodes.Size() == 0 ? nullptr : &nodes[nodes.Size() - 1];
}
node_t *HeadGamenode() const
{
return headgamenode;
}
// Returns true if level is loaded from saved game or is being revisited as a part of a hub
bool IsReentering() const
{
return savegamerestore
|| (info != nullptr && info->Snapshot.mBuffer != nullptr && info->isValid());
}
};
extern FLevelLocals level;
extern FLevelLocals *primaryLevel; // level for which to display the user interface. This will always be the one the current consoleplayer is in.
extern FLevelLocals *currentVMLevel;
inline FSectorPortal *line_t::GetTransferredPortal()
{
auto Level = GetLevel();
return portaltransferred >= Level->sectorPortals.Size() ? (FSectorPortal*)nullptr : &Level->sectorPortals[portaltransferred];
}
inline FSectorPortal *sector_t::GetPortal(int plane)
{
return &Level->sectorPortals[Portals[plane]];
}
inline double sector_t::GetPortalPlaneZ(int plane)
{
return Level->sectorPortals[Portals[plane]].mPlaneZ;
}
inline DVector2 sector_t::GetPortalDisplacement(int plane)
{
return Level->sectorPortals[Portals[plane]].mDisplacement;
}
inline int sector_t::GetPortalType(int plane)
{
return Level->sectorPortals[Portals[plane]].mType;
}
inline int sector_t::GetOppositePortalGroup(int plane)
{
return Level->sectorPortals[Portals[plane]].mDestination->PortalGroup;
}
inline bool sector_t::PortalBlocksView(int plane)
{
if (GetPortalType(plane) != PORTS_LINKEDPORTAL) return false;
return !!(planes[plane].Flags & (PLANEF_NORENDER | PLANEF_DISABLED | PLANEF_OBSTRUCTED));
}
inline bool sector_t::PortalBlocksSight(int plane)
{
return PLANEF_LINKED != (planes[plane].Flags & (PLANEF_NORENDER | PLANEF_NOPASS | PLANEF_DISABLED | PLANEF_OBSTRUCTED | PLANEF_LINKED));
}
inline bool sector_t::PortalBlocksMovement(int plane)
{
return PLANEF_LINKED != (planes[plane].Flags & (PLANEF_NOPASS | PLANEF_DISABLED | PLANEF_OBSTRUCTED | PLANEF_LINKED));
}
inline bool sector_t::PortalBlocksSound(int plane)
{
return PLANEF_LINKED != (planes[plane].Flags & (PLANEF_BLOCKSOUND | PLANEF_DISABLED | PLANEF_OBSTRUCTED | PLANEF_LINKED));
}
inline bool sector_t::PortalIsLinked(int plane)
{
return (GetPortalType(plane) == PORTS_LINKEDPORTAL);
}
inline FLevelLocals *line_t::GetLevel() const
{
return frontsector->Level;
}
inline FLinePortal *line_t::getPortal() const
{
return portalindex >= GetLevel()->linePortals.Size() ? (FLinePortal*)nullptr : &GetLevel()->linePortals[portalindex];
}
// returns true if the portal is crossable by actors
inline bool line_t::isLinePortal() const
{
return portalindex >= GetLevel()->linePortals.Size() ? false : !!(GetLevel()->linePortals[portalindex].mFlags & PORTF_PASSABLE);
}
// returns true if the portal needs to be handled by the renderer
inline bool line_t::isVisualPortal() const
{
return portalindex >= GetLevel()->linePortals.Size() ? false : !!(GetLevel()->linePortals[portalindex].mFlags & PORTF_VISIBLE);
}
inline line_t *line_t::getPortalDestination() const
{
return portalindex >= GetLevel()->linePortals.Size() ? (line_t*)nullptr : GetLevel()->linePortals[portalindex].mDestination;
}
inline int line_t::getPortalAlignment() const
{
return portalindex >= GetLevel()->linePortals.Size() ? 0 : GetLevel()->linePortals[portalindex].mAlign;
}
inline bool line_t::hitSkyWall(AActor* mo) const
{
return backsector &&
backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
mo->Z() >= backsector->ceilingplane.ZatPoint(mo->PosRelative(this));
}
// This must later be extended to return an array with all levels.
// It is meant for code that needs to iterate over all levels to make some global changes, e.g. configuation CCMDs.
inline TArrayView<FLevelLocals *> AllLevels()
{
return TArrayView<FLevelLocals *>(&primaryLevel, 1);
}