Clear references to map data on level change
These shouldn't be left as they'll now point towards potentially invalid memory and also cause errors with serializing. Arrays and maps holding them are cleared. Also unlinks and relinks inventory items correctly from the hashmap on traveling.
This commit is contained in:
parent
29b2253bdb
commit
269689703d
6 changed files with 87 additions and 3 deletions
|
|
@ -293,9 +293,16 @@ void FLevelLocals::ClearLevelData(bool fullgc)
|
|||
auto it = GetThinkerIterator<AActor>(NAME_None, STAT_TRAVELLING);
|
||||
for (AActor *actor = it.Next(); actor != nullptr; actor = it.Next())
|
||||
{
|
||||
actor->BlockingMobj = nullptr;
|
||||
actor->BlockingLine = actor->MovementBlockingLine = nullptr;
|
||||
actor->BlockingFloor = actor->BlockingCeiling = actor->Blocking3DFloor = nullptr;
|
||||
}
|
||||
|
||||
// Make sure map data gets cleared appropriately so any leftover Objects aren't pointing
|
||||
// towards anything invalid.
|
||||
TArray<FName> fieldTypes = { NAME_SectorPortal, NAME_LinePortal, NAME_Vertex, NAME_Side, NAME_Line, NAME_SecPlane, NAME_F3DFloor, NAME_Sector };
|
||||
for (DObject* probe = GC::Root; probe != nullptr; probe = probe->ObjNext)
|
||||
probe->ClearNativePointerFields(fieldTypes);
|
||||
}
|
||||
|
||||
interpolator.ClearInterpolations(); // [RH] Nothing to interpolate on a fresh level.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue