mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- split up P_FreeLevelData, so that everything that clears out fields in FLevelLocals is now in a member function of that class.
This commit is contained in:
parent
c45e1cbbf0
commit
3f8d565dbb
4 changed files with 110 additions and 97 deletions
|
@ -105,6 +105,8 @@ struct FLevelLocals : public FLevelData
|
|||
void AddScroller(int secnum);
|
||||
void SetInterMusic(const char *nextmap);
|
||||
void SetMusicVolume(float v);
|
||||
void ClearLevelData();
|
||||
void ClearPortals();
|
||||
|
||||
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
|
||||
|
|
161
src/p_setup.cpp
161
src/p_setup.cpp
|
@ -207,6 +207,113 @@ static void PrecacheLevel(FLevelLocals *Level)
|
|||
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// clears all portal data for a new level start
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
void FLevelLocals::ClearPortals()
|
||||
{
|
||||
Displacements.Create(1);
|
||||
linePortals.Clear();
|
||||
linkedPortals.Clear();
|
||||
sectorPortals.Resize(2);
|
||||
PortalBlockmap.Clear();
|
||||
|
||||
// The first entry must always be the default skybox. This is what every sector gets by default.
|
||||
memset(§orPortals[0], 0, sizeof(sectorPortals[0]));
|
||||
sectorPortals[0].mType = PORTS_SKYVIEWPOINT;
|
||||
sectorPortals[0].mFlags = PORTSF_SKYFLATONLY;
|
||||
// The second entry will be the default sky. This is for forcing a regular sky through the skybox picker
|
||||
memset(§orPortals[1], 0, sizeof(sectorPortals[0]));
|
||||
sectorPortals[1].mType = PORTS_SKYVIEWPOINT;
|
||||
sectorPortals[1].mFlags = PORTSF_SKYFLATONLY;
|
||||
|
||||
// also clear the render data
|
||||
for (auto &sub : subsectors)
|
||||
{
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
if (sub.portalcoverage[j].subsectors != nullptr)
|
||||
{
|
||||
delete[] sub.portalcoverage[j].subsectors;
|
||||
sub.portalcoverage[j].subsectors = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (unsigned i = 0; i < portalGroups.Size(); i++)
|
||||
{
|
||||
delete portalGroups[i];
|
||||
}
|
||||
portalGroups.Clear();
|
||||
linePortalSpans.Clear();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FLevelLocals::ClearLevelData()
|
||||
{
|
||||
total_monsters = total_items = total_secrets =
|
||||
killed_monsters = found_items = found_secrets =
|
||||
wminfo.maxfrags = 0;
|
||||
|
||||
// delete allocated data in the level arrays.
|
||||
if (sectors.Size() > 0)
|
||||
{
|
||||
delete[] sectors[0].e;
|
||||
}
|
||||
for (auto &sub : subsectors)
|
||||
{
|
||||
if (sub.BSP != nullptr) delete sub.BSP;
|
||||
}
|
||||
ClearPortals();
|
||||
|
||||
canvasTextureInfo.EmptyList();
|
||||
sections.Clear();
|
||||
segs.Clear();
|
||||
sectors.Clear();
|
||||
linebuffer.Clear();
|
||||
subsectorbuffer.Clear();
|
||||
lines.Clear();
|
||||
sides.Clear();
|
||||
segbuffer.Clear();
|
||||
loadsectors.Clear();
|
||||
loadlines.Clear();
|
||||
loadsides.Clear();
|
||||
vertexes.Clear();
|
||||
nodes.Clear();
|
||||
gamenodes.Reset();
|
||||
subsectors.Clear();
|
||||
gamesubsectors.Reset();
|
||||
rejectmatrix.Clear();
|
||||
Zones.Clear();
|
||||
blockmap.Clear();
|
||||
Polyobjects.Clear();
|
||||
|
||||
for (auto &pb : PolyBlockMap)
|
||||
{
|
||||
polyblock_t *link = pb;
|
||||
while (link != nullptr)
|
||||
{
|
||||
polyblock_t *next = link->next;
|
||||
delete link;
|
||||
link = next;
|
||||
}
|
||||
}
|
||||
PolyBlockMap.Reset();
|
||||
|
||||
deathmatchstarts.Clear();
|
||||
AllPlayerStarts.Clear();
|
||||
memset(playerstarts, 0, sizeof(playerstarts));
|
||||
Scrolls.Clear();
|
||||
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -236,64 +343,12 @@ void P_FreeLevelData ()
|
|||
FPolyObj::ClearAllSubsectorLinks(); // can't be done as part of the polyobj deletion process.
|
||||
SN_StopAllSequences ();
|
||||
DThinker::DestroyAllThinkers ();
|
||||
P_ClearPortals();
|
||||
tagManager.Clear();
|
||||
level.total_monsters = level.total_items = level.total_secrets =
|
||||
level.killed_monsters = level.found_items = level.found_secrets =
|
||||
wminfo.maxfrags = 0;
|
||||
|
||||
// delete allocated data in the level arrays.
|
||||
if (level.sectors.Size() > 0)
|
||||
{
|
||||
delete[] level.sectors[0].e;
|
||||
}
|
||||
for (auto &sub : level.subsectors)
|
||||
{
|
||||
if (sub.BSP != nullptr) delete sub.BSP;
|
||||
}
|
||||
|
||||
FBehavior::StaticUnloadModules ();
|
||||
level.canvasTextureInfo.EmptyList();
|
||||
level.sections.Clear();
|
||||
level.segs.Clear();
|
||||
level.sectors.Clear();
|
||||
level.linebuffer.Clear();
|
||||
level.subsectorbuffer.Clear();
|
||||
level.lines.Clear();
|
||||
level.sides.Clear();
|
||||
level.segbuffer.Clear();
|
||||
level.loadsectors.Clear();
|
||||
level.loadlines.Clear();
|
||||
level.loadsides.Clear();
|
||||
level.vertexes.Clear();
|
||||
level.nodes.Clear();
|
||||
level.gamenodes.Reset();
|
||||
level.subsectors.Clear();
|
||||
level.gamesubsectors.Reset();
|
||||
level.rejectmatrix.Clear();
|
||||
level.Zones.Clear();
|
||||
level.blockmap.Clear();
|
||||
level.Polyobjects.Clear();
|
||||
|
||||
for(auto &pb : level.PolyBlockMap)
|
||||
{
|
||||
polyblock_t *link = pb;
|
||||
while (link != nullptr)
|
||||
{
|
||||
polyblock_t *next = link->next;
|
||||
delete link;
|
||||
link = next;
|
||||
}
|
||||
}
|
||||
level.PolyBlockMap.Reset();
|
||||
|
||||
level.deathmatchstarts.Clear();
|
||||
level.AllPlayerStarts.Clear();
|
||||
memset(level.playerstarts, 0, sizeof(level.playerstarts));
|
||||
|
||||
P_FreeStrifeConversations ();
|
||||
level.Scrolls.Clear();
|
||||
P_ClearUDMFKeys();
|
||||
level.ClearLevelData();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -492,49 +492,6 @@ bool P_ChangePortal(line_t *ln, int thisid, int destid)
|
|||
return res;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// clears all portal data for a new level start
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
void P_ClearPortals()
|
||||
{
|
||||
level.Displacements.Create(1);
|
||||
level.linePortals.Clear();
|
||||
level.linkedPortals.Clear();
|
||||
level.sectorPortals.Resize(2);
|
||||
level.PortalBlockmap.Clear();
|
||||
|
||||
// The first entry must always be the default skybox. This is what every sector gets by default.
|
||||
memset(&level.sectorPortals[0], 0, sizeof(level.sectorPortals[0]));
|
||||
level.sectorPortals[0].mType = PORTS_SKYVIEWPOINT;
|
||||
level.sectorPortals[0].mFlags = PORTSF_SKYFLATONLY;
|
||||
// The second entry will be the default sky. This is for forcing a regular sky through the skybox picker
|
||||
memset(&level.sectorPortals[1], 0, sizeof(level.sectorPortals[0]));
|
||||
level.sectorPortals[1].mType = PORTS_SKYVIEWPOINT;
|
||||
level.sectorPortals[1].mFlags = PORTSF_SKYFLATONLY;
|
||||
|
||||
// also clear the render data
|
||||
for (auto &sub : level.subsectors)
|
||||
{
|
||||
for (int j = 0; j<2; j++)
|
||||
{
|
||||
if (sub.portalcoverage[j].subsectors != nullptr)
|
||||
{
|
||||
delete[] sub.portalcoverage[j].subsectors;
|
||||
sub.portalcoverage[j].subsectors = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (unsigned i = 0; i<level.portalGroups.Size(); i++)
|
||||
{
|
||||
delete level.portalGroups[i];
|
||||
}
|
||||
level.portalGroups.Clear();
|
||||
level.linePortalSpans.Clear();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// check if this line is between portal and the viewer. clip away if it is.
|
||||
|
|
|
@ -263,7 +263,6 @@ struct FSectorPortalGroup
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
void P_ClearPortals();
|
||||
void P_SpawnLinePortal(line_t* line);
|
||||
void P_FinalizePortals();
|
||||
bool P_ChangePortal(line_t *ln, int thisid, int destid);
|
||||
|
|
Loading…
Reference in a new issue